From b548d75606ea90cc6f2981ef07a3a2f754f64cd9 Mon Sep 17 00:00:00 2001 From: Packit Service Date: Dec 09 2020 08:17:44 +0000 Subject: bash-4.4.19 base --- diff --git a/ABOUT-NLS b/ABOUT-NLS new file mode 100644 index 0000000..47d5e39 --- /dev/null +++ b/ABOUT-NLS @@ -0,0 +1,625 @@ +Notes on the Free Translation Project +************************************* + + Free software is going international! The Free Translation Project +is a way to get maintainers of free software, translators, and users all +together, so that will gradually become able to speak many languages. +A few packages already provide translations for their messages. + + If you found this `ABOUT-NLS' file inside a distribution, you may +assume that the distributed package does use GNU `gettext' internally, +itself available at your nearest GNU archive site. But you do _not_ +need to install GNU `gettext' prior to configuring, installing or using +this package with messages translated. + + Installers will find here some useful hints. These notes also +explain how users should proceed for getting the programs to use the +available translations. They tell how people wanting to contribute and +work at translations should contact the appropriate team. + + When reporting bugs in the `intl/' directory or bugs which may be +related to internationalization, you should tell about the version of +`gettext' which is used. The information can be found in the +`intl/VERSION' file, in internationalized packages. + +Quick configuration advice +========================== + + If you want to exploit the full power of internationalization, you +should configure it using + + ./configure --with-included-gettext + +to force usage of internationalizing routines provided within this +package, despite the existence of internationalizing capabilities in the +operating system where this package is being installed. So far, only +the `gettext' implementation in the GNU C library version 2 provides as +many features (such as locale alias, message inheritance, automatic +charset conversion or plural form handling) as the implementation here. +It is also not possible to offer this additional functionality on top +of a `catgets' implementation. Future versions of GNU `gettext' will +very likely convey even more functionality. So it might be a good idea +to change to GNU `gettext' as soon as possible. + + So you need _not_ provide this option if you are using GNU libc 2 or +you have installed a recent copy of the GNU gettext package with the +included `libintl'. + +INSTALL Matters +=============== + + Some packages are "localizable" when properly installed; the +programs they contain can be made to speak your own native language. +Most such packages use GNU `gettext'. Other packages have their own +ways to internationalization, predating GNU `gettext'. + + By default, this package will be installed to allow translation of +messages. It will automatically detect whether the system already +provides the GNU `gettext' functions. If not, the GNU `gettext' own +library will be used. This library is wholly contained within this +package, usually in the `intl/' subdirectory, so prior installation of +the GNU `gettext' package is _not_ required. Installers may use +special options at configuration time for changing the default +behaviour. The commands: + + ./configure --with-included-gettext + ./configure --disable-nls + +will respectively bypass any pre-existing `gettext' to use the +internationalizing routines provided within this package, or else, +_totally_ disable translation of messages. + + When you already have GNU `gettext' installed on your system and run +configure without an option for your new package, `configure' will +probably detect the previously built and installed `libintl.a' file and +will decide to use this. This might be not what is desirable. You +should use the more recent version of the GNU `gettext' library. I.e. +if the file `intl/VERSION' shows that the library which comes with this +package is more recent, you should use + + ./configure --with-included-gettext + +to prevent auto-detection. + + The configuration process will not test for the `catgets' function +and therefore it will not be used. The reason is that even an +emulation of `gettext' on top of `catgets' could not provide all the +extensions of the GNU `gettext' library. + + Internationalized packages have usually many `po/LL.po' files, where +LL gives an ISO 639 two-letter code identifying the language. Unless +translations have been forbidden at `configure' time by using the +`--disable-nls' switch, all available translations are installed +together with the package. However, the environment variable `LINGUAS' +may be set, prior to configuration, to limit the installed set. +`LINGUAS' should then contain a space separated list of two-letter +codes, stating which languages are allowed. + +Using This Package +================== + + As a user, if your language has been installed for this package, you +only have to set the `LANG' environment variable to the appropriate +`LL_CC' combination. Here `LL' is an ISO 639 two-letter language code, +and `CC' is an ISO 3166 two-letter country code. For example, let's +suppose that you speak German and live in Germany. At the shell +prompt, merely execute `setenv LANG de_DE' (in `csh'), +`export LANG; LANG=de_DE' (in `sh') or `export LANG=de_DE' (in `bash'). +This can be done from your `.login' or `.profile' file, once and for +all. + + You might think that the country code specification is redundant. +But in fact, some languages have dialects in different countries. For +example, `de_AT' is used for Austria, and `pt_BR' for Brazil. The +country code serves to distinguish the dialects. + + The locale naming convention of `LL_CC', with `LL' denoting the +language and `CC' denoting the country, is the one use on systems based +on GNU libc. On other systems, some variations of this scheme are +used, such as `LL' or `LL_CC.ENCODING'. You can get the list of +locales supported by your system for your country by running the command +`locale -a | grep '^LL''. + + Not all programs have translations for all languages. By default, an +English message is shown in place of a nonexistent translation. If you +understand other languages, you can set up a priority list of languages. +This is done through a different environment variable, called +`LANGUAGE'. GNU `gettext' gives preference to `LANGUAGE' over `LANG' +for the purpose of message handling, but you still need to have `LANG' +set to the primary language; this is required by other parts of the +system libraries. For example, some Swedish users who would rather +read translations in German than English for when Swedish is not +available, set `LANGUAGE' to `sv:de' while leaving `LANG' to `sv_SE'. + + In the `LANGUAGE' environment variable, but not in the `LANG' +environment variable, `LL_CC' combinations can be abbreviated as `LL' +to denote the language's main dialect. For example, `de' is equivalent +to `de_DE' (German as spoken in Germany), and `pt' to `pt_PT' +(Portuguese as spoken in Portugal) in this context. + +Translating Teams +================= + + For the Free Translation Project to be a success, we need interested +people who like their own language and write it well, and who are also +able to synergize with other translators speaking the same language. +Each translation team has its own mailing list. The up-to-date list of +teams can be found at the Free Translation Project's homepage, +`http://www.iro.umontreal.ca/contrib/po/HTML/', in the "National teams" +area. + + If you'd like to volunteer to _work_ at translating messages, you +should become a member of the translating team for your own language. +The subscribing address is _not_ the same as the list itself, it has +`-request' appended. For example, speakers of Swedish can send a +message to `sv-request@li.org', having this message body: + + subscribe + + Keep in mind that team members are expected to participate +_actively_ in translations, or at solving translational difficulties, +rather than merely lurking around. If your team does not exist yet and +you want to start one, or if you are unsure about what to do or how to +get started, please write to `translation@iro.umontreal.ca' to reach the +coordinator for all translator teams. + + The English team is special. It works at improving and uniformizing +the terminology in use. Proven linguistic skill are praised more than +programming skill, here. + +Available Packages +================== + + Languages are not equally supported in all packages. The following +matrix shows the current state of internationalization, as of May 2003. +The matrix shows, in regard of each package, for which languages PO +files have been submitted to translation coordination, with a +translation percentage of at least 50%. + + Ready PO files am az be bg ca cs da de el en en_GB eo es + +-------------------------------------------+ + a2ps | [] [] [] [] | + aegis | () | + anubis | | + ap-utils | | + bash | [] [] [] | + batchelor | | + bfd | [] [] | + binutils | [] [] | + bison | [] [] [] | + bluez-pin | [] [] | + clisp | | + clisp | [] [] [] | + coreutils | [] [] [] [] | + cpio | [] [] [] | + darkstat | () [] | + diffutils | [] [] [] [] [] [] [] | + e2fsprogs | [] [] | + enscript | [] [] [] [] | + error | [] [] [] [] [] | + fetchmail | [] () [] [] [] [] | + fileutils | [] [] [] | + findutils | [] [] [] [] [] [] | + flex | [] [] [] [] | + gas | [] | + gawk | [] [] [] [] | + gcal | [] | + gcc | [] [] | + gettext | [] [] [] [] [] | + gettext-runtime | [] [] [] [] [] | + gettext-tools | [] [] | + gimp-print | [] [] [] [] [] | + gliv | | + glunarclock | [] [] [] | + gnucash | () [] | + gnucash-glossary | [] () [] | + gnupg | [] () [] [] [] [] | + gpe-calendar | [] | + gpe-conf | [] | + gpe-contacts | [] | + gpe-edit | | + gpe-login | [] | + gpe-ownerinfo | [] | + gpe-sketchbook | [] | + gpe-timesheet | | + gpe-today | [] | + gpe-todo | [] | + gphoto2 | [] [] [] [] | + gprof | [] [] | + gpsdrive | () () () | + grep | [] [] [] [] [] | + gretl | [] | + hello | [] [] [] [] [] [] | + id-utils | [] [] | + indent | [] [] [] [] | + jpilot | [] [] [] [] | + jwhois | [] | + kbd | [] [] [] [] [] | + ld | [] [] | + libc | [] [] [] [] [] [] | + libgpewidget | [] | + libiconv | [] [] [] [] [] | + lifelines | [] () | + lilypond | [] | + lingoteach | | + lingoteach_lessons | () () | + lynx | [] [] [] [] | + m4 | [] [] [] [] | + mailutils | [] [] | + make | [] [] [] | + man-db | [] () [] [] () | + mysecretdiary | [] [] [] | + nano | [] () [] [] [] | + nano_1_0 | [] () [] [] [] | + opcodes | [] [] | + parted | [] [] [] [] [] | + ptx | [] [] [] [] [] | + python | | + radius | | + recode | [] [] [] [] [] [] | + screem | | + sed | [] [] [] [] [] | + sh-utils | [] [] [] | + sharutils | [] [] [] [] [] [] | + sketch | [] () [] | + soundtracker | [] [] [] | + sp | [] | + tar | [] [] [] [] | + texinfo | [] [] [] [] | + textutils | [] [] [] [] | + tin | () () | + util-linux | [] [] [] [] [] | + vorbis-tools | [] [] [] | + wastesedge | () | + wdiff | [] [] [] [] | + wget | [] [] [] [] [] [] [] | + xchat | [] [] [] | + xpad | | + +-------------------------------------------+ + am az be bg ca cs da de el en en_GB eo es + 0 1 4 2 31 17 54 60 14 1 4 12 56 + + et fa fi fr ga gl he hr hu id it ja ko + +----------------------------------------+ + a2ps | [] [] [] () () | + aegis | | + anubis | [] | + ap-utils | [] | + bash | [] [] | + batchelor | [] | + bfd | [] [] | + binutils | [] [] | + bison | [] [] [] [] | + bluez-pin | [] [] [] [] | + clisp | | + clisp | [] | + coreutils | [] [] [] [] | + cpio | [] [] [] [] | + darkstat | () [] [] [] | + diffutils | [] [] [] [] [] [] [] | + e2fsprogs | | + enscript | [] [] | + error | [] [] [] [] | + fetchmail | [] | + fileutils | [] [] [] [] [] | + findutils | [] [] [] [] [] [] [] [] [] [] [] | + flex | [] [] | + gas | [] | + gawk | [] [] | + gcal | [] | + gcc | [] | + gettext | [] [] [] | + gettext-runtime | [] [] [] [] | + gettext-tools | [] | + gimp-print | [] [] | + gliv | () | + glunarclock | [] [] [] [] | + gnucash | [] | + gnucash-glossary | [] | + gnupg | [] [] [] [] [] [] [] | + gpe-calendar | [] | + gpe-conf | | + gpe-contacts | [] | + gpe-edit | [] [] | + gpe-login | [] | + gpe-ownerinfo | [] [] [] | + gpe-sketchbook | [] | + gpe-timesheet | [] [] [] | + gpe-today | [] [] | + gpe-todo | [] [] | + gphoto2 | [] [] [] | + gprof | [] [] | + gpsdrive | () [] () () | + grep | [] [] [] [] [] [] [] [] [] [] [] | + gretl | [] | + hello | [] [] [] [] [] [] [] [] [] [] [] [] [] | + id-utils | [] [] [] | + indent | [] [] [] [] [] [] [] [] | + jpilot | [] () | + jwhois | [] [] [] [] | + kbd | [] | + ld | [] | + libc | [] [] [] [] [] [] | + libgpewidget | [] [] [] | + libiconv | [] [] [] [] [] [] [] [] | + lifelines | () | + lilypond | [] | + lingoteach | [] [] | + lingoteach_lessons | | + lynx | [] [] [] [] | + m4 | [] [] [] [] | + mailutils | | + make | [] [] [] [] [] [] | + man-db | [] () () | + mysecretdiary | [] [] | + nano | [] [] [] [] | + nano_1_0 | [] [] [] [] | + opcodes | [] [] | + parted | [] [] [] | + ptx | [] [] [] [] [] [] [] | + python | | + radius | | + recode | [] [] [] [] [] [] | + screem | | + sed | [] [] [] [] [] [] [] [] | + sh-utils | [] [] [] [] [] [] | + sharutils | [] [] [] [] [] | + sketch | [] | + soundtracker | [] [] [] | + sp | [] () | + tar | [] [] [] [] [] [] [] [] [] | + texinfo | [] [] [] [] | + textutils | [] [] [] [] [] | + tin | [] () | + util-linux | [] [] [] [] () [] | + vorbis-tools | [] | + wastesedge | () | + wdiff | [] [] [] [] [] | + wget | [] [] [] [] [] [] [] [] | + xchat | [] [] [] | + xpad | | + +----------------------------------------+ + et fa fi fr ga gl he hr hu id it ja ko + 20 1 15 73 14 24 8 10 30 31 19 31 9 + + lg lt lv ms nb nl nn no pl pt pt_BR ro + +----------------------------------------+ + a2ps | [] [] () () () [] [] | + aegis | () | + anubis | [] [] | + ap-utils | () | + bash | [] | + batchelor | | + bfd | | + binutils | | + bison | [] [] [] [] | + bluez-pin | [] | + clisp | | + clisp | [] | + coreutils | [] | + cpio | [] [] [] | + darkstat | [] [] [] [] | + diffutils | [] [] [] | + e2fsprogs | | + enscript | [] [] | + error | [] [] | + fetchmail | () () | + fileutils | [] | + findutils | [] [] [] [] | + flex | [] | + gas | | + gawk | [] | + gcal | | + gcc | | + gettext | [] | + gettext-runtime | [] | + gettext-tools | | + gimp-print | [] | + gliv | [] | + glunarclock | [] | + gnucash | | + gnucash-glossary | [] [] | + gnupg | | + gpe-calendar | [] [] | + gpe-conf | [] [] | + gpe-contacts | [] | + gpe-edit | [] [] | + gpe-login | [] [] | + gpe-ownerinfo | [] [] | + gpe-sketchbook | [] [] | + gpe-timesheet | [] [] | + gpe-today | [] [] | + gpe-todo | [] [] | + gphoto2 | | + gprof | [] | + gpsdrive | () () () | + grep | [] [] [] [] | + gretl | | + hello | [] [] [] [] [] [] [] [] [] | + id-utils | [] [] [] | + indent | [] [] [] | + jpilot | () () | + jwhois | [] [] [] | + kbd | | + ld | | + libc | [] [] [] [] | + libgpewidget | [] [] | + libiconv | [] [] | + lifelines | | + lilypond | [] | + lingoteach | | + lingoteach_lessons | | + lynx | [] [] | + m4 | [] [] [] [] | + mailutils | | + make | [] [] | + man-db | [] | + mysecretdiary | [] | + nano | [] [] [] [] | + nano_1_0 | [] [] [] [] | + opcodes | [] [] [] | + parted | [] [] [] | + ptx | [] [] [] [] [] [] [] | + python | | + radius | | + recode | [] [] [] | + screem | | + sed | [] [] | + sh-utils | [] | + sharutils | [] | + sketch | [] | + soundtracker | | + sp | | + tar | [] [] [] [] [] [] | + texinfo | [] | + textutils | [] | + tin | | + util-linux | [] [] | + vorbis-tools | [] [] | + wastesedge | | + wdiff | [] [] [] [] | + wget | [] [] [] | + xchat | [] [] | + xpad | [] | + +----------------------------------------+ + lg lt lv ms nb nl nn no pl pt pt_BR ro + 0 0 2 11 7 26 3 4 18 15 34 34 + + ru sk sl sr sv ta tr uk vi wa zh_CN zh_TW + +-------------------------------------------+ + a2ps | [] [] [] [] [] | 16 + aegis | () | 0 + anubis | [] [] | 5 + ap-utils | () | 1 + bash | [] | 7 + batchelor | | 1 + bfd | [] [] [] | 7 + binutils | [] [] [] | 7 + bison | [] [] | 13 + bluez-pin | | 7 + clisp | | 0 + clisp | | 5 + coreutils | [] [] [] [] [] | 14 + cpio | [] [] [] | 13 + darkstat | [] () () | 9 + diffutils | [] [] [] [] | 21 + e2fsprogs | [] | 3 + enscript | [] [] [] | 11 + error | [] [] [] | 14 + fetchmail | [] | 7 + fileutils | [] [] [] [] [] [] | 15 + findutils | [] [] [] [] [] [] | 27 + flex | [] [] [] | 10 + gas | [] | 3 + gawk | [] [] | 9 + gcal | [] [] | 4 + gcc | [] | 4 + gettext | [] [] [] [] [] [] | 15 + gettext-runtime | [] [] [] [] [] [] | 16 + gettext-tools | [] [] | 5 + gimp-print | [] [] | 10 + gliv | | 1 + glunarclock | [] [] [] | 11 + gnucash | [] [] | 4 + gnucash-glossary | [] [] [] | 8 + gnupg | [] [] [] [] | 16 + gpe-calendar | [] | 5 + gpe-conf | | 3 + gpe-contacts | [] | 4 + gpe-edit | [] | 5 + gpe-login | [] | 5 + gpe-ownerinfo | [] | 7 + gpe-sketchbook | [] | 5 + gpe-timesheet | [] | 6 + gpe-today | [] | 6 + gpe-todo | [] | 6 + gphoto2 | [] [] | 9 + gprof | [] [] | 7 + gpsdrive | [] [] | 3 + grep | [] [] [] [] | 24 + gretl | | 2 + hello | [] [] [] [] [] | 33 + id-utils | [] [] [] | 11 + indent | [] [] [] [] | 19 + jpilot | [] [] [] [] [] | 10 + jwhois | () () [] [] | 10 + kbd | [] [] | 8 + ld | [] [] | 5 + libc | [] [] [] [] | 20 + libgpewidget | | 6 + libiconv | [] [] [] [] [] [] | 21 + lifelines | [] | 2 + lilypond | [] | 4 + lingoteach | | 2 + lingoteach_lessons | () | 0 + lynx | [] [] [] [] | 14 + m4 | [] [] [] | 15 + mailutils | | 2 + make | [] [] [] [] | 15 + man-db | [] | 6 + mysecretdiary | [] [] | 8 + nano | [] [] [] | 15 + nano_1_0 | [] [] [] | 15 + opcodes | [] [] | 9 + parted | [] [] | 13 + ptx | [] [] [] | 22 + python | | 0 + radius | | 0 + recode | [] [] [] [] | 19 + screem | [] | 1 + sed | [] [] [] [] [] | 20 + sh-utils | [] [] [] | 13 + sharutils | [] [] [] [] | 16 + sketch | [] | 5 + soundtracker | [] | 7 + sp | [] | 3 + tar | [] [] [] [] [] | 24 + texinfo | [] [] [] [] | 13 + textutils | [] [] [] [] [] | 15 + tin | | 1 + util-linux | [] [] | 14 + vorbis-tools | [] | 7 + wastesedge | | 0 + wdiff | [] [] [] [] | 17 + wget | [] [] [] [] [] [] [] | 25 + xchat | [] [] [] | 11 + xpad | | 1 + +-------------------------------------------+ + 50 teams ru sk sl sr sv ta tr uk vi wa zh_CN zh_TW + 97 domains 32 19 16 0 56 0 48 10 1 1 12 23 913 + + Some counters in the preceding matrix are higher than the number of +visible blocks let us expect. This is because a few extra PO files are +used for implementing regional variants of languages, or language +dialects. + + For a PO file in the matrix above to be effective, the package to +which it applies should also have been internationalized and +distributed as such by its maintainer. There might be an observable +lag between the mere existence a PO file and its wide availability in a +distribution. + + If May 2003 seems to be old, you may fetch a more recent copy of +this `ABOUT-NLS' file on most GNU archive sites. The most up-to-date +matrix with full percentage details can be found at +`http://www.iro.umontreal.ca/contrib/po/HTML/matrix.html'. + +Using `gettext' in new packages +=============================== + + If you are writing a freely available program and want to +internationalize it you are welcome to use GNU `gettext' in your +package. Of course you have to respect the GNU Library General Public +License which covers the use of the GNU `gettext' library. This means +in particular that even non-free programs can use `libintl' as a shared +library, whereas only free software can use `libintl' as a static +library or use modified versions of `libintl'. + + Once the sources are changed appropriately and the setup can handle +the use of `gettext' the only thing missing are the translations. The +Free Translation Project is also available for packages which are not +developed inside the GNU project. Therefore the information given above +applies also for every other Free Software Project. Contact +`translation@iro.umontreal.ca' to make the `.pot' files available to +the translation teams. + diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..9ad0ba2 --- /dev/null +++ b/AUTHORS @@ -0,0 +1,466 @@ +# +# Master author manifest for bash +# +# The files in lib/intl were taken from the GNU gettext distribution. +# +# Any files appearing in the bash distribution not listed in this file +# were created by Chet Ramey. +# +# Filename authors (first is original author) +# +README Brian Fox, Chet Ramey +INSTALL Brian Fox, Chet Ramey +COPYING Brian Fox, Chet Ramey +MANIFEST Brian Fox, Chet Ramey +configure Chet Ramey +Makefile.in Brian Fox, Chet Ramey +configure.in Chet Ramey +aclocal.m4 Chet Ramey +config.h.top Chet Ramey +config.h.bot Chet Ramey +config.h.in Chet Ramey +array.c Chet Ramey +print_cmd.c Brian Fox, Chet Ramey +general.c Brian Fox, Chet Ramey +variables.c Brian Fox, Chet Ramey +make_cmd.c Brian Fox, Chet Ramey +copy_cmd.c Brian Fox, Chet Ramey +unwind_prot.c Brian Fox, Chet Ramey +dispose_cmd.c Brian Fox, Chet Ramey +getcwd.c Roland McGrath, Brian Fox, Chet Ramey +bashhist.c Chet Ramey +hash.c Brian Fox, Chet Ramey +parse.y Brian Fox, Chet Ramey +subst.c Brian Fox, Chet Ramey +shell.c Brian Fox, Chet Ramey +sig.c Chet Ramey +trap.c Brian Fox, Chet Ramey +siglist.c Brian Fox, Chet Ramey +version.c Brian Fox, Chet Ramey +flags.c Brian Fox, Chet Ramey +jobs.c Brian Fox, Chet Ramey +input.c Chet Ramey +mailcheck.c Brian Fox, Chet Ramey +pathexp.c Chet Ramey +test.c Brian Fox, Chet Ramey +expr.c Chet Ramey, Brian Fox +alias.c Brian Fox, Chet Ramey +execute_cmd.c Brian Fox, Chet Ramey +bashline.c Brian Fox, Chet Ramey +braces.c Brian Fox, Chet Ramey +bracecomp.c Brian Fox, Chet Ramey, Tom Tromey +nojobs.c Brian Fox, Chet Ramey +vprint.c Chet Ramey +oslib.c Chet Ramey +error.c Brian Fox, Chet Ramey +xmalloc.c Brian Fox, Chet Ramey +alias.h Brian Fox, Chet Ramey +array.h Chet Ramey +builtins.h Brian Fox, Chet Ramey +parser.h Brian Fox, Chet Ramey +variables.h Brian Fox, Chet Ramey +machines.h Brian Fox, Chet Ramey +jobs.h Brian Fox, Chet Ramey +maxpath.h Brian Fox, Chet Ramey +pathexp.h Chet Ramey +mailcheck.h Chet Ramey +filecntl.h Brian Fox, Chet Ramey +hash.h Brian Fox, Chet Ramey +quit.h Brian Fox, Chet Ramey +flags.h Brian Fox, Chet Ramey +shell.h Brian Fox, Chet Ramey +bashjmp.h Chet Ramey +sig.h Chet Ramey +trap.h Brian Fox, Chet Ramey +general.h Brian Fox, Chet Ramey +unwind_prot.h Brian Fox, Chet Ramey +input.h Brian Fox, Chet Ramey +error.h Brian Fox, Chet Ramey +command.h Brian Fox, Chet Ramey +externs.h Chet Ramey +siglist.h Chet Ramey +subst.h Brian Fox, Chet Ramey +dispose_cmd.h Brian Fox, Chet Ramey +bashansi.h Brian Fox, Chet Ramey +make_cmd.h Brian Fox, Chet Ramey +bashhist.h Chet Ramey +bashline.h Chet Ramey +execute_cmd.h Chet Ramey +bashtypes.h Chet Ramey +bashtty.h Chet Ramey +pathnames.h Chet Ramey +y.tab.c Brian Fox, Chet Ramey +y.tab.h Brian Fox, Chet Ramey +parser-built Brian Fox, Chet Ramey +posixstat.h Brian Fox, Chet Ramey +stdc.h Chet Ramey +ansi_stdlib.h Brian Fox, Chet Ramey +memalloc.h Chet Ramey +builtins/ChangeLog Brian Fox, Chet Ramey +builtins/Makefile.in Brian Fox, Chet Ramey +builtins/alias.def Brian Fox, Chet Ramey +builtins/bind.def Brian Fox, Chet Ramey +builtins/break.def Brian Fox, Chet Ramey +builtins/builtin.def Brian Fox, Chet Ramey +builtins/caller.def Rocky Bernstein, Chet Ramey +builtins/cd.def Brian Fox, Chet Ramey +builtins/colon.def Brian Fox, Chet Ramey +builtins/command.def Brian Fox, Chet Ramey +builtins/common.c Brian Fox, Chet Ramey +builtins/declare.def Brian Fox, Chet Ramey +builtins/echo.def Brian Fox, Chet Ramey +builtins/enable.def Brian Fox, Chet Ramey +builtins/eval.def Brian Fox, Chet Ramey +builtins/exec.def Brian Fox, Chet Ramey +builtins/exit.def Brian Fox, Chet Ramey +builtins/fc.def Brian Fox, Chet Ramey +builtins/fg_bg.def Brian Fox, Chet Ramey +builtins/getopt.c Roland McGrath, Brian Fox, Chet Ramey +builtins/getopt.h Roland McGrath, Brian Fox, Chet Ramey +builtins/getopts.def Brian Fox, Chet Ramey +builtins/hash.def Brian Fox, Chet Ramey +builtins/hashcom.h Brian Fox, Chet Ramey +builtins/help.def Brian Fox, Chet Ramey +builtins/let.def Chet Ramey, Brian Fox +builtins/history.def Brian Fox, Chet Ramey +builtins/jobs.def Brian Fox, Chet Ramey +builtins/kill.def Brian Fox, Chet Ramey +builtins/mapfile.def Rocky Bernstein +builtins/mkbuiltins.c Brian Fox, Chet Ramey +builtins/pushd.def Brian Fox, Chet Ramey +builtins/read.def Brian Fox, Chet Ramey +builtins/reserved.def Brian Fox, Chet Ramey +builtins/return.def Brian Fox, Chet Ramey +builtins/set.def Brian Fox, Chet Ramey +builtins/setattr.def Brian Fox, Chet Ramey +builtins/shift.def Brian Fox, Chet Ramey +builtins/shopt.def Chet Ramey +builtins/source.def Brian Fox, Chet Ramey +builtins/suspend.def Brian Fox, Chet Ramey +builtins/test.def Brian Fox, Chet Ramey +builtins/times.def Brian Fox, Chet Ramey +builtins/trap.def Brian Fox, Chet Ramey +builtins/type.def Brian Fox, Chet Ramey +builtins/ulimit.def Chet Ramey, Brian Fox +builtins/umask.def Brian Fox, Chet Ramey +builtins/wait.def Brian Fox, Chet Ramey +builtins/psize.c Chet Ramey, Brian Fox +builtins/psize.sh Chet Ramey, Brian Fox +builtins/inlib.def Chet Ramey +builtins/bashgetopt.c Chet Ramey +builtins/common.h Chet Ramey +builtins/bashgetopt.h Chet Ramey +lib/doc-support/texindex.c bug-texinfo@prep.ai.mit.edu, Chet Ramey +lib/doc-support/Makefile.in Chet Ramey +lib/doc-support/getopt.h Roland McGrath +lib/doc-support/getopt.c Roland McGrath +lib/doc-support/getopt1.c Roland McGrath +lib/glob/ChangeLog Brian Fox, Chet Ramey +lib/glob/Makefile.in Brian Fox, Chet Ramey +lib/glob/strmatch.c Roland McGrath, Brian Fox, Chet Ramey +lib/glob/strmatch.h Roland McGrath, Brian Fox, Chet Ramey +lib/glob/glob.c Richard Stallman, Roland McGrath, Brian Fox, Chet Ramey +lib/glob/glob.h Chet Ramey +lib/glob/ndir.h Doug Gwyn, Richard Stallman +lib/glob/doc/Makefile.in Brian Fox, Chet Ramey +lib/glob/doc/glob.texi Brian Fox, Chet Ramey +lib/malloc/Makefile.in Chet Ramey +lib/malloc/alloca.c Doug Gwyn, Richard Stallman, Brian Fox, Chet Ramey +lib/malloc/getpagesize.h Brian Fox, Chet Ramey +lib/malloc/malloc.c Chris Kingsley, Mike Muuss, Richard Stallman, Brian Fox, Chet Ramey +lib/malloc/gmalloc.c Mike Haertel, Roland McGrath +lib/malloc/stub.c Chet Ramey +lib/malloc/i386-alloca.s Richard Stallman +lib/malloc/x386-alloca.s Chip Salzenberg, Richard Stallman +lib/malloc/xmalloc.c Brian Fox, Chet Ramey +lib/posixheaders/posixstat.h Brian Fox, Chet Ramey +lib/posixheaders/ansi_stdlib.h Brian Fox, Chet Ramey +lib/posixheaders/stdc.h Chet Ramey +lib/posixheaders/memalloc.h Chet Ramey +lib/posixheaders/filecntl.h Brian Fox, Chet Ramey +lib/readline/Makefile.in Brian Fox, Chet Ramey +lib/readline/COPYING Brian Fox, Chet Ramey +lib/readline/ChangeLog Brian Fox, Chet Ramey +lib/readline/readline.c Brian Fox, Chet Ramey +lib/readline/vi_mode.c Brian Fox, Chet Ramey +lib/readline/emacs_keymap.c Brian Fox, Chet Ramey +lib/readline/vi_keymap.c Brian Fox, Chet Ramey +lib/readline/funmap.c Brian Fox, Chet Ramey +lib/readline/keymaps.c Brian Fox, Chet Ramey +lib/readline/xmalloc.c Brian Fox, Chet Ramey +lib/readline/search.c Brian Fox, Chet Ramey +lib/readline/isearch.c Brian Fox, Chet Ramey +lib/readline/parens.c Brian Fox, Chet Ramey +lib/readline/rltty.c Brian Fox, Chet Ramey +lib/readline/complete.c Brian Fox, Chet Ramey +lib/readline/bind.c Brian Fox, Chet Ramey +lib/readline/display.c Brian Fox, Chet Ramey +lib/readline/signals.c Brian Fox, Chet Ramey +lib/readline/kill.c Brian Fox, Chet Ramey +lib/readline/undo.c Brian Fox, Chet Ramey +lib/readline/input.c Brian Fox, Chet Ramey +lib/readline/macro.c Brian Fox, Chet Ramey +lib/readline/util.c Brian Fox, Chet Ramey +lib/readline/callback.c Chet Ramey +lib/readline/readline.h Brian Fox, Chet Ramey +lib/readline/chardefs.h Brian Fox, Chet Ramey +lib/readline/keymaps.h Brian Fox, Chet Ramey +lib/readline/rldefs.h Brian Fox, Chet Ramey +lib/readline/posixstat.h Brian Fox, Chet Ramey +lib/readline/ansi_stdlib.h Brian Fox, Chet Ramey +lib/readline/memalloc.h Chet Ramey +lib/readline/rlconf.h Chet Ramey +lib/readline/rltty.h Chet Ramey +lib/readline/history.c Brian Fox, Chet Ramey +lib/readline/histexpand.c Brian Fox, Chet Ramey +lib/readline/histfile.c Brian Fox, Chet Ramey +lib/readline/histsearch.c Brian Fox, Chet Ramey +lib/readline/history.h Brian Fox, Chet Ramey +lib/readline/histlib.h Brian Fox, Chet Ramey +lib/readline/tilde.c Brian Fox, Chet Ramey +lib/readline/tilde.h Brian Fox, Chet Ramey +lib/readline/doc/texindex.c bug-texinfo@prep.ai.mit.edu, Chet Ramey +lib/readline/doc/Makefile Brian Fox, Chet Ramey +lib/readline/doc/rlman.texinfo Brian Fox, Chet Ramey +lib/readline/doc/rltech.texinfo Brian Fox, Chet Ramey +lib/readline/doc/rluser.texinfo Brian Fox, Chet Ramey +lib/readline/doc/hist.texinfo Brian Fox, Chet Ramey +lib/readline/doc/hstech.texinfo Brian Fox, Chet Ramey +lib/readline/doc/hsuser.texinfo Brian Fox, Chet Ramey +lib/readline/examples/Makefile Brian Fox +lib/readline/examples/fileman.c Brian Fox +lib/readline/examples/manexamp.c Brian Fox +lib/readline/examples/histexamp.c Brian Fox, Chet Ramey +lib/readline/examples/rltest.c Brian Fox, Chet Ramey +lib/readline/examples/Inputrc Brian Fox, Chet Ramey +lib/termcap/Makefile.in David MacKenzie, Chet Ramey +lib/termcap/termcap.c David MacKenzie +lib/termcap/termcap.h David MacKenzie +lib/termcap/tparam.c David MacKenzie +lib/termcap/version.c David MacKenzie +lib/termcap/grot/termcap.info David MacKenzie +lib/termcap/grot/termcap.info-1 David MacKenzie +lib/termcap/grot/termcap.info-2 David MacKenzie +lib/termcap/grot/termcap.info-3 David MacKenzie +lib/termcap/grot/termcap.info-4 David MacKenzie +lib/termcap/grot/NEWS David MacKenzie +lib/termcap/grot/INSTALL David MacKenzie +lib/termcap/grot/ChangeLog David MacKenzie +lib/termcap/grot/texinfo.tex David MacKenzie +lib/termcap/grot/termcap.texi David MacKenzie +lib/termcap/grot/Makefile.in David MacKenzie +lib/termcap/grot/configure David MacKenzie +lib/termcap/grot/configure.in David MacKenzie +lib/termcap/grot/COPYING David MacKenzie +lib/termcap/grot/README David MacKenzie +lib/tilde/ChangeLog Brian Fox, Chet Ramey +lib/tilde/Makefile.in Brian Fox, Chet Ramey +lib/tilde/doc/tilde.texi Brian Fox, Chet Ramey +lib/tilde/doc/Makefile Brian Fox, Chet Ramey +lib/tilde/tilde.c Brian Fox, Chet Ramey +lib/tilde/tilde.h Brian Fox, Chet Ramey +lib/tilde/memalloc.h Brian Fox, Chet Ramey +CWRU/misc/open-files.c Chet Ramey +CWRU/misc/sigs.c Chet Ramey +CWRU/misc/pid.c Chet Ramey +CWRU/misc/sigstat.c Chet Ramey +CWRU/misc/bison Chet Ramey +CWRU/misc/aux-machine-desc Chet Ramey +CWRU/PLATFORMS Chet Ramey +CWRU/README Chet Ramey +CWRU/CWRU.CHANGES.051093 Chet Ramey +CWRU/POSIX.NOTES Chet Ramey +CWRU/CWRU.CHANGES.071193 Chet Ramey +CWRU/CWRU.CHANGES.090393 Chet Ramey +doc/Makefile.in Brian Fox, Chet Ramey +doc/bash.1 Chet Ramey +doc/builtins.1 Chet Ramey +doc/bash.ps Chet Ramey +doc/bash.txt Chet Ramey +doc/readline.3 Chet Ramey +doc/readline.ps Chet Ramey +doc/readline.txt Chet Ramey +doc/texinfo.tex Richard Stallman +doc/features.texi Brian Fox, Chet Ramey +doc/features.ps Brian Fox, Chet Ramey +doc/features.info Brian Fox, Chet Ramey +doc/features.dvi Brian Fox, Chet Ramey +doc/bash_builtins.1 Chet Ramey +doc/bash_builtins.ps Chet Ramey +doc/bash_builtins.txt Chet Ramey +doc/bash_builtins.readme Chet Ramey +doc/article.ms Chet Ramey +doc/FAQ Chet Ramey +support/cat-s Brian Fox, Chet Ramey +support/mksysdefs Brian Fox, Chet Ramey +support/mkversion.c Brian Fox, Chet Ramey +support/mksignames.c Brian Fox, Chet Ramey +support/getcppsyms.c Brian Fox, Chet Ramey +support/cppmagic Brian Fox, Chet Ramey +support/pagesize.sh Chet Ramey, Brian Fox +support/pagesize.c Chet Ramey, Brian Fox +support/bash.xbm Brian Fox +support/FAQ Brian Fox +support/PORTING Brian Fox +support/mklinks Brian Fox +support/fixlinks Chet Ramey +support/mkdirs Chet Ramey +support/clone-bash Chet Ramey +support/bashbug.sh Chet Ramey +support/mkmachtype Chet Ramey +support/recho.c Chet Ramey +support/config.guess Per Bothner, Chet Ramey +support/config.sub Richard Stallman, Chet Ramey +support/install.sh MIT X Consortium (X11R5) +support/endian.c Chet Ramey +support/printenv Chet Ramey +examples/precedence-tester Brian Fox, Chet Ramey +examples/functions/substr Brian Fox, Chet Ramey +examples/functions/kshenv Chet Ramey +examples/functions/autoload Chet Ramey +examples/functions/csh-compat Brian Fox, Chet Ramey +examples/functions/shcat Chet Ramey +examples/functions/substr2 Chet Ramey +examples/functions/term Chet Ramey +examples/functions/whatis Chet Ramey +examples/functions/whence Chet Ramey +examples/functions/func Chet Ramey +examples/functions/dirname Brian Fox, Noah Friedman +examples/functions/basename Brian Fox, Noah Friedman +examples/functions/exitstat Noah Friedman, Roland McGrath +examples/functions/external Noah Friedman +examples/functions/fact Brian Fox +examples/functions/manpage Tom Tromey +examples/functions/fstty Chet Ramey +examples/functions/jj.bash Chet Ramey +examples/functions/notify.bash Chet Ramey +examples/loadables/getconf.c J.T. Conklin +examples/scripts/shprompt Chet Ramey +examples/scripts/adventure.sh Chet Ramey, Doug Gwyn +examples/scripts/bcsh.sh Chris Robertson, Chet Ramey +examples/startup-files/Bashrc Brian Fox +examples/startup-files/Bash_aliases Brian Fox +examples/startup-files/Bash_profile Brian Fox +examples/startup-files/bash-profile Brian Fox +examples/startup-files/bashrc Chet Ramey +examples/suncmd.termcap Brian Fox, Chet Ramey +examples/alias-conv.sh Brian Fox, Chet Ramey +tests/README Chet Ramey +tests/arith.tests Chet Ramey +tests/arith.right Chet Ramey +tests/array.tests Chet Ramey +tests/array.right Chet Ramey +tests/dollar-at.sh Chet Ramey +tests/dollar-star.sh Chet Ramey +tests/dollar.right Chet Ramey +tests/exp-tests Chet Ramey +tests/exp.right Chet Ramey +tests/glob-test Chet Ramey +tests/glob.right Chet Ramey +tests/ifs-test-1.sh Chet Ramey +tests/ifs-test-2.sh Chet Ramey +tests/ifs-test-3.sh Chet Ramey +tests/ifs.1.right Chet Ramey +tests/ifs.2.right Chet Ramey +tests/ifs.3.right Chet Ramey +tests/input-line.sh Chet Ramey +tests/input-line.sub Chet Ramey +tests/input.right Chet Ramey +tests/minus-e Chet Ramey +tests/minus-e.right Chet Ramey +tests/new-exp.tests Chet Ramey +tests/new-exp.right Chet Ramey +tests/prec.right Chet Ramey +tests/precedence Chet Ramey +tests/run-all Chet Ramey +tests/run-dollars Chet Ramey +tests/run-exp-tests Chet Ramey +tests/run-glob-test Chet Ramey +tests/run-ifs-tests Chet Ramey +tests/run-input-test Chet Ramey +tests/run-minus-e Chet Ramey +tests/run-new-exp Chet Ramey +tests/run-precedence Chet Ramey +tests/run-set-e-test Chet Ramey +tests/run-strip Chet Ramey +tests/run-varenv Chet Ramey +tests/set-e-test Chet Ramey +tests/set-e.right Chet Ramey +tests/strip.tests Chet Ramey +tests/strip.right Chet Ramey +tests/tilde-tests Chet Ramey +tests/tilde.right Chet Ramey +tests/unicode1.sub Chet Ramey, John Kearney +tests/varenv.right Chet Ramey +tests/varenv.sh Chet Ramey +tests/misc/chld-trap.sh Chet Ramey +tests/misc/dot-test-1.sh Chet Ramey +tests/misc/dot-test-1.sub Chet Ramey +tests/misc/gotest Chet Ramey +tests/misc/perf-script Chet Ramey +tests/misc/redir.t1.sh Chet Ramey +tests/misc/redir.t2.sh Chet Ramey +tests/misc/redir.t3.sh Chet Ramey +tests/misc/redir.t3.sub Chet Ramey +tests/misc/redir.t4.sh Chet Ramey +tests/misc/run.r1.sh Chet Ramey +tests/misc/run.r2.sh Chet Ramey +tests/misc/run.r3.sh Chet Ramey +tests/misc/sigint.t1.sh Chet Ramey +tests/misc/sigint.t2.sh Chet Ramey +tests/misc/sigint.t3.sh Chet Ramey +tests/misc/sigint.t4.sh Chet Ramey +tests/misc/test-minus-e.1 Chet Ramey +tests/misc/test-minus-e.2 Chet Ramey +lib/sh/Makefile.in Chet Ramey +lib/sh/clktck.c Chet Ramey +lib/sh/clock.c Chet Ramey +lib/sh/fmtullong.c Chet Ramey +lib/sh/fmtulong.c Chet Ramey +lib/sh/getcwd.c Chet Ramey, Roland McGrath +lib/sh/getenv.c Chet Ramey, Brian Fox +lib/sh/inet_aton.c Chet Ramey, Ulrich Drepper, Paul Vixie +lib/sh/itos.c Chet Ramey +lib/sh/mailstat.c Chet Ramey +lib/sh/makepath.c Chet Ramey +lib/sh/mktime.c Chet Ramey, Paul Eggert +lib/sh/netconn.c Chet Ramey +lib/sh/netopen.c Chet Ramey +lib/sh/oslib.c Chet Ramey, Brian Fox +lib/sh/pathcanon.c Chet Ramey +lib/sh/pathphys.c Chet Ramey +lib/sh/rename.c Chet Ramey +lib/sh/setlinebuf.c Chet Ramey, Brian Fox +lib/sh/shquote.c Chet Ramey +lib/sh/shtty.c Chet Ramey +lib/sh/snprintf.c Chet Ramey, Unknown +lib/sh/spell.c Chet Ramey +lib/sh/strcasecmp.c Chet Ramey, Brian Fox +lib/sh/strerror.c Chet Ramey, Brian Fox +lib/sh/strftime.c Arnold Robbins +lib/sh/strindex.c Chet Ramey +lib/sh/stringlist.c Chet Ramey +lib/sh/stringvec.c Chet Ramey +lib/sh/strpbrk.c Roland McGrath +lib/sh/strtod.c Chet Ramey, Roland McGrath +lib/sh/strtoimax.c Chet Ramey, Paul Eggert +lib/sh/strtol.c Chet Ramey, Paul Eggert +lib/sh/strtoll.c Chet Ramey, Paul Eggert +lib/sh/strtoul.c Chet Ramey, Paul Eggert +lib/sh/strtoull.c Chet Ramey, Paul Eggert +lib/sh/strtoumax.c Chet Ramey, Paul Eggert +lib/sh/strtrans.c Chet Ramey +lib/sh/times.c Chet Ramey, Brian Fox +lib/sh/timeval.c Chet Ramey +lib/sh/tmpfile.c Chet Ramey +lib/sh/vprint.c Chet Ramey, Brian Fox +lib/sh/xstrchr.c Chet Ramey, Mitsuru Chinen +lib/sh/zread.c Chet Ramey +lib/sh/zwrite.c Chet Ramey + +tests/posix-ifs.sh Glenn Fowler + +support/checkbashisms Julian Gilbey, Debian Linux team + +lib/readline/colors.c Richard Stallman, David MacKenzie +lib/readline/parse-colors.c Richard Stallman, David MacKenzie diff --git a/CHANGES b/CHANGES new file mode 100644 index 0000000..43cb134 --- /dev/null +++ b/CHANGES @@ -0,0 +1,8862 @@ +This document details the changes between this version, bash-4.4-release, and +the previous version, bash-4.4-rc2. + +1. Changes to Bash + +a. Fixed a bug that could potentially result in a crash due to an integer + overflow. + +b. Fixed a bug in where commands printed due to `set -x' could be incorrectly + quoted if being printed in contexts where they haven't yet been expanded. + +c. Fixed several memory leaks. + +d. Fixed a bug that could potentially cause the terminal attributes to be + set incorrectly by a command run from a programmable completion. + +e. Fixed several potential buffer overflow issues in the word expansion code. + +2. Changes to Readline + +3. New Features in Bash + +4. New Features in Readline + +------------------------------------------------------------------------------ +This document details the changes between this version, bash-4.4-rc2, and +the previous version, bash-4.4-beta2. + +1. Changes to Bash + +a. Fixed an out-of-bounds read in the redirection operator completion code. + +b. Fixed execution context so `until continue' doesn't disable execution for + subsequent commands. + +c. Fixed trap handling code so traps don't inherit a command's temporary + environment. + +d. Fixed a bug that resulted in incorrect line numbers when a function is + defined as part of another function's execution. + +e. Fixed a bug in the expansion of ${a[@]} in contexts where word splitting + is not performed and $IFS is not the default. + +f. Fixed a bug that caused ''"$@" to not expand to an empty argument when + there are no positional parameters. + +g. Fixed a bug that caused a shell compiled without job control to use the + incorrect exit status for builtin commands preceded by a command executed + from the file system that causes the shell to call waitpid(). + +h. Improved word completion for quoted strings containing unterminated command + substitutions with embedded double quotes. + +2. Changes to Readline + +a. Fixed a bug that caused mode strings to be displayed incorrectly if the + prompt was shorter than the mode string. + +3. New Features in Bash + +a. Using ${a[@]} or ${a[*]} with an array without any assigned elements when + the nounset option is enabled no longer throws an unbound variable error. + +4. New Features in Readline + +a. New application-callable function: rl_pending_signal(): returns the signal + number of any signal readline has caught but not yet handled. + +b. New application-settable variable: rl_persistent_signal_handlers: if set + to a non-zero value, readline will enable the readline-6.2 signal handler + behavior in callback mode: handlers are installed when + rl_callback_handler_install is called and removed removed when a complete + line has been read. + +------------------------------------------------------------------------------ +This document details the changes between this version, bash-4.4-beta2, and +the previous version, bash-4.4-rc1. + +1. Changes to Bash + +a. Fixed a memory leak when processing ${!var[@]}. + +b. Fixed a bug that caused subshells to free trap strings associated with + inherited signals. + +c. Inheriting BASHOPTS from the environment now works to force actions + associated with enabling an option, instead of just marking the option + as enabled. + +d. Fixed a bug that allowed assignments to BASH_CMDS when the shell was in + restricted mode. + +e. Fixed a bug caused by an accidental omission of part of the original patch + for EXECIGNORE. + +e. Prompt expansion now quotes the results of the \s, \h, and \H expansions. + +f. Fixed a bug that caused parsing errors in command substitutions with + consecutive case statements separated by newlines. + +g. Updated logic used to decide whether bash is running inside an emacs + terminal emulator to work with future emacs versions. + +h. Fixed two extended pattern matching bugs caused by premature short- + circuiting. + +i. Fixed a memory leak in the code that removes duplicate history entries. + +j. There are a number of bug fixes to coproc, mapfile, declare, unset, + and assignment statements that prevent nameref variables from creating + and unsetting variables with invalid names. + +k. Fixed a bug that caused variables to be inadvertently marked as both an + associative and an indexed array. + +l. Fixed a bug that caused `bash -c' to not run a trap specified in the + command string. + +j. There are a number of bug fixes to coproc, mapfile, declare, and assignment + statements that prevent nameref variables from overwriting or modifying + attributes of readonly variables. + +k. Fixed a bug that caused command substitution to attempt to set the + terminal's process group incorrectly. + +l. Fixed a bug that could cause prompt string expansion to display error + messages when the `nounset' shell option is set. + +m. Fixed a bug that caused "$@" to not expand to an empty string under the + circumstances when Posix says it should ("${@-${@-$@}}"). + +n. Fixed several bugs caused by referencing nameref variables whose values + are names of unset variables (or names that are valid for referencing + but not assignment), including creating variables in the temporary + environment. + +o. Function tracing and error tracing are disabled if --debugger is supplied + at startup but the shell can't find the debugger start file. + +p. Fixed a bug when IFS is used as the control variable in a for statement. + +q. Fixed a bug with SIGINT received by a command substitution in an interactive + shell. + +r. The checks for nameref variable self-references are more thorough. + +s. Fixed several bugs with multi-line aliases. + +t. Fixed `test' to handle the four-argument case where $1 == '(' and + $4 == ')'. + +u. Fixed a bug in the expansion of $* in the cases where word splitting is + not performed. + +v. Fixed a bug in execution of case statements where IFS includes the + pattern matching characters. + +2. Changes to Readline + +a. When refreshing the line as the result of a key sequence, Readline attempts + to redraw only the last line of a multiline prompt. + +b. Fixed an issue that caused completion of git commands to display + incorrectly when using colored-completion-prefix. + +c. Fixed several redisplay bugs having to do with multibyte characters and + invisible characters in prompt strings. + +3. New Features in Bash + +a. Value conversions (arithmetic expansions, case modification, etc.) now + happen when assigning elements of an array using compound assignment. + +b. There is a new option settable in config-top.h that makes multiple + directory arguments to `cd' a fatal error. + +c. Bash now uses mktemp() when creating internal temporary files; it produces + a warning at build time on many Linux systems. + +4. New Features in Readline + +a. The default binding for ^W in vi mode now uses word boundaries specified + by Posix (vi-unix-word-rubout is bindable command name). + +b. rl_clear_visible_line: new application-callable function; clears all + screen lines occupied by the current visible readline line. + +c. rl_tty_set_echoing: application-callable function that controls whether + or not readline thinks it is echoing terminal output. + +d. Handle >| and strings of digits preceding and following redirection + specifications as single tokens when tokenizing the line for history + expansion. + +e. Fixed a bug with displaying completions when the prefix display length + is greater than the length of the completions to be displayed. + +f. The :p history modifier now applies to the entire line, so any expansion + specifying :p causes the line to be printed instead of expanded. + +------------------------------------------------------------------------------ +This document details the changes between this version, bash-4.4-rc1, and +the previous version, bash-4.4-beta. + +1. Changes to Bash + +a. Fixed several problems with bash completion not special-casing bash syntax + constructs. + +b. Fixed a bug that caused the mapfile builtin to not create array variables + when a variable of the same name appears in the temporary environment. + +c. Fixed a bug that caused prompt expansion to loop when PS1 contained a + syntax error. + +d. Fixed a bug that caused the ${array[@]@A} expansion to split the results + even when double-quoted. + +e. There is a new implementation of the code that saves the last CHILD_MAX + exited background pids so their status can be queried later. + +f. Bash-4.4 can now be configured and built on very old versions of Solaris 2. + +g. Fixed problems with --help support for several builtins. + +h. Fixed values added to BASH_SOURCE and BASH_LINENO for functions inherited + from the environment. + +i. Fixed a bug that caused background processes run from non-interactive shells + with job control enabled to place the terminal in the wrong process group + under certain circumstances. + +j. Fixed a bug that caused `fc' to return an incorrect exit status when + executing commands from the history list. + +k. Fixed a bug that caused the shell to exit when a process substitution + received a SIGINT when run in certain terminal emulators. + +l. EXECIGNORE now honors the setting of `extglob' when attempting to match + executable names. + +m. Fixed a bug where `return' used the wrong exit status when executed in a + DEBUG trap. + +n. Fixed a bug that caused a command containing a here-document and an escaped + newline to be stored in the history list incorrectly. + +o. Fixed a bug that caused set -e to be honored in cases of builtins invoking + other builtins when it should be ignored. + +p. Fixed a bug that caused `readonly' and `export' to create local array + variables when used within shell functions. + +q. Fixed a bug that allowed subshells begun to execute process substitutions + to have access to the command's temporary environment. + +r. Fixed a bug that could cause the shell to dump core when receiving a + SIGCHLD for which a trap has been set while running in posix mode. + +s. Fixed a bug that caused bash to not restore BASH_ARGC, BASH_ARGV, + BASH_SOURCE, BASH_LINENO, and FUNCNAME if the shell received a SIGINT + while reading commands from a file while executing `.'. + +t. Fixed a bug that caused the `-o history' option to have no effect when + supplied on the command line when starting a new shell. + +u. Fixed a bug that caused history expansions occurring in command + substitutions to not be performed. + +v. Fixed a bug that caused `eval' run in a non-interactive shell to disable + history expansion for the remainder of the shell script, even if the script + had previously enabled it. + +w. Fixed a bug that caused "$@" to not expand to multiple words when IFS is set + to the empty string. + +x. Fixed a bug that caused process and command substitution to inherit output + buffered in the stdio library but not written. + +y. Fixed a bug that caused a terminating signal received during `echo' to run + an exit trap in a signal handler context. + +z. Fixed a bug that caused a builtin command containing a process substitution + to return the wrong exit status. + +aa. Fixed a bug that caused `()' subshells with piped input to incorrectly + redirect the standard input of some of the commands in the subshell from + /dev/null. + +bb. The history builtin now uses more descriptive error messages for missing or + invalid timestamps. + +2. Changes to Readline + +a. The history file writing functions only attempt to create and use a backup + history file if the history file exists and is a regular file. + +b. Fixed an out-of-bounds read in readline's internal tilde expansion + interface. + +c. Fixed several redisplay bugs with prompt strings containing multibyte + and non-visible characters whose physical length is longer than the screen + width. + +d. Fixed a redisplay bug with prompt strings containing invisible characters + whose physical length exceeds the screen width and using incremental search. + +e. Readline prints more descriptive error messages when it encounters errors + while reading an inputrc file. + +f. Fixed a bug in the character insertion code that attempts to optimize + typeahead when it reads a character that is not bound to self-insert and + resets the key sequence state. + +3. New Features in Bash + +a. BASH_COMPAT and FUNCNEST can be inherited and set from the shell's initial + environment. + +b. inherit_errexit: a new `shopt' option that, when set, causes command + substitutions to inherit the -e option. By default, those subshells disable + -e. It's enabled as part of turning on posix mode. + +c. New prompt string: PS0. Expanded and displayed by interactive shells after + reading a complete command but before executing it. + +d. Interactive shells now behave as if SIGTSTP/SIGTTIN/SIGTTOU are set to + SIG_DFL when the shell is started, so they are set to SIG_DFL in child + processes. + +e. Posix-mode shells now allow double quotes to quote the history expansion + character. + +f. OLDPWD can be inherited from the environment if it names a directory. + +g. Shells running as root no longer inherit PS4 from the environment, closing + a security hole involving PS4 expansion performing command substitution. + +h. If executing an implicit `cd' when the `autocd' option is set, bash will + now invoke a function named `cd' if one exists before executing the `cd' + builtin. + +4. New Features in Readline + +a. If an incremental search string has its last character removed with DEL, + the resulting empty search string no longer matches the previous line. + +b. If readline reads a history file that begins with `#' (or the value of + the history comment character) and has enabled history timestamps, the + history entries are assumed to be delimited by timestamps. This allows + multi-line history entries. + +c. Readline now throws an error if it parses a key binding without a + terminating `:' or whitespace. + +------------------------------------------------------------------------------ +This document details the changes between this version, bash-4.4-beta, and +the previous version, bash-4.4-alpha. + +1. Changes to Bash + +a. Fixed two bugs that caused out-of-bounds reads when skipping over assignment + statements while finding the word on which to perform programmable + completion. + +b. Fixed a memory leak in programmable completion. + +c. Fixed a bug that could cause the shell to crash when interrupting the + wait builtin. + +d. Fixed a bug that caused ${!vvv@} to be interpreted as introducing the new + `@' operator. + +e. Fixed a bug that caused the && and || operators to be incorrectly optimized. + +f. The shell now undoes redirections before exiting the shell when the `-e' + option is enabled, and a shell function fails. + +g. History expansion now skips over the history expansion character in command + and process substitution. + +h. Fixed a bug that caused stray '\001' characters to be added to the output + of `declare -p'. + +i. Fixed a memory leak when processing declare commands that perform compound + array assignments. + +j. Fixed a bug that could cause the shell to crash when reading input from a + file and the limit on open file descriptors is high. + +k. Fixed a bug that caused the ERR and RETURN traps to be unset if they were + set in a shell function but unset previously. + +l. Fixed a bug that caused several signals to be ignored if `exec' failed in + an interactive shell. + +m. A posix-mode non-interactive shell now considers a parameter expansion error + to be a fatal error. + +n. The `time' command now prints timing statistics for failed commands when + the -e option is enabled. + +o. Fixed a bug that caused the shell to crash when attempting to indirectly + expand a shell variable with an invalid name. + +p. Fixed a bug that caused the shell to crash when running a trap containing + a process substitution. + +q. Bash now prints the keyword `function' before a function with the same name + as a reserved word when using `declare -f' to avoid parse errors when + reusing the output as input. + +r. Fixed a bug that caused the shell to crash when using declare -g to attempt + to redefine an existing global indexed array variable as an associative + array. + +s. Fixed a memory leak that occurred when interrupting brace expansions + generating a sequence. + +t. Fixed a bug that resulted in alias expansion in redirections. + +u. The `declare -a' and `declare -A' commands now print fewer warnings when + attempting to create and initialize an array at the same time, but + relying on word expansions to construct the compound assignment. + +v. The `help' builtin now behaves better in locales where each wide + character occupies more than one display column. + +w. The `read' builtin no longer has a possible race condition when a timeout + occurs. + +x. Fixed several expansion problems encountered when IFS="'". + +y. Fixed a problem with the expansion of $'\c?'. + +z. Bash no longer splits the expansion of here-strings, as the documentation + has always said. + +aa. Bash now puts `s' in the value of $- if the shell is reading from standard + input, as Posix requires. + +bb. Fixed a bug that caused the shell to crash if invoked with a NULL + environment. + +cc. The shell now only trusts an inherited value for $PWD if it begins with a + `/'. + +dd. Fixed a memory leak when creating local array variables and assigning to + them using compound assignment with the `declare' builtin. + +ee. Fixed a bug that could cause the shell to crash when processing nested here + documents inside a command substitution. + +ff. Array keys and values are now displayed using $'...' quoting where + appropriate. + +gg. Fixed a bug that could cause the shell to crash if the replacement string + in pattern substitution was NULL. + +hh. Fixed a bug that could cause the shell to crash if a command substitution + contained a non-fatal syntax error. + +ii. Fixed a bug that could cause the shell to crash if variable indirection + resulted in a NULL variable. + +jj. Fixed a bug that could cause the shell to crash if a long string contained + multiple unterminated parameter expansion constructs. + +kk. Improved the code that acts on SIGINT received while waiting for a child + process only if the child exits due to SIGINT. + +ll. $BASH_SUBSHELL now has more consistent values in asynchronous simple + commands. + +2. Changes to Readline + +a. Colored completion prefixes are now displayed using a different color, less + likely to collide with files. + +b. Fixed a bug that caused vi-mode character search to misbehave when + running in callback mode. + +c. Fixed a bug that caused output to be delayed when input is coming from a + macro in vi-mode. + +d. Fixed a bug that caused the vi-mode `.' command to misbehave when redoing + a multi-key key sequence via a macro. + +e. Fixed a bug that caused problems with applications that supply their own + input function when performing completion. + +f. When read returns -1/EIO when attempting to read a key, return an error + instead of line termination back to the caller. + +g. Updated tty auditing feature based on patch from Red Hat. + +h. Fixed a bug that could cause the history library to crash on overflows + introduced by malicious editing of timestamps in the history file. + +3. New Features in Bash + +a. `make install' now installs the example loadable builtins and a set of + bash headers to use when developing new loadable builtins. + +b. `enable -f' now attempts to call functions named BUILTIN_builtin_load when + loading BUILTIN, and BUILTIN_builtin_unload when deleting it. This allows + loadable builtins to run initialization and cleanup code. + +c. There is a new BASH_LOADABLES_PATH variable containing a list of directories + where the `enable -f' command looks for shared objects containing loadable + builtins. + +d. The `complete_fullquote' option to `shopt' changes filename completion to + quote all shell metacharacters in filenames and directory names. + +e. The `kill' builtin now has a `-L' option, equivalent to `-l', for + compatibility with Linux standalone versions of kill. + +4. New Features in Readline +------------------------------------------------------------------------------ +This document details the changes between this version, bash-4.4-alpha, and +the previous version, bash-4.3-release. + +1. Changes to Bash + +a. A bug that caused pipelines to be corrupted while running the DEBUG trap + was fixed. + +b. A bug that accidentally omitted the `-R' unary operator from `test' was + fixed. + +c. A bug that could cause the shell to not restore the terminal's process + group on shell exit was fixed. + +d. Several changes were made to programmable completion to accommodate + assumptions made by the bash-completion package. + +e. Bash no longer inhibits C-style escape processing ($'...') while performing + pattern substitution word expansions. + +f. Fixed a bug that caused `return' executed from a trap handler to use the + wrong return status when one was not supplied as an argument. + +g. In Posix mode, defining a function with the same name as a special + builtin is now an error, fatal only when the shell is not interactive. + +h. Fixed a bug that caused compound array assignments to discard unset or null + variables used as subscripts, thereby making it appear as if the index was + not present. + +i. Fixed a bug that caused extended glob patterns to incorrectly match + filenames with a leading `.'. + +j. Fixed a bug involving sign extension when reallocating the input line + after a history expansion, causing segmentation faults. + +k. Bash now does a better job at identifying syntax errors during word + completion and tailoring completion appropriately. + +l. Bash now uses the current locale's decimal point in comamnd timing output. + +m. Fixed a bug that caused segmentation faults while reading here documents if + PS2 contains a command substitution. + +n. There are several changes to how $@ is expanded when unquoted but in a + context where word splitting is not performed (e.g., on the rhs of an + assignment or in a conditional command). + +o. Bash now quotes command hash table entries that contain shell metacharacters + when displaying hash table contents. + +p. Fixed a potential file descriptor leak when dup2() fails while performing a + redirection. + +q. Fixed a bug that caused directory names evaluated during word completion to + be dequoted twice. + +r. Fixed several bugs which could result in indirect variable expansion and + namerefs creating variables with invalid names or referencing variables + set to the empty string. + +s. Fixed a bug that caused bash to not expand $0 in word expansions where it + should. + +t. Fixed a bug that caused bash to perform process substitution if <( + appeared inside an arithmetic context. + +u. Fixed a bug in extglob pattern parsing that caused slashes in the pattern + to be confused as directory names. + +v. Fixed several bugs with treatment of invisible variables (variables with + attributes that are unset because they have never been assigned values). + +w. Fixed a bug that caused the `read' builtin to not clean up readline's + state when using the -e and -t options together and the read timed out. + +x. Fixed a bug that caused the shell to exit with the wrong (but non-zero) + value if a command was not found or was not executable. + +y. Fixed a bug that caused the `time' reserved word to not be recognized as + such in all contexts where it should have been. + +z. Fixed a bug that caused the shell to close process subsitution file + descriptors when executing a script without the `#!' leading line. + +aa. Fixed a typo that caused the `compat42' shell option to set the wrong + compatibility level. + +bb. The shell now handles process substitution commands with embedded + parentheses the same way as it does when parsing command substitution. + +cc. Fixed a bug that caused nested pipelines and the `lastpipe' shell option + to produce core dumps. + +dd. Fixed a bug that caused patterns containing `*' to match pathnames in cases + where slashes must be matched explicitly. + +ee. Fixed a problem with patterns containing `:' in colon-separated variables + like GLOBIGNORE. + +ff. Fixed a bug that caused indirect variable expansion using indexed arrays to + always use index 0. + +gg. Fixed a parsing problem that caused quoted newlines immediately following a + command substitution to be mishandled in certain cases. + +hh. Fixed a potential buffer overflow on systems without locale_charset or the + bash replacement. + +ii. Fixed a bug that caused background processes to modify the terminal's + process group under certain circumstances. + +jj. Asynchronous commands now always set $? to 0 and are not affected by + whether or not the command's exit status is being inverted. + +kk. Fixed a problem that caused a line ending with an escaped newline and + containingh a prior `eval' to be incorrectly parsed. + +ll. Fixed an issue with programmable completion and `!' in extglob patterns + used as arguments to `compgen -X'. + +mm. Word completion now treats the two-character token `>|' as requiring + filename expansion. + +nn. Bash no longer expands tildes in $PATH elements while in Posix mode. + +oo. Fixed a bug that caused bash to not clean up readline's state, including + the terminal settings, if it received a fatal signal while in a readline() + call (including `read -e' and `read -s'). + +pp. Fixed bug that caused importing shell functions from the environment to + execute additional commands following the function. + +qq. Fixed a bug that caused the parser to return a lookahead character pushed + back by a previous call, even when on another line. + +rr. Fixed a bug that caused many here-documents or many nested case statements + to overflow an internal stack. + +ss. Changed the way bash encodes exported functions for inclusion in the + environment to avoid name collisions with valid variable names and to + indicate that they are exported functions. + +tt. Fixed a bug that could result in an invalid memory access when processing + a here document delimited by end of file or end of string. + +uu. Fixed a bug that could cause an invalid memory access if a command was run + before initializing the job control framework. + +vv. When in Posix mode, bash prints shell function definitions as Posix + specifies them, without the leading `function' keyword. + +ww. The variable attribute display builtins no longer display variables with + invalid names that were imported from the environment. + +xx. Fixed a bug that could allow `break' or `continue' executed from shell + functions to affect loops running outside of the function. + +yy. Fixed a bug that could cause a restricted shell to attempt to import shell + functions from the environment. + +zz. The shell now allows double-quoted identifiers in arithmetic expressions. + +aaa. Fixed a bug that could allow scalar variables subscripted using [@] in + word expansions to be incorrectly quoted. + +bbb. The shell now makes sure to ignore SIGTSTP/SIGTTIN/SIGTTOU in child + processes if they were ignored at shell startup, even if job control is + in effect. + +ccc. Fixed a bug that could cause $* to be split on spaces when IFS is set to + the empty string. + +ddd. Posix says that expanding $* in a pattern context where the expansion is + double-quoted should not treat $* as if it were double quoted. + +eee. Bash now restores getopts' internal state between calls to getopts even if + a shell function declares a local copy of OPTIND. + +fff. Fixed a bug that could cause `history -r' or `history -n' to read identical + lines from the history file more than once. + +ggg. The commands executed by `bind -x' now redisplay at most the final line + of a multi-line prompt, and those commands may return 124 to indicate that + the entire prompt should be redrawn. + +hhh. Fixed a bug that could cause `mapfile' to create variables with invalid + names. + +iii. The shell only goes into debugging mode when --debugger is supplied if + the debugger initialization file is present. + +jjj. Fixed a bug that disallowed an assignment to (implicit) subscript 0 of an + existing array in a declare command that set the readonly attribute. + +kkk. Fixed a bug that inadvertently allowed assignments to FUNCNAME to disable + its special status. + +lll. Appending to an existing array variable using the compound assignment + syntax (var+=(aaa)) should not affect assignments to existing subscripts + appearing in the compound assignment. + +mmm. Fixed a bug that could cause the shell to crash when a variable with a + null value was passed in the temporary environment and the variable's + attributes are modified using `declare' while performing a redirection. + +nnn. Fixed a bug in printf so that a missing precision specifier after a `.' + is treated as 0. + +ooo. Fixed a bug that attempted to use the internal command timing to time + pipeline components if the pipeline elements are separated by newlines. + +ppp. Fixed a bug that caused `declare -al foo=(ONE TWO THREE)' to not lowercase + the values on assignment. + +qqq. Bash does a better job of determining whether or not files are executable + when running on Windows, since the X_OK flag to access(2) is not supported. + +rrr. Fixed a bug that caused some of the shell's internal traps (e.g., ERR) to + be interrupted (and leave incorrect state) by pending SIGINTs. + +sss. Fixed a bug in the bash interface to history expansion to avoid attempting + expansion if the history expansion character occurs in a command + substitution. + +ttt. Fixed a bug that caused the select command to crash if the REPLY variable + ends up empty (e.g., if it's made readonly) + +uuu. Bash handles backslash-quoting of multibyte characters better when quoting + output that is intended to be reused. + +vvv. System-specific changes for: Windows, Cygwin. + +www. Fixes for upper and lower-casing multibyte characters, some locales have + characters whose upper and lowercase versions have different numbers of + bytes. + +xxx. Fixed a bug that caused the ERR trap in a shell function to have the + wrong value for $LINENO. + +yyy. Fixed a bug that resulted in incorrect quoting of regexps for the =~ + operator when an open brace appears without a close brace. + +zzz. Fixed a bug in the array unset operation that caused it to attempt to + parse embedded single and double quotes. + +aaaa. Fixed a bug that caused $* to not expand with the first character of + $IFS as a separator in a context where word splitting will not take + place. + +bbbb. Fixed two bugs that could cause the shell to dereference a null pointer + while attempting to print an error message from arithmetic expansion. + +cccc. Fixed a bug that resulted in short-circuited evaluation when reading + commands from a string ending in an unquoted backslash, or when sourcing + a file that ends with an unquoted backslash. + +dddd. Fixed a bug that resulted in the no-fork optimization not cleaning up + any FIFOs created by process substitution. + +eeee. If the -T option is not set, allow the source builtin and shell functions + to set a DEBUG trap that persists after the sourced file or function + returns, instead of restoring the old (unset) value unconditionally. + +ffff. Fixed a bug that caused redirections to not be undone on some syntax + errors, e.g., when parsing a command substitution. + +gggg. Bash only adds asynchronous commands to the table of background pids + whose status it remembers, to avoid it growing too large during scripts + that create and reap large numbers of child processes. This means that + `wait' no longer works on synchronous jobs, but $? can be used to get + the exit status in those cases. + +hhhh. Bash now checks whether or not a shell script argument is a directory + before trying to open it; Posix says implementations may allow open(2) + on a directory. + +iiii. Fixed a bug that could cause the shell to set the terminal's process + group to a background process group when running as part of a pipeline. + +jjjj. Made a few changes to strings to avoid possible potential negative effects + caused by malicious translations. + +kkkk. Fixed a bug that caused the `unset' builtin to continue to treat its + arguments as functions after unsetting a function when invoked with no + options. + +llll. Fixed a bug that would not replace empty strings using pattern + substitution even if the pattern matched the empty string. + +mmmm. Fixed a bug with word completion that prevented some characters from + being backslash-quoted (backquote, dollar sign). + +nnnn. Fixed a bug that prevented a command from the history re-executed by the + `fc' builtin from setting verbose mode. + +oooo. Fixed a bug that caused the shell to not enable and disable function + tracing with changes to the `extdebug' shell option. + +pppp. Fixed a bug that caused assignments to nameref variables pointing to + unset variables with attributes but no values to create variables with + incorrect names. + +qqqq. Fixed a bug that caused `unset' on nameref variables (without -n) to + unset the wrong variable under certain circumstances. + +rrrr. Fixed a bug that caused close braces occurring in brace expansions within + command substitutions to incorrectly terminate parameter expansions. + +ssss. Fixed a bug that caused `command -p' to temporarily alter $PATH. + +tttt. Fixed a bug that caused interactive shells compiled without job control + to return incorrect status values for child processes when running a + single command that creates enough children to use the entire PID space. + +uuuu. `esac' should not be recognized as a reserved word when it appears as the + second or later pattern in a case statement pattern list. + +vvvv. Fixed a bug that caused the completion code to read past the end of the + readline line buffer while skipping assignment statements to find the + command name. + +wwww. Fixed a bug that caused case statements within loops contained in a + command substitution to be parsed incorrectly. + +xxxx. Fixed a bug that could cause SIGCHLD handling to be delayed after + running `wait' with no arguments and interrupting it with ^C without + a trap handler installed. + +2. Changes to Readline + +a. A bug that caused vi-mode `.' to be unable to redo `c', `d', and `y' + commands with modifiers was fixed. + +b. Fixed a bug that caused callback mode to dump core when reading a + multiple-key sequence (e.g., arrow keys). + +c. Fixed a bug that caused the redisplay code to erase some of the line when + using horizontal scrolling with incremental search. + +d. Readline's input handler now performs signal processing if read(2) is + interrupted by SIGALRM or SIGVTALRM. + +e. Fixed a problem with revert-all-at-newline freeing freed memory. + +f. Clarified the documentation for the history_quotes_inhibit_expansion + variable to note that it inhibits scanning for the history comment + character and that it only affects double-quoted strings. + +g. Fixed an off-by-one error in the prompt printed when performing searches. + +h. Use pselect(2), if available, to wait for input before calling read(2), so + a SIGWINCH can interrupt it, since it doesn't interrupt read(2). + +i. Some memory leaks caused by signals interrupting filename completion have + been fixed. + +j. Reading EOF twice on a non-empty line causes EOF to be returned, rather + than the partial line. This can cause partial lines to be executed on + SIGHUP, for example. + +k. Fixed a bug concerning deleting multibyte characters from the search + string while performing an incremental search. + +l. Fixed a bug with tilde expanding directory names in filename completion. + +m. Fixed a bug that did not allow binding sequences beginning with a `\'. + +n. Fixed a redisplay bug involving incorrect line wrapping when the prompt + contains a multibyte character in the last screen column. + +o. Fixed a bug that caused history expansion to disregard characters that are + documented to delimit a history event specifier without requiring `:'. + +p. Fixed a bug that could cause reading past the end of a string when reading + the value when binding the set of isearch terminators. + +q. Fixed a bug that caused readline commands that depend on knowing which + key invoked them to misbehave when dispatching key sequences that are + prefixes of other key bindings. + +r. Paren matching now works in vi insert mode. + +3. New Features in Bash + +a. There is now a settable configuration #define that will cause the shell + to exit if the shell is running setuid without the -p option and setuid + to the real uid fails. + +b. Command and process substitutions now turn off the `-v' option when + executing, as other shells seem to do. + +c. The default value for the `checkhash' shell option may now be set at + compile time with a #define. + +d. The `mapfile' builtin now has a -d option to use an arbitrary character + as the record delimiter, and a -t option to strip the delimiter as + supplied with -d. + +e. The maximum number of nested recursive calls to `eval' is now settable in + config-top.h; the default is no limit. + +f. The `-p' option to declare and similar builtins will display attributes for + named variables even when those variables have not been assigned values + (which are technically unset). + +g. The maximum number of nested recursive calls to `source' is now settable + in config-top.h; the default is no limit. + +h. All builtin commands recognize the `--help' option and print a usage + summary. + +i. Bash does not allow function names containing `/' and `=' to be exported. + +j. The `ulimit' builtin has new -k (kqueues) and -P (pseudoterminals) options. + +k. The shell now allows `time ; othercommand' to time null commands. + +l. There is a new `--enable-function-import' configuration option to allow + importing shell functions from the environment; import is enabled by + default. + +m. `printf -v var ""' will now set `var' to the empty string, as if `var=""' + had been executed. + +n. GLOBIGNORE, the pattern substitution word expansion, and programmable + completion match filtering now honor the value of the `nocasematch' option. + +o. There is a new ${parameter@spec} family of operators to transform the + value of `parameter'. + +p. Bash no longer attempts to perform compound assignment if a variable on the + rhs of an assignment statement argument to `declare' has the form of a + compound assignment (e.g., w='(word)' ; declare foo=$w); compound + assignments are accepted if the variable was already declared as an array, + but with a warning. + +q. The declare builtin no longer displays array variables using the compound + assignment syntax with quotes; that will generate warnings when re-used as + input, and isn't necessary. + +r. Executing the rhs of && and || will no longer cause the shell to fork if + it's not necessary. + +s. The `local' builtin takes a new argument: `-', which will cause it to save + the single-letter shell options and restore their previous values at + function return. + +t. `complete' and `compgen' have a new `-o nosort' option, which forces + readline to not sort the completion matches. + +u. Bash now allows waiting for the most recent process substitution, since it + appears as $!. + +v. The `unset' builtin now unsets a scalar variable if it is subscripted with + a `0', analogous to the ${var[0]} expansion. + +w. `set -i' is no longer valid, as in other shells. + +x. BASH_SUBSHELL is now updated for process substitution and group commands + in pipelines, and is available with the same value when running any exit + trap. + +y. Bash now checks $INSIDE_EMACS as well as $EMACS when deciding whether or + not bash is being run in a GNU Emacs shell window. + +z. Bash now treats SIGINT received when running a non-builtin command in a + loop the way it has traditionally treated running a builtin command: + running any trap handler and breaking out of the loop. + +aa. New variable: EXECIGNORE; a colon-separate list of patterns that will + cause matching filenames to be ignored when searching for commands. + +bb. Aliases whose value ends in a shell metacharacter now expand in a way to + allow them to be `pasted' to the next token, which can potentially change + the meaning of a command (e.g., turning `&' into `&&'). + +4. New Features in Readline + +a. The history truncation code now uses the same error recovery mechansim as + the history writing code, and restores the old version of the history file + on error. The error recovery mechanism handles symlinked history files. + +b. There is a new bindable variable, `enable-bracketed-paste', which enables + support for a terminal's bracketed paste mode. + +c. The editing mode indicators can now be strings and are user-settable + (new `emacs-mode-string', `vi-cmd-mode-string' and `vi-ins-mode-string' + variables). Mode strings can contain invisible character sequences. + Setting mode strings to null strings restores the defaults. + +d. Prompt expansion adds the mode string to the last line of a multi-line + prompt (one with embedded newlines). + +e. There is a new bindable variable, `colored-completion-prefix', which, if + set, causes the common prefix of a set of possible completions to be + displayed in color. + +f. There is a new bindable command `vi-yank-pop', a vi-mode version of emacs- + mode yank-pop. + +g. The redisplay code underwent several efficiency improvements for multibyte + locales. + +h. The insert-char function attempts to batch-insert all pending typeahead + that maps to self-insert, as long as it is coming from the terminal. + +i. rl_callback_sigcleanup: a new application function that can clean up and + unset any state set by readline's callback mode. Intended to be used + after a signal. + +------------------------------------------------------------------------------ +This document details the changes between this version, bash-4.3-release, and +the previous version, bash-4.3-rc2. + +1. Changes to Bash + +a. Only Posix-mode shells should exit on an assignment failure in the + temporary environment preceding a special builtin. This is how it's been + documented. + +b. Fixed a bug that caused a failed special builtin to not exit a posix-mode + shell if the failing builtin was on the LHS of a && or ||. + +c. Changed the handling of unquoted backslashes in regular expressions to be + closer to bash-4.2. + +d. globstar (**) no longer traverses symbolic links that resolve to + directories. This eliminates some duplicate entries. + +e. Fixed a bug that caused a SIGCHLD trap handler to not be able to change the + SIGCHLD disposition. + +f. Fixed a bug that caused a crash when -x was enabled and a command + contained a printable multibyte (wide) character. + +g. Fixed a bug that caused an interactive shell without line editing enabled + to read invalid data after receiving a SIGINT. + +h. Fixed a bug that caused command word completion to fail if the directory in + $PATH where the completion would be found contained single or double quotes. + +i. Fixed a bug that caused a shell with -v enabled to print commands in $() + multiple times. + +2. Changes to Readline + +a. Fixed a bug that caused `undo' to reference freed memory or null pointers. + +3. New Features in Bash + +a. The [[ -v ]] option now understands array references (foo[1]) and returns + success if the referenced element has a value. + +------------------------------------------------------------------------------ +This document details the changes between this version, bash-4.3-rc2, and the +previous version, bash-4.3-rc1. + +1. Changes to Bash + +a. Fixed a bug that left variables set by printf -v marked as invisible. + +b. Fixed an off-by-one error in a job control warning message. + +c. Fixed a bug that caused the shell to crash after declaring a nameref variable + without a value. + +d. Fixed a bug that caused asynchronous commands to not set $? correctly. + +e. Fixed a bug that caused out-of-order execution when executing aliases with + embedded newlines containing `.' commands. + +f. Fixed a bug that caused error messages generated by expansion errors in + `for' commands to have the wrong line number. + +g. Fixed a bug that caused the `wait' builtin to not be interruptible in an + interactive shell with job control enabled. + +h. Fixed a bug that caused SIGINT and SIGQUIT to not be trappable in + asynchronous subshell commands. + +i. Bash now requires that the value assigned to a nameref variable be a valid + shell identifier (variable name or array reference). + +j. Converting an existing variable to a nameref variable now turns off the + -i/-l/-u/-c attributes. + +k. Displaying a nameref variable with `declare -p' now displays the nameref + variable and its value rather than following the nameref chain. + +l. Fixed a problem with interrupt handling that caused a second and subsequent + SIGINT to be ignored by interactive shells. + +m. Fixed a bug that caused certain positional parameter and array expansions + to mishandle (discard) null positional parameters and array elements. + +n. The shell no longer blocks receipt of signals while running trap handlers + for those signals, and allows most trap handlers to be run recursively + (running trap handlers while a trap handler is executing). + +o. The shell now handles backslashes in regular expression arguments to the + [[ command's =~ operator slightly differently, resulting in more + consistent behavior. + +2. Changes to Readline + +a. Fixed a bug that could cause readline to crash and seg fault attempting to + expand an empty history entry. + +b. Fixed a bug that caused a bad entry in the $LS_COLORS variable to abort all + color processing but leave color enabled. + +c. Fixed a bug that caused display problems with multi-line prompts containing + invisible characters on multiple lines. + +d. Fixed a bug that caused effects made by undoing changes to a history line to + be discarded. + +3. New Features in Bash + +4. New Features in Readline + +a. When creating shared libraries on Mac OS X, the pathname written into the + library (install_name) no longer includes the minor version number. +------------------------------------------------------------------------------ +This document details the changes between this version, bash-4.3-rc1, and the +previous version, bash-4.3-beta2. + +1. Changes to Bash + +a. Fixed a bug in bash completion that caused a tilde to be expanded even if + the `direxpand' option was not enabled. + +b. Fixed a potential bug that could cause corrupted input in interactive shells + running without line editing and with `ignoreeof' enabled. + +c. Fixed a bug that could cause failures when opening pipes back to shells + created to run process substitutions. + +d. Fixed a bug that caused an assignment to TEXTDOMAIN to require TEXTDOMAINDIR + to be set in order to actually change the current text domain. + +e. Changed the way redirections are printed to avoid confusion when the target + of an output redirection is a process substitution beginning with `>'. + +2. Changes to Readline + +a. Shared library building is now supported on Mac OS X 10.9 (Darwin 13). + +3. New Features in Bash + +a. `cd' has a new `-@' option to browse a file's extended attributes on + systems that support O_XATTR. + +4. New Features in Readline + +a. There are additional default key bindings for MinGW32 + +------------------------------------------------------------------------------ +This document details the changes between this version, bash-4.3-beta2, and the +previous version, bash-4.3-beta. + +1. Changes to Bash + +a. Fixed a bug that caused assignment to an unset variable using a negative + subscript to result in a segmentation fault. + +b. Fixed a bug that caused assignment to a string variable using a negative + subscript to use the incorrect index. + +c. Fixed a bug that caused some strings to be interpreted as invalid + extended globbing expressions when used with the help builtin. + +d. Fixed a bug that caused an attempt to trap a signal whose disposition + cannot be changed to reference uninitialized memory. + +e. Command completion now skips assignment statements preceding a command + name and completes the command. + +f. Fixed a bug that caused `compgen -f' in a non-interactive shell to dump + core under certain circumstances. + +g. Fixed a bug that caused the `read -N' to misbehave when the input stream + contains 0xff. + +2. Changes to Readline + +a. Changed message when an incremental search fails to include "failed" in + the prompt and display the entire search string instead of just the last + matching portion. + +b. Fixed a bug that caused an arrow key typed to an incremental search prompt + to process the key sequence incorrectly. + +c. Additional key bindings for arrow keys on MinGW. + +3. New Features in Bash + +a. The help builtin now attempts substring matching (as it did through + bash-4.2) if exact string matching fails. + +b. The fc builtin now interprets -0 as the current command line. + +c. Completing directory names containing shell variables now adds a trailing + slash if the expanded result is a directory. + +4. New Features in Readline + +a. rl_change_environment: new application-settable variable that controls + whether or not Readline modifies the environment (currently readline + modifies only LINES and COLUMNS). + +------------------------------------------------------------------------------ +This document details the changes between this version, bash-4.3-beta, and the +previous version, bash-4.3-alpha. + +1. Changes to Bash + +a. Fixed a bug in the prompt directory name "trimming" code that caused + memory corruption and garbled the results. + +b. Fixed a bug that caused single quotes that resulted from $'...' quoting + in the replacement portion of a double-quoted ${word/pat/rep} expansion + to be treated as quote characters. + +c. Fixed a bug that caused assignment statements preceding a command word to + result in assignment statements following a declaration command to not be + expanded like assignment statements. + +d. Fixed a bug with variable search order in the presence of local variables + with the same name as variables in the temporary environment supplied to + a shell function. + +e. Fixed a bug that caused constructs like 1<(2) to be interpreted as process + substitutions even in an arithmetic context. + +f. Fixed several cases where `invisible' variables (variables with attributes + but no values, which are technically unset) were treated incorrectly. + +g. Fixed a bug that caused group commands in pipelines that were not the + last element to not run the EXIT trap. + +h. Fixed a bug that caused `unset -n' to not unset a nameref variable in + certain cases. + +i. Fixed the nameref circular reference checking to be less strict and only + disallow a nameref variable with the same value as its name at the global + scope. + +j. Fixed a bug that caused trap handlers to be executed recursively, + corrupting internal data structures. + +k. Fixed a bug that could result in bash not compiling if certain options were + not enabled. + +l. Fixed a bug that caused the arithmetic expansion code to attempt variable + assignments when operator precedence prohibited them. + +m. Word expansions like ${foo##bar} now understand indirect variable references. + +n. Fixed a bug that caused `declare -fp name' to not display a function + definition. + +o. Fixed a bug that caused asynchronous child processes to modify the stdin + file pointer when bash was using it to read a script, which modified the + parent's value as well. + +2. Changes to Readline + +a. Fixed a bug in vi mode that caused the arrow keys to set the saved last + vi-mode command to the wrong value. + +b. Fixed a bug that caused double-quoted strings to be scanned incorrectly + when being used as the value of a readline variable assignment. + +c. Fixed a bug with vi mode that prevented `.' from repeating a command + entered on a previous line (command). + +d. Fixed a bug that could cause completion to core dump if it was interrupted + by a signal. + +e. Readline now sends the meta-key enable string to the terminal if the + terminal has been successfully initialized. + +f. Readline now calls the signal hook after resizing the terminal when it + receives a SIGWINCH. + +g. Fixed a bug that could cause the history list code to perform an out-of- + bounds array reference if the history list is empty. + +3. New Features in Bash + +a. Shells started to run process substitutions now run any trap set on EXIT. + +b. There is now a configure-time option to enable the globasciiranges option + by default. + +c. The read builtin now checks its first variable argument for validity before + trying to read any input. + +------------------------------------------------------------------------------ +This document details the changes between this version, bash-4.3-alpha, +and the previous version, bash-4.2-release. + +1. Changes to Bash + +a. Fixed several bugs concerning incomplete bracket expressions in filename + generation (globbing) patterns. + +b. Fixed a bug with single quotes and WORD in ${param op WORD} when running + in Posix mode. + +c. Fixed a bug that caused the pattern removal and pattern substitution word + expansions and case statement word expansion to not match the empty string. + +d. Fixed a bug that caused the tzset() function to not work after changing + the TZ enviroment variable. + +e. Fixed a bug that caused the RHS of an assignment statement to undergo + word splitting when it contained an unquoted $@. + +f. Fixed bugs that caused the shell to not react to a SIGINT sent while + waiting for a child process to exit. + +g. Bash doesn't try to run things in a signal handler context when it gets a + signal (SIGINT/SIGHUP/etc) while reading input using readline but still + be responsive to terminating signals. + +h. Fixed a bug that caused bash to go into an infinite loop if a filename + to be matched contained an invalid multibyte character. + +i. Fixed a bug that caused PS4 to end up being truncated if it is longer + than 128 bytes. + +j. Fixed a bug that caused brace expansion to not skip over double-quoted + command substitution. + +k. System-specific updates for: DJGPP, HP/UX, Mac OS X + +l. Fixed a bug in displaying commands that caused redirections to be associated + with the wrong part of the command. + +m. Fixed the coproc cleanup to unset the appropriate shell variables when a + coproc terminates. + +n. Fixed a bug that caused `fc' to dump core due to incorrect calculation of + the last history entry. + +o. Added workarounds for FreeBSD's implementation of faccessat/eaccess and + `test -x'. + +p. Fixed a bug that caused the shell to not match patterns containing + control-A. + +q. Fixed a bug that could result in doubled error messages when the `printf' + builtin got a write error. + +r. Fixed a bug that caused the shell to not correctly expand words containing + multiple consecutive quoted empty strings (""""""aa). + +s. Fixed a bug that caused the shell to not correctly parse multi-line + process substitutions containing comments and quoted strings. + +t. Fixed a problem with the bash malloc's internal idea of the top of the + memory heap that resulted in incorrect decisions to try to reduce the + break and give memory back to the kernel. + +u. There are changes to the expansions peformed on compound array assignments, + in an effort to make foo=( [ind1]=bar [ind2]=baz ) identical to + foo[ind1]=bar foo[ind2]=baz. + +v. Bash now reports an error if `read -a name' is used when `name' is an + existing associative array. + +w. Fixed a bug that allowed an attempted assignment to a readonly variable + in an arithmetic expression to not return failure. + +x. Fixed several bugs that caused completion functions to be invoked even when + the cursor was before the first word in the command. + +y. Fixed a bug that caused parsing a command substitution to overwrite the + parsing state associated with the complete input line. + +z. Fixed several bugs with the built-in snprintf replacement and field widths + and floating point. + +aa. Fixed a bug that caused incorrect offset calculations and input buffer + corruption when reading files longer than 2^31 bytes. + +bb. Fixed several bugs where bash performed arithmetic evaluation in contexts + where evaluation is suppressed. + +cc. Fixed a bug that caused bash to close FIFOs used for process substitution + too early when a shell function was executing, but protect against using + all file descriptors when the shell functions are invoked inside loops. + +dd. Added checks for printable (and non-printable) multibyte characters for + use in error messages. + +ee. Fixed a bug that caused ^O (operate-and-get-next) to not work correctly + at the end of the history list. + +ff. Fixed a bug that caused command-oriented history to incorrectly combine + here documents into one line. + +gg. Fixed a bug that caused importing SHELLOPTS from the environment into a + Posix-mode shell to print an error message and refuse to parse it. + +hh. Fixed a bug that caused the shell to delete an extra history entry when + using `history -s'. + +ii. Fixed a bug that caused floating-point exceptions and overflow errors + for the / and % arithmetic operators when using INTMAX_MIN and -1. + +jj. Fixed a bug that caused parsing errors when reading an arithmetic for + loop inside a command substitution. + +kk. Fixed a bug that caused a readonly function to be unset when unset was + called without the -f or -v option. + +ll. Fixed several bugs in the code that quotes characters special to regular + expressions when used in a quoted string on the RHS of the =~ operator + to the [[ command. + +mm. Fixed a bug that caused redirections to fail because the file descriptor + limit was set to a value less than 10. + +nn. Fixed a bug that caused the `read' builtin to execute code in a signal + handler context if read timed out. + +oo. Fixed a bug that caused extended globbing patterns to not match files + beginning with `.' correctly when a `.' was explicitly supplied in the + pattern. + +pp. Fixed a bug that caused key sequences longer than two characters to not + work when used with `bind -x'. + +qq. Fixed a bug that resulted in redefined functions having the wrong source + file names in BASH_SOURCE. + +rr. Fixed a bug that caused the read builtin to assign null strings to variables + when using `read -N', which caused core dumps when referenced + +ss. Fixed a bug that caused `bash -m script' to not enable job control while + running the script. + +tt. Fixed a bug that caused `printf -v var' to dump core when used with the + %b format code. + +uu. Fixed a bug that caused the shell to exit with the wrong status if -e was + active and the shell exited on a substitution error. + +vv. Fixed a bug that caused the shell to seg fault if an array variable with + the same name as an existing associative array was implicitly created by + an assignment (declare a[n]=b). + +ww. Fixed a bug that caused a redirection to misbehave if the number specified + for a file descriptor overflows an intmax_t. + +xx. Fixed several bugs with the handling of valid and invalid unicode character + values when used with the \u and \U escape sequences to printf and $'...'. + +yy. Fixed a bug that caused tildes to not be escaped in expanded filenames, + making them subject to later expansion. + +zz. When using the pattern substitution word expansion, bash now runs the + replacement string through quote removal, since it allows quotes in that + string to act as escape characters. This is not backwards compatible, so + it can be disabled by setting the bash compatibility mode to 4.2. + +aaa. Fixed the rest of the cases where the shell runs non-allowed code in a + signal handler context. + +bbb. Fixed a bug that caused spurious DEL characters (\177) to appear in + double-quoted expansion where the RHS is evaluated to the empty string. + +ccc. Fixed a bug that caused the use of the shell's internal random number + generator for temporary file names to perturb the random number + sequence. + +ddd. Fixed several bugs that caused `declare -g' to not set the right global + variables or to misbehave when declaring global indexed arrays. + +eee. Fixed a logic bug that caused extended globbing in a multibyte locale to + cause failures when using the pattern substititution word expansions. + +fff. Fixed a bug that caused the `lastpipe' option to corrupt the file + descriptor used to read the script. + +ggg. Fixed a bug that causes the shell to delete DEL characters in the + expanded value of variables used in the same quoted string as variables + that expand to nothing. + +hhh. Fixed a bug that caused the shell to assign the wrong value from an + assignment like (( x=7 )) when `x' was an existing array variable. + +iii. Fixed a bug that caused the shell to misbehave when generating sequences + and the boundary values overflow an intmax_t. + +jjj. Fixed a bug caused expansion errors if an expansion of "$@" appeared + next to another expansion (e.g.. "${@}${x}"). + +kkk. Fixed a potential buffer overflow bug when performing /dev/fd expansion. + +lll. Fixed a bug that resulted in an extra semicolon being added to compound + assignments when they were added to the history list. + +mmm. Fixed a bug that caused mapfile to read one extra line from the input. + +nnn. Fixed a bug that caused the mail checking code to use uninitialized + values. + +ooo. Fixed a bug that prevented history timestamps from being saved if the + history comment character is unset. + +ppp. Fixed a bug that caused the case-modifying expansions to not work with + multibyte characters. + +qqq. Fixed a bug that caused the edit-and-execute bindable readline command + to see the wrong data if invoked in the middle of a multi-line quoted + string. + +rrr. Fixed a bug that resulted in the shell returning the wrong exit status + for a background command on systems that recycle PIDs very quickly. + +sss. Fixed a bug that caused asynchronous group commands to not run any EXIT + trap defined in the body of the command. + +ttt. Fixed a bug that caused `eval "... ; return"' to not clean up properly. + +uuu. Fixed a bug that caused the shell to dump core if `read' reads an escaped + IFS whitespace character. + +vvv. Fixed a bug that caused BASH_COMMAND to be set to an incorrect value when + executing a (...) subshell. + +www. Fixed a couple of pointer aliasing bugs with the token string in arithmetic + evaluation. + +xxx. Fixed a bug with parsing multi-line command substitutions when reading + the `do' keyword followed by whitespace. + +yyy. Fixed a bug that caused the shell to seg fault if the time given to the + printf %(...)T format overflowed the value accepted by localtime(3). + +zzz. Fixed a problem with displaying help topics in two columns when the + translated text contained multibyte characters. + +aaaa. Fixed a bug with the extended globbing pattern matcher where a `*' was + followed by a negated extended glob pattern. + +bbbb. Fixed a race condition with short-lived coproc creation and reaping that + caused the child process to be reaped before the various coproc shell + variables were initialized. + +cccc. Fixed a bug where turning off `errexit' in command substitution subshells + was not reflected in $SHELLOPTS. + +dddd. Partially fixed an inconsistency in how the shell treated shell + functions run from an EXIT trap. + +eeee. Fixed a bug in how the shell invalidated FIFOs used for process + substitution when executing a pipeline (once rather than in every child). + +ffff. Fixed a bug that occurred when expanding a special variable ($@, $*) + within double quotes and the expansion resulted in an empty string. + +gggg. Fixed bugs with executing a SIGCHLD trap handler to make sure that it's + executed once per exited child. + +hhhh. Fixed a bug that caused `declare' and `test' to find variables that + had been given attributes but not assigned values. Such variables are + not set. + +iiii. Fixed a bug that caused commands in process substitutions to not look in + the local temporary environment when performing word expansions. + +jjjj. Fixed several problems with globstar expansions (**/**) returning null + filenames and multiple instances of the same pathname. + +kkkk. Fixed an oversight that did not allow the exit status of `coproc' to + be inverted using `!'. + +llll. Fixed a bug that caused the -e option to be re-enabled using `set -e' + even when executing in a context where -e is ignored. + +mmmm. Fixed a (mostly theoretical) bug with input lines longer than SIZE_MAX. + +nnnn. Fixed a bug that could result in double evaluation of command + substitutions when they appear in failed redirections. + +oooo. Fixed a bug that could cause seg faults during `mapfile' callbacks if + the callback unsets the array variable mapfile is using. + +pppp. Fixed several problems with variable assignments using ${var:=value} + when the variable assignment is supposed to have side effects. + +qqqq. Fixed a bug that caused a failure of an assignment statement preceding a + builtin caused the next invocation of a special builtin to exit the shell. + +rrrr. Fixed several problems with IFS when it appears in the temporary environment + and is used in redirections. + +ssss. Fixed a problem that caused IFS changes using ${IFS:=value} to modify + how preceding expansions were split. + +tttt. Fixed a problem that caused subshells to not run an EXIT trap they set. + +uuuu. Fixed a problem that caused shells started in posix mode to attempt to + import shell functions with invalid names from the environment. We now + print a warning. + +vvvv. Worked around a kernel problem that caused SIGCHLD to interrupt open(2) + on a FIFO used for process substitution, even if the SIGCHLD handler was + installed with the SA_RESTART flag. + +wwww. Fixed a problem that resulted in inconsistent expansion of $* and ${a[*]}. + +xxxx. Fixed a problem that caused `read -t' to crash when interrupted by + SIGINT. + +yyyy. Fixed a problem that caused pattern removal to fail randomly because the + pattern matcher read beyond the end of a string. + +zzzz. Fixed a bug that caused core dumps when shell functions tried to create + local shadow copies of special variables like GROUPS. + +aaaaa. Fixed a bug that caused SIGTERM to be occasionally lost by children of + interactive shells when it arrived before the child process reset the + handler from SIG_DFL. + +bbbbb. Fixed a bug that caused redirections like <&n- to leave file descriptor + n closed if executed with a builtin command. + +ccccc. Fixed a bug that caused incorrect completion quoting when completing a + word containing a globbing character with `show-all-if-ambiguous' set. + +ddddd. Fixed a bug that caused printf's %q format specifier not to quote a + tilde even if it appeared in a location where it would be subject to + tilde expansion. + +2. Changes to Readline + +a. Fixed a bug that did not allow the `dd', `cc', or `yy' vi editing mode + commands to work on the entire line. + +b. Fixed a bug that caused redisplay problems with prompts longer than 128 + characters and history searches. + +c. Fixed a bug that caused readline to try and run code to modify its idea + of the screen size in a signal handler context upon receiving a SIGWINCH. + +d. Fixed a bug that caused the `meta' key to be enabled beyond the duration + of an individual call top readline(). + +e. Added a workaround for a wcwidth bug in Mac OS X that caused readline's + redisplay to mishandle zero-width combining characters. + +f. Fixed a bug that caused readline to `forget' part of a key sequence when + a multiple-key sequence caused it to break out of an incremental search. + +g. Fixed bugs that caused readline to execute code in a signal handler + context if interrupted while reading from the file system during completion. + +h. Fixed a bug that caused readline to `forget' part of a key sequence when + reading an unbound multi-character key sequence. + +i. Fixed a bug that caused Readline's signal handlers to be installed beyond + the bounds of a single call to readline(). + +j. Fixed a bug that caused the `.' command to not redo the most recent `R' + command in vi mode. + +k. Fixed a bug that caused ignoring case in completion matches to result in + readline using the wrong match. + +l. Paren matching now works in vi insert mode. + +m. Fix menu-completion to make show-all-if-ambiguous and menu-complete-display-prefix + work together. + +n. Fixed a bug that didn't allow the `cc', `dd', or `yy' commands to be redone + in vi editing mode. + +o. Fixed a bug that caused the filename comparison code to not compare + multibyte characters correctly when using case-sensitive or case-mapping + comparisons. + +p. Fixed the input reading loop to call the input hook function only when there + is no terminal input available. + +q. Fixed a bug that caused binding a macro to a multi-character key sequence + where the sequence and macro value share a common prefix to not perform + the macro replacement. + +r. Fixed several redisplay errors with multibyte characters and prompts + containing invisible characters when using horizontal scrolling. + +s. Fixed a bug that caused redisplay errors when trying to overwrite + existing characters using multibyte characters. + +3. New Features in Bash + +a. The `helptopic' completion action now maps to all the help topics, not just + the shell builtins. + +b. The `help' builtin no longer does prefix substring matching, so `help read' + does not match `readonly'. + +c. The shell can be compiled to not display a message about processes that + terminate due to SIGTERM. + +d. Non-interactive shells now react to the setting of checkwinsize and set + LINES and COLUMNS after a foreground job exits. + +e. There is a new shell option, `globasciiranges', which, when set to on, + forces globbing range comparisons to use character ordering as if they + were run in the C locale. + +f. There is a new shell option, `direxpand', which makes filename completion + expand variables in directory names in the way bash-4.1 did. + +g. In Posix mode, the `command' builtin does not change whether or not a + builtin it shadows is treated as an assignment builtin. + +h. The `return' and `exit' builtins accept negative exit status arguments. + +i. The word completion code checks whether or not a filename containing a + shell variable expands to a directory name and appends `/' to the word + as appropriate. The same code expands shell variables in command names + when performing command completion. + +j. In Posix mode, it is now an error to attempt to define a shell function + with the same name as a Posix special builtin. + +k. When compiled for strict Posix conformance, history expansion is disabled + by default. + +l. The history expansion character (!) does not cause history expansion when + followed by the closing quote in a double-quoted string. + +m. `complete' and its siblings compgen/compopt now takes a new `-o noquote' + option to inhibit quoting of the completions. + +n. Setting HISTSIZE to a value less than zero causes the history list to be + unlimited (setting it 0 zero disables the history list). + +o. Setting HISTFILESIZE to a value less than zero causes the history file size + to be unlimited (setting it to 0 causes the history file to be truncated + to zero size). + +p. The `read' builtin now skips NUL bytes in the input. + +q. There is a new `bind -X' option to print all key sequences bound to Unix + commands. + +r. When in Posix mode, `read' is interruptible by a trapped signal. After + running the trap handler, read returns 128+signal and throws away any + partially-read input. + +s. The command completion code skips whitespace and assignment statements + before looking for the command name word to be completed. + +t. The build process has a new mechanism for constructing separate help files + that better reflects the current set of compilation options. + +u. The -nt and -ot options to test now work with files with nanosecond + timestamp resolution. + +v. The shell saves the command history in any shell for which history is + enabled and HISTFILE is set, not just interactive shells. + +w. The shell has `nameref' variables and new -n(/+n) options to declare and + unset to use them, and a `test -R' option to test for them. + +x. The shell now allows assigning, referencing, and unsetting elements of + indexed arrays using negative subscripts (a[-1]=2, echo ${a[-1]}) which + count back from the last element of the array. + +y. The {x} operators to [[ do string comparisons using the current locale + only if the compatibility level is greater than 40 (set to 41 by default). + +4. New Features in Readline + +------------------------------------------------------------------------------ +This document details the changes between this version, bash-4.1-alpha, +and the previous version, bash-4.0-release. + +1. Changes to Bash + +a. Fixed bugs in the parser involving new parsing of the commands contained + in command substitution when the substitution is read. + +b. Fixed a bug that caused the shell to dump core when performing programmable + completion using a shell function. + +c. Fixed a bug in `mapfile' that caused it to invoke callbacks at the wrong + time. + +d. Fixed a bug that caused the shell to dump core when listing jobs in the + `exit' builtin. + +e. Fixed several bugs encountered when reading subscripts in associative + array assignments and expansions. + +f. Fixed a bug that under some circumstances caused an associative array to + be converted to an indexed array. + +g. Fixed a bug that caused syntax errors and SIGINT interrupts to not set + $? to a value > 128. + +h. Fixed a bug that caused the shell to remove FIFOs associated with process + substitution inside shell functions. + +i. Fixed a bug that caused terminal attributes to not be reset when the + `read' builtin timed out. + +j. Fixed a bug in brace expansion that caused unwanted zero padding of the + expanded terms. + +k. Fixed a bug that prevented the |& construct from working as intended when + used with a simple command with additional redirections. + +l. Fixed a bug with the case statment ;& terminator that caused the shell to + dereference a NULL pointer. + +m. Fixed a bug that caused assignment statements or redirections preceding + a simple command name to inhibit alias expansion. + +n. Fixed the behavior of `set -u' to conform to the latest Posix interpretation: + every expansion of an unset variable except $@ and $* will cause the + shell to exit. + +o. Fixed a bug that caused double-quoted expansions of $* inside word + expansions like ${x#$*} to not expand properly when $IFS is empty. + +p. Fixed a bug that caused traps to set $LINENO to the wrong value when they + execute. + +q. Fixed a bug that caused off-by-one errors when computing history lines in + the `fc' builtin. + +r. Fixed a bug that caused some terminating signals to not exit the shell + quickly enough, forcing the kernel to send the signal (e.g., SIGSEGV) + multiple times. + +s. Fixed a bug that caused the shell to attempt to add empty lines to the + history list when reading here documents. + +t. Made some internal changes that dramatically speeds up sequential indexed + array access. + +u. Fixed a bug that caused the shell to write past the end of a string when + completing a double-quoted string ending in a backslash. + +v. Fixed a bug that caused the shell to replace too many characters when a + pattern match was null in a ${foo//bar} expansion. + +w. Fixed bugs in the expansion of ** that caused duplicate directory names + and the contents of the current directory to be omitted. + +x. Fixed a bug that caused $? to not be set correctly when referencing an + unset variable with set -u and set -e enabled. + +y. Fixed a bug caused by executing an external program from the DEBUG trap + while a pipeline was running. The effect was to disturb the pipeline + state, occasionally causing it to hang. + +z. Fixed a bug that caused the ** glob expansion to dump core if it + encountered an unsearchable directory. + +aa. Fixed a bug that caused `command -v' and `command -V' to not honor the + path set by the -p option. + +bb. Fixed a bug that caused brace expansion to take place too soon in some + compound array assignments. + +cc. Fixed a bug that caused programmable completion functions' changes to + READLINE_POINT to not be reflected back to readline. + +dd. Fixed a bug that caused the shell to dump core if a trap was executed + during a shell assignment statement. + +ee. Fixed an off-by-one error when computing the number of positional + parameters for the ${@:0:n} expansion. + +ff. Fixed a problem with setting COMP_CWORD for programmable completion + functions that could leave it set to -1. + +gg. Fixed a bug that caused the ERR trap to be triggered in some cases where + `set -e' would not have caused the shell to exit. + +hh. Fixed a bug that caused changes made by `compopt' to not persist past the + completion function in which compopt was executed. + +ii. Fixed a bug that caused the list of hostname completions to not be cleared + when HOSTNAME was unset. + +jj. Fixed a bug that caused variable expansion in here documents to look in + any temporary environment. + +kk. Bash and readline can now convert file names between precomposed and + decomposed Unicode on Mac OS X ("keyboard" and file system forms, + respectively). This affects filename completion (using new + rl_filename_rewrite_hook), globbing, and readline redisplay. + +ll. The ERR and EXIT traps now see a non-zero value for $? when a parser + error after set -e has been enabled causes the shell to exit. + +mm. Fixed a bug that in brace expansion that caused zero-prefixed terms to + not contain the correct number of digits. + +nn. Fixed a bug that caused the shell to free non-allocated memory when + unsetting an associative array which had had a value implicitly assigned + to index "0". + +oo. Fixed a memory leak in the ${!prefix@} expansion. + +pp. Fixed a bug that caused printf to not correctly report all write errors. + +qq. Fixed a bug that caused single and double quotes to act as delimiters + when splitting a command line into words for programmable completion. + +rr. Fixed a bug that caused ** globbing that caused **/path/* to match every + directory, not just those matching `path'. + +ss. Fixed a bug that caused the shell to dump core when running `help' without + arguments if the terminal width was fewer than 7 characters. + +2. Changes to Readline + +a. The SIGWINCH signal handler now avoids calling the redisplay code if + one arrives while in the middle of redisplay. + +b. Changes to the timeout code to make sure that timeout values greater + than one second are handled better. + +c. Fixed a bug in the redisplay code that was triggered by a prompt + containing invisible characters exactly the width of the screen. + +d. Fixed a bug in the redisplay code encountered when running in horizontal + scroll mode. + +e. Fixed a bug that prevented menu completion from properly completing + filenames. + +f. Fixed a redisplay bug caused by a multibyte character causing a line to + wrap. + +g. Fixed a bug that caused key sequences of two characters to not be + recognized when a longer sequence identical in the first two characters + was bound. + +h. Fixed a bug that caused history expansion to be attempted on $'...' + single-quoted strings. + +i. Fixed a bug that caused incorrect redisplay when the prompt contained + multibyte characters in an `invisible' sequence bracketed by \[ and + \]. + +j. Fixed a bug that caused history expansion to short-circuit after + encountering a multibyte character. + +3. New Features in Bash + +a. Here-documents within $(...) command substitutions may once more be + delimited by the closing right paren, instead of requiring a newline. + +b. Bash's file status checks (executable, readable, etc.) now take file + system ACLs into account on file systems that support them. + +c. Bash now passes environment variables with names that are not valid + shell variable names through into the environment passed to child + processes. + +d. The `execute-unix-command' readline function now attempts to clear and + reuse the current line rather than move to a new one after the command + executes. + +e. `printf -v' can now assign values to array indices. + +f. New `complete -E' and `compopt -E' options that work on the "empty" + completion: completion attempted on an empty command line. + +g. New complete/compgen/compopt -D option to define a `default' completion: + a completion to be invoked on command for which no completion has been + defined. If this function returns 124, programmable completion is + attempted again, allowing a user to dynamically build a set of completions + as completion is attempted by having the default completion function + install individual completion functions each time it is invoked. + +h. When displaying associative arrays, subscripts are now quoted. + +i. Changes to dabbrev-expand to make it more `emacs-like': no space appended + after matches, completions are not sorted, and most recent history entries + are presented first. + +j. The [[ and (( commands are now subject to the setting of `set -e' and the + ERR trap. + +k. The source/. builtin now removes NUL bytes from the file before attempting + to parse commands. + +l. There is a new configuration option (in config-top.h) that forces bash to + forward all history entries to syslog. + +m. A new variable $BASHOPTS to export shell options settable using `shopt' to + child processes. + +n. There is a new confgure option that forces the extglob option to be + enabled by default. + +o. New variable $BASH_XTRACEFD; when set to an integer bash will write xtrace + output to that file descriptor. + +p. If the optional left-hand-side of a redirection is of the form {var}, the + shell assigns the file descriptor used to $var or uses $var as the file + descriptor to move or close, depending on the redirection operator. + +q. The < and > operators to the [[ conditional command now do string + comparison according to the current locale. + +r. Programmable completion now uses the completion for `b' instead of `a' + when completion is attempted on a line like: a $(b c. + +s. Force extglob on temporarily when parsing the pattern argument to + the == and != operators to the [[ command, for compatibility. + +t. Changed the behavior of interrupting the wait builtin when a SIGCHLD is + received and a trap on SIGCHLD is set to be Posix-mode only. + +u. The read builtin has a new `-N nchars' option, which reads exactly NCHARS + characters, ignoring delimiters like newline. + +4. New Features in Readline + +a. New bindable function: menu-complete-backward. + +b. In the vi insertion keymap, C-n is now bound to menu-complete by default, + and C-p to menu-complete-backward. + +c. When in vi command mode, repeatedly hitting ESC now does nothing, even + when ESC introduces a bound key sequence. This is closer to how + historical vi behaves. + +d. New bindable function: skip-csi-sequence. Can be used as a default to + consume key sequences generated by keys like Home and End without having + to bind all keys. + +e. New application-settable function: rl_filename_rewrite_hook. Can be used + to rewite or modify filenames read from the file system before they are + compared to the word to be completed. + +f. New bindable variable: skip-completed-text, active when completing in the + middle of a word. If enabled, it means that characters in the completion + that match characters in the remainder of the word are "skipped" rather + than inserted into the line. + +g. The pre-readline-6.0 version of menu completion is available as + "old-menu-complete" for users who do not like the readline-6.0 version. + +h. New bindable variable: echo-control-characters. If enabled, and the + tty ECHOCTL bit is set, controls the echoing of characters corresponding + to keyboard-generated signals. + +i. New bindable variable: enable-meta-key. Controls whether or not readline + sends the smm/rmm sequences if the terminal indicates it has a meta key + that enables eight-bit characters. + +------------------------------------------------------------------------------ +This document details the changes between this version, bash-4.0-release, +and the previous version, bash-4.0-rc1. + +1. Changes to Bash + +a. Changed the message printed when setlocale(3) fails to only include the + strerror error text if the call changes errno. + +b. Changed trap command execution to reset the line number before running a + trap (except DEBUG and RETURN traps). + +c. Fixed behavior of case-modifiying word expansions to not work on + individual words within a variable's value. + +d. Fixed a bug that caused mapfile to not be interruptible when run in an + interactive shell. + +e. Fixed a bug that caused mapfile to not run callbacks for the first line + read. + +f. Fixed a bug that caused mapfile to not honor EOF typed in an interactive + shell. + +g. Fixed the coprocess reaping code to not run straight from a signal handler. + +h. Fixed a bug that caused printf -b to ignore the first % conversion specifier + in the format string on 64-bit systems. + +i. Fixed a bug that caused incorrect word splitting when `:', `=', or `~' + appeared in $IFS. + +j. Fixed a bug that caused data corruption in the programmable completion code + when a shell function called from a completion aborted execution. + +k. Fixed a bug that caused the CPU usage reported by the `time' builtin to be + capped at 100%. + +l. Changed behavior of shell when -e option is in effect to reflect consensus + of Posix shell standardization working group. + +m. Fixed a bug introduced in bash-4.0-alpha that caused redirections to not + be displayed by `type' or `declare' when appearing in functions under + certain circumstances. + +2. Changes to Readline + +a. Fixed a bug that caused !(...) extended glob patterns to inhibit later + history expansion. + +b. Reworked the signal handling to avoid calling disallowed functions from a + signal handler. + +3. New Features in Bash + +a. `readarray' is now a synonym for `mapfile'. +------------------------------------------------------------------------------ +This document details the changes between this version, bash-4.0-rc1, +and the previous version, bash-4.0-beta2. + +1. Changes to Bash + +a. Fixed a bug that caused parsing errors when a $()-style command + substitution was follwed immediately by a quoted newline. + +b. Fixed a bug that caused extended shell globbing patterns beginning with + `*(' to not work when used with pattern substitution word expansions. + +------------------------------------------------------------------------------ +This document details the changes between this version, bash-4.0-beta2, +and the previous version, bash-4.0-beta. + +1. Changes to Bash + +a. Fixed a bug that caused failed word expansions to set $? but not + PIPESTATUS. + +b. Changed filename completion to quote the tilde in a filename with a + leading tilde that exists in the current directory. + +c. Fixed a bug that caused a file descriptor leak when performing + redirections attached to a compound command. + +d. Fixed a bug that caused expansions of $@ and $* to not exit the shell if + the -u option was enabled and there were no posititional parameters. + +e. Fixed a bug that resulted in bash not terminating immediately if a + terminating signal was received while performing output. + +f. Fixed a bug that caused the shell to crash after creating 256 process + substitutions during word completion. + +2. Changes to Readline + +a. Fixed a bug that caused redisplay errors when using prompts with invisible + characters and numeric arguments to a command in a multibyte locale. + +b. Fixed a bug that caused redisplay errors when using prompts with invisible + characters spanning more than two physical screen lines. + +------------------------------------------------------------------------------ +This document details the changes between this version, bash-4.0-beta, +and the previous version, bash-4.0-alpha. + +1. Changes to Bash + +a. Fixed a typo that caused a variable to be used before initialization + while parsing Posix-style command substitutions. + +b. Fixed a bug that caused stray ^? when the expansion of a parameter used + as part of a pattern removal expansion is empty, but part of a non- + empty string. + +c. Fixed a bug that could cause strings not converted to numbers by strtol + to be treated as if the conversion had been successful. + +d. The `return' builtin now accepts no options and requires a `--' before + a negative return value, as Posix requires. + +e. Fixed a bug that caused local variables to be created with the empty + string for a value rather than no value. + +f. Changed behavior so the shell now acts as if it received an interrupt + when a pipeline is killed by SIGINT while executing a list. + +g. Fixed a bug that caused `declare var' and `typeset var' to initialize + `var' to the empty string. + +h. Changed `bind' builtin to print a warning but proceed if invoked when + line editing is not active. + +i. Fixed a bug that caused the shell to exit when the `errexit' option is + set and a command in a pipeline returns a non-zero exit status. + +j. Fixed a bug that caused the shell to not run the exit trap in a command + run with `bash -c' under some circumstances. + +k. Fixed a bug that caused parser errors to occasionally not set $? when + running commands with `eval'. + +l. Fixed a bug that caused stray control characters when evaluating compound + array assignments containing $'\x7f' escapes. + +m. Fixed a bug that caused redirections involving file descriptor 10 as the + target to behave incorrectly. + +n. Fixed a bug that could cause memory to be freed multiple times when + assigning to COMP_WORDBREAKS. + +o. Fixed a bug that could cause NULL pointer dereferences when COMP_WORDBREAKS + was unset. + +2. Changes to Readline + +3. New Features in Bash + +a. A value of 0 for the -t option to `read' now returns success if there is + input available to be read from the specified file descriptor. + +b. CDPATH and GLOBIGNORE are ignored when the shell is running in privileged + mode. + +c. New bindable readline functions shell-forward-word and shell-backward-word, + which move forward and backward words delimited by shell metacharacters + and honor shell quoting. + +d. New bindable readline functions shell-backward-kill-word and shell-kill-word + which kill words backward and forward, but use the same word boundaries + as shell-forward-word and shell-backward-word. + +4. New Features in Readline + +a. If the kernel supports it, readline displays special characters + corresponding to a keyboard-generated signal when the signal is received. + +------------------------------------------------------------------------------ +This document details the changes between this version, bash-4.0-alpha, +and the previous version, bash-3.2-release. + +1. Changes to Bash + +a. Fixed several bugs in old-style `` command substitution parsing, including + comment parsing and quoted string handling. + +b. Fixed problems parsing arguments to the [[ command's =~ regular expression + matching operator: metacharacter and whitespace parsing. + +c. Fixed a bug that caused the shell to inappropriately reuse high-numbered + file descriptors it used internally. + +d. Fixed a bug in pattern replacement word expansions that caused a `/' as + the first character of an expanded pattern to be mistaken for a global + replacement specifier. + +e. Fixed several problems with the asprintf and snprintf replacement functions + that caused hangs and crashes. + +f. Fixed a bug in the calculation of the current and previous job that caused + it to refer to incorrect jobs. + +g. Fixed a bug in the check for the validity of a hashed command pathname that + caused unnecessary hash table deletions and additions. + +h. Fixed a bug that caused child processes to inherit the wrong value for $!. + +i. Fixed a bug that caused `.' to fail to read and execute commands from non- + regular files such as devices or named pipes. + +j. Fixed a bug in printf formatting for the %x and %X expansions that occurred + on some systems. + +k. Fixed a bug that caused the shell to crash when creating temporary files if + $TMPDIR named a non-writable directory. + +l. Fixed a bug that caused the shell to ignore $TMPDIR when creating temporary + files under some circumstances. + +m. Fixed a bug that caused named pipes created by process substitution to not + be cleaned up. + +n. Fixed a bug that caused HISTTIMEFORMAT to not be honored when it appeared + in the initial shell environment. + +o. Fixed several bugs in the expansion of $* and $@ (quoted and unquoted) + when IFS is null or contains non-whitespace characters; the same changes + apply to arrays subscripted with * or @. + +p. Fixed several problems with pattern substitution expansions on the + positional parameters and arrays subscripted with * or @ that occurred + when $IFS was set to the empty string. + +q. Made a change to the default locale initialization code that should + result in better behavior from the locale-aware library functions. + +r. Fixed a bug that caused compacting the jobs list to drop jobs. + +s. Fixed a bug that caused jumps back to the top-level processing loop from + a builtin command to leave the shell in an inconsistent state. + +t. Fixed a bug that caused characters that would be escaped internally to be + doubled when escaped with a backslash. + +u. Fixed the initialization of mailboxes to not cause maildirs to be read + (and stat(2) called for every message file) at shell startup. + +v. Fixed a bug that caused the shell to not display $PS2 when the read builtin + reads a line continued with a backslash. + +w. Fixed a bug that caused errors in word splitting when $IFS contained + characters used for internal quoting. + +x. Fixed bugs that caused problems with output from shell builtins not being + completely displayed on some systems. + +y. Fixed a bug that caused output to be lost when a redirection is acting on + the shell's output file descriptor. + +z. Fixed bugs caused by shell builtins not checking for all write errors. + +aa. Fixed a problem that caused the shell to dump core if expansions on the + pattern passed to the pattern removal word expansions resulted in expansion + errors. + +bb. Fixed a bug that caused bash to loop infinitely after creating and + waiting for 4096 jobs. + +cc. Fixed a bug that caused bash to lose the status of a background job under + certain circumstances. + +dd. Fixed a bug that caused bash to not look in the temporary environment + when performing variable lookup under certain circumstances. + +ee. Fixed a bug that caused bash to close file descriptors greater than 10 + when they were used in redirections. + +ff. Fixed a problem that caused the shell to attempt to read from the standard + input when called as `bash -i script'. + +gg. Fixed a memory leak and variable initialization problems when the -v option + was supplied to `printf' that could cause incorrect results. + +hh. Fixed a bug that caused the `read' builtin to count bytes when the -n option + was supplied, rather than (possibly multibyte) characters. + +ii. Fixed a bug when displaying a function due to not converting the function + to an external form. + +jj. Changed job control initialization to ensure that the shell has a tty + as its controlling terminal before enabling job control. + +kk. Fixed a bug with the `test' builtin that caused it to misinterpret + arguments beginning with `-' but containing more than one character. + +ll. Fixed bug that could cause the shell to dump core in certain cases where + a command sets the SIGINT disposition to the default. + +mm. Fixed a bug in the pattern replacement (affecting both word expansion + and the `fc' builtin) that occurred when the pattern and replacement + strings were empty. + +nn. Fixed a bug that caused an arithmetic evaluation error to disable all + further evaluation. + +oo. Fixed a bug in pathname expansion that caused it to interpret backslashes + in the pathname as quoting characters. + +pp. Fixed a bug in the replacement getcwd() implementation that could cause + memory to be overwritten. + +qq. When in Posix mode, the `ulimit' builtin now uses a block size of 512 for + the `-c' and `-f' options. + +rr. Brace expansion now allows process substitutions to pass through unchanged. + +ss. Fixed a problem in the command name completion code to avoid quoting + escaped special characters twice when the command name begins with a tilde. + +tt. Fixed a problem in the printf builtin that resulted in single-byte + output for the "'" escape, even when using multibyte characters. + +uu. Fixed a bug that caused the failure exit status to be lost when redirections + attached to a compound command failed. + +vv. Fixed a bug that caused the internal random number generator to not be + re-seeded correctly when creating a subshell. + +ww. Fixed a bug that could cause the bash replacement getcwd to overwrite + memory. + +xx. Fixed a bug that caused the shell to not receive SIGINT if it was sent + while the shell was waiting for a command substitution to terminate, and + make sure the exit status is correct when it does. + +yy. Fixed a bug that resulted in the second and subsequent children spawned + by a shell begun to run a command substitution being placed into the + wrong process group. + +zz. Fixed a bug that caused the results of successful tilde expansion to be + subject to pathname expansion and word splitting. + +aaa. Fixed a bug that could cause the shell to hang if it encountered an + error that caused it to jump back to the top processing loop during a + command substitution or `eval' command. + +bbb. Fixed a bug that caused the `read' builtin to use the tty's attributes + instead of those of the file descriptor passed with the -u option when + processing the -n and -d options. + +ccc. Fixed a bug that caused incorrect expansion of ${array[@]:foo} if the + first character of $IFS was not whitespace. + +ddd. Fixed a bug that occurred when scanning for the ending delimiter of a + ${parameter/pat/sub} expansion. + +eee. Fixed a bug that caused the shell to inappropriately expand command + substitutions in words when expanding directory names for completion. + +fff. Fixed a bug that caused the `fc' builtin to look too far back in the + history list under certain circumstances. + +ggg. Fixed a bug that caused a shell running in Posix mode to search $PWD for + a file specified as an argument to source/. when the file was not found + in $PATH. + +hhh. Fixed a bug that caused the shell to modify the case of a command word + found via command completion when the shell was performing case- + insensitive completion. + +iii. Fixed a bug that caused the shell to search $PATH for an argument to + source/. even when it contained a `/'. + +jjj. Fixed a bug that caused brace expansion to misorder expansions when the + locale did not have a collating order like aAbBcC...zZ. + +kkk. Fixed a bug that did not allow `set +o history' to have any effect when + run in a startup file or from a sourced file. + +lll. Fixed a bug with the precedence of the ?: conditional arithmetic operator. + +mmm. Fixed a bug that caused side effects of temporary variable assignments + to persist in the shell environment. + +nnn. Fixed a bug that caused the terminal to be left in non-canonical mode + when using editing commands that invoke the an editor on the current + command line. + +ooo. Fixed a bug that caused globbing characters and characters in $IFS to not + be quoted appropriately when displaying assignment statements. + +ppp. Fixed a bug that caused the `-e' option to be inherited when sourcing a + file or evaluating a command with `eval' even if the return value of the + command was supposed to be ignored. + +qqq. Fixed a bug that caused the shell to attempt to created variables with + invalid names if such names appeared in the initial environment. + +rrr. Fixed a bug with quote removal in strings where the final character is a + backslash. + +sss. Fixed a bug that caused the effects of special variables to persist even + when the variables were unset as part of the shell reinitializing itself + to execute a shell script. + +ttt. Fixed a bug that caused the history to not be saved after `history -c' or + `history -d' was executed until a sufficient number of commands had been + saved to the history. + +uuu. Bash now parses command substitutions according to Posix rules: parsing + the command contained in $() to find the closing delimiter. + +vvv. Fixed a bug that caused traps on SIGCHLD set in a SIGCHLD handler to + not persist. + +www. Fixed a bug that didn't allow SIGCHLD to interrupt the `wait' builtin + as Posix specifies. + +xxx. Invalid numeric arguments to shell builtins no longer cause the shell to + short-circuit any executing compound command. + +yyy. Fixed a bug that caused the exit status to be lost when `break' was + used to short-circuit a loop's execution. + +zzz. Fixed a bug that caused stray ^? characters to be left in expansions of + "${array[*]}". + +aaaa. Bash now prints better error messages for here documents terminated by + EOF and for identifying the incorrect token in an invalid arithmetic + expression. + +bbbb. Fixed a bug in the variable length word expansion that caused it to + incorrectly calculate the number of multibyte characters. + +cccc. Fixed a race condition that could result in the top-level shell setting + the terminal's process group to an incorrect value if the process + group was changed by a child of a child of the shell. + +dddd. Fixed a bug that caused here documents belonging to commands within a + compound command to be displayed in a syntactially-incorrect form, which + prevented them from being re-read as input. + +eeee. The shell displays more warnings about failures to set the locale. + +ffff. Fixed a bug that caused the body of a here-document to not be saved to + the history list. + +gggg. Fixed a bug that caused configure to incorrectly conclude that FreeBSD + had /dev/fd available, resulting in problems with process substitution. + +2. Changes to Readline + +a. Fixed a number of redisplay errors in environments supporting multibyte + characters. + +b. Fixed bugs in vi command mode that caused motion commands to inappropriately + set the mark. + +c. When using the arrow keys in vi insertion mode, readline allows movement + beyond the current end of the line (unlike command mode). + +d. Fixed bugs that caused readline to loop when the terminal has been taken + away and reads return -1/EIO. + +e. Fixed bugs in redisplay occurring when displaying prompts containing + invisible characters. + +f. Fixed a bug that caused the completion append character to not be reset to + the default after an application-specified completion function changed it. + +g. Fixed a problem that caused incorrect positioning of the cursor while in + emacs editing mode when moving forward at the end of a line while using + a locale supporting multibyte characters. + +h. Fixed an off-by-one error that caused readline to drop every 511th + character of buffered input. + +i. Fixed a bug that resulted in SIGTERM not being caught or cleaned up. + +j. Fixed redisplay bugs caused by multiline prompts with invisible characters + or no characters following the final newline. + +k. Fixed redisplay bug caused by prompts consisting solely of invisible + characters. + +l. Fixed a bug in the code that buffers characters received very quickly in + succession which caused characters to be dropped. + +m. Fixed a bug that caused readline to reference uninitialized data structures + if it received a SIGWINCH before completing initialzation. + +n. Fixed a bug that caused the vi-mode `last command' to be set incorrectly + and therefore unrepeatable. + +o. Fixed a bug that caused readline to disable echoing when it was being used + with an output file descriptor that was not a terminal. + +p. Readline now blocks SIGINT while manipulating internal data structures + during redisplay. + +q. Fixed a bug in redisplay that caused readline to segfault when pasting a + very long line (over 130,000 characters). + +r. Fixed bugs in redisplay when using prompts with no visible printing + characters. + +3. New Features in Bash + +a. When using substring expansion on the positional parameters, a starting + index of 0 now causes $0 to be prefixed to the list. + +b. The `help' builtin now prints its columns with entries sorted vertically + rather than horizontally. + +c. There is a new variable, $BASHPID, which always returns the process id of + the current shell. + +d. There is a new `autocd' option that, when enabled, causes bash to attempt + to `cd' to a directory name that is supplied as the first word of a + simple command. + +e. There is a new `checkjobs' option that causes the shell to check for and + report any running or stopped jobs at exit. + +f. The programmable completion code exports a new COMP_TYPE variable, set to + a character describing the type of completion being attempted. + +g. The programmable completion code exports a new COMP_KEY variable, set to + the character that caused the completion to be invoked (e.g., TAB). + +h. If creation of a child process fails due to insufficient resources, bash + will try again several times before reporting failure. + +i. The programmable completion code now uses the same set of characters as + readline when breaking the command line into a list of words. + +j. The block multiplier for the ulimit -c and -f options is now 512 when in + Posix mode, as Posix specifies. + +k. Changed the behavior of the read builtin to save any partial input received + in the specified variable when the read builtin times out. This also + results in variables specified as arguments to read to be set to the empty + string when there is no input available. When the read builtin times out, + it returns an exit status greater than 128. + +l. The shell now has the notion of a `compatibility level', controlled by + new variables settable by `shopt'. Setting this variable currently + restores the bash-3.1 behavior when processing quoted strings on the rhs + of the `=~' operator to the `[[' command. + +m. The `ulimit' builtin now has new -b (socket buffer size) and -T (number + of threads) options. + +n. The -p option to `declare' now displays all variable values and attributes + (or function values and attributes if used with -f). + +o. There is a new `compopt' builtin that allows completion functions to modify + completion options for existing completions or the completion currently + being executed. + +p. The `read' builtin has a new -i option which inserts text into the reply + buffer when using readline. + +q. A new `-E' option to the complete builtin allows control of the default + behavior for completion on an empty line. + +r. There is now limited support for completing command name words containing + globbing characters. + +s. Changed format of internal help documentation for all builtins to roughly + follow man page format. + +t. The `help' builtin now has a new -d option, to display a short description, + and a -m option, to print help information in a man page-like format. + +u. There is a new `mapfile' builtin to populate an array with lines from a + given file. + +v. If a command is not found, the shell attempts to execute a shell function + named `command_not_found_handle', supplying the command words as the + function arguments. + +w. There is a new shell option: `globstar'. When enabled, the globbing code + treats `**' specially -- it matches all directories (and files within + them, when appropriate) recursively. + +x. There is a new shell option: `dirspell'. When enabled, the filename + completion code performs spelling correction on directory names during + completion. + +y. The `-t' option to the `read' builtin now supports fractional timeout + values. + +z. Brace expansion now allows zero-padding of expanded numeric values and + will add the proper number of zeroes to make sure all values contain the + same number of digits. + +aa. There is a new bash-specific bindable readline function: `dabbrev-expand'. + It uses menu completion on a set of words taken from the history list. + +bb. The command assigned to a key sequence with `bind -x' now sets two new + variables in the environment of the executed command: READLINE_LINE_BUFFER + and READLINE_POINT. The command can change the current readline line + and cursor position by modifying READLINE_LINE_BUFFER and READLINE_POINT, + respectively. + +cc. There is a new &>> redirection operator, which appends the standard output + and standard error to the named file. + +dd. The parser now understands `|&' as a synonym for `2>&1 |', which redirects + the standard error for a command through a pipe. + +ee. The new `;&' case statement action list terminator causes execution to + continue with the action associated with the next pattern in the + statement rather than terminating the command. + +ff. The new `;;&' case statement action list terminator causes the shell to + test the next set of patterns after completing execution of the current + action, rather than terminating the command. + +gg. The shell understands a new variable: PROMPT_DIRTRIM. When set to an + integer value greater than zero, prompt expansion of \w and \W will + retain only that number of trailing pathname components and replace + the intervening characters with `...'. + +hh. There are new case-modifying word expansions: uppercase (^[^]) and + lowercase (,[,]). They can work on either the first character or + array element, or globally. They accept an optional shell pattern + that determines which characters to modify. There is an optionally- + configured feature to include capitalization operators. + +ii. The shell provides associative array variables, with the appropriate + support to create, delete, assign values to, and expand them. + +jj. The `declare' builtin now has new -l (convert value to lowercase upon + assignment) and -u (convert value to uppercase upon assignment) options. + There is an optionally-configurable -c option to capitalize a value at + assignment. + +kk. There is a new `coproc' reserved word that specifies a coprocess: an + asynchronous command run with two pipes connected to the creating shell. + Coprocs can be named. The input and output file descriptors and the + PID of the coprocess are available to the calling shell in variables + with coproc-specific names. + +4. New Features in Readline + +a. A new variable, rl_sort_completion_matches; allows applications to inhibit + match list sorting (but beware: some things don't work right if + applications do this). + +b. A new variable, rl_completion_invoking_key; allows applications to discover + the key that invoked rl_complete or rl_menu_complete. + +c. The functions rl_block_sigint and rl_release_sigint are now public and + available to calling applications who want to protect critical sections + (like redisplay). + +d. The functions rl_save_state and rl_restore_state are now public and + available to calling applications; documented rest of readline's state + flag values. + +e. A new user-settable variable, `history-size', allows setting the maximum + number of entries in the history list. + +f. There is a new implementation of menu completion, with several improvements + over the old; the most notable improvement is a better `completions + browsing' mode. + +g. The menu completion code now uses the rl_menu_completion_entry_function + variable, allowing applications to provide their own menu completion + generators. + +h. There is support for replacing a prefix of a pathname with a `...' when + displaying possible completions. This is controllable by setting the + `completion-prefix-display-length' variable. Matches with a common prefix + longer than this value have the common prefix replaced with `...'. + +i. There is a new `revert-all-at-newline' variable. If enabled, readline will + undo all outstanding changes to all history lines when `accept-line' is + executed. + +------------------------------------------------------------------------------ +This document details the changes between this version, bash-3.2-release, +and the previous version, bash-3.2-beta. + +1. Changes to Bash + +a. Fixed a bug that caused the temporary environment passed to a command to + affect the shell's environment under certain circumstances. + +b. Fixed a bug in the printf builtin that caused the %q format specifier to + ignore empty string arguments. + +c. Improved multibyte character environment detection at configuration time. + +d. Fixed a bug in the read builtin that left spurious escape characters in the + input after processing backslashes when assigning to an array variable. + +2. Changes to Readline + +a. Fixed a redisplay bug that occurred in multibyte-capable locales when the + prompt was one character longer than the screen width. +------------------------------------------------------------------------------ +This document details the changes between this version, bash-3.2-beta, +and the previous version, bash-3.2-alpha. + +1. Changes to Bash + +a. Changed the lexical analyzer to treat locale-specific blank characters as + white space. + +b. Fixed a bug in command printing to avoid confusion between redirections and + process substitution. + +c. Fixed problems with cross-compiling originating from inherited environment + variables. + +d. Added write error reporting to printf builtin. + +e. Fixed a bug in the variable expansion code that could cause a core dump in + a multi-byte locale. + +f. Fixed a bug that caused substring expansion of a null string to return + incorrect results. + +g. BASH_COMMAND now retains its previous value while executing commands as the + result of a trap, as the documentation states. + +2. Changes to Readline + +a. Fixed a bug with prompt redisplay in a multi-byte locale to avoid redrawing + the prompt and input line multiple times. + +b. Fixed history expansion to not be confused by here-string redirection. + +c. Readline no longer treats read errors by converting them to newlines, as + it does with EOF. This caused partial lines to be returned from readline(). + +------------------------------------------------------------------------------ +This document details the changes between this version, bash-3.2-alpha, +and the previous version, bash-3.1-release. + +1. Changes to Bash + +a. Fixed a source bug that caused the minimal configuration to not compile. + +b. Fixed memory leaks in error handling for the `read' builtin. + +c. Changed the [[ and (( compound commands to set PIPESTATUS with their exit + status. + +d. Fixed some parsing problems with compound array assignments. + +e. Added additional configuration changes for: NetBSD (incomplete multibyte + character support) + +f. Fixed two bugs with local array variable creation when shadowing a variable + of the same name from a previous context. + +g. Fixed the `read' builtin to restore the correct set of completion functions + if a timeout occurs. + +h. Added code to defer the initialization of HISTSIZE (and its stifling of the + history list) until the history file is loaded, allowing a startup file to + override the default value. + +i. Tightened up the arithmetic expression parsing to produce better error + messages when presented with invalid operators. + +j. Fixed the cross-compilation support to build the signal list at shell + invocation rather than compile time if cross-compiling. + +k. Fixed multibyte support for non-gcc compilers (or compilers that do not + allow automatic array variable sizing based on a non-constant value). + +l. Several fixes to the code that manages the list of terminated jobs and + their exit statuses, and the list of active and recently-terminated jobs + to avoid pid aliasing/wraparound and allocation errors. + +m. Fixed a problem that allowed scripts to die due to SIGINT while waiting + for children, even when started in the background or otherwise ignoring + SIGINT. + +n. Fixed a bug that caused shells invoked as -/bin/bash from not being + recognized as login shells. + +o. Fixed a problem that caused shells in the background to give the terminal + to a process group other than the foreground shell process group. + +p. Fixed a problem with extracting the `varname' in ${#varname}. + +q. Fixed the code that handles SIGQUIT to not exit immediately -- thereby + calling functions that may not be called in a signal handler context -- + but set a flag and exit afterward (like SIGINT). + +r. Changed the brace expansion code to skip over braces that don't begin a + valid matched brace expansion construct. + +s. Fixed `typeset' and `declare' to not require that their shell function + operands to be valid shell identifiers. + +t. Changed `test' to use access(2) with a temporary uid/euid swap when testing + file attributes and running setuid, and access(2) in most other cases. + +u. Changed completion code to not attempt command name completion on a line + consisting solely of whitespace when no_empty_command_completion is set. + +v. The `hash' builtin now prints nothing in posix mode when the hash table is + empty, and prints a message to that effect to stdout instead of stderr + when not in posix mode. + +w. Fixed a bug in the extended pattern matching code that caused it to fail to + match periods with certain patterns. + +x. Fixed a bug that caused the shell to dump core when performing filename + generation in directories with thousands of files. + +y. Returned to the original Bourne shell rules for parsing ``: no recursive + parsing of embedded quoted strings or ${...} constructs. + +z. The inheritence of the DEBUG, RETURN, and ERR traps is now dependent only + on the settings of the `functrace' and `errtrace' shell options, rather + than whether or not the shell is in debugging mode. + +aa. Fixed a problem with $HOME being converted to ~ in the expansion of + members of the DIRSTACK array. + +bb. Fixed a problem with quoted arguments to arithmetic expansions in certain + constructs. + +cc. The command word completion code now no longer returns matching directories + while searching $PATH. + +dd. Fixed a bug with zero-padding and precision handling in snprintf() + replacement. + +ee. Fixed a bug that caused the command substitution code not to take embedded + shell comments into account. + +ff. Fixed a bug that caused $((...);(...)) to be misinterpreted as an + arithmetic substitution. + +gg. Fixed a bug in the prompt expansion code that inappropriately added a + \001 before a \002 under certain circumstances. + +hh. Fixed a bug that caused `unset LANG' to not properly reset the locale + (previous versions would set the locale back to what it was when bash + was started rather than the system's "native" locale). + +ii. Fixed a bug that could cause file descriptors > 10 to not be closed even + when closed explicitly by a script. + +jj. Fixed a bug that caused single quotes to be stripped from ANSI-C quoting + inside double-quoted command substitutions. + +kk. Fixed a bug that could cause core dumps when `return' was executed as the + last element of a pipeline inside a shell function. + +ll. Fixed a bug that caused DEBUG trap strings to overwrite commands stored in + the jobs list. + +2. Changes to Readline + +a. Fixed a problem that caused segmentation faults when using readline in + callback mode and typing consecutive DEL characters on an empty line. + +b. Fixed several redisplay problems with multibyte characters, all having to + do with the different code paths and variable meanings between single-byte + and multibyte character redisplay. + +c. Fixed a problem with key sequence translation when presented with the + sequence \M-\C-x. + +d. Fixed a problem that prevented the `a' command in vi mode from being + undone and redone properly. + +e. Fixed a problem that prevented empty inserts in vi mode from being undone + properly. + +f. Fixed a problem that caused readline to initialize with an incorrect idea + of whether or not the terminal can autowrap. + +g. Fixed output of key bindings (like bash `bind -p') to honor the setting of + convert-meta and use \e where appropriate. + +h. Changed the default filename completion function to call the filename + dequoting function if the directory completion hook isn't set. This means + that any directory completion hooks need to dequote the directory name, + since application-specific hooks need to know how the word was quoted, + even if no other changes are made. + +i. Fixed a bug with creating the prompt for a non-interactive search string + when there are non-printing characters in the primary prompt. + +j. Fixed a bug that caused prompts with invisible characters to be redrawn + multiple times in a multibyte locale. + +k. Fixed a bug that could cause the key sequence scanning code to return the + wrong function. + +l. Fixed a problem with the callback interface that caused it to fail when + using multi-character keyboard macros. + +m. Fixed a bug that could cause a core dump when an edited history entry was + re-executed under certain conditions. + +n. Fixed a bug that caused readline to reference freed memory when attmpting + to display a portion of the prompt. + +3. New Features in Bash + +a. Changed the parameter pattern replacement functions to not anchor the + pattern at the beginning of the string if doing global replacement - that + combination doesn't make any sense. + +b. When running in `word expansion only' mode (--wordexp option), inhibit + process substitution. + +c. Loadable builtins now work on MacOS X 10.[34]. + +d. Shells running in posix mode no longer set $HOME, as POSIX requires. + +e. The code that checks for binary files being executed as shell scripts now + checks only for NUL rather than any non-printing character. + +f. Quoting the string argument to the [[ command's =~ operator now forces + string matching, as with the other pattern-matching operators. + +4. New Features in Readline + +a. Calling applications can now set the keyboard timeout to 0, allowing + poll-like behavior. + +b. The value of SYS_INPUTRC (configurable at compilation time) is now used as + the default last-ditch startup file. + +c. The history file reading functions now allow windows-like \r\n line + terminators. + +------------------------------------------------------------------------------ +This document details the changes between this version, bash-3.1-release, +and the previous version, bash-3.1-rc2. + +1. Changes to Readline + +a. Several changes to the multibyte redisplay code to fix problems with + prompts containing invisible characters. + +------------------------------------------------------------------------------ +This document details the changes between this version, bash-3.1-rc2, +and the previous version, bash-3.1-rc1. + +1. Changes to Bash + +a. Fixed a bug that caused a DEBUG trap to overwrite a command string that's + eventually attached to a background job. + +b. Changed some code so that filenames with leading tildes with spaces in the + name aren't tilde-expanded by the bash completion code. + +c. Fixed a bug that caused the pushd builtin to fail to change to + directories with leading `-'. + +d. Fixed a small memory leak in the programmable completion code. + +2. Changes to Readline + +a. Fixed a redisplay bug caused by moving the cursor vertically to a line + with invisible characters in the prompt in a multibyte locale. + +b. Fixed a bug that could cause the terminal special chars to be bound in the + wrong keymap in vi mode. + +3. New Features in Bash + +a. If compiled for strict POSIX conformance, LINES and COLUMNS may now + override the true terminal size. + +4. New Features in Readline + +a. A new external application-controllable variable that allows the LINES + and COLUMNS environment variables to set the window size regardless of + what the kernel returns. + +------------------------------------------------------------------------------ +This document details the changes between this version, bash-3.1-rc1, +and the previous version, bash-3.1-beta1. + +1. Changes to Bash + +a. Fixed a bug that could cause core dumps due to accessing the current + pipeline while in the middle of modifying it. + +b. Fixed a bug that caused pathnames with backslashes still quoting characters + to be passed to opendir(). + +c. Command word completion now obeys the setting of completion-ignore-case. + +d. Fixed a problem with redirection that caused file descriptors greater than + 2 to be inappropriately marked as close-on-exec. + +e. In Posix mode, after `wait' is called to wait for a particular process + explicitly, that process is removed from the list of processes known to + the shell, and subsequent attempts to wait for it return errors. + +f. Fixed a bug that caused extended pattern matching to incorrectly scan + backslash-escaped pattern characters. + +g. Fixed a synchronization problem that could cause core dumps when handling + a SIGWINCH. + +h. Fixed a bug that caused an unmatched backquote to be accepted without an + error when processing here documents. + +i. Fixed a small memory leak in the `cd' builtin. + +j. Fix for MacOS X so it gets the values for the HOSTTYPE, MACHTYPE, and + OSTYPE variables at build time, to support universal binaries. + +k. Fixed a bug that could cause an exit trap to return the exit status of + the trap command rather than the status as it was before the trap was + run as the shell's exit status. + +2. New Features in Bash + +3. Changes to Readline + +a. Fixed a bug that caused reversing the incremental search direction to + not work correctly. + +b. Fixed the vi-mode `U' command to only undo up to the first time insert mode + was entered, as Posix specifies. + +c. Fixed a bug in the vi-mode `r' command that left the cursor in the wrong + place. + +4. New Features in Readline + +a. New application-callable auxiliary function, rl_variable_value, returns + a string corresponding to a readline variable's value. + +b. When parsing inputrc files and variable binding commands, the parser + strips trailing whitespace from values assigned to boolean variables + before checking them. + + +------------------------------------------------------------------------------ +This document details the changes between this version, bash-3.1-beta1, +and the previous version, bash-3.1-alpha1. + +1. Changes to Bash + +a. Added some system-specific signal names. + +b. Fixed a typo in the ulimit builtin to make `x' the right option to + maniuplate the limit on file locks. + +c. Fixed a problem with using += to append to index 0 of an array variable + when not using subscript syntax. + +d. A few changes to configure.in to remove calls to obsolete or outdated + macros. + +e. Make sure changes to variables bash handles specially (e.g., LC_ALL) are + made when the variable is set in the temporary environment to a command. + +f. Make sure changes to variables bash handles specially (e.g., LC_ALL) are + made when the variable is modified using `printf -v'. + +g. The export environment is now remade on cygwin when HOME is changed, so + DLLs bash is linked against pick up the new value. This fixes problems + with tilde expansion when linking against and already-installed readline. + +h. Small fix to the logic for performing tilde expansion in posix mode, so + expansion on the right-hand side of an assignment statement takes place. + +i. Fixed a bug that prevented redirections associated with a shell function + from being executed when in a subshell. + +j. Fixed `source' and `.' builtins to not require an executable file when + searching $PATH for a file to source. + +k. Fixed a bug that caused incorrect word splitting in a function when IFS + was declared local, then unset. + +l. Fixed a problem with the `kill' builtin that prevented sending signals + to a process group under certain circumstances when providing a pid < 0. + +m. When in POSIX mode, `pwd' now checks that the value it prints is the same + directory as `.', even when displaying $PWD. + +n. Fixed a problem with the `read' builtin when reading a script from standard + input and reading data from the same file. + +o. Fixed a problem with the `type' and `command' builtins that caused absolute + pathnames to be displayed incorrectly. + +p. Some changes to the `bg' builtin for POSIX conformance. + +q. The `fc' builtin now removes the `fc' command that caused it to invoke an + editor on specified history entries from the history entirely, rather than + simply ignoring it. + +r. When in POSIX mode, the `v' command in vi editing mode simply invokes vi + on the current command, rather than checking $FCEDIT and $EDITOR. + +s. Fixed a small memory leak in the pathname canonicalization code. + +t. Fixed a bug that caused the expanded value of a $'...' string to be + incorrectly re-quoted if it occurred within a double-quoted ${...} + parameter expansion. + +u. Restored default emacs-mode key binding of M-TAB to dynamic-complete-history. + +v. Fixed a bug that caused core dumps when interrupting loops running builtins + on some systems. + +w. Make sure that some of the functions bash provides replacements for are + not cpp defines. + +x. The code that scans embedded commands for the parser (`...` and $(...)) is + now more aware of embedded comments and their effect on quoted strings. + +y. Changed the `-n' option to the `history' builtin to not reset the number of + history lines read in the current session after reading the new lines from + the history file if the history is being appended when it is written to + the file, since the appending takes care of the problem that the adjustment + was intended to solve. + +z. Improved the error message displayed when a shell script fails to execute + because the environment and size of command line arguments are too large. + +aa. A small fix to make sure that $HISTCMD is evaluated whenever the shell is + saving commands to the history list, not just when HISTSIZE is defined. + +2. Changes to Readline + +a. The `change-case' command now correctly changes the case of multibyte + characters. + +b. Changes to the shared library construction scripts to deal with Windows + DLL naming conventions for Cygwin. + +c. Fixed the redisplay code to avoid core dumps resulting from a poorly-timed + SIGWINCH. + +d. Fixed the non-incremental search code in vi mode to dispose of any current + undo list when copying a line from the history into the current editing + buffer. + +e. The variable assignment code now ignores whitespace at the end of lines + when assigning to boolean variables. + +f. The `C-w' binding in incremental search now understands multibyte + characters. + +3. New Features in Bash + +a. A new configuration option, `--enable-strict-posix-default', which will + build bash to be POSIX conforming by default. + +4. New Features in Readline + +a. If the rl_completion_query_items is set to a value < 0, readline never + asks the user whether or not to view the possible completions. + +------------------------------------------------------------------------------ +This document details the changes between this version, bash-3.1-alpha1, +and the previous version, bash-3.0-release. + +1. Changes to Bash + +a. Fixed a bug that caused bash to crash if referencing an unset local array. + +b. Fixed a problem that caused tilde expansion to not be performed before + attempting globbing word completion. + +c. Fixed an incompatibility so that a first argument to trap that's a valid + signal number will be trated as a signal rather than a command to execute. + +d. Fixed ${#word} expansion to correctly compute the length of a string + containing multibyte characters. + +e. Fixed a bug that caused bash to not pass the correct flags for signal + disposition to child processes. + +f. Fixed a bug that caused `fc -l' to list one too many history entries. + +g. Some fixes to `fc' for POSIX conformance. + +h. Some fixes to job status display for POSIX conformance. + +i. Fixed a bug that caused `command -v' to display output if a command was not + found -- it should be silent. + +j. In POSIX mode, `type' and `command -[vV]' do not report non-executable + files, even if the shell will attempt to execute them. + +k. Fixed a bug that caused the `==' operator to the [[ command to not attempt + extended pattern matching. + +l. Fixed the brace expansion code to handle characters whose value exceeds 128. + +m. Fixed `printf' to handle strings with a leading `\0' whose length is + non-zero. + +n. Fixed a couple of problems with brace expansion where `${' was handled + incorrectly. + +o. Fixed off-by-one error when calculating the upper bound of `offset' when + processing the ${array[@]:offset:length} expansion. + +p. System-specific configuration changes for: FreeBSD 5.x, Interix, MacOS X + 10.4, Linux 2.4+ kernels, Linux 3.x kernels, Dragonfly BSD, QNX 6.x, + Cygwin + +q. Fixed a bug that caused the shell to ignore the status of the rightmost + command in a pipeline when the `pipefail' option was enabled. + +r. Fixed a completion bug that caused core dumps when expanding a directory + name. + +s. Fixed a bug that prevented `hash -d' from removing commands from the hash + table. + +t. Fixed word splitting to avoid really bad quadratic performance when + expanding long lists. + +u. Fixed a bug that caused negative offsets in substring expansion to use the + wrong values. + +v. Fixed a bug in printf that caused it to not return failure on write errors. + +w. Fixed a bug that caused commands in subshells to not be properly timed. + +x. The shell parser no longer attempts to parse a compound assignment specially + unless in a position where an assignment statement is acceptable or parsing + arguments to a builtin that accepts assignment statements. + +y. Fixed a problem that caused a `case' statement to be added to the history + incorrectly as a single command if the `case word' was on one line and the + `in' on another. + +z. Fixed a problem that caused internal shell quoting characters to be + incorrectly quoted with backslashes under some circumstances. + +aa. The shell now performs correct word splitting when IFS contains multibyte + characters. + +bb. The mail checking code now resets the cached file information if the size + drops to 0, even if the times don't change. + +cc. A completed command name that is found in $PATH as well as the name of a + directory in the current directory no longer has a slash appended in certain + circumstances: a single instance found in $PATH when `.' is not in $PATH, + and multiple instances found in $PATH, even when `.' is in $PATH. + +dd. Incorporated tilde expansion into the word expansion code rather than as a + separately-called function, fixing some cases where it was performed + inappropriately (e.g., after the second `=' in an assignment statement or + in a double-quoted parameter expansion). + +ee. Fixed several bugs encountered when parsing compound assignment statements, + so that compound assignments appearing as arguments to builtins are no + longer double-expanded. + +ff. Fixed a bug in the command execution code that caused asynchronous commands + containing command substitutions to not put the terminal in the wrong + process group. + +gg. Bash now handles the case where the WCONTINUED flag causes waitpid() to + return -1/EINVAL at runtime as well as configuration time. + +hh. Fixed parser to generate an error when the pipeline `argument' to `!' or + `time' is NULL. + +ii. The shell now takes a little more care when manipulating file descriptors + greater than 9 with the `exec' builtin. + +jj. Fixed a bug that caused variable assignments preceding the `command' builtin + preceding a special builtin to be preserved after the command completed in + POSIX mode. + +kk. Fixed a bug that allowed variables beginning with a digit to be created. + +ll. Fixed a bug that caused a \ to be removed when parsing a $'...' + construct. + +mm. A shell whose name begins with `-' will now be a restricted shell if the + remainder of the name indicates it should be restricted. + +nn. Fixed a bug that could cause a core dump if FUNCNAME were changed or unset + during a function's execution. + +oo. Fixed a bug that caused executing a `return' in a function to not execute + a RETURN trap. The RETURN trap is inherited by shell functions only if + function tracing is globally enabled or has been enabled for that function. + +pp. Fixed cases where var[@] was not handled exactly like var, when var is a + scalar variable. + +qq. Fixed a bug that caused the first character after a SIGINT to be discarded + under certain circumstances. + +rr. Fixed exit status code so that a suspended job returns 128+signal as its + exit status (preventing commands after it in `&&' lists from being + executed). + +ss. Fixed a bug that caused the shell parser state to be changed by executing + a shell function as a result of word completion. + +tt. Fixed a long-standing bug that caused '\177' characters in variable + values to be discarded when expanded in double-quoted strings. + +uu. Fixed a bug that caused $RANDOM to be re-seeded multiple times in a + subshell environment. + +vv. Extensive changes to the job management code to avoid the pid-reuse and + pid-aliasing problems caused by retaining the exit status of too many jobs, + but still retain as many background job statuses as POSIX requires. + +ww. Fixed a parser bug in processing \ that caused things like + + ((echo 5) \ + (echo 6)) + + to not work correctly. + +xx. `pwd -P' now sets $PWD to a directory name containing no symbolic links + when in posix mode, as POSIX requires. + +yy. In posix mode, bash no longer sets $PWD to a name containing no symbolic + links if a directory is chosen from $CDPATH. + +zz. The word splitting code now treats an IFS character that is not space, + tab, or newline and any adjacent IFS white space as a single delimiter, as + SUSv3/XPG6 require. + +aaa. The `read' builtin now checks whether or not the number of fields read is + exactly the same as the number of variables instead of just assigning the + rest of the line (minus any trailing IFS white space) to the last + variable. This is what POSIX/SUS/XPG all require. + +bbb. Fixed a bug that caused `read' to always check whether or not fd 0 was a + pipe, even when reading from another file descriptor. + +ccc. Fixed a bug that caused short-circuiting of execution even if the return + value was being inverted. + +ddd. Fixed a bug that caused a core dump while decoding \W escapes in PS1 if + PWD was unset. + +eee. Fixed a bug in `read' that counted internal quoting characters for the + purposes of `read -n'. + +fff. Fixed a bug so that a function definition in a pipeline causes a child + process to be forked at the right time. + +ggg. Bash will not attempt to link against a readline library that doesn't + have rl_gnu_readline_p == 1. + +hhh. Fixed a bug that caused `read' to consume one too many characters when + reading a fixed number of characters and the Nth character is a backslash. + +iii. Fixed a bug that caused `unset' on variables in the temporary environment + to leave them set when `unset' completed. + +jjj. Fixed a bug that caused bash to close fd 2 if an `exec' failed and the + shell didn't exit. + +kkk. The completion code is more careful to not turn `/' or `///' into `//', + for those systems on which `//' has special meaning. + +lll. Fixed a bug that caused command substitution in asynchronous commands to + close the wrong file descriptors. + +mmm. The shell no longer prints status messages about terminated background + processes unless job control is active. + +nnn. Fixed a bug that prevented multiple consecutive invocations of `history -s' + from adding all the commands to the history list. + +ooo. Added a couple of changes to make arithmetic expansion more consistent in + all its contexts (still not perfect). + +ppp. Fixed a bug that caused the parser to occasionally not find the right + terminating "`" in an old-style command substitution. + +qqq. Fixed a bug that caused core dumps when the shell was reading its non- + interactive input from fd 0 and fd 0 was duplicated and restored using a + combination of `exec' (to save) and redirection (to restore). + +rrr. Fixed a problem that caused loops in sourced scripts to not be cleaned + up properly when a `return' is executed. + +sss. Change internal command substitution completion function to append a slash + to directory names in the command. + +2. Changes to Readline + +a. Fixed a bug that caused multiliine prompts to be wrapped and displayed + incorrectly. + +b. Fixed a bug that caused ^P/^N in emacs mode to fail to display the current + line correctly. + +c. Fixed a problem in computing the number of invisible characters on the first + line of a prompt whose length exceeds the screen width. + +d. Fixed vi-mode searching so that failure preserves the current line rather + than the last line in the history list. + +e. Fixed the vi-mode `~' command (change-case) to have the correct behavior at + end-of-line when manipulating multibyte characters. + +f. Fixed the vi-mode `r' command (change-char) to have the correct behavior at + end-of-line when manipulating multibyte characters. + +g. Fixed multiple bugs in the redisplay of multibyte characters: displaying + prompts longer than the screen width containing multibyte characters, + +h. Fix the calculation of the number of physical characters in the prompt + string when it contains multibyte characters. + +i. A non-zero value for the `rl_complete_suppress_append' variable now causes + no `/' to be appended to a directory name. + +j. Fixed forward-word and backward-word to work when words contained + multibyte characters. + +k. Fixed a bug in finding the delimiter of a `?' substring when performing + history expansion in a locale that supports multibyte characters. + +l. Fixed a memory leak caused by not freeing the timestamp in a history entry. + +m. Fixed a bug that caused "\M-x" style key bindings to not obey the setting + of the `convert-meta' variable. + +n. Fixed saving and restoring primary prompt when prompting for incremental + and non-incremental searches; search prompts now display multibyte + characters correctly. + +o. Fixed a bug that caused keys originally bound to self-insert but shadowed + by a multi-character key sequence to not be inserted. + +p. Fixed code so rl_prep_term_function and rl_deprep_term_function aren't + dereferenced if NULL (matching the documentation). + +q. Extensive changes to readline to add enough state so that commands + requiring additional characters (searches, multi-key sequences, numeric + arguments, commands requiring an additional specifier character like + vi-mode change-char, etc.) work without synchronously waiting for + additional input. + +r. Lots of changes so readline builds and runs on MinGW. + +s. Readline no longer tries to modify the terminal settings when running in + callback mode. + +t. The Readline display code no longer sets the location of the last invisible + character in the prompt if the \[\] sequence is empty. + +3. New Features in Bash + +a. Bash now understands LC_TIME as a special variable so that time display + tracks the current locale. + +b. BASH_ARGC, BASH_ARGV, BASH_SOURCE, and BASH_LINENO are no longer created + as `invisible' variables and may not be unset. + +c. In POSIX mode, if `xpg_echo' option is enabled, the `echo' builtin doesn't + try to interpret any options at all, as POSIX requires. + +d. The `bg' builtin now accepts multiple arguments, as POSIX seems to specify. + +e. Fixed vi-mode word completion and glob expansion to perform tilde + expansion. + +f. The `**' mathematic exponentiation operator is now right-associative. + +g. The `ulimit' builtin has new options: -i (max number of pending signals), + -q (max size of POSIX message queues), and -x (max number of file locks). + +h. A bare `%' once again expands to the current job when used as a job + specifier. + +i. The `+=' assignment operator (append to the value of a string or array) is + now supported for assignment statements and arguments to builtin commands + that accept assignment statements. + +j. BASH_COMMAND now preserves its value when a DEBUG trap is executed. + +k. The `gnu_errfmt' option is enabled automatically if the shell is running + in an emacs terminal window. + +l. New configuration option: --single-help-strings. Causes long help text + to be written as a single string; intended to ease translation. + +m. The COMP_WORDBREAKS variable now causes the list of word break characters + to be emptied when the variable is unset. + +n. An unquoted expansion of $* when $IFS is empty now causes the positional + parameters to be concatenated if the expansion doesn't undergo word + splitting. + +o. Bash now inherits $_ from the environment if it appears there at startup. + +p. New shell option: nocasematch. If non-zero, shell pattern matching ignores + case when used by `case' and `[[' commands. + +q. The `printf' builtin takes a new option: -v var. That causes the output + to be placed into var instead of on stdout. + +r. By default, the shell no longer reports processes dying from SIGPIPE. + +s. Bash now sets the extern variable `environ' to the export environment it + creates, so C library functions that call getenv() (and can't use the + shell-provided replacement) get current values of environment variables. + +4. New Features in Readline + +a. The key sequence sent by the keypad `delete' key is now automatically + bound to delete-char. + +b. A negative argument to menu-complete now cycles backward through the + completion list. + +c. A new bindable readline variable: bind-tty-special-chars. If non-zero, + readline will bind the terminal special characters to their readline + equivalents when it's called (on by default). + +d. New bindable command: vi-rubout. Saves deleted text for possible + reinsertion, as with any vi-mode `text modification' command; `X' is bound + to this in vi command mode. + +------------------------------------------------------------------------------ +This document details the changes between this version, bash-3.0-release, +and the previous version, bash-3.0-rc1. + +1. Changes to Bash + +a. Fixed a boundary overrun that could cause segmentation faults when the + completion code hands an incomplete construct to the word expansion + functions. + +b. Changed posix mode behavior so that an error in a variable assignment + preceding a special builtin causes a non-interactive shell to exit. + +c. Change the directory expansion portion of the completion code to not + expand embedded command substitutions if the directory name appears in + the file system. + +d. Fixed a problem that caused `bash -r' to turn on restrictions before + reading the startup files. + +e. Fixed a problem with the default operation of the `umask' builtin. + +2. Changes to Readline + +a. Fixed a problem with readline saving the contents of the current line + before beginning a non-interactive search. + +b. Fixed a problem with EOF detection when using rl_event_hook. + +c. Fixed a problem with the vi mode `p' and `P' commands ignoring numeric + arguments. + +------------------------------------------------------------------------------ +This document details the changes between this version, bash-3.0-rc1, +and the previous version, bash-3.0-beta1. + +1. Changes to Bash + +a. Fixed a bug that caused incorrect behavior when referecing element 0 of + an array using $array, element 0 was unset, and `set -u' was enabled. + +b. System-specific changes for: SCO Unix 3.2, Tandem. + +c. Fixed a bug that caused inappropriate word splitting when a variable was + expanded within a double-quoted string that also included $@. + +d. Fixed a bug that caused `pwd' to not display anything in physical mode + when the file system had changed underneath the shell. + +e. Fixed a bug in the pre- and post- increment and decrement parsing in the + expression evaluator that caused errors when the operands and corresponding + operators were separated by whitespace. + +f. Fixed a bug that caused `history -p' to add an entry to the history list, + counter to the documentation. (Keeps the history expansions invoked by + emacs-mode command line editing from doing that as well.) + +g. Fixed a bug that could cause a core dump if `cd' is asked to print out a + pathname longer than PATH_MAX characters. + +h. Fixed a bug that caused jobs to be put into the wrong process group under + some circumstances after enabling job control with `set -m'. + +i. `unalias' now returns failure if no alias name arguments are supplied. + +j. Documented the characters not allowed to appear in an alias name. + +k. $* is no longer expanded as if in double quotes when it appears in the + body of a here document, as the SUS seems to require. + +l. The `bashbug' script now uses a directory in $TMPDIR for exclusive + access rather than trying to guess how the underlying OS provides for + secure temporary file creation. + +m. Fixed a few problems with `cd' and `pwd' when asked to operate on pathnames + longer than PATH_MAX characters. + +n. Fixed a memory leak caused when creating multiple local array variables + with identical names. + +o. Fixed a problem with calls to getcwd() so that bash now operates better + when the full pathname to the current directory is longer than PATH_MAX + bytes. + +p. The `trap' builtin now reports an error if a single non-signal argument + is specified. + +q. Fixed a bug that caused `umask' to not work correctly when presented + with a mask of all 0s. + +r. When `getopts' reaches the end of options, OPTARG is unset, as POSIX + appears to specify. + +s. Interactive mode now depends on whether or not stdin and stderr are + connected to a tty; formerly it was stdin and stdout. POSIX requires + this. + +t. Fixed vi-mode completion to work more as POSIX specifies (e.g., doing the + right kind of filename generation). + +2. Changes to Readline + +a. Fixed a problem that could cause readline to refer to freed memory when + moving between history lines while doing searches. + +b. Improvements to the code that expands and displays prompt strings + containing multibyte characters. + +c. Fixed a problem with vi-mode not correctly remembering the numeric argument + to the last `c'hange command for later use with `.'. + +d. Fixed a bug in vi-mode that caused multi-digit count arguments to work + incorrectly. + +e. Fixed a problem in vi-mode that caused the last text modification command + to not be remembered across different command lines. + +f. Fixed problems with changing characters and changing case at the end of + the line. + +3. New Features in Bash + +a. The `jobs', `kill', and `wait' builtins now accept job control notation + even if job control is not enabled. + +b. The historical behavior of `trap' that allows a missing `action' argument + to cause each specified signal's handling to be reset to its default is + now only supported when `trap' is given a single non-option argument. + +4. New Features in Readline + +a. When listing completions, directories have a `/' appended if the + `mark-directories' option has been enabled. + +------------------------------------------------------------------------------ +This document details the changes between this version, bash-3.0-beta1, +and the previous version, bash-3.0-alpha. + +1. Changes to Bash + +a. Fixes to build correctly when arrays are not compiled into the shell. + +b. Fixed command substitution to run any exit trap defined in the command + substitution before returning; the exit trap is not inherited from the + calling shell. + +c. Fixes to process group synchronization code so that every child process + attempts to set the terminal's process group; fixes some synchronization + problems on Linux kernels that schedule the child to always run before + the parent. + +d. Fixed processing of octal and hex constants in printf builtin for POSIX.2 + compliance. + +e. Fixed a couple of core dumps in the pattern removal code. + +f. Fixes to the array subrange extraction code to deal better with sparse + arrays. + +g. Parser errors and other errors that result in the shell exiting now cause + the exit trap to be run. + +h. Change the command substitution completion functions to not append any + closing quote, because it would be inserted a closing "`" or ")". + +i. Fix history initialization so assignments to $histchars made in startup + files are honored. + +j. If an exit trap does not contain a call to `exit', the shell now uses + the exit status of the last command executed before the trap as the exit + status of the shell. + +k. The parser now prompts with $PS2 if it reads a newline while parsing a + compound array assignment statement. + +l. When performing a compound array assignment, the parser doesn't treat + words of the form [index]=value as assignments if they're the result of + expansions. + +m. Fixed a bug that caused `return' executed in a trap command to make the + shell think it was still running the trap. + +n. Fixed the value of errno set by the pathname canonicalization functions. + +o. Changed the grammar so that `time' alone on a line times a null command + rather than being a syntax error. + +p. The pattern substitution code no longer performs quote removal on the + pattern before trying to match it, as the pattern removal functions do. + +q. Fixed a bug that could cause core dumps when checking whether a quoted + command name was being completed. + +r. Fixes to the pattern removal and pattern replacement expansions to deal + with multibyte characters better (and faster). + +s. Fix to the substring expansion (${param:off[:len]}) to deal with (possibly + multibyte) characters instead of raw bytes. + +t. Fixed a bug that caused some key bindings set in an inputrc to be ignored + at shell startup. + +u. Fixed a bug that caused unsetting a local variable within a function to + not work correctly. + +v. Fixed a bug that caused invalid variables to be created when using + `read -a'. + +w. Fixed a bug that caused "$@" to expand incorrectly when used as the right + hand side of a parameter expansion such as ${word:="$@"} if the first + character of $IFS was not a space. + +x. Fixed a slight cosmetic problem when printing commands containing a + `>&word' redirection. + +y. Fixed a problem that could cause here documents to not be created correctly + if the system temporary directory did not allow writing. + +2. Changes to Readline + +a. Change to history expansion functions to treat `^' as equivalent to word + one, as the documention states. + +b. Some changes to the display code to improve display and redisplay of + multibyte characters. + +c. Changes to speed up the multibyte character redisplay code. + +d. Fixed a bug in the vi-mode `E' command that caused it to skip over the + last character of a word if invoked while point was on the word's + next-to-last character. + +e. Fixed a bug that could cause incorrect filename quoting when + case-insensitive completion was enabled and the word being completed + contained backslashes quoting word break characters. + +f. Fixed a bug in redisplay triggered when the prompt string contains + invisible characters. + +g. Fixed some display (and other) bugs encountered in multibyte locales + when a non-ascii character was the last character on a line. + +h. Fixed some display bugs caused by multibyte characters in prompt strings. + +i. Fixed a problem with history expansion caused by non-whitespace characters + used as history word delimiters. + +3. New Features in Bash + +a. printf builtin understands two new escape sequences: \" and \?. + +b. `echo -e' understands two new escape sequences: \" and \?. + +c. The GNU `gettext' package and libintl have been integrated; the shell's + messages can be translated into different languages. + +d. The `\W' prompt expansion now abbreviates $HOME as `~', like `\w'. + +e. The error message printed when bash cannot open a shell script supplied + as argument 1 now includes the name of the shell, to better identify + the error as coming from bash. + +4. New Features in Readline + +a. New application variable, rl_completion_quote_character, set to any + quote character readline finds before it calls the application completion + function. + +b. New application variable, rl_completion_suppress_quote, settable by an + application completion function. If set to non-zero, readline does not + attempt to append a closing quote to a completed word. + +c. New application variable, rl_completion_found_quote, set to a non-zero + value if readline determines that the word to be completed is quoted. + Set before readline calls any application completion function. + +d. New function hook, rl_completion_word_break_hook, called when readline + needs to break a line into words when completion is attempted. Allows + the word break characters to vary based on position in the line. + +e. New bindable command: unix-filename-rubout. Does the same thing as + unix-word-rubout, but adds `/' to the set of word delimiters. + +------------------------------------------------------------------------------ +This document details the changes between this version, bash-3.0-alpha, +and the previous version, bash-2.05b-release. + +1. Changes to Bash + +a. Fixes so that the shell will compile without some of the default options + defined. + +b. Fixed an error message that did not pass enough arguments to printf. + +c. Fixed a bug that caused input redirection to a builtin inside a script + being read from standard input to result in the rest of the already- + read and buffered script to be discarded. + +d. Fixed a bug that caused subshell initialization to close the file + descriptor from which the shell was reading a script under certain + circumstances. + +e. Fixed a bug that caused the shell to not advance a string pointer over + a null wide character when doing string operations. + +f. Fixed the internal logout code so that shells that time out waiting for + input (using $TMOUT) run ~/.bash_logout. + +g. Portability and configuration changes for: cygwin, HP/UX, GNU/FreeBSD. + +h. The parser no longer adds implicit double quotes to ((...)) arithmetic + commands. + +i. The ((...)) arithmetic command evaluation code was fixed to not dump core + when the expanded string is null. + +j. The ((...)) arithmetic command evaluation code was fixed to not perform + variable assignments while expanding the expression. + +k. Fixed a bug that caused word splitting to be performed incorrectly when + IFS is set, but null. + +l. Fixed a bug in brace expansion that caused a quoted `$' preceding an + open brace to inhibit brace expansion. + +m. Fixed a bug that caused a leading `-' in the shell's name to cause it to + not be recognized as a restricted shell. + +n. Fixed a bug in the arithmetic evaluation code that could cause longjmps + to an invalid location and result in a core dump. + +o. Fixed a bug in the calculation of how many history lines are new in a + single shell session when reading new history lines from a file with + `history -n'. + +p. Fixed a bug in pathname canonicalization that caused the shell to dump + core when presented with a pathname longer than PATH_MAX. + +q. Fixed the parser so that it doesn't try to compare a char variable to + EOF, which fails when chars are unsigned. + +r. Fixed a bug in the simple command execution code that caused occasional + core dumps. + +s. The shell does a better job of saving any partial parsing state during + operations which cause a command to be executed while a line is being + entered and parsed. + +t. The completion code now splits words more like the expansion code when + $IFS is used to split. + +u. The locale code does a better job of recomputing the various locale + variable values when LC_ALL is unset. + +v. The programmable completion code does a better job of dequoting expanded + word lists before comparing them against the word to be matched. + +w. The shell no longer seg faults if the expanded value of $PS4 is null + and `set -x' is enabled. + +x. Fixed a bug that caused core dumps when a here string expanded to NULL. + +y. The mail checking code now makes sure the mailbox is bigger before + reporting the existence of new mail. + +z. The parser does not try to expand $'...' and $"..." when the appear + within double quotes unless the `extquote' option has been enabled with + `shopt'. For backwards compatibility, it is enabled by default. + +aa. Fixed a bug that caused `for x; do ...' and `select x; do ... to use + $@ instead of "$@" for the implicit list of arguments. + +bb. Fixed a bug that caused a subshell of a restricted shell (e.g., one + spawned to execute a pipeline) to not exit immediately if attempting + to use a command containing a slash. + +cc. Fixed a problem with empty replacements for a pattern that doesn't match + when performing ${param/word/} expansion. + +dd. Word expansions performed while expanding redirections no longer search + a command's temporary environment to expand variable values. + +ee. Improvements to the alias expansion code when expanding subsequent words + because an aliase's value ends with a space. + +ff. `cd -' now prints the current working directory after a successful chdir + even when the shell is not interactive, as the standard requires. + +gg. The shell does a better job of ensuring a child process dies of SIGINT + before resending SIGINT to itself. + +hh. The arithmetic expansion variable assignment code now does the right + thing when assigning to `special' variables like OPTIND. + +ii. When history expansion verification is enabled, the bash readline helper + functions that do history expansion on the current line don't print + the results. + +jj. Fixed bugs with multiple consecutive alias expansion when one of the + expansions ends with a space. + +kk. Fixed a problem in the programmable completion code that could cause core + dumps when trying to initialize a set of possible completions from a + list of variables. + +ll. The \[ and \] escape characters are now ignored when decoding the prompt + string if the shell is started with editing disabled. + +mm. Fixed a bug that could leave extra characters in a string when doing + quoted null character removal. + +nn. Command substitution and other subshell operations no longer reset the + line number (aids the bash debugger). + +oo. Better line number management when executing simple commands, conditional + commands, for commands, and select commands. + +pp. The globbing code now uses malloc, with its better failure properties, + rather than alloca(). + +qq. Fixed a bug that caused expansions like #{a[2]:=value} to create the + appropriate array element instead of a variable named `a[2]'. + +rr. Fixed a bug in the handling of a `?(...)' pattern immediately following + a `*' when extglob is enabled. + +ss. Fixed a bug that caused a `return' invoked in an exit trap when exit is + invoked in a function to misbehave. + +tt. Fixed a bug that caused CTLESC and CTLNUL characters to not be escaped + by the internal shell string quoting functions. + +uu. Fixed a bug that caused quoted null characters in an expanded word list + to be inappropriately assigned to an array variable when using `read -a'. + +vv. Fixed a bug that caused redirections accompanying a null command to persist + in the current shell. + +ww. Fixed a bug that caused the prompt to be printed when the shell was + expanding a multiline alias. + +xx. Fixed a bug that resulted in core dumps when the completion for a command + changed the compspec. + +yy. Fixed a bug that caused evaluation of programmable completions to print + notifications of completed jobs. + +zz. Bash now disables line editing when $EMACS == `t' and $TERM == `dumb' + (which is what emacs shell windows do). + +aaa. In posix mode, `kill -l' causes signal names to be displayed without + a leading `SIG'. + +bbb. Clear error flag on standard output so it doesn't persist across multiple + builtin commands. + +ccc. In posix mode, `alias' displays alias values without the leading `alias', + so the output cannot be used as subsequent input. + +ddd. In posix mode, the `trap' builtin doesn't check whether or not its + first argument is a signal specification and revert the signal handling + to its original disposition if it is. + +eee. Fixed several bugs in the handling of "$*" and "${array[*]}" by the + pattern substitution and removal expansions. + +fff. Fixed several problems with the handling of ${array[@]}, ${array[*]}, + $@, and $* by the indirect variable expansion code. + +ggg. Fixed a bug that did not allow `time' to be aliased. + +hhh. Improved the mail checking code so it won't check (and possibly cause an + NFS file system mount) until MAILPATH or MAIL is given a value -- there + is no default if DEFAULT_MAIL_DIRECTORY is not defined at compile time. + (It is computed by configure, but can be #undef'd in config-bot.h.) + +iii. If the `chkwinsize' option is enabled, the shell checks for window size + changes if a child process exits due to a signal. + +jjj. Removed the attempts to avoid adding a slash at the end of a completed + executable name if there was a directory with the same name in the + current directory. + +kkk. Fixed PATH lookup code so it treats the permission bits separately for + owner, group, and other, rather than checking them all. + +lll. Fixed the locale code to reset the parser's idea of the character class + , which controls how it splits tokens, when the locale changes. + +mmm. The shell now binds its special readline functions and key bindings only + if the user's inputrc file has not already bound them. + +nnn. The shell now reports on processes that dump core due to signals when + invoked as `-c command'. + +2. Changes to Readline + +a. Fixes to avoid core dumps because of null pointer references in the + multibyte character code. + +b. Fix to avoid infinite recursion caused by certain key combinations. + +c. Fixed a bug that caused the vi-mode `last command' to be set incorrectly. + +d. Readline no longer tries to read ahead more than one line of input, even + when more is available. + +e. Fixed the code that adjusts the point to not mishandle null wide + characters. + +f. Fixed a bug in the history expansion `g' modifier that caused it to skip + every other match. + +g. Fixed a bug that caused the prompt to overwrite previous output when the + output doesn't contain a newline and the locale supports multibyte + characters. This same change fixes the problem of readline redisplay + slowing down dramatically as the line gets longer in multibyte locales. + +h. History traversal with arrow keys in vi insertion mode causes the cursor + to be placed at the end of the new line, like in emacs mode. + +i. The locale initialization code does a better job of using the right + precedence and defaulting when checking the appropriate environment + variables. + +j. Fixed the history word tokenizer to handle <( and >( better when used as + part of bash. + +k. The overwrite mode code received several bug fixes to improve undo. + +l. Many speedups to the multibyte character redisplay code. + +m. The callback character reading interface should not hang waiting to read + keyboard input. + +n. Fixed a bug with redoing vi-mode `s' command. + +o. The code that initializes the terminal tracks changes made to the terminal + special characters with stty(1) (or equivalent), so that these changes + are reflected in the readline bindings. New application-callable function + to make it work: rl_tty_unset_default_bindings(). + +p. Fixed a bug that could cause garbage to be inserted in the buffer when + changing character case in vi mode when using a multibyte locale. + +q. Fixed a bug in the redisplay code that caused problems on systems + supporting multibyte characters when moving between history lines when the + new line has more glyphs but fewer bytes. + +r. Undo and redo now work better after exiting vi insertion mode. + +s. Make sure system calls are restarted after a SIGWINCH is received using + SA_RESTART. + +t. Improvements to the code that displays possible completions when using + multibyte characters. + +u. Fixed a problem when parsing nested if statements in inputrc files. + +v. The completer now takes multibyte characters into account when looking for + quoted substrings on which to perform completion. + +w. The history search functions now perform better bounds checking on the + history list. + +3. New Features in Bash + +a. ANSI string expansion now implements the \x{hexdigits} escape. + +b. There is a new loadable `strftime' builtin. + +c. New variable, COMP_WORDBREAKS, which controls the readline completer's + idea of word break characters. + +d. The `type' builtin no longer reports on aliases unless alias expansion + will actually be performed. + +e. HISTCONTROL is now a colon-separated list of values, which permits + more extensibility and backwards compatibility. + +f. HISTCONTROL may now include the `erasedups' option, which causes all lines + matching a line being added to be removed from the history list. + +g. `configure' has a new `--enable-multibyte' argument that permits multibyte + character support to be disabled even on systems that support it. + +h. New variables to support the bash debugger: BASH_ARGC, BASH_ARGV, + BASH_SOURCE, BASH_LINENO, BASH_SUBSHELL, BASH_EXECUTION_STRING, + BASH_COMMAND + +i. FUNCNAME has been changed to support the debugger: it's now an array + variable. + +j. for, case, select, arithmetic commands now keep line number information + for the debugger. + +k. There is a new `RETURN' trap executed when a function or sourced script + returns (not inherited child processes; inherited by command substitution + if function tracing is enabled and the debugger is active). + +l. New invocation option: --debugger. Enables debugging and turns on new + `extdebug' shell option. + +m. New `functrace' and `errtrace' options to `set -o' cause DEBUG and ERR + traps, respectively, to be inherited by shell functions. Equivalent to + `set -T' and `set -E' respectively. The `functrace' option also controls + whether or not the DEBUG trap is inherited by sourced scripts. + +n. The DEBUG trap is run before binding the variable and running the action + list in a `for' command, binding the selection variable and running the + query in a `select' command, and before attempting a match in a `case' + command. + +o. New `--enable-debugger' option to `configure' to compile in the debugger + support code. + +p. `declare -F' now prints out extra line number and source file information + if the `extdebug' option is set. + +q. If `extdebug' is enabled, a non-zero return value from a DEBUG trap causes + the next command to be skipped, and a return value of 2 while in a + function or sourced script forces a `return'. + +r. New `caller' builtin to provide a call stack for the bash debugger. + +s. The DEBUG trap is run just before the first command in a function body is + executed, for the debugger. + +t. `for', `select', and `case' command heads are printed when `set -x' is + enabled. + +u. There is a new {x..y} brace expansion, which is shorthand for {x.x+1, + x+2,...,y}. x and y can be integers or single characters; the sequence + may ascend or descend; the increment is always 1. + +v. New ksh93-like ${!array[@]} expansion, expands to all the keys (indices) + of array. + +w. New `force_fignore' shopt option; if enabled, suffixes specified by + FIGNORE cause words to be ignored when performing word completion even + if they're the only possibilities. + +x. New `gnu_errfmt' shopt option; if enabled, error messages follow the `gnu + style' (filename:lineno:message) format. + +y. New `-o bashdefault' option to complete and compgen; if set, causes the + whole set of bash completions to be performed if the compspec doesn't + result in a match. + +z. New `-o plusdirs' option to complete and compgen; if set, causes directory + name completion to be performed and the results added to the rest of the + possible completions. + +aa. `kill' is available as a builtin even when the shell is built without + job control. + +bb. New HISTTIMEFORMAT variable; value is a format string to pass to + strftime(3). If set and not null, the `history' builtin prints out + timestamp information according to the specified format when displaying + history entries. If set, bash tells the history library to write out + timestamp information when the history file is written. + +cc. The [[ ... ]] command has a new binary `=~' operator that performs + extended regular expression (egrep-like) matching. + +dd. `configure' has a new `--enable-cond-regexp' option (enabled by default) + to enable the =~ operator and regexp matching in [[ ... ]]. + +ee. Subexpressions matched by the =~ operator are placed in the new + BASH_REMATCH array variable. + +ff. New `failglob' option that causes an expansion error when pathname + expansion fails to produce a match. + +gg. New `set -o pipefail' option that causes a pipeline to return a failure + status if any of the processes in the pipeline fail, not just the last + one. + +4. New Features in Readline + +a. History expansion has a new `a' modifier equivalent to the `g' modifier + for compatibility with the BSD csh. + +b. History expansion has a new `G' modifier equivalent to the BSD csh `g' + modifier, which performs a substitution once per word. + +c. All non-incremental search operations may now undo the operation of + replacing the current line with the history line. + +d. The text inserted by an `a' command in vi mode can be reinserted with + `.'. + +e. New bindable variable, `show-all-if-unmodified'. If set, the readline + completer will list possible completions immediately if there is more + than one completion and partial completion cannot be performed. + +f. There is a new application-callable `free_history_entry()' function. + +g. History list entries now contain timestamp information; the history file + functions know how to read and write timestamp information associated + with each entry. + +h. Four new key binding functions have been added: + + rl_bind_key_if_unbound() + rl_bind_key_if_unbound_in_map() + rl_bind_keyseq_if_unbound() + rl_bind_keyseq_if_unbound_in_map() + +------------------------------------------------------------------------------ +This document details the changes between this version, bash-2.05b-release, +and the previous version, bash-2.05b-beta2. + +1. Changes to Bash + +a. Fixed an off-by-one error in the function that translates job + specifications. + +b. Note that we're running under Emacs and disable line editing if + $EMACS == `t'. + +------------------------------------------------------------------------------ +This document details the changes between this version, bash-2.05b-beta2, +and the previous version, bash-2.05b-beta1. + +1. Changes to Bash + +a. Fixed the /= and %= arithmetic operators to catch division by zero. + +b. Added putenv, setenv, unsetenv to getenv replacement for completeness. + +c. Fixed a bug that could cause the -O expand_aliases invocation option + to not take effect. + +d. Fixed a problem with process substitution that resulted in incorrect + behavior when the number of process substitutions in an individual + command approached 64. + +2. Changes to Readline + +a. Fixed a problem with backward-char-search when on a system with support + for multibyte characters when running in a locale without any multibyte + characters. + +------------------------------------------------------------------------------ +This document details the changes between this version, bash-2.05b-beta1, +and the previous version, bash-2.05b-alpha1. + +1. Changes to Bash + +a. Fixed a problem when parsing a POSIX.2 character class name while + evaluating a bracket expression containing multibyte characters. + +b. Changed the help text for `bind' to make it clear that any command + that may be placed in ~/.inputrc is a valid argument to `bind'. + +c. Added `help' builtin entries for `((', `[[', and arithmetic for. + +d. malloc updated again: + o slightly better overflow and underflow detection by putting the + chunk size at the beginning and end of the chunk and making + sure they match in free/realloc + o partial page allocated to make things page-aligned no longer + completely wasted + o block coalescing now enabled by default + o splitting and coalescing enabled for 32-byte chunks, the most + common size requested + o fixed a problem that resulted in spurious underflow messages and + aborts + o bin sizes are precomputed and stored in an array rather than + being computed at run time + o malloc will return memory blocks back to the system if the block + being freed is at the top of the heap and of sufficient size to + make it worthwhile + o malloc/free/realloc now inline memset instead of calling the + libc function; uses Duff's device for good performance + +e. Check for getservent(); make the service name completion code dependent + on its presence. + +f. Changed the readline callback that executes a command bound to a key + sequence to not save the executed command on the history list and to + save and restore the parsing state. + +g. Changes to lib/sh/snprintf.c: fixed some bugs in the `g' and `G' + floating point format display; implemented the "'" flag character + that turns on thousands' grouping; fixed behavior on systems where + MB_CUR_MAX does not evaluate to a constant. + +h. The `unset' builtin no longer returns a failure status when asked to + unset a previously-unset variable or function. + +i. Changes to the build system to make it easier to cross-compile bash + for different systems. + +j. Added `,' to the characters that are backslash-escaped during filename + completion, to avoid problems with complete-into-braces and RCS filenames + containing commas. + +k. Some changes to the multibyte character support code to avoid many calls + to strlen(). + +l. Bash now correctly honors setting LANG to some value when LC_ALL does not + already have a value. + +m. Fixed a bug that could cause SIGSEGV when processing nested traps with + trap handlers. + +n. The `source/.' builtin now restores the positional parameters when it + returns unless they were changed using the `set' builtin during the file's + execution. + +o. Fixed a bug that caused a syntax error when a command was terminated by + EOF. + +2. New Features in Bash + +a. There is now support for placing the long help text into separate files + installed into ${datadir}/bash. Not enabled by default; can be turned + on with `--enable-separate-helpfiles' option to configure. + +b. All builtins that take operands accept a `--' pseudo-option, except + `echo'. + +c. The `echo' builtin now accepts \0xxx (zero to three octal digits following + the `0') in addition to \xxx (one to three octal digits) for SUSv3/XPG6/ + POSIX.1-2001 compliance. + +3. Changes to Readline + +a. Fixed a small problem in _rl_insert_char with multibyte characters. + +b. Fixes from IBM for line wrapping problems when using multibyte characters. + +c. Fixed a problem which caused the display to be messed up when the last + line of a multi-line prompt (possibly containing invisible characters) + was longer than the screen width. + +d. Fixed a problem with the vi-mode `r' command that ocurred on systems with + support for multibyte characters when running in a locale without any + multibyte characters. + +------------------------------------------------------------------------------ +This document details the changes between this version, bash-2.05b-alpha1, +and the previous version, bash-2.05a-release. + +1. Changes to Bash + +a. Some changes to work around inlining differences between compilers. + +b. Added more prototypes for internal shell typedefs, to catch argument + passing errors when using pointers to functions. + +c. The `cd' builtin now fails in posix mode when a valid directory cannot be + constructed from a relative pathname argument and the $PWD using pathname + canonicalization, and the -P option has not been supplied. Previously, + the shell would attempt to use what the user typed, leading to weird + values for $PWD and discrepancies between the value of $PWD and the + actual working directory. + +d. The `cd' builtin now resets $PWD when canonicalization fails but a chdir + to the pathname passed as an argument succeeds (when not in posix mode). + +e. The `fc' builtin has been fixed, as POSIX requires, to use the closest + history position in range when given an out-of-range argument. + +f. The history file loading code was changed to allow lines to be saved in + the history list from the shell startup files. + +g. `history -s args' now works better in compound commands. + +h. The tilde expansion code was fixed to better recognize when it's being + invoked in an assignment context, which enables expansion after `=' + and `:'. + +i. Fixed the command name completion code so a slash is no longer appended + to a single match if there happens to be a directory with that name in + $PWD. + +j. Fixed compound array assignment to no longer perform alias expansion, to + allow reserved words as array members, and to not produce extra output + when the `-v' option had been enabled. + +k. Fixed the programmable completion code to better handle newlines in lists + of possible completions (e.g., `complete -W'). + +l. Removed the reserved words from the `bash-builtins' manual page. + +m. Parser error reporting now attempts to do a better job of identifying the + token in error rather than doing straight textual analysis. + +n. Fixes for Inf/NaN, locales, wide/multibyte characters and zero-length + arguments in the library snprintf(3) replacement. + +o. `read -e' no longer does command name completion on the first word on + the line being read. + +p. `select' now returns failure if the read of the user's selection fails. + +q. Fixed a bug that could cause a core dump when setting $PIPESTATUS. + +r. Fixes to not allocate so many job slots when the shell is running a loop + with job control enabled in a subshell of an interactive shell. + +s. Fixed a bug in the trap code that caused traps to be inherited by + command substitutions in some cases. + +t. Fixed a bug that could cause alias expansion to inappropriately expand + the word following the alias. + +u. Fixed a bug in the `kill' builtin that mishandled negative pid arguments. + +v. The parser is less lenient when parsing assignment statements where the + characters before the `=' don't comprise a valid identifier. + +w. The arithmetic expression evaluation code now honors the setting of the + `-u' option when expanding variable names. + +x. Fixed the arithmetic evaluation code to allow array subscripts to be + assigned (`let b[7]=42') and auto-incremented and auto-decremented + (e.g., b[7]++). + +y. Reimplemented the existing prompt string date and time expansions using + strftime(3), which changed the output of \@ in some locales. + +z. Fixed a bug that could cause a core dump when a special shell variable + (like RANDOM) was converted to an array with a variable assignment. + +aa. Fixed a bug that would reset the handler for a signal the user had + trapped to a function that would exit the shell when setting the exit + trap in a non-interactive shell. + +bb. Changed the execve(2) wrapper code to check whether or not a failing + command is a directory before looking at whether a `#!' interpreter + failed for some reason. + +cc. Fixed a bug in the command printing code so it no longer inserts a `;' + after a newline, which produces a syntax error when reused as input. + +dd. The code that expands $PS4 no longer inherits the `-x' flag. + +ee. The bash-specific completion functions may now take advantage of the + double-TAB and M-? features of the standard readline completion + functions. + +ff. The mail checking code no longer prints a message if the checked file's + size has not increased, even if the access time is less than the modification time. + +gg. Rewrote the variable symbol table code: there is now a stack of + contexts, each possibly including a separate symbol table; there can + be more than one temporary environment supplied to nested invocations + of `./source'; the temporary environments no longer require so much + special-case code; shell functions now handle the temporary environment + and local variables more consistently; function scope exit is faster now + that the entire symbol table does not have to be traversed to dispose of + local variables; it is now easier to push vars from the temporary + environment to the shell's variable table in posix mode; some duplicated + code has been removed. + +hh. Regularized the error message printing code; builtin_error is now called + more consistently, and common error message strings are handled by small + functions. This should make eventual message translation easier. + +ii. Error messages now include the line number in a script when the shell + is not interactive. + +jj. Array subscript expansion now takes place even when the array variable is + unset, so side effects will take place. + +kk. Fixed a bug in the SICGHLD child-reaping code so that it won't find + jobs already marked as terminated if the OS reuses pids quickly enough. + +ll. Fixed a bug that could cause a signal to not interrupt the `wait' + builtin while it was waiting for a background process to terminate. + +mm. A couple of changes to make it easier for multiple shells to share history + files using `history -n', `history -r', and `history -w'. + +nn. The `getopts' builtin always increments OPTIND to point to the next + option to be handled when an option is returned, whether it's valid + or not, as POSIX 1003.x-2001 requires. + +oo. Changed some parts of the expansion code to avoid allocating and + immediately freeing memory without using the results for anything. + +pp. The shell now keeps track of $IFS internally, updating its internal map + each time the variable is assigned a new value (or at local scope exit). + This saves thousands of hash lookups for IFS, which, while individually + cheap, add up. + +qq. Rewrote the hash table code: searching and insertion are much faster now, + and it uses a better string hashing function; augmented the function + interface to simplify other parts of the code and remove duplicated code + +rr. The shell now uses a simple, generic `object cache' for allocating and + caching words and word lists, which were the major users of + malloc/free. + +ss. Fixed the assignment statement parsing code to allow whitespace and + newlines in subscripts when performing array element assignment. + +tt. The shell now issues many fewer calls to sigprocmask and other signal + masking system calls. + +uu. Fixed the `test' and conditional command file comparison operators to + work right when one file has a non-positive timestamp and the other + does not exist. + +vv. Fixed some cases where the special characters '\001' and '\177' in the + values of variables or positional parameters caused incorrect expansion + results. + +2. Changes to Readline + +a. Fixed output of comment-begin character when listing variable values. + +b. Added some default key bindings for common escape sequences produced by + HOME and END keys. + +c. Fixed the mark handling code to be more emacs-compatible. + +d. A bug was fixed in the code that prints possible completions to keep it + from printing empty strings in certain circumstances. + +e. Change the key sequence printing code to print ESC as M\- if ESC is a + meta-prefix character -- it's easier for users to understand than \e. + +f. Fixed unstifle_history() to return values that match the documentation. + +g. Fixed the event loop (rl_event_hook) to handle the case where the input + file descriptor is invalidated. + +h. Fixed the prompt display code to work better when the application has a + custom redisplay function. + +i. Changes to make reading and writing the history file a little faster, and + to cope with huge history files without calling abort(3) from xmalloc. + +j. The vi-mode `S' and `s' commands are now undone correctly. + +3. New Features in Bash + +a. If set, TMOUT is the default timeout for the `read' builtin. + +b. `type' has two new options: `-f' suppresses shell function lookup, and + `-P' forces a $PATH search. + +c. New code to handle multibyte characters. + +d. `select' was changed to be more ksh-compatible, in that the menu is + reprinted each time through the loop only if REPLY is set to NULL. + The previous behavior is available as a compile-time option. + +e. `complete -d' and `complete -o dirnames' now force a slash to be + appended to names which are symlinks to directories. + +f. There is now a bindable edit-and-execute-command readline command, + like the vi-mode `v' command, bound to C-xC-e in emacs mode. + +g. Added support for ksh93-like [:word:] character class in pattern matching. + +h. The $'...' quoting construct now expands \cX to Control-X. + +i. A new \D{...} prompt expansion; passes the `...' to strftime and inserts + the result into the expanded prompt. + +j. The shell now performs arithmetic in the largest integer size the + machine supports (intmax_t), instead of long. + +k. If a numeric argument is supplied to one of the bash globbing completion + functions, a `*' is appended to the word before expansion is attempted. + +l. The bash globbing completion functions now allow completions to be listed + with double tabs or if `show-all-if-ambiguous' is set. + +m. New `-o nospace' option for `complete' and `compgen' builtins; suppresses + readline's appending a space to the completed word. + +n. New `here-string' redirection operator: <<< word. + +o. When displaying variables, function attributes and definitions are shown + separately, allowing them to be re-used as input (attempting to re-use + the old output would result in syntax errors). + +p. There is a new configuration option `--enable-mem-scramble', controls + bash malloc behavior of writing garbage characters into memory at + allocation and free time. + +q. The `complete' and `compgen' builtins now have a new `-s/-A service' + option to complete on names from /etc/services. + +r. `read' has a new `-u fd' option to read from a specified file descriptor. + +s. Fix the completion code so that expansion errors in a directory name + don't cause a longjmp back to the command loop. + +t. Fixed word completion inside command substitution to work a little more + intuitively. + +u. The `printf' %q format specifier now uses $'...' quoting to print the + argument if it contains non-printing characters. + +v. The `declare' and `typeset' builtins have a new `-t' option. When applied + to functions, it causes the DEBUG trap to be inherited by the named + function. Currently has no effect on variables. + +w. The DEBUG trap is now run *before* simple commands, ((...)) commands, + [[...]] conditional commands, and for ((...)) loops. + +x. The expansion of $LINENO inside a shell function is only relative to the + function start if the shell is interactive -- if the shell is running a + script, $LINENO expands to the line number in the script. This is as + POSIX-2001 requires. + +y. The bash debugger in examples/bashdb has been modified to work with the + new DEBUG trap semantics, the command set has been made more gdb-like, + and the changes to $LINENO make debugging functions work better. Code + from Gary Vaughan. + +z. New [n]<&word- and [n]>&word- redirections from ksh93 -- move fds (dup + and close). + +aa. There is a new `-l' invocation option, equivalent to `--login'. + +bb. The `hash' builtin has a new `-l' option to list contents in a reusable + format, and a `-d' option to remove a name from the hash table. + +4. New Features in Readline + +a. Support for key `subsequences': allows, e.g., ESC and ESC-a to both + be bound to readline functions. Now the arrow keys may be used in vi + insert mode. + +b. When listing completions, and the number of lines displayed is more than + the screen length, readline uses an internal pager to display the results. + This is controlled by the `page-completions' variable (default on). + +c. New code to handle editing and displaying multibyte characters. + +d. The behavior introduced in bash-2.05a of deciding whether or not to + append a slash to a completed name that is a symlink to a directory has + been made optional, controlled by the `mark-symlinked-directories' + variable (default is the 2.05a behavior). + +e. The `insert-comment' command now acts as a toggle if given a numeric + argument: if the first characters on the line don't specify a + comment, insert one; if they do, delete the comment text + +f. New application-settable completion variable: + rl_completion_mark_symlink_dirs, allows an application's completion + function to temporarily override the user's preference for appending + slashes to names which are symlinks to directories. + +g. New function available to application completion functions: + rl_completion_mode, to tell how the completion function was invoked + and decide which argument to supply to rl_complete_internal (to list + completions, etc.). + +h. Readline now has an overwrite mode, toggled by the `overwrite-mode' + bindable command, which could be bound to `Insert'. + +i. New application-settable completion variable: + rl_completion_suppress_append, inhibits appending of + rl_completion_append_character to completed words. + +j. New key bindings when reading an incremental search string: ^W yanks + the currently-matched word out of the current line into the search + string; ^Y yanks the rest of the current line into the search string, + DEL or ^H deletes characters from the search string. + +------------------------------------------------------------------------------ +This document details the changes between this version, bash-2.05a-release, +and the previous version, bash-2.05a-rc1. + +1. Changes to Bash + +a. Fixed the `printf' builtin so that the variable name supplied as an + argument to a %n conversion must be a valid shell identifier. + +b. Improved the random number generator slightly. + +c. Changes to configuration to not put -I/usr/include into $CFLAGS, since + it messes up some includes. + +d. Corrected description of POSIXLY_CORRECT in man page and info manual. + +e. Fixed a couple of cases of incorrect function prototypes that sneaked + through and caused compilation problems. + +f. A few changes to avoid potential core dumps in the programmable completion + code. + +g. Fixed a configure problem that could cause a non-existent file to show + up in LIBOBJS. + +h. Fixed a configure problem that could cause siglist.o to not be built when + required. + +i. Changes to the strtoimax and strtoumax replacement functions to work + around buggy compilers. + +j. Fixed a problem with the snprintf replacement function that could + potentially cause a core dump. + +2. Changes to Readline + +a. Fixed a locale-specific problem in the vi-mode `goto mark' command. + +b. Fixed Makefile to not put -I/usr/include into CFLAGS, since it can cause + include file problems. + +------------------------------------------------------------------------------ +This document details the changes between this version, bash-2.05a-rc1, +and the previous version, bash-2.05a-beta1. + +1. Changes to Bash + +a. Fixed the snprintf replacement to correctly implement the `alternate form' + of the %g and %G conversions. + +b. Fixed snprintf to correctly handle the optional precision with the %g and + %G conversions. + +c. Fixed the arithmetic evaluation code to correct the values of `@' and `_' + when translating base-64 constants (they were backwards). + +d. New library functions for formatting long and long long ints. + +e. Fixed a few places where negative array subscripts could have occurred, + mostly as the result of systems using signed characters. + +f. Fixed a few places that assumed a pid_t was no wider than an int. + +g. Fixed the `maildir' mail checking code to work on systems where a + `struct stat' doesn't include an `st_blocks' member. + +h. Fixed snprintf to make `unsigned long long' conversion formats (%llu) + work better. + +i. Fixed snprintf to not print a sign when asked to do an unsigned conversion. + +j. Made configure changes to avoid compiling empty source files in lib/sh. + +k. New replacement functions (if necessary) for strtoull, strtoll, strtoimax, + strtoumax. + +l. The `printf' builtin now handles the `ll' and `j' length modifiers + directly, since they can affect the type and width of the argument + passed to printf(3). + +m. Renamed a number of the bash-specific autoconf macros in aclocal.m4 to + have more sytematic naming, with accompanying changes to configure.in. + +n. Fixed snprintf to handle long doubles and the %a/%A conversions by + falling back to sprintf, as long as sprintf supports them. + +o. Fixed return value from vsnprintf/snprintf to be the number of characters + that would have been printed, even if that number exceeds the buffer + size passed as an argument. + +p. Bash no longer attempts to define its own versions of some ctype macros + if they are implemented as functions in libc but not as macros in + . + +q. Changed the variable printing code (used by `set', `export', etc.) to + not use the $'...' syntax when in posix mode, since that caused + interoperability problems with other shells (most notably with autoconf). + When not in posix mode, it uses $'...' if the string to be printed + contains non-printing characters and regular single quotes otherwise. + +r. snprintf now recognizes the %F conversion. + +s. Fixed a bug that could cause the wrong status to be returned by a shell + function when the shell is compiled without job control and a null + command containing a command substutition was executed in the function. + +t. When in posix mode, the default value for MAILCHECK is 600. + +u. Bash only initializes FUNCNAME, GROUPS, and DIRSTACK as special variables + if they're not in the initial environment. + +v. If SECONDS appears in the initial environment with a valid integer value, + bash uses that as the starting value, as if an assignment had been + performed. + +w. Bash no longer auto-exports HOME, PATH, SHELL, or TERM, even though it + gives them default values if they don't appear in the initial environment. + +x. Bash no longer auto-exports HOSTNAME, HOSTTYPE, MACHTYPE, or OSTYPE, + even if it assigns them default values. + +y. Bash no longer removes the export attribute from SSH_CLIENT or SSH2_CLIENT + if they appear in the initial environment. + +z. Bash no longer attempts to discover if it's being run by sshd in order to + run the startup files. If the SSH_SOURCE_BASHRC is uncommented in + config-top.h it will attempt to do so as previously, but that's commented + out in the distributed version. + +aa. Fixed a typo in the code that tests for LC_NUMERIC. + +bb. The POSIXLY_CORRECT shell variable and its effects are now documented. + +cc. Some changes to several of the support shell scripts included in the + definitions to try to avoid race conditions and attacks. + +dd. Several changes to avoid warnings from `gcc -Wall'. + +ee. Fixed a problem with the `unset' builtin that could cause incorrect + results if asked to unset a variable and an array subscript in the + same command. + +ff. A few changes to the shell's temporary file creation code to avoid + potential file descriptor leaks and to prefer the system's idea of + the temporary directory to use. + +gg. Fixes to build with the C alloca in lib/malloc/alloca.c if the system + requires it but the shell has been configured --without-bash-malloc. + +hh. Updated the documentation to note that only interactive shells resend + SIGHUP to all jobs before exiting. + +ii. Fixes to only pass unquoted tilde words to tilde_expand, rather than + rely on tilde_expand or getpwnam(3) to handle the quotes (MacOS 10.x + will remove backslashes in any login name passed to getpwnam(3)). + +jj. Small change from Paul Eggert to make LINENO right in commands run with + `bash -c'. + +2. New Features in Bash + +a. The `printf' builtin now handles the %a and %A conversions if they're + implemented by printf(3). + +b. The `printf' builtin now handles the %F conversion (just about like %f). + +c. The `printf' builtin now handles the %n conversion like printf(3). The + corresponding argument is the name of a shell variable to which the + value is assigned. + +3. Changes to Readline + +a. Fixed a few places where negative array subscripts could have occurred. + +b. Fixed the vi-mode code to use a better method to determine the bounds of + the array used to hold the marks. + +c. Fixed the defines in chardefs.h to work better when chars are signed. + +d. Fixed configure.in to use the new names for bash autoconf macros. + +e. Readline no longer attempts to define its own versions of some ctype + macros if they are implemented as functions in libc but not as macros in + . + +f. Fixed a problem where rl_backward could possibly set point to before + the beginning of the line. + +------------------------------------------------------------------------------ +This document details the changes between this version, bash-2.05a-beta1, +and the previous version, bash-2.05a-alpha1. + +1. Changes to Bash + +a. Fixed a bug in the evalution of arithmetic `for' statements when the + expanded expression is NULL. + +b. Fixed an unassigned variable problem in the redirection printing code. + +c. Added more prototypes to extern function declarations in the header + files and to static function declarations in C source files. + +d. Make sure called functions have a prototype in scope, to get the arguments + and return values right instead of casting. Removed extern function + declarations from C source files that were already included in header + files. + +e. Changed some function arguments to use function typedefs in general.h so + the prototypes can be checked. The only use of Function and VFunction + now is for unwind-protects. + +f. More const changes to function arguments and appropriate variables. + +g. Changed the mail checking support to handle `maildir'-style mail + directories. + +h. Augmented the bash malloc to pass in the file and line number information + for each malloc, realloc, and free. This should result in better error + messages. + +i. The `old' gnu malloc is no longer a configuration option. + +j. Augmented the bash malloc with optional tracing and registering allocated + and freed memory. + +k. Prompt string decoding now saves and restores the value of $? when it + expands the prompt string, so command substitutions don't change $?. + +i. Array indices are now `long', since shell arithmetic is performed as long, + and the internal arrayind_t type is used consistently. + +j. Some more `unsigned char *' fixes from Paul Eggert. + +k. Fixed a bad call to builtin_error that could cause core dumps when making + local variables. + +l. `return' may no longer be used to terminate a `select' command, for + compatibility with ksh. + +m. Changed code that reads octal numbers to do a better job of detecting + overflows. + +n. The time formatting code no longer uses absolute indices into a buffer, + because the buffer size changes depending on the size of a `time_t'. + +o. `umask' now prints four digits when printing in octal mode, for + compatibility with other shells. + +p. Lots of changes to the `printf' builtin from Paul Eggert: it handles `L' + formats and long doubles better, and internal functions have been + simpified where appropriate. + +q. Some `time_t' fixes for machines were a time_t is bigger than a long. + +r. Replaced some bash-specific autoconf macros with standard equivalents. + +s. Improvmed the code that constructs temporary filenames to make the + generated names a bit more random. + +t. Added code that checks for ascii before calling any of the is* ctype + functions. + +u. Changed some places where a `char' was used as an array subscript to use + `unsigned char', since a `char' can be negative if it's signed by default. + +v. Lots of changes to the `ulimit' builtin from Paul Eggert to add support + for the new POSIX-200x RLIM_SAVED_CUR and RLIM_SAVED_MAX values and + simplify the code. + +w. `ulimit' now prints the description of a resource in any error message + relating to fetching or setting that resource's limits. + +x. The `snprintf' replacement now computes maximum values at compile + time rather than using huge constants for things like long long. + +y. Interactive shells now ignore `set -n'. + +z. Changed the malloc bookkeeping information so that it's now 8 bytes + instead of 12 on most 32-bit machines (saving 4 bytes per allocation), + restoring 8-byte alignment. + +aa. The malloc error reporting code now attempts to print the file and line + number of the call that caused the error. + +bb. Changed the redirection error reporting code to catch EBADF errors and + report the file descriptor number rather than the file being redirected + to or from (e.g., things like `exec 4242&word' redirection now works in POSIX mode as it does by default, + since POSIX.2 leaves it unspecified. + +------------------------------------------------------------------------------ +This document details the changes between this version, bash-2.05-beta2, +and the previous version, bash-2.05-beta1. + +1. Changes to Bash + +a. Fixed a bug in the arithmetic evaluation code so that a^=b is supported. + +b. Fixed startup so posixly_correct is retained across subshells begun to + execute scripts without a leading `#!'. + +c. Fixed a bug that caused $(< file) to not work in a (...) subshell. + +d. Added config support for Linux running on the IBM S390. + +e. Fixed a bug that caused bash to get its input pointer out of sync when + reading commands through a pipe and running a command with standard + input redirected from a file. + +f. Made a change so that command completion now makes about half as many + stat(2) calls when searching the $PATH. + +g. Fixed a bug that caused variable assignments preceding `return' to not + be propagated to the shell environment in POSIX mode. + +h. Fixed a bug with ${parameter[:]?word} -- tilde expansion was not performed + on `word'. + +i. In POSIX mode, `break' and `continue' do not complain and return success + if called when the shell is not executing a loop. + +j. Fixed `bash -o posix' to work the same as `bash --posix'. + +k. Fixed a bug where variable assignments preceding `eval' or `source/.' + would not show up in the environment exported to subshells run by the + commands. + +l. In POSIX mode, shells started to execute command substitutions inherit + the value of the `-e' option from their parent shell. + +m. In POSIX mode, aliases are expanded even in non-interactive shells. + +n. Changed some of the job control messages to display the text required by + POSIX.2 when the shell is in POSIX mode. + +o. Fixed a bug in `test' that caused it to occasionally return incorrect + results when non-numeric arguments were supplied to `-t'. + +2. Changes to Readline + +a. Some changes were made to avoid gcc warnings with -Wall. + +b. rl_get_keymap_by_name now finds keymaps case-insensitively, so + `set keymap EMACS' works. + +c. The history file writing and truncation functions now return a useful + status on error. + +d. Fixed a bug that could cause applications to dereference a NULL pointer + if a NULL second argument was passed to history_expand(). + +3. New Features in Bash + +a. doc/readline.3 has been moved to the readline distribution. + +4. New Features in Readline + +a. New function, rl_get_screen_size (int *rows, int *columns), returns + readline's idea of the screen dimensions. + +b. The timeout in rl_gather_tyi (readline keyboard input polling function) + is now settable via a function (rl_set_keyboard_input_timeout()). + +c. Renamed the max_input_history variable to history_max_entries; the old + variable is maintained for backwards compatibility. + +d. The list of characters that separate words for the history tokenizer is + now settable with a variable: history_word_delimiters. The default + value is as before. + +------------------------------------------------------------------------------ +This document details the changes between this version, bash-2.05-beta1, +and the previous version, bash-2.05-alpha1. + +1. Changes to Bash + +a. Changes to allow shared library and object building on the GNU Hurd. + +b. Fixes to the way exported functions are placed into the environment and + cached. + +c. The globbing library once again respects locales when processing ranges + in bracket expressions while doing pattern matching. + +d. System-specific configuration changes for: Tru 64, Interix + +e. Bashbug now uses /usr/bin/editor as one of the editing alternatives, and + will use mktemp(1) or tempfile(1), if present, for temporary file creation. + +f. Bash no longer performs a binary file check on a script argument that's + really a tty (like /dev/fd/0 or /dev/stdin). + +g. Fixed a bug in the execution of shell scripts that caused the effects of + $BASH_ENV to be undone in some cases. + +h. Fixed several bugs that made `bash [-i] /dev/stdin' not work correctly. + +i. Several changes to the job control code to avoid some signal state + manipulation. + +j. The Bash malloc no longer blocks signals as often, which should make it + faster. + +k. Fixed a parsing bug that did not allow backslash to escape a single quote + inside a $'...' construct. + +l. Fixed a bug that caused things like ${var:=$'value'} to be parsed + incorrectly. This showed up in newer versions of autoconf. + +m. Fixed a bug in the bash-specific readline initialization that caused + key bindings to bash-specific function names appearing in .inputrc to + not be honored. + +n. Bash now sets the file descriptor it uses to save the file descriptor + opened on a shell script to close on exec. + +o. Fixed a bug in the prompt string decoding that caused it to misbehave + when presented an octal sequence of fewer than three characters. + +p. Fixed the `test' builtin to return an error if `[' is supplied a single + argument that is not `]'. + +q. Fixed a bug that caused subshells started to run executable shell scripts + without a leading `#!' to incorrectly inherit an argument list preceding + a shell builtin (like such a script called from a script sourced with `.', + where there were variable assignments preceding the `.' command) + +r. Fixed a bug that caused changes to variables supplied in an assignment + statement preceding a shell builtin to not be honored (like a script + run with `.'). + +s. HOSTTYPE, OSTYPE, and MACHTYPE are set only if they do not have values + when the shell is started. + +t. Fixed a bug that caused SIGINT to kill shell scripts after the script + called `wait'. + +u. The `fc' builtin now tries to create its temporary files in the directory + named by $TMPDIR. + +v. Bash no longer calls any Readline functions or uses any Readline variables + not declared in readline.h. + +w. Fixed a bug that caused some substitutions involving $@ to not be split + correctly, especially expansions of the form ${paramterOPword}. + +x. SSH2_CLIENT is now treated like SSH_CLIENT and not auto-exported if it + appears in the initial environment. + +y. Fixed a couple of problems with shell scripts without a leading `#!' + being executed out of shell functions that could cause core dumps if + such a script attempted to execute `return'. + +z. Fixed a problem with the `-nt' and `-ot' binary operators for the + `test/[' builtin and the `[[' conditional command that caused wrong + return values if one of the file arguments did not exist. + +aa. Fixed a bug that caused non-interactive shells which had previously + executed `shopt -s expand_aliases' to fail to expand aliases in a + command like `(command) &'. + +2. Changes to Readline + +a. Changes to make most (but not yet all -- there is still crlf()) of the + exported readline functions declared in readline.h have an rl_ prefix. + +b. More `const' changes in function arguments, mostly for completion + functions. + +c. Fixed a bug in rl_forward that could cause the point to be set to before + the beginning of the line in vi mode. + +d. Fixed a bug in the callback read-char interface to make it work when a + readline function pushes some input onto the input stream with + rl_execute_next (like the incremental search functions). + +e. Fixed a file descriptor leak in the history file manipulation code that + was tripped when attempting to truncate a non-regular file (like + /dev/null). + +f. Some existing variables are now documented and part of the public + interface (declared in readline.h): rl_explict_arg, rl_numeric_arg, + rl_editing_mode, rl_last_func. + +g. Renamed rltty_set_default_bindings to rl_tty_set_default_bindings and + crlf to rl_crlf, so there are no public functions declared in readline.h + without an `rl_' prefix. The old functions still exist for backwards + compatibility. + +3. New Features in Bash + +a. A new loadable builtin, realpath, which canonicalizes and expands symlinks + in pathname arguments. + +b. When `set' is called without options, it prints function defintions in a + way that allows them to be reused as input. This affects `declare' and + `declare -p' as well. + +4. New Features in Readline + +a. New application-callable function rl_set_prompt(const char *prompt): + expands its prompt string argument and sets rl_prompt to the result. + +b. New application-callable function rl_set_screen_size(int rows, int cols): + public method for applications to set readline's idea of the screen + dimensions. + +c. The history example program (examples/histexamp.c) is now built as one + of the examples. + +------------------------------------------------------------------------------ +This document details the changes between this version, bash-2.05-alpha1, +and the previous version, bash-2.04-release. + +1. Changes to Bash + +a. A fix was made to allow newlines in compond array assignments. + +b. configure now checks for real-time signals with unusable values. + +c. Interactive shells no longer exit if a substitution fails because of an + unset variable within a sourced file. + +d. Fixed a problem with incorrect matching of extended glob patterns when + doing pattern substitution. + +e. `{' is now quoted by the completion code when it appears in a filename. + +f. Fixed an error in pattern matching that caused the matcher to not + correctly skip the rest of a bracket expression after a character + matched. + +g. Fixed a bug in the IFS word splitting code to make a non-whitespace IFS + character preceded by IFS whitespace part of the current delimiter rather + than generating a separate field. + +h. The {!prefix@} expansion now generates separate words, analogous to $@, + when double-quoted. + +i. Command substitution now ignores NUL bytes in the command output, and the + parser ignores them on input. + +j. A fix was made to the job control code to prevent hanging processes when + the shell thinks background processes are running but the kernel returns + -1/ECHILD from waitpid(). + +k. `pwd' now prints an error message if the write fails when displaying the + current directory. + +l. When in POSIX mode, the shell prints trap dispostions without a leading + `SIG' in the signal specification. + +m. Fixed a parser bug that caused the current command's line count to be + messed up by a compound array assignment. + +n. Fixed a bug in the unwind-protect code that caused bad behavior on machines + where ints and pointers are not the same size. + +o. System-specific configure changes for: MacOS X. + +p. Changes for Cygwin to translate \r\n and \r to \n and to set file + descriptors used for reading input to text mode in various places. + +q. Fixed a bug that caused `!' to occasionally not be honored when in + a (...) subshell. + +r. Bash no longer assumes that getcwd() will return any useful error message + in the buffer passed as an argument if the call fails. + +s. The `source', `.', and `fc' builtins no longer check whether a file is + binary before reading commands from it. + +t. Subshells no longer turn off job control when they exit, since that + sometimes resulted in the terminal being reset to the wrong process + group. + +u. The history code no longer tries to save the second and subsequent lines + of a multi-line command if the first line was not saved. + +v. The history saving code now does a better job of saving blank lines in a + multi-line command. + +w. Removed a `feature' that made `ulimit' silently translate `unlimited' to + the current hard limit, which obscured some kernel error returns. + +x. Fixed the grammar so that `}' is recognized as a reserved word after + another reserved word, rather than requiring a `;' or newline. This + means that constructs like + + { { echo a b c ; } } + + work as expected. + +y. Conditional commands ([[...]]) now perform tilde expansion on their + arguments. + +z. Noted in the documentation that `set -a' will cause functions to be + exported if they are defined after `set -a' is executed. + +aa. When an interactive login shell starts, if $PWD and $HOME refer to the + same directory but are not the same string, $PWD is set to $HOME. + +bb. Fixed `printf' to handle invalid floating point numbers better. + +cc. Temporary files are now created with random filenames, to improve security. + +dd. The readline initialization code now binds the custom bash functions and + key bindings after the readline defaults are set up. + +ee. Fixed the `source' builtin to no longer overwrite a shell function's + argument list, even if the sourced file changes the positional parameters. + +ff. A bug fix was made in the expansion of `$*' in contexts where it should + not be split, like assignment statements. + +gg. Fixed a bug in the parameter substring expansion to handle conditional + arithmetic expressions ( exp ? val1 : val2 ) without cutting the expression + off at the wrong `:'. + +hh. The `<>' redirection is no longer subject to the current setting of + `noclobber', as POSIX.2 specifies. + +ii. Fixed a bug in the conditional command parsing code that caused expressions + in parentheses to occasionally be parsed incorrectly. + +jj. Fixed a bug in the ((...)) arithmetic command to allow do...done or + {...} to follow the )) without an intervening list terminator. + +kk. `printf' now treats `\E' the same as `\e' when performing backslash escape + expansion for the `%b' format specifier. + +ll. When in POSIX mode, the shell no longer searches the current directory for + a file to be sourced with `.' or `source' if `.' is not in $PATH. + +mm. Interactive comments are no longer turned off when POSIX mode is disabled. + +nn. The UID, EUID, HOSTNAME variables are not set if they are in the shell's + environment when it starts up. + +oo. Fixed a bug in the `command' builtin so the effect of a command like + `command exec 4(...) + expansions to defer removal until after any current shell function has + finished executing. + +f. Fixed a bug in `select' which caused it to not handle the `continue' + builtin correctly. + +g. Autoconf tests added for cygwin32 and mingw32. + +2. New Features in Bash + +a. The `--with-bash-malloc' configure option replaces `--with-gnu-malloc' + (which is still there for backwards compatibility). + +------------------------------------------------------------------------------ +This document details the changes between this version, bash-2.04-beta1, +and the previous version, bash-2.04-alpha1. + +1. Changes to Bash + +a. Fixed a bug in the programmable completion code that occurred when + trying to complete command lines containing a `;' or `@'. + +b. The file descriptor from which the shell is reading a script is now + moved to a file descriptor above the user-addressible range. + +c. Changes to `printf' so that it can handle integers beginning with 0 + or 0x as octal and hex, respectively. + +d. Fixes to the programmable completion code so it handles nonsense like + `compgen -C xyz' gracefully. + +e. The shell no longer modifies the signal handler for SIGPROF, allowing + profiling again on certain systems. + +f. The shell checks for a new window size, if the user has requested it, + after a process exits due to a signal. + +g. Fixed a bug with variables with null values in a program's temporary + environment and the bash getenv() replacement. + +h. `declare' and the other builtins that take variable assignments as + arguments now honor `set -a' and mark modified variables for export. + +i. Some changes were made for --dump-po-strings mode when writing strings + with embedded newlines. + +j. The code that caches export strings from the initial environment now + duplicates the string rather than just pointing into the environment. + +k. The filename completion quoting code now uses single quotes by default + if the filename being completed contains newlines, since \ + has a special meaning to the parser. + +l. Bash now uses typedefs bits32_t and u_bits32_t instead of int32_t and + u_int32_t, respectively to avoid conflicts on certain Unix versions. + +m. Configuration changes were made for: Rhapsody, Mac OS, FreeBSD-3.x. + +n. Fixed a problem with hostname-to-ip-address translation in the + /dev/(tcp|udp)/hostname/port redirection code. + +o. The texinfo manual has been reorganized slightly. + +p. Filename generation (globbing) range comparisons in bracket expressions + no longer use strcoll(3) even if it is available, since it has unwanted + effects in certain locales. + +q. Fixed a cosmetic problem in the source that caused the shell to not + compile if DPAREN_ARITHMETIC was not defined but ARITH_FOR_COMMAND was. + +r. Fixed a bug in the here-document code tripped when the file descriptor + opened to the file containing the text of the here document was the + same as a redirector specified by the user. + +s. Fixed a bug where the INVERT_RETURN flag was not being set for `pipeline' + in `time ! pipeline'. + +t. Fixed a bug with the `wait' builtin which manifested itself when an + interrupt was received while the shell was waiting for asynchronous + processes in a shell script. + +u. Fixed the DEBUG trap code so that it has the correct value of $?. + +v. Fixed a bug in the parameter pattern substitution code that could cause + the shell to attempt to free unallocated memory if the pattern started + with `/' and an expansion error occurs. + +w. Fixed a bug in the positional parameter substring code that could + cause the shell to loop freeing freed memory. + +x. Fixed a bug in the positional parameter pattern substitution code so + that it correctly handles null replacement strings with a pattern + string prefixed with `%' or `#'. + +y. The shell no longer attempts to import functions from the environment if + started with `-n'. + +z. Fixed a bug that caused `return' in a command substitution executed in + a shell function to return from the function in a subshell and continue + execution. + +aa. `hash -p /pathname/with/slashes name' is no longer allowed when the shell + is restricted. + +bb. The wait* job control functions now behave better if called when there + are no unwaited-for children. + +cc. Command substitution no longer unconditionally disables job control in + the subshell started to run the command. + +dd. A bug was fixed that occasionally caused traps to mess up the parser + state. + +ee. `bashbug' now honors user headers in the mail message it sends. + +ff. A bug was fixed that caused the `:p' history modifier to not print the + history expansion if the `histverify' option was set. + +2. Changes to Readline + +a. Fixed a bug in the redisplay code for lines with more than 256 line + breaks. + +b. A bug was fixed which caused invisible character markers to not be + stripped from the prompt string if the terminal was in no-echo mode. + +c. Readline no longer tries to get the variables it needs for redisplay + from the termcap entry if the calling application has specified its + own redisplay function. Readline treats the terminal as `dumb' in + this case. + +d. Fixes to the SIGWINCH code so that a multiple-line prompt with escape + sequences is redrawn correctly. + +3. New Features in Bash + +a. `bashbug' now accepts `--help' and `--version' options. + +b. There is a new `xpg_echo' option to `shopt' that controls the behavior + of echo with respect to backslash-escaped characters at runtime. + +------------------------------------------------------------------------------ +This document details the changes between this version, bash-2.04-alpha1, +and the previous version, bash-2.04-devel. + +1. Changes to Bash + +a. Fixed a bug that could cause core dumps when performing substring + expansion. + +b. Shared object configuration changes for: Solaris, OSF/1 + +c. The POSIX_GLOB_LIBRARY code that uses the POSIX.2 globbing facilities + for pathname expansion now understands GLOBIGNORE. + +d. The code that implements `eval' was changed to save the value of the + current prompt, so an eval in a shell function called by the programmable + completion code will not change the prompt to $PS2. + +e. Restored the undocumented NON_INTERACTIVE_LOGIN_SHELLS #define to + config-top.h. If this is defined, all login shells will read the + startup files, not just interactive and non-interactive started with + the `--login' option. + +f. Fixed a bug that caused the expansion code to occasionally dump core if + IFS contained characters > 128. + +g. Fixed a problem with the grammar so that a newline is not required + after the `))' in the new-style arithmetic for statement; a semicolon + may be used as expected. + +h. Variable indirection may now reference the shell's special variables. + +i. The $'...' and $"..." constructs are now added to the history correctly + if they contain newlines and command-oriented history is enabled. + +j. It is now an error to try to assign a value to a function-local copy + of a readonly shell variable (declared with the `local' builtin). + +2. Changes to Readline + +a. The history file code now uses O_BINARY mode when reading and writing + the history file on cygwin32. + +3. New Features in Bash + +a. A new programmable completion facility, with two new builtin commands: + complete and compgen. + +b. configure has a new option, `--enable-progcomp', to compile in the + programmable completion features (enabled by default). + +c. `shopt' has a new option, `progcomp', to enable and disable programmable + completion at runtime. + +d. Unsetting HOSTFILE now clears the list of hostnames used for completion. + +4. New Features in Readline + +a. A new variable, rl_gnu_readline_p, always 1. The intent is that an + application can verify whether or not it is linked with the `real' + readline library or some substitute. + +------------------------------------------------------------------------------ +This document details the changes between this version, bash-2.04-devel, +and the previous version, bash-2.03-release. + +1. Changes to Bash + +a. System-specific configuration and source changes for: Interix, Rhapsody + +b. Fixed a bug in execute_cmd.c that resulted in a compile-time error if + JOB_CONTROL was not defined. + +c. An obscure race condition in the trap code was fixed. + +d. The string resulting from $'...' is now requoted to avoid any further + expansion. + +e. The $'...' quoting syntax now allows backslash to escape a single quote, + for ksh-93 compatibility. + +f. The $"..." quoting syntax now escapes backslashes and double quotes in + the translated string when displaying them with the --dump-po-strings + option. + +g. `echo -e' no longer converts \' to '. + +h. Fixes were made to the extended globbing code to handle embedded (...) + patterns better. + +i. Some improvements were made to the code that unsets `nodelay' mode on + the file descriptor from which bash is reading input. + +j. Some changes were made to the replacement termcap library for better + operation on MS-DOS. + +k. Some changes were made to the tilde expansion code to handle backslash + as a pathname separator on MS-DOS. + +l. The source has been reorganized a little bit -- there is now an `include' + subdirectory, and lib/posixheaders has been removed. + +m. Improvements were made to the `read' builtin so that it makes many + fewer read(2) system calls. + +n. The expansion of $- will include `c' and `s' when those options are + supplied at shell invocation. + +o. Several improvments were made to the completion code: variable completion + now works better when there are unterminated expansions, command + completion understands quotes better, and completion now works in certain + unclosed $(... constructs. + +p. The arithmetic expansion code was fixed to not need the value of a + variable being assigned a value (fixes the "ss=09; let ss=10" bug). + +q. Some changes were made to make exported environment creation faster. + +r. The html documentation will be installed into $(htmldir) if that variable + has a value when `make install' is run. + +s. Fixed a bug that would cause the bashrc file to be sourced inappropriately + when bash is started by sshd. + +t. The SSH_CLIENT environment variable is no longer auto-exported. + +u. A bug that caused redirections with (...) subshells to be performed in + the wrong order was fixed. + +v. A bug that occasionally caused inappropriate expansion of assignment + statements in compound array assignments was fixed. + +w. The code that parses the words in a compound array assignment was + simplified considerably and should work better now. + +x. Fixes to the non-job-control code in nojobs.c to make it POSIX.2-compliant + when a user attempts to retrieve the status of a terminated background + process. + +y. Fixes to the `printf' builtin so that it doesn't try to expand all + backslash escape sequences in the format string before parsing it for + % format specifiers. + +2. Changes to Readline + +a. The history library tries to truncate the history file only if it is a + regular file. + +b. A bug that caused _rl_dispatch to address negative array indices on + systems with signed chars was fixed. + +c. rl-yank-nth-arg now leaves the history position the same as when it was + called. + +d. Changes to the completion code to handle MS-DOS drive-letter:pathname + filenames. + +e. Completion is now case-insensitive by default on MS-DOS. + +f. Fixes to the history file manipulation code for MS-DOS. + +g. Readline attempts to bind the arrow keys to appropriate defaults on MS-DOS. + +h. Some fixes were made to the redisplay code for better operation on MS-DOS. + +i. The quoted-insert code will now insert tty special chars like ^C. + +j. A bug was fixed that caused the display code to reference memory before + the start of the prompt string. + +k. More support for __EMX__ (OS/2). + +l. A bug was fixed in readline's signal handling that could cause infinite + recursion in signal handlers. + +m. A bug was fixed that caused the point to be less than zero when rl_forward + was given a very large numeric argument. + +n. The vi-mode code now gets characters via the application-settable value + of rl_getc_function rather than calling rl_getc directly. + +3. New Features in Bash + +a. The history builtin has a `-d offset' option to delete the history entry + at position `offset'. + +b. The prompt expansion code has two new escape sequences: \j, the number of + active jobs; and \l, the basename of the shell's tty device name. + +c. The `bind' builtin has a new `-x' option to bind key sequences to shell + commands. + +d. There is a new shell option, no_empty_command_completion, which, when + enabled, disables command completion when TAB is typed on an empty line. + +e. The `help' builtin has a `-s' option to just print a builtin's usage + synopsys. + +f. There are several new arithmetic operators: id++, id-- (variable + post-increment/decrement), ++id, --id (variabl pre-increment/decrement), + expr1 , expr2 (comma operator). + +g. There is a new ksh-93 style arithmetic for command: + for ((expr1 ; expr2; expr3 )); do list; done + +h. The `read' builtin has a number of new options: + -t timeout only wait timeout seconds for input + -n nchars only read nchars from input instead of a full line + -d delim read until delim rather than newline + -s don't echo input chars as they are read + +i. The redirection code now handles several filenames specially: + /dev/fd/N, /dev/stdin, /dev/stdout, and /dev/stderr, whether or + not they are present in the file system. + +j. The redirection code now recognizes pathnames of the form + /dev/tcp/host/port and /dev/udp/host/port, and tries to open a socket + of the appropriate type to the specified port on the specified host. + +k. The ksh-93 ${!prefix*} expansion, which expands to the names of all + shell variables whose names start with prefix, has been implemented. + +l. There is a new dynamic variable, FUNCNAME, which expands to the name of + a currently-executing function. Assignments to FUNCNAME have no effect. + +m. The GROUPS variable is no longer readonly; assignments to it are silently + discarded. This means it can be unset. + +4. New Features in Readline + +a. Parentheses matching is now always compiled into readline, and enabled + or disabled when the value of the `blink-matching-paren' variable is + changed. + +b. MS-DOS systems now use ~/_inputrc as the last-ditch inputrc filename. + +c. MS-DOS systems now use ~/_history as the default history file. + +d. history-search-{forward,backward} now leave the point at the end of the + line when the string to search for is empty, like + {reverse,forward}-search-history. + +e. history-search-{forward,backward} now leave the last history line found + in the readline buffer if the second or subsequent search fails. + +f. New function for use by applications: rl_on_new_line_with_prompt, used + when an application displays the prompt itself before calling readline(). + +g. New variable for use by applications: rl_already_prompted. An application + that displays the prompt itself before calling readline() must set this to + a non-zero value. + +------------------------------------------------------------------------------ +This document details the changes between this version, bash-2.03-release, +and the previous version, bash-2.03-beta2. + +1. Changes to Bash + +a. A file descriptor leak in the `fc' builtin was fixed. + +b. A bug was fixed in the `read' builtin that caused occasional spurious + failures when using `read -e'. + +c. The version code needed to use the value of the cpp variable + CONF_MACHTYPE rather than MACHTYPE. + +d. A new test was added to exercise the command printing and copying code. + +e. A bug was fixed that caused `time' to be recognized as a reserved word + if it was the first pattern in a `case' statement pattern list. + +------------------------------------------------------------------------------ +This document details the changes between this version, bash-2.03-beta2, +and the previous version, bash-2.03-beta1. + +1. Changes to Bash + +a. Slight additions to support/shobj-conf, mostly for the benefit of AIX 4.2. + +b. config.{guess,sub} support added for the NEC SX4. + +c. Changed some of the cross-compiling sections of the configure macros in + aclocal.m4 so that configure won't abort. + +d. Slight changes to how the HTML versions of the bash and readline manuals + are generated. + +e. Fixed conditional command printing to avoid interpreting printf `%'-escapes + in arguments to [[. + +f. Don't include the bash malloc on all variants of the alpha processor. + +g. Changes to configure to make --enable-profiling work on Solaris 2.x. + +h. Fixed a bug that manifested itself when shell functions were called + between calls to `getopts'. + +i. Fixed pattern substitution so that a bare `#'as a pattern causes the + replacement string to be prefixed to the search string, and a bare + `%' causes the replacement string to be appended to the search string. + +j. Fixed a bug in the command execution code that caused child processes + to occasionally have the wrong value for $!. + +2. Changes to Readline + +a. Added code to the history library to catch history substitutions using + `&' without a previous history substitution or search having been + performed. + +3. New Features in Bash + +4. New Features in Readline + +a. New bindable variable: `isearch-terminators'. + +b. New bindable function: `forward-backward-delete-char' (unbound by default). + +------------------------------------------------------------------------------ +This document details the changes between this version, bash-2.03-beta1, +and the previous version, bash-2.03-alpha. + +1. Changes to Bash + +a. A change was made to the help text for `{...}' to make it clear that a + semicolon is required before the closing brace. + +b. A fix was made to the `test' builtin so that syntax errors cause test + to return an exit status > 1. + +c. Globbing is no longer performed on assignment statements that appear as + arguments to `assignment builtins' such as `export'. + +d. System-specific configuration changes were made for: Rhapsody, + AIX 4.2/gcc, BSD/OS 4.0. + +e. New loadable builtins: ln, unlink. + +f. Some fixes were made to the globbing code to handle extended glob patterns + which immediately follow a `*'. + +g. A fix was made to the command printing code to ensure that redirections + following compound commands have a space separating them from the rest + of the command. + +h. The pathname canonicalization code was changed to produce fewer leading + `//' sequences, since those are interpreted as network file system + pathnames on some systems. + +i. A fix was made so that loops containing `eval' commands in commands passed + to `bash -c' would not exit prematurely. + +j. Some changes were made to the job reaping code when the shell is not + interactive, so the shell will retain exit statuses longer for examination + by `wait'. + +k. A fix was made so that `jobs | command' works again. + +l. The erroneous compound array assignment var=((...)) is now a syntax error. + +m. A change was made to the dynamic loading code in `enable' to support + Tenon's MachTen. + +n. A fix was made to the globbing code so that extended globbing patterns + will correctly match `.' in a bracket expression. + +2. Changes to Readline + +a. A fix was made to the completion code in which a typo caused the wrong + value to be passed to the function that computed the longest common + prefix of the list of matches. + +b. The completion code now checks the value of rl_filename_completion_desired, + which is set by application-supplied completion functions to indicate + that filename completion is being performed, to decide whether or not to + call an application-supplied `ignore completions' function. + +3. New Features in Bash + +a. A change was made to the startup file code so that any shell begun with + the `--login' option, even non-interactive shells, will source the login + shell startup files. + +4. New Features in Readline + +a. A new variable, rl_erase_empty_line, which, if set by an application using + readline, will cause readline to erase, prompt and all, lines on which the + only thing typed was a newline. + +------------------------------------------------------------------------------ +This document details the changes between this version, bash-2.03-alpha, +and the previous version, bash-2.02.1-release. + +1. Changes to Bash + +a. System-specific configuration changes were made for: Irix 6.x, Unixware 7. + +b. The texi2dvi and texi2html scripts were updated to the latest versions + from the net. + +c. The configure tests that determine which native type is 32 bits were + changed to not require a compiled program. + +d. Fixed a bug in shell_execve that could cause memory to be freed twice + after a failed exec. + +e. The `printf' test uses `diff -a' if it's available to prevent confusion + due to the non-ascii output. + +f. Shared object configuration is now performed by a shell script, + support/shobj-conf, which generates values to be substituted into + makefiles by configure. + +g. Some changes were made to `ulimit' to avoid the use of RLIM_INVALID as a + return value. + +h. Changes were made to `ulimit' to work around HPUX 9.x's peculiar + handling of RLIMIT_FILESIZE. + +i. Some new loadable builtins were added: id, printenv, sync, whoami, push, + mkdir. `pushd', `popd', and `dirs' can now be built as regular or + loadable builtins from the same source file. + +j. Changes were made to `printf' to handle NUL bytes in the expanded format + string. + +k. The various `make clean' Makefile targets now descend into lib/sh. + +l. The `type' builtin was changed to use the internal `getopt' so that things + like `type -ap' work as expected. + +m. There is a new configuration option, --with-installed-readline, to link + bash with a locally-installed version of readline. Only readline version + 4.0 and later releases can support this. Shared and static libraries + are supported. The installed include files are used. + +n. There is a new autoconf macro used to find which basic type is 64 bits. + +o. Dynamic linking and loadable builtins should now work on SCO 3.2v5*, + AIX 4.2 with gcc, Unixware 7, and many other systems using gcc, where + the `-shared' options works correctly. + +p. A bug was fixed in the bash filename completion code that caused memory to + be freed twice if a directory name containing an unset variable was + completed and the -u option was set. + +q. The prompt expansion code now quotes the `$' in the `\$' expansion so it + is not processed by subsequent parameter expansion. + +r. Fixed a parsing bug that caused a single or double quote after a `$$' to + trigger ANSI C expansion or locale translation. + +s. Fixed a bug in the globbing code that caused quoted filenames containing + no globbing characters to sometimes be incorrectly expanded. + +t. Changes to the default prompt strings if prompt string decoding is not + compiled into the shell. + +u. Added `do', `then', `else', `{', and `(' to the list of keywords that may + precede the `time' reserved word. + +v. The shell may now be cross-built for BeOS as well as cygwin32. + +w. The conditional command execution code now treats `=' the same as `==' + for deciding when to perform pattern matching. + +x. The `-e' option no longer causes the shell to exit if a command exits + with a non-zero status while running the startup files. + +y. The `printf' builtin no longer dumps core if a modifier is supplied in + the format string without a conversion character (e.g. `%h'). + +z. Array assignments of the form a=(...) no longer show up in the history + list. + +aa. The parser was fixed to obey the POSIX.2 rules for finding the closing + `}' in a ${...} expression. + +bb. The history file is now opened with mode 0600 rather than 0666, so bash + no longer relies on the user's umask being set appropriately. + +cc. Setting LANG no longer causes LC_ALL to be assigned a value; bash now + relies on proper behavior from the C library. + +dd. Minor changes were made to allow quoted variable expansions using + ${...} to be completed correctly if there is no closing `"'. + +ee. Changes were made to builtins/Makefile.in so that configuring the shell + with `--enable-profiling' works right and builtins/mkbuiltins is + generated. + +2. Changes to Readline + +a. The version number is now 4.0. + +b. There is no longer any #ifdef SHELL code in the source files. + +c. Some changes were made to the key binding code to fix memory leaks and + better support Win32 systems. + +d. Fixed a silly typo in the paren matching code -- it's microseconds, not + milliseconds. + +e. The readline library should be compilable by C++ compilers. + +f. The readline.h public header file now includes function prototypes for + all readline functions, and some changes were made to fix errors in the + source files uncovered by the use of prototypes. + +g. The maximum numeric argument is now clamped at 1000000. + +h. Fixes to rl_yank_last_arg to make it behave better. + +i. Fixed a bug in the display code that caused core dumps if the prompt + string length exceeded 1024 characters. + +j. The menu completion code was fixed to properly insert a single completion + if there is only one match. + +k. A bug was fixed that caused the display code to improperly display tabs + after newlines. + +3. New Features in Bash + +a. New `shopt' option, `restricted_shell', indicating whether or not the + shell was started in restricted mode, for use in startup files. + +b. Filename generation is now performed on the words between ( and ) in + array assignments (which it probably should have done all along). + +c. OLDPWD is now auto-exported, as POSIX.2 seems to require. + +d. ENV and BASH_ENV are read-only variables in a restricted shell. + +4. New Features in Readline + +a. Many changes to the signal handling: + o Readline now catches SIGQUIT and cleans up the tty before returning; + o A new variable, rl_catch_signals, is available to application writers + to indicate to readline whether or not it should install its own + signal handlers for SIGINT, SIGTERM, SIGQUIT, SIGALRM, SIGTSTP, + SIGTTIN, and SIGTTOU; + o A new variable, rl_catch_sigwinch, is available to application + writers to indicate to readline whether or not it should install its + own signal handler for SIGWINCH, which will chain to the calling + applications's SIGWINCH handler, if one is installed; + o There is a new function, rl_free_line_state, for application signal + handlers to call to free up the state associated with the current + line after receiving a signal; + o There is a new function, rl_cleanup_after_signal, to clean up the + display and terminal state after receiving a signal; + o There is a new function, rl_reset_after_signal, to reinitialize the + terminal and display state after an application signal handler + returns and readline continues + +b. There is a new function, rl_resize_terminal, to reset readline's idea of + the screen size after a SIGWINCH. + +c. New public functions: rl_save_prompt and rl_restore_prompt. These were + previously private functions with a `_' prefix. + +d. New function hook: rl_pre_input_hook, called just before readline starts + reading input, after initialization. + +e. New function hook: rl_display_matches_hook, called when readline would + display the list of completion matches. The new function + rl_display_match_list is what readline uses internally, and is available + for use by application functions called via this hook. + +f. New bindable function, delete-char-or-list, like tcsh. + +------------------------------------------------------------------------------ +This document details the changes between this version, bash-2.02.1-release, +and the previous version, bash-2.02-release. + +1. Changes to Bash + +a. A bug that caused the bash readline support to not compile unless aliases + and csh-style history were configured into the shell was fixed. + +b. Fixed a bug that could cause a core dump when here documents contained + more than 1000 characters. + +c. Fixed a bug that caused a CDPATH entry of "" to not be treated the same + as the current directory when in POSIX mode. + +d. Fixed an alignment problem with the memory returned by the bash malloc, + so returned memory is now 64-bit aligned. + +e. Fixed a bug that caused command substitutions executed within pipelines + to put the terminal in the wrong process group. + +f. Fixes to support/config.sub for: alphas, SCO Open Server and Open Desktop, + Unixware 2, and Unixware 7. + +g. Fixes to the pattern matching code to make it work correctly for eight-bit + characters. + +h. Fixed a problem that occasionally caused the shell to display the wrong + value for the new working directory when changing to a directory found + in $CDPATH when in physical mode. + +i. Fixed a bug that caused core dumps when using conditional commands in + shell functions. + +j. Fixed a bug that caused the printf builtin to loop forever if the format + string did not consume any of the arguments. + +k. Fixed a bug in the parameter expansion code that caused "$@" to be + incorrectly split if $IFS did not contain a space character. + +l. Fixed a bug that could cause a core dump when completing hostnames if + the number of matching hostnames was an exact multiple of 16. + +m. Fixed a bug that caused the shell to fork too early when a command + such as `%2 &' was given. + +2. Changes to Readline + +a. Fixed a problem with redisplay that showed up when the prompt string was + longer than the screen width and the prompt contained invisible characters. + +------------------------------------------------------------------------------ +This document details the changes between this version, bash-2.02-release, +and the previous version, bash-2.02-beta2. + +1. Changes to Bash + +a. A bug was fixed that caused the terminal process group to be set + incorrectly when performing command substitution of builtins in a + pipeline. + +------------------------------------------------------------------------------ +This document details the changes between this version, bash-2.02-beta2, +and the previous version, bash-2.02-beta1. + +1. Changes to Bash + +a. Attempting to `wait' for stopped jobs now generates a warning message. + +b. Pipelines which exit due to SIGPIPE in non-interactive shells are now + not reported if the shell is compiled -DDONT_REPORT_SIGPIPE. + +c. Some changes were made to builtins/psize.sh and support/bashbug.sh to + attempt to avoid some /tmp file races and surreptitious file + substitutions. + +d. Fixed a bug that caused the shell not to compile if configured with + dparen arithmetic but without aliases. + +e. Fixed a bug that caused the input stream to be switched when assigning + empty arrays with `bash -c'. + +f. A bug was fixed in the readline expansion glue code that caused bash to + dump core when expanding lines with an unclosed single quote. + +g. A fix was made to the `cd' builtin so that using a non-empty directory + from $CDPATH results in an absolute pathname of the new current working + directory to be displayed after the current directory is changed. + +h. Fixed a bug in the variable assignment code that caused the shell to + dump core when referencing an unset variable with `set -u' enabled in + an assignment statement preceding a command. + +i. Fixed a bug in the exit trap code that caused reserved words to not be + recognized under certain circumstances. + +j. Fixed a bug in the parameter pattern substitution code so that quote + removal is performed. + +k. The shell should now configure correctly on Apple Rhapsody systems. + +l. The `kill' builtin now prints a usage message if it is not passed any + arguments. + +------------------------------------------------------------------------------ +This document details the changes between this version, bash-2.02-beta1, +and the previous version, bash-2.02-alpha1. + +1. Changes to Bash + +a. A few compilation bugs were fixed in the new extended globbing code. + +b. Executing arithmetic commands now sets the command name to `((' so + error messages look right. + +c. Fixed some build problems with various configuration options. + +d. The `printf' builtin now aborts immediately if an illegal format + character is encountered. + +e. The code that creates here-documents now behaves better if the file it's + trying to create already exists for some reason. + +f. Fixed a problem with the extended globbing code that made patterns like + `x+*' expand incorrectly. + +g. The prompt string expansion code no longer quotes tildes with backslashes. + +h. The bash getcwd() implementation in lib/sh/getcwd.c now behaves better in + the presence of lstat(2) failures. + +i. Fixed a bug with strsub() that caused core dumps when executing `fc -s'. + +j. The mail checking code now ensures that it has a valid default mailpath. + +k. A bug was fixed that caused local variables to be unset inappropriately + when sourcing a script from within another sourced script. + +l. A bug was fixed in the history saving code so that functions are saved + in the history list correctly if `cmdhist' is enabled, but `lithist' + is not. + +m. A bug was fixed that caused printf overflows when displaying error + messages. + +n. It should be easier to build the loadble builtins in examples/loadables, + though some manual editing of the generated Makefile is still required. + +o. The user's primary group is now always ${GROUPS[0]}. + +p. Some updates were made to support/config.guess from the GNU master copy. + +q. Some changes were made to the autoconf support for Solaris 2.6 large + files. + +r. The `command' builtins now does the right thing when confstr(3) cannot + find a value for _CS_PATH. + +s. Extended globbing expressions like `*.!(c)' are not history expanded if + `extglob' is enabled. + +t. Using the `-P' option to `cd' will force the value that is assigned to + PWD to not contain any symbolic links. + +2. Changes to Readline + +a. The code that prints completion listings now behaves better if one or + more of the filenames contains non-printable characters. + +b. The time delay when showing matching parentheses is now 0.5 seconds. + +------------------------------------------------------------------------------ +This document details the changes between this version, bash-2.02-alpha1, +and the previous version, bash-2.01.1-release. + +1. Changes to Bash + +a. OS-specific configuration changes for: BSD/OS 3.x, Minix 2.x, + Solaris 2.6, SINIX SVR4. + +b. Changes were made to the generated `info' files so that `install-info' + works correctly. + +c. PWD is now auto-exported. + +d. A fix was made to the pipeline code to make sure that the shell forks + to execute simple commands consisting solely of assignment statements. + +e. Changes to the test suite for systems with 14-character filenames. + +f. The default sizes of some internal hash tables have been made smaller + to reduce the shell's memory footprint. + +g. The `((...))' arithmetic command is now executed directly instead of + being translated into `let "..."'. + +h. Fixes were made to the expansion code so that "$*", "$@", "${array[@]}", + and "${array[@]}" expand correctly when IFS does not contain a space + character, is unset, or is set to NULL. + +i. The indirect expansion code (${!var}) was changed so that the only + valid values of `var' are variable names, positional parameters, `#', + `@', and `*'. + +j. An arithmetic expression error in a $((...)) expansion now causes a + non-interactive shell running in posix mode to exit. + +k. Compound array assignment now splits the words within the parentheses + on shell metacharacters like the parser would before expansing them + and performing the assignment. This is for compatibility with ksh-93. + +l. The internal shell backslash-quoting code (used in the output of `set' + and completion) now quotes tildes if they appear at the start of the + string or after a `=' or `:'. + +m. A couple of bugs with `shopt -o' were fixed. + +n. `bash +o' now displays the same output as `set +o' before starting an + interactive shell. + +o. A bug that caused command substitution and the `eval' builtin to + occasionally free memory twice when an error was encountered was fixed. + +p. The filename globbing code no longer requires read permission for a + directory when the filename to be matched does not contain any globbing + characters, as POSIX.2 specifies. + +q. A bug was fixed so that the job containing the last asynchronous + process is not removed from the job table until a `wait' is executed + for that process or another asynchronous process is started. This + satisfies a POSIX.2 requirement. + +r. A `select' bug was fixed so that a non-numeric user response is treated + the same as a numeric response that is out of range. + +s. The shell no longer parses the value of SHELLOPTS from the environment + if it is restricted, running setuid, or running in `privileged mode'. + +t. Fixes were made to enable large file support on systems such as + Solaris 2.6, where the size of a file may be larger than can be held + in an `int'. + +u. The filename hashing code was fixed to not add `./' to the beginning of + filenames which already begin with `./'. + +v. The configure script was changed so that the GNU termcap library is not + compiled in if `prefer-curses' has been specified. + +w. HISTCONTROL and HISTIGNORE are no longer applied to the second and + subsequent lines of a multi-line command. + +x. A fix was made to `disown' so that it does a better job of catching + out-of-range jobs. + +y. Non-interactive shells no longer report the status of processes terminated + due to SIGINT, even if the standard output is a terminal. + +z. A bug that caused the output of `jobs' to have extra carriage returns + was fixed. + +aa. A bug that caused PIPESTATUS to not be set when builtins or shell + functions were executed in the foreground was fixed. + +bb. Bash now attempts to detect when it is being run by sshd, and treats + that case identically to being run by rshd. + +cc. A bug that caused `set -a' to export SHELLOPTS when one of the shell + options was changed was fixed. + +dd. The `kill' builtin now disallows empty or missing process id arguments + instead of treating them as identical to `0', which means the current + process. + +ee. `var=value declare -x var' now behaves identically to + `var=value export var'. Similarly for `var=value declare -r var' and + `var=value readonly var'. + +ff. A few memory leaks were fixed. + +gg. `alias' and `unalias' now print error messages when passed an argument + that is not an alias for printing or deletion, even when the shell is + not interactive, as POSIX.2 specifies. + +hh. `alias' and `alias -p' now return a status of 0 when no aliases are + defined, as POSIX.2 specifes. + +ii. `cd -' now prints the pathname of the new working directory if the shell + is interactive. + +jj. A fix was made so that the code that binds $PWD now copes with getcwd() + returning NULL. + +kk. `unset' now checks whether or not a function name it's trying to unset + is a valid shell identifier only when the shell is running in posix mode. + +ll. A change was made to the code that generates filenames for here documents + to make them less prone to name collisions. + +mm. The parser was changed so that `time' is recognized as a reserved word + only at the beginning of a pipeline. + +nn. The pathname canonicalization code was changed so that `//' is converted + into `/', but all other pathnames beginning with `//' are left alone, as + POSIX.2 specifies. + +oo. The `logout' builtin will no longer exit a non-interactive non-login + shell. + +2. Changes to Readline + +a. Fixed a problem in the readline test program rltest.c that caused a core + dump. + +b. The code that handles parser directives in inputrc files now displays + more error messages. + +c. The history expansion code was fixed so that the appearance of the + history comment character at the beginning of a word inhibits history + expansion for that word and the rest of the input line. + +3. New Features in Bash + +a. A new version of malloc, based on the older GNU malloc, that has many + changes, is more page-based, is more conservative with memory usage, + and does not `orphan' large blocks when they are freed. + +b. A new version of gmalloc, based on the old GLIBC malloc, with many + changes and range checking included by default. + +c. A new implementation of fnmatch(3) that includes full POSIX.2 Basic + Regular Expression matching, including character classes, collating + symbols, equivalence classes, and support for case-insensitive pattern + matching. + +d. ksh-88 egrep-style extended pattern matching ([@+*?!](patlist)) has been + implemented, controlled by a new `shopt' option, `extglob'. + +e. There is a new ksh-like `[[' compound command, which implements + extended `test' functionality. + +f. There is a new `printf' builtin, implemented according to the POSIX.2 + specification. + +g. There is a new feature for command substitution: $(< filename) now expands + to the contents of `filename', with any trailing newlines removed + (equivalent to $(cat filename)). + +h. There are new tilde prefixes which expand to directories from the + directory stack. + +i. There is a new `**' arithmetic operator to do exponentiation. + +j. There are new configuration options to control how bash is linked: + `--enable-profiling', to allow bash to be profiled with gprof, and + `--enable-static-link', to allow bash to be linked statically. + +k. There is a new configuration option, `--enable-cond-command', which + controls whether or not the `[[' command is included. It is on by + default. + +l. There is a new configuration option, `--enable-extended-glob', which + controls whether or not the ksh extended globbing feature is included. + It is enabled by default. + +m. There is a new configuration #define in config.h.top that, when enabled, + will cause all login shells to source /etc/profile and one of the user- + specific login shell startup files, whether or not the shell is + interactive. + +n. There is a new invocation option, `--dump-po-strings', to dump + a shell script's translatable strings ($"...") in GNU `po' format. + +o. There is a new `shopt' option, `nocaseglob', to enable case-insensitive + pattern matching when globbing filenames and using the `case' construct. + +p. There is a new `shopt' option, `huponexit', which, when enabled, causes + the shell to send SIGHUP to all jobs when an interactive login shell + exits. + +q. `bind' has a new `-u' option, which takes a readline function name as an + argument and unbinds all key sequences bound to that function in a + specified keymap. + +r. `disown' now has `-a' and `-r' options, to limit operation to all jobs + and running jobs, respectively. + +s. The `shopt' `-p' option now causes output to be displayed in a reusable + format. + +t. `test' has a new `-N' option, which returns true if the filename argument + has been modified since it was last accessed. + +u. `umask' now has a `-p' option to print output in a reusable format. + +v. A new escape sequence, `\xNNN', has been added to the `echo -e' and $'...' + translation code. It expands to the character whose ascii code is NNN + in hexadecimal. + +w. The prompt string expansion code has a new `\r' escape sequence. + +x. The shell may now be cross-compiled for the CYGWIN32 environment on + a Unix machine. + +4. New Features in Readline + +a. There is now an option for `iterative' yank-last-arg handline, so a user + can keep entering `M-.', yanking the last argument of successive history + lines. + +b. New variable, `print-completions-horizontally', which causes completion + matches to be displayed across the screen (like `ls -x') rather than up + and down the screen (like `ls'). + +c. New variable, `completion-ignore-case', which causes filename completion + and matching to be performed case-insensitively. + +d. There is a new bindable command, `magic-space', which causes history + expansion to be performed on the current readline buffer and a space to + be inserted into the result. + +e. There is a new bindable command, `menu-complete', which enables tcsh-like + menu completion (successive executions of menu-complete insert a single + completion match, cycling through the list of possible completions). + +f. There is a new bindable command, `paste-from-clipboard', for use on Win32 + systems, to insert the text from the Win32 clipboard into the editing + buffer. + +g. The key sequence translation code now understands printf-style backslash + escape sequences, including \NNN octal escapes. These escape sequences + may be used in key sequence definitions or macro values. + +h. An `$include' inputrc file parser directive has been added. + +------------------------------------------------------------------------------ +This document details the changes between this version, bash-2.01.1-release, +and the previous version, bash-2.01-release. + +1. Changes to Bash + +a. The select command was fixed to check the validity of the user's + input more strenuously. + +b. A bug was fixed that prevented `time' from timing commands correctly + when supplied as an argument to `bash -c'. + +c. A fix was made to the mail checking code to keep from adding the same + mail file to the list of files to check multiple times when parsing + $MAILPATH. + +d. Fixed an off-by-one error in the tilde expansion library. + +e. When using the compound array assignment syntax, the old value of + the array is cleared before assigning the new value. + +f. Fixed a bug that could cause a core dump when a trap handler was reset + to the default in the trap command associated with that signal. + +g. Fixed a bug in the locale code that occurred when assigning a value + to LC_ALL. + +h. A change was made to the parser so that words of the form xxx=(...) + are not considered compound assignment statements unless there are + characters before the `='. + +i. A fix was made to the command tracing code to correctly quote each + word of output. + +j. Some changes were made to the bash-specific autoconf tests to make them + more portable. + +k. Completion of words with globbing characters now correctly quotes the + result. + +l. The directory /var/spool/mail is now preferred to /usr/spool/mail when + configure is deciding on the default mail directory. + +m. The brace completion code was fixed to not quote the `{' and `}'. + +n. Some fixes were made to make $RANDOM more random in subshells. + +o. System-specific changes were made to configure for: SVR4.2 + +p. Changes were made so that completion of words containing globbing chars + substitutes the result only if a single filename was matched. + +q. The window size is now recomputed after a job is stopped with SIGTSTP if + the user has set `checkwinsize' with `shopt'. + +r. When doing substring expansion, out-of-range substring specifiers now + cause nothing to be substituted rather than an expansion error. + +s. A fix was made so that you can no longer trap `SIGEXIT' or `SIGDEBUG' -- + only `EXIT' and `DEBUG' are accepted. + +t. The display of trapped signals now uses the signal number if signals + for which bash does not know the name are trapped. + +u. A fix was made so that `bash -r' does not turn on restricted mode until + after the startup files are executed. + +v. A bug was fixed that occasionally caused a core dump when a variable + found in the temporary environment of export/declare/readonly had a + null value. + +w. A bug that occasionally caused unallocated memory to be passed to free() + when doing arithmetic substitution was fixed. + +x. A bug that caused a buffer overrun when expanding a prompt string + containing `\w' and ${#PWD} exceeded PATH_MAX was fixed. + +y. A problem with the completion code that occasionally caused it to + refer to a character before the beginning of the readline line buffer + was fixed. + +z. A bug was fixed so that the `read' builtin restarts reads when + interrupted by signals other than SIGINT. + +aa. Fixed a bug that caused a command to be freed twice when there was + an evaluation error in the `eval' command. + +2. Changes to Readline + +a. Added a missing `extern' to a declaration in readline.h that kept + readline from compiling cleanly on some systems. + +b. The history file is now opened with mode 0600 when it is written for + better security. + +c. Changes were made to the SIGWINCH handling code so that prompt redisplay + is done better. + +d. ^G now interrupts incremental searches correctly. + +e. A bug that caused a core dump when the set of characters to be quoted + when completing words was empty was fixed. + +------------------------------------------------------------------------------ +This document details the changes between this version, bash-2.01-release, +and the previous version, bash-2.01-beta2. + +1. Changes to Bash + +a. The `distclean' target should remove the `printenv' executable if it + has been created. + +b. The test suite was changed slightly to ensure that the error messages + are printed in English. + +c. A bug that caused the shell to dump core when a filename containing a + `/' was passed to `hash' was fixed. + +d. Pathname canonicalization now leaves a leading `//' intact, as POSIX.1 + requires. + +e. A memory leak when completing commands was fixed. + +f. A memory leak that occurred when checking the hash table for commands + with relative paths was fixed. + +------------------------------------------------------------------------------ +This document details the changes between this version, bash-2.01-beta2, +and the previous version, bash-2.01-beta1. + +1. Changes to Bash + +a. The `ulimit' builtin translates RLIM_INFINITY to the hard limit only if + the current (soft) limit is less than or equal to the hard limit. + +b. Fixed a bug that caused the bash emulation of strcasecmp to produce + incorrect results. + +c. A bug that caused memory to be freed twice when a trap handler resets + the trap more than once was fixed. + +d. A bug that caused machines where sizeof (pointer) > sizeof (int) to + fail (and possibly dump core) when trying to unwind-protect a null + pointer was fixed. + +e. The startup files should not be run with job control enabled. This fix + allows SIGINT to once again interrupt startup file execution. + +f. Bash should not change the SIGPROF handler if it is set to something + other than SIG_DFL. + +g. The completion code that provides bash-specific completions for readline + now quotes characters that the readline code would treat as word break + characters if they appear in a file name. + +h. The completion code now correctly quotes filenames containing a `!', + even if the user attempted to use double quotes when attempting + completion. + +i. A bug that caused the shell to dump core when `disown' was called without + arguments and there was no current job was fixed. + +j. A construct like $((foo);bar) is now processed as a command substitution + rather than as a bad arithmetic substitution. + +k. A couple of bugs that caused `fc' to not obey the `cmdhist' and `lithist' + shell options when editing and re-executing a series of commands were + fixed. + +l. A fix was made to the grammar -- the list of commands between `do' and + `done' in the body of a `for' command should be treated the same as a + while loop. + +2. Changes to Readline + +a. A couple of bugs that caused the history search functions to attempt to + free a NULL pointer were fixed. + +b. If the C library provides setlocale(3), readline does not need to look + at various environment variables to decide whether or not to go into + eight-bit mode automatically -- just check whether the current locale + is not `C' or `POSIX'. + +c. If the filename completion function finds that a directory was not closed + by a previous (interrupted) completion, it closes the directory with + closedir(). + +3. New Features in Bash + +a. New bindable readline commands: history-and-alias-expand-line and + alias-expand-line. The code was always in there, there was just no + way to execute it. + +------------------------------------------------------------------------------ +This document details the changes between this version, bash-2.01-beta1, +and the previous version, bash-2.01-alpha1. + +1. Changes to Bash + +a. Fixed a problem that could cause file descriptors used for process + substitution to conflict with those used explicitly in redirections. + +b. Made it easier to regenerate configure if the user changes configure.in. + +c. ${GROUPS[0]} should always be the primary group, even on systems without + multiple groups. + +d. Spelling correction is no longer enabled by default. + +e. Fixes to quoting problems in `bashbug'. + +f. OS-specific configuration changes were made for: Irix 6. + +g. OS-specific code changes were made for: QNX. + +h. A more meaningful message is now printed when the file in /tmp for a + here document cannot be created. + +i. Many changes to the shell's variable initialization code to speed + non-interactive startup. + +j. Changes to the non-job-control code so that it does not try to open + /dev/tty. + +k. The output of `set' and `export' is once again sorted, as POSIX wants. + +l. Fixed a problem caused by a recursive call reparsing the value of + $SHELLOPTS. + +m. The tilde code no longer calls getenv() when it's compiled as part of + the shell, which should eliminate problems on systems that cannot + redefine getenv(), like the NeXT OS. + +n. Fixed a problem that caused `bash -o' or `bash +o' to not list all + the shell options. + +o. Fixed `ulimit' to convert RLIM_INFINITY to the appropriate hard limit + only if the hard limit is greater than the current (soft) limit. + +p. Fixed a problem that arose when building bash in a different directory + than the source and y.tab.[ch] were remade with something other than + bison. This came up most often on NetBSD. + +q. Fixed a problem with completion -- it thought that `pwd`/[TAB] indicated + an unfinished command completion (`/), which generated errors. + +r. The bash special tilde expansions (~-, ~+) are now attempted before + calling the standard tilde expansion code, which should eliminate the + problems people have been seeing with this on Solaris 2.5.1. + +s. Added support for to places where it was missing. + +t. Changed the code that reads the output of a command substitution to not + go through stdio. This reduces the memory requirements and is faster. + +u. A number of changes to speed up export environment creation were made. + +v. A number of memory leaks were fixed as the result of running the test + scripts through Purify. + +w. Fixed a bug that caused subshells forked to interpret executable + scripts without a leading `#!' to not reinitialize the values of + the shell options. + +2. Changes to Readline + +a. History library has less `#ifdef SHELL' code -- abstracted stuff out + into application-specific function hooks. + +b. Readline no longer calls getenv() if it's compiled as part of the shell, + which should eliminate problems on systems that cannot redefine getenv(), + like the NeXT OS. + +c. Fixed translation of ESC when `untranslating' macro values. + +d. The region kill operation now fixes the mark if it ends up beyond the + boundaries of the line after the region is deleted. + +3. New Features in Bash + +a. New argument for `configure': `--with-curses'. This can be used to + override the selection of the termcap library on systems where it is + deficient. + +------------------------------------------------------------------------------ +This document details the changes between this version, bash-2.01-alpha1, +and the previous version, bash-2.0-release. + +1. Changes to Bash + +a. System-specific configuration changes for: FreeBSD, SunOS4, Irix, + MachTen, QNX 4.2, Harris Night Hawk, SunOS5. + +b. System-specific code changes were made for: Linux, 4.4 BSD, QNX 4.2, + HP-UX, AIX 4.2. + +c. A bug that caused the exec builtin to fail because the full pathname of + the command could not be found was fixed. + +d. The code that performs output redirections is now more resistant to + race conditions and possible security exploits. + +e. A bug that caused the shell to dump core when performing pattern + substitutions on variable values was fixed. + +f. More hosts are now recognized by the auto-configuration mechanism + (OpenBSD, QNX, others). + +g. Assignments to read-only variables that attempt to convert them to + arrays are now errors. + +h. A bug that caused shell scripts using array assignments in POSIX mode + to exit after the assignment was performed was fixed. + +i. The substring expansion code is now more careful about running off the + ends of the expanded variable value. + +j. A bug that caused completion to fail if a backquoted command substitution + appeared anywhere on the line was fixed. + +k. The `source' builtin no longer turns off history if it has been enabled + in a non-interactive shell. + +l. A bug that caused the shell to crash when `disown' was given a pid + instead of a job number was fixed. + +m. The `cd' spelling correction code will not try to change to `.' if no + directory entries match a single-character argument. + +n. A bad variable name supplied to `declare', `export', or `readonly' no + longer causes a non-interactive shell in POSIX mode to exit. + +o. Some fixes were made to the test suite to handle peculiarities of + various Unix versions. + +p. The bash completion code now quotes characters that readline would + treat as word breaks for completion but are not shell metacharacters. + +q. Bad options supplied at invocation now cause a usage message to be + displayed. + +r. Fixes were made to the code that handles DEBUG traps so that the trap + string is not freed inappropriately. + +s. Some changes were made to the bash debugger in examples/bashdb -- it + should be closer to working now. + +t. A problem that caused the default filename used for mail checking to be + wrong was fixed. + +u. A fix was made to the `echo' builtin so that NUL characters printed with + `echo -e' do not cause the output to be truncated. + +v. A fix was made to the job control code so that the shell behaves better + when monitor mode is enabled in a non-interactive shell. + +w. Bash no longer catches all of the terminating signals in a non- + interactive shell until a trap is set on EXIT, which should result in + quicker startup. + +x. A fix was made to the command timing code so that `time' can be used in + a loop. + +y. A fix was made to the parser so that `((cmd); cmd2)' is now parsed as + a nested subshell rather than strictly as an (erroneous) arithmetic + command. + +z. A fix was made to the globbing code so that it correctly matches quoted + filenames beginning with a `.'. + +aa. A bug in `fc' that caused some multi-line commands to not be stored as + one command in the history when they were re-executed after editing + (with `fc -e') was fixed. + +bb. The `ulimit' builtin now attempts to catch some classes of integer + overflows. + +cc. The command-oriented-history code no longer attempts to add `;' + inappropriately when a newline appears while reading a $(...) command + substitution. + +dd. A bug that caused the shell to dump core when `help --' was executed + was fixed. + +ee. A bug that caused the shell to crash when an unset variable appeared + in the body of a here document after `set -u' had been executed was + fixed. + +ff. Implicit input redirections from /dev/null for asynchronous commands + are now handled better. + +gg. A bug that caused the shell to fail to compile when configured with + `--disable-readline' was fixed. + +hh. The globbing code should now be interruptible. + +ii. Bash now notices when the `kill' builtin is used to send SIGCONT to a + stopped job and adjusts the data structures accordingly, as if `bg' had + been executed instead. + +jj. A bug that caused the shell to crash when mixing calls to `getopts' + and `shift' on the same set of positional parameters was fixed. + +kk. The command printing code now preserves the `-p' flag to `time'. + +ll. The command printing code now handles here documents better when there + are other redirections associated with the command. + +mm. The special glibc environment variable (NNN_GNU_nonoption_argv_flags_) + is no longer placed into the environment of executed commands -- users + of glibc had too many problems with it. + +nn. Reorganized the code that generates signames.h. The signal_names list + is now more complete but may be slightly different (SIGABRT is favored + over SIGIOT, for example). The preferred signal names are those + listed in the POSIX.2 standard. + +oo. `bashbug' now uses a filename shorter than 14 characters for its + temporary file, and asks for confirmation before sending the bug + report. + +pp. A bug that caused TAB completion in vi editing mode to not be turned + off when `set -o posix' was executed or back on when `set +o posix' + was executed was fixed. + +qq. A bug in the brace expansion code that caused brace expansions appearing + in new-style $(...) command substitutions to be inappropriately expanded + was fixed. + +rr. A bug in the readline hook shell-expand-line that could cause memory to + be inappropriately freed was fixed. + +ss. A bug that caused some arithmetic expressions containing `&&' and `||' + to be parsed with the wrong precedence has been fixed. + +tt. References to unbound variables after `set -u' has been executed now + cause the shell to exit immediately, as they should. + +uu. A bug that caused the shell to exit inappropriately when `set -e' had + been executed and a command's return status was being inverted with the + `!' reserved word was fixed. + +vv. A bug that could occasionally cause the shell to crash with a + divide-by-zero error when timing a command was fixed. + +ww. A bug that caused parameter pattern substitution to leave stray + backslashes in the replacement string when the expression is in + double quotes was fixed. + +xx. The `break' and `continue' builtins now break out of all loops when an + invalid count argument is supplied. + +yy. Fixed a bug that caused PATH to be set to the empty string if + `command -p' is executed with PATH unset. + +zz. Fixed `kill -l signum' to print the signal name without the `SIG' prefix, + as POSIX specifies. + +aaa. Fixed a bug that caused the shell to crash while setting $SHELLOPTS + if there were no shell options set. + +bbb. Fixed `export -p' and `readonly -p' so that when the shell is in POSIX + mode, their output is as POSIX.2 specifies. + +ccc. Fixed a bug in `readonly' so that `readonly -a avar=(...)' actually + creates an array variable. + +ddd. Fixed a bug that prevented `time' from correctly timing background + pipelines. + +2. Changes to Readline + +a. A bug that caused an extra newline to be printed when the cursor was on + an otherwise empty line was fixed. + +b. An instance of memory being used after it was freed was corrected. + +c. The redisplay code now works when the prompt is longer than the screen + width. + +d. `dump-macros' is now a bindable name, as it should have been all along. + +e. Non-printable characters are now expanded when displaying macros and + their values. + +f. The `dump-variables' and `dump-macros' commands now output a leading + newline if they're called as the result of a key sequence, rather + than directly by an application. + +3. New Features in Bash + +a. There is a new builtin array variable: GROUPS, the set of groups to which + the user belongs. This is used by the test suite. + +4. New Features in Readline + +a. If a key sequence bound to `universal-argument' is read while reading a + numeric argument started with `universal-argument', it terminates the + argument but is otherwise ignored. This provides a way to insert multiple + instances of a digit string, and is how GNU emacs does it. + +------------------------------------------------------------------------------ +This document details the changes between this version, bash-2.0-release, +and the previous version, bash-2.0-beta3. + +1. Changes to Bash + +a. Fix to the `getopts' builtin so that it does the right thing when a + required option argument is not present. + +b. The completion code now updates the common prefix of matched names + after FIGNORE processing is done, since any names that were removed + may have changed the common prefix. + +c. Fixed a bug that made messages in MAILPATH entries not work correctly. + +d. Fixed a serious documentation error in the description of the new + ${parameter:offset[:length]} expansion. + +e. Fixes to make parameter substring expansion ({$param:offset[:length]}) + work when within double quotes. + +f. Fixes to make ^A (CTLESC) survive an unquoted expansion of positional + parameters. + +g. Corrected a misspelling of `unlimited' in the output of `ulimit'. + +h. Fixed a bug that caused executable scripts without a leading `#!' to + occasionally pick up the wrong set of positional parameters. + +i. Linux systems now have a working `ulimit -v', using RLIMIT_AS. + +j. Updated config.guess so that many more machine types are recognized. + +k. Fixed a bug with backslash-quoted slashes in the ${param/pat[/sub]} + expansion. + +l. If the shell is named `-su', and `-c command' is supplied, read and + execute the login shell startup files even though the shell is not + interactive. This is to support the `-' option to `su'. + +m. Fixed a bug that caused core dumps when the DEBUG trap was ignored + with `trap "" DEBUG' and a shell function was subsequently executed. + +n. Fixed a bug that caused core dumps in the read builtin when IFS was + set to the null string and the input had leading whitespace. + +2. Changes to Readline + +a. Fixed a bug that caused a numeric argument of 1024 to be ignored when + inserting text. + +b. Fixed the display code so that the numeric argument is displayed as it's + being entered. + +c. Fixed the numeric argument reading code so that `M-- command' is + equivalent to `M--1 command', as the prompt implies. + +3. New Features in Bash + +a. `ulimit' now sets both hard and soft limits and reports the soft limit + by default (when neither -H nor -S is specified). This is compatible + with versions of sh and ksh that implement `ulimit'. + +b. Integer constants have been extended to base 64. + +4. New Features in Readline + +a. The `home' and `end' keys are now bound to beginning-of-line and + end-of-line, respectively, if the corresponding termcap capabilities + are present. + +------------------------------------------------------------------------------ +This document details the changes between this version, bash-2.0-beta3, +and the previous version, bash-2.0-beta2. + +1. Changes to Bash + +a. System-specific changes for: AIX 4.2, SCO 3.2v[45], HP-UX. + +b. When in POSIX mode, variable assignments preceding a special builtin + persist in the shell environment after the builtin completes. + +c. Changed all calls to getwd() to getcwd(). Improved check for systems + where the libc getcwd() calls popen(), since that breaks on some + systems when job control is being used. + +d. Fixed a bug that caused seg faults when executing scripts with the + execute bit set but without a leading `#!'. + +e. The environment passed to executed commands is never sorted. + +f. A bug was fixed in the code that expands ${name[@]} to the number of + elements in an array variable. + +g. A bug was fixed in the array compound assignment code ( A=( ... ) ). + +h. Window size changes now correctly propagate down to readline if + the shopt `checkwinsize' option is enabled. + +i. A fix was made in the code that expands to the length of a variable + value (${#var}). + +j. A fix was made to the command builtin so that it did not turn on the + `no fork' flag inappropriately. + +k. A fix was made to make `set -n' work more reliably. + +l. A fix was made to the job control initialization code so that the + terminal process group is set to the shell's process group if the + shell changes its own process group. + +2. Changes to Readline + +a. System-specific changes for: SCO 3.2v[45]. + +b. The behavior of the vi-mode `.' when redoing an `i' command was changed + to insert the text previously inserted by the `i' command rather than + simply entering insert mode. + +3. New features in Bash + +a. There is a new version of the autoload function package, in + examples/functions/autoload.v2, that uses arrays and provides more + functionality. + +b. Support for LC_COLLATE and locale-specific sorting of the results of + pathname expansion if strcoll() is available. + +4. New Features in Readline + +a. Support for locale-specific sorting of completion possibilities if + strcoll() is available. + +------------------------------------------------------------------------------ +This document details the changes between this version, bash-2.0-beta2, +and the previous version, bash-2.0-beta1. + +1. Changes to Bash + +a. `pushd -' is once again equivalent to `pushd $OLDPWD'. + +b. OS-specific changes for: SCO 3.2v[45]. + +c. A change was made to the fix for the recently-reported security hole + when reading characters with octal value 255 to make it work better on + systems with restartable system calls when not using readline. + +d. Some changes were made to the test suite so that it works if you + configure bash with --enable-usg-echo-default. + +e. A fix was made to the parsing of conditional arithmetic expressions. + +f. Illegal arithmetic bases now cause an arithmetic evaluation error rather + than being silently reset. + +g. Multiple arithmetic bases now cause an arithmetic evaluation error + instead of being ignored. + +h. A fix was made to the evaluation of ${param?word} to conform to POSIX.2. + +i. A bug that sometimes caused array indices to be evaluated twice (which + would cause errors when they contained assignment statements) was fixed. + +j. `ulimit' was rewritten to avoid problems with getrlimit(2) returning + unsigned values and to simplify the code. + +k. A bug in the command-oriented-history code that caused it to sometimes + put semicolons after right parens inappropriately was fixed. + +l. The values inserted into the prompt by the \w and \W escape sequences + are now quoted to prevent further expansion. + +m. An interactive shell invoked as `sh' now reads and executes commands + from the file named by $ENV when it starts up. If it's a login shell, + it does this after reading /etc/profile and ~/.profile. + +n. The file named by $ENV is never read by non-interactive shells. + +2. Changes to Readline + +a. A few changes were made to hide some macros and functions that should not + be public. + +b. An off-by-one error that caused seg faults in the history expansion code + was fixed. + +3. New Features in Bash + +a. The ksh-style ((...)) arithmetic command was implemented. It is exactly + identical to let "...". This is controlled by a new option to configure, + `--enable-dparen-arithmetic', which is on by default. + +b. There is a new #define available in config.h.top: SYS_BASH_LOGOUT. If + defined to a filename, bash reads and executes commands from that file + when a login shell exits. It's commented out by default. + +c. `ulimit' has a `-l' option that reports the maximum amount of data that + may be locked into memory on 4.4BSD-based systems. + +------------------------------------------------------------------------------ +This document details the changes between this version, bash-2.0-beta1, +and the previous version, bash-2.0-alpha4. + +1. Changes to Bash + +a. A bug that sometimes caused traps to be ignored on signals the + shell treats specially was fixed. + +b. The internationalization code was changed to track the values of + LC_* variables and call setlocale() as appropriate. The TEXTDOMAIN + and TEXTDOMAINDIR variables are also tracked; changes cause calls + to textdomain() and bindtextdomain(), if available. + +c. A bug was fixed that sometimes caused double-quoted strings to be + parsed incorrectly. + +d. Changes were made so that the siglist code compiles correctly on + Solaris 2.5. + +e. Added `:' to the set of characters that cause word breaks for the + completion code so that pathnames in assignments to $PATH can be + completed. + +f. The `select' command was fixed to print $PS3 to stderr. + +g. Fixed an error in the manual page section describing the effect that + setting and unsetting GLOBIGNORE has on the setting of the `dotglob' + option. + +h. The time conversion code now uses CLK_TCK rather than CLOCKS_PER_SEC + on systems without gettimeofday() and resources. + +i. The getopt static variables are now initialized each time a subshell + is started, so subshells using `getopts' work right. + +j. A sign-extension bug that caused a possible security hole was fixed. + +k. The parser now reads characters between backquotes within a double- + quoted string as a single word, so double quotes in the backquoted + string don't terminate the enclosing double-quoted string. + +l. A bug that caused `^O' to work incorrectly when typed as the first + thing to an interactive shell was fixed. + +m. A rarely-exercised off-by-one error in the code that quotes variable + values was fixed. + +n. Some memory and file descriptor leaks encountered when running a + shell script that is executable but does not have a leading `#!' + were plugged. + +2. Changes to Readline + +a. A bug that sometimes caused incorrect results when trying to read + typeahead on systems without FIONREAD was fixed. + +3. New Features in Bash + +a. The command timing code now uses the value of the TIMEFORMAT variable + to format and display timing statistics. + +b. The `time' reserved word now accepts a `-p' option to force the + POSIX.2 output format. + +c. There are a couple of new and updated scripts to convert csh startup + files to bash format. + +d. There is a new builtin array variable: BASH_VERSINFO. The various + members hold the parts of the version information in BASH_VERSION, + plus the value of MACHTYPE. + +4. New Features in Readline + +a. Setting LANG to `en_US.ISO8859-1' now causes readline to enter + eight-bit mode. + +------------------------------------------------------------------------------ +This document details the changes between this version, bash-2.0-alpha4, +and the previous version, bash-2.0-alpha3. + +1. Changes to Bash + +a. There is better detection of rsh connections on Solaris 2. + +b. Assignments to read-only variables preceding a command name are now + variable assignment errors. Variable assignment errors cause + non-interactive shells running in posix mode to exit. + +c. The word tokenizer was rewritten to handle nested quotes and pairs + ('', "", ``, ${...}, $(...), $[...], $'...', $"...", <(...), >(...)) + correctly. Some of the parameter expansion code was updated as a + consequence. + +d. A fix was made to `test' when given three arguments so that a binary + operator is checked for first, before checking that the first argument + is `!'. + +e. 2''>/dev/null is no longer equivalent to 2>/dev/null. + +f. Parser error messages were regularized, and in most cases the name of + the shell script being read by a non-interactive shell is not printed + twice. + +g. A fix was made to the completion code so that it no longer removes the + text the user typed in some cases. + +h. The special glibc `getopt' environment variable is no longer put into + the environment on machines with small values of ARG_MAX. + +i. The expansion of ${...} now follows the POSIX.2 rules for finding the + closing `}'. + +j. The shell no longer displays spurious status messages for background + jobs in shell scripts that complete successfully when the script is + run from a terminal. + +k. `shopt -o' now correctly updates $SHELLOPTS. + +l. A bug that caused the $PATH searching code to return a non-executable + file even when an executable file with the same name appeared later in + $PATH was fixed. + +m. The shell now does tilde expansions on unquoted `:~' in assignment + statements when not in posix mode. + +n. Variable assignment errors when a command consists only of assignments + now cause non-interactive shells to exit when in posix mode. + +o. If the variable in a `for' or `select' command is read-only, or not a + legal shell identifier, a variable assignment error occurs. + +p. `test' now handles `-a' and `-o' as binary operators when three arguments + are supplied, and correctly parses `( word )' as equivalent to `word'. + +q. `test' was fixed so that file names of the form /dev/fd/NN mean the same + thing on all systems, even Linux. + +r. Fixed a bug in the globbing code that caused patterns with multiple + consecutive `*'s to not be matched correctly. + +s. Fixed a bug that caused $PS2 to not be printed when an interactive shell + not using readline is reading a here document. + +t. Fixed a bug that caused history expansion to be performed inappropriately + when a single-quoted string spanned more than one line. + +u. `getopts' now checks that the variable name passed by the user as the + second argument is a legal shell identifier and that the variable is + not read-only. + +v. Fixed `getopts' to obey POSIX.2 rules for setting $OPTIND when it + encounters an error. + +w. Fixed `set' to display variable values in a form that can be re-read. + +x. Fixed a bug in the code that keeps track of whether or not local variables + have been declared at the current level of function nesting. + +y. Non-interactive shells in posix mode now exit if the name in a function + declaration is not a legal identifier. + +z. The job control code now ignores stopped children when the shell is not + interactive. + +aa. The `cd' builtin no longer attempts spelling correction on the directory + name if the shell is not interactive, regardless of the setting of the + `cdspell' option. + +bb. Some OS-specific changes were made for SCO 3.2v[45] and AIX 4.2. + +cc. `time' now prints its output to stderr, as POSIX.2 specifies. + +2. Fixes to Readline + +a. After printing possible completions, all lines of a multi-line prompt + are redisplayed. + +b. Some changes were made to the terminal handling code in rltty.c to + work around AIX 4.2 bugs. + +3. New Features in Bash + +a. There is a new loadable builtin: sprintf, with calling syntax + sprintf var format [args] + This provides an easy way to simulate ksh left- and right-justified + variable values. + +b. The expansions of \h and \H in prompt strings were swapped. \h now + expands to the hostname up to the first `.', as in bash-1.14. + +4. New Features in Readline + +a. The bash-1.14 behavior when ^M is typed while doing an incremental + search was restored. ^J may now be used to terminate the search without + accepting the line. + +b. There is a new bindable variable: disable-completion. This inhibits + word completion and causes the completion character to be inserted as + if it had been bound to self-insert. + +------------------------------------------------------------------------------ +This document details the changes between this version, bash-2.0-alpha3, +and the previous version, bash-2.0-alpha2. + +There is now a file `COMPAT' included in the distribution that lists the +user-visible incompatibilities between 1.14 and 2.0. + +1. Changes to Bash + +a. Some work was done so that word splitting of the rhs of assignment + statements conforms more closely to historical practice. + +b. A couple of errant memory frees were fixed. + +c. A fix was made to the test builtin so it recognizes `<' and `>' as + binary operators. + +d. The GNU malloc in lib/malloc/malloc.c now scrambles memory as it's + allocated and freed. This is to catch callers that refer to freed + memory or assume something about newly-allocated memory. + +e. Fixed a problem with conversion to 12-hour time in the prompt + expansion code. + +f. Fixed a problem with configure's argument parsing order. Now you can + correctly turn on specific options after using --enable-minimal-config. + +g. The configure script now automatically disables the use of GNU malloc + on systems where it's appropriate (better than having people read the + NOTES file and do it manually). + +h. There are new prompt expansions (\v and \V) to insert version information + into the prompt strings. + +i. The default prompt string now includes the version number. + +j. Most of the builtins that take no options were changed to use the + internal getopt so they can produce proper error messages for -? + and incorrect options. + +k. Some system-specific changes were made for SVR4.2 and Solaris 2.5. + +l. Bash now uses PATH_MAX instead of MAXPATHLEN and NAME_MAX instead of + MAXNAMLEN. + +m. A couple of problems caused by uninitialized variables were fixed. + +n. There are a number of new loadable builtin examples: logname, basename, + dirname, tty, pathchk, tee, head, and rmdir. All of these conform to + POSIX.2. + +o. Bash now notices changes in TZ and calls tzset() if present, so + changing TZ will alter the time printed by prompt expansions. + +p. The source was reorganized a bit so I don't have to wait so long for + some files to compile, and to facilitate the creation of a `shell + library' at some future point. + +q. Bash no longer turns off job control if called as `sh', since the + POSIX.2 spec includes job control as a standard feature. + +r. `bash -o posix' now works as intended. + +s. Fixed a problem with the completion code: when completing a filename + that contained globbing characters, if show-all-if-ambiguous was set, + the completion code would remove the user's text. + +t. Fixed ulimit so that (hopefully) the full range of limits is available + on HPUX systems. + +u. A new `shopt' option (`hostcomplete') enables and disables hostname + completion. + +v. The shell no longer attempts to save the history on an abort(), + which is usually called by programming_error(). + +w. The `-s' option to `fc' was changed to echo the command to be executed + to stderr instead of stdout. + +x. If the editor invoked by `fc -e' exits with a non-zero status, no + commands are executed. + +y. Fixed a bug that made the shopt `histverify' option work incorrectly. + +z. There is a new variable `MACHTYPE' whose value is the GNU-style + `cpu-company-system' system description as set by configure. (The + values of MACHTYPE and HOSTTYPE should really be swapped.) + +aa. The `ulimit' builtin now allows the maximum virtual memory size to be + set via setrlimit(2) if RLIMIT_VMEM is defined. + +bb. `bash -nc 'command'' no longer runs `command'. + +2. Changes to Readline + +a. Fixed a typo in the code that checked for FIONREAD in input.c. + +b. Fixed a bug in the code that outputs keybindings, so things like C-\ + are quoted properly. + +c. Fixed a bug in the inputrc file parsing code to handle the problems + caused by inputrc files created from the output of `bind -p' in + previous versions of bash. The problem was due to the bug fixed + in item b above. + +d. Readline no longer turns off the terminal's meta key, and turns it on + once the first time it's called. + +------------------------------------------------------------------------------ +This file documents the changes between this version, bash-2.0-alpha2, +and the previous version, bash-2.0-alpha. + +1. Changes to Bash + +a. The shell no longer thinks directories are executable. + +b. `disown' has a new option, `h', which inhibits the resending of SIGHUP + but does not remove the job from the jobs table. + +c. The varargs functions in error.c now use ANSI-C `stdarg' if available. + +d. The build process now treats the `build version' in .build as local to + the build directory, so different versions built from the same source + tree have different `build versions'. + +e. Some problems with the grammar have been fixed. (It used `list' in a few + productions where `compound_list' was needed. A `list' must be terminated + with a newline or semicolon; a `compound_list' need not be.) + +f. A fix was made to keep `wait' from hanging when waiting for all background + jobs. + +g. `bash --help' now writes its output to stdout, like the GNU Coding Standards + specify, and includes the machine type (the value of MACHTYPE). + +h. `bash --version' now prints more information and exits successfully, like + the GNU Coding Standards specify. + +i. The output of `time' and `times' now prints fractional seconds with three + places after the decimal point. + +j. A bug that caused process substitutions to screw up the pipeline printed + by `jobs' was fixed. + +k. Fixes were made to the code that implements $'...' and $"..." so they + work as documented. + +l. The process substitution code now opens named pipes for reading with + O_NONBLOCK to avoid hanging. + +m. Fixes were made to the trap code so the shell cleans up correctly if the + trap command contains a `return' and we're executing a function or + sourcing a script with `.'. + +n. Fixes to doc/Makefile.in so that it doesn't try to remake all of the + documentation (ps, dvi, etc.) on a `make install'. + +o. Fixed an auto-increment error that caused bash -c args to sometimes dump + core. + +p. Fixed a bug that caused $HISTIGNORE to fail when the history line + contained globbing characters. + +2. Changes to Readline + +a. There is a new string variable, rl_library_version, available for use by + applications. The current value is "2.1". + +b. A bug encountered when expand-tilde was enabled and file completion was + attempted on a word beginning with `~/' was fixed. + +c. A slight change was made to the incremental search termination behavior. + ESC still terminates the search, but if input is pending or arrives + within 0.1 seconds (on systems with select(2)), it is used as a prefix + character. This is intented to allow users to terminate searches with + the arrow keys and get the behavior they expect. diff --git a/COMPAT b/COMPAT new file mode 100644 index 0000000..9959b96 --- /dev/null +++ b/COMPAT @@ -0,0 +1,459 @@ +Compatibility with previous versions +==================================== + +This document details the incompatibilities between this version of bash, +bash-4.4, and the previous widely-available versions, bash-3.x (which is +still the `standard' version for Mac OS X), 4.1/4.2 (which are still +standard on a few Linux distributions), and bash-4.3, the current +widely-available version. These were discovered by users of bash-2.x +through 4.x, so this list is not comprehensive. Some of these +incompatibilities occur between the current version and versions 2.0 and +above. + +1. Bash uses a new quoting syntax, $"...", to do locale-specific + string translation. Users who have relied on the (undocumented) + behavior of bash-1.14 will have to change their scripts. For + instance, if you are doing something like this to get the value of + a variable whose name is the value of a second variable: + + eval var2=$"$var1" + + you will have to change to a different syntax. + + This capability is directly supported by bash-2.0: + + var2=${!var1} + + This alternate syntax will work portably between bash-1.14 and bash-2.0: + + eval var2=\$${var1} + +2. One of the bugs fixed in the YACC grammar tightens up the rules + concerning group commands ( {...} ). The `list' that composes the + body of the group command must be terminated by a newline or + semicolon. That's because the braces are reserved words, and are + recognized as such only when a reserved word is legal. This means + that while bash-1.14 accepted shell function definitions like this: + + foo() { : } + + bash-2.0 requires this: + + foo() { :; } + + This is also an issue for commands like this: + + mkdir dir || { echo 'could not mkdir' ; exit 1; } + + The syntax required by bash-2.0 is also accepted by bash-1.14. + +3. The options to `bind' have changed to make them more consistent with + the rest of the bash builtins. If you are using `bind -d' to list + the readline key bindings in a form that can be re-read, use `bind -p' + instead. If you were using `bind -v' to list the key bindings, use + `bind -P' instead. + +4. The `long' invocation options must now be prefixed by `--' instead + of `-'. (The old form is still accepted, for the time being.) + +5. There was a bug in the version of readline distributed with bash-1.14 + that caused it to write badly-formatted key bindings when using + `bind -d'. The only key sequences that were affected are C-\ (which + should appear as \C-\\ in a key binding) and C-" (which should appear + as \C-\"). If these key sequences appear in your inputrc, as, for + example, + + "\C-\": self-insert + + they will need to be changed to something like the following: + + "\C-\\": self-insert + +6. A number of people complained about having to use ESC to terminate an + incremental search, and asked for an alternate mechanism. Bash-2.03 + uses the value of the settable readline variable `isearch-terminators' + to decide which characters should terminate an incremental search. If + that variable has not been set, ESC and Control-J will terminate a + search. + +7. Some variables have been removed: MAIL_WARNING, notify, history_control, + command_oriented_history, glob_dot_filenames, allow_null_glob_expansion, + nolinks, hostname_completion_file, noclobber, no_exit_on_failed_exec, and + cdable_vars. Most of them are now implemented with the new `shopt' + builtin; others were already implemented by `set'. Here is a list of + correspondences: + + MAIL_WARNING shopt mailwarn + notify set -o notify + history_control HISTCONTROL + command_oriented_history shopt cmdhist + glob_dot_filenames shopt dotglob + allow_null_glob_expansion shopt nullglob + nolinks set -o physical + hostname_completion_file HOSTFILE + noclobber set -o noclobber + no_exit_on_failed_exec shopt execfail + cdable_vars shopt cdable_vars + +8. `ulimit' now sets both hard and soft limits and reports the soft limit + by default (when neither -H nor -S is specified). This is compatible + with versions of sh and ksh that implement `ulimit'. The bash-1.14 + behavior of, for example, + + ulimit -c 0 + + can be obtained with + + ulimit -S -c 0 + + It may be useful to define an alias: + + alias ulimit="ulimit -S" + +9. Bash-2.01 uses a new quoting syntax, $'...' to do ANSI-C string + translation. Backslash-escaped characters in ... are expanded and + replaced as specified by the ANSI C standard. + +10. The sourcing of startup files has changed somewhat. This is explained + more completely in the INVOCATION section of the manual page. + + A non-interactive shell not named `sh' and not in posix mode reads + and executes commands from the file named by $BASH_ENV. A + non-interactive shell started by `su' and not in posix mode will read + startup files. No other non-interactive shells read any startup files. + + An interactive shell started in posix mode reads and executes commands + from the file named by $ENV. + +11. The <> redirection operator was changed to conform to the POSIX.2 spec. + In the absence of any file descriptor specification preceding the `<>', + file descriptor 0 is used. In bash-1.14, this was the behavior only + when in POSIX mode. The bash-1.14 behavior may be obtained with + + <>filename 1>&0 + +12. The `alias' builtin now checks for invalid options and takes a `-p' + option to display output in POSIX mode. If you have old aliases beginning + with `-' or `+', you will have to add the `--' to the alias command + that declares them: + + alias -x='chmod a-x' --> alias -- -x='chmod a-x' + +13. The behavior of range specificiers within bracket matching expressions + in the pattern matcher (e.g., [A-Z]) depends on the current locale, + specifically the value of the LC_COLLATE environment variable. Setting + this variable to C or POSIX will result in the traditional ASCII behavior + for range comparisons. If the locale is set to something else, e.g., + en_US (specified by the LANG or LC_ALL variables), collation order is + locale-dependent. For example, the en_US locale sorts the upper and + lower case letters like this: + + AaBb...Zz + + so a range specification like [A-Z] will match every letter except `z'. + Other locales collate like + + aAbBcC...zZ + + which means that [A-Z] matches every letter except `a'. + + The portable way to specify upper case letters is [:upper:] instead of + A-Z; lower case may be specified as [:lower:] instead of a-z. + + Look at the manual pages for setlocale(3), strcoll(3), and, if it is + present, locale(1). + + You can find your current locale information by running locale(1): + + caleb.ins.cwru.edu(2)$ locale + LANG=en_US + LC_CTYPE="en_US" + LC_NUMERIC="en_US" + LC_TIME="en_US" + LC_COLLATE="en_US" + LC_MONETARY="en_US" + LC_MESSAGES="en_US" + LC_ALL=en_US + + My advice is to put + + export LC_COLLATE=C + + into /etc/profile and inspect any shell scripts run from cron for + constructs like [A-Z]. This will prevent things like + + rm [A-Z]* + + from removing every file in the current directory except those beginning + with `z' and still allow individual users to change the collation order. + Users may put the above command into their own profiles as well, of course. + +14. Bash versions up to 1.14.7 included an undocumented `-l' operator to + the `test/[' builtin. It was a unary operator that expanded to the + length of its string argument. This let you do things like + + test -l $variable -lt 20 + + for example. + + This was included for backwards compatibility with old versions of the + Bourne shell, which did not provide an easy way to obtain the length of + the value of a shell variable. + + This operator is not part of the POSIX standard, because one can (and + should) use ${#variable} to get the length of a variable's value. + Bash-2.x does not support it. + +15. Bash no longer auto-exports the HOME, PATH, SHELL, TERM, HOSTNAME, + HOSTTYPE, MACHTYPE, or OSTYPE variables. If they appear in the initial + environment, the export attribute will be set, but if bash provides a + default value, they will remain local to the current shell. + +16. Bash no longer initializes the FUNCNAME, GROUPS, or DIRSTACK variables + to have special behavior if they appear in the initial environment. + +17. Bash no longer removes the export attribute from the SSH_CLIENT or + SSH2_CLIENT variables, and no longer attempts to discover whether or + not it has been invoked by sshd in order to run the startup files. + +18. Bash no longer requires that the body of a function be a group command; + any compound command is accepted. + +19. As of bash-3.0, the pattern substitution operators no longer perform + quote removal on the pattern before attempting the match. This is the + way the pattern removal functions behave, and is more consistent. + +20. After bash-3.0 was released, I reimplemented tilde expansion, incorporating + it into the mainline word expansion code. This fixes the bug that caused + the results of tilde expansion to be re-expanded. There is one + incompatibility: a ${paramOPword} expansion within double quotes will not + perform tilde expansion on WORD. This is consistent with the other + expansions, and what POSIX specifies. + +21. A number of variables have the integer attribute by default, so the += + assignment operator returns expected results: RANDOM, LINENO, MAILCHECK, + HISTCMD, OPTIND. + +22. Bash-3.x is much stricter about $LINENO correctly reflecting the line + number in a script; assignments to LINENO have little effect. + +23. By default, readline binds the terminal special characters to their + readline equivalents. As of bash-3.1/readline-5.1, this is optional and + controlled by the bind-tty-special-chars readline variable. + +24. The \W prompt string expansion abbreviates $HOME as `~'. The previous + behavior is available with ${PWD##/*/}. + +25. The arithmetic exponentiation operator is right-associative as of bash-3.1. + +26. The rules concerning valid alias names are stricter, as per POSIX.2. + +27. The Readline key binding functions now obey the convert-meta setting active + when the binding takes place, as the dispatch code does when characters + are read and processed. + +28. The historical behavior of `trap' reverting signal disposition to the + original handling in the absence of a valid first argument is implemented + only if the first argument is a valid signal number. + +29. In versions of bash after 3.1, the ${parameter//pattern/replacement} + expansion does not interpret `%' or `#' specially. Those anchors don't + have any real meaning when replacing every match. + +30. Beginning with bash-3.1, the combination of posix mode and enabling the + `xpg_echo' option causes echo to ignore all options, not looking for `-n' + +31. Beginning with bash-3.2, bash follows the Bourne-shell-style (and POSIX- + style) rules for parsing the contents of old-style backquoted command + substitutions. Previous versions of bash attempted to recursively parse + embedded quoted strings and shell constructs; bash-3.2 uses strict POSIX + rules to find the closing backquote and simply passes the contents of the + command substitution to a subshell for parsing and execution. + +32. Beginning with bash-3.2, bash uses access(2) when executing primaries for + the test builtin and the [[ compound command, rather than looking at the + file permission bits obtained with stat(2). This obeys restrictions of + the file system (e.g., read-only or noexec mounts) not available via stat. + +33. Bash-3.2 adopts the convention used by other string and pattern matching + operators for the `[[' compound command, and matches any quoted portion + of the right-hand-side argument to the =~ operator as a string rather + than a regular expression. + +34. Bash-4.0 allows the behavior in the previous item to be modified using + the notion of a shell `compatibility level'. If the compat31 shopt + option is set, quoting the pattern has no special effect. + +35. Bash-3.2 (patched) and Bash-4.0 fix a bug that leaves the shell in an + inconsistent internal state following an assignment error. One of the + changes means that compound commands or { ... } grouping commands are + aborted under some circumstances in which they previously were not. + This is what Posix specifies. + +36. Bash-4.0 now allows process substitution constructs to pass unchanged + through brace expansion, so any expansion of the contents will have to be + separately specified, and each process subsitution will have to be + separately entered. + +37. Bash-4.0 now allows SIGCHLD to interrupt the wait builtin, as Posix + specifies, so the SIGCHLD trap is no longer always invoked once per + exiting child if you are using `wait' to wait for all children. As + of bash-4.2, this is the status quo only when in posix mode. + +38. Since bash-4.0 now follows Posix rules for finding the closing delimiter + of a $() command substitution, it will not behave as previous versions + did, but will catch more syntax and parsing errors before spawning a + subshell to evaluate the command substitution. + +39. The programmable completion code uses the same set of delimiting characters + as readline when breaking the command line into words, rather than the + set of shell metacharacters, so programmable completion and readline + should be more consistent. + +40. When the read builtin times out, it attempts to assign any input read to + specified variables, which also causes variables to be set to the empty + string if there is not enough input. Previous versions discarded the + characters read. + +41. Beginning with bash-4.0, when one of the commands in a pipeline is killed + by a SIGINT while executing a command list, the shell acts as if it + received the interrupt. This can be disabled by setting the compat31 or + compat32 shell options. + +42. Bash-4.0 changes the handling of the set -e option so that the shell exits + if a pipeline fails (and not just if the last command in the failing + pipeline is a simple command). This is not as Posix specifies. There is + work underway to update this portion of the standard; the bash-4.0 + behavior attempts to capture the consensus at the time of release. + +43. Bash-4.0 fixes a Posix mode bug that caused the . (source) builtin to + search the current directory for its filename argument, even if "." is + not in $PATH. Posix says that the shell shouldn't look in $PWD in this + case. + +44. Bash-4.1 uses the current locale when comparing strings using the < and + > operators to the `[[' command. This can be reverted to the previous + behavior (ASCII collating and strcmp(3)) by setting one of the + `compatNN' shopt options, where NN is less than 41. + +45. Bash-4.1 conforms to the current Posix specification for `set -u': + expansions of $@ and $* when there are no positional parameters do not + cause the shell to exit. + +46. Bash-4.1 implements the current Posix specification for `set -e' and + exits when any command fails, not just a simple command or pipeline. + +47. Command substitutions now remove the caller's trap strings when trap is + run to set a new trap in the subshell. Previous to bash-4.2, the old + trap strings persisted even though the actual signal handlers were reset. + +48. When in Posix mode, a single quote is not treated specially in a + double-quoted ${...} expansion, unless the expansion operator is + # or % or the new `//', `^', or `,' expansions. In particular, it + does not define a new quoting context. This is from Posix interpretation + 221. + +49. Posix mode shells no longer exit if a variable assignment error occurs + with an assignment preceding a command that is not a special builtin. + +50. Bash-4.2 attempts to preserve what the user typed when performing word + completion, instead of, for instance, expanding shell variable + references to their value. + +51. When in Posix mode, bash-4.2 exits if the filename supplied as an argument + to `.' is not found and the shell is not interactive. + +52. When compiled for strict Posix compatibility, bash-4.3 does not enable + history expansion by default in interactive shells, since it results in + a non-conforming environment. + +53. Bash-4.3 runs the replacement string in the pattern substitution word + expansion through quote removal. The code already treats quote + characters in the replacement string as special; if it treats them as + special, then quote removal should remove them. + +54. Bash-4.4 no longer considers a reference to ${a[@]} or ${a[*]}, where `a' + is an array without any elements set, to be a reference to an unset + variable. This means that such a reference will not cause the shell to + exit when the `-u' option is enabled. + +55. Bash-4.4 allows double quotes to quote the history expansion character (!) + when in Posix mode, since Posix specifies the effects of double quotes. + +56. Bash-4.4 does not inherit $PS4 from the environment if running as root. + +57. Bash-4.4 doesn't allow a `break' or `continue' in a function to affect + loop execution in the calling context. + +58. Bash-4.4 no longer expands tildes in $PATH elements when in Posix mode. + +59. Bash-4.4 does not attempt to perform a compound array assignment if an + argument to `declare' or a similar builtin expands to a word that looks + like a compound array assignment (e.g. declare w=$x where x='(foo)'). + +Shell Compatibility Level +========================= + +Bash-4.0 introduced the concept of a `shell compatibility level', specified +as a set of options to the shopt builtin (compat31, compat32, compat40, +compat41, and compat42 at this writing). There is only one current +compatibility level -- each option is mutually exclusive. This list does not +mention behavior that is standard for a particular version (e.g., setting +compat32 means that quoting the rhs of the regexp matching operator quotes +special regexp characters in the word, which is default behavior in bash-3.2 +and above). + +Bash-4.3 introduces a new shell variable: BASH_COMPAT. The value assigned +to this variable (a decimal version number like 4.2, or an integer +corresponding to the compatNN option, like 42) determines the compatibility +level. + +Bash-4.4 has begun deprecating older compatibility levels. Eventually, the +options will be removed in favor of the BASH_COMPAT variable. + +compat31 set + - the < and > operators to the [[ command do not consider the current + locale when comparing strings; they use ASCII ordering + - quoting the rhs of the regexp matching operator (=~) has no + special effect + +compat32 set + - the < and > operators to the [[ command do not consider the current + locale when comparing strings; they use ASCII ordering + +compat40 set + - the < and > operators to the [[ command do not consider the current + locale when comparing strings; they use ASCII ordering + - interrupting a command list such as "a ; b ; c" causes the execution + of the entire list to be aborted (in versions before bash-4.0, + interrupting one command in a list caused the next to be executed) + +compat41 set + - interrupting a command list such as "a ; b ; c" causes the execution + of the entire list to be aborted (in versions before bash-4.0, + interrupting one command in a list caused the next to be executed) + - when in posix mode, single quotes in the `word' portion of a + double-quoted parameter expansion define a new quoting context and + are treated specially + +compat42 set + - the replacement string in double-quoted pattern substitution is not + run through quote removal, as in previous versions + +compat43 set + - the shell does not print a warning message if an attempt is made to + use a quoted compound assignment as an argument to declare + (declare -a foo='(1 2)') + - word expansion errors are considered non-fatal errors that cause the + current command to fail, even in Posix mode + - when executing a shell function, the loop state (while/until/etc.) is + not reset, so `break' or `continue' in a shell function will break or + continue loops in the calling context. Bash-4.4 and later reset the + loop state to prevent this. + +------------------------------------------------------------------------------- + +Copying and distribution of this file, with or without modification, +are permitted in any medium without royalty provided the copyright +notice and this notice are preserved. This file is offered as-is, +without any warranty. diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..94a9ed0 --- /dev/null +++ b/COPYING @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + 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 3 of the License, 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, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/CWRU/PLATFORMS b/CWRU/PLATFORMS new file mode 100644 index 0000000..f05caff --- /dev/null +++ b/CWRU/PLATFORMS @@ -0,0 +1,31 @@ +The version of bash in this directory has been compiled on the +following systems: + +By chet: + +SunOS 4.1.4 +SunOS 5.5 +BSDI BSD/OS 2.1 +FreeBSD 2.2 +NetBSD 1.2 +AIX 4.2 +AIX 4.1.4 +HP/UX 9.05, 10.01, 10.10, 10.20 +Linux 2.0.29 (libc 5.3.12) +Linux 2.0.4 (libc 5.3.12) + +By other testers: + +SCO ODT 2.0 +SCO 3.2v5.0, 3.2v4.2 +SunOS 5.3 +SunOS 5.5 +BSD/OS 2.1 +FreeBSD 2.2 +SunOS 4.1.3 +Irix 5.3 +Irix 6.2 +Linux 2.0 (unknown distribution) +Digital OSF/1 3.2 +GNU Hurd 0.1 +SVR4.2 diff --git a/CWRU/README b/CWRU/README new file mode 100644 index 0000000..7d7ca1a --- /dev/null +++ b/CWRU/README @@ -0,0 +1,20 @@ +Contents of this directory: + +changelog - my change log since the last release + +POSIX.NOTES - list of what changes for `posix mode' + +README - this file + +misc - directory with some useful tools + +The following are distributed `as-is'. They will not apply without some +modification. + +sh-redir-hack - diff to parse.y to get redirections before + compound commands + +empty-for-wordlist - diff to parse.y to allow an empty wordlist after + the `in' keyword in a `for' statement + +mh-folder-comp - diffs that reportedly add MH folder completion diff --git a/CWRU/changelog b/CWRU/changelog new file mode 100644 index 0000000..f37159d --- /dev/null +++ b/CWRU/changelog @@ -0,0 +1,11681 @@ + 2/14/2011 + --------- +[bash-4.2 released] + + 2/15 + ---- +lib/glob/gmisc.c + - fix wmatchlen and umatchlen to avoid going past the end of the + string on an incomplete bracket expression that ends with a + NUL. Partial fix for bug reported by Clark Wang + + 2/16 + ---- +subst.h + - new string extract flag value: SX_WORD. Used when calling + extract_dollar_brace_string to skip over the word in + ${param op word} from parameter_brace_expand + +subst.c + - change parameter_brace_expand to add SX_WORD to flags passed to + extract_dollar_brace_string + - change parameter_brace_expand to use SX_POSIXEXP for all non-posix + word expansion operators that treat single quotes as special, not + just % and # + - change extract_dollar_brace_string to initialize dolbrace_state to + DOLBRACE_WORD if SX_WORD flag supplied and we shouldn't use + DOLBRACE_QUOTE. Fixes bug reported by Juergen Daubert + +doc/{bash.1,bashref.texi} + - document the exact expansions here strings undergo + + 2/17 + ---- +lib/readline/vi_mode.c + - make sure that `dd', `cc', and `yy' call vidomove_dispatch from + rl_domove_read_callback. Fixes bug reported by Clark Wang + + +lib/readline/callback.c + - make sure _rl_internal_char_cleanup is called after the + vi-motion callbacks (rl_vi_domove_callback) in rl_callback_read_char. + Companion to above fix + +doc/{bash.1,bashref.texi} + - make sure that the text describing the rhs of the == and =~ + operators to [[ states that only the quoted portion of the pattern + is matched as a string + + 2/18 + ---- +lib/glob/gmisc.c + - better fix for umatchlen/wmatchlen: keep track of the number of + characters in a bracket expression as the value to increase + matchlen by if the bracket expression is not well-formed. Fixes + bug reported by Clark Wang + +subst.c + - change expand_string_for_rhs so that it sets the W_NOSPLIT2 flag + in the word flags. We will not perform word splitting or quote + removal on the result, so we do not want to add quoted nulls if + we see "" or ''. Fixes bug reported by Mike Frysinger + + + 2/19 + ---- +variables.c + - new function, int chkexport(name), checks whether variable NAME is + exported and remakes the export environment if necessary. Returns + 1 if NAME is exported and 0 if not + - call chkexport(name) to get tzset to look at the right variable in + the environment when modifying TZ in sv_tz. Don't call tzset if + chkexport doesn't indicate that the variable is exported + +variables.h + - new extern declaration for chkexport + + +{parse.y,builtins/printf.def} + - call sv_tz before calling localtime() when formatting time strings + in prompt strings or using printf. Fixes bug reported by + Dennis Williamson + +execute_cmd.c + - modify fix of 2/9 to add casts when those variables are passed to + functions; some compilers throw errors instead of warnings. Report + and fix from Joachim Schmitz + +support/shobj-conf + - add a stanza for nsk on the Tandem from Joachim Schmitz + + +{shell,lib/readline/shell}.c + - Tandem systems should use getpwnam (getlogin()); for some reason + they don't do well with using getuid(). Fix from Joachim Schmitz + + + 3/1 + --- +variables.c + - make sure that the return value from find_variable is non-null + before trying to use it in chkexport. Fixes bug reported by + Evangelos Foutras + + 3/3 + --- +parse.y + - when adding $$ to the current token buffer in read_token_word(), + don't xmalloc a buffer for two characters and then strcpy it, just + copy the characters directly into the token buffer. Fix from + Michael Whitten + +execute_cmd.c + - fix expand_word_unsplit to add the W_NOSPLIT2 flag to the word to + be expanded, so "" doesn't add CTLNUL. Similar to fix of 2/18 to + expand_string_for_rhs. Fixes bug reported by Nathanael D. Noblet + and Matthias Klose + +parse.y + - fix extended_glob case of read_token_word to allocate an extra + space in the buffer for the next character read after the extended + glob specification if it's a CTLESC or CTLNUL. Report and fix from + Michael Witten + - fix shell expansions case of read_token_word to allocate an extra + space in the buffer for the next character read after the shell + expansion if it's a CTLESC or CTLNUL. Report and fix from + Michael Witten + - TENTATIVE: fix read_token_word to reduce the amount of buffer space + required to hold the translated and double-quoted value of $"..." + strings. Report and fix from Michael Witten + - change code around got_character and got_escaped_character labels to + make sure that we call RESIZE_MALLOCED_BUFFER before adding the + CTLESC before a CTLESC or CTLNUL, and before adding the character if + we're not adding a CTLESC. Report and fix from + Michael Witten + +subst.c + - new param flags value, PF_ASSIGNRHS, mirrors W_ASSIGNRHS, noting that + parameter expansion is on rhs of assignment statement. That inhibits + word splitting + - change param_expand to call string_list_dollar_at with quoted == 1 + if PF_ASSIGNRHS is set, so it will quote IFS characters in the + positional parameter before separating them with the first char of + $IFS. This keeps the rhs from being split inappropriately. Fixes + bug reported by Andres Perera + + 3/4 + --- +lib/readline/bind.c + - add a missing free of `names' in rl_function_dumper. Bug report + and fix from Michael Snyder + + 3/5 + --- +lib/readline/rltty.c + - change rl_deprep_terminal so it uses fileno (stdin) for the tty fd + if rl_instream is not set, like rl_prep_terminal + + 3/6 + --- +lib/readline/display.c + - fix rl_message to use a dynamically-allocated buffer instead of a + fixed-size buffer of 128 chars for the `local message prompt'. Bug + report and fix from Micah Cowan + + 3/7 + --- +jobs.c + - add sentinel to wait_sigint_handler so it only sets wait_sigint_received + if waiting_for_child is non-zero; otherwise, it restores the old + SIGINT handler and sends itself the SIGINT + - set waiting_for_child around the calls to waitchld that use it to + synchronously wait for a process + - change logic that decides whether or not the child process blocked + or handled SIGINT based on whether or not waitpid returns -1/EINTR + and the shell receives a SIGINT and the child does not exit. If + the child later exits due to SIGINT, cancel the assumoption that it + was handled + - instead of testing whether or not the child exited due to SIGINT + when deciding whether the shell should act on a SIGINT it received + while waiting, test whether or not we think the child caught + SIGINT. If it did, we let it go (unless the shell has it trapped); + if it did not catch it, the shell acts on the SIGINT. Fix from + Linus Torvalds , bug report originally + from Oleg Nesterov + + 3/8 + --- +shell.c + - initialize no_line_editing to 1 if READLINE is not defined -- we + can't have line editing without readline + + 3/12 + ---- +lib/readline/signals.c + - add SIGHUP to the set of signals readline handles + +lib/readline/doc/rltech.texi + - document that SIGHUP is now part of the set of signals readline + handles + +lib/readline/input.c + - if _rl_caught_signal indicates that read() was interrupted by a + SIGHUP or SIGTERM, return READERR or EOF as appropriate + - call rl_event_hook, if it's set, if call to read in rl_getc + returns -1/EINTR. If rl_event_hook doesn't do anything, this + continues the loop as before. This handles the other fatal + signals + +execute_cmd.c + - add a couple of QUIT; calls to execute_disk_command and + execute_simple_command to improve responsiveness to interrupts + and fatal signals + +input.c + - rearrange getc_with_restart so that the return values from read() + are handled right + +parse.y + - don't need to set terminate_immediately in yy_stream_get, since + getc_with_restart checks for terminating signals itself + - since readline returns READERR on SIGHUP or SIGTERM, don't need + to set terminate_immediately. Still doesn't handle other + signals well -- will have to check that some more + +bashline.c + - new function, bash_event_hook, for rl_event_hook. Just checks for + terminating signals and acts on them using CHECK_TERMSIG. + - set rl_event_hook to bash_event_hook + +builtins/read.def + - take out setting terminate_immediately; add calls to CHECK_TERMSIG + after read calls + +doc/{bash.1,bashref.texi} + - move the text describing the effect of negative subscripts used to + reference indexed array elements to the paragraphs describing + ${parameter[subscript]}, since that's where they are implemented. + Pointed out by Christopher F. A. Johnson + +arrayfunc.[ch],subst.c + - array_expand_index now takes a new first argument: a SHELL_VAR * + of the array variable being subscripted. Can be used later to fully + implement negative subscripts + + 3/14 + ---- +lib/glob/glob.c + - fix mbskipname to not turn the directory entry name into a wide char + string if the conversion of the pattern to a wide char string fails + - fix mbskipname to call skipname if either the pattern or the filename + can't be converted into a wide-char string + +lib/glob/xmbsrtowcs.c + - fix xdupmbstowcs2 to handle return value of 0 from mbsnrtowcs and + short-circuit with failure in that case. Fixes bug reported by + Roman Rakus + + 3/15 + ---- +bashline.c + - new variable, bash_filename_quote_characters to store the value + assigned to rl_filename_quote_characters so it can be restored + if changed. + - change bashline_reset and attempt_shell_completion to restore + rl_filename_quote_characters if not set to default + + 3/22 + ---- +lib/glob/glob.c + - wdequote_pathname falls back to udequote_pathname if xdupmbstowcs + fails to convert the pathname to a wide-character string + +lib/glob/xmbsrtowcs.c + - xdupmbstowcs2: change to fix problem with leading '\\' (results in + nms == 0, which causes it to short-circuit with failure right + away). Fixes bug pointed out by Werner Fink + - xdupmbstowcs2: compensate for mbsnrtowcs returning 0 by taking the + next single-byte character and going on + - xdupmbstowcs2: change memory allocation to increase by WSBUF_INC + bytes; try to avoid calls to realloc (even if they don't actually + result in more memory being allocated) + + 3/24 + ---- +doc/{bash.1,bashref.texi} + - slightly modify BASH_SUBSHELL description based on complaint from + Sam Liddicott + + 3/25 + ---- +trap.c + - change free_trap_strings to not call free_trap_string for signals + that are being ignored, like reset_or_restore_signal_handlers. + Fixes bug reported by Satoshi Takahashi + + 3/26 + ---- +lib/readline/rltypedefs.h + - remove old Function/VFunction/CPFunction/CPPFunction typedefs as + suggested by Tom Tromey + +lib/readline/rlstdc.h + - move defines for USE_VARARGS/PREFER_STDARG/PREFER_VARARGS from + config.h.in to here because declaration of rl_message in + readline.h uses the defines. This makes it hard for another packages + to use after the header files are installed, since config.h is not + one of the installed files. Suggested by Tom Tromey + + + 3/27 + ---- +print_cmd.c + - change indirection_string from a static buffer to a dynamic one + managed by indirection_level_string(), so we don't end up truncating + PS4. Suggested by Dennis Williamson + +lib/readline/shell.c + - change sh_set_lines_and_columns to use static buffers instead of + allocating the buffers to pass to setenv/putenv + +lib/readline/terminal.c + - change _rl_get_screen_size to not call sh_set_lines_and_columns if + ignore_env == 0 + - _rl_sigwinch_resize_terminal: new function to just retrieve terminal + size, ignoring environment + +lib/readline/rlprivate.h + - new external declaration for _rl_sigwinch_resize_terminal() (currently + unused) + +lib/readline/signals.c + - rl_sigwinch_handler: set _rl_caught_signal to SIGWINCH + - rl_sigwinch_handler: don't immediately call rl_resize_terminal; just + leave _rl_caught_signal set for RL_CHECK_SIGNALS to handle + - _rl_signal_handler: call rl_resize_terminal if sig == SIGWINCH. + Should fix hang when sending multiple repeated SIGWINCH reported by + Henning Bekel + + 3/29 + ---- +lib/sh/snprintf.c + - include math.h for any defines for isinf/isnan + - use code from gnulib documentation to implement isinf/isnan if they + are not defined + +configure.in + - don't check for isinf or isnan; c99 says they're macros anyway + +config.h.in + - remove defines for ISINF_IN_LIBC and ISNAN_IN_LIBC, no longer used + by snprintf.c + + 4/2 + --- +braces.c + - brace_gobbler: fix to understand double-quoted command substitution, + since the shell understands unquoted comsubs. Fixes bug reported + by Michael Whitten + +lib/readline/display.c + - include on MDOS + - get and set screen size using DJGPP-specific calls on MSDOS + - move cursor up clear screen using DJGPP-specific calls + - don't call tputs on DJGPP; there is no good terminfo support + +lib/readline/terminal.c + - include on MDOS + - get and set screen size using DJGPP-specific calls on MSDOS + - use DJGPP-specific initialization on MSDOS, zeroing all the + _rl_term_* variables + - don't call tputs on DJGPP; there is no good terminfo support + DJGPP support from Eli Zaretskii + + 4/6 + --- + +config-top.h + - change DEFAULT_PATH_VALUE to something more useful and modern + + 4/8 + --- +tests/printf2.sub + - make sure LC_ALL and LC_CTYPE are set so LANG assignment takes effect. + Reported by Cedric Arbogast + + 4/11 + ---- +include/chartypes.h + - fix a couple of dicey defines (though ones that don't cause any + compiler warnings) in IN_CTYPE_DOMAIN + +doc/{bashref.texi,bash.1} + - add note referring to duplicating file descriptors in sections + describing redirecting stdout and stderr and appending to stdout + and stderr. Suggested by Matthew Dinger + +pcomplete.c + - it_init_helptopics: new function to support completing on help topics, + not just builtins + - it_helptopics: new programmable completion list of help topics + - build list of helptopic completions in gen_action_completions on + demand + +pcomplete.h + - new extern declaration for it_helptopics + +builtins/complete.def + - the `helptopic' action now maps to CA_HELPTOPIC intead of CA_BUILTIN, + since there are more help topics than just builtins. Suggested by + Clark Wang + + 4/12 + ---- +print_cmd.c + - fix print_arith_for_command to add a call to PRINT_DEFERRED_HEREDOCS + before ending the body of the command, so heredocs get attached to + the right command instead of to the loop. From gentoo bug 363371 + http://bugs.gentoo.org/show_bug.cgi?id=363371 + +execute_cmd.c + - change coproc_pidchk to unset the appropriate shell variables when + the (currently single) known coproc pid terminates + - cleanup and new functions to fully support multiple coprocesses when + and if I decide to go there + + 4/13 + ---- +print_cmd.c + - fix print_group_command to add a call to PRINT_DEFERRED_HEREDOCS + after call to make_command_string_internal before printing closing + `}' + - fix make_command_string_internal to add a call to + PRINT_DEFERRED_HEREDOCS after recursive call to + make_command_string_internal in case cm_subshell before printing + closing `)' + + 4/14 + ---- +print_cmd.c + - change overlapping strcpy in named_function_string to memmove + +sig.h + - UNBLOCK_SIGNAL: convenience define, same as UNBLOCK_CHILD, just + restores an old signal mask + +trap.c + - set_signal: instead of setting the signal handler to SIG_IGN while + installing the new trap handler, block the signal and unblock it + after the new handler is installed. Fixes bug reported by Roman + Rakus + + 4/15 + ---- +doc/{bash.1,bashref.texi} + - make it clear that enabling monitor mode means that all jobs run in + separate process groups + + 4/18 + ---- +builtins/fc.def + - update fix of 4/15/2010 to not take saved_command_line_count into + account when stepping down the history list to make sure that + last_hist indexes something that is valid. Fixes bug reported by + + + 4/19 + ---- +builtins/fc.def + - fc_gethnum: make sure the calculation to decide the last history + entry is exactly the same as fc_builtin. Fixes bug uncovered by + fix of 4/18 to stop seg fault + + 4/22 + ---- +lib/readline/terminal.c + - change _rl_enable_meta_key to set a flag indicating that it sent the + enable-meta sequence + - _rl_disable_meta_key: new function to turn off meta mode after we + turned it on with _rl_enable_meta_key + +lib/readline/rlprivate.h + - extern declaration for _rl_disable_meta_key + +configure.in + - if not cross-compiling, set CFLAGS_FOR_BUILD from any CFLAGS inherited + from the environment. Fixes HP/UX build problem reported by + "Daniel Richard G." + + 4/26 + ---- +config-top.h + - define MULTIPLE_COPROCS to 0 so the code is still disabled but easy + to enable via configure option or editing this file + + 4/29 + ---- +lib/sh/eaccess.c + - freebsd provides faccessat, with the same misfeature as their eaccess + and access implementations (X_OK returns true for uid==0 regardless + of the actual file permissions), so reorganize code to check the + file permissions as with eaccess. Report and fix from Johan Hattne + + + 5/2 + --- +doc/{bash.1,bashref.texi} + - add forward reference to `Pattern Matching' from `Pathname + Expansion', suggested by Greg Wooledge + + 5/5 + --- +pcomplib.c + - the bash_completion project now distributes over 200 completions + for various programs, with no end in sight, so increase the value + of COMPLETE_HASH_BUCKETS from 32 to 128 + +pathexp.c + - quote_string_for_globbing: make sure CTLESC quoting CTLESC is + translated into \ even if the flags include QGLOB_REGEXP. + We don't want to process the second CTLESC as a quote character. + Fixes bug reported by Shawn Bohrer + + 5/6 + --- +builtins/printf.def + - change PRETURN to not call fflush if ferror(stdout) is true + - if a call to one of the stdio functions or printstr leaves + ferror(stdout) true, and PRETURN is going to be called, let PRETURN + print the error message rather than doubling up the messages. Fixes + problem reported by Roman Rakus + + 5/9 + --- +doc/{bash.1,bashref.texi} + - add note to the effect that lists inside compound command can be + terminated by newlines as well as semicolons. Suggested by + Roman Byshko + + 5/10 + ---- +subst.c + - remove_quoted_nulls: fix problem that caused it to skip over the + character after a CTLNUL, which had the effect of skipping every + other of a series of CTLNULs. Fixes bug reported by + Marten Wikstrom + + 5/11 + ---- +subst.c + - extract_process_subst: add SX_COMMAND flag to call to + extract_delimited_string, since we're expanding the same sort of + command as command substitution. Fixes bug reported in Ubuntu + bug 779848 + + 5/12 + ---- +configure.in + - set the prefer_shared and prefer_static variables appropriately + depending on the value of $opt_static_link + +aclocal.m4 + - AC_LIB_LINKFLAGS_BODY: change to not prefer shared versions of the + libraries it's searching for if the prefer_shared variable is "no". + Fixes problem reported by Cedric Arbogast + + 5/13 + ---- +lib/readline/readline.c + - _rl_internal_teardown: add call to _rl_disable_meta_key to make the + meta key active only for the duration of the call to readline() + - _rl_internal_setup: move call to _rl_enable_meta_key here from + readline_initialize_everything so the meta key is active only for + the duration of the call to readline(). Suggestion from Miroslav + Lichvar + +builtins/help.def + - help_builtin: change strncmp to strcmp so that `help read' no longer + matches `readonly'. Suggested by Clark Wang + +config.h.in + - add define for GLIBC21, checked using jm_GLIBC21 as part of the tests + for libintl + +lib/malloc/malloc.c + - internal_free: don't use the cached value of memtop when deciding + whether or not to adjust the break and give memory back to the kernel + when using the GNU C library, since glibc uses sbrk for its own + internal purposes. From Debian bug 614815, reported by Samuel + Thibault + +aclocal.m4 + - BASH_STRUCT_WEXITSTATUS_OFFSET: change AC_RUN_IFELSE to AC_TRY_RUN + to avoid warning about not using AC_LANG_SOURCE + + 5/14 + ---- +bashline.[ch] + - two new functions, bashline_set_event_hook and bashline_reset_event_hook, + to set rl_event_hook to bash_event_hook and back to NULL, respectively + - don't set rl_event_hook unconditionally + +sig.c + - termsig_sighandler: if the shell is currently interactive and + readline is active, call bashline_set_event_hook to cause + termsig_handler to be called via bash_event_hook when the shell + returns from the signal handler + + 5/15 + ---- +lib/readline/display.c + - _rl_col_width: Mac OS X has a bug in wcwidth: it does not return 0 + for UTF-8 combining characters. Added workaround dependent on + MACOSX. Fixes problem pointed out by Thomas De Contes + + + 5/16 + ---- +lib/readline/rlmbutil.h + - WCWIDTH: wrapper for wcwidth that returns 0 for Unicode combining + characters on systems where wcwidth is broken (e.g., Mac OS X). + +lib/readline/{complete,display,mbutil}.c + - use WCWIDTH instead of wcwidth + + 5/17 + ---- +lib/readline/display.c + - update_line: after computing ofd and nfd, see whether the next + character in ofd is a zero-width combining character. If it is, + back ofd and nfd up one, so the base characters no longer compare + as equivalent. Fixes problem reported by Keith Winstein + + +lib/readline/nls.c + - _rl_utf8locale: new flag variable, set to non-zero if the current + locale is UTF-8 + - utf8locale(): new function, returns 1 if the passed lspec (or the + current locale) indicates that the locale is UTF-8. Called from + _rl_init_eightbit + +lib/readline/rlprivate.h + - extern declaration for _rl_utf8locale + +locale.c + - locale_utf8locale: new flag variable, set to non-zero if the current + locale is UTF-8 (currently unused) + - locale_isutf8(): new function, returns 1 if the passed lspec (or the + current locale) indicates that the locale is UTF-8. Should be called + whenever the locale or LC_CTYPE value is modified + +aclocal.m4 + - BASH_WCWIDTH_BROKEN: new test for whether or not wcwidth returns + zero-width characters like unicode combining characters as having + display length 1; define WCWIDTH_BROKEN in this case + +config.h.in + - WCWIDTH_BROKEN: new define + +lib/readline/rlmbutil.h + - change WCWIDTH macro to use _rl_utf8locale and the full range of + Unicode combining characters (U+0300-U+036F) + + 5/19 + ---- +lib/readline/rlprivate.h + - _rl_search_context: new member, prevc, will hold character read + prior to lastc + +lib/readline/isearch.c + - _rl_isearch_dispatch: if the character causes us to index into + another keymap, save that character in cxt->prevc + - _rl_isearch_dispatch: if we index into another keymap, but don't + find a function that's special to i-search, and the character that + caused us to index into that keymap would have terminated the + search, push back cxt->prevc and cxt->lastc to make it appear as + if `prevc' terminated the search, and execute lastc as a command. + We have to push prevc back so we index into the same keymap before + we read lastc. Fixes bug report from Davor Cubranic + + + 5/20 + ---- +expr.c + - expr_bind_variable: pay attention to the return value from + bind_variable and check whether or not we should error out due to + a readonly or noassign variable. Fixes bug reported by Eric + Blake + + 5/26 + ---- + +lib/readline/search.c + - include histlib.h for ANCHORED_SEARCH defines + - rl_history_search_flags: new variable, holds ANCHORED_SEARCH flag for + the duration of a history search + - rl_history_search_reinit: takes a new flags variable, defines whether + or not the search is anchored; assigned to rl_history_search_flags + - rl_history_serarch_reinit: if ANCHORED_SEARCH flag passed, add ^ to + beginning of search string; otherwise search string is unmodified + - rl_history_search_internal: set rl_point appropriately based on + whether or not rl_history_search_flags includes ANCHORED_SEARCH + - rl_history_substr_search_forward: new function, for non-anchored + substring search forward through history for string of characters + preceding rl_point + - rl_history_substr_search_backward: new function, for non-anchored + substring search backward through history for string of characters + preceding rl_point. Original code from Niraj Kulkarni + + +lib/readline/readline.h + - extern declarations for rl_history_substr_search_{for,back}ward + +lib/readline/funmap.c + - history-substring-search-forward: new bindable command, invokes + rl_history_substr_search_forward + - history-substring-search-backward: new bindable command, invokes + rl_history_substr_search_backward + +lib/readline/doc/{rluser.texi,readline.3} + - document history-substring-search-forward and + history-substring-search-backward + + 5/27 + ---- +{nojobs,jobs}.c + - add support for DONT_REPORT_SIGTERM so that the shell doesn't print + a message when a job exits due to SIGTERM since that's the default + signal sent by the kill builtin. Suggested by Marc Herbert + + +config-top.h + - DONT_REPORT_SIGTERM: new user-modifiable setting. Commented out + by default + + 5/28 + ---- +lib/readline/bind.c + - _rl_skip_to_delim: skip to a closing double quote or other delimiter, + allowing backslash to quote any character, including the delimiter + - rl_parse_and_bind: call _rl_skip_to_delim instead of using inline + code + - rl_parse_and_bind: allow quoted strings as the values of string + variables. Variable values without double quotes have trailing + whitespace removed (which still allows embedded whitespace, for + better or worse). Fixes problem with string variables not matching + in `set' command if values happen to have trailing spaces or tabs + (debian bash bug #602762), but introduces slight incompatibility. + + 5/29 + ---- +doc/{bash.1,bashref.texi} + - clarify unset description to specify that without options, a + variable, then a shell function if there is no variable by that + name, is unset. Fixes discrepancy reported by Mu Qiao + + + 6/4 + ---- +doc/{bash.1,bashref.texi} + - clarify description of LINES and COLUMNS (and checkwinsize shopt + option) to make it clear that only interactive shells set a + handler for SIGWINCH and update LINES and COLUMNS. Original + report submitted by Jonathan Nieder + +arrayfunc.c + - expand_compound_array_assignment: defer expansion of words between + parens when performing compound assignmnt to an associative array + variable + - assign_compound_array_list: perform the same expansions when doing + a compound array assignment to an associative array variable as + when doing a straight array index assignment. The idea is that + foo=( [ind1]=bar [ind2]=quux) + is the same as + foo[ind1]=bar ; foo[ind2]=quux + + This fixes problems with double-expansion and quote removal being + performed on the array indices + + 6/13 + ---- +doc/{bash.1,bashref.texi} + - Add a little text to make it clear that the locale determines how + range expressions in glob patterns are handled. + + + 6/21 + ---- +builtins/read.def + - display a message and return error status if -a is used with an + existing associative array. Fixes bug reported by Curtis Doty + + + 6/24 + ---- +{jobs,nojobs}.c + - non-interactive shells now react to the setting of checkwinsize + and set LINES and COLUMNS after a foreground job exits. From a + suggestion by Leslie Rhorer + +doc/{bash.1,bashref.texi} + - checkwinsize: remove language saying that only interactive shells + check the window size after each command + +lib/readline/histfile.c + - history_backupfile: new file, creates a backup history file name + given a filename (appending `-') + - history_do_write: when overwriting the history file, back it up + before writing. Restore backup file on a write error. Suggested + by chkno@chkno.net + +bashline.c + - find_cmd_name: two new arguments, return the start and end of the + actual text string used to find the command name, without taking + whitespace into account + - attempt_shell_completion: small changes to make sure that completion + attempted at the beginning of a non-empty line does not find a + programmable completion, even if the command name starts at point + - attempt_shell_completion: small change to make sure that completion + does not find a progcomp when in whitespace before the command + name + - attempt_shell_completion: small change to make sure that completion + does not find a progcomp when point is at the first character of a + command name, even when there is leading whitespace (similar to + above). Fixes problems noted by Ville Skytta + +subst.c + - brace_expand_word_list: since the individual strings in the strvec + returned by brace_expand are already allocated, don't copy them to + newly-allocated memory when building the WORD_LIST, just use them + intact + +locale.c + - locale_mb_cur_max: cache value of MB_CUR_MAX when we set or change + the locale to avoid a function call every time we need to read it + +shell.h + - new struct to save shell_input_line and associated variables: + shell_input_line_state_t + - add members of sh_parser_state_t to save and restore token and the + size of the token buffer + +parse.y + - {save,restore}_input_line_state: new functions to save and restore + shell_input_line and associated variables + - {save,restore}_parser_state: add code to save and restore the token + and token buffer size + - xparse_dolparen: call save_ and restore_input_line_state to avoid + problems with overwriting shell_input_line when we recursively + call the parser to parse a command substitution. Fixes bug + reported by Rui Santos + +include/shmbutil.h + - use locale_mb_cur_max instead of MB_CUR_MAX in ADVANCE_CHAR and + similar macros + +lib/glob/smatch.c + - rangecmp,rangecmp_wc: change to take an additional argument, which + forces the use of strcoll/wscoll when non-zero. If it's 0, a new + variable `glob_asciirange' controls whether or not we use strcoll/ + wscoll. If glob_asciirange is non-zero, we use straight + C-locale-like ordering. Suggested by Aharon Robbins + + + 6/30 + ---- +execute_cmd.c + - execute_pipeline: make sure the lastpipe code is protected by + #ifdef JOB_CONTROL. Fixes problem reported by Thomas Cort + + + 7/2 + --- +lib/readline/complete.c + - EXPERIMENTAL: remove setting of _rl_interrupt_immediately around + completion functions that touch the file system. Idea from Jan + Kratochvil and the GDB development + team + +lib/readline/signals.c + - rl_signal_handler: if we're in callback mode, don't interrupt + immediately on a SIGWINCH + + 7/3 + --- +bashline.c + - set_directory_hook: and its siblings are a new set of functions to + set, save, and restore the appropriate directory completion hook + - change callers to use {set,save,restore}_directory_hook instead of + manipulating rl_directory_rewrite_hook directly + - dircomplete_expand: new variable, defaults to 0, if non-zero causes + directory names to be word-expanded during word and filename + completion + - change {set,save,restore}_directory_hook to look at dircomplete_expand + and change rl_directory_completion_hook or rl_directory_rewrite_hook + appropriately + +bashline.h + - extern declaration for set_directory_hook so shopt code can use it + + 7/6 + --- +builtins/shopt.def + - globasciiranges: new settable shopt option, makes glob ranges act + as if in the C locale (so b no longer comes between A and B). + Suggested by Aharon Robbins + + 7/7 + --- +doc/{bash.1,bashref.texi} + - document new `globasciiranges' shopt option + + 7/8 + --- +builtins/shopt.def + - direxpand: new settable option, makes filename completion expand + variables in directory names like bash-4.1 did. + - shopt_set_complete_direxpand: new function, does the work for the + above by calling set_directory_hook + +doc/{bash.1,bashref.texi} + - document new `direxpand' shopt option + + 7/15 + ---- +lib/readline/isearch.c + - _rl_isearch_dispatch: when adding character to search string, use + cxt->lastc (which we use in the switch statement) instead of c, + since lastc can be modified earlier in the function + + 7/18 + ---- +lib/readline/rlprivate.h + - _rl_search_context: add another member to save previous value of + (multibyte) lastc: pmb is to mb as prevc is to lastc + +lib/readline/isearch.c: + - _rl_isearch_dispatch: if a key sequence indexes into a new keymap, + but doesn't find any bound function (k[ind].function == 0) or is + bound to self-insert (k[ind].function == rl_insert), back up and + insert the previous character (the one that caused the index into a + new keymap) and arrange things so the current character is the next + one read, so both of them end up in the search string. Fixes bug + reported by Clark Wang + - _rl_isearch_dispatch: a couple of efficiency improvements when adding + characters to the isearch string + + 7/24 + ---- +lib/readline/isearch.c + - _rl_isearch_dispatch: save and restore cxt->mb and cxt->pmb + appropriately when in a multibyte locale + +doc/{bash.1,bashref.texi} + - correct description of {x}>file (and other redirection operators + that allocate a file descriptor) to note the the fd range is + greater than or equal to 10. Fixes problem reported by + Christian Ullrich + +lib/readline/signals.c + - rl_signal_handler: don't interrupt immediately if in callback mode + +lib/readline/callback.c + - rl_callback_read_char: install signal handlers only when readline + has control in callback mode, so readline's signal handlers aren't + called when the application is active (e.g., between the calls to + rl_callback_handler_install and rl_callback_read_char). If the + readline signal handlers only set a flag, which the application + doesn't know about, the signals will effectively be ignored until + the next time the application calls into the readline callback + interface. Fixes problem of calling unsafe functions from signal + handlers when in callback mode reported by Jan Kratochvil + + +execute_cmd.c + - fix_assignment_words: when in Posix mode, the `command' builtin + doesn't change whether or not the command name it protects is an + assignment builtin. One or more instances of `command' + preceding `export', for instance, doesn't make `export' treat its + assignment statement arguments differently. Posix interpretation + #351 + +doc/{bash.1,bashref.texi} + - document new Posix-mode behavior of `command' when preceding builtins + that take assignment statements as arguments + +builtins/printf.def + - printstr: if fieldwidth or precision are < 0 or > INT_MAX when + supplied explicitly (since we take care of the `-' separately), + clamp at INT_MAX like when using getint(). Fixes issue reported + by Ralph Coredroy + + 7/25 + ---- +lib/readline/chardefs.h + - isxdigit: don't define if compiling with c++; declared as a c++ + template function. Fixes bug reported by Miroslav Lichvar + + +builtins/printf.def + - getint: if garglist == 0, return whatever getintmax returns (0). + Fixes bug reported by Ralph Coredroy + + 7/28 + ---- +doc/{bash.1,bashref.texi} + - minor changes to the descriptions of the cd and pushd builtins + +lib/sh/zread.c + - zsyncfd: change variable holding return value from lseek to + off_t. Bug report and fix from Gregory Margo + + 8/1 + --- +expr.c + - don't check for division by 0 when in a context where no evaluation + is taking place. Fixes bug reported by dnade.ext@orange-ftgroup.com + + 8/6 + --- +execute_cmd.c + - execute_command_internal: the parent branch of the subshell code + (where the child calls execute_in_subshell) should not close all + open FIFOs with unlink_fifo_list if it's part of a shell function + that's still executing. Fixes bug reported by Maarten Billemont + + + 8/9 + --- +builtins/common.c + - get_exitstat: return EX_BADUSAGE (2) on a non-numeric argument + +builtins/return.def + - return_builtin: just call get_exitstat to get the return status, + let it handle proper parsing and handling of arguments. Fixes + issue most recently raised by Linda Walsh . + Reverses change from 9/11/2008 (see above) + + 8/16 + ---- +doc/{bash.1,bashref.texi} + - clean up `set -e' language to make it clearer that any failure of + a compound command will cause the shell to exit, not just subshells + and brace commands + + 8/17 + ---- +configure.in + - make the various XXX_FOR_BUILD variables `precious' to autoconf to + avoid stale data + - change how CC_FOR_BUILD is initialized when cross-compiling and not, + but do not change behavior + - initialize CFLAGS_FOR_BUILD to -g when cross-compiling + - initialize LIBS_FOR_BUILD to $(LIBS) when not cross-compiling, empty + when cross-compiling + - create AUTO_CFLAGS variable to hold basic CFLAGS defaults; used when + CFLAGS not inherited from environment (like effect of old + auto_cflags variable) + - substitute LIBS_FOR_BUILD into output Makefiles + [changes inspired by bug report from Nathan Phillip Brink + -- gentoo bug 378941] + +builtins/Makefile.in + - substitute LIBS_FOR_BUILD from configure, not strictly initialized + to $(LIBS) + + 8/27 + ---- +doc/{bash.1,bashref.texi} + - minor changes to the here string description to clarify the + expansions performed on the word + +support/shobj-conf + - handle compilation on Lion (Mac OS X 10.7/darwin11) with changes + to darwin stanzas. Fixes readline bug reported by Vincent + Sheffer + +lib/sh/strtrans.c + - ansic_wshouldquote: check a string with multi-byte characters for + characters that needs to be backslash-octal escaped for $'...' + - ansic_shouldquote: if is_basic fails for one character, let + ansic_wshouldquote examine the rest of the string and return what + it returns. From a patch sent by Roman Rakus + + 8/30 + ---- +lib/sh/strtrans.c + - ansic_quote: changes to quote (or not) multibyte characters. New + code converts them to wide characters and uses iswprint to check + valid wide chars. From a patch sent by Roman Rakus + + + 9/7 + --- +lib/sh/shquote.c + - sh_backslash_quote: change to be table-driven so we can use a + different table if we want to + - sh_backslash_quote: takes a second char table[256] argument; + +externs.h + - sh_backslash_quote: add second argument to function prototype + +bashline.c,braces.c,parse.y,builtins/printf.def + - change callers of sh_backslash_quote to add second argument + +bashline.c + - filename_bstab: table of characters to pass to sh_backslash_quote; + characters with value 1 will be backslash-quoted + - set_filename_bstab: turn on characters in filename backslash-quote + table according to passed string argument + - call set_filename_bstab every time rl_filename_quote_characters is + assigned a value + - bash_quote_filename: call sh_backslash_quote with filename_bstab + as second argument. This allows other characters in filenames to + be quoted without quoting, for instance, a dollar sign in a shell + variable reference + + 9/8 + --- +bashline.c + - complete_fullquote: new variable, controls table passed to + sh_backslash_quote. If non-zero (the default), the standard set + of shell metacharacters -- as in bash versions up to and including + bash-4.2 -- gets backslash-quoted by the completion code. If zero, + sh_backslash_quote gets the table with the characters in the + variable reference removed, which means they are removed from the + set of characters to be quoted in filenames + + 9/10 + ---- +bashline.c + - bash_filename_stat_hook: new function, designed to expand variable + references in filenames before readline passes them to stat(2) + to determine whether or not they are a directory + + 9/15 + ---- +builtins/declare.def + - if assign_array_element fails due to a bad (or empty) subscript, mark + it as an assignment error and don't attempt any further processing + of that declaration. Fixes segfault bug reported by Diego Augusto + Molina + + 9/19 + ---- +expr.c + - exppower: replace the simple exponentiation algorithm with an + implementation of exponentiation by squaring. Inspired by report + from Nicolas ARGYROU + +bashline.c + - bash_quote_filename: check for rtext being non-null before + dereferencing it + - set_saved_history: operate_and_get_next assumes that the previous + line was added to the history, even when the history is stifled and + at the max number of entries. If it wasn't, make sure the history + number is incremented properly. Partial fix for bug reported by + gregrwm + +doc/{bash.1,bashref.texi},lib/readline/doc/{hsuser,rluser}.texi + - minor editorial changes inspired by suggestions from + Roger Zauner + + 9/20 + ---- +lib/intl/localealias.c + - read_alias_file: close resource leak (fp) when returning on error + + 9/22 + ---- +execute_command.c + - execute_intern_function: implement Posix interpretation 383 by making + it an error to define a function with the same name as a special + builtin when in Posix mode. + http://austingroupbugs.net/view.php?id=383#c692 + + 9/25 + ---- +doc/{bash.1,bashref.texi} + - formatting and some content changes from Benno Schulenberg + + - document new posix-mode behavior from interp 383 change of 9/22 + + 9/30 + ---- +execute_cmd.c + - shell_execve: add strerror to error message about executable file + that shell can't execute as a shell script. From suggestion by + daysleeper + + 10/1 + ---- +bashhist.c + - maybe_add_history: act as if literal_history is set when parser_state + includes PST_HEREDOC, so we save the bodies of here-documents just + as they were entered. Fixes bug reported by Jonathan Wakely + + - bash_add_history: make sure that the second and subsequent lines of + a here document don't have extra newlines or other delimiting + chars added, since they have the trailing newline preserved, when + `lithist' is set and history_delimiting_chars isn't called + +execute_cmd.c + - execute_command_internal: avoid fd exhaustion caused by using + process substitution in loops inside shell functions by using + copy_fifo_list and close_new_fifos (). Fixes debian bash bug + 642504 + +lib/readline/complete.c + - new variable, rl_filename_stat_hook, used by append_to_match. If + filename completion is desired, and rl_filename_stat_hook points + to a function, call that function to expand the filename in an + application-specific way before calling stat. + +bashline.c + - bash_default_completion: if variable completion returns a single + match, use bash_filename_stat_hook and file_isdir to determine + whether or not the variable name expands to a directory. If it + does, set the filename_append_character to `/'. This is not + perfect, so we will see how it works out. Adds functionality + requested by Peter Toft and Patrick Pfeifer + + - rl_filename_stat_hook: assigned bash_filename_stat_hook, so things + like $HOME/Downloads (after completion) have a slash appended. + In general, this causes the stat hook to be called whenever + filename completion is appended. Adds functionality requested by + Patrick Pfeifer + +lib/readline/readline.h + - new extern declaration for rl_filename_stat_hook + +lib/readline/doc/rltech.texi + - rl_directory_rewrite_hook: now documented + - rl_filename_stat_hook: document + +pcomplete.c + - gen_action_completions: in the CA_DIRECTORY case, turn off + rl_filename_completion_desired if it was off before we called + rl_filename_completion_function and we didn't get any matches. + Having it on causes readline to quote the matches as if they + were filenames. Adds functionality requested by many, + including Clark Wang + +assoc.[ch] + - assoc_replace: new function, takes the same arguments as + assoc_insert, but returns the old data instead of freeing it + - assoc_insert: if the object returned by hash_insert doesn't have + the same value for its key as the key passed as an argument, we + are overwriting an existing value. In this case, we can free the + key. Fixes bug reported by David Parks + + 10/5 + ---- +print_cmd.c + - indirection_level_string: small change to only re-enable `x' + option after calling decode_prompt_string if it was on before. In + normal mode, it will be, but John Reiser + has a novel use for that code in conjunction with a pre-loaded + shared library that traces system call usage in shell scripts + + 10/10 + ----- +Makefile.in + - Fix from Mike Frysinger to avoid trying to + build y.tab.c and y.tab.h with two separate runs of yacc if + parse.y changes. Problem with parallel makes + - Fix from Mike Frysinger to avoid subdirectory + builds each trying to make version.h (and all its dependencies) + +lib/sh/Makefile.in + - remove some dependencies on version.h where it doesn't make sense + +variables.c + - initialize_shell_variables: while reading the environment, a shell + running in posix mode now checks for SHELLOPTS being readonly (it + gets set early on in main()) before trying to assign to it. It + saves an error message and the variable gets parsed as it should. + Fixes bug reported by Len Giambrone + + 10/14 + ----- +doc/{bash.1,bashref.texi} + - add to the "duplicating file descriptors" description that >&word + doesn't redirect stdout and stderr if word expands to `-' + - add to the "appending standard output and standard error" + description a note that >&word, where word is a number or `-', + causes other redirection operators to apply for sh and Posix + compatibility reasons. Suggested by Greg Wooledge + + + 10/15 + ----- +pcomplete.c + - change pcomp_filename_completion_function to only run the filename + dequoting function in the cases (as best as it can figure) where + readline won't do it via rl_filename_completion_function. Based + on reports from + + 10/19 + ----- +bashline.c + - attempt_shell_completion: add call to set_directory_hook() to make + sure the rewrite functions are correct. It's cheap and doesn't + hurt + - command_word_completion_function: if completing a command name that + starts with `.' or `..', temporarily suppress the effects of the + `direxpand' option and restore the correct value after calling + rl_filename_completion_function. If it's enabled, the directory + name will be rewritten and no longer match `./' or `../'. Fixes + problem reported by Michael Kalisz + + 10/22 + ----- +builtins/history.def + - push_history: make sure remember_on_history is enabled before we + try to delete the last history entry -- the `history -s' command + might not have been saved. Fixes bug reported by + lester@vmw-les.eng.vmware.com + +lib/readline/complete.c + - rl_callback_read_char: add calls to a macro CALLBACK_READ_RETURN + instead of straight return; add same call at end of function. + Placeholder for future work in deinstalling signal handlers when + readline is not active + + 10/25 + ----- +expr.c + - exp2: catch arithmetic overflow when val1 == INTMAX_MIN and val2 == -1 + for DIV and MOD and avoid SIGFPE. Bug report and pointer to fix + from Jaak Ristioja + - expassign: same changes for arithmetic overflow for DIV and MOD + + 10/28 + ----- +subst.c + - parameter_brace_expand: allow pattern substitution when there is an + expansion of the form ${var/} as a no-op: replacing nothing with + nothing + - parameter_brace_patsub: don't need to check for PATSUB being NULL; + it never is + +flags.c + - if STRICT_POSIX is defined, initialize history_expansion to 0, since + history expansion (and its treatment of ! within double quotes) is + not a conforming posix environment. From austin-group issue 500 + +lib/readline/histexpand.c + - history_expand: when processing a string within double quotes + (DQUOTE == 1), make the closing double quote inhibit history + expansion, as if the word were outside double quotes. In effect, + we assume that the double quote is followed by a character in + history_no_expand_chars. tcsh and csh seem to do this. This + answers a persistent complaint about history expansion + + 10/29 + ----- +make_cmd.c + - make_arith_for_command: use skip_to_delim to find the next `;' + when breaking the string between the double parens into three + separate components instead of a simple character loop. Fixes + bug reported by Dan Douglas + + 11/2 + ---- +Makefile.in + - make libbuiltins.a depend on builtext.h to serialize its creation + and avoid conflict between multiple invocations of mkbuiltins. + Fix from Mike Frysinger + + 11/5 + ---- +findcmd.c + - user_command_matches: if stat(".", ...) returns -1, set st_dev + and st_ino fields in dotinfo to 0 to avoid same_file matches + - find_user_command_in_path: check stat(2) return the same way + +lib/glob/glob.c + - glob_vector: don't call strlen(pat) without checking pat == 0 + - glob_dir_to_array: make sure to free `result' and all allocated + members before returning error due to malloc failure + - glob_vector: make sure to free `nextname' and `npat' on errors + (mostly when setting lose = 1) + - glob_vector: if flags & GX_MATCHDIRS but not GX_ALLDIRS, make + sure we free `subdir' + - glob_filename: when expanding ** (GX_ALLDIRS), make sure we + free temp_results (return value from glob_vector) + +lib/glob/xmbsrtowcs.c + - xdupmbstowcs: fix call to realloc to use sizeof (char *) instead + of sizeof (char **) when assigning idxtmp + +execute_cmd.c + - print_index_and_element: return 0 right away if L == 0 + - is_dirname: fix memory leak by freeing `temp' + - time_command: don't try to deref NULL `command' when assigning + to `posix_time' + - shell_execve: null-terminate `sample' after READ_SAMPLE_BUF so it's + terminated for functions that expect that + +builtins/read.def + - read_builtin: don't call bind_read_variable with a potentially-null + string + +pcomplete.c + - gen_command_matches: don't call dispose_word_desc with a NULL arg + - gen_compspec_completions: fix memory leak by freeing `ret' before + calling gen_action_completions (tcs, ...). happens when + performing directory completion as default and no completions + have been generated + - gen_progcomp_completions: make sure to set foundp to 0 whenever + returning NULL + - it_init_aliases: fix memory leak by freeing alias_list before + returning + +bashline.c + - command_word_completion_function: don't call restore_tilde with a + NULL directory_part argument + - bash_directory_expansion: bugfix: don't throw away results of + rl_directory_rewrite_hook if it's set and returns non-zero + - bind_keyseq_to_unix_command: free `kseq' before returning error + +arrayfunc.c + - assign_array_element_internal: make sure `akey' is freed if non-null + before returning error + - assign_compound_array_list: free `akey' before returning error + - array_value_internal: free `akey' before returning error + - unbind_array_element: free `akey' before returning error + +subst.c + - array_length_reference: free `akey' before returning error in case + of expand_assignment_string_to_string error + - array_length_reference: free `akey' after call to assoc_reference + - skip_to_delim: if skipping process and command substitution, free + return value from extract_process_subst + - parameter_brace_substring: free `val' (vtype == VT_VARIABLE) before + returning if verify_substring_values fails + - parameter_brace_expand: remove two duplicate lines that allocate + ret in parameter_brace_substring case + - parameter_brace_expand: convert `free (name); name = xmalloc (...)' + to use `xrealloc (name, ...)' + - parameter_brace_expand: free `name' before returning when handling + ${!PREFIX*} expansion + - split_at_delims: fix memory leak by freeing `d2' before returning + +redir.c + - redirection_error: free `filename' if the redirection operator is + REDIR_VARASSIGN by assigning allocname + +eval.c + - send_pwd_to_eterm: fix memory leak by freeing value returned by + get_working_directory() + +builtins/cd.def + - change_to_directory: fix memory leak by freeing return value from + resetpwd() + - cd_builtin: fix memory leak by freeing value returned by dirspell() + - cd_builtin: fix memory leak by freeing `directory' if appropriate + before overwriting with return value from resetpwd() + +builtins/type.def + - describe_command: free `full_path' before overwriting it with return + value from sh_makepath + +builtins/complete.def + - compgen_builtin: fix memory leak by calling strlist_dispose (sl) + before overwriting sl with return value from completions_to_stringlist + +builtins/hash.def + - list_hashed_filename_targets: fix memory leak by freeing `target' + +make_cmd.c + - make_arith_for_command: free `init', `test', and `step' before + returning error on parse error + +jobs.c + - initialize_job_control: don't call move_to_high_fd if shell_tty == -1 + +general.c + - check_dev_tty: don't call close with an fd < 0 + - legal_number: deal with NULL `string' argument, return invalid + +lib/sh/fmtulong.c + - fmtulong: if the `base' argument is invalid, make sure we index + buf by `len-1' at maximum + +print_cmd.c + - print_deferred_heredocs: don't try to dereference a NULL `cstring' + - cprintf: make sure to call va_end (args) + +variables.c + - push_dollar_vars: fix call to xrealloc to use sizeof (WORD_LIST *) + instead of sizeof (WORD_LIST **) + +lib/sh/zmapfd.c + - zmapfd: if read returns error, free result and return -1 immediately + instead of trying to reallocate it + + 11/6 + ---- +execute_cmd.c + - cpl_reap: rewrote to avoid using pointer after freeing it; now builds + new coproc list on the fly while traversing the old one and sets the + right values for coproc_list when done + + 11/12 + ----- +builtins/set.def + - if neither -f nor -v supplied, don't allow a readonly function to + be implicitly unset. Fixes bug reported by Jens Schmidt + + +lib/readline/callback.c + - change CALLBACK_READ_RETURN to clear signal handlers before returning + from rl_callback_read_char so readline's signal handlers aren't + installed when readline doesn't have control. Idea from Jan + Kratochvil and the GDB development + team + +pcomplete.h + - COPT_NOQUOTE: new complete/compgen option value + +builtins/complete.def + - noquote: new complete/compgen option; will be used to disable + filename completion quoting + +pcomplete.c + - pcomp_set_readline_variables: pay attention to COPT_NOQUOTE; turns + of rl_filename_quoting_desired if set; turns it on if unset (value + is inverted, since default is on) + +doc/bash.1,lib/readline/doc/rluser.texi + - document new -o noquote option to complete/compgen/compopt + +pathexp.c + - quote_string_for_globbing: if QGLOB_REGEXP, make sure characters + between brackets in an ERE bracket expression are not inappropriately + quoted with backslashes. This is a pretty substantial change, + should be stressed when opening bash up for alpha and beta tests. + Fixes bug pointed out by Stephane Chazleas + + +doc/{bash.1,bashref.texi} + - document that regexp matches can be inconsistent when quoting + characters in bracket expressions, since usual quoting characters + lose their meaning within brackets + - note that regular expression matching when the pattern is stored + in a shell variable which is quoted for expansion causes string + matching + +redir.h + - RX_SAVEFD: new flag value; notes that a redirection denotes an + fd used to save another even if it's not >= SHELL_FD_BASE + +redir.c + - do_redirection_internal: when deciding whether or not to reset the + close-on-exec flag on a restored file descriptor, trust the value + of redirect->flags & RX_SAVCLEXEC even if the fd is < SHELL_FD_BASE + if the RX_SAVEFD flag is set + - add_undo_redirect: set the RX_SAVEFD flag if the file descriptor + limit is such that the shell can't duplicate to a file descriptor + >= 10. Fixes a limitation that tripped a coreutils test reported + by Paul Eggert + + 11/19 + ----- +doc/{bash.1,bashref.texi},lib/readline/doc/hsuser.texi + - make it clear that bash runs HISTFILESIZE=$HISTSIZE after reading + the startup files + - make it clear that bash runs HISTSIZE=500 after reading the + startup files + - make it clear that setting HISTSIZE=0 causes commands to not be + saved in the history list + - make it clear that setting HISTFILESIZE=0 causes the history file + to be truncated to zero size + +variables.c + - sv_histsize: change so setting HISTSIZE to a value less than 0 + causes the history to be `unstifled' + - sv_histsize: change so setting HISTFILESIZE to a value less than 0 + results in no file truncation + - make it clear that numeric values less than 0 for HISTFILESIZE or + HISTSIZE inhibit the usual functions + + 11/23 + ----- +parse.y + - save_input_line_state: add missing `return ls' at the end, since the + function is supposed to return its argument. Pointed out by + Andreas Schwab + +builtins/read.def + - skip over NUL bytes in input, as most modern shells seem to. Bug + report by Matthew Story + +lib/readline/vi_mode.c + - rl_vi_replace: set _rl_vi_last_key_before_insert to invoking key + + 11/25 + ----- +builtins/read.def + - read_builtin: if xrealloc returns same pointer as first argument, + don't bother with the remove_unwind_protect/add_unwind_protect pair + - read_builtin: set a flag (`reading') around calls to zread/zreadc + and readline() + - sigalrm: change to set flag (`sigalrm_seen') and only longjmp if + currently in read(2) (reading != 0) + - CHECK_ALRM: new macro, checks sigalrm_seen and longjmps if non-zero, + behavior of old SIGALRM catching function + - read_builtin: call CHECK_ALRM in appropriate places while reading + line of input. Fixes bug reported by Pierre Gaston + + +lib/readline/vi_mode.c + - rl_vi_replace: initialize characters before printing characters in + vi_replace_keymap to their default values in vi_insertion_keymap, + since we're supposed to be in insert mode replacing characters + - rl_vi_replace: call rl_vi_start_inserting to set last command to + `R' for undo + - rl_vi_replace: set _rl_vi_last_key_before_insert to `R' for future + use by _rl_vi_done_inserting + - vi_save_insert_buffer: new function, broke out code that copies text + into vi_insert_buffer from _rl_vi_save_insert + - _rl_vi_save_replace: new function, saves text modified by + rl_vi_replace (using current point and vi_replace_count to figure + it out) to vi_replace_buffer + - _rl_vi_save_insert: call vi_save_insert_buffer + - _rl_vi_done_inserting: if _rl_vi_last_key_before_insert == 'R', call + _rl_vi_save_replace to save text modified in replace mode (uses + vi_save_insert_buffer) + - _rl_vi_replace_insert: new function, replaces the number of chars + in vi_insert_buffer after rl_point with contents ov vi_insert_buffer + - rl_vi_redo: call _rl_vi_replace_insert if last command == 'R' and + there's something in vi_insert_buffer. Fixes bug with `.' not + redoing the most recent `R' command, reported by Geoff Clare + in readline area on savannah + + 11/26 + ----- +lib/readline/rlprivate.h + - RL_SIG_RECEIVED(): evaluate to non-zero if there is a pending signal + to be handled + - RL_SIGINT_RECEIVED(): evaluate to non-zero if there is a pending + SIGINT to be handled + +lib/readline/complete.c + - remove all mention of _rl_interrupt_immediately + - rl_completion_matches: check RL_SIG_RECEIVED after each call to + the entry function, call RL_CHECK_SIGNALS if true to handle the + signal + - rl_completion_matches: if RL_SIG_RECEIVED evaluates to true, free + and zero out the match_list this function allocated + - rl_completion_matches: if the completion entry function is + rl_filename_completion_function, free the contents of match_list, + because that function does not keep state and will not free the + entries; avoids possible memory leak pointed out by + Garrett Cooper + - gen_completion_matches: if RL_SIG_RECEIVED evalutes to true after + calling rl_attempted_completion_function, free the returned match + list and handle the signal with RL_CHECK_SIGNALS; avoids + possible memory leak pointed out by Garrett Cooper + + - gen_completion_matches: if RL_SIG_RECEIVED evaluates to true after + calling rl_completion_matches, free the returned match list and + handle the signal with RL_CHECK_SIGNALS + +lib/readline/util.c + - rl_settracefp: new utility function to set the tracing FILE * + +lib/readline/signals.c + - _rl_sigcleanup: pointer to a function that will be called with the + signal and a void * argument from _rl_handle_signal + - _rl_sigcleanarg: void * that the rest of the code can set to have + passed to the signal cleanup function + - _rl_handle_signal: if _rl_sigcleanup set, call as + (*_rl_sigcleanup) (sig, _rl_sigcleanarg) + +lib/readline/rlprivate.h + - extern declarations for _rl_sigcleanup and _rl_sigcleanarg + +lib/readline/complete.c + - _rl_complete_sigcleanup: signal cleanup function for completion code; + calls _rl_free_match_list on _rl_sigcleanarg if signal == SIGINT + - rl_complete_internal: before calling display_matches if what_to_do + == `?', set _rl_sigcleanup to _rl_complete_sigcleanup so the match + list gets freed on SIGINT; avoids possible memory leak pointed out + by Garrett Cooper + - rl_complete_internal: in default switch case, call _rl_free_match_list + before returning to avoid memory leak + +doc/bashref.texi + - start at a set of examples for the =~ regular expression matching + operator, touching on keeping the pattern in a shell variable and + quoting portions of the pattern to remove their special meaning + + 12/1 + ---- +lib/glob/gmisc.c + - extglob_pattern: new function, returns 1 if pattern passed as an + argument looks like an extended globbing pattern + +lib/glob/glob.c + - skipname: return 0 immediately if extglob_pattern returns non-zero, + let the extended globbing code do the right thing with skipping + names beginning with a `.' + - mbskipname: return 0 immediately if extglob_pattern returns non-zero, + let the extended globbing code do the right thing with skipping + names beginning with a `.'. Fixes bug reported by Yongzhi Pan + + + 12/2 + ---- +lib/glob/smatch.c + - patscan, patscan_wc: no longer static so other parts of the glob + library can use them, renamed to glob_patscan, glob_patscan_wc + +lib/glob/glob.c + - extern declarations for glob_patscan, glob_patscan_wc + - wchkname: new function, does skipname on wchar_t pattern and dname, + old body of mbskipname after converting to wide chars + - extglob_skipname: new function, checks all subpatterns in an extglob + pattern to determine whether or not a filename should be skipped. + Calls skipname for each subpattern. Dname is only skipped if all + subpatterns indicate it should be. Better fix for bug reported by + Yongzhi Pan + - wextglob_skipname: wide-char version of extglob_skipname, calls + wchkname instead of calling back into mbskipname for each + subpattern to avoid problems with char/wchar_t mismatch + - skipname: call extglob_skipname if extglob_pattern returns non-zero + - mbskipname: call wextglob_skipname if extglob_pattern returns non-zero + - mbskipname: short-circuit immediately if no multibyte chars in + pattern or filename + +execute_cmd.c + - execute_cond_node: added parens to patmatch assignment statement to + make intent clearer + + 12/3 + ---- +configure.in,config.h.in + - check for imaxdiv, define HAVE_IMAXDIV if present + +expr.c + - expassign, exp2: use imaxdiv if available. Doesn't help with checks + for overflow from 10/25 + + 12/6 + ---- +lib/readline/complete.c + - compute_lcd_of_matches: if we're ignoring case in the matches, only + use what the user typed as the lcd if it matches the first match + (after sorting) up to the length of what was typed (if what the + user typed is longer than the shortest of the possible matches, use + the shortest common length of the matches instead). If it doesn't + match, use the first of the list of matches, as if case were not + being ignored. Fixes bug reported by Clark Wang + + + 12/7 + ---- +builtins/cd.def + - cd_builtin: add code to return error in case cd has more than one + non-option argument, conditional on CD_COMPLAINS define (which is + not defined anywhere) + +doc/{bash.1,bashref.texi} + - note that additional arguments to cd following the directory name + are ignored. Suggested by Vaclav Hanzl + + 12/10 + ----- +lib/readline/input.c + - rl_read_key: don't need to increment key sequence length here; doing + it leads to an off-by-one error + +lib/readline/macro.c + - rl_end_kbd_macro: after off-by-one error with rl_key_sequence_length + fixed, can decrement current_macro_index by rl_key_sequence_length + (length of key sequence that closes keyboard macro) + +lib/readline/readline.c + - _rl_dispatch_subseq: fix extra increment of rl_key_sequence_length + when ESC maps to a new keymap and we're converting meta characters + to ESC+key + - _rl_dispatch_subseq: better increment of rl_key_sequence_length + before we dispatch to a function in the ISFUNC case (where the + second increment above should have happened) + - rl_executing_keyseq: the full key sequence that ended up executing + a readline command. Available to the calling application, maintained + by _rl_dispatch_subseq, indexed by rl_key_sequence_length + - rl_executing_key: the key that was bound to the currently-executing + readline command. Same as the `key' argument to the function + +lib/readline/readline.h + - rl_executing_keyseq: extern declaration + - rl_executing_key: extern declaration + - rl_key_sequence_length: declaration moved here from rlprivate.h, + now part of public interface + +lib/readline/rlprivate.h + - new extern declaration for _rl_executing_keyseq_size, buffer size + for rl_executing_keyseq + +lib/readline/doc/rltech.texi + - documented new variables: rl_executing_key, rl_executing_keyseq, + rl_key_sequence_length + + 12/13 + ----- +bashline.c + - bash_execute_unix_command: replace ad-hoc code that searches + cmd_xmap for correct command with call to rl_function_of_keyseq + using rl_executing_keyseq; now supports key sequences longer + than two characters. Fixes bug reported by Michael Kazior + + + 12/15 + ----- +make_cmd.c + - make_function_def: don't null out source_file before calling + make_command so it can be used later on when the function definition + is executed + +execute_cmd.c + - execute_intern_function: second argument is now FUNCTION_DEF * + instead of COMMAND * + - execute_command_internal: call execute_intern_function with the + new second argument (the entire FUNCTION_DEF instead of just the + command member) + - execute_intern_function: if DEBUGGER is defined, call + bind_function_def before calling bind_function, just like + make_function_def does (might be able to take out the call in + make_function_def depending on what the debugger does with it). + Fixes bug reported by + +expr.c + - more minor changes to cases of INTMAX_MIN % -1 and INTMAX_MIN / 1; + fix typos and logic errors + + 12/16 + ----- +bashline.c + - find_cmd_start: change flags to remove SD_NOSKIPCMD so it skips over + command substitutions and doesn't treat them as command separators + - attempt_shell_completion: instead of taking first return from + find_cmd_name as command name to use for programmable completion, + use loop to skip over assignment statements. Fixes problem reported + by Raphael Droz + - attempt_shell_completion: if we don't find a command name but the + command line is non-empty, assume the other words are all assignment + statements and flag that point is in a command position so we can + do command name completion + - attempt_shell_completion: if the word being completed is the first + word following a series of assignment statements, and the + command line is non-empty, flag that point is in a command position + so we can do command name completion + +lib/readline/history.c + - history_get_time: atol -> strtol + + 12/18 + ----- +parse.y + - parser_in_command_position: external interface to the + command_token_position macro for use by other parts of the shell, + like the completion mechanism + +externs.h + - extern declaration for parser_in_command_position + + 12/19 + ----- + +builtins/read.def + - read_builtin: make sure all calls to bind_read_variable are passed + a non-null string. Fixes bug reported by Dan Douglas + + +bashline.c + - attempt_shell_completion: mark that we're in a command position if + we're at the start of the line and the parser is ready to accept + a reserved word or command name. Feature most recently suggested + by Peng Yu + + 12/21 + ----- +lib/readline/bind.c + - _rl_escchar: return the character that would be backslash-escaped + to denote the control character passed as an argument ('\n' -> 'n') + - _rl_isescape: return 1 if character passed is one that has a + backslash escape + - _rl_untranslate_macro_value: new second argument: use_escapes, if + non-zero translate to backslash escapes where possible instead of + using straight \C-x for control character `x'. Change callers + - _rl_untranslate_macro_value: now global + +lib/readline/rlprivate.h + - _rl_untranslate_macro_value: extern declaration + +lib/readline/{macro.c,readline.h} + - rl_print_last_kbd_macro: new bindable function, inspired by patch + from Mitchel Humpherys + +lib/readline/funmap.c + - print-last-kbd-macro: new bindable command, bound to + rl_print_last_kbd_macro + +lib/readline/doc/{rluser.texi,readline.3},doc/bash.1 + - print-last-kbd-macro: document. + +lib/readline/text.c + - _rl_insert_next: if we're defining a macro, make sure the key gets + added to the macro text (should really audit calls to rl_read_key() + and make sure the right thing is happening for all of them) + +bashline.[ch] + - print_unix_command_map: new function, prints all bound commands in + cmd_xmap using rl_macro_dumper in a reusable format + +builtins/bind.def + - new -X option: print all keysequences bound to Unix commands using + print_unix_command_map. Feature suggested by Dennis Williamson + (2/2011) + +doc/{bash.1,bashref.texi} + - document new `bind -X' option + + 12/24 + ----- + +doc/{bash.1,bashref.texi} + - add a couple of sentences to the description of the case modification + operators making it clearer that each character of parameter is + tested against the pattern, and that the pattern should only attempt + to match a single character. Suggested by Bill Gradwohl + + + 12/28 + ----- +shell.c + - init_noninteractive: instead of calling set_job_control(0) to + unconditionally turn off job control, turn on job control if + forced_interactive or jobs_m_flag is set + - shell_initialize: call initialize_job_control with jobs_m_flag as + argument so `bash -m script' enables job control while running the + script + +jobs.c + - initialize_job_control: if the `force' argument is non-zero, turn on + job control even if the shell is not currently interactive + (interactive == 0) + + 12/29 + ----- + +flags.h + - new extern declaration for jobs_m_flag + +builtins/{cd,set}.def,doc/{bash.1,bashref.texi} + - added text clarifying the descriptions of cd -L and -P, suggested by + Padraig Brady + - slight change to the description of `set -P' about resolving symbolic + links + +lib/readline/doc/rluser.texi + - Added an example to the programmable completion section: _comp_cd, + a completion function for cd, with additional verbiage. Text + includes a reference to the bash_completion project + + 1/1/2012 + -------- +jobs.c + - set_job_status_and_cleanup: note that a job is stopped due to + SIGTSTP (any_tstped) if job_control is set; there's no need to + test interactive + + 1/5 + --- +quit.h + - LASTSIG(): new macro, expands to signal number of last terminating + signal received (terminating_signal or SIGINT) + +trap.c + - first_pending_trap: returns lowest signal number with a trap pending + - trapped_signal_received: set to the last trapped signal the shell + received in trap_handler(); reset to 0 in run_pending_traps + +builtins/read.def + - read_builtin: changes to posix-mode (posixly_correct != 0) to make + `read' interruptible by a trapped signal. After the trap runs, + read returns 128+sig and does not assign the partially-read line + to the named variable(s). From an austin-group discussion started + by David Korn + + 1/11 + ---- +doc/{bash.1,bashref.texi} + - slight changes to the descriptions of the compat32 and compat40 shell + options to clarify their meaning + + 1/12 + ---- +lib/readline/{colors.[ch],parse-colors.[ch]} + - new files, part of color infrastructure support + +Makefile.in,lib/readline/Makefile.in + - arrange to have colors.o and parse-colors.o added to readline + library + +{configure,config.h}.in + - check for stdbool.h, define HAVE_STDBOOL_H if found + + 1/14 + ---- +lib/readline/bind.c + - colored_stats: new bindable variable, enables using colors to + indicate file type when listing completions + +lib/readline/complete.c + - _rl_colored_stats: new variable, controlled by colored-stats bindable + variable + - colored_stat_start, colored_stat_end: new functions to set and reset + the terminal color appropriately depending on the type of the + filename to be printed + - print_filename: changes to print colors if `colored-stats' variable + set. Changes contributed by Raphael Droz + + +lib/readline/readline.c + - rl_initialize_everything: add call to _rl_parse_colors to parse + color values out of $LS_COLORS. May have to add to rl_initialize + to make more dynamic if LS_COLORS changes (which doesn't happen + very often, if at all) + +lib/readline/rlprivate.h + - _rl_colored_stats: new extern declaration + +lib/readline/doc/{readline.3,rluser.texi},doc/bash.1 + - colored-stats: document new bindable readline variable + +lib/readline/colors.c + - _rl_print_color_indicator: call rl_filename_stat_hook before calling + lstat/stat so we can get color indicators for stuff like + $HOME/Applications + +lib/readline/complete.c + - stat_char: call rl_filename_stat_hook before calling lstat/stat + +findcmd.[ch],execute_cmd.c + - search_for_command: now takes a second `flags' argument; changed + header function prototype and callers + - search_for_command: if (flags & 1), put the command found in $PATH + into the command hash table (previous default behavior) + +execute_cmd.c + - is_dirname: call search_for_command with flags argument of 0 so it + doesn't try to put something in the command hash table + +bashline.c + - bash_command_name_stat_hook: a hook function for readline's + filename_stat_hook that does $PATH searching the same way that + execute_cmd.c:execute_disk_command() does it, and rewrites the + passed filename if found. Does not put names into command hash + table. This allows command name completion to take advantage + of `visible-stats' and `colored-stats' settings. + - executable_completion: new function, calls the directory completion + hook to expand the filename before calling executable_file or + executable_or_directory; change command_word_completion_function to + call executable_completion. This allows $HOME/bin/[TAB] to do + command completion and display alternatives + + 1/17 + ---- +pcomplete.c + - gen_command_matches: now takes a new second argument: the command + name as deciphered by the programmable completion code and used + to look up the compspec; changed callers (gen_compspec_completions) + - gen_shell_function_matches: now takes a new second argument: the + command that originally caused the completion function to be + invoked; changed callers (gen_compspec_completions)) + - build_arg_list: now takes a new second argument: the command name + corresponding to the current compspec; changed callers + (gen_command_matches, gen_shell_function_matches) + - build_arg_list: now uses `cmd' argument to create $1 passed to + invoked command or shell function + - gen_compspec_completions: if we skipped a null command at the + beginning of the line (e.g., for completing `>'), add a new word for + it at the beginning of the word list and increment nw and cw + appropriately. This is all a partial fix for the shortcoming + pointed out by Sung Pae + + 1/18 + ---- + +{configure,config.h}.in + - new check: check for AUDIT_USER_TTY defined in , + define HAVE_DECL_AUDIT_USER_TTY if both are found + +lib/readline/rlconf.h + - ENABLE_TTY_AUDIT_SUPPORT: new define, allows use of the Linux kernel + tty auditing system if it's available and enabled + +lib/readline/util.c + - _rl_audit_tty: new function, send a string to the kernel tty audit + system + +lib/readline/rlprivate.h + - _rl_audit_tty: new extern declaration + +lib/readline/readline.c + - readline: call _rl_audit_tty with line to be returned before returning + it if the Linux tty audit system is available and it's been enabled + in rlconf.h Original patch from Miroslav Trmac; recent request + from Miroslav Lichvar + + 1/21 + ---- + +lib/readline/readline.c: + - _rl_dispatch_subseq: add an inter-character timeout for multi-char + key sequences. Suggested by . Still needs + work to make a user-settable variable + +parse.y + - shell_getc: make code that uses the pop_alias dependent on ALIAS + define + +variables.h + - sv_tz: extern define should only depend on HAVE_TZSET + +expr.c + - expr_streval: if ARRAY_VARS is not defined, set lvalue->ind to -1; + move assignment to `ind' inside define + - expr_bind_array_element: declaration and uses need to be #ifdef + ARRAY_VARS + +arrayfunc.h + - AV_ALLOWALL, AV_QUOTED, AV_USEIND: define to 0 if ARRAY_VARS not + defined; used in subst.c unconditionally + +sig.h + - make the signal blocking functions not dependent on JOB_CONTROL + +sig.c + - sigprocmask: make the replacement definition not dependent on + JOB_CONTROL + +trap.c + - use BLOCK_SIGNAL/UNBLOCK_SIGNAL instead of code dependent on + HAVE_POSIX_SIGNALS and BSD signals + + 1/24 + ---- + +print_cmd.c + - print_redirection_list: change the conditions under which + r_duplicating_output_word is mapped to r_err_and_out to more or + less match those used in redir.c. Fixes bug pointed out by + Dan Douglas + + + 1/29 + ---- +lib/readline/signals.c + - _rl_block_sigwinch,_rl_release_sigwinch: don't compile in bodies + unless SIGWINCH is defined. Fixes bug reported by Pierre Muller + + +doc/{bash.1,bashref.texi} + - small modifications to the introduction to the REDIRECTION section + to describe how redirections can modify file handles + - small modification to the section describing base#n to make it + clearer that n can be denoted using non-numerics. From a posting + by Linda Walsh + + 2/2 + --- +builtins/printf.def + - printf_builtin: make sure vbuf is intialized and non-null when -v + is supplied, since other parts of the code assume that it's not + null (e.g., bind_printf_variable()). Fixes bug reported by Jim + Avera + + 2/4 + --- +lib/readline/undo.c + - _rl_free_undo_list: new function, old body of rl_free_undo_list, + frees undo entries in UNDO_LIST * passed as argument + - rl_free_undo_list: call _rl_free_undo_list + +lib/readline/rlprivate.h + - _rl_free_undo_list: new extern declaration + - _rl_keyseq_timeout: new extern declaration (see below) + +lib/readline/misc.c + - rl_clear_history: new function. Clears the history list and frees + all associated data similar to history.c:clear_history(), but + takes rl_undo_list into account and frees and UNDO_LISTs saved as + `data' members of a history list entry + +lib/readline/doc/rltech.texi + - rl_clear_history: documented + +lib/readline/readline.c + - _rl_keyseq_timeout: new variable to hold intra-key timeout value + from 1/21 fix; specified in milliseconds. Default value is 500 + - _rl_dispatch_subseq: change to use _rl_keyseq_timeout as intra-key + timeout if it's greater than 0; no timeout if <= 0 + - _rl_dispatch_subseq: don't check for queued keyboard input if we have + pushed or pending input, or if we're reading input from a macro + +lib/readline/bind.c + - keyseq-timeout: new bindable variable, shadows _rl_keyseq_timeout + - string_varlist: add keyseq-timeout + - sv_seqtimeout: new function to modify value of _rl_keyseq_timeout; + clamps negative values at 0 for now + - _rl_get_string_variable_value: return value for keyseq-timeout + +doc/bash.1,lib/readline/doc/{rluser.texi,readline.3} + - keyseq-timeout: documented + +lib/readline/isearch.c + - _rl_isearch_dispatch: modification to fix from 7/18 to not use + cxt->keymap and cxt->okeymap, since by the time this code is + executed, they are equal. Use `f' to check for rl_insert or + unbound func + - _rl_isearch_dispatch: if we're switching keymaps, not in + callback mode, and don't have pending or pushed input, use + _rl_input_queued to resolve a potentially ambiguous key sequence. + Suggested by Roger Zauner + - _rl_isearch_dispatch: if we have changed keymaps and resolved to + an editing function (not self-insert), make sure we stuff the + right characters back onto the input after changing the keymap + back so the right editing function is executed after the search + is terminated. Rest of fix for bug reported by Roger Zauner + + + 2/5 + --- +builtins/gen-helpfiles.c + - new file: reads struct builtin and writes the long docs to files + in the `helpdirs' subdirectory. The filename is given in the + previously-unused `handle' member of the struct builtin. Links + with `tmpbuiltins.o', which is created by Makefile to have the + right long documentation. When not cross-compiling, gets the + right #defines based on configuration options from config.h instead + of trying to parse conditional parts of def files. Fixes + shortcoming pointed out by Andreas Schwab + +builtins/Makefile.in + - tmpbuiltins.c: new generated file, created to enable creation of + separate helpfiles based on correct #defines instead of trying to + parse conditional parts of def files + - gen-helpfiles: new program to generate helpfiles, links with + tmpbuiltins.o + - HELPFILES_TARGET: new target, substituted by configure to `helpdoc' + if separate helpfiles requested + - targets: new target, libbuiltins.a and $(HELPFILES_TARGET) + - CREATED_OBJECTS: new variable, holds created object files for + make clean; changed make clean to remove created objects + - helpdoc: changed to call gen-helpfiles instead of mkbuiltins + +Makefile.in + - when building libbuiltins.a, recursively call make with `targets' + argument to make sure separate helpfiles get built + +configure.in + - substitute `helpdoc' as value of HELPFILES_TARGET if + --enable-separate-helpfiles supplied as configure argument + +builtins/mkbuiltins.c + - `-nofunctions': new argument, causes mkbuiltins to not write value + for function implementing a particular builtin to struct builtin + and to write document file name to `handle' member of struct builtin + - no longer writes separate helpfiles; that is left to gen-helpfiles + + 2/8 + --- +subst.c + - make sure last_command_exit_value is set to a non-zero value before + any calls to report_error, since `-e' set will short-circuit + report_error. Fixes bug reported by Ewan Mellor + + +variables.c + - make_local_array_variable: added second argument; if non-zero, + function will return an existing local associative array variable + instead of insisting on an indexed array + +variable.h,subst.c + - make_local_array_variable: changed prototype and caller + +builtins/declare.def + - declare_internal: add second arg to call to make_local_array_variable; + making_array_special, which indicates we're processing an + assignment like declare a[b]=c. Fixes seg fault resulting from + a being an already-declared local associative array variable in a + function. Ubuntu bash bug 928900. + + 2/14 + ---- + +execute_cmd.c + - execute_command_internal: if redirections into or out of a loop fail, + don't try to free ofifo_list unless saved_fifo is non-zero. It's + only valid if saved_fifo is set + + 2/15 + ---- +{arrayfunc,braces,variables}.c + - last_command_exit_value: make sure it's set before any calls to + report_error, since -e will cause that to exit the shell + +builtins/common.c + - get_job_by_name: call internal_error instead of report_error so this + doesn't exit the shell + + 2/18 + ---- +builtins/evalstring.c + - parse_and_execute: make sure the file descriptor to be redirected to + is 1 before calling cat_file. One fix for bug reported by Dan Douglas + + +parse.y + - read_token_word: don't return NUMBER if a string of all digits + resolves to a number that overflows the bounds of an intmax_t. + Other fix for bug reported by Dan Douglas + + 2/19 + ---- +lib/sh/strtrans.c + - ansicstr: use 0x7f as the boundary for characters that translate + directly from ASCII to unicode (\u and \U escapes) instead of + UCHAR_MAX, since everything >= 0x80 requires more than one byte. + Bug and fix from John Kearney + +builtins/printf.def + - tescape: ditto for printf \u and \U escape sequences + + 2/20 + ---- +lib/sh/unicode.c + - u32toutf8: fix to handle encodings up to six bytes long correctly + (though technically UTF-8 only has characters up to 4 bytes long). + Report and fix from John Kearney + - u32toutf8: first argument is now an unsigned 32-bit quantity, + changed callers (u32cconv) to pass c instead of wc + - u32reset: new function, resets local static state to uninitialized + (locale information, currently) + +locale.c + - call u32reset whenever LC_CTYPE/LC_ALL/LANG is changed to reset the + cached locale information used by u32cconv. From a report from + John Kearney + + 2/21 + ---- +doc/{bash,builtins}.1 + - minor changes from Bjarni Ingi Gislason + +lib/sh/unicode.c + - u32cconv: only assume you can directly call wctomb on the passed + value if __STDC_ISO_10646__ is defined and the value is <= + 0x7fffffff + - stub_charset: return locale as default instead of "ASCII", let + rest of code decide what to do with it + +lib/readline/parens.c + - _rl_enable_paren_matching: make paren matching work in vi insert + mode. Bug report from + + 2/22 + ---- +lib/sh/shquote.c + - sh_backslash_quote: quote tilde in places where it would be + expanded. From a report from John Kearney + + 2/23 + ---- +execute_cmd.c + - execute_pipeline: wrap the discard_unwind_frame call in #ifdef + JOB_CONTROL, since the frame is only created if JOB_CONTROL is + defined. Bug and fix from Doug Kehn + + 2/25 + ---- +error.c + - report_error: make sure last_command_exit_value is non-zero before + we call exit_shell, since the exit trap may reference it. Call + exit_shell with last_command_exit_value to allow exit statuses + other than 1 + +unicode.c + - stub_charset: use local static buffer to hold charset, don't change + value returned by get_locale_var. Based on idea and code from + John Kearney + - u32toutf16: function to convert unsigned 32-bit value (unicode) to + UTF-16. From John Kearney + - u32cconv: call u32toutf16 if __STDC_ISO_10646__ defined and wchar_t + is two bytes, send result to wcstombs, return if not encoding error. + From John Kearney + - u32cconv: return UTF-8 conversion if iconv conversion to local + charset is unsupported + + 3/2 + --- +lib/readline/complete.c + - print_filename: if there is no directory hook, but there is a stat + hook, and we want to append a slash to directories, call the stat + hook before calling path_isdir on the expanded directory name. + Report and pointer to fix from Steve Rago + + 3/3 + --- +builtins/evalstring.c + - parse_and_execute: fix to change of 2/18: make sure the file + descriptor being redirected to is 0 before calling cat_file when + we see something like $(< file). Real fix for bug reported by + Dan Douglas + +subst.c + - parameter_brace_patsub: run the replacement string through quote + removal even if the expansion is within double quotes, because + the parser and string extract functions treat the quotes and + backslashes as special. If they're treated as special, quote + removal should remove them (this is the Posix position and + compatible with ksh93). THIS IS NOT BACKWARDS COMPATIBLE. + + 3/4 + --- +lib/readline/complete.c + - rl_menu_complete: fix to make show-all-if-ambiguous and + menu-complete-display-prefix work together if both are set. Fix + from Sami Pietila + + 3/5 + --- +bashline.c + - dircomplete_expand_relpath: new variable, if non-zero, means that + `shopt -s direxpand' should expand relative pathnames. Zero by + default, not user-settable yet + - bash_directory_completion_hook: if we have a relative pathname that + isn't changed by canonicalization or spell checking after being + appended to $PWD, then don't change what the user typed. Controlled + by dircomplete_expand_relpath + + 3/7 + --- +m4/timespec.m4 + - new macros, cribbed from gnulib and coreutils: find out whether we + have `struct timespec' and what file includes it + +m4/stat-time.m4 + - new macros, cribbed from gnulib and coreutils: find out whether the + mtime/atime/ctime/etctime fields of struct stat are of type + struct timespec, and what the name is + +include/stat-time.h + - new file, cribbed from gnulib, with additions from coreutils: include + the right file to get the struct timespec define, or provide our own + replacement. Provides a bunch of inline functions to turn the + appropriate members of struct stat into `struct timespec' values, + zeroing out the tv_nsec field if necessary + +test.c + - include "stat-time.h" for the nanosecond timestamp resolution stuff + - stat_mtime: new function, returns struct stat and the mod time + normalized into a `struct timespec' for the filename passed as the + first argument + - filecomp: call stat_mtime instead of sh_stat for each filename + argument to get the mtime as a struct timespec + - filecomp: call timespec_cmp instead of using a straight arithmetic + comparison for the -nt and -ot operators, using timespec returned by + stat_mtime. Added functionality requested by by Werner Fink + for systems that can support it + + 3/10 + ---- +include/posixdir.h + - REAL_DIR_ENTRY: remove dependency on _POSIX_SOURCE, only use feature + test macros to decide whether dirent.d_ino is present and usable; + define D_INO_AVAILABLE. Report and fix from Fabrizion Gennari + + - D_FILENO_AVAILABLE: define if we can use dirent.d_fileno + +lib/sh/getcwd.c + - use D_FILENO_AVAILABLE to decide whether or not to compile in + _path_checkino and whether or not to call it. Report and initial + fix from Fabrizion Gennari + +lib/readline/signals.c + - make sure all occurrences of SIGWINCH are protected by #ifdef + +sig.c + - make sure all occurrences of SIGCHLD are protected by #ifdef + +nojobs.c + - make sure SA_RESTART is defined to 0 if the OS doesn't define it + +version.c + - show_shell_version: don't use string literals in printf, use %s. + Has added benefit of removing newline from string to be translated + +trap.c + - queue_sigchld_trap: new function, increments the number of pending + SIGCHLD signals by the argument, which is by convention the number + of children reaped in a call to waitchld() + +trap.h + - queue_sigchld_trap: new extern declaration + +jobs.c + - waitchld: if called from the SIGCHLD signal handler (sigchld > 0), + then call queue_sigchld_trap to avoid running the trap in a signal + handler context. Report and original fix from Siddhesh Poyarekar + + +lib/sh/unicode.c + - u32tocesc: take an unsigned 32-bit quantity and encode it using + ISO C99 string notation (\u/\U) + - u32cconv: call u32tocesc as a fallback instead of u32cchar + - u32cconv: call u32tocesc if iconv cannot convert the character. + Maybe do the same thing if iconv_open fails + - u32reset: call iconv_close on localconv if u32init == 1 + + 3/11 + ---- +config-top.h + - CHECKWINSIZE_DEFAULT: new define, set to initial value of + check_window_size (shopt checkwinsize): 0 for off, 1 for on. + Default is 0 + +{jobs,nojobs}.c + - check_window_size: default initial value to CHECKWINSIZE_DEFAULT + + 3/13 + ---- +doc/bashref.texi + - change text referring to the copying restrictions to that + recommended by the FSF (no Front-Cover Texts and no Back-Cover + Texts) + +lib/readline/doc/{history,rlman,rluserman}.texi + - change text referring to the copying restrictions to that + recommended by the FSF (no Front-Cover Texts and no Back-Cover + Texts) + + 3/15 + ---- +array.c + - LASTREF_START: new macro to set the starting position for an array + traversal to `lastref' if that's valid, and to the start of the array + if not. Used in array_reference, array_insert, array_remove + - array_remove: try to be a little smarter with lastref instead of + unconditionally invalidating it + + 3/16 + ---- +array.c + - array_insert: fix memory leak by deleting element to be added in the + case of an error + + 3/18 + ---- +lib/sh/mbschr.c + - mbschr: don't call mbrlen unless is_basic is false; devolves to a + straight character-by-character run through the string + + 3/19 + ---- +stringlib.c + - substring: use memcpy instead of strncpy, since we know the length + and are going to add our own NUL terminator + + 3/20 + ---- +subst.c + - parameter_brace_expand_rhs: if expand_string_for_rhs returns a quoted + null string (a list with one element for which + QUOTED_NULL(list->word->word) returns true), return the quoted null + and set the flags in the returned word to indicate it. Fixes bug + reported by Mark Edgar + +lib/sh/tmpfile.c + - use random(3) instead of get_random_number to avoid perturbing the + random sequence you get using $RANDOM. Bug report and fix from + Jurij Mihelic + + 3/21 + ---- +config-top.h + - OPTIMIZE_SEQUENTIAL_ARRAY_ASSIGNMENT: define to 1 to optimize + sequential indexed array assignment patterns. Defined to 1 by + default + +array.c + - array_insert: if OPTIMIZE_SEQUENTIAL_ARRAY_ASSIGNMENT is defined, + start the search at lastref (see change from 3/15) + + 3/27 + ---- +print_cmd.c + - debug_print_word_list: new debugging function, prints a word list + preceded by an optional string and using a caller-specified + separator + + 4/1 + --- +command.h + - W_ASSNGLOBAL: new flag, set to indicate declare -g + +execute_cmd.c + - fix_assignment_words: note that we have a -g argument to an assignment + builtin and set the W_ASSNGLOBAL flag in the variable word + +subst.c + - dump_word_flags: print out W_ASSNGLOBAL if present + - do_assignment_internal: only set ASS_MKLOCAL if W_ASSIGNARG is set + and W_ASSNGLOBAL is not. Don't want to create a local variable even + if variable_context is non-zero if ASSNGLOBAL is set. Fixes bug + reported by Bill Gradwohl + + 4/7 + --- +lib/readline/readline.c + - _rl_dispatch_subseq: make the `keyseq-timeout' variable apply to + ESC processing when in vi mode. After hitting ESC, readline will + wait up to _rl_keyseq_timeout*1000 microseconds (if set) for + additional input before dispatching on the ESC and switching to + command/movement mode. Completes timeout work suggested by + ; this prompted by report from Barry Downes + + +lib/sh/shmbchar.c + - sh_mbsnlen: new function, returns the number of (possibly multibyte) + characters in a passed string with a passed length, examining at most + maxlen (third argument) bytes + +externs.h + - sh_mbsnlen: extern declaration for new function + +shell.c + - exit_shell: call maybe_save_shell_history if remember_on_history is + set, not just in interactive shells. That means the history is + saved if history is enabled, regardless of whether or not the shell + is interactive + +doc/{bash.1,bashref.texi} + - TMOUT: fix description to make it explicit that TMOUT is the timeout + period for a complete line of input, not just any input. Fixes + problem reported in Ubuntu bug 957303: + https://bugs.launchpad.net/ubuntu/+source/bash/+bug/957303 + - HISTFILE: document change to write history list to history file in + any shell with history enabled, not just interactive shells. This + seems to be more logical behavior. Suggested by Greg Wooledge + + + 4/12 + ---- +lib/readline/colors.h + - only include stdbool.h if HAVE_STDBOOL_H is defined + - if HAVE_STDBOOL_H is not defined, provide enough definition for the + library to use `bool', `true', and `false' + +lib/readline/parse-colors.[ch] + - don't try to include at all; rely on colors.h to do it + +lib/sh/snprintf.c + - vsnprintf_internal: only treat '0' as a flag to indicate zero padding + if `.' hasn't been encountered ((flags&PF_DOT) == 0); otherwise treat + it as the first digit of a precision specifier. Fixes bug reported + by Petr Sumbera + + 4/15 + ---- +lib/sh/snprintf.c + - vsnprintf_internal: if the '0' and '-' flags both occur, the '0' + flag is ignored -- Posix. Start of a series of fixes based on + tests and patches from Petr Sumbera + - PUT_PLUS: make sure PF_PLUS flag is specified before putting the `+' + - vsnprintf_internal: when '+' is read as a flag, don't set right- + justify flag if the LADJUST (`-') flag has already been supplied + - floating: make sure to output space padding before the `+', zero + padding after + - exponent: make sure to output space padding before the `+', zero + padding after + - exponent: only subtract one from the width for the decimal point + if we're really going to print one + - floating: use presence of PF_PLUS flag to decide whether to account + for the `+' in the padded field width. Ditto for exponent() + + 4/16 + ---- +lib/sh/snprintf.c + - vsnprint_internal: only reduce precision by 1 when processing the `g' + format if it's > 0. A precision of 0 should stay 0; otherwise it + gets set to -1 (NOT_FOUND) and converted to the default + - number, lnumber: if an explicit precision is supplied, turn off the + zero-padding flag and set the pad character back to space + - number, lnumber: only account for a `+' when performing the field + width calculation if the coversion is base 10; we don't add a `+' + for other bases + + 4/18 + ---- +tests/printf3.sub + - try using "perl -e 'print time'" to get the current time in seconds + since the epoch if "date +%s" is not available (solaris 8-10) + + 4/19 + ---- +tests/run-printf + - use cat -v instead of relying on diff -a being available to convert + control characters to ascii and avoid the dreaded "Binary files + /tmp/xx and printf.right differ" + + 4/20 + ---- +lib/sh/strftime.c + - incoporated new version from Aharon Robbins + + 4/22 + ---- +doc/{bash.1,bashref.texi} + - slight change to the description of /dev/tcp and /dev/udp + +subst.c + - match_wpattern: logic fix to the calculation of `simple' (was |=, + needs to be &=). Bug report from Mike Frysinger , + fix from Andreas Schwab + +bashline.c + - bash_filename_stat_hook: add code from bash_directory_completion_hook + that performs pathname canonicalization in the same way that cd and + other builtins will do + + 4/25 + ---- +execute_cmd.c + - execute_pipeline: change the call to move_to_high_fd to make it use + getdtablesize() and to not stomp on existing open file descriptors, + like the fd the shell is using to read a script. Bug report from + Greg Wooledge + + 5/6 + --- +subst.c + - expand_word_internal: case '$': after calling param_expand and + setting had_quoted_null, set TEMP to null. The code that builds the + returned string at the end of the function will take care of making + and returning a quoted null string if there's nothing else in + ISTRING. If there is, the quoted null should just go away. Part of + fix for bug reported by Ruediger Kuhlmann + - expand_word_internal: when processing ISTRING to build return value, + only set W_HASQUOTEDNULL in the returned word flags if the word is + a quoted null string AND had_quoted_null is set. Rest of fix + + 5/9 + --- +variables.c + - bind_variable_internal: if we get an array variable here (implicit + assignment to index 0), call make_array_variable_value, which + dummies up a fake SHELL_VAR * from array[0]. This matters when + we're appending and have to use the current value + - bind_variable_internal: after computing the new value, treat assoc + variables with higher precedence than simple array variables; it + might be that a variable has both attributes set + +arrayfunc.c + - bind_array_var_internal: break code out that handles creating the + new value to be assigned to an array variable index into a new + function, make_array_variable_value. This handles creating a + dummy SHELL_VAR * for implicit array[0] assignment. Fixes bug + reported by Dan Douglas + +arrayfunc.h + - make_array_variable_value: new extern declaration + + 5/19 + ---- +variables.c + - bind_int_variable: if an assignment statement like x=y comes in + from the expression evaluator, and x is an array, handle it like + x[0]=y. Fixes bug reported by Dan Douglas + + 5/24 + ---- + +braces.c + - mkseq: handle possible overflow and break the sequence generating + loop if it occurs. Fixes OpenSUSE bug 763591: + https://bugzilla.novell.com/show_bug.cgi?id=763591 + + 5/25 + ---- +Makefile.in + - LDFLAGS_FOR_BUILD: add to compilation recipes for build tools + buildversion, mksignames, mksyntax + - LDFLAGS_FOR_BUILD: add to compilation recipes for test tools + recho, zecho, printenv, xcase + +builtins/Makefile.in + - LDFLAGS_FOR_BUILD: add to compilation recipes for build tools + gen-helpfiles, psize.aux + +variables.c + - bind_int_variable: if LHS is a simple variable name without an array + reference, but resolves to an array variable, call + bind_array_variable with index 0 to make x=1 equivalent to x[0]=1. + Fixes bug reported by Dan Douglas + + 5/27 + ---- +subst.c + - expand_word_internal: make sure has_dollar_at doesn't get reset before + recursive calls to param_expand or expand_word_internal, since it has + to save state of what came before. Use temp variable and make sure + has_dollar_at is incremented if recursive call processes "$@". + Fixes bug reported by gregrwm and + supplemented by Dan Douglas + +doc/{bash.1,bashref.texi} + - changes to the description of substring expansion inspired by + suggestions from Bill Gradwohl + +doc/bashref.texi + - added substring expansion examples inspired by suggestions from + Bill Gradwohl + +variables.c + - find_shell_variable: search for a variable in the list of shell + contexts, ignore the temporary environment + - find_variable_tempenv: search for a variable in the list of shell + contexts, force search of the temporary environment + - find_variable_notempenv: search for a variable in the list of shell + contexts, don't force search of the temporary environment + +variables.h + - find_shell_variable: extern declaration + - find_variable_tempenv: extern declaration + - find_variable_notempenv: extern declaration + +arrayfunc.c + - bind_array_variable: call find_shell_variable instead of calling + var_lookup directly + +findcmd.c + - search_for_command: call find_variable_tempenv instead of + find_variable_internal directly + - _find_user_command_internal: call find_variable_tempenv instead of + find_variable_internal directly + +builtins/setattr.def + - set_var_attribute: call find_variable_notempenv instead of + find_variable_internal directly + - show_name_attributes: call find_variable_tempenv instead of + find_variable_internal directly + + 6/1 + --- +sig.c + - termsig_handler: don't try to save the shell history on a terminating + signal any more, since it just causes too many problems on Linux + systems using glibc and glibc malloc + +lib/readline/vi_mode.c + - rl_vi_change_to: change to correctly redo `cc', since `c' is not a vi + motion character. From Red Hat bug 813289 + - rl_vi_delete_to: change to correctly redo `dd', since `d' is not a vi + motion character + - rl_vi_yank_to: change to correctly redo `yy', since `y' is not a vi + motion character + + 6/4 + --- +lib/sh/mktime.c + - current versions of VMS do not need to include . Fix from + John E. Malmberg + + 6/5 + --- +lib/sh/eaccess.c + - sh_stat: instead of using a static buffer to do the DEV_FD_PREFIX + translation, use a dynamically-allocated buffer that we keep + resizing. Fixes potential security hole reported by David Leverton + + + 6/5 + --- +braces.c + - expand_seqterm: check errno == ERANGE after calling strtoimax for + rhs and incr. Part of a set of fixes from Scott McMillan + + - expand_seqterm: incr now of type `intmax_t', which changes + arguments to mkseq + - mkseq: a better fix for detecting overflow and underflow since it's + undefined in C and compilers `optimize' out overflow checks. Uses + ADDOVERFLOW and SUBOVERFLOW macros + - mkseq: use sh_imaxabs (new macro) instead of abs() for intmax_t + variables + - mkseq: don't allow incr to be converted to -INTMAX_MIN + - mkseq: make sure that strvec_create isn't called with a size argument + greater than INT_MAX, since it only takes an int + + 6/6 + --- +braces.c + - mkseq: try and be smarter about not overallocating elements in + the return array if the increment is not 1 or -1 + + 6/7 + --- +parse.y + - history_delimiting_chars: if the parser says we're in the middle of + a compound assignment (PST_COMPASSIGN), just return a space to avoid + adding a stray semicolon to the history entry. Fixes bug reported + by "Davide Brini" + + 6/8 + --- +bashline.c + - bash_directory_completion_hook: don't attempt spelling correction + on the directory name unless the direxpand option is set and we are + going to replace the directory name with the corrected one in the + readline line. Suggested by Linda Walsh + +lib/sh/shquote.c + - sh_backslash_quote: now takes a third argument: flags. If non-zero, + tildes are not backslash-escaped. Have to handle both printf %q, + where they should be escaped, and filename completion, where they + should not when used as usernames + +externs.h + - sh_backslash_quote: declaration now takes a third argument + +builtins/printf.def + - printf_builtin: call sh_backslash_quote with 1 as third argument + so tildes get escaped + +{bashline,bracecomp}.c + - call sh_backslash_quote with 0 as third argument so tildes are not + escaped in completed words + +doc/bash.1 + - add `coproc' to the list of reserved words. From a report by + Jens Schweikhardt + + 6/10 + ---- +execute_cmd.c + - line_number_for_err_trap: now global, so parse_and_execute can save + and restore it with unwind-protect + +builtins/evalstring.c + - parse_prologue: save and restore line_number_for_err_trap along + with line_number + - restore_lastcom: new function, unwind-protect to restore + the_printed_command_except_trap + - parse_prologue: use restore_lastcom to save and restore the value + of the_printed_command_except_trap around calls to parse_and_execute + (eval/source/.) + + 6/15 + ---- +lib/readline/complete.c + - complete_fncmp: change filename comparison code to understand + multibyte characters, even when doing case-sensitive or case-mapping + comparisons. Fixes problem reported by Nikolay Shirokovskiy + + + 6/20 + ---- +builtins/mapfile.def + - mapfile: move the line count increment and check for having read + the specified number of lines to the end of the loop to avoid + reading an additional line with zgetline. Fixes bug reported by + Dan Douglas + + 6/21 + ---- + +execute_cmd.c + - execute_pipeline: make sure `lastpipe_flag' is initialized to 0 on + all systems, since it's tested later in the function. Fixes bug + reported by John E. Malmberg + + 6/22 + ---- +mailcheck.c + - file_mod_date_changed: return 0 right away if mailstat() does not + return success. Fixes bug with using uninitialized values reported + by szymon.kalasz@uj.edu.pl + +builtins/set.def + - the `monitor' option is not available when the shell is compiled + without job control, since the underlying `m' flag is not available + +nojobs.c + - job_control: now declared as int variable, initialized to 0, never + modified + +jobs.h + - job_control: extern declaration no longer dependent on JOB_CONTROL + +execute_cmd.c + - execute_pipeline: made necessary changes so `lastpipe' shell option + is now available in all shells, even those compiled without + JOB_CONTROL defined + + 6/23 + ---- +lib/glob/glob.c + - glob_filename: check for interrupts before returning if glob_vector + returns NULL or an error. Bug reported by Serge van den Boom + , fix from Andreas Schwab + - call run_pending_traps after each call to QUIT or test of + interrupt_state, like we do in mainline shell code + - glob_vector: don't call QUIT; in `if (lose)' code block; just free + memory, return NULL, and let callers deal with interrupt_state or + other signals and traps + + 6/25 + ---- +lib/readline/input.c + - rl_read_key: restructure the loop that calls the event hook a little, + so that the hook is called only after rl_gather_tyi returns no input, + and any pending input is returned first. This results in better + efficiency for processing pending input without calling the hook + on every input character as bash-4.1 did. From a report from + Max Horn + + 6/26 + ---- +trap.c + - signal_is_pending: return TRUE if SIG argument has been received and + a trap is waiting to execute + +trap.h + - signal_is_pending: extern declaration + +lib/glob/glob.c + - glob_vector: check for pending SIGINT trap each time through the loop, + just like we check for interrupt_state or terminating_signal, and + set `lose = 1' so we clean up after ourselves and interrupt the + operation before running the trap. This may require a change later, + maybe call run_pending_traps and do that if run_pending_traps returns? + +variables.c + - sv_histtimefmt: set history_comment_character to default (`#') if + it's 0 when we're turning on history timestamps. The history code + uses the history comment character to prefix timestamps, and + leaving it at 0 effectively removes them from the history. From a + report to help-bash by Dennis Williamson + + 6/27 + ---- +lib/readline/signals.c + - rl_maybe_restore_sighandler: new function, sets handler for SIG to + HANDLER->sa_handler only if it's not SIG_IGN. Needs to be called + on same signals set using rl_maybe_set_sighandler, which does not + override an existing SIG_IGN handler (SIGALRM is ok since it does + the check inline; doesn't mess with SIGWINCH) + + 6/30 + ---- +variables.h + - additional defines for the new `nameref' variable attribute + (att_nameref): nameref_p, nameref_cell, var_setref + +variables.c + - find_variable_nameref: resolve SHELL_VAR V through chain of namerefs + - find_variable_last_nameref: resolve variable NAME until last in a + chain of possibly more than one nameref starting at shell_variables + - find_global_variable_last_nameref: resolve variable NAME until last + in a chain of possibly more than one nameref starting at + global_variables + - find_nameref_at_context: resolve SHELL_VAR V through chain of namerefs + in a specific variable context (usually a local variable hash table) + - find_variable_nameref_context: resolve SHELL_VAR V through chain of + namerefs following a chain of varible contexts + - find_variable_last_nameref_context: resolve SHELL_VAR V as in + find_variable_last_context, but return the final nameref instead of + what the final nameref resolves to + - find_variable_tempenv, find_variable_notempenv, find_global_variable, + find_shell_variable, find_variable: modified to follow namerefs + - find_global_variable_noref: look up a global variable without following + any namerefs + - find_variable_noref: look up a shell variable without following any + namerefs + - bind_variable_internal: modify to follow a chain of namerefs in the + global variables table; change to handle assignments to a nameref by + following nameref chain + - bind_variable: modify to follow chain of namerefs when binding to a + local variable + - unbind_variable: changes to unset nameref variables (unsets both + nameref and variable it resolves to) + +subst.c + - parameter_brace_expand_word: change to handle expanding nameref whose + value is x[n] + - parameter_brace_expand_indir: change to expand in ksh93-compatible + way if variable to be indirected is nameref and a simple (non-array) + expansion + - param_expand: change to expand $foo where foo is a nameref whose value + is x[n] + +execute_cmd.c + - execute_for_command: changes to implement ksh93 semantics when index + variable is a nameref + +builtins/setattr.def + - show_var_attributes: change to add `n' to flags list if att_nameref + is set + +builtins/set.def + - unset_builtin: changes to error messages to follow nameref variables + +builtins/declare.def + - document new -n option + - declare_internal: new `-n' and `+n' options + - declare_internal: handle declare -n var[=value] and + declare +n var[=value] for existing and non-existant variables. + Enforce restriction that nameref variables cannot be arrays. + Implement semi-peculiar ksh93 semantics for typeset +n ref=value + + 7/5 + --- +variables.c + - unbind_variable: unset whatever a nameref resolves to, leaving the + nameref variable itself alone + - unbind_nameref: new function, unsets a nameref variable, not the + variable it references + +variables.h + - unbind_nameref: extern declaration + +builtins/set.def + - unset_builtin: modify to add -n option, which calls unbind_nameref + leaving unbind_variable for the usual case. This required slight + changes and additions to the test suite + +doc/{bash.1,bashref.texi} + - document namerefs and typeset/declare/local/unset -n + + 7/13 + ---- +lib/sh/casemod.c + - include shmbchar.h for is_basic and supporting pieces + - sh_casemod: use _to_wupper and _to_wlower to convert wide character + case instead of TOUPPER and TOLOWER. Fixes bug reported by + Dennis Williamson , fix from + Andreas Schwab + - cval: short-circuit and return ascii value if is_basic tests true + - sh_casemod: short-circuit and use non-multibyte case modification + and toggling code if is_basic tests true + +lib/readline/signals.c + - _rl_{block,release}_sigint: remove the code that actually blocks and + releases the signals, since we defer signal handling until calls to + RL_CHECK_SIGNALS() + +lib/readline/{callback,readline,util}.c + - if HAVE_POSIX_SIGSETJMP is defined, use sigsetjmp/siglongjmp without + saving and restoring the signal mask instead of setjmp/longjmp + +lib/readline/rltty.c + - prepare_terminal_settings: don't mess with IXOFF setting if + USE_XON_XOFF defined + +doc/{bash.1,bashref.texi} + - add some text to the description of set -e clarifying its effect + on shell functions and shell function execution. Suggested by + Rainer Blome + +bashline.c + - edit_and_execute_command: increment current_command_line_count before + adding partial line to command history (for command-oriented-history + because of rl_newline at beginning of function), then reset it to 0 + before adding the dummy history entry to make sure the dummy entry + doesn't get added to previous incomplete command. Partial fix for + problem reported by Peng Yu + + 7/24 + ---- +configure.in + - interix: define RECYCLES_PIDS. Based on a report from Michael + Haubenwallner + + 7/26 + ---- +jobs.c + - make_child: call bgp_delete on the newly-created pid unconditionally. + Some systems reuse pids before cycling through an entire set of + CHILD_MAX/_SC_CHILD_MAX unique pids. This is no longer dependent + on RECYCLES_PIDS. Based on a report from Michael Haubenwallner + + +support/shobj-conf + - Mac OS X: drop MACOSX_DEPLOYMENT_TARGET=10.3 from the LDFLAGS. We + can finally kill Panther + + 7/28 + ---- +subst.c + - command_substitute: make sure last_made_pid gets reset if make_child + fails + +execute_cmd.c + - execute_command_internal: case cm_simple: decide whether or not to + wait_for a child if already_making_children is non-zero, indicates + that there is an unwaited-for child. More of fix for bug report + from Michael Haubenwallner + +jobs.c + - make_child: call delete_old_job (new_pid) unconditionally, don't + bother to check whether or not pid wrap occurred. Rest of fix for + bug report from Michael Haubenwallner + + + 7/29 + ---- +shell.c + - subshell_exit: new function, exits the shell (via call to sh_exit()) + after calling any defined exit trap + +externs.h + - subshell_exit: new extern declaration + +execute_cmd.c + - execute_command_internal: make sure to call subshell_exit for + {} group commands executed asynchronously (&). Part of fix for + EXIT trap bug reported by Maarten Billemont + +sig.c + - reset_terminating_signals: make sure to set termsigs_initialized back + to 0, so a subsequent call to initialize_terminating_signals works + right. Rest of fix for bug reported by Maarten Billemont + + +{execute_cmd,general,jobs,mailcheck,mksyntax,test}.c +builtins/{cd,fc,pushd,ulimit}.def +lib/malloc/getpagesize.h +lib/sh/{clktck,fpurge,inet_aton,mailstat,oslib,pathcanon,pathphys,spell,strerror}.c + - make inclusion of dependent on HAVE_SYS_PARAM_H + consistently + + 8/6 + --- +lib/readline/histexpand.c + - history_expand_internal: now takes an additional argument saying + whether the history expansion occurs within a quoted string, set to + the open quote character + - history_expand_internal: use new argument instead of checking prev + char and initializing quoted_search_delimiter, pass qc directly to + get_history_event, where it allows a matching quote to terminate a + string defining an event + - history_expand: change single-quote handling code so that if + history_quotes_inhibit_expansion is 0, single quotes are treated + like double quotes + - history_expand: change call to history_expand_internal to pass new + argument of `"' if double-quoted string, `'' if single-quoted string; + this lets history_expand decide what is a quoted string and what + is not + + 8/7 + --- +configure.in + - AC_CANONICAL_BUILD: invoke for later use + +lib/readline/macro.c + - _rl_prev_macro_key: new function, inverse of _rl_next_macro_key: + backs up the index into the current macro by 1 + +lib/readline/rlprivate.h + - _rl_prev_macro_key: extern declaration + + +lib/readline/readline.c + - _rl_dispatch_subseq, _rl_subseq_result: don't call _rl_unget_char + if we're currently reading from a macro; call _rl_prev_macro_key + instead. Fixes bug reported by Clark Wang + + 8/13 + ---- +builtins/evalstring.c + - evalstring(): new function, wrapper around parse_and_execute. + make sure we handle cases where parse_and_execute can call `return' + and short-circuit without cleaning up properly. We call + parse_and_execute_cleanup() then jump to the previous-saved return + location + +builtins/common.h + - extern declaration for evalstring() + +builtins/eval.def + - eval_builtin: make sure we handle `eval " ... return"' in contexts + where `return' is valid by calling evalstring(). Fixes bug with + `eval return' in sourced files reported by Clark Wang + + +trap.c + - run_pending_traps: call evalstring instead of parse_and_execute. + XXX - still needs to handle saving and restoring token state in the + presence of `return'; could use unwind_protects for that + +builtins/mapfile.def + - run_callback: call evalstring instead of parse_and_execute + + 8/15 + ---- +bashline.c + - bash_filename_stat_hook: make sure we don't free local_dirname + before using it to canonicalize any expanded filename. Make sure + it always points to *dirname and only free it if we're replacing + it. + +lib/readline/complete.c + - append_to_match: make sure we call rl_filename_stat_hook with + newly-allocated memory to avoid problems with freeing it twice + + 8/17 + ---- +variables.c,config-top.h + - if ARRAY_EXPORT is defined to 1 when variables.c is compiled, the + code that allows indexed arrays to be exported is enabled and + included + + 8/19 + ---- +shell.c + - call start_debugger from main() only if dollar_vars[1] != 0 (close + enough to a non-interactive shell, since we can be interactive with + -i while running a shell script). Fixes oddity reported by + Techlive Zheng + + 8/20 + ---- +arrayfunc.c + - quote_array_assignment_chars: don't bother quoting if the word has + not been marked as an assignment (W_ASSIGNMENT) + - quote_array_assignment_chars: turn on W_NOGLOB in the word flags + so assignment statements don't undergo globbing. Partial fix for + problems reported by Dan Douglas + + 8/21 + ---- +command.h + - W_NOBRACE: new word flag that means to inhibit brace expansion + +subst.c + - brace_expand_word_list: suppress brace expansion for words with + W_NOBRACE flag + + 8/22 + ---- +builtins/read.def + - read_builtin: don't call dequote_string on what we've read, even if + we saw an escape character, unless (input_string && *input_string). + We may have escaped an IFS whitespace character. Fixes seg fault + reported by + +execute_cmd.c + - execute_command_internal: set the_printed_command_except trap when + about to execute a ( ... ) user subshell. For now, set it only if + ERR is trapped; can relax that later. Fixes bug reported by + Mike Frysinger + + 8/23 + ---- +jobs.c + - remove references to first_pid and pid_wrap, since we're not using + them for anything anymore + + 8/24 + ---- +subst.c + - changes for W_NOBRACE everywhere appropriate: so it can be displayed + for debugging, and passed out of expand_word_internal + +doc/{bash.1,bashref.texi} + - small changes to make it clearer that the = and == operators are + equivalent, and will cause pattern matching when used with [[. + From a question from Michal Soltys + +doc/bashref.texi + - some small formatting changes from Karl Berry + + 8/27 + ---- +lib/readline/doc/{history,rlman,rluserman}.texi + - some small formatting changes from Karl Berry + +arrayfunc.c + - assign_array_element_internal, assign_compound_array_list, + unbind_array_element, array_value_internal: changes to make + assignment statements to negative indices (a[-1]=2) and unsetting + array elements using negative indices (unset 'a[-1]') work. + From suggestions by Dennis Williamson + and Chris F. A. Johnson + +subst.c + - array_length_reference: changes to make length references to array + elements using negative indices (${#a[-1]}) work + + 8/28 + ---- +doc/{bash.1,bashref.texi} + - document new treatment of negative indices to indexed arrays when + assigning, referencing, calculating length, and unsetting + + 8/29 + ---- +shell.c + - show_shell_usage: add -l to list of shell invocation options (short + for --login). From Red Hat bug 852469 + +configure.ac + - renamed from configure.in, as latest autoconf versions want. Patches + Stefano Lattarini + +MANIFEST,Makefile.in,doc/bashref.texi,support/mkconffiles + - configure.in -> configure.ac + + 9/1 + --- + +parse.y + - read_token_word: allow words like {array[ind]} to be valid redirection + words for constructs like {x} + +lib/readline/display.c + - update_line: if the first difference between the old and new lines + is completely before any invisible characters in the prompt, we + should not adjust _rl_last_c_pos, since it's before any invisible + characters. Fixed in two places + - prompt_modechar: return a character indicating the editing mode: + emacs (@), vi command (:), or vi insert (+) + - _rl_reset_prompt: new function, just calls rl_expand_prompt. Will be + inlined, placeholder for more changes + - expand_prompt: if show-mode-in-prompt is enabled, add a character to + the front of the prompt indicating the editing mode, adjusting the + various variables as appropriate to keep track of the number of + visible characters and number of screen positions + +lib/readline/bind.c + - show-mode-in-prompt: new bindable boolean variable, shadowed by + _rl_show_mode_in_prompt variable + - hack_special_boolean_var: call _rl_reset_prompt when toggling or + setting show-mode-in-prompt + +lib/readline/readline.c + - readline_internal_setup: make sure the correct vi mode keymap is set + before expanding the prompt string for the first time + +lib/readline/misc.c + - rl_emacs_editing_mode: make sure to call _rl_reset_prompt if we're + showing the editing mode in the prompt + +lib/readline/rlprivate.h + - _rl_reset_prompt, _rl_show_mode_in_prompt: extern declarations + +lib/readline/vi_mode.c + - rl_vi_insertion_mode: call _rl_reset_prompt + - rl_vi_movement_mode: call _rl_reset_prompt. Finishes changes for + showing mode in prompt string, originally requested by Miroslav + Koskar and most recently by Jordan Michael + Ziegler + +doc/bash.1,lib/readline/doc/{readline.3,rluser.texi} + - document new show-mode-in-prompt variable, off by default + + 9/3 + --- + +jobs.c + - set_childmax: new function, external mechanism for other parts of + the shell to set js.c_childmax, the number of saved exited child + statuses to remember +jobs.h + - set_childmax: extern declaration + +variables.c + - CHILD_MAX: new special variable, with sv_childmax function to + run when it changes. Setting CHILD_MAX to a value greater than + zero but less than some maximum (currently 8192) sets the number of + exited child statuses to remember. set_childmax (jobs.c) ensures + that the number does not drop below the posix-mandated minimum + (CHILD_MAX) + +doc/{bash.1,bashref.texi} + - CHILD_MAX: document new meaning and action when variable is set + + 9/5 + --- +redir.c + - redir_varassign: call stupidly_hack_special_variables after + assigning fd number to specified variable, so we can use constructs + like {BASH_XTRACEFD}>foo. Suggested by Pierre Gaston + + + 9/8 + --- +expr.c + - readtok: invalidate previous contents of `curlval' before freeing + and reallocating tokstr (which, chances are, will get the same + pointer as before and render curlval inconsistent). Fixes other + bug reported by Dan Douglas + + 9/9 + --- +lib/readline/complete.c + - rl_username_completion_function: protect call to setpwent() with + #ifdef (HAVE_GETPWENT)/#endif. Fixes bug reported by + Gerd Hofmann + +lib/readline/display.c + - rl_message: second and subsequent calls to rl_message can result in + local_prompt being overwritten with new values (e.g., from the + successive calls displaying the incremental search string). Need + to free before overwriting if it's not the same as the value saved + in saved_local_prompt. Fixes memory leak reported by + Wouter Vermaelen + +lib/readline/{terminal.c,rlprivate.h} + - move CUSTOM_REDISPLAY_FUNC and CUSTOM_INPUT_FUNC defines from + terminal.c to rlprivate.h so other files can use them + +expr.c + - expr_streval: if noeval is non-zero, just return 0 right away, + short-circuiting evaluation completely. readtok will leave curtok + set correctly without re-entering the evaluator at all. Rest of + fix for bug reported by Dan Douglas + + 9/11 + ---- + +parse.y + - parse_comsub: make sure the `reserved word ok in this context' flag + is preserved after we read `do' followed by whitespace. Fixes bug + reported by Benoit Vaugon + + 9/13 + ---- +configure.ac,config.h.in + - enable-direxpand-default: new configure option, turns the `direxpand' + shell option on by default + +bashline.c + - dircomplete_expand, dircomplete_expand_relpath: initialize to 1 if + DIRCOMPLETE_EXPAND_DEFAULT is defined and non-zero + +doc/bashref.texi + - enable-direxpand-default: document new configure option + + 9/14 + ---- +shell.c + - --protected: make option valid only when wordexp is compiled into + the shell. Fix from Roman Rakus + +configure.ac + - HP NonStop (*-nsk*): compile --without-bash-malloc. Change from + Joachim Schmitz + + 9/16 + ---- +subst.c,execute_cmd.c,lib/glob/sm_loop.c,lib/sh/shquote.c + - minor code cleanups from Joachim Schmitz + +lib/readline/colors.h + - workaround for HP NonStop compiler issue with from + Joachim Schmitz + + 9/17 + ---- +builtins/printf.def + - printf_builtin: handle localtime returning NULL, as can happen when + encountering overflow. Bug report and initial fix from + Eduardo A. Bustamante López + +doc/{bash.1,bashref.texi} + - emphasize that brace expansion using character ranges ({a..c}) acts + as if the C locale were in use. Prompted by message from + Marcel Giannelia + + 9/20 + ---- +lib/sh/wcsnwidth.c + - wcsnwidth: new function, variant of wcwidth, returns the number of + wide characters from a string that will be displayed to not exceed + a specified max column position + + 9/21 + ---- +builtins/help.def + - show_builtin_command_help: break code that displays the short-doc + for each builtin in two columns into a new function: dispcolumn + - wdispcolumn: multibyte-char version of dispcolumn; uses wide + chars and printf "%ls" format. Fixes problem reported by + Nguy�n Thái Ng�c Duy + + 9/22 + ---- +execute_cmd.c + - execute_disk_command: before running the command-not-found hook, + call kill_current_pipeline() to make sure we don't add processes + to an existing pipeline or wait for processes erroneously + + 9/23 + ---- +lib/readline/input.c + - rl_input_available_hook: new hook function, called from + _rl_input_available (or _rl_input_queued) to return whether or not + input is available wherever the input source is + +lib/readline/doc/rltech.texi + - rl_input_available_hook: document + + 9/27 + ---- +lib/glob/sm_loop.c: + - GMATCH: after one or more `*', an instance of ?(x) can match zero or + 1 times (unlike ?, which has to match one character). The old code + failed if it didn't match at least once. Fixes `a*?(x)' bug. + - GMATCH: if we hit the end of the search string, but not the end of + the pattern, and the rest of the pattern is something that can + match the NUL at the end of the search string, we should successfully + match. Fixes `a*!(x)' bug reported by + + 10/2 + ---- +command.h + - add c_lock member to coproc structure for future use to tell who is + manipulating it + +execute_cmd.c + - execute_coproc: block SIGCHLD while parent is forking coproc + process and adding pid to sh_coproc struct to avoid race condition + where child is reaped before the pid is assigned and the coproc is + never marked as having died. Fixes race condition identified by + Davide Baldini + - add assignments to c_lock member of struct coproc in various + functions that manipulate it; was used to identify race condition + - coproc_pidchk: don't call coproc_dispose to avoid using malloc and + other functions in a signal handler context + - coproc_dispose: call BLOCK_SIGNAL/UNBLOCK_SIGNAL for SIGCHLD while + manipulating the sh_coproc struct + + 10/6 + ---- +lib/readline/complete.c + - rl_display_match_list: if printing completions horizontally, don't + bother with spacing calculations if limit == 1, which means we are + printing one completion per line no matter what. Fixes bug + reported by David Kaasen + + 10/7 + ---- +builtins/declare.def + - declare_internal: add error checking for nameref attribute and + variable assignments: self-references, attempts to make an array + variable a nameref + +subst.c + - parameter_brace_expand: handle parameter_brace_expand_word returning + &expand_param_fatal or &expand_param_error and return the appropriate + error value + - parameter_brace_expand_word: if a nameref variable's value is not a + valid identifier, return an error + - param_expand: if a nameref variable's value is not a valid identifier, + return an error + +test.c + - unary_operator: add new -R variable, returns true if variable is set + and has the nameref attribute. From ksh93 + +builtins/test.def + - add -R to description of conditional commands for help test + +doc/{bash.1,bashref.texi} + - document new -R unary conditional operator + + 10/13 + ----- +trap.c + - check_signals_and_traps: new function, convenience function for the + rest of the shell to check for pending terminating and interrupt + signals, and to check for and process any pending traps + - any_signals_trapped: new function, returns non-zero if any signals + are trapped and -1 if not + +trap.h + - extern declaration for check_signals_and_traps + +bashline.c + - bashline_reset: make sure we reset the event hook + - bash_event_hook: call check_signals_and_traps instead of just + checking for terminating signals so we can run pending traps and + react to interrupts, and reset the event hook when we're done + + + 10/14 + ----- +trap.c + - trap_handler: if executing in a readline signal handler context, + call bashline_set_event_hook to install bash_event_hook to process + the signal (if bash cares about it) + +sig.c + - sigint_sighandler: call bashline_set_event_hook to set the event + hook if we're executing in a readline signal handler context + +lib/readline/input.c + - rl_getc: call RL_CHECK_SIGNALS if read returns -1/EINTR and the caught + signal is SIGINT or SIGQUIT rather than waiting until the next time + around the loop + - rl_getc: call rl_event_hook after calling RL_CHECK_SIGNALS to allow + an application signal handler to set the event hook in its own + signal handler (e.g., like bash trap_handler or sigint_sighandler) + + +parse.y + - yy_readline_get: don't set interrupt_immediately before we call + readline(). Inspired by report from lanshun zhou + + +input.c + - getc_with_restart: add call to run_pending_traps after call to + CHECK_TERMSIG + +lib/sh/zread.c + - zread: call check_signals_and_traps if read() returns -1/EINTR + instead of just ignoring the EINTR and deferring handling any + signal that generated it + +builtins/mapfile.def + - mapfile: don't set interrupt_immediately before calling zgetline() + (which uses zread internally) + +builtins/read.def + - read_builtin: don't set interrupt_immediately before calling zread + (moved code around so that it was only being set right around calls + to zread to avoid signal handler conflicts). Inspired by report + from lanshun zhou + - edit_line: don't set interrupt_immediately around call to readline() + - include shmbutil.h + - read_builtin: don't call read_mbchar unless is_basic(c) returns + false for the character we just read + + 10/15 + ----- +sig.c + - throw_to_top_level: if interrupt_state is non-zero, make sure that + last_command_exit_value reflects 128+SIGINT if it's not already + greater than 128 + + 10/20 + ----- +builtins/wait.def + - WAIT_RETURN: set wait_signal_received back to 0 for the potential + next call to wait + +quit.h + - CHECK_WAIT_INTR: macro to check whether trap_handler handled a + signal and set wait_signal_received; longjmp to wait_intr_buf in + that case + +jobs.c + - wait_for, waitchld: call CHECK_WAIT_INTR at the same places we call + CHECK_TERMSIG to check for terminating signals + - wait_sigint_handler: don't longjmp out of the wait builtin unless + interrupt_immediately is set; otherwise just SIGRETURN from the + handler + - wait_sigint_handler: if interrupt_immediately not set, but we are + executing in the wait builtin and SIGINT is not trapped, treat it + as a `normally received' SIGINT: restore the signal handler and + send SIGINT to ourselves + - waitchld: when in posix mode and running SIGCHLD traps, don't longjmp + to wait_intr_buf (and let wait be interrupted) if we're running from + a signal handler. Wait for CHECK_WAIT_INTR to do the longjmp. + run_pending_traps will run the SIGCHLD trap later + +nojobs.c + - reap_zombie_children, wait_for_single_pid, wait_for: call + CHECK_WAIT_INTR where we call CHECK_TERMSIG + - wait_sigint_handler: don't longjmp out of the wait builtin unless + interrupt_immediately is set; otherwise just SIGRETURN from the + handler + +trap.c + - trap_handler: make sure wait_signal_received is set if the wait + builtin is executing, and only longjmp if interrupt_immediately is + set. This whole set of fixes was prompted by report from + lanshun zhou + + 10/24 + ----- +lib/glob/glob.c + - glob_filename: only check directory_name for globbing chars if + it's of non-zero length + +lib/sh/strchrnul.c + - new simpler implementation + +subst.c + - command_substitute: call set_shellopts after turning off errexit + in subshells so it's reflected in $SHELLOPTS + + 11/7 + ---- +builtins/evalstring.c + - parse_and_execute: treat ERREXIT case like reader_loop does: set + variable_context to 0 before longjmping back to top_level. Don't + run the unwind-protect context to avoid side effects from popping + function contexts. Part of fix for problem reported by Nikolai + Kondrashov + +execute_cmd.c + - execute_simple_command: call unlink_fifo_list only if this is the + last element of a pipeline (or not in a pipeline), rather than for + every child. Fixes difference in behavior between /dev/fd and + FIFOs reported by Zev Weiss + - execute_null_command: do the same thing in the parent branch after + make_child + + 11/14 + ----- +subst.c + - parameter_brace_expand: a variable is null if it's special ($@, $*), + the expansion occurs within double quotes, and the expansion turns + into a quoted null. Fixes debian bug 692447 reported by + Matrosov Dmitriy + +jobs.c + - run_sigchld_trap: make sure `running_trap' sentinel is set + appropriately + - waitchld: only run the sigchld trap if we're not in a signal + handler, not running a trap, and executing the wait builtin. + Otherwise, queue for later handling. We still run one instance + of the trap handler per exited child. Bulk of fix for bug + reported by Elliott Forney + +trap.c + - queue_sigchld_trap: set catch_flag so run_pending_traps notices, + and set trapped_signal_received for completeness. Rest of fix + for bug reported by Elliott Forney + +lib/malloc/malloc.c + - block_signals: renamed to _malloc_block_signals, made public + - unblock_signals: renamed to _malloc_unblock_signals, made public + +lib/malloc/imalloc.h + - extern declarations for _malloc_{un,}block_signals + +lib/malloc/table.c + - mregister_alloc, mregister_free: block signals around table + manipulation + + 11/15 + ----- +trap.c + - run_pending_traps: set SIG_INPROGRESS flag around calls to + run_sigchld_handler so other parts of the shell know that the + SIGCHLD trap handler is executing + - run_pending_traps: if we get a situation where we are looking at + running a SIGCHLD trap but the trap string is IMPOSSIBLE_TRAP_HANDLER + and the SIG_INPROGRESS flag is set, just skip it. This is possible + if run_pending_traps is called from a SIGCHLD trap handler run by + run_sigchld_trap + +doc/bash.1,lib/readline/doc/{rluser.texi,readline.3} + - corrected description of the effect of `set history-size 0'. Report + from Vesa-Matti J Kari + +include/stdc.h + - CPP_STRING: new define, replaces __STRING + +lib/malloc/{malloc.c,imalloc.h} + - replace __STRING with CPP_STRING + + 11/16 + ----- +lib/readline/bind.c + - sv_histsize: if argument evaluates to a value < 0, unstifle the + history + + 11/22 + ----- +redir.c + - do_redirection_internal: if we have REDIR_VARASSIGN set in the + redirection flags and we set up `redirector' using fcntl or dup2, + don't add a redirect to make sure it stays open. Let the + script programmer manage the file handle. Fixes bug reported by + Sam Liddicott + + 11/24 + ----- +jobs.c + - wait_for_any_job: new function, waits for an unspecified background + job to exit and returns its exit status. Returns -1 on no background + jobs or no children or other errors. Calls wait_for with new + sentinel value ANY_PID + - wait_for: changes to handle argument of ANY_PID: don't look up or + try to modify the child struct, only go through the wait loop once. + Return -1 if waitpid returns no children + +jobs.h + - ANY_PID: new define + +builtins/wait.def + - new option: -n. Means to wait for the next job and return its exit + status. Returns 127 if there are no background jobs (or no + children). Feature most recently requested by Elliott Forney + + +doc/{bash.1,bashref.texi} + - document new `wait -n' option + +execute_cmd.c + - execute_command_internal: save make_command_string () result in a + temp variable before calling savestring() on it; avoids evaluating + make_command_string() result twice. Fix from John E. Malmberg + + + 11/28 + ----- + +builtins/declare.def + - declare_internal: if an array variable is declared using `declare -a' + or `declare -A', but not assigned a value, set the `invisible' + attribute so the variable does not show up as set. Fix for bug + about variable initialization reported by Tim Friske + +builtins/{mapfile,read}.def + - after calling find_or_make_array_variable, make sure the invisible + flag is turned off, in case the variable was declared previously + using `declare -a' or `declare -A'. Side effect of above change to + declare_internal + +subst.c + - shell_expand_word_list: handle the W_ASSNGLOBAL flag and put -g into + the list of options passed to make_internal_declare as appropriate. + Fix for bug reported by Tim Friske + + 11/30 + ----- +test.c + - unary_op: make sure -v and -n check that the variable is not marked + as invisible before calling var_isset. Fix for bug reported by Tim + Friske + + 12/2 + ---- +subst.c + - process_substitute: turn off the `expanding_redir' flag, which + controls whether or not variables.c:find_variable_internal uses the + temporary environment to find variables. We want to use the + temp environment, since we don't have to worry about order of + evaluation in a subshell. Fixes bug reported by Andrey Borzenkov + + + 12/4 + ---- +lib/glob/glob.c + - glob_filename: changes to avoid null filenames and multiple entries + returned for patterns like **/** (globstar enabled). Fixes bug + reported by Ulf Magnusson + + 12/10 + ----- +lib/glob/glob.c + - glob_filename: finish up a series of changes to make globstar-style + globbing more efficient, avoid more duplicate filenames, and be more + compatible with other shells that implement it + o collapse a sequence of **/**/** to one ** + o note when the directory name is all ** or ends in ** so we + can treat it specially when the filename is ** + All inspired by report from Andrey Borzenkov + +lib/sh/zread.c + - zreadn: new function, like zread, but takes an additional argument + saying how many bytes to read into the local buffer. Can be used to + implement `read -N' without so many one-byte calls to zreadc. Code + from Mike Frysinger + + 12/12 + ----- +lib/glob/sm_loop.c + - PATSCAN (glob_patscan): if passed string already points to end of + pattern, return NULL immediately. Fixes problem with + extglob_skipname reported by Raphaël Droz + + 12/13 + ----- +execute_cmd.c + - execute_coproc: handle the command's exit status being inverted + (an oversight). Fixes bug reported by DJ Mills + and Andreas Schwab + + 12/14 + ----- +lib/readline/readline.c + - bind_arrow_keys_internal: add MINGW key bindings for Home, End, + Delete, and Insert keys. Fix from Pierre Muller + + +builtins/printf.def + - printf_builtin: '%()T' conversion: if there is no argument supplied, + behave as if -1 had been supplied (current time). ksh93-like feature + suggested by Clark Wang + +doc/{bash.1,bashref.texi} + - document new printf %()T default argument behavior + + 12/15 + ----- +lib/readline/display.c + - displaying_prompt_first_line: new variable, indicates whether or + not the first line of output is displaying the prompt. Always true + in normal mode, sometimes false in horizontal scrolling mode + - rl_redisplay: set displaying_prompt_first_line to true unless we + are in horizontal mode; set to false in horizontal mode if the left + margin of the displayed line is greater than the end of the prompt + string + - rl_redisplay: when in horizontal scroll mode, don't adjust + _rl_last_c_pos by the wrap offset unless the line is displaying + a prompt containing invisible chars + - update line: don't adjust _rl_last_c_pos by the wrap offset unless + the line is displaying a prompt containing invisible chars + - update_line: if shrinking the line by reducing the number of + displayed characters, but we have already moved the cursor to the + beginning of the line where the first difference starts, don't + try to delete characters + +builtins/read.def + - unbuffered_read: set to 2 if invoked as `read -N' + - if unbuffered_read is set to 2, compute the number of chars we + need to read and read that many with zreadn. Posix mode still + uses zreadintr. Code from Mike Frysinger + +doc/{bash.1,bashref.texi} + - read: make it clear that if read times out, it saves any input + read to that point into the variable arguments. Report from + Fiedler Roman + +subst.c + - command_substitute: change direct assignment of exit_immediately_on_error + to use change_flag ('e', FLAG_OFF) instead + +flags.c + - use errexit_flag as the variable modified by changes to the -e + option, reflect those changes to exit_immediately_on_error + +execute_cmd.c + - execute_builtin: new global variable, builtin_ignoring_errexit, set + to 0 by default and set to 1 if eval/source/command executing in a + context where -e should be ignored + - execute_builtin: set exit_immediately_on_error to errextit_flag + after executing eval/source/command in a context where -e should + be ignored + +flags.c + - if builtin_ignoring_errexit is set, changes to errexit_flag are + not reflected in the setting of exit_immediately_on_error. Fixes + bug reported by Robert Schiele + + 12/23 + ----- +include/posixjmp.h + - setjmp_nosigs: new define, call setjmp in such a way that it will + not manipulate the signal mask + +{expr,test,trap}.c + - setjmp_nosigs: call instead of setjmp; don't need to manipulate + signal mask + +builtins/read.def + - read_builtin: setjmp_nosigs: call instead of setjmp; don't need + to manipulate signal mask + +builtins/evalstring.c: + - parse_and_execute: setjmp_nosigs: call instead of setjmp; don't need + to manipulate signal mask + - parse_string: setjmp_nosigs: call instead of setjmp; don't need + to manipulate signal mask + - parse_and_execute: save and restore the signal mask if we get a + longjmp that doesn't cause us to return or exit (case DISCARD) + + 12/24 + ----- +general.c + - bash_tilde_expand: only set interrupt_immediately if there are no + signals trapped; we want to jump to top level if interrupted but + not run any trap commands + + 12/25 + ----- +jobs.c + - run_sigchld_trap: no longer set interrupt_immediately before calling + parse_and_execute, even if this is no longer run in a signal handler + context + +input.c + - getc_with_restart: add call to QUIT instead of CHECK_TERMSIG + +parse.y + - yy_stream_get: now that getc_with_restart calls QUIT, don't need to + set interrupt_immediately (already had call to run_pending_traps) + +execute_cmd.c + - execute_subshell_builtin_or_function,execute_function,execute_in_subshell: + setjmp_nosigs: call instead of setjmp when saving return_catch; don't + need to manipulate signal mask + - execute_subshell_builtin_or_function,execute_in_subshell: + setjmp_nosigs: call instead of setjmp where appropriate when saving + top_level; don't need to manipulate signal mask if we're going to + exit right away + +subst.c + - command_substitute: setjmp_nosigs: call instead of setjmp when saving + return_catch; don't need to manipulate signal mask + - command_substitute: setjmp_nosigs: call instead of setjmp where + appropriate when saving top_level; don't need to manipulate signal + mask if we're going to exit right away + +trap.c + - run_exit_trap: setjmp_nosigs: call instead of setjmp when saving + return_catch; don't need to manipulate signal mask + - run_exit_trap: setjmp_nosigs: call instead of setjmp where + appropriate when saving top_level; don't need to manipulate signal + mask if we're going to exit right away + - _run_trap_internal: setjmp_nosigs: call instead of setjmp when saving + return_catch; don't need to manipulate signal mask + +builtins/evalfile.c + - _evalfile: setjmp_nosigs: call instead of setjmp when saving + return_catch; don't need to manipulate signal mask + +builtins/evalstring.c + - evalstring: setjmp_nosigs: call instead of setjmp when saving + return_catch; don't need to manipulate signal mask + +shell.c + - main: setjmp_nosigs: call instead of setjmp where appropriate when + saving top_level; don't need to manipulate signal mask if we're + going to exit right away + - run_one_command: setjmp_nosigs: call instead of setjmp where + appropriate when saving top_level; don't need to manipulate signal + mask if we're going to exit right away + - run_wordexp: setjmp_nosigs: call instead of setjmp where + appropriate when saving top_level; don't need to manipulate signal + mask if we're going to exit right away + +eval.c + - reader_loop: save and restore the signal mask if we get a longjmp + that doesn't cause us to return or exit (case DISCARD) + + 12/26 + ----- +parse.y + - shell_input_line_{index,size,len}: now of type size_t; in some cases + the unsigned property makes a difference + - STRING_SAVER: saved_line_{size,index} now of type size_t + - shell_getc: don't allow shell_input_line to grow larger than SIZE_MAX; + lines longer than that are truncated until read sees a newline; + addresses theoretical buffer overflow described by Paul Eggert + + - set_line_mbstate: size_t changes like shell_getc + - shell_getc: if shell_input_line is larger than 32K, free it and + start over to avoid large memory allocations sticking around + +variables.c + - bind_global_variable: new function, binds value to a variable in + the global shell_variables table + +variables.h + - bind_global_variable: new extern declaration + +builtins/declare.def + - declare_internal: if -g given with name=value, but variable is not + found in the global variable table, make sure to call + bind_global_variable so the variable is created and modified at + global scope. Fixes a bug where declare -g x=y could modify `x' + at a previous function scope + +command.h + - W_ASSIGNARRAY: new word flag, compound indexed array assignment + +subst.h + - ASS_MKGLOBAL: new assignment flag, forcing global assignment even in + a function context, used by declare -g + +execute_cmd.c + - fix_assignment_words: set W_ASSIGNARRAY flag if -a option given to + declaration builtin + +subst.c + - do_assignment_internal: explicitly handle case where we are + executing in a function and we want to create a global array or + assoc variable + - shell_expand_word_list: call make_internal_declare if -a option + given to declaration builtin (W_ASSIGNARRAY); handle -g option with + it (W_ASSNGLOBAL). Fixes inconsistency noticed by Vicente Couce + Diaz , where declare -ag foo=(bar) could modify + array variable foo at previous function scope, not global scope + + 12/27 + ----- +bashline.c + - Minix needs the third argument to tputs to be a void funtion taking + an int argument, not an int-returning function. Fix from + John E. Malmberg as part of VMS bash port + + 12/29 + ----- +configure.ac,version.c,patchlevel.h + - bash-4.3-devel: new version, new shell compatibility level (43) + +subst.c + - parameter_brace_patsub: put the bash-4.2 code back in from the + change of 3/3 that runs the replacement string through quote + removal, make it dependent on shell_compatibility_level <= 42 + +builtins/shopt.def + - compat42: new shopt option + - set_compatibility_level: change logic to set and unset various + compat variables and shell_compatibility_level + +COMPAT + - new documentation for bash-4.3 compatibility changes + +doc/{bash.1,bashref.texi} + - compat42: document new shopt option + +builtins/shopt.def + - set_compatibility_opts: new function, sets the various shopt + compat variables based on the value of shell_compatibility_level + +builtins/common.h + - set_compatibility_opts: new extern declaration + +variables.c + - BASH_COMPAT: new special variable; sets the shell compatibility + level. Accepts values in decimal (4.2) or integer (42) form; + Unsetting variable, setting it to empty string, or setting it to + out-of-range value sets the shell's compatibility level to the + default for the current version. Valid values are 3.1/31 through + the current version + - sv_shcompat: new function implementing logic for BASH_COMPAT + +variables.h + - sv_shcompat: new extern declaration + +doc/{bash.1,bashref.texi} + - BASH_COMPAT: description of new variable + +lib/readline/complete.c + - _rl_colored_stats: default back to 0 for 4.3 release branch + + 1/5/2013 + -------- +quit.h + - remove spurious call to itrace in CHECK_WAIT_INTR + +bashline.c + - bash_event_hook: if we're going to jump to top_level, make sure we + clean up after readline() by calling rl_cleanup_after_signal(). + Fixes bug reported against devel branch by Raphaël Droz + + - bash_event_hook: reset the event hook before checking for signals + or traps in case we longjmp + +doc/{bash.1,bashref.texi} + - small additions to the set -e section to make it more clear that + contexts where -e is ignored extend to compound commands as well + as shell functions + +lib/readline/readline.h + - rl_signal_event_hook: new extern declaration + +lib/readline/input.c + - rl_signal_event_hook: new variable, hook function to call when a + function (currently just read(2)) is interrupted by a signal and + not restarted + - rl_getc: call rl_signal_event_hook instead of rl_event_hook + +lib/readline/doc/rltech.texi + - rl_signal_event_hook: document new function + +bashline.c + - changes to set rl_signal_event_hook instead of rl_event_hook + +lib/readline/readline.h + - change readline version numbers to 6.3 + + 1/6 + --- +doc/{bash.1,bashref.texi} + - a couple of changes to the descriptions of the ERR trap and its + effects based on a message from Rob Nagler + + 1/9 + --- +expr.c + - expassign: invalidate curlval before freeing and NULLing tokstr to + avoid aliasing issues. Fixes bug reported by Eduardo A. Bustamante + López and Dan Douglas + +braces.c + - array_concat: don't be so aggressive in trying to short-circuit. We + can only short-circuit if we have a single-element array where the + element is an empty string (array[0] == "" array[1] = 0x0). Existing + practice requires us to replicate arrays and prefix or append empty + strings. Fixes bug reported by Eduardo A. Bustamante López + + + 1/11 + ---- +execute_cmd.c + - execute_builtin: since mapfile uses evalstring() to run its callbacks + internally, just like eval, so it needs to handle the case where the + temp environment given to mapfile persists throughout the entire + set of callback commands. This might be a problem with trap also, but + trap isn't run in the same way. Fixes bug reported by Dan Douglas + + + 1/13 + ---- +redir.c + - redirection_error: before expanding the redirection word (if + expandable_redirection_filename returns true), disable command + substitution during expansion. Fixes bug reported by Dan Douglas + + +subst.c + - expand_word_internal: case '\\': if the next character is an IFS + character, and the expansion occurs within double quotes, and the + character is not one for which backslash retains its meaning, add + the (escaped) '\' and the (escaped) character. Fixes bug reported + by Dan Douglas + + 1/15 + ---- +builtins/cd.def + - cd_builtin: make sure call to internal_getopt handles -e option. + Fixes bug reported by + + 1/17 + ---- +subst.c + - expand_word_list_internal: make sure tempenv_assign_error is + initialized to 0 + +execute_cmd.c + - execute_simple_command: make sure tempenv_assign_error is reset to 0 + after it's tested to see if an error should force the shell to exit. + Fixes problem where a the failure of a tempenv assignment preceding + a non-special builtin `sticks' and causes the next special builtin + to exit the shell. From a discussion on bug-bash started by + douxin + + 1/20 + ---- +subst.c + - parameter_brace_expand_rhs: call stupidly_hack_special_variables + after assigning with ${param[:]=word} even if IFS is changing. + Suggested by Dan Douglas [TENTATIVE, needs work + on IFS side effects] + +command.h + - W_GLOBEXP (which was unused) is now W_SPLITSPACE (which isn't used + yet) + +{execute_cmd,subst,variables}.c + - removed all code that mentioned W_GLOBEXP + - removed mention of gnu_argv_flags and code that set it + + 1/22 + ---- +subst.c + - param_expand: set W_SPLITSPACE if we expand (unquoted) $* and + IFS is unset or null so we can be sure to split this on spaces + no matter what happens with IFS later + - expand_word_internal: note that param_expand returns W_SPLITSPACE + in the returned word flags and keep track of that state with + `split_on_spaces' + + 1/23 + ---- +subst.c + - expand_word_internal: if split_on_spaces is non-zero, make sure + we split `istring' on spaces and return the resultant word. The + previous expansions should have quoted spaces in the positional + parameters where necessary. Suggested by Dan Douglas + + +execute_cmd.c + - execute_command_internal: make sure any subshell forked to run a + group command or user subshell at the end of a pipeline runs any + EXIT trap it sets. Fixes debian bash bug 698411 + http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=698411 + +subst.c + - shell_expand_word_list: fix code that creates args for and calls + make_internal_declare to avoid calling it twice (missing `else' + in 12/26 change) + - do_assignment_internal: fix code from 12/26 change to fix problem + where an existing assoc variable could be converted to an array + without checking `mkassoc' + + 1/24 + ---- +builtins/evalfile.c + - _evalfile: add missing `close (fd)' calls before returning to + avoid fd leaks. Bug and fix from Roman Rakus + + 1/25 + ---- +builtins/read.def + - read_builtin: don't try to play tricks with the top of the unwind- + protect stack after read gets a SIGALRM; save input_string to new + memory, run the stack, then restore input_string and assign the + variables. Part of fix for bug reported by konsolebox + ; the rest of the fix is with the changes in + trap and signal handling and doing away with interrupt_immediately + + 1/26 + ---- +redir.c + - redirection_expand, write_here_string, write_here_document: before + calling any of the word expansion functions, after setting + expanding_redir to 1 (which bypasses the temp environment in the + variable lookup functions), call sv_ifs to reset the cached IFS- + related variables set by subst.c:setifs(). This ensures that + redirections will not get any IFS values that are set in the + temporary environment, as Posix specifies. Then, after the word + expansions, after resetting expanding_redir to 0, call sv_ifs + again to make sure the cached IFS values are set from any + assignments in the temporary environment. We force executing_builtin + to 1 to `fool' the variable lookup functions into using any temp + environment, then reset it to its old value after sv_ifs returns. + This is what allows read() to use the (cached) IFS variables set + in the temp environment. Fixes inconsistency reported by Dan Douglas + + + 1/29 + ---- +lib/readline/display.c + - update_line: fix off-by-one error when updating vis_lbreaks array + in a multibyte locale that occurs when moving multibyte chars from + one line down to another. Bug report and fix from Egmont + Koblinger + + 1/30 + ---- +configure.ac + - changed version to 4.3-alpha + +redir.c + - redir_open: handle open returning -1/EINTR, which seems to happen + a lot with FIFOs and SIGCHLD, and call QUIT to handle other + signals that can interrupt open(2). Bug report and initial fix + from Mike Frysinger + + 1/31 + ---- +subst.c + - parameter_brace_expand: make sure to propagate the PF_ASSIGNRHS flag + to parameter_brace_expand_word + - parameter_brace_expand_word: make sure that if the PF_ASSIGNRHS flag + is set and we are expanding ${a[@]} or ${a[*]} we set quoted to + include Q_DOUBLE_QUOTES before calling array_value_internal, mirroring + what we do for $@ and $*. Fixes inconsistency reported by Dan + Douglas + +configure.ac + - use AC_CHECK_TOOL instead of AC_CHECK_PROG to check for ar, since it + will find $host-prefixed versions of utilities. Report and fix from + Mike Frysinger + +builtins/setattr.def + - set_var_attribute: check whether bind_variable (called when the + variable whose attributes are being modified is found in the temp + environment) just modified a read-only global variable, and don't + bother marking the temporary variable for propagation if so. The + propagation is superfluous and will result in a strange error + message + + 2/2 + --- +variables.c + - initialize_shell_variables: don't try to import function definitions + with invalid names from the environment if already in posix mode, + but create them as (invisible) exported variables so they pass + through the environment. Print an error message so user knows + what's wrong. Fixes bug reported by Tomas Trnka + + 2/9 + --- + +builtins/read.def + - sigalrm_seen, alrmbuf: now global so the rest of the shell (trap.c) + can use them + - sigalrm: just sets flag, no longer longjmps to alrmbuf; problem was + longjmp without manipulating signal mask, leaving SIGALRM blocked + +quit.h + - move CHECK_ALRM macro here from builtins/read.def so trap.c: + check_signals() can call it + +trap.c + - check_signals: add call to CHECK_ALRM before QUIT + - check_signals_and_traps: call check_signals() instead of including + CHECK_ALRM and QUIT inline. Integrating check for read builtin's + SIGALRM (where zread call to check_signals_and_traps can see it) + fixes problem reported by Mike Frysinger + + 2/12 + ---- +lib/glob/xmbsrtowcs.c + - xdupmbstowcs2: fixed but where end of string was not handled + correctly, causing loop to go past end of string in a bunch of cases. + Fixes bug reported by "Dashing" + + + 2/13 + ---- +builtins/pushd.def + - popd_builtin: treat any argument that isn't -n or of the form + [-+][[:digit:]]* as an error. Fixes problem reported by Bruce + Korb + + 2/14 + ---- +configure.ac + - add check for sig_atomic_t; already a placeholder for it in + config.h.in + + 2/15 + ---- +subst.c + - do_compound_assignment: don't call assign_compound_array_list with + a NULL variable in case make_local_xxx_variable returns NULL + (it will if you try to shadow a readonly or noassign variable). + Fixes bug reported by Richard Tollerton + + 2/16 + ---- +variables.c + - make_local_variable: print error messager if an attempt is made to + create a local variable shadowing a `noassign' variable. Previously + we just silently refused to do it + +trap.[ch] + - get_original_signal: now global so rest of the shell can use it + +sig.c + - initialize_shell_signals: install a signal handler for SIGTERM + that does nothing except set a sigterm_received flag instead of + ignoring it with SIG_IGN, as long as SIGTERM is not ignored when + the shell is started. Use get_original_signal early to get the + original handler, since we will do that later anyway + - set_signal_handler: if installing sigterm_sighandler as the SIGTERM + handler, make sure to add SA_RESTART flag to make it as close to + SIG_IGN as possible + +sig.h + - sigterm_sighandler: new extern declaration + +quit.h + - RESET_SIGTERM: set sigterm_receved to 0 + - CHECK_SIGTERM: check sigterm_received; if it's non-zero, treat it + as a fatal signal and call termsig_handler to exit the shell + +jobs.c + - make_child: call RESET_SIGTERM just before fork() so we can detect + if the child process received a SIGTERM before it's able to change + the signal handler back to what it was when the shell started + (presumably SIG_DFL). Only has effect if the shell installed + sigterm_sighandler for SIGTERM, interactive shells that were not + started with SIG_IGN as the SIGTERM handler + - make_child: call RESET_SIGTERM in the parent after fork() so the + rest of the shell won't react to it + +execute_cmd.c + - execute_simple_command: call CHECK_SIGTERM after make_child in child + to catch SIGTERM received after fork() and before restoring old + signal handlers + - execute_disk_command: call CHECK_SIGTERM after make_child in child + process after restoring old signal handlers and again just before + calling shell_execve. Fixes race condition observed by + Padraig Brady when testing with his `timeout' + program + +lib/readline/display.c + - open_some_spaces: new function, subset of insert_some_chars that just + opens up a specified number of spaces to be overwritten + - insert_some_spaces: now just calls to open_some_spaces followed by + _rl_output_some_chars + - update_line: use col_temp instead of recalculating it using + _rl_col_width in the case where we use more columns with fewer bytes + - update_line: use open_some_spaces and then output the right number + of chars instead of trying to print new characters then overwrite + existing characters in two separate calls. This includes removing + some dodgy code and making things simpler. Fix from Egmont + Koblinger + - use new variable `bytes_to_insert' instead of overloading temp in + some code blocks (nls - nfd, bytes that comprise the characters + different in the new line from the old) + + 2/18 + ---- +redir.c + - do_redirection_internal: add undoable redirection for the implicit + close performed by the <&n- and >&n- redirections. Fixes bug + reported by Stephane Chazelas + + 2/19 + ---- +sig.c + - termsig_handler: an interactive shell killed by SIGHUP and keeping + command history will try to save the shell history before exiting. + This is an attempt to preserve the save-history-when-the-terminal- + window-is-closed behavior + + 2/21 + ---- +braces.c + - brace_expand: if a sequence expansion fails (e.g. because the + integers overflow), treat that expansion as a simple string, including + the braces, and try to process any remainder of the string. The + remainder may include brace expansions. Derived from SuSE bug + 804551 example (https://bugzilla.novell.com/show_bug.cgi?id=804551) + + 2/23 + ---- +{quit,sig}.h,sig.c + - sigterm_received declaration now in sig.h; type is sig_atomic_t + - sigwinch_received type now sig_atomic_t + - sig.h includes bashtypes.h and if SIG_DFL not defined + (same logic as trap.h) to pick up sig_atomic_t + +unwind_prot.c + - include sig.h before quit.h (reverse order) + + 2/27 + ---- +builtins/shopt.def + - reset_shopt_options: make sure check_window_size is reset to the + default from config.h, not unconditionally to 0 + +jobs.[ch] + - last_made_pid, last_asynchronous_pid: now volatile. Change from SuSE + +jobs.c + - wait_for: if we're using sigaction to install a handler for SIGCHLD, + make sure we specify SA_RESTART + +lib/{tilde,readline}/shell.c + - get_home_dir: instead of looking in the password file every time, + look once and cache the result + +sig.[ch] + - sigwinch_received, sigterm_received: now `volatile' qualified + +sig.c,quit.h + - interrupt_state,terminating_signal: now sig_atomic_t + + 3/1 + --- +MANIFEST,examples/* + - removed around 120 files without FSF copyrights; requested by + Karl Berry in early January + + 3/2 + --- +lib/malloc/malloc.c + - morecore: only check whether SIGCHLD is trapped if SIGCHLD is defined + +doc/bashref.texi + - Fixed most of the examples in the GNU Parallel section to use better + shell idioms following complaints on bug-bash; added a couple of + examples and smoothed out the text + +quit.h + - include "sig.h" for sig_atomic_t + +lib/readline/display.c + - update_line: when inserting one or more characters at the end of + the display line in a non-multibyte environment, just write from the + first difference to the end of the line and return. We don't have + to adjust _rl_last_c_pos. This is needed to adjust from the old + two-part copy to a single call to _rl_output_some_chars (change of + 2/16) + + 3/4 + --- +Makefile.in,doc/Makefile.in + - PACKAGE_TARNAME, docdir: new variables substituted by autoconf + - OTHER_DOCS,OTHER_INSTALLED_DOCS: new variables with auxiliary + documentation files to be installed into $(docdir) + - install: add new rule to install $(OTHER_DOCS) + - uninstall: add new rule to uninstall $(docdir)/$(OTHER_INSTALLED_DOCS) + +doc/bash.1 + - add URL to `POSIX' file in `SEE ALSO' section; put pointer to that + section in --posix and set -o posix descriptions + +examples/ + - removed around 110 examples at the request of the FSF due to copyright + issues + + 3/5 + --- +builtins/setattr.def + - readonly: modified help text slightly to make it clearer that + functions aren't changed or displayed unless the -f option is given. + Report from + + 3/9 + --- +include/typemax.h + - SIZE_MAX: define to 65535 (Posix minimum maximum) if not defined + +parse.y + - include "typemax.h" for possible SIZE_MAX definition, make sure we + include it after shell.h + +{braces,expr}.c + - include "typemax.h" for possible INTMAX_MIN and INTMAX_MAX definitions + + 3/10 + ---- +bashline.c + - bash_default_completion: make sure completion type of `!' (same as + TAB but with show-all-if-ambiguous set) and glob-word-completion + sets rl_filename_completion_desired to 0 so extra backslashes don't + get inserted by `quoting' the completion. We can't kill all the + matches because show-all-if-ambiguous needs them. Bug report from + Marcel (Felix) Giannelia + +[bash-4.3-alpha frozen] + + 3/14 + ---- +general.c + - trim_pathname: use memmove instead of memcpy since the source and + destination pathnames may overlap. Report and fix from Matthew + Riley + + 3/18 + ---- +configure.ac + - socklen_t is defined as `unsigned int' if configure can't find it + + 3/20 + ---- +lib/readline/complete.c + - S_ISVTX: since it's not defined on all platforms (Minix), make sure + its use is protected with #ifdef + + 3/21 + ---- +doc/{bash.1,bashref.texi} + - Added mention of ${!name[@]} and ${!name[*]} expansions to get all + indices of an array. Suggested by Jonathan Leffler + + + 3/24 + ---- +subst.h + - SD_IGNOREQUOTE: new define for skip_to_delim; if set, means that + single quotes (for now) will be treated as ordinary characters + +subst.c + - skip_to_delim: handle SD_IGNOREQUOTE. no callers use it for now + + 3/25 + ---- +support/config.{guess,sub} + - updated to versions from autoconf-2.69 + + 3/31 + ---- +lib/sh/shquote.c + - sh_single_quote: short-circuit quoting a single "'" instead of + creating a long string with empty single-quoted strings + +parser.h + - DOLBRACE_QUOTE2: new define, like DOLBRACE_QUOTE, but need to single- + quote results of $'...' expansion because quote removal will be + done later. Right now this is only done for ${word/pat/rep} + +parse.y + - parse_matched_pair: set state to DOLBRACE_QUOTE2 for pattern + substitution word expansion so we don't treat single quote specially + in the pattern or replacement string + - parse_matched_pair: if we're parsing a dollar-brace word expansion + (${...}) and we're not treating single quote specially within + double quotes, single-quote the translation of $'...' ansi-c + escaped strings. Original report and fix from Eduardo A. + Bustamante López + +subst.c + - extract_dollar_brace_string: ${word/pat/rep} scanning now sets the + DOLBRACE_QUOTE2 flag instead of DOLBRACE_QUOTE so we don't treat + single quotes specially within a double-quoted string + +execute_cmd.c + - fix_assignment_words: skip over assignment statements preceding a + command word before trying to figure out whether or not assignment + statements following a possible declaration command should be + treated specially. Fixes bug reported by Dan Douglas + + + 4/4 + --- +lib/readline/readline.c + - _rl_dispatch_subseq: only call _rl_vi_set_last (and check whether + the key is a text modification command) if the key sequence length + is 1. That keeps the arrow keys from setting the last command + when called in vi command mode. Fixes bug reported by Ian A. + Watson + + 4/6 + --- +lib/readline/bind.c + - rl_parse_and_bind: when parsing a double-quoted string as the value + of a variable, make sure we skip past the leading double quote. + Fix from Andreas Schwab + +variables.c + - hash_lookup: set new local variable last_table_searched to the table + a successful lookup appears in; tested in make_local_variable to + solve the problem below + - make_local_variable: if we find a variable with the tempenv flag + set at the same `level' as variable_context', but not found in the + temporary_env (temp environment preceding the builtin), return it. + The temp environment preceding the function call has already been + merged (in execute_function) into the list of variable contexts the + function sees as shell_variables by the time this is called. Fixes + inconsistency pointed out by Dan Douglas + +subst.c + - expand_arith_string: expanded out contents of expand_string, + expand_string_internal, expand_string_if_necessary to create a + WORD_DESC and call call_expand_word_internal() on it directly. + We don't want process substitution to be performed ( 1<(2) ) should + mean something different in an arithmetic expression context. + It doesn't work to just turn on the DQUOTE flag, since that means + that things like ${x["expression"]} are not expanded correctly. + Fixes problem pointed out by Dan Douglas + + 4/13 + ---- +subst.c + - process_substitute: run the EXIT trap before exiting, as other + shells seem to. Fixes problem pointed out by Dan Douglas + + +lib/readline/readline.c + - readline_internal_setup: call rl_vi_insertion_mode to enter vi + mode instead of rl_vi_insert_mode to avoid resetting the saved last + command information. Posix says that `.' can repeat a command + that was entered on a previous line so we need to save the info. + Fixes bug reported by Ian A. Watson + + 4/14 + ---- +lib/readline/complete.c + - rl_completion_matches: make sure xrealloc returns something non-null + (can happen when interrupted by a signal) before trying to add + matches to match_list + +subst.c + - array_remove_pattern: return NULL right away if array_variable_part + returns an invisible variable + - array_length_reference: handle array_variable_part returning an + invisible variable + - get_var_and_type: handle array_variable_part returning an invisible + variable + + 4/15 + ---- +execute_cmd.c + - execute_command_internal: make sure to run the EXIT trap for group + commands anywhere in pipelines, not just at the end. From a point + raised by Andreas Schwab + +variables.c + - bind_int_variable: make sure invisible flag is unset. Fixes problems + like "declare -ai a; : $(( a[4]=4 ));" + +arrayfunc.c + - array_variable_part: return variable even if invisible flag set, + callers must handle invisible vars + + 4/18 + ---- +builtins/set.def + - unset_builtin: if -n flag given, call unset_nameref instead of + unset_variable + +variables.c + - find_variable_nameref: print warning message if nameref circular + reference detected, return NULL and let caller deal with it + +builtins/declare.def + - declare_builtin: only disallow global references at this point if + we are at the global scope + + 5/16 + ---- +configure.ac + - update release status to beta + + 5/23 + ---- +trap.c + - run_pending_traps: save and restore pipeline around calls to + evalstring() in case we get a trap while running a trap. Have to + figure out the recursive running traps issue elsewhere. Fixes + bug reported by Roman Rakus + - run_pending_traps: make sure to set running_trap to the appropriate + signal value when running a trap command + - run_pending_traps: short-circuit immediately if running_trap set + when invoked. Could change this later to only skip if it would + run the same trap as currently being run (running_trap == sig + 1) + +configure.ac + - add warning if bison not found + +lib/readline/doc/rltech.texi + - new section with an example program illustrating the callback + interface. Suggested by Peng Yu + +examples/loadables/Makefile.in + - remove references to `cut' and `getconf', which were removed in + early March + + 5/28 + ---- +lib/sh/pathphys.c + - sh_realpath: correct inverted two arguments to call to sh_makepath. + Report and fix from Julien Thomas + + 6/7 + --- +execute_cmd.c + - executing_line_number: the else clauses that are conditional on + various options being defined can simply be if clauses -- they are + mutually exclusive and all have `return' in the body. Fixes bug + reported by Flavio Medeiros + + 6/25 + ---- +lib/readline/readline.c + - readline_internal_setup: only sent the meta-key enable string to the + terminal if we've been told to use one and the terminal has been + successfully initialized (RL_ISSTATE (RL_STATE_TERMPREPPED) != 0). + Suggested by Dan Mick + +lib/readline/signals.c + - _rl_signal_handler: call any defined signal hook after calling + rl_resize_terminal when handling a SIGWINCH. We already have called + the original SIGWINCH handler but will not be resending the signal + to ourselves + + 6/27 + ---- +lib/readline/doc/history.3, doc/bash.1 + - fix description of the `$' modifier to note that it expands to the + last *word*, which is not always the last argument. Report from + ariyetz@gmail.com via gnu.org RT + + 6/29 + ---- +lib/glob/smatch.c + - glob_asciiranges: initialize to value of GLOBASCII_DEFAULT instead + of 0 (0 if not defined) + +configure.ac,config.h.in + - --enable-glob-asciiranges-default: new option, controls the value of + GLOBASCII_DEFAULT; use it to turn globasciiranges shopt option on + by default + +doc/bashref.texi + - document new --enable-glob-asciiranges-default configure option + +variables.c + - assign_in_env: implement += value appending semantics for assignments + preceding command names + + 7/4 + --- +expr.c + - set lasttok = NUM in all of the functions that result in a number, + even if it's a boolean, to avoid errors with constructs like + 1 * x = 1, which should be an asignment error. Fixes problem + pointed out by Dan Douglas + +parse.y + - decode_prompt_string: don't bother to call strcpy if + polite_directory_format returns its argument unchanged. It's not + necessary and Mac OS X 10.9 aborts because of a supposed overlapping + string copy. Bug and fix from simon@hitzemann.org + +subst.c + - parameter_brace_find_indir: new function, code from + parameter_brace_expand_indir that looks up the indirectly-referenced + variable, but does not expand it + - parameter_brace_expand_indir: call parameter_brace_find_indir to + look up indirected variable reference + - get_var_and_type: call parameter_brace_find_indir if it looks like we + are trying to manipulate an indirect variable reference like + ${!b%%foo}. This makes a difference if !b references an array + variable. Bug report from Dan Douglas + + 7/6 + --- +lib/sh/casemod.c + - sh_modcase: make sure argument passed to is_basic is <= UCHAR_MAX, + since cval can convert something to a wchar_t greater than UCHAR_MAX. + Fixes bug reported by Tomasz Tomasik + + 7/8 + --- +lib/readline/history.c + - add_history_time: if history_length == 0, referencing history_length + - 1 will result in an array bounds error, so make history_length be + at least 1 before going on. Fixes bug reported by Geng Sheng Liu + + +builtins/setattr.def + - show_func_attributes: display definition (if NODEFS argument is 0) and + attributes for a particular function; used by `declare -fp name' + +builtins/declare.def + - declare_internal: call show_func_attributes if -f supplied with -p. + Fixes inconsistency observed by Linda Walsh + +builtins/common.h + - new extern declaration for show_func_attributes + +builtins/read.def + - read_builtin: check the first supplied variable name for validity + before attempting to read any input, since we know we will have to + at least use that one. Don't check any other names yet. Suggested + by jidanni@jidanni.org + + 7/10 + ---- +redir.c + - do_redirection_internal: when closing a file descriptor with + r_close_this ([n]<&-) count close errors as redirection errors if + errno ends up as EIO or ENOSPC. Originally reported back in April + 2012 by Andrey Zaitsev + + 7/11 + ---- +redir.c + - do_redirection_internal: before calling check_bash_input, make sure + that we don't call check_bash_input for an asynchronous process that + is replacing stdin with something else. The seek backwards affects + the parent process as well, since parents and children share the + file pointer. Fixes problem originally reported in March 2013 by + Martin Jackson + + 7/13 + ---- +doc/{bash.1,bashref.texi} + - slight change to add a description of `shopt -o' suggested by Bruce + Korb + + 7/19 + ---- +lib/readline/histfile.c + - history_do_write: if close returns < 0, make sure we restore the + backup history file and return a non-zero value + - history_truncate_file: if write or close return < 0, make sure we + return a non-zero value + +[bash-4.3-beta frozen] + + 7/21 + ---- +lib/readline/isearch.c + - rl_display_search: now takes an entire search context flags word as + the second argument, instead of just reverse flag; changed callers + - rl_display_search: if the search has failed, add `failed ' to the + beginning of the search prompt + - _rl_isearch_dispatch: if the search has failed, display the entire + search string with an indication that the search failed but with the + last matching line. Suggested by jidanni@jidanni.org + +command.h + - W_ASSIGNINT: new word flag; used internally for make_internal_declare + and set by fix_assignment_words + +execute_cmd.c + - fix_assignment_words: set W_ASSIGNINT if compound assignment and -i + given as option. We don't do anything with the value yet + +subst.c + - shell_expand_word_list: rework the way the option list that is + passed to make_internal_declare is created + + 8/1 + --- +doc/{bash.1,bashref.texi} + - minor changes to description of $! based on a report from Chris + Down + +arrayfunc.c + - assign_array_element_internal: before trying to get an array's max + index to process a negative subscript, make sure the array exists. + Bug report from Geir Hauge + + 8/2 + --- +arrayfunc.c + - assign_array_element_internal: before using array_max_index() when + processing a negative subscript, make sure the variable is an array. + if it's not, use 0 as array_max_index assuming it's a string. + Fixes bug report from Geir Hauge + + 8/3 + --- +Makefile.in + - pcomplete.o: add dependency on $(DEFDIR)/builtext.h. Suggested by + Curtis Doty + + 8/5 + --- +lib/glob/sm_loop.c + - strcompare: short-circuit and return FNM_NOMATCH if the lengths of the + pattern and string (pe - p and se - s, respectively) are not equal + - strcompare: don't bother trying to set *pe or *se to '\0' if that's + what they already are. Fixes bug reported by Geir Hauge + + + 8/6 + --- +doc/{bash.1,bashref.texi},builtins/hash.def,lib/readline/doc/rluser.texi + - minor typo changes from Geir Hauge + +bultins/help.def + - show_longdoc: avoid trying to translate the empty string because it + often translates to some boilerplate about the project and + translation. Report and fix from Geir Hauge + + 8/8 + --- +builtins/help.def + - help_builtin: try two passes through the list of help topics for each + argument: one doing exact string matching and one, if the first pass + fails to find a match, doing string prefix matching like previous + versions. This prevents `help read' from matching both `read' and + `readonly', but allows `help r' to match everything beginning with + `r'. Inspired by report from Geir Hauge + + 8/13 + ---- +builtins/fc.def + - fc_builtin,fc_gethnum: calculate `real' end of the history list and + use it if -0 is specified as the beginning or end of the history + range to list. Doesn't work for fc -e or fc -s by design. Feature + requested by Mike Fied + + 8/16 + ---- +trap.c + - _run_trap_internal: use {save,restore}_parser_state instead of + {save,restore}_token_state. It's more comprehensive + + 8/23 + ---- +doc/bash.1 + - disown: remove repeated text. Report and fix from Thomas Hood + + + 8/25 + ---- +lib/readline/rltty.c + - set_special_char: fix prototype (last arg is rl_command_func_t *) + +sig.c + - set_signal_handler: return oact.sa_handler only if sigaction + succeeds; if it doesn't, return SIG_DFL (reasonable default). From + https://bugzilla.redhat.com/show_bug.cgi?id=911404 + +bashline.c + - attempt_shell_completion: fix to skip assignment statements preceding + command name even if there are no programmable completions defined. + From https://bugzilla.redhat.com/show_bug.cgi?id=994659 + - attempt_shell_completion: if still completing command word following + assignment statements, do command completion even if programmable + completion defined for partial command name entered so far + + 8/26 + ---- +pcomplete.c + - pcomp_filename_completion_function: make sure rl_filename_dequoting_function + is non-NULL before trying to call it. Bug and fix from + Andreas Schwab + +bashline.c + - bash_command_name_stat_hook: if *name is not something we're going + to look up in $PATH (absolute_program(*name) != 0), just call the + usual bash_filename_stat_hook and return those results. This makes + completions like $PWD/exam[TAB] add a trailing slash + + 9/2 + --- +builtins/read.def + - read_builtin: before comparing what we read to the delim, make sure + we are not supposed to be ignoring the delimiter (read -N). We + set the delim to -1, but it's possible to read a character whose + int value ends up being between -1 and -128. Fixes bug + reported by Stephane Chazelas + +doc/{bash.1,bashref.texi} + - word splitting: crib some language from Posix to make it clear that + characters in IFS are treated as field *terminators*, not field + *separators*. Addresses issue raised by DJ Mills + + +lib/readline/{util.c,rldefs.h} + - _rl_stricmp,_rl_strnicmp: now take const char * string arguments; + changed prototype declarations + + 9/5 + --- +doc/{bash.1,bashref.texi} + - [[: modify description of pattern matching to make it clear that the + match is performed as if the extglob option were enabled. From Red + Hat bug https://bugzilla.redhat.com/show_bug.cgi?id=1002078 + + 9/12 + ---- +lib/readline/isearch.c + - _rl_isearch_dispatch: if we read an ESC and it's supposed to + terminate the search, make sure we check for typeahead with + _rl_pushed_input_available, since installing a hook function causes + typeahead to be collected in `ibuffer' (input.c). If there is any, + make sure we still use the ESC as a prefix character. Bug and fix + from Mike Miller + + 9/16 + ---- +builtins/{caller,cd,kill,pushd,wait}.def + - builtin_usage(): make sure call to this sets return status to + EX_USAGE + + 9/18 + ---- +terminal.c + - rl_change_environment: new application-settable variable; if non- + zero (the default), readline will modify LINES and COLUMNS in the + environment when it handles SIGWINCH + - _rl_get_screen_size: if rl_change_environment is non-zero, use setenv + to modify LINES and COLUMNS environment variables + +readline.h + - rl_change_environment: new extern declaration for applications + + 9/22 + ---- +configure.ac + - relstatus: bumped version to bash-4.3-beta2 + + 9/24 + ---- + +lib/readline/readline.c + - bind_arrow_keys_internal: added more key bindings for the numeric key + pad arrow keys on mingw32. Patch from Pierre Muller + + + 10/19 + ----- + +bashline.c + - maybe_restore_tilde: version of restore_tilde that honors `direxpand'; + calls restore_tilde after saving directory expansion hook if + necessary. Report from Andreas Schwab + +builtins/cd.def + - -@: new option, allows cd to use `extended attributes' present in + NFSv4, ZFS; idea taken from ksh93. Attributes associated with a + file are presented as a directory containing the attributes as + individual files. Original patch contributed by Cedric Blancher + + + 10/20 + ----- +aclocal.m4 + - BASH_CHECK_MULTIBYTE: check for wcwidth being broken with unicode + combining characters needs a value to use when cross-compiling. + Bug report from Bert Sutherland + +doc/{bash.1,bashref.texi} + - document new -@ option to cd builtin + + 10/28 + ----- +lib/glob/{{gmisc,glob}.c,glob.h} + - extglob_pattern renamed to extglob_pattern_p, declared in glob.h + +subst.c + - expand_word_internal: typo fix: case to fix " $@\ " bug in bash-4.2 + had a typo (& isexp instead of &&) + + 10/29 + ----- +input.c + - getc_with_restart: make sure local_index and local_bufused are + reset to 0 before returning EOF, in case we are running an interactive + shell without line editing and ignoreeof is set. Report and fix + from Yong Zhang + +lib/readline/search.c + - _rl_nsearch_init: take out extra third argument to rl_message; it + only matches prototype (and maybe format) in cases where + PREFER_STDARG and USE_VARARGS are both undefined, which is rare + + 10/31 + ----- +subst.c + - process_substitute: when opening the named pipe in the child, open + without O_NONBLOCK to avoid race conditions. Happens often on AIX. + Bug report and fix from Michael Haubenwallner + + +builtins/ulimit.def + - RLIMIT_NTHR: if RLIMIT_PTHREAD is not defined, but RLIMIT_NTHR is, + use RLIMIT_NTHR (NetBSD) + + 11/5 + ---- +locale.c + - set_default_locale_vars,set_locale_var: if TEXTDOMAINDIR has been + set, and default_dir has a non-null value, call bindtextdomain(3) + when TEXTDOMAIN is assigned a value. Fixes problem reported by + Michael Arlt + + 11/6 + ---- +builtins/cd.def + - cdxattr: only create synthetic pathname in `buf' if NDIRP argument + is non-null + - change_to_directory: if we have specified -@ and cdxattr returns + failure, fail immediately. Fixes bug reported by Joshuah Hurst + + + 11/12 + ----- +redir.c + - print_redirection: change r_err_and_out (&>) and its append form, + r_append_err_and_out (&>>) cases to separate redirection operator + from filename by a space, in case we have a process substitution. + Fixes bug reported by admn ombres + + 11/15 + ----- +execute_cmd.c + - execute_simple_command: don't close process substitution fds until + we are finished executing any current shell function. Partial fix + for bug reported by John Dawson + +support/shobj-conf + - add support for Darwin 13 (Mac OS X 10.9, Mavericks). Based on a + report by Ludwig Schwardt + + 11/20 + ----- +[bash-4.3-rc1 frozen] + + 11/24 + ----- +builtins/printf.def + - bind_printf_variable: make sure that the variable assigned to is + no longer marked as invisible. Fixes bug reported by NBaH + + + 11/28 + ----- +jobs.c + - delete_old_job: fix off-by-one error in job index in call to + internal_warning. Bug report from Peter Cordes + + 11/30 + ----- +doc/bashref.texi + - add string to description of special parameters with name of + special parameter prefixed by a $, so you can search for $#, + for instance + + 12/2 + ---- +lib/readline/{histexpand.c + - get_history_event: account for current_history() possibly returning + NULL. Report and fix from Pankaj Sharma + + + 12/11 + ----- + +lib/readline/parse-colors.c + - get_funky_string: don't call abort if we see something we can't + parse; just return an error + - _rl_parse_colors: if we encounter an error while parsing $LS_COLORS + we need to leave _rl_color_ext_list as NULL after freeing its + elements, then turn off _rl_colored_stats. Report and fix from Martin + Wesdorp + + 12/13 + ----- + +lib/readline/parse-colors.c + - _rl_parse_colors: if we encounter an unrecognized prefix, throw an + error but try to recover and go on to the next specification + +variables.c + - make_local_variable: for new variables this function creates, set + the att_invisible attribute. All callers from declare_internal. + Indirectly, this is a fix for bug with `declare -n var; var=foo;' + reported by Pierre Gaston + - bind_variable: if assigning to nameref variable that doesn't have + a value yet (e.g., with `declare -n var; var=foo'), don't try to + use the unset name. Fixes a segfault reported by Pierre Gaston + + +execute_cmd.c + - execute_command_internal: make sure last_command_exit_value is set + to 0 after any command executed in the background. Fixes bug + reported by Martin Kealey + + 12/17 + ----- +support/config.{guess,sub} + - updated to latest versions from git + + 12/19 + ----- +parse.y + - struct STRING_SAVER: now has a new `flags' element, to identify the + caller: alias expansion, double-paren parsing, or parse_and_execute + - push_string: now sets flags to PSH_ALIAS if `ap' argument is non-NULL + - push_string: now doesn't attempt to call strlen on a NULL string to + set shell_input_line_size + - parser_expanding_alias, parser_save_alias, parser_restore_alias: new + functions to provide an external interface to push_string and + pop_string; parser_save_alias sets flags element to PSH_SOURCE (could + be renamed PSH_EXTERN someday) + - shell_getc: when yy_getc returns '\0', instead of just testing + whether the pushed_string_list is not-empty before popping it, don't + pop if if the saved string has flags PSH_SOURCE, indicating that + parse_and_execute set it before setting bash_input to the string. + We should continue reading to the end of that string before popping + back to a potential alias. Partial solution for the problem of aliases + with embedded newlines containing `.' commands being executed out of + order reported by Andrew Martin + - shell_getc: when yy_getc returns '\0' and there is a saved string of + type PSH_SOURCE, restart the read without popping the string stack + if we have not read to the end of bash_input.location.string. Rest + of fix for out-of-order execution problem + +externs.h + - parser_expanding_alias, parser_save_alias, parser_restore_alias: new + extern function declarations + +builtins/evalstring.c + - pe_prologue: if the parser is expanding an alias, make sure to add + an unwind-protect to restore the alias; undoes the work that will be + performed by parse_and_execute/parse_string + - parse_and_execute,parse_string: after calling push_stream to save + bash_input, check whether or not the parser is currently expanding + an alias (parser_expanding_alias() != 0). If it is, we want to save + that string in the pushed_string_list, which we do with + parser_save_alias. + + 12/23 + ----- +execute_cmd.c + - execute_for_command: make sure to set line_number before expanding + the word list, so expansion errors have the right line number. + From a report from Ben Okopnik + +expr.c + - exp2: save token pointer before calling readtok(), arrange to use + saved token pointer when printing error token on a division by 0 + error + + 12/27 + ----- +lib/readline/display.c + - rl_redisplay: when calculating effects of invisible characters in a + prompt that is split across physical screen lines to set the indices + of linebreaks, don't bother testing local_prompt_prefix (line 751). + That prefix doesn't matter when calculating prompt visible and + invisible characters. Fixes problem reported by Jinesh Choksi + + +Makefile.in + - install: make sure to use $(DESTDIR) when installing OTHER_DOCS. + Report and fix from Matthias Klose + +doc/texinfo.tex + - updated to version of 2013-09-11 + + 12/28 + ----- +lib/readline/undo.c + - rl_do_undo: if we are undoing from a history entry (rl_undo_list == + current_history()->data), make sure the change to rl_line_buffer is + reflected in the history entry. We use the guts of + rl_maybe_replace_line to do the work. Fixes problem reported by + gregrwm + + 12/30 + ----- +sig.c + - sigint_sighandler: if we get a SIGINT (and this signal handler is + installed) while the wait builtin is running, note that we received + it in the same way as jobs.c:wait_sigint_handler and return. The + various wait_for functions will look for that with CHECK_WAIT_INTR. + This fixes the wait builtin not being interruptible in an interactive + job control shell + + 12/31 + ----- +trap.c + - set_signal_hard_ignored: rename set_signal_ignored to this, since it + both sets original_signals[sig] and sets the HARD_IGNORE flag + - set_signal_ignored: new function, now just sets original_signals[sig] + +trap.h + - set_signal_hard_ignored: new external declaration + +sig.c + - initialize_terminating_signals: call set_signal_hard_ignored instead + of set_signal_ignored for signals with disposition SIG_IGN when the + shell starts + +execute_cmd.c + - setup_async_signals: make sure we get the original dispositions for + SIGINT and SIGQUIT before starting the subshell, and don't call + set_signal_ignored because that sets original_signals[sig]. If we + don't, subsequent attempts to reset handling using trap will fail + because it thinks the original dispositions were SIG_IGN. Posix + interpretation 751 (http://austingroupbugs.net/view.php?id=751) + + 1/2/2014 + -------- +lib/sh/stringvec.c + - strvec_mcreate, strvec_mresize: versions of create and resize that + use malloc and realloc, respectively, instead of xmalloc/xrealloc + +braces.c + - expand_amble,mkseq: use strvec_mcreate/strvec_mresize so we can + catch and handle memory allocation failures instead of aborting + with the xmalloc/xrealloc interface + +lib/sh/strdup.c + - strdup replacement function for ancient systems that don't have it + +lib/sh/itos.c + - mitos: new function, itos that uses strdup instead of savestring + +externs.h + - strvec_mcreate/strvec_mresize: new extern declarations + - mitos: new extern declaration + +configure.ac + - bash version moved to 4.3-rc2 + + 1/6 + --- +doc/bash.1,lib/readline/doc/{rluser.texi,readline.3} + - separate the description of what happens when readline reads the + tty EOF character from the description of delete-char, leaving a + note in the delete-char description about common binding for ^D. + From suggestion by Parke + +lib/readline/doc/{version.texi,history.3,*.texi} + - updated email addresses and copyright dates + + 1/7 + --- +variables.c + - delete_var: new function, just removes a variable from a hash table + and frees it, without doing anything else + - make_variable_value: if we are trying to assign to a nameref variable, + return NULL if the value is null or the empty string or not a valid + identifier + +variables.h + - delete_var: new extern declaration + +subst.h + - ASS_NAMEREF: new define for assignments, means assigning to a nameref + variable + +builtins/declare.def + - declare_internal: if we are creating and assigning to a nameref + variable, make sure the value is a valid variable name (checks done + by make_variable_value via bind_variable_value) and display an + error message, deleting the variable we just created, if it is not. + Fixes bug reported by Peggy Russell + + 1/9 + --- +builtins/declare.def + - declare_internal: turning on nameref attribute for an existing + variable turns off -i/-l/-u/-c attributes (essentially the ones + that cause evaluation at assignment time) for ksh93 compat + +builtins/setattr.def + - show_name_attributes: if asked to display attributes and values for + a nameref variable, don't follow the nameref chain to the end. More + ksh93 compat + + 1/10 + ---- +trap.c + - _run_trap_internal: use {save,restore}_parser_state instead of + {save,restore}_token_state, like in run_pending_traps(); don't + need to save and restore last_command_exit_value as a result + - _run_trap_internal: call {save,restore}_pipeline like in + run_pending_traps() + - run_pending_traps: since we no longer run traps in a signal handler + context, do not block and unblock the trapped signal while the + trap is executing + - run_pending_traps: allow recursive invocations (basically, running + traps from a trap handler) with only a warning if the shell is + compiled in debug mode. If a caller doesn't want this to happen, + it should test running_trap > 0. signal_in_progress (sig) only works + for the signals the shell handles specially + +bashline.c + - bash_event_hook: make sure we clean up readline if interrupt_state + is set, not only when SIGINT is not trapped. check_signals_and_traps + will call check_signals, which calls QUIT, which will longjmp back + to top_level, running the interrupt trap along the way. Fixes the + problem of signal handlers being reset out from under readline, and + not being set properly the next time readline is called, because + signals_set_flag is still set to 1. XXX - might need to do this + for other signals too? + + 1/11 + ---- +subst.h + - SD_GLOB: new define for skip_to_delim; means we are scanning a + glob pattern. + +subst.c + - skip_to_delim: if flags include SD_GLOB, assume we are scanning a + glob pattern. Currently only used to skip bracket expressions + which may contain one of the delimiters + + 1/12 + ---- +subst.c + - parameter_brace_expand: when expanding $@ as part of substring + expansion, pattern substitution, or case modification, don't turn + on the QUOTED_NULL flag. The code that constructs the word to be + returned from expand_word_internal expects a different code path + when $@ is being expanded. Fixes bug reported by Theodoros + V. Kalamatianos + + 1/19 + ---- +subst.c + - list_dequote_escapes: new function; analogue of list_quote_escapes + +pathexp.c + - quote_string_for_globbing: fix case where unescaped ^A is last char + in string; need to pass it through unaltered instead of turning it + into a bare backslash + - quote_string_for_globbing: when quoting for regexp matching in [[, + don't treat backslash as a quote character; quote the backslash as + any other character. Part of investigation into reports from + Eduardo A. Bustamante López + + 1/25 + ---- +builtins/gen-helpfiles.c + - write_helpfiles: add prototype + - make sure to #undef xmalloc/xfree/xrealloc/free if USING_BASH_MALLOC + is defined. the code does not use them, and we don't link against + xmalloc.o. Report from Linda Walsh + +Makefile.in + - variables.o: add dependency on builtins/builtext.h; helps with + parallel builds. Report from Linda Walsh + +support/shobj-conf + - darwin: combine the stanzas into one that will not require them to + be updated on each Mac OS X release. Report and fix from Max Horn + + + 1/27 + ---- +support/shobj-conf + - darwin: changed the install_name embedded into the shared library + to contain only the major version number, not the minor one. The + idea is that the minor versions should all be API/ABI compatible, + and it is better to link automatically with the latest one. Idea + from Max Horn + + 1/29 + ---- +[bash-4.3-rc2 released] + + 1/30 + ---- +lib/readline/readline.h + - rl_clear_history, rl_free_keymap: add extern declarations. Report + from Hiroo Hayashi + +general.c + - include trap.h for any_signals_trapped() prototype + +lib/sh/unicode.c + - include for sprintf prototype + + 1/31 + ---- +execute_cmd.c + - execute_simple_command: only posix-mode shells should exit on an + assignment failure in the temporary environment preceding a special + builtin. This is what the documentation and code comments have + always said + - execute_simple_command: make sure redirection errors, word expansion + errors, and assignment errors to Posix special builtins cause a + non-interactive posix mode shell to exit. Previously the shell + would not exit if the failed special builtin was on the LHS of || + or && + +pathexp.c + - quote_string_for_globbing: when quoting a regular expression + (QGLOB_REGEXP), allow an unquoted backslash to pass through + unaltered. Don't use it as a quote character or quote it. More + investigation from 1/24 and report by Mike Frysinger + + - quote_string_for_globbing: when quoting a regular expression + (QGLOB_REGEXP), turn CTLESC CTLESC into CTLESC without adding a + backslash to quote it. We should not have to quote it because it is + not a character special to EREs. More investigation from 1/24 + +lib/glob/glob.c + - glob_testdir: now takes a second flags argument (currently unused); + changed prototype and callers + + 2/1 + --- +lib/glob/glob.c + - glob_testdir: if flags argument includes GX_ALLDIRS (globstar), use + lstat so we skip symlinks when traversing the directory tree. + Originally reported by Chris Down + + 2/2 + --- +lib/readline/undo.c + - rl_do_undo: make sure CUR is non-zero before dereferencing it to + check cur->data against rl_undo_list. Report and fix from + Andreas Schwab + +doc/{bash.1,bashref.texi} + - added slight clarifying language to the description of $*, + describing what happens when the expansion is not within double + quotes + + 2/4 + --- +test.c + - unary_test: add code to -v case so that it interprets `bare' array + references (foo[1]) and returns true if that index has a value + + 2/5 + --- +trap.c + - restore_default_signal: fix SIGCHLD special case for SIG_TRAPPED flag + off but SIG_INPROGRESS mode set and handler IMPOSSIBLE_TRAP_HANDLER; + continue with resetting handler in this case. maybe_set_sigchld_trap + will check these things before resetting sigchld trap from + run_sigchld_trap. Fixes (apparently long-standing?) problem reported + by Alexandru Damian + + 2/6 + --- +lib/sh/strtrans.c + - ansic_quote: fixed a bug when copying a printable character that + consumes more than one byte; byte counter was not being incremented. + Bug report from jidanni@jidanni.org + + 2/7 + --- +input.c + - getc_with_restart: if read(2) returns -1/EINTR and interrupt_state or + terminating_signal is set (which means QUIT; will longjmp out of this + function), make sure the local buffer variables are zeroed out to + avoid reading past the end of the buffer on the next call. Bug report + from Dan Jacobson + + 2/9 + --- +bashline.c + - command_word_completion_function: if a directory in $PATH contains + quote characters, we need to quote them before passing the candidate + path to rl_filename_completion_function, which performs dequoting on + the pathname it's passed. Fixes bug reported by Ilyushkin Nikita + + + 2/11 + ---- +parse.y + - xparse_dolparen: save and restore shell_eof_token around call to + parse_string, intead of just leaving it set to ')' + - shell_getc: when -v is set, only print the command line when + shell_eof_token is 0, so we don't print it multiple times when + recursively entering the parser to parse $(...) commands. Fixes + bug reported by Greg Wooledge + +[changed release status to 4.3-release] + + 2/13 + ---- +lib/sh/strtrans.c + - ansic_quote: handle case where mbrtowc reports that the multibyte + sequence is incomplete or invalid. Fixes bug reported by + Eduardo A. Bustamante López + + 2/14 + ---- +variables.c + - find_variable_nameref_context: fix a problem that caused the loop + to go one context too close to the global context. In some cases, + simple variable assignment would set a variable in the global + context instead of a local context. Bug report from + Geir Hauge + + 2/26 + ---- +[bash-4.3 released] + + 2/27 + ---- +aclocal.m4 + - broken wcwidth check: fix typo reported by David Michael + + + 2/28 + ---- +support/bashbug.sh + - add ${BUGADDR} to error message printed if sending mail fails + +trap.c + - _run_trap_internal: don't call {save,restore}_pipeline if running + DEBUG trap; run_debug_trap calls them itself. Fixes bug reported + by Moe Tunes + +test.c + - unary_test: fix 'R' case by using find_variable_noref instead of + find_variable + - test_unop: add back missing 'R' case. Fixes bug reported by + NBaH + + 3/2 + --- +jobs.c + - end_job_control: if job control is active, we changed the terminal's + process group, so make sure we restore it. Fixes bug reported by + Eduardo A. Bustamante López + + 3/7 + --- +pcomplete.c + - pcomp_curtxt: new variable, holds the original text to be completed + as passed to the programmable completion code + - pcomp_filename_completion_function: if we are running compgen + (presumably in a shell function completion) and performing readline + completion, check the word being completed. If it's not empty, but + the original word passed to the programmable completion code is an + empty string (""), call a dequoting function if one is available. + This compensates for an assumption in bash-completion. Reported by + Albert Shih + +lib/readline/readline.c + - _rl_dispatch_subseq: when deciding whether or not to set vi mode's + idea of the last command, use whether or not the dispatching keymap + is vi_movement_keymap instead of the key sequence length. The `c', + `d', and `y' commands all take motion commands as `arguments' and + will produce key sequences longer than 1 character. The arrow keys + will end up dispatching out of a different keymap, so the test will + prevent arrow keys from setting the last command (the problem in + bash-4.2). Bug report from Daan van Rossum + +lib/readline/vi_mode.c + - _rl_vi_motion_command: convenience function to test whether a key is + a vi-mode motion command + +lib/readline/rlprivate.h + - _rl_vi_motion_command: extern declaration + +parse.y + - parse_matched_pair: we should not skip processing single quotes in + posix mode if dolbrace_state == DOLBRACE_QUOTE2 (pattern + substitution). Fixes bug reported by David Sines + + + 3/10 + ---- +lib/readline/readline.c + - _rl_dispatch_callback: treat a return value of -1 as the end of + a command dispatch sequence if the current context doesn't + indicate that we're reading a multi-key sequence + ((cxt->flags & KSEQ_SUBSEQ) == 0). Turn off the multikey flag + and free the context chain in this case. Fixes one bug reported + by Felix Yan to bug-readline list + - _rl_dispatch_callback: treat a return value of > 0 the same as 0 + and return from the function, since only values < 0 cause us to + simulate recursion. Rest of fix for bug tracked down by + Anatol Pomozov + + 3/11 + ---- + +execute_cmd.c + - execute_in_subshell: if a longjmp occurs, set result to + EXECUTION_FAILURE only if last_command_exit_value == EXECUTION_SUCCESS; + use value of last_command_exit_value otherwise. Fixes cosmetic + issue reported by Dennis Lambe Jr. + +doc/bash.1 + - shell-kill-word and shell-backward-kill-word should be documented + as unbound by default. Report from Oliver Hartley + + +trap.c + - run_pending_traps: save value of $? before running trap commands in + trap_saved_exit_value, like run_exit_trap + - _run_trap_internal: save value of $? before running trap commands in + trap_saved_exit_value, like run_exit_trap + +builtins/common.c + - get_exitstat: when running `return' in a trap action, and it is not + supplied an argument, use the saved exit status in + trap_saved_exit_value. Fixes Posix problem reported by + Eduardo A. Bustamante López + + 3/13 + ---- +lib/sh/shquote.c + - sh_contains_quotes: new function, returns true if a given string + contains any of the shell quote characters (single quote, double + quote, or backslash) + +externs.h + - sh_contains_quotes: new extern declaration + +pcomplete.c + - pcomp_filename_completion_function: more changes for the benefit of + bash-completion: if the argument is not the same as the original + argument passed to the programmable completion code (pcomp_curtxt), + and we are being run by compgen as part of a completion, dequote the + argument as bash-completion expects. Fix for the complete-word- + with-quoted-special-chars problem with bash-completion + + 3/17 + ---- +execute_cmd.c + - execute_intern_function: when in posix mode, make defining a function + with the same name as a special builtin a fatal error only when the + shell is not interactive. Interactive shells display an error + message and go on. From a discussion with Doug McIlroy + + + 3/18 + ---- +arrayfunc.c + - assign_compound_array_list: when using expand_assignment_string_to_string + to expand the value in a ( [x]=y ) compound assignment, make sure + that we convert 0x0 to "" when expanding [x]= so it doesn't appear as + if the index is unset. Fixes bug reported by Geir Hauge + + +builtins/common.c + - get_exitstat: update fix of 3/11 to allow the DEBUG trap to use the + current value of $? instead of the value it had before the trap + action was run. This is one reason the DEBUG trap exists, and + extended debug mode uses it. Might want to do this only in Posix + mode + +doc/{bash.1,bashref.texi} + - return: add language cribbed from Posix saying what happens when + return is run without an argument from a trap, including the DEBUG + trap exception + + 3/19 + ---- +lib/glob/gmisc.c + - extglob_pattern_p: make sure ?(patlist) is flagged as an extglob + pattern + +lib/glob/glob.c + - extglob_skipname: rewrite to handle patterns that begin but do not + end with an extglob pattern; change test for easy case and loop + through patterns accordingly. Fixes problem with matching filenames + with a leading dot reported by Stephane Chazelas + + - wextglob_skipname: make analogous changes + + 3/20 + ---- +Makefile.in + - pass -DDEBUG down to builds in readline and history directories + +lib/readline/util.c + - _rl_trace and related functions are now only compiled in if DEBUG + is defined + +lib/readline/Makefile.in + - substitute @DEBUG@ and pass -DDEBUG, if necessary, to compilation + in LOCAL_CFLAGS + + 3/21 + ---- +parse.y + - shell_getc: when checking whether or not to reallocate + shell_input_line to add trailing newline, don't try to subtract from + shell_input_line_size. size_t is unsigned, so if its value is less + than 3 (like, say, 2), size-3 is a very large number and the string + will not be reallocated. Use len+3 > size instead of len > size-3. + Fixes bug reported in + https://bugs.launchpad.net/ubuntu/+source/bash/+bug/1295467 + + 3/27 + ---- +lib/readline/display.c + - _rl_clean_up_for_exit: don't bother to call _rl_move_vert to whatever + readline thinks the last displayed line is if it's 0. Two reasons: a + minor optimization, and it protects against unwanted moving if this + function is called twice, as it is when ^C is pressed. Fixes bug + reported by Egmont Koblinger + + 3/28 + ---- +bashline.c + - invalid_completion: new function, used to identify attempts to + complete words that are syntax errors + - attempt_shell_completion: if invalid_completion returns true for a + word in a command position, punt on all completions. Fixes cosmetic + issue reported by Uwe Storbeck + - attempt_shell_completion: add clause so that in_command_position + remains set to 1 for an empty word following a command separator like + (, &, or | + +lib/readline/kill.c + - rl_yank, rl_yank_nth_arg_internal: don't return -1 from bindable + functions, return 1 instead + +lib/readline/text.c + - rl_rubout, _rl_rubout_char, rl_delete, rl_change_case, + rl_transpose_chars, rl_transpose_words, _rl_set_mark_at_pos, + rl_exchange_point_and_mark, _rl_insert_next, _rl_char_search, + _rl_char_search_internal: + don't return -1 from bindable functions, return 1 instead + +lib/readline/vi_mode.c + - rl_vi_end_word, rl_vi_rubout, rl_vi_delete, rl_vi_char_search, + rl_vi_match, _rl_vi_set_mark, _rl_vi_goto_mark: + don't return -1 from bindable functions, return 1 instead + +lib/readline/macro.c + - rl_start_kbd_macro, rl_end_kbd_macro: + don't return -1 from bindable functions, return 1 instead + +builtins/setattr.def + - set_var_attribute: honor setting of no_invisible_vars when setting + att_invisible on a variable + - include "../flags.h" for no_invisible_vars + +builtins/declare.def + - declare_internal: honor setting of no_invisible_vars when setting + att_invisible on a variable + - include "../flags.h" for no_invisible_vars + +Makefile.in,builtins/Makefile.in + - make sure declare.o and setattr.o depend on flags.h + +execute_cmd.c + - decpoint: new function, returns locale's decimal point or `.' default + - mkfmt: use decpoint() to get decimal point instead of unconditionally + using `.'. Fixes bug reported by Andrey Tataranovich + in debian bug 741669 + + 4/10 + ---- +lib/readline/rltypedefs.h + - add back old Function/VFunction/etc typedefs, since other packages + (python, samba) use them. Mark as deprecated using gcc and clang + attributes. Report and fix from Max Horn + + 4/14 + ---- +jobs.c + - run_sigchld_trap: unwind-protect value of this_shell_builtin, since + it matters in some cases whether or not we are running `wait' or + `eval'. Fixes bug reported by Eduardo A. Bustamante López + + + 4/18 + ---- +shell.h + - sh_parser_state_t: add `need_here_doc' flags member, since + xparse_dolparen (via parse_command) sets it to 0 + +parse.y + - gather_here_documents: make sure need_here_doc is > 0, since we + don't want to just decrement it forever if it ends up < 0. Partial + fix for bug reported by Jared Yanovich + - {save,restore}_parser_state: save and restore need_here_doc flag. + Rest of fix for bug reported by Jared Yanovich + + 4/19 + ---- +subst.c + - cond_expand_word: since we are not supposed to be performing word + splitting here, set expand_no_split_dollar_star to 1 in addition to + setting W_NOSPLIT2 + - expand_word_internal: if we have a case where we have an unquoted + $@ but we are in a case where we don't want to split (W_NOSPLIT2), + make sure we return a list consisting of a single word with the + arguments separated by spaces and don't do word splitting. Fixes + bug reported by Greg Wooledge from an IRC + discussion + +builtins/hash.def + - print_portable_hash_info: single-quote pathnames and hashed filenames + that contain shell metacharacters. Fixes bug reported by + in debian bash bug #739853 + + 4/20 + ---- +lib/readline/display.c + - When using horizontal scrolling, the redisplay code erases too much + of the line containing successful results, so make sure we only + erase to the end of the line after making sure we move the cursor + to the end. Fixes bug reported by + + 4/23 + ---- +{bashhist,bashline}.c +builtins{bind,help,type}.def +lib/glob/glob.c, lib/intl/{loadmsgcat,localealias}.c,lib/sh/mktime.c + - fixes to memory leaks uncovered by coverity scan + + 4/24 + ---- +{bashhist,subst,redir,assoc,jobs,array,trap}.c +lib/intl/l10flist.c +builtins/complete.def + - fixes to memory leaks and other resource usage problems uncovered by + coverity scan + +redir.c + - do_redirection_internal: if dup2 fails (presumably because of a + resource limit), close the file descriptor we opened before returning + error + + 4/25 + ---- +config-top.h + - DEFAULT_BASHRC: new define with the name of the default shell + startup file + +bashline.c + - bash_directory_completion_matches: don't dequote the directory name. + If rl_completion_found_quote is non-zero, readline will dequote the + filename itself. Fixes bug reported by Clark Wang + + + 4/27 + ---- +subst.c + - parameter_brace_expand_rhs: if parameter_brace_find_indir returns + NULL or "", or if it returns something that is not a valid identifier, + report an error and return &expand_wdesc_error so the error can + propagate up. Fixes bug reported by Andre Holzhey + + + 4/29 + ---- +subst.c + - parameter_brace_substring: don't short-circuit right away if the + value is NULL but we are looking at the positional parameters. Part + of fix for bug reported by Pierre Gaston + - pos_params: if there are no positional parameters, only short-circuit + if we are looking for $1 and above. Rest of fix for bug reported + by Pierre Gaston + +subst.h + - SD_NOPROCSUB: new flag for skip_to_delim, means to not allow any + process subsitutions (should not have overloaded SD_NOSKIPCMD) + +subst.c + - skip_to_delim: honor SD_NOPROCSUB flag + +make_cmd.c + - make_arith_for_expr: set W_NOPROCSUB flag in the created word + - make_arith_for_command: set SD_NOPROCSUB in the flags argument to + skip_to_delim so we don't treat <( or >( as a process substitution + (we won't evaluate them in eval_arith_for_expr anyway). Fixes + bug reported by Pierre Gaston + + 5/1 + --- +lib/glob/gmisc.c + - glob_dirscan: new function, takes a pattern and a directory separator + argument and advances the pattern to the last occurrence of the + separator. Like strrchr, but understands extended glob patterns and + uses glob_patscan to skip over them + +lib/glob/glob.c + - extglob_skipname: if the extended globbing pattern is invalid, don't + skip the name + - glob_filename: if there is a slash in the pattern to be matched, and + extglob is enabled, use glob_dirscan to find the real last occurrence + of `/' to avoid being confused by slashes in extglob patterns. Fix + for bug reported by Pierre Gaston + + 5/6 + --- +variables.c + - make_local_variable: only set the att_invisible attribute if + no_invisible_vars isn't set + - find_variable_for_assignment: new function, intended to be called by + code that eventually wants to assign a value to the variable; will not + skip invisible variables; currently identical to find_variable + - find_variable_no_invisible: new function, finds the first visible + instance of variable with a given name in the variable context chain; + eventually will be used to replace find_variable; separate right now + for testing + +variables.h + - find_variable_for_assignment: extern declaration + - find_variable_no_invisible: extern declaration + + 5/7 + --- +variables.c + - make_local_variable: don't clear `invisible' attribute if we are + returning an existing local variable at the right context. Let the + upper layers do that. Fixes bug reported by Dan Douglas + + + 5/8 + --- +lib/readline/input.c + - rl_getc: call RL_CHECK_SIGNALS if a read(2) is interrupted (-1/EINTR) + by SIGALRM or SIGVTALRM (placeholder for non-keyboard-generated + signals of interest) + +builtins/read.def + - edit_line: call bashline_set_event_hook and + bashline_reset_event_hook around call to readline(), so the right + signal handling happens + - read_builtin: make sure we add an unwind_protect call to + bashline_reset_event_hook. These changes fix bug reported in + https://bugs.launchpad.net/ubuntu/+source/bash/+bug/1317476 + +bashline.c + - bash_event_hook: make sure we clean up the readline state by calling + rl_cleanup_after_signal if sigalrm_seen is non-zero. The read builtin + sets this when it times out + + 5/12 + ---- +doc/{bash.1,bashref.texi} + - clarify language to make it clear that changing attributes of a + nameref variable (e.g., export), actually changes the attributes of + the referenced variable. Fixes omission noted by Jeff Haemer + + +arrayfunc.c + - bind_array_var_internal: make sure ENTRY no longer has invisible + attribute before returning. Fixes bug reported by Geir Hauge + + + 5/22 + ---- +execute_cmd.c + - shell_execve: if execve fails and we return 127 or 126, make sure to + set last_command_exit_value if a call to file_error or report_error + causes the shell to exit. This ensures that the shell exits with + the right value. + + 6/6 + --- +shell.c + - drop_priv_mode: print an error message on setuid() failure, optionally + exit if errno == EAGAIN, as it can be on Linux when RLIMIT_NPROC for + the target user is exceeded. + +config-top.h + - EXIT_ON_SETUID_FAILURE: new settable define, will cause the shell to + exit if setuid fails with errno == EAGAIN + + 6/10 + ---- +parse.y + - time_command_acceptable: fix so time is accepted everywhere the + grammar is looking for a `compound_list'. Fixes bug reported by + Dale Worley + + 6/12 + ---- +subst.c + - clear_fifo_list: new function, clears FDs associated with open pipes + in current FIFO list without closing the file descriptors. Can + possibly be used when shell_execve fails and the shell jumps back + to top_level and we don't want the shell to close the open FIFOs + each time through the read-execute loop. Bug reported by Harald + Koenig + + + 6/16 + ---- +builtins/shopt.def + - compat42: make sure the `compat42' option sets the correct variable + for compatibility level. Fixes bug reported by Ondrej Oprala + + +support/bashbug.sh + - fix typo when echoing $USAGE. Report from Shantanu Kulkarni + + +execute_cmd.c + - shell_execve: before longjmp back to subshell_top_level, clear out the + FIFO fd list by calling clear_fifo_list so the FDs (which we inherited + from our parent) aren't closed every time through the read-eval loop. + Fix for bug reported by Harald Koenig + + 6/18 + ---- +subst.c + - extract_process_subst: add additional argument: xflags, allow callers to + pass flags like extract_command_subst + - extract_process_subst: call xparse_dolparen like command substitution + to avoid problems when parsing commands constructs with embedded open + parens. Fixes bug reported by Tim Friske + +subst.h + - extract_process_subst: modified prototype for extern declaration + + 6/19 + ---- +execute_cmd.c + - execute_pipeline: if running with lastpipe enabled, make sure that we + check whether or not the job id is valid using INVALID_JOB before + calling job_exit_status. the jobs list can get frozen and unfrozen in + the presence of nested pipelines and loops and wait_for can clear a + job table entry. Fixes bug reported by + +jobs.c + - freeze_jobs_list: now returns old value of jobs_list_frozen; unused at + current time + +jobs.h + - freeze_jobs_list: change return value + + 6/20 + ---- +lib/glob/smatch.c + - MEMCHR: single-byte and wide character defines (memchr/wmemchr) + +lib/glob/sm_loop.c + - GMATCH: when the wildcards are the last element of the pattern, make + sure they do not match a string containing a `/' if FNM_PATHNAME is + set in FLAGS + - GMATCH: when recursively calling GMATCH after we see a `*', don't + try to consume the rest of the pattern with `*' if FNM_PATHNAME is + set in FLAGS, just consume up to the next slash and then see whether + or not the rest of the pattern matches. Fixes bug reported by Ian + Kelling + - GMATCH: when processing `*' in the pattern, after skipping consecutive + wildcards, if we hit a literal `/' in the pattern and we're looking + for a pathname, skip characters in the string until we find a `/' + (no slash means the match fails), and try to match the rest of the + pattern against the portion of the string after the next `/'. Picked + up from gnulib/glibc + +pathexp.c + - split_ignorespec: since split_ignorespec gets globbing patterns, + make sure we call skip_to_delim with the SD_GLOB flag so delimiters + that occur within bracket expressions don't delimit the pattern. + Fixes problem with [[:digit:]] in GLOBIGNORE reported by Ian Kelling + + +unwind_prot.c + - unwind_protect_tag_on_stack: new function, returns 1 if unwind-protect + frame corresponding to `tag' argument is on unwind-protect stack + +unwind_prot.h + - unwind_protect_tag_on_stack: extern declaration + + 6/30 + ---- +lib/readline/misc.c + - _rl_revert_all_lines: set entry->data to 0 after assigning it to + rl_undo_list to avoid pointer aliasing problems that would result + in entry->line being freed by an undo. The subsequent free would + be a double free. Report and fix from Jared Yanovich + + +subst.c + - command_substitute: other shells do not appear to inherit the -v + option when reading and executing command substitutions. Reported + by Ondrej Oprala + + 7/1 + --- +config-top.h + - CHECKHASH_DEFAULT: new define that supplies the default value for + check_hashed_filenames (`checkhash' shopt option); still 0 by default + +findcmd.c + - check_hashed_filenames: initialize using CHECKHASH_DEFAULT + +lib/readline/histexpand.c + - history_expand: double quotes can inhibit recognition of the history + comment character if history_quotes_inhibit_expansion is non-zero + +lib/readline/doc/{history.3,hstech.texi} + - history_quotes_inhibit_expansion: expand definition to note that it + inhibits scanning for the history comment character as well; correct + typo to make it clear that it only works on double-quoted strings + +lib/sh/zgetline.c + - add new fourth argument: DELIM, allows delimiter to be something + other than newline (if DELIM != '\n', UNBUFFERED_READ should be + non-zero) + - UNBUFFERED_READ is now fifth argument + - check character against DELIM rather than strictly newline + +externs.h + - zgetline: change function prototype for extern declaration + +builtins/mapfile.def + - mapfile: change calling sequence for zgetline calls + - mapfile_builtin: new -d option: DELIM, like in read builtin + - mapfile_builtin: pass `delim' to mapfile() as new argument; default + to '\n' unless -d option supplied + - mapfile: take new DELIM argument, pass to zgetline + - mapfile: if DELIM != '\n', set unbuffered_read to 1 + +doc/{bash.1,bashref.texi} + - mapfile: document new `-d DELIM' option + + 7/5 + --- +lib/readline/histfile.c + - history_truncate_file: if there is an error writing the truncated + history list back to the history file, use the same strategy as + history_do_write: create a backup file, rename the history file to + the backup file, and restore the original history file from the + backup file name if the write or the close fails. Suggestion from + Chen Gang to bug-readline + +execute_cmd.c + - evalnest, evalnest_max: new variables establishing maximum number of + recursive `eval' calls; current max is 4096 + - execute_builtin: unwind-protect value of evalnest around calls to + eval builtin. Suggested by Oliver Morais + - {initialize_subshell,execute_subshell_builtin_or_function}: reset + evalnest to 0 in a subshell + +builtins/setattr.def + - show_name_attributes: show a variable's attributes even if it's + invisible (don't show any value since it has none). This means that + declare -p var will display VAR's attributes even when var marked + as invisible. Feature request from Peggy Russell + + - show_var_attributes: don't print assignment if array or assoc + attribute is set but variable marked as invisible + +tests/array.right + - special note: changed all declare -a output tests because the shell + will no longer print out values for invisible array variables. This + is a change, but one for correctness: + + declare -a foo='()' + and + declare -a foo + are not equivalent + + 7/22 + ---- +subst.c + - parameter_brace_expand: after calling parameter_brace_expand_indir, + turn off the W_ARRAYIND flag in the word it returns, because there + is no way for it to return the index that should be used, and the + rest of the function assumes that IND is valid if W_ARRAYIND is set. + Fixes bug reported by Corentin Peuvrel + + 8/2 + --- +parse.y + - read_token_word: if we read a character that will end a command + substitution, don't skip over quoted newlines when we read an + additional character to figure out whether it's a two-character + token. This lets the higher layers deal with quoted newlines after + the command substitution. Fixes bug reported by EmanueL Czirai + + + 8/11 + ---- +execute_cmd.c + - execute_pipeline: check whether lastpipe_jid corresponds to a valid + job before calling append_process, for the same reason as fix from + 6/19. Fixes bug reported by + + 8/12 + ---- +lib/sh/unicode.c + - stub_charset: use strncpy instead of strcpy because we are copying + into a local fixed-length buffer. Fixes vulnerability reported by + + +execute_cmd.c + - execute_pipeline: if we don't call append_process, call + wait_for_single_pid to get the status of `lastpid', since that will + check the status of already-reaped processes. Fixes spurious error + message about non-existent process from fix of 8/11 + + 8/15 + ---- +jobs.c + - running_in_background: new variable, keeps track of whether or not we + are running in the background (not perfect yet) + - initialize_job_control: even if we are not turning on job control, + get the terminal pgrp so we can use it later + - {set_job_control,initialize_job_control}: set running_in_background + to 1 if terminal pgrp != shell pgrp + - {stop_pipeline,make_child,wait_for}: if we are running in the + background, don't mess with the terminal's process group; assume that + the parent shell will do that. Fixes bug reported by Greg Wooledge + + +shell.c + - shell_reinitialize: reset running_in_background back to 0 + + 8/24 + ---- +execute_cmd.c + - {execute_connection,execute_command_internal}: make sure that + asynchronous commands always set $? to 0 and are not affected by the + command's exit status being inverted using `!'. Fixes bug reported + by Vincent Lefevre + +lib/readline/display.c + - rl_message: call vsnprintf with full msg_bufsiz, since it counts + one fewer than the buffer length passed as an argument. Bug report + and fix from Dylan Cali + + 8/26 + ---- +builtins/evalstring.c + - evalstring: if CURRENT_TOKEN == yacc_EOF, reset it to newline. This + is instead of calling reset_parser(); that might still be needed. + Fixes bug with eval and a subsequent statement ending with EOF + reported by + +pcomplete.c + - filter_stringlist: when extglob is on, a leading ! in the filter + pattern should be left alone when it introduces a !(pat) pattern; + otherwise it messes up the pattern. Fixes bug reported by David + Korn + + 8/27 + ---- +doc/{bash.1,bashref.texi} + - clarify the behavior of bash when given the -c option, since $0 is + technically not a positional parameter. Bug reported by Stephane + Chazelas + + 8/28 + ---- +lib/readline/history.c + - add_history: use history_max_entries (if history is stifled) or + DEFAULT_HISTORY_INITIAL_SIZE if not (new define, defaults to 502) + to size the initial allocation of the history array. Assumption + is that this will reduce the number of allocations + + 8/29 + ---- +execute_command.c: + - sourcenest, sourcenest_max: new variables used to track level of + sourced files and (maybe) one day catch infinite source recursion + - execute_builtin: if current source level exceeds sourcenest_max, + trigger an error and jump back to the top level + - {initialize_subshell,execute_subshell_builtin_or_function}: reset + sourcenest to 0 in a subshell + + 9/2 + --- +variables.c + - bind_variable: if a nameref expands to an array reference, make + sure that assign_array_element gets called (maybe even + recursively) instead of bind_variable_internal, so invalid variable + names (like arr[0]) don't get created. Fixes bug reported by + + + 9/3 + --- +execute_cmd.c + - evalnest_max,sourcenest_max: initialize from EVALNEST_MAX and + SOURCENEST_MAX, respectively. Feature suggested by + + +config-top.h + - define EVALNEST_MAX and SOURCENEST_MAX to 0 + + 9/6 + --- +bashline.c + - find_cmd_start: fix to (crudely) deal with >| token; even though + skip_to_delim finds `|' as a delimiter, we call it again and use + what the second call finds. Fixes bug reported by Dan Jacobson + + +findcmd.c + - find_in_path_element: if in posix mode, do not expand a literal + tilde in a $PATH element + +doc/bashref.texi + - add change to tilde expansion in $PATH elements to posix mode + description + +builtins/common.h + - ISHELP: new define for builtins that do their own option parsing + and don't use internal_getopt(); checks whether argument is --help + - CHECK_HELPOPT: convenience define to help builtins that do their + own option parsing to check for --help with one line of code + - CASE_HELPOPT: convenience define to help builtins that use + internal_getopt() check for --help with one line of code + +builtins/help.def + - builtin_help: new function, prints out --help output for current + builtin + +builtins/{kill,let,pushd}.def + - add CHECK_HELPOPT to builtins that use ISOPTION; call builtin_help + and return EX_USAGE (kill/let/pushd/popd/dirs) + +builtins/{caller,fg_bg}.def + - use CHECK_HELPOPT to recognize --help, since these builtins perform + checks that can cause them to return before calling no_options + (caller/fg/bg) + +builtins/{exit,return}.def + - use CHECK_HELPOPT to recognize --help before calling get_exitstat() + (return/exit/logout) + +builtins/{break,shift}.def + - use CHECK_HELPOPT to recognize --help before any other checks + (break/continue/shift) + +builtins/bashgetopt.h + - GETOPT_EOF: convenience define + - GETOPT_HELP: new define, to indicate internal_getopt saw --help + +builtins/bashgetopt.c + - internal_getopt: return GETOPT_HELP for --help + +builtins/common.c + - no_options: recognize --help, call builtin_help and return 2 + (builtin/eval/source/./times) + +builtins/command.def + - use CASE_HELPOPT() to handle --help after calling internal_getopt() + (command) + +builtins/{colon,echo,test}.def + - do not recognize --help (:/true/false/echo/test) + + 9/8 + --- +sig.c + - termsig_sighandler: if readline is active now, set the bashline event + hook. Old code just set it for interactive shells. Part of fix for + bug reported by + +bashline.c + - bash_event_hook: call rl_cleanup_after_signal if terminating_signal + is non-zero, since check_signals_and_traps() will cause the shell to + exit if it is and we want to clean up the readline state first. Rest + of fix for bug reported by + + 9/9 + --- +jobs.c + - waitchld: when running the wait builtin in posix mode, with a trap set + on SIGCHLD, use queue_sigchld_trap instead of trap_handler (SIGCHLD), + otherwise you will lose SIGCHLDs when children_exited > 1. Fixes bug + reported by + +builtins/read.def + - read_builtin: if we are changing the tty settings, call + initialize_terminating_signals so we have a chance to catch all + terminating signals and potentially clean up the terminal before + exiting + - read_builtin: tty_modified: new variable, set to 1 if we change the + terminal attributes and have to call ttyrestore() to restore them + - if one of the `reads' returns -1/EINTR due to a terminating signal, + and we have modified the terminal, call ttyrestore before calling + CHECK_TERMSIG + - ttyrestore: set tty_modified to 0 when called + + 9/10 + ---- +builtins/read.def + - termsave: now global to file so other functions can use it + - read_tty_cleanup: if tty_modified is non-zero, call ttycleanup to + restore old terminal settings and turn off tty_modified + +sig.c + - termsig_handler: call read_tty_cleanup if currently executing read + builtin; it does the right thing. Final piece of fix for bug reported + by Jan Rome + + 9/11 + ---- +general.c + - printable_filename: general function to return a printable + representation of a string (presumed to be a filename) + +general.h + - extern declaration for printable_filename + +execute_cmd.c + - execute_disk_command: use printable_filename + +builtins/{bind,cd,enable,hash,source}.def + - use printable_filename as appropriate when printing error messages. + From a suggestion by Vincent Lefevre + +builtins/bind.def + - use CASE_HELPOPT() to handle --help after calling internal_getopt() + (bind) + + 9/12 + ---- +builtins/common.h + - SEVAL_FUNCDEF: new flag for parse_and_execute; it means that we only + accept a single function definition command, as when we are importing + functions from the environment + - SEVAL_ONECMD: new flag for parse_and_execute; for future use + +builtins/evalstring.c + - parse_and_execute: if the SEVAL_FUNCDEF flag is set, disallow anything + but a function definition command + +variables.c + - initialize_shell_variables: don't allow functions with invalid names + to be imported from the environment, even though we still allow them + to be defined + - initialize_shell_variables: when importing function definitions from + the environment, call parse_and_execute with the SEVAL_FUNCDEF flag + to force the command to be just a function definition + +subst.c + - param_expand: when expanding a $name variable expansion, make sure that + the variable is visible and set before following the nameref chain + - param_expand: when expanding a $name variable expansion and following the + nameref chain, make sure the resulting variable is visible and set + before using it + + 9/13 + ---- +variables.c + - initialize_shell_variables: when importing function definitions from + environment, use SEVAL_ONECMD flag for parse_and_execute. Part of + CVE-2014-6271 + +builtins/evalstring.c + - parse_and_execute: if SEVAL_ONECMD flag set, return immediately after + calling execute_command_internal. Final piece for fix for bug + reported by Stephane Chazelas . Part of + CVE-2014-6271 + + 9/24 + ---- +parse.y + - reset_parser: reset eol_ungetc_lookahead to 0 here, since we don't want + shell_getc returning it on the next call. Fixes problem reported by + Tavis Ormandy and Michal Zalewski + . Potentially part of CVE-2014-6271; fix for + CVE-2014-7169 + + 9/25 + ---- +parse.y + - push_heredoc: new function, pushes a here-doc redirection onto + redir_stack handling overflow of redir_stack. Exits on overflow. + Original fix from Florian Weimer . Fix for + CVE-2014-7186 + - change straight assignments to redir_stack to call push_redir + - add one to size of word_lineno stack to avoid off-by-one error + below in read_token_word. Overflow just results in line numbers + being wrong. Fix for CVE-2014-7187 + + 9/27 + ---- +{execute_cmd,trap}.c + - changes to make minimal-config builds work again, mostly missing + #ifdefs for optional features + +builtins/common.c + - builtin_help: dummy version to be included if HELP_BUILTIN not + defined, for minimal-config builds + +variables.c + - initialize_shell_variables: incorporated patches from Florian + Weimer to change the strings bash looks + for when importing shell functions from the environment. It + adds a prefix (BASH_FUNC_) and a suffix (%%) to the name to + mark it as having been created by bash as an exported function. + Fix for remote attacks part of CVE-2014-6271 and CVE-2014-7169 + - mk_env_string: takes new argument, indicating whether we are + constructing a function + - mk_env_string: encodes function names as described above, so + initialize_shell_variables can find them + + 9/28 + ---- +copy_cmd.c + - copy_redirects: before calling savestring on here_doc_eof, make + sure it's not NULL (it could have been the result of a here + document delimited by EOF or EOS). Fixes bug reported by + Michal Zalewski . Fix for CVE-2014-6277 + +make_cmd.c + - make_redirection: initialize here_doc_eof member to NULL. Rest of + fix for CVE-2014-6277 + + 9/29 + ---- +parse.y + - current_input_line_state: return a sh_input_line_state_t containing + the current shell_input_line and its index and size variables + +shell.h + - current_input_line_state: extern declaration + +builtins/evalstring.c + - parse_and_execute: call reset_parser() before returning if + SEVAL_ONECMD set. Fixes bug reported by Michal Zalewski + and designated CVE-2014-6278 + - parse_and_execute: if we parse a function definition when + SEVAL_FUNCDEF is set, but don't consume the entire passed string, + throw an error, reset the parser, and return. Part of fix for + CVE-2014-6278 + - parse_and_execute: if parsing the shell function definition when + SEVAL_FUNCDEF is set transforms the function name (e.g., if it + begins with a newline or begins or ends with whitespace), throw + an error, reset the parser, and return. Fixes bug reported by + Eric Kobrin + + 10/2 + ---- +jobs.c + - bgp_prune: don't do anything if bgpids.npid == 0 or + bgpids.list == NULL. This can happen if something gets run before + the job control framework is initialized. Bug report from + + + 10/3 + ---- +parse.y + - xparse_dolparen: don't set token_to_read to newline after calling + parse_string() and cleaning up when the shell is not interactive. This + makes the parser think it's ok to read new commands even if it's not in + a state where that should be possible. Underlying fix for bug reported + by Michal Zalewski and designated CVE-6278 + - parser_remaining_input: new function, returns the portion of + shell_input_line that hasn't yet been read + - current_input_line_state: removed + +shell.h + - parser_remaining_input: extern declaration + - current_input_line_state: removed + +builtins/evalstring.c + - parse_and_execute: change code that checks whether parse_command has + consumed the entire passed string when SEVAL_FUNCDEF is used to use + parser_remaining_input instead of messing around with (new) + current_input_line_state. Part of fix for CVE-2014-6278 + +variables.c + - initialize_shell_variables: if we don't call parse_and_execute, free + the temporary string, since parse_and_execute won't. Report and fix + from Eric Kobrin + + 10/4 + ---- +print_cmd.c + - print_function_def: when in posix mode, print shell function + definitions as posix specifies them, without the leading + `function' keyword + +general.c + - exportable_function_name: return 1 if the passed string can be + added to the environment as an exported function name. Currently + prohibits function names containing `/' and `=' from being + exported + +general.h + - exportable_function_name: extern declaration + +builtins/setattr.def + - set_or_show_attributes: if exporting a function with export -f, + call exportable_function_name to determine whether the function + should be exported; don't export function if it returns 0 + + 10/7 + ---- +builtins/setattr.def + - set_or_show_attributes: don't show identifiers that are invisible + and imported from the environment, since that combination of + attributes means that the imported variable is not a valid shell + identifier. Report from Stephane Chazelas + + + 10/8 + ---- +shell.c + - shell_initialize: set new variable should_be_restricted, which + says whether or not the shell will be a restricted one based on the + shell name; use in calls to initialize_shell_variables (to inhibit + importing shell functions) and initialize_shell_options (to inhibit + parsing $SHELLOPTS) and initialize_bashopts (to inhibit parsing + $BASHOPTS). Report from + + 10/12 + ----- +execute_cmd.c + - execute_function: unwind-protect loop_level, set loop_level to 0 + when entering a function so break and continue in functions don't + break loops running outside of the function. Fix picked up from + dash via Herbert Xu + + 10/13 + ----- +doc/Makefile.in + - bashref.pdf: create using texi2dvi --pdf rather than postprocessing + the dvi file, so we have PDF bookmarks and links. Fix from + Siep Kroonenberg + + 10/14 + ----- +subst.h + - Q_ARITH: new quoting flag. Semantics are per Posix's spec for + arithmetic expansion: act as if string is quoted, but don't treat + double quotes specially (in this case, they will be removed by quote + removal) + - Q_ARRAYSUB: new quoting flag, indicates we are expanding an indexed + array subscript + +subst.c + - expand_arith_string: if we are not expanding the string, but we saw + a quote with Q_ARITH specified as one of quoting flags, perform + quote removal even if Q_DOUBLE_QUOTES is specified + - param_expand: change calls to expand_arith_string for $[ and $(( + cases to specify Q_ARITH. Now $(( "$x" )) and $(( "x" )) work if x + has a value that evaluates to a valid number, as Posix specifies + - expand_word_internal: add test for quoted&Q_ARITH to the tilde case, + so we continue to perform tilde expansion in arithmetic contexts + - expand_word_internal: if quoted&Q_ARITH, continue processing when we + see a `"', acting as if the double quote isn't present (already + Q_DOUBLE_QUOTED) + +arrayfunc.c + - array_expand_index: pass Q_DOUBLE_QUOTED|Q_ARITH|Q_ARRAYSUB as quoted + argument in call to expand_arith_string. This inhibits word + splitting (Q_DOUBLE_QUOTED) while discarding double quotes (Q_ARITH), + identical to the quote flags passed while expanding $(( )) and $[ ]. + Q_ARRAYSUB reserved for future use. Fixes problem reported by + Stephane Chazelas + + 10/16 + ----- +subst.c + - parameter_brace_expand_word: if the PF_ASSIGNRHS flag is set and we + are expanding what looks like an array subscripted with @ or *, + make sure the variable we're expanding is actually an array before + we add Q_DOUBLE_QUOTES to the flags. If we don't, things like + scalar[@] will remain quoted. Fixes ubuntu bug 1381567 + https://bugs.launchpad.net/ubuntu/+source/bash/+bug/1381567 + + 10/17 + ----- +{jobs,nojobs}.c + - get_original_tty_job_signals: get original signal dispostions for + SIGTSTP, SIGTTIN, SIGTTOU before we start manipulating them in + make_child + - default_tty_job_signals: make sure we set SIGTSTP, SIGTTIN, or + SIGTTOU to SIG_IGN if they were ignored at shell startup instead of + unconditionally setting them to SIG_DFL. Fixes bug reported by + idallen@idallen.ca + +jobs.h + - get_original_tty_job_signals: extern declaration + +trap.c + - initialize_traps: add call to get_original_tty_job_signals + + 10/22 + ----- +subst.c + - expand_string_for_rhs: when expanding in this context (rhs of a word + expansion or pattern removal), we don't perform word splitting, so + we don't want to split $* if IFS is empty. Fixes bug reported by + Stephane Chazelas + + 10/23 + ----- +subst.c + - param_expand: when expanding $* in a pattern context where the + expansion is quoted (Q_PATQUOTE), don't quote the expansion -- + the outer quotes don't make the characters in the expansion of + $* special. Posix interp 221. Reported by Stephane Chazelas + + + 10/28 + ----- +lib/readline/bind.c + - enable-bracketed-paste: new bindable variable, enables support for + a terminal's `bracketed paste mode'. Code contributed by + Daniel Colascione + +doc/bash.1,lib/readline/doc/{readline.3,rluser.texi} + - enable-bracketed-paste: add description + +lib/readline/{readline.c,rlprivate.h} + - _rl_enable_bracketed_paste: declarations + - #defines for use by bracketed paste implementation + +lib/readline/rltty.c + - rl_prep_terminal: send BRACK_PASTE_INIT string to terminal if we + are supposed to enable bracketed-paste mode; change terminal_prepped + to indicate we sent that string and need to clean up + - rl_deprep_terminal: if terminal_prepped indicates we sent the + bracketed-paste mode init string to the terminal, send the cleanup + string before restoring the terminal modes + +lib/readline/kill.c + - rl_bracketed_paste_begin: function to read bracketed paste until + BRACK_PASTE_SUFF; discard the suffix, and insert the rest of the + paste as a single (undoable) object. Bound to BRACK_PASTE_PREF + +lib/readline/funmap.c + - bracketed-paste-begin: new bindable command, executes + rl_bracketed_paste_begin + +lib/readline/readline.c + - bind_bracketed_paste_prefix: new function, sets up to recognize + the bracketed paste prefix sequence (BRACK_PASTE_PREF) in emacs + keymap and vi insertion keymap + - readline_initialize_everything: call bind_bracketed_paste_prefix + + 11/1 + ---- +builtins/ulimit.def + - RLIMIT_POSIXLOCKS: now synonym for RLIMIT_LOCKS + - -k: new option: RLIMIT_KQUEUES, max kqueues allocated for this + process + - -P: new option: RLIMIT_NPTS, max number of pseudoterminals available + to this process + +doc/{bash.1,bashref.texi} + - document `ulimit -k' option + - document `ulimit -P' option + +parse.y + - `timespec list_terminator' production: if the list terminator is `;' + set last_read_token to `;' to allow things like `time ; command' to + time null commands and not throw a syntax error. Patch from + Piotr Grzybowski + - `BANG list_terminator' production: do the same thing + +variables.c + - sv_optind: use find_shell_variable and get_variable_value so we can + have the variable's context in the case we need to do something + when we are restoring a previous variable context's value + +builtins/getopt.h + - sh_getopt_state_t: struct to save sh_getopt's internal state so we + can restore it around function calls in the event that we have a + local copy of OPTIND + +builtins/getopt.[ch] + - sh_getopt_{save,restore}_istate: new functions to save and restore + getopt's internal state + - sh_getopt_{alloc,dispose}_istate: new functions to allocate and + deallocate sh_getopt_istate_t objects + +execute_cmd.c + - maybe_restore_getopt_state: restore sh_getopt state after executing + function body iff the funtion declared a local copy of OPTIND + - execute_function: save sh_getopt state before executing function body + - execute_function: note in getopt_state->flags whether or not the + function declared a local copy of OPTIND; used by + maybe_restore_getopt_state + - execute_function: maybe restore sh_getopt state before returning via + call to maybe_restore_getopt_state. Fixes bugs with getopts and + state between calls reported in 2011 by Bernd Eggink + and in 2014 by Oyvind Hvidsten + + +configure.ac + - enable-function-import: new option, controls whether function imports + are included. Enabled by default. Patch from David Galos + + +config.h.in + - FUNCTION_IMPORT: define controlled by enable-function-import above + +variables.c + - initialize_shell_variables: include code to import function + definitions from the environment if FUNCTION_IMPORT is defined + +doc/bashref.texi + - --enable_function-import: document new configuration option + + 11/5 + ---- +lib/readline/history.c + - history_lines_read_from_file: new variable, set by read_history and + read_history_range to the actual number of lines read from the + history file. The value is valid immediately after a call to one + of those functions + - history_lines_written_to_file: new variable, set by write_history, + history_do_write, and history_truncate_file to the actual number of + lines written to the history file. The value is valid immediately + after a call to one of those functions + +variables.c + - sv_histsize: set history_lines_in_file after history_truncate_file() + only if hmax < history_lines_in_file (lines we've already read); a + cosmetic change only + +bashhist.c + - load_history: set history_lines_in_file after read_history() from + history_lines_read_from_file, since read_history reads all of the + lines from the history file even if it's more than $HISTSIZE + - maybe_save_shell_history: after calling write_history(), set + history_lines_in_file to history_lines_written_to_file, since we + can assume that we read everyhing we just wrote + +builtins/history.def + - history_builtin: after calling read_history (history -r), set the + new value of history_lines_in_file, for the same reason as above + - history_builtin: after calling read_history_range (history -n), set + history_lines_in_file from history_lines_read_from_file + + 11/6 + ---- +lib/readline/histfile.c + - history_truncate_file: since we move the old file to a backup copy + before truncating, make sure the new file is owned by the same uid + as the old + - history_do_write: use chown in the same way as history_truncate_file + + 11/12 + ----- +lib/readline/display.c + - expand_prompt: takes a new `flags' argument; only one flag defined + so far: PMT_MULTILINE + - expand_prompt: changed all callers to add new flags argument + - rl_expand_prompt, redraw_prompt: make sure to set PMT_MULTILINE in + FLAGS argument to expand_prompt if expanding parts of a prompt + containing embedded newlines + - expand_prompt: only add mode char to last line of a prompt with + embedded newlines, so mode indicator doesn't get lost and gets + updated properly. Fixes problem reported by Renlin Li + + + 11/13 + ----- + +lib/readline/display.c + - prompt_modestr: changed prompt_modechar to return a string denoting + the editing mode; default strings for emacs and both vi modes are + #defines in this file. prompt_modestr takes an argument in which + it returns the length of the mode string + - expand_prompt: if expanding mode strings in the prompt, get the + mode string to use and add it at the beginning of the prompt string, + before expanding it. This will allow future work allowing the mode + string to contain invisible characters + + 11/15 + ----- +lib/readline/rlprivate.h + - _rl_{emacs,vi_cmd,vi_ins}_mode_str: extern declarations for + variables to hold current values of user-settable mode strings; + variables to hold lengths + +lib/readline/rlconf.h + - defines for default values of the mode strings for each editing mode + and keymap + +lib/readline/display.c + - _rl_{emacs,vi_cmd,vi_ins}_mode_str: new variables to hold values of + user-settable mode strings + - _rl_{emacs,vi_cmd,vi_ins}_modestr_len: new variables to hold lengths + of corresponding mode string variables + - prompt_modestr: return appropriate user-settable mode string + variables + +lib/readline/bind.c + - {emacs,vi-ins,vi-cmd}-mode-string: new user-settable mode string + variables + - sv_{emacs,viins,vicmd}_modestr: variable handling functions for user- + settable mode string variables. Non-null values are run through + rl_translate_keyseq so users can include invisible character + sequences in the mode strings; null values restore the default + - _rl_get_string_variable_value: handle values for new user-settable + mode string variables. Original code contributed by Dylan Cali + + +lib/readline/doc/rluser.texi + - {emacs,vi-ins,vi-cmd}-mode-string: document, including the fact that + you can use \1 and \2 to bracket sequences of non-printing + characters + + 11/16 + ----- +lib/readline/history.c + - add_history: replace loop that copies history list down one item + with call to memmove to take advantage of whatever efficiencies + libc can offer. Won't be any slower than current loop + +lib/readline/display.c + - rl_redraw_prompt_last_line: new function, calls redraw_prompt if + the prompt contains multiple lines; calls rl_forced_update_display + if not + +lib/readline/readline.h + - rl_redraw_prompt_last_line: extern declaration, undocumented in + texinfo manual until I get it a little more work + +bashline.c + - bash_execute_unix_command: instead of unconditionally calling + rl_forced_update_display, call rl_redraw_prompt_last_line if we + cleared the last line before executing the command. This keeps + commands that don't display any other output but just manipulate + the contents of the line buffer from redisplaying the prompt lines + before the last newline multiple times. Fixes bug reported by + Jesper Nygards and Rob Foehl + . This means that commands that display output + will *only* display the final line of the prompt + - bash_execute_unix_command: if the command returns 124, we redraw + the line unconditionally, including all lines of the prompt + + 11/18 + ----- +builtins/mapfile.def + - mapfile_builtin: don't allow a valid array reference through to + mapfile(), since it will just create a shell variable with that name. + Bug and fix from Eduardo A. Bustamante López + + 11/19 + ----- +lib/readline/complete.c + - _rl_colored_completion_prefix: new variable, if non-zero, and color + support is compiled in, and the $LS_COLORS variable exists and + contains color definitions, display any common prefix of a set of + completions in blue when displaying all the possible completions. + Doesn't work with menu-complete, which inserts possible completions + inline + - colored_prefix_start(), colored_prefix_end(): new functions, used to + bracket colored completion prefixes + - fnprint: if prefix_bytes is non-zero, and _rl_colored_completion_prefix + is > 0, display the first PREFIX_BYTES bytes of the word bracketed + by calls to colored_prefix_start and colored_prefix_end + - print_filename: if _rl_colored_completion_prefix is > 0, compute the + length in bytes of the common prefix and pass that to fnprint + +lib/readline/readline.c + - readline_initialize_everything: initialize the colors from $LS_COLORS + if _rl_colored_completion_prefix is non-zero + +lib/readline/colors.c + - _rl_print_prefix_color: new function, changes text color to that + defined for the common prefix of a set of possible completions + (currently cyan, same as directories); currently uses C_PREFIX, + defined in colors.h as C_DIR + +lib/readline/colors.h + - _rl_print_prefix_color: new extern declaration + +lib/readline/bind.c + - colored-completion-prefix: new bindable variable, if set, common + prefix of a set of possible completions is displayed in color. + Feature requested by several, most recently by Richard Neill + (in a slightly different form) and + Duy Nguyen + + 11/20 + ----- +builtins/printf.def + - printf_builtin: allow null (empty) format strings supplied with + -v var to set `var' to the empty string. That is, printf -v var "" + is now the same as var="". Change suggested by Mike Frysinger + + +pathexp.h + - FNMATCH_NOCASEGLOB: macro to decide whether or not to pass + FNM_CASEFOLD flag to strmatch depending on whether glob_ignore_case + is set; analogout to FNMATCH_IGNCASE + +pathexp.c + - glob_name_is_acceptable: use FNMATCH_NOCASEMATCH to determine flags + passed to strmatch; if nocaseglob is used to generate glob matches, + it should be used to generate ignored matches + + 11/21 + ----- +pcomplete.c + - filter_stringlist: the call to strmatch now honors the setting of + nocasematch. Feature request from Ville Skytta + back in 2010 + +doc/bash.1,lib/readline/doc/rluser.texi + - complete -X: document that filtering the list of possible completions + honors the nocasematch option when performing matching + +lib/glob/gmisc.c + - include chartypes.h and strmatch.h for new defines + - match_pattern_{wchar,char}: now take new third FLAGS argument, flags + have same meanings as strmatch(); intent is to handle case + insensitive comparisons under same conditions as strmatch + - FOLD: imported case-folding define from sm_loop.c; wide and single- + byte character versions + - match_pattern_{wchar,char}: use FOLD when comparing characters to + honor FNM_CASEFOLD if set in FLAGS argument + +externs.h + - match_pattern_{wchar,char}: updated extern declarations + +subst.c + - match_{upattern,wpattern}: update strmatch/wcsmatch calls to include + FNMATCH_IGNCASE in flags argument + - match_{upattern,wpattern}: update match_pattern_{char,wchar} calls + to include FNMATCH_IGNCASE in flags argument (consistent with calls + to strmatch). This makes pattern substitution word expansion honor + nocasematch shell option. Feature requested by Davide Baldini + + - match_wpattern: make sure to fold case if necessary when doing simple + matching + +doc/{bash.1,bashref.texi} + - pattern substitution: updated description to include honoring setting + of nocasematch when performing matching + +subst.c + - expand_word_internal: optimize handling of "$@" idiom by calling + list_rest_of_args() and quote_list() directly at the top of the + function instead of going through normal code path + - cached_quoted_dollar_at: WORD_LIST of quoted positional parameters, + used by same code above that optimizes "$@"; if non-null we just + return a copy of the list; if null, we save a copy of the list we + create + - invalidate_cached_quoted_dollar_at: convenience function to allow + other parts of the shell (e.g., remember_args()) to destroy the + cached list of quoted positional parameter when the positional + parameters change + +builtins/common.c + - remember_args: call invalidate_cached_quoted_dollar_at() + +builtins/shift.def + - shift_builtin: call invalidate_cached_quoted_dollar_at after modifying + dollar_vars[] + +builtins/source.def + - maybe_pop_dollar_vars: call invalidate_cached_quoted_dollar_at just + to be safe + + 11/23 + ----- +builtins/evalfile.c + - _evalfile: return -1 if errno == ENOENT and the flags don't include + FEVAL_ENOENTOK. If we print an error message we should return an + error + - force_execute_file: new function, reads and executes commands from + a file but returns an error if file doesn't exist + +builtins/common.h + - force_execute_file: new extern declaration + +shell.c + - main: call start_debugger even if dollar_vars[1] == 0 if the shell + isn't interactive (interactive_shell == 0) + - start_debugger: call force_execute_file instead of maybe_execute_file; + turn off debugging mode if it returns value < 0 + + 11/24 + ----- +hashlib.h + - DEFAULT_HASH_BUCKETS: doubled to 128, cost in memory use is small but + changes traversal order when not sorting results + + 11/25 + ----- +doc/{bash.1,bashref.texi} + - make it clearer, by breaking it out into a separate paragraph, that + referencing an array without a subscript is equivalent to referencing + it with subscript 0 + - add text saying that referencing any variable using a valid subscript + is OK + + 11/28 + ----- + +arrayfunc.c + - bind_array_variable, bind_assoc_variable: allow binding value to a + readonly variable if the ASS_FORCE flag is set in the FLAGS + argument + +subst.h + - ASS_FORCE: new assignment flag; means to allow assignment even if + variable is marked readonly + +builtins/declare.def + - when assigning a value to an array or assoc variable using + something like `declare -r foo=bar' where foo is an existing array + variable, pass the ASS_FORCE to assign_array_var_from_string so + the assignment is allowed. Fixes debian bug 765759 + http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=765759 + +builtins/setattr.def + - var_attribute_string: new function to return (as argument) a char + array with attribute flag values for a given variable; returns the + length of the array + +lib/sh/shquote.c + - sh_quote_reusable: function returning a version of its string + argument that is quoted for reuse + +externs.h + - sh_quote_reusable: extern declaration + +builtins/common.h + - MAX_ATTRIBUTES: define used to size arrays for attribute flag + characters + - var_attribute_string: new extern function declaration + +subst.c + - array_remove_pattern: fixed a bug where `var' instead of `v' was + tested for invisible attribute + - get_var_and_type: fill in a valid *VARP if returning VT_VARIABLE + because callers may need to use it + - parameter_brace_transform: family of functions to implement the new + mksh-inspired ${param@spec} transformation word expansions. Some + of the operators transform the (expanded) value of the parameter, + the rest expand to information about the parameter itself + (array_transform, parameter_list_transform, list_transform, + string_transform, pos_params_assignment, array_var_assignment, + string_var_assignment) + - parameter_brace_expand: changes to parse the new `@' word expansion + operator and call parameter_brace_transform appropriately + - parameter_brace_expand: make sure we handle ${#@} as we have before + even in the presence of the new `@' operator + +variables.c + - push_temp_var: make sure to call bind_variable_internal with the + ASS_FORCE flag so we override readonly variables created with + something like `tempvar=foo declare -r foo'. + - bind_variable_internal: honor ASS_FORCE flag to allow binding even + if a variable is readonly + +execute_cmd.c + - struct func_array_state: new state to save state of BASH_LINENO, + BASH_SOURCE, and FUNCNAME during function execution so it can be + restored on a jump to top level + - restore_funcarray_state: new function to restore func_array_state + - execute_function: fill in func_array_state variable, add unwind- + protect to restore it on jump to top level, call explicitly at + end of function if subshell != 0 (may not be necessary, but safe + for now). Fixes bug with local assignments to FUNCNAME reported + by Arfrever Frehtes Taifersar Arahesis + + 11/29 + ----- +arrayfunc.c + - assign_compound_array_list: turn off ASS_APPEND flag when processing + each individual assignment inside the parens in var+=(...). The + outer += should not affect assignments to existing subscripts; + those should be treated like usual assignments unless += supplied + inside the parens. Bug report from Maarten Billemont + , fix from Eduardo A. Bustamante López + + +config.h.in + - HAVE_PSELECT: define if pselect(2) available + +configure.ac + - check for pselect(2), define HAVE_PSELECT if found + +lib/readline/input.c + - rl_getc: use pselect(2) to wait for input ready on readline's + input fd or for a signal to arrive, will handle SIGWINCH (which + does not interrupt read(2)) and thus allow resize to happen without + having to wait to read more input. Only works if pselect available + and returns -1/EINTR on a signal even if the signal was installed + with SA_RESTART. From a suggestion from Egmont Koblinger + + + 12/3 + ---- +variables.c + - flush_temporary_env: new function, disposes all temp variables in + temporary_env hash table + - bind_variable: only try to update a temporary variable's value in the + temporary env if the value argument is not null. Fixes bug reported + by + +variables.h + - flush_temporary_env: new extern declaration + +subst.c + - command_substitute: if running command substitution as part of + expanding a redirection (expanding_redir == 1), flush any temporary + environment we've inherited as part of this command, since we are not + supposed to have access to the temporary environment. Since + expanding_redir only controls access to the temporary environment for + variable lookup and binding, we can turn it off in the subshell + + 12/4 + ---- +builtins/printf.def + - printstr: make sure a missing precision specifier after a `.' is + treated as 0, as printf(3) specifies. Fixes ubuntu bash bug + 1399087 (https://bugs.launchpad.net/ubuntu/+source/bash/+bug/1399087) + + 12/5 + ---- +subst.c + - skip_to_delim: if scanning past process substitution (skipcmd == 1, + noprocsub == 0), use extract_delimited_string instead of + extract_process_subst, which was changed a while back (bash-4.3.23) + to use xparse_dolparen. xparse_dolparen complains if the command + or process substitution is unterminated, since it runs the parser, + which is not what we want here. Command substitution does the same + thing. Fixes bug reported by Daniel Kahn Gillmor + as Debian bash bug 771968 + (https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=771968) + + 12/6 + ---- +subst.c + - command_substitute: short-circuit without forking on a command string + that consists entirely of s and newlines + +jobs.c + - make_child: changes to allow interrupts through if fork fails and + we are sleeping for `forksleep' seconds + - waitchld: make things a little more resilient if CHILD ends up NULL + + 12/12 + ----- +lib/readline/complete.c + - rl_display_match_list: when calculating common prefix to display in + color, make sure we correctly handle a common prefix with a trailing + `/' as we do when checking whether or not to add an ellipis. + printable_part() doesn't return the whole pathname if it ends in a + slash, to avoid printing null strings, so we have to make sure we + have the entire prefix + +lib/readline/complete.c + - _rl_complete_display_matches_interrupt: new variable, set to 1 by + _rl_complete_sigcleanup to let rl_display_match_list know it has + freed the match list + - display_matches: check for signals during the printing loops with + RL_SIG_RECEIVED(), return immediately if there is a pending signal + (might not want to do this if it's SIGWINCH -- CHECK) + - rl_complete_internal: if _rl_complete_display_matches_interrupt + set after calling display_matches, just null out `matches' since + it's already been freed and call any application-set signal hook + + 12/14 + ----- +parse.y + - time_command_acceptable: if the token before a newline is `|', + return 0, since it's not really valid to time inside a pipeline. + Only handles a single newline but allows things like + echo a | + time cat + to invoke /usr/bin/time, which is probably enough to catch the + stray carriage return. Fixes bug reported by Andre Majorel + + +builtins/declare.def + - declare_internal: don't try to perform compound assignments unless + the WORD_DESC has flags including W_COMPASSIGN (maybe should check + W_ASSIGNMENT as well), avoiding unexpected evaluation if a word + is of the form (word) and is assigned to an array variable like so: + declare -x var=$value. Bug reported by Stephane Chazelas + . Will eventually be contingent on + compatibility level > 43, but not there yet. TENTATIVE + + 12/15 + ----- +lib/sh/Makefile.in + - add missing dependencies for shmatch.o. Pointed out by Sergey + Mikhailov + + 12/16 + ----- +{execute_cmd,subst}.c + - W_ASSIGNINT: remove, not used any more + +execute_cmd.c + - fix_assignment_words: don't look for `-i' option and set W_ASSIGNINT + flag any more; doing things a different way + - shell_expand_word_list: instead of using W_ASSIGNINT flag, since it + doesn't take into account all options that can transform values on + assignment (-l/-u/-c can also), go through option arguments looking + for options that need special handling and add them to the `opts' + array for make_internal_declare to use. Fixes bug with constructs + like `declare -al foo=(UPONE UPTWO UPTHREE)' not being lowercased on + assignment reported by Linda Walsh + + + + 12/18 + ----- +lib/readline/readline.c + - rl_internal_char: when we read EOF on a non-empty line, check for + signals and invoke any readline signal handling and any application- + installed signal hook + + 12/20 + ----- +lib/readline/readline.c + - rl_internal_char: if we read EOF on a non-empty line, set c to + _rl_eof_char the first time through. If we read EOF the next time, + return EOF from readline(). If callbacks are defined, this returns + EOF immediately, since lastc isn't available. Fix for problem + most recently identified by Jiri Kukacka , + it has come up in the past + + 12/21 + ----- +builtins/declare.def + - declare_internal: keep track of whether or not an assignment statement + argument to declare is an array subscript assignment; need to + differentiate assignments from straight declarations (declare a[4]) + which are accepted for backwards compatibility + - assignment statements like declare a[2]=foo are now treated as + straight subscript assignment statements if a already exists as an + array variable + - declare foo='(1 2 3)' is treated as an assignment to foo[0] if foo + exists and is an array, just as it would be if it were an assignment + statement and `declare' was not present. All this from a proposal + by Stephane Chazelas + + 12/22 + ----- +builtins/read.def + - read_tty_modified: function to tell the rest of the shell if the + read builtin has modified the tty + - read_builtin: make sure to initialize terminating signals before + installing a SIGALRM signal handler in case we modify the tty as + well as ask for a timeout; the subsequent call to + initialize_terminating_signals would overwrite the read-builtin- + local SIGALRM handler + +builtins/common.h + - read_tty_modified: new extern declaration + +shell.c + - exit_shell: if read_tty_modified() returns true, call read_tty_cleanup + to undo the terminal modifications. Extension of previous fixes; + fixes bug with read -s reported by Richard W. Marsden + + + + 12/23 + ----- +builtins/setattr.def + - show_var_attributes: call print_array_assignment and print_assoc_assignment + with a `not quoted' flag so the assignment statements are not + surrounded by single quotes. Caused changes to a lot of test output + + 12/29 + ----- +lib/readline/complete.c + - stat_char: Windows doesn't handle X_OK flag to access(2); use file + extensions to determine whether or not a file is executable. Bug + report and fix from Eli Zaretskii + +configure.ac + - changed version to bash-4.4-devel + +lib/readline/readline.h + - changed version to readline-6.4 + + 12/30 + ----- +readline.h + - struct readline_state: fix types of `ignorefunc' and `attemptfunc' + members + +lib/sh/shquote.c,externs.h + - sh_contains_shell_metas, sh_contains_quotes: now take `const char *' + as parameter + +stringlib.c,externs.h + - strcreplace: `text' argument now `const char *' + +pathexp.[ch] + - quote_globbing_chars: `string' argument now `const char *', accompanying + changes to function local variables + +pcomplete.c + - preproc_filterpat: `text' argument now `const char *' + - filter_stringlist: `text' argument now `const char *' + + 12/31 + ----- +builtins/evalstring.c + - should_suppress_fork: new function, broke code that decides whether + to turn on CMD_NO_FORK flag out of parse_and_execute into a separate + function + +execute_cmd.c + - execute_command_internal: AND_AND, OR_OR: call should_suppress_fork + for the RHS of && and ||, make `make' invocations marginally more + efficient + +flags.c + - get_current_flags: returns a bitmap of all single-letter shell + options with a non-zero value meaning option is enabled + - set_current_flags: set current single-letter options from a passed + bitmap, which has presumably been initialized with get_current_flags + +flags.h + - {get,set}_current_flags: new extern declarations + +builtins/declare.def + - declare_internal: if invoked as `local', interpret name argument of + `-' to mean to save (and restore at shell return) single-letter + shell options + +variables.c + - push_func_var: if we encounter `-' as the name of a local variable, + take the value and call set_current_flags on it to restore old + flag settings + +builtins/set.def + - get_current_options: returns a bitmap of all shell options settable + with `set', with a non-zero value meaning option is enabled + - set_current_options: set current shell options from a passed + bitmap, which has presumably been initialized with get_current_options + + + 1/1/2015 + -------- +lib/readline/parens.c + - _rl_blink_matching_paren: initialize to 0 whether or not select(2) is + available. Inconsistency reported by Mark Karpov + + +builtins/declare.def + - declare_internal: use get_current_options instead of + get_current_flags, so `local -' can be generalized + +variables.c + - push_func_var: use set_current_options instead of set_current_flags + so `local -' can be generalized + +doc/{bash.1,bashref.texi} + - document new `local -' feature; originally inspired by Robert Elz + describing feature in NetBSD sh + + 1/3 + --- +lib/readline/{complete,funmap,kill,histfile,util} +lib/readline/readline.h +lib/tilde/tilde.c + - fixes for filename- and evironment-related issues on Windows. Fixes + from Eli Zaretskii + - Windows can paste to the console from the clipboard like Cygwin + - Windows uses $APPDATA as a pseudo-$HOME + +lib/readline/input.c + - rl_getc: use _getch on Windows to avoid being overridden by a getch + ncurses function + - win32_isatty: replace Windows isatty(3) with a function that does + additional checks, sinces Windows isatty returns non-zero for + every character device. From Eli Zaretskii + +lib/readline/display.c + - delete_chars: if compiled with ncurses on Windows, this code can + work, so build it in if NCURSES_VERSION defined + - open_some_spaces: ditto + + 1/6 + --- +doc/{bash.1,bashref.texi} + - minor grammar and typo corrections from TonyMc + + 1/8 + --- +sig.c + - throw_to_top_level: only attempt to run the interrupt trap if SIGINT + is trapped -- minor optimization + - throw_to_top_level: if we are running a trap, call run_trap_cleanup + to turn off the sigmodes flags + +trap.c + - _run_trap_internal: temporarily suppress pending SIGINTs while running + one of the traps the shell handles internally (e.g., ERR). Fixes bug + reported by Keith Thompson + + 1/10 + ---- +bashhist.c + - bash_history_inhibit_expansion: use skip_to_delim with the history + expansion character to see whether or not the instance of the + history expansion character should be skipped because, for instance, + it is in a command substitution. Fixes issue reported by + Zigmund.Ozean@zig-home.localdomain + + 1/14 + ---- +lib/readline/isearch.c + - _rl_isearch_dispatch: if we are in a multibyte locale, make sure to + use _rl_find_prev_mbchar when trying to delete characters from the + search string, instead of just chopping off the previous byte. + Fixes bug reported by Kyrylo Shpytsya + +lib/readline/complete.c + - rl_filename_completion_function: if we tilde-expand `dirname', make + sure we use the expanded result instead of throwing it away for the + quote-removed `users_dirname', which still has any leading tilde. + Fixes bug reported by Dave Rutherford + +execute_cmd.c + - select_query: if the read builtin doesn't return anything in REPLY, + return NULL (failure). Fixes bug reported by Etherial Raine + + +builtins/read.def + - read_builtin: if REPLY has the readonly or noassign attribute, return + failure + + 1/16 + ---- +redir.c + - redir_open: if open() returns -1/EINTR, check traps as well as + using QUIT to handle signals + + 1/18 + ---- +jobs.c + - wait_for: make sure queue_sigchld is set to 1 before unblocking + SIGCHLD if MUST_UNBLOCK_CHLD is defined + + 1/19 + ---- +pcomplete.h + - new progcomp option: COPT_NOSORT, means to not sort list of possible + completions + +pcomplete.c + - pcomp_set_readline_variables: if COPT_NOSORT set in compspec flags, + set rl_sort_completion_duplicates to 0 + +builtins/complete.def + - _compopt: new option value: -o nosort, sets COPT_NOSORT in compspec + option flags. Provides new -o nosort option for complete and compgen + +bashline.c + - attempt_shell_completion: make sure rl_sort_completion_matches is + set to 1 before completion is attempted; allow a compspec to turn + it off + +lib/readline/kill.c + - rl_vi_yank_pop: new function, vi-mode version of yank-pop. Original + code from Ian Kelling + +lib/readline/funmap.c + - `vi-yank-pop': bindable name mapped to rl_vi_yank_pop + +lib/readline/readline.h + - rl_vi_yank_pop: extern declaration + + 1/21 + ---- +lib/sh/shquote.c + - sh_backslash_quote: change to understand and handle multibyte + characters, using is_basic, COPY_CHAR_P. See + https://bugzilla.redhat.com/show_bug.cgi?id=1184320 for original + report + + 1/23 + ---- +include/posixjmp.h + - use setjmp_sigs instead of redefined setjmp, it fails on Cygwin. + Report from Eric Blake + +builtins/wait.def,shell.c + - use setjmp_sigs instead of setjmp call, since setjmp no longer + redefined to something known + +include/chartypes.h, lib/readline/chardefs.h + - make sure all ctype.h macros are called with unsigned char args, + casting to make sure + +lib/sh/casemod.c + - sh_modcase: don't assume that the upper and lower case versions of a + character are the same width, so don't try to do the conversion in + place: convert and copy the converted characters one or more at a + time to the returned string + - sh_modcase: since upper and lower case versions of same character + may have different widths in some locales, don't shortcut and assume + that we can do single-byte case modification (toupper) with a + single-byte input character (e.g., `i'). Fix for problem reported + by Stephane Chazelas + + 1/31 + ---- +lib/readline/histfile.c + - history_truncate_file, history_do_write: if the first rename(2) + of the history file to the backup file fails, set the backup file + name to NULL to prevent any later attempts to restore the + original. Report from Jonathan Hankins + - history_do_write: don't attempt to back up non-regular files. + Report from Jonathan Hankins + + 2/2 + --- +trap.c + - run_interrupt_trap: now takes an argument indicating whether or not + it was called just before a longjmp to top_level; change callers + - run_interrupt_trap: if running a trap and we are being called before + a longjmp to top_level, call run_trap_cleanup on running trap so + a QUIT call while running a DEBUG trap, for instance, doesn't leave + sigmodes[DEBUG_TRAP] including SIG_INPROGRESS. Fixes bug reported + by Chih-Chieh Chou + +sig.c + - throw_to_top_level: change call to run_interrupt_trap to pass arg 1 + - termsig_handler: change call to run_interrupt_trap + +trap.h + - run_interrupt_trap: update extern prototype declaration + + 2/4 + --- +lib/readline/histfile.c + - histfile_backup, histfile_restore: new functions to back up and restore + history file to `filename-', following (one level of) symlinks through + so we don't rename the symlink itself. From a suggestion by + Jonathan Hankins + +assoc.c + - assoc_to_assign: if an index happens to be `@' or `*', make sure it's + double-quoted. Bug report from Greg Wooledge + + 2/5 + --- +lib/readline/bind.c + - rl_bind_key: if we are rebinding a key that is not bound to a + function or a macro, construct a key sequence and pass it to + rl_bind_keyseq. Make sure that '\' when it is used as a key is + changed to "\\" so it can survive rl_translate_keyseq. Fixes + https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=776743 + + 2/8 + --- +include/posixjmp.h + - _rl_longjmp, sh_longjmp: new defines, expand to siglongjmp or longjmp + depending on autoconf results, used to avoid redefining longjmp, + remove _OPENNT conditional code. Report from Eric Blake + + +{bashjmp,quit}.h,{execute_cmd,expr,jobs,sig,trap}.c,builtins/{evalstring.c,return.def} + - change calls to longjmp to use sh_longjmp + +lib/readline/util.c + - change calls to longjmp to use _rl_longjmp + + 2/18 + ---- +variables.c + - bind_int_variable: make sure `v' is non-null before making it visible + + 2/19 + ---- +arrayfunc.c + - assign_array_var_from_word_list: after assignment, mark variable as no + longer invisible + - assign_array_var_from_string: after assignment, mark variable as no + longer invisible + +builtins/declare.def + - declare_internal: add warning if an attempt is made to use a quoted + compound assignment as an argument to declare (declare -a foo='( 1 2 )'); + backwards compatible with bash-4.3. Still a tentative change + + 2/20 + ---- +lib/glob/smatch.c + - is_wcclass: check malloc() return value, return -1 if it fails + Report from Tobias Stoeckmann + +lib/sh/shmatch.c + - sh_regmatch: check malloc() return value, handle NULL value if it + fails. Report from Tobias Stoeckmann + + 2/22 + ---- +lib/readline/doc/rltech.texi + - rl_callback_handler_install: note that the handler function should + free the line it receives, as with readline. Suggested by + Ulf Magnusson + - Readline Signal Handling: note that application needs to clean up + readline's terminal state if it wants to handle a signal before + the line handler restores it. Suggested by Ulf Magnusson + + + 2/24 + ---- +lib/readline/histfile.c + - history_do_write,history_truncate_file: if the write fails, make sure + to set history_lines_written_to_file to 0 so we don't lose those + history entries + + 2/27 + ---- +execute_cmd.c + - execute_function: unwind-protect the value of line_number_for_err_trap, + so a function that returns a non-zero value and triggers an ERR trap + has the right value for LINENO. Any simple command in the function + body can change it. Bug report from Paul Donohue + + 3/5 + --- +lib/sh/shquote.c + - sh_backslash_quote: cast `c' to `unsigned char' before using as + index into backslash_table. Report and fix from + alexeyv.90@gmail.com + +arrayfunc.[ch] + - valid_array_reference: added second `flags' argument for future use; + currently unused + +parse.y,{redir,subst,variables,test}.c +builtins/{declare,printf,read,set}.def + - valid_array_reference: changed callers + + 3/7 + --- +lib/readline/signals.c + - _rl_handle_signal: if readline gets a SIGTSTP or SIGTTIN, block + SIGTTOU so a backgrounded readline can reset the terminal settings + appropriately, otherwise the terminal state and readline's idea + of it can get messed up. Original report from Dave Wysochanski + and Dave Anderson + +trap.c + - run_pending_traps: don't allow recursive SIGWINCH trap invocations; + they're wasteful and trying to handle a stream of signals while a + user resizes the terminal can lead to malloc errors trying to save + and restore the_pipeline multiple times. Problem reported most + recently by Martin M. S. Pederson (Fedora bash bug 1197768 + https://bugzilla.redhat.com/show_bug.cgi?id=1197768) + - reset_or_restore_signal_handlers: set pending_traps to 0 for all + signals when forking a child. TENTATIVE fix + +jobs.c + - {save,restore}_pipeline: block SIGCHLD while manipulating the_pipeline + like cleanup_the_pipeline does. XXX - may not be necessary + +lib/readline/display.c + - rl_redisplay: fixed case where multibyte character in the prompt + (e.g., \u03bb) in the last screen column causes problems with line + wrapping because the newline marker is put in the middle of the + multibyte char. Most recently reported on Ubuntu by + + +pathexp.c + - quote_string_for_globbing: if a bracket expression doesn't have a + closing right bracket, rescan it from just after the opening + bracket without treating it as a bracket expression. Bug report + from Stephane Chazelas + + 3/9 + --- +subst.c + - process_substitute: keep the last pipeline created to run a process + substitution in LAST_PROCSUB_CHILD; discard it when another one is + created + +jobs.[ch] + - discard_pipeline: now global, so process_substitute can call it + +jobs.c + - last_procsub_child: new variable, set and modified only by the process + substitution code + - find_pipeline: if the requested pid is in LAST_PROCSUB_CHILD, return + it; analogous to the way this code handles the_pipeline + - waitchld: if we find a child via find_pipeline that is a part of the + last process substitution child, mark that child appropriately. If + the child is dead, add it to the bgp list. This and the previous + change allow waiting for the most recent process substitution (the + one corresponding to $!). Original report from Stephane Chazelas + + + 3/10 + ---- +arrayfunc.c + - unbind_array_element: make sure skipsubscript() doesn't try to parse + embedded quotes in the subscript, since this has already been through + one round of word expansion before calling the unset builtin. (This + function is only called by the unset builtin). Fixes bug reported by + + + 3/17 + ---- +jobs.c + - waitchld: move code that adds the last process substitution pid to + the bgpids array from waitchld (where it can call malloc in a signal + handler context) to cleanup_dead_jobs + + 3/19 + ---- +subst.c + - parameter_brace_expand: if expanding an array in a context where word + splitting will not take place (W_ASSIGNRHS only for now), make sure + to pass the double-quoted flag to chk_atstar so we don't get the + unquoted $* behavior, which will cause unwanted word splitting. + Fixes bug reported by isabella parakiss + +arrayfunc.c + - unbind_array_element: don't assume that caller will check and pass + only array variables; don't allow non-array variables to be unset + using the `@' or `*' subscripts and don't allow any subscripts other + than 0; return -2 in those cases + - unbind_array_element: unset a non-array variable if passed a subscript + of `0' (e.g., `unbind "scalar[0]"'). This is new functionality that + parallels the ${scalar[0]} expansion + +builtins/set.def + - unset_builtin: don't check whether a variable is an array if it's + referenced using array syntax (scalar[0]); pass it to + unbind_array_element anyway and check the result. This means that + `unset scalar' and `unset scalar[0]' are equivalent + + 3/20 + ---- +builtins/set.def + - set_builtin: make `-i' an invalid option, unconditionally for now. + From a bug-bash discussion started by Peng Yu + + 3/21 + ---- +lib/readline/colors.c + - _rl_print_color_indicator: handle dangling symlinks (C_ORPHAN) and + the `target' specifier for links (dereference S_ISLNK if the target + exists). Bug report and fix from andreas@stapelspeicher.org + +{arrayfunc,subst}.c + - add code to save and restore this_command_name in places that set + this_command_name to NULL to prevent error messages from arithmetic + evaluation. Fixes bug reported by brian.carpenter@gmail.com + +builtins/mapfile.def + - do_chop: remove a new DELIM argument from the line, instead of + unconditionally removing newline + - mapfile: if -d delim is supplied and we are breaking fields at DELIM, + remove DELIM if the -t option is supplied by passing DELIM to do_chop(). + Suggested by Geir Hauge + +doc/{bash.1,bashref.texi} + - mapfile: document new -t option behavior, defaults are the same + +builtins/alias.def + - print_alias: if the first character of an alias name is `-', add a + `-- ' after `alias' to avoid option errors when trying to reuse the + output. Bug report and fix on savannah from Pasha Bolokhov + + + 3/22 + ---- +builtins/declare.def + - declare_internal: if creating a variable does not return a valid + variable in VAR, check for null variable before dereferencing it. + This happens with nameref variables referencing variables set to + the empty string. + Fixes bug reported by Arthur200000 + + 3/23 + ---- +doc/{bash.1,bashref.texi} + - INVOCATION: add language to make it clear that non-interactive login + shells execute ~/.bash_logout if they run the `exit' builtin. From a + question from Christoph Anton Mitterer + + 4/6 + --- +subst.c + - process_substitute: increment and decrement subshell_level around + calls to parse_and_execute, as in command substitution, so + $BASH_SUBSHELL gets new values in the subshell. Fixes inconsistency + pointed out by Peng Yu + +doc/{bash.1,bashref.texi} + - read: add clarifying text to note that the -N option does not split + on $IFS, but does retain backslash as an escape character subject + to -r. Report from isabella parakiss + +builtins/declare.def + - declare_internal: unless it's the last statement in a {...} block, + NEXT_VARIABLE must be protected by braces. Bug introduced in patch + from 3/22, reported by Eduardo A. Bustamante López + + + 4/7 + --- +parse.y + - shell_getc: if bash is reading input from a string that ends with an + unquoted backslash, add another backslash instead of a newline, since + the backslash and newline will disappear in normal processing. Fixes + bug with `bash -c 'eval \\; echo y' ' skipping the eval command and + setting incorrect exit status, and `bash -ic 'eval \\; echo y' ' + seeing EOF on empty line and exiting before the echo. Keep track of + backslash state with last_was_backslash; set in char reading loop. + Fixes bug reported by Eduardo A. Bustamante López + + 4/8 + --- +shell.c + - main: check for $INSIDE_EMACS as well as $EMACS when deciding whether + or not bash is being run in a GNU emacs shell window. Don't bother + checking whether $TERM is unset because variable initialization sets + it to `dumb' if unset. Fixes from Paul Eggert + +parse.y + - push_token: new function, rotates current_token through last_read_token, + saving old values like yylex() does, sets current_token to argument + +evalfile.c + - _evalfile: if current_token is yacc_EOF, push a newline as the value + of current_token instead, using push_token(). yacc_EOF can result if + sourced file doesn't end with a newline but does end with an unescaped + backslash. Fixes bug reported by Pedro Gimeno + + +lib/readline/histfile.c + - use PARAMS(x) instead of __P(x). Bug reported by Evan Gates + + + 4/9 + --- +execute_cmd.c + - execute_simple_command: if we haven't already forked, and we have + created FIFOs, turn off the no-fork optimization in the simple + command's flags. Originally reported to savannah by Kuang-che Wu as + https://savannah.gnu.org/support/index.php?108732 + + 4/10 + ---- +trap.c + - trap_if_untrapped: new function, sets a trap on a signal if that + signal is not already trapped + - maybe_set_debug_trap: new function, sets DEBUG trap to command string + argument only if it's not already trapped + +trap.h + - maybe_set_debug_trap: new extern declaration + + +builtins/source.def + - source_builtin: if the -T option isn't set, use maybe_set_debug_trap + in the unwind-protect instead of unconditionally restoring the old + trap string. That means if the sourced file changes the DEBUG trap, + that new trap will persist instead of being undone when the old + value is restored. Fixes bug reported by Scott Bronson + + +builtins/evalstring.c + - parse_string: before we jump to top_level, if we are at the `bottom' + of the parse_and_execute stack (parse_and_execute_level == 0), call + top_level_cleanup() before jumping so the right cleanup happens (e.g., + cleaning up redirections and other state). Fixes bug reported by + Sam Liddicott + + 4/15 + ---- +jobs.c + - delete_job: only add J_ASYNC (and not J_FOREGROUND) jobs to the + bgpids array, since Posix says shells only need to save the status + of async jobs. Report and fix from John Fremlin + + 4/17 + ---- +pcomplib.c + - COMPLETE_HASH_BUCKETS: increase to 256 since bash-completion is + over 300 completions by now + +variables.c + - VARIABLES_HASH_BUCKETS: constant used to size shell variables hash + table instead of relying on hash library default. Used in calls + to hash_create in create_variable_tables(), push_temp_var(), and + push_func_var(). Currently set to 1024 because why not? From a + discussion starting at + https://lists.gnu.org/archive/html/bug-bash/2015-04/msg00089.html + - initialize_shell_variables: if FUNCTION_IMPORT is not defined, the + nested conditional compilation causes syntax errors. Bug and fix + from Eric Blake + +configure.ac + - function-import: fix typo, assign to correct variable. Found as the + result of a report by Eric Blake + +shell.c + - open_shell_script: check whether or not file argument is a + directory before opening; Posix says that implementations may open + a directory with O_RDONLY. Bug report from + Eduardo A. Bustamante López + + 4/19 + ---- +ulimit.def + - fix typo in limits[] declaration of `k' + + 4/20 + ---- +configure.ac + - add template definitions set by AC_USE_SYSTEM_EXTENSIONS from a report + from Andreas Schwab + +variables.c + - FUNCTIONS_HASH_BUCKETS: constant used to size the hash tables used for + shell functions and the text of shell function definitions. Initially + set to 512, even though it's a really rare case that someone has more + than around 150 functions, even with bash-completion + + 4/21 + ---- +shell.c + - main: malloc_set_register: change arg to 0 to disable keeping track of + allocations and frees in table; change to 1 for malloc debugging on + demand. Table is too small to keep effective track of allocations on + a modern system, need to use something like valgrind + + 4/22 + ---- +shell.c + - main: move cmd_init() (initialize word desc and word list object + caches) after startup files are read so the cache doesn't get filled + up with semi-permanent storage for shell functions and variables + +execute_cmd.c + - execute_function: use maybe_set_debug_trap in the same way as source + builtin change from 4/10 to allow functions to reset a DEBUG trap + when set -T not in effect. From a report by Peng Yu + + + 4/23 + ---- +execute_cmd.c + - execute_disk_command: don't overwrite value of subshell_environment + by assigning SUBSHELL_FORK; just OR in SUBSHELL_FORK so something + like SUBSHELL_ASYNC or SUBSHELL_PIPE is preserved + +jobs.c + - wait_for: don't call give_terminal_to if running in a subshell + environment, not just if running_in_background is set; don't want + shell functions waiting for a process to complete in a pipeline to + give the terminal to the wrong process group. Part of fix for bug + reported by Valentin Bajrami + - make_child: child process should not try to give the terminal to the + pipeline_pgrp if running as part of a pipeline (SUBSHELL_PIPE in + subshell_environment); functions in execute_cmd.c don't set that + flag until after make_child returns and the child process is running. + Rest of fix for bug reported by Valentin Bajrami + + + 4/24 + ---- +redir.c + - redirection_error: if the redirection involves {varname}, only use + `varname' in the error message if the error code is < 0 (one of the + internal redirection errors, like ambiguous or bad variable name); + otherwise the issue is probably with the filename and should be treated + as usual. Fixes problem reported by Dr. David Alan Gilbert + + +configure.ac,config.h.in + - sys/ioctl.h: add check in AC_CHECK_HEADERS macro, define HAVE_SYS_IOCTL_H + +lib/readline/{rltty,terminal}.c + - sys/ioctl.h: include unconditionally for ioctl declaration, avoid + issues with `implicit declaration' warnings. Issue originally + raised on gdb list by Chen Gang + + 4/27 + ---- +lib/malloc/table.c + - mem_table: now a circular buffer showing the state of the last + REG_TABLE_SIZE allocations rather than a hash table that quickly + fills up + +builtins/declare.def + - typeset_builtin: add -n to list of supported options. Omission + reported by Valentin Bajrami + +unwind_prot.c + - use object caches instead of malloc/free to allocate and deallocate + unwind-protect elements + - uwp_init: initialize unwind-protect element object cache + +unwind_prot.h + - uwp_init: extern declaration + +shell.c + - main: call uwp_init right after calling cmd_init -- initialize all the + object caches at the same place + +lib/malloc/table.[ch] + - mlocation_table: new table to keep track of allocation locations by + file and line, functions to initialize table, record an allocation, + and dump the table to stderr + - mregister_alloc: call mlocation_register_alloc to record the location + (source file/line) for each allocation to pinpoint malloc hot spots + by number of calls. More detail than gprof + +parse.y + - set_line_mbstate: replace free/xmalloc pair with xrealloc call + - read_token_word: call alloc_word_desc instead of xmalloc so we can take + advantage of the WORD_DESC cache + + 4/28 + ---- +execute_cmd.c + - execute_simple_command: if command execution fails because the command + is a directory, and the `autocd' option is set, add a `--' argument + to the constructed `cd' command to protect against command names with + the same name as options to `cd'. Report and fix from + isabella parakiss + + 4/30 + ---- +jobs.c + - printable_job_status, j_strsignal: change calls to strcpy and sprintf + that write to retcode_name_buffer to use strncpy and snprintf to + avoid buffer overflows caused by malicious translations. Bug and fix + from Trammell Hudson + + 5/1 + --- +strtrans.c + - ansicstr: make sure the buffer is at least 12 bytes to ensure enough + space for any eventual call to u32cesc for one multibyte char + + 5/4 + --- +jobs.c + - wait_for: if an interactive shell is running a loop and waiting for + a non-builtin command to exit, and the command exits due to SIGINT, + act as if the shell received the SIGINT as well and break the loop. + This matches the behavior when the shell is running a builtin command + in a loop, and when running a non-builtin command outside a loop, and + seems more broadly useful than running the trap handler over and over + again. Report originally from Kaz Kylheku + +builtins/set.def + - unset_builtin: use different variables for keeping the state of the + -f and -v options than the loop uses to decide whether or not to + treat a name as a function or a variable. Fixes problem with + unset_function setting `sticking' after you unset a function when + invoked with no options. Bug report from Dreamcat4 + + +shell.c + - open_shell_script: set running_shell_script to 1, set to 0 in every + other case (new variable) + - main: when checking whether or not to call start_debugger, test + running_shell_script instead of dollar_vars[1]. The goal is to not + invoke the debugger for interactive shells but allow it to run for + things like `bash --debugger -i /tmp/script'. Problem reported by + Rocky Bernstein + +lib/readline/histexpand.c + - history_event_delimiter_chars: new (as yet undocumented) variable + containing by default characters that can delimit a history event + specifier without requiring a `:': "^$*%-" as the documentation has + always said. Fixes bug reported by Anders Granlund + + + 5/10 + ---- +lib/glob/gmisc.c + - match_pattern_char, match_pattern_wchar: if passed an empty string, + return a match if the first character of the pattern is `*' + +subst.c + - pat_subst: change to allow empty strings to be replaced as long as + pattern matches empty string. Report and fix from isabella parakiss + + + 5/12 + ---- +lib/sh/strtrans.c + - ansic_wshouldquote: make behavior consistent in the event of an + invalid multibyte sequence: return 1 to the caller so the string + will be $'...' quoted + +builtins/cd.def + - cd_builtin: print the right error message even if printable_filename + changes errno (e.g., EILSEQ) + +lib/sh/shquote.c + - sh_backslash_quote: in multibyte locales, even if is_basic does not + return true, backslash-quote an ASCII character that backslash_table + says should be quoted. Part of fix for bug reported by Igor + Bogomazov + +bashline.c + - directory_exists: new function, dequotes the string argument, removes + any trailing slash, and returns true if the result is a valid + existing filename + - bash_filename_stat_hook,bash_directory_completion_hook: use + directory_exists instead of calling lstat/stat on the quoted + directory name. Rest of fix for bug reported by Igor Bogomazov + + + 5/15 + ---- +aclocal.m4 + - BASH_CHECK_MULTIBYTE: when checking for locale_charset, add $LIBINTL + to $LIBS. If we're using the included lib/intl/libintl.a, it will + include a version of locale_charset + + 5/17 + ---- +lib/readline/bind.c + - sv_isrchterm: make sure we check for v[end] == 0 while in the loop + looking for whitespace. Bug report and fix from Sergio Durigan + Junior + +lib/sh/shmbchar.c + - mbstrlen,mbsmbchar: move calculation of MB_CUR_MAX out of loop; + calculate it once at beginning + +lib/sh/mbscmp.c + - mbscmp: move calculation of MB_CUR_MAX out of loop; calculate it once + at beginning + +lib/sh/mbscasecmp.c + - mbscasecmp: move calculation of MB_CUR_MAX out of loop; calculate it + once at beginning + +lib/sh/shquote.c + - sh_backslash_quote: move calculation of MB_CUR_MAX out of loop; + calculate it once at beginning + +lib/sh/casemod.c + - sh_modcase: move calculation of MB_CUR_MAX out of loop; calculate it + once at beginning + +subst.c + - expand_word_internal: move calculation of MB_CUR_MAX out of loops; + calculate it once at beginning of function (XXX should use + locale_mb_cur_max) + + 5/22 + ---- +lib/readline/rlmbutil.h + - _rl_wcwidth: new function, short-circuits wcwidth calls for ASCII + printable characters, returns 1 for those + - WCWIDTH: call _rl_wcwidth instead of wcwidth + +lib/readline/display.c + - rl_redisplay: move calculation of MB_CUR_MAX out of loop; calculate + it once at beginning. Report and patch from Ole Laursen + + + 5/24 + ---- +lib/readline/text.c + - rl_insert: change to attempt to batch-insert pending typeahead (not + pushed input or input from a macro) that maps to rl_insert. An + attempt to suppress redisplay until readline reads all typeahead -- + pasted input, for instance. Inspired by report from Ole Laursen + . XXX - need to make this a bindable + variable; already controlled by _rl_optimize_typeahead + +lib/readline/rlprivate.h + - _rl_optimize_typeahead: extern declaration + +lib/readline/doc/{hstech.texi,history.3} + - next_history: clarify under what circumstances the history offset is + incremented; suggestion from Glenn Golden + +print_cmd.c + - print_arith_command: should be compiled in if either DPAREN_ARITHMETIC + or ARITH_FOR_COMMAND is defined. Report from Flavio Medeiros + + +flags.c + - change_flag: new variable verbose_flag, set when `v' flag modified; + sets value of echo_input_at_read correspondingly + +flags.h + - verbose_flag: new extern declaration + +shell.c + - long_options: --verbose now sets verbose_flag + - main: set echo_input_at_read from verbose_flag after parsing any + long options + +builtins/fc.def + - fc_builtin: don't unwind-protect echo_input_at_read directly; set it + to 1 before calling fc_execute_file as before, and reset it to value + of global verbose_flag using set_verbose_flag called from an + unwind_protect. Report from isabella parakiss + +builtins/shopt.def + - shopt_set_debug_mode: new function, called when the extdebug shell + option changes. Right now, it sets function_trace_mode when extdebug + is enabled, and turns off when extdebug is disabled. The + documentation has always said that shopt does this. Report from + Peng Yu + + 5/27 + ---- +findcmd.[ch] + - add support for EXECIGNORE shell variable, list of extglob patterns + that prevent matching filenames from being identified as executable + files + +variables.c + - EXECIGNORE: arrange for findcmd.c:setup_exec_ignore to be called when + $EXECIGNORE changes + +variables.h + - sv_execignore: extern declaration + +doc/{bash.1,bashref.texi} + - document EXECIGNORE variable + + 5/28 + ---- +lib/readline/callback.c + - rl_callback_sigcleanup: new function, cleans up and unsets any state + rl_callback_read_char uses. Intended to be used after a signal + +lib/readline/signals.c + - _rl_handle_signal: call rl_callback_sigcleanup on SIGINT. Fixes bug + reported to python group by Martin Panter + +lib/readline/isearch.c + - _rl_isearch_cleanup: now a public function so rl_callback_cleanup can + call it + +lib/readline/search.c + - _rl_nsearch_cleanup: now a public function so rl_callback_cleanup can + call it + +lib/readline/rlprivate.h + - _rl_[in]search_cleanup: extern declarations + +lib/readline/readline.h + - rl_callback_sigcleanup: new extern declaration + +lib/readline/doc/rltech.texi + - rl_callback_sigcleanup: documented + +lib/readline/readline.h + - bump readline version to 7.0 due to addition of rl_callback_sigcleanup + + 5/29 + ---- +builtins/declare.def + - declare_internal: if we are trying to change attributes or value for + a nameref variable whose value points to an unset variable, make + sure we create a new variable whose name is the value of the nameref + variable. That is, + + declare -n foo=bar + unset foo # unsets bar + declare -i foo + + should create a (invisible) variable named `bar' with the integer + attribute. Fixes problem reported by Greg Wooledge + + +builtins/set.def + - unset_builtin: if we find a nameref variable when we look it up with + find_variable (the returned variable has a name different from what + we looked up), make sure we use that new name for the rest of the + function rather than rely on unbind_variable to do the same thing as + find_variable. Fixes problem reported by Greg Wooledge + + - unset_builtin: if we try to unset a nameref variable whose value is + not a set variable, make sure we don't try to unset the nameref + itself, but rather the variable it points to. This ensures that the + following always works as it should + + declare -n foo=bar + unset foo # unsets bar and leaves foo unchanged + +lib/readline/funmap.c + - vi-insertion-mode: make sure it maps to rl_vi_insert_mode, which is + actually what the `i' keybinding in vi_movement_keymap maps to. + Cosmetic fix from isabella parakiss + + 6/2 + --- +general.c + - conf_standard_path: moved get_standard_path here from command.def; made + public function + +general.h + - conf_standard_path: extern declaration + + + 6/3 + --- +parse.y + - parse_matched_pair: make sure that command substitution constructs + within ${...} expansions are parsed as such using parse_comsub, so + the P_FIRSTCLOSE flag doesn't stop parsing if a right brace appears + within the comsub. Report from Christos Zoulas + +findcmd.c + - search_for_command: take two new flags for FLAGS arg: CMDSRCH_STDPATH, + which means use the command -p path, and CMDSRCH_TEMPENV, currently + unused. Existing flag value of 1 now CMDSRCH_HASH + - search_for_command: don't set `path' to NULL if it wasn't found in + the temporary environment; we can use it later + - search_for_command: look for the hashed file if temp_path == 0, not + if we set path back to 0 (or path lookup failed) + - search_for_command: just call find_user_command_in_path with a + pathlist argument that's set depending on the flags passed + - find_in_path: new function, just calls find_user_command_in_path at + this point + - search_for_command: don't put non-existent files into the hash table + +findcmd.h + - CMDSRCH_*: new flags for search_for_command + - find_in_path: extern declaration + +execute_cmd.c + - execute_disk_command: check for CMD_STDPATH and call search_for_command + with CMDSRCH_STDPATH if it's set + +builtins/command.def + - command_builtin: if -p given without -v or -V, set the CMD_STDPATH + flag in the simple command we construct from the rest of the + argument list. This fixes the command -p cmd issue with changing + $PATH for the duration of `cmd's execution reported by + + +builtins/common.h + - CDESC_STDPATH: new flag for describe_command; means to use standard + path for command -pv or -pV + +builtins/command.def + - command_builtin: if -p given with -v or -V, pass the CDESC_STDPATH + flag to describe_command + +builtins/type.def + - describe_command: if given the CDESC_STDPATH flag, use find_in_path + with the conf_standard_path() result. Since `all' will never be on + with this flag, at least not yet, we can allocate and free the path + list. Fixes the bug of a temporary environment value for PATH + preceding a `command -pv' or `command -pV' persisting when the + command finishes and means we use fewer unwind-protects + + 6/4 + --- +Makefile.in (plus other Makefile.ins) + - VPATH: remove `.' from VPATH value. It's not needed any more and it + trips a GNU make 4.1 bug on Cygwin. Report and fix from Eric Blake + + +lib/readline/histfile.c + - history_tempfile: new function, takes history file name as template + and creates a temp file name including the PID + - history_truncate_file, history_do_write: instead of creating backup + and restoring it on failure, use history_tempfile to create a temp + file name, write to it, then rename to original history filename + (handling symlinks using history_restore()). Original report and + patch from Russell Stuart + +doc/{bash.1,bashref.texi} + - ulimit: clarify that -c and -f are in increments of 512 bytes when + in posix mode. Fix from Robin Johnson via + + + 6/9 + --- +execute_cmd.c + - execute_in_subshell: don't call restore_default_signal for the exit + trap, reset_signal_handlers already does the right thing and keeps + the trap string around; no need to kill trap string. Bug report + from Miroslav Koskar + + 6/11 + ---- +nojobs.c + - find_proc_slot: now takes pid as an argument to avoid finding old + procs when pids wrap around + - add_pid: pass pid to find_proc_slot to avoid multiple instances of + the same pid in the list when pids wrap around. Fixes bug reported + by Roy Keene + +execute_cmd.c + - REAP: test for job_control == 0 also to determine whether or not + to call reap_dead_jobs, since shells without job control enabled + don't report on background process status + +doc/bash.1,lib/readline/doc/hsuser.texi + - history: clarify documentation of -a option to note that it will not + append the same line to the history file more than once. Fixes + problem reported by Reuben Thomas + + 6/12 + ---- +execute_cmd.c + - execute_in_subshell: don't bother decrementing subshell_level before + this returns; the caller will just exit. This means that + $BASH_SUBSHELL will have consistent values in the subshell and any + subsequent exit trap. Fixes bug reported by Miroslav Koskar + + - shell_execve: before longjmp to subshell_top_level, call reset_parser + to free up any input line and stack of pushed strings + +parse.y + - mk_alexpansion: if the last character of the alias is a shell + metacharacter, don't add a space to the string following the alias + value, since that will change the meaning of the command. THIS IS + NOT BACKWARDS COMPATIBLE AND MAY REQUIRE REVERTING. Inspired by an + email message from Jilles Tjoelker to austin + group + + 6/13 + ---- +subst.c + - dequote_string: don't turn strings consisting of a single CTLESC + into empty strings; return them unmodified. The idea is that there + is nothing to quote. This means that something like + c=$'\001' + x=$c + results in x containing '\001' when IFS=$'\001'. See if this will + cause problems by adding a debugging statement in the code + + 6/15 + ---- +parse.y + - CHECK_FOR_RESERVED_WORD: don't return ESAC when you read `esac' + after a `|' while in a case pattern list (parser_state & PST_CASEPAT). + This is Posix grammar rule 4 + (http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_10_02) + + 6/16 + ---- +jobs.c + - wait_for: make sure we queue SIGCHLD signals if a SIGCHLD trap + handler is running (signal_in_progress or IMPOSSIBLE_TRAP_HANDLER), + since we allow recursive trap invocations now + - wait_for: make sure we treat SIGCHLD as trapped if the trap handler + is set to IMPOSSIBLE_TRAP_HANDLER so we don't miss signals during + calls to run_sigchld_trap() + +trap.c + - run_pending_traps: since we allow recursive trap handler invocations, + make sure we set pending_traps[SIGCHLD] to 0 while we mark the + signal handler in progress (SIG_INPROGRESS) and don't reset it to 0 + after run_sigchld_trap returns in case more SIGCHLDs have been + queued while it's running + + 6/22 + ---- +lib/readline/readline.c + - _rl_dispatch_subseq: if we shadowed any function, not just self- + insert, bind that function to the key we shadowed and dispatch on it. + This preserves and dispatches off the original key, not ANYOTHERKEY, + and makes sure we are dispatching from a keymap with the right key + binding. Fixes bug reported by Carlos Pita + + + 6/23 + ---- +bashline.c + - attempt_shell_completion: don't read past the end of rl_line_buffer + while skipping assignment statements before command names. Fix for + bug reported by Hanno Böck + +lib/readline/parens.c + - _rl_enable_paren_matching: make paren matching work in vi insert + mode. Really, this time. Bug report from Carlos Pita + + + 6/29 + ---- +parse.y + - parse_comsub: when starting to parse a word, make sure that we set + lex_rwlen to 0 along with lex_wlen if we are in a position where we + can read a reserved word. Fixes bug reported by Nathan Neulinger + + + 6/30 + ---- +sig.h + - include unconditionally and rely on guards in sig.h to + keep from including it more than once. Irix 6.5 defines SIG_DFL + in other files and defeats the test of SIG_DFL. Fixes bug + reported by Klaus Ziegler + +alias.c + - ALIAS_HASH_BUCKETS: table size increased to 64 + + 7/7 + --- + +{jobs,nojobs}.c + - wait_sigint_cleanup: new function, to be called by longjmp targets + for wait_intr_buf. Performs any necessary cleanup of internal waitchld + state before going back to top level + +jobs.h + - wait_sigint_cleanup: new extern declaration + +builtins/wait.def + - wait_builtin: call wait_sigint_cleanup after longjmp back to + wait_intr_buf on interrupt + +[bash-4.4-alpha frozen] + + 7/7 + --- +bashline.c + - attempt_shell_completion: when skipping assignment statements, don't + skip past rl_point to find the word on which to perform programmable + completion. Fixes bug reported by Hanno Böck + + 7/10 + ---- + +pcomplib.c + - compspec_copy: set the refcount on the copy to 1, since it's a freshly + allocated copy and there are no other pointers to it. Fixes memory + leak from gen_progcomp_completions + +lib/readline/complete.c + - printable_part: if the pathname passed is just `/', just return it + instead of potentially reading before the `/'. Fixes bug reported + by Hanno Böck + + 7/11 + ---- +support/man2html.c + - change calls to malloc to use xmalloc; provide standard xmalloc + definition. Report from Bill Parker + +builtins/wait.def + - wait_intr_flag: set to denote validity of wait_intr_buf as target + for longjmp; reset by WAIT_RETURN macro; should always be 0 when + wait_builtin returns + +quit.h + - CHECK_WAIT_INTR: now also checks wait_intr_flag to ensure valid state + of wait_intr_buf before sh_longjmp + +{jobs,nojobs}.c + - wait_intr_flag: extern declaration for use by CHECK_WAIT_INTR + +sig.c + - wait_intr_flag: set back to 0 every place the shell resets state after + a jump to top_level + - sigint_sighandler: only set wait_signal_received if wait_intr_flag + indicates that the wait builtin has correctly set wait_intr_buf. + Final fix for bug reported by Ondrej Oprala + +subst.c + - parameter_brace_expand: fix so that ${!vvv@} is not interpreted as + introducing a `@' operator, but instead retains its meaning as all + variables whose name begins with vvv. Fixes bug reported by + konsolebox + + 7/14 + ---- +execute_cmd.c + - execute_connection: remove the fork optimization from and AND_AND + and OR_OR cases; it has trouble with `a && b && c', since the `&&' + is left-associative. Putting that code here can result in unwanted + fork optimizations since the `b' will end up as `second' on a + recursive call to execute_command. Bug reported by Mike Frysinger + + +builtins/evalstring.c + - optimize_fork: moved code from execute_connection to here; checks + whether the RHS of a && or || passes the suppress_fork() tests and + turns on the NO_FORK bit if so + - parse_and_execute: if suppress_fork() tests fail, check whether the + command to be executed is a connection and attempt to optimize the + fork for the right side using optimize_fork(). The key is dealing + with the entire command passed to `bash -c' or `eval' + +builtins/common.h + - optimize_fork: new extern declaration + +execute_cmd.c + - execute_command_internal: enable code put in to undo redirections + before exiting the shell due to `set -e' in the case of a shell + function that gets command-not-found or a syntax error. Reported + back in May, 2014 by Mark Ferrell + +bashhist.c + - bash_history_inhibit_expansion: enable change from 1/10 that skips + over history expansion character in command and process + substitution + + 7/15 + ---- +lib/readline/{history,undo}.c + - replace_history_data now _hs_replace_history_data + + 7/16 + ---- +lib/readline/readline.c + - make sure _rl_to_lower doesn't ever get characters that are outside + of its valid range by casting arg to unsigned char + +lib/readline/colors.h + - change completion prefix color (C_PREFIX) to be the same as C_SOCK, + which is less likely to collide with file type colorings (magenta) + +lib/readline/complete.c + - fnprint: now takes an additional argument: the full, expanded pathname + corresponding to the `toprint' argument + - fnprint: don't zero out prefix_bytes if we're not printing the + ellipisis but we still want to use prefix_bytes for displaying + the common prefix in a color + - print_filename: move colored-stats display responsibility into fnprint + - fnprint: change so colored-prefix and colored-stats can cooperate + and display filenames with multiple colors: one for the prefix and + one for the file type. The prefix is displayed in the prefix color + and the remainder of the pathname, if any, is displayed in the color + corresponding to the file type. Report and suggestion from Mike + Frysinger + + 7/17 + ---- +lib/readline/readline.[ch] + - rl_readline_state: now unsigned long, prepare for more than 32 states + + + 7/18 + ---- +lib/readline/history.h + - history_offset: now declared here, was always a global variable + - copy_history_entry: now declared here, part of the public interface + - alloc_history_entry: now declared here, part of the public interface + + 7/20 + ---- +lib/readline/readline.h + - RL_STATE_CHARSEARCH: new state, for vi mode character search. Was + previously handled by simply setting _rl_callback_func + +lib/readline/vi_mode.c + - rl_domove_motion_callback: split into two functions, remaining code + after _rl_dispatch call goes into new function + _rl_vi_domove_motion_cleanup + - rl_vi_char_search: set RL_STATE_CHARSEARCH + - rl_vi_char_search: sets `i2' member of callback data to the key used + to invoke the char search + - _rl_vi_callback_char_search: unset RL_STATE_CHARSEARCH after reading + the character to find + - _rl_vi_domove_motion_cleanup: make sure RL_STATE_VIMOTION is unset in + all cases where this function returns + - _rl_vi_domove_motion_cleanup: use `end' member of vi motion context + as value of rl_end to restore after adding blank at end of line in + rl_domove_motion_callback; avoids need to keep `old_end' and somehow + pass it between the two functions + +lib/readline/rlprivate.h + - _rl_vi_domove_motion_cleanup: new extern declaration + +lib/readline/callback.c + - rl_callback_read_char: handle RL_STATE_CHARSEARCH, including case + where char search is vi motion command for d/c/y/m and RL_STATE_VIMOTION + is set when this is called. Last of set of fixes for bug reported + by Carlos Pita with vi-mode `dty' command + in callback mode + + 7/21 + ---- +subst.c + - command_substitute, process_substitute: add QUIT call in the child + after restoring original signal handlers to catch post-fork SIGINT + or terminating signal + +jobs.c,nojobs.c + - make_child: after forking, clear interrupt_state in child + before restoring signal mask so children get their own set of + interrupts + + 7/22 + ---- +lib/sh/shquote.c + - sh_double_quote: since all uses of the return value from this function + are for display and not subject to subsequent expansion, we don't + need to protect CTLESC and CTLNUL with CTLESC. Bug report and fix + from isabella parakiss + +parse.y + - decode_prompt_string: need to protect literal instances of CTLESC + and CTLNUL with CTLESC, even if they are not coming out of one of + the backslash-expansions + +subst.c + - make_internal_declare: fixed memory leak; make_internal_declare should + free the memory it allocates to construct the word list. From Red + Hat bug 1245233; https://bugzilla.redhat.com/show_bug.cgi?id=1245233 + +lib/readline/readline.c + - _rl_dispatch_subseq: when checking whether an ESC in vi insert mode + should be treated as part of a key sequence or as a single char, + make sure we are getting input from the keyboard before we check + _rl_input_queued(). If we are getting input from a macro, this + causes a needless delay. Report from Carlos Pita + + + 7/23 + ---- +input.c + - save_bash_input: before checking to see whether or not a new fd has a + stale associated buffer, make sure that the new fd is within bounds. + Bug report and fix from Alexey Makhalov + + + 7/24 + ---- +doc/{bash.1,bashref.texi} + - note that the `return' builtin accepts arguments beginning with `-' + without requiring `--' + + 7/27 + ---- +examples/loadables/Makefile.in + - add variables and targets to support `make install'; installs + supported builtins in $(libdir)/bash + + 7/28 + ---- +lib/readline/{readline,rlprivate}.h, lib/readline/display.c + - rearrange some structure members for better alignment and to reduce + padding. Fix from + +tests/run-* + - use BASH_TSTOUT instead of hardcoded /tmp/xx as output file + +trap.[ch] + - maybe_set_error_trap: set a trap for the ERR trap if it is not already + trapped; similar to maybe_set_debug_trap back from 4/10 + +lib/malloc/malloc.c + - internal_free: make sure `ubytes' is initialized if MALLOC_WATCH is + defined and we'll be passing it to _malloc_ckwatch. Report from + Flavio Medeiros + +execute_cmd.c + - execute_function: use maybe_set_error_trap in the same way as + maybe_set_debug_trap. Fixes bug reported by David Waddell + + + 7/29 + ---- +jobs.c + - wait_for: no longer need to call job_signal_status when checking + whether a comsub shell reaped a child that died due to SIGINT; code + now uses child_caught_sigint + + 7/30 + ---- +builtins/exec.def + - exec_builtin: after call to restore_original_signals, need to call + default_tty_job_signals to undo changes done by initialize_job_signals. + Fix for problem reported by Andreas Schwab + +doc/{bash.1,bashref.texi} + - clarify definition of metacharacter to explicitly include newline; + prompted by report from George Gallo + + 8/3 + --- +lib/readline/search.c + - _rl_free_history_entry: should be void, not int. Report from + Dilyan Palauzov + +general.h + - sh_load_func_t, sh_unload_func_t: new function pointer types, used by + enable for load and unload hook functions + +builtins/enable.def + - dyn_load_builtin: attempt to execute a function named + BUILTIN_builtin_load, where BUILTIN is the name of the command being + loaded. If that function returns 0, the load fails + - dyn_unload_builtin: attempt to execute a function named + BUILTIN_builtin_unload, where BUILTIN is the name of the command + being unloaded. It offers a dynamic builtin a way to clean up after + itself. Inspired by suggestion from Piotr Grzybowski + in response to a bug report from isabella + parakiss + + 8/6 + --- +lib/readline/colors.[ch] + - _rl_print_color_indicator: now takes `const char *' argument + +lib/readline/complete.c + - colored_stat_start: now takes `const char *' argument + +lib/malloc/table.h + - ma_table_t: `file' member is now `const char *' + +lib/malloc/table.c + - mlocation_register_alloc: make sure variable assigned to `file' in + ma_table_t is of type `const char *'. Fixes from Dilyan Palauzov + + +lib/termcap/termcap.[ch] + - tputs: should return int instead of void + +lib/readline/readline.h + - RL_STATE_DONE: correct value, avoid collision + +lib/readline/vi_mode.c + - _rl_vi_redoing: now global, added _rl_ prefix to `vi_redoing' + +lib/readline/readline.c + - _rl_subseq_result: call _rl_dispatch_subseq instead of rl_dispatch to + avoid changing _rl_dispatching_keymap + - _rl_subseq_result: in the -2 case, set _rl_dispatching_keymap to the + map passed as an argument. Without this, vi mode doesn't call + rl_vi_set_last when it should + - _rl_dispatch_subseq: if redoing a vi mode command with `.' + (_rl_vi_redoing != 0) in callback mode and we're indirecting into + another keymap that has shadowed the key corresponding to the command + we are redoing, just call _rl_subseq_result immediately: vi redo + doesn't need to read any additional input, and rl_vi_redo assumes + that a single call to rl_dispatch is sufficient. Fixes bug reported + by Carlos Pita + + 8/7 + --- +subst.c + - parameter_brace_expand: if a substitution (parameter expansion) error + occurs, and shell_compatibility_level is <= 43, return expansion error + as in all previous versions. If shell_compatibility_level is > 43, + a posix-mode non-interactive shell will consider this a fatal error. + Problem reported by Christian Neukirchen + +doc/bashref.texi + - documented that word expansion errors cause fatal errors in posix mode + non-interactive shells + + 8/8 + --- +subst.h + - SD_COMPLETE: skip_to_delim being called as part of word completion + - SX_COMPLETE: one of the string_extract functions being called as + part of word completion + +bashline.c + - find_cmd_start,find_cmd_end,find_cmd_name: call skip_to_delim with + SD_COMPLETE flag + +subst.c + - skip_double_quoted: takes new flags argument; changed callers + - skip_double_quoted: if flags argument includes SX_COMPLETE, pass it + to extract_command_subst + - extract_command_subst: if flags&SX_COMPLETE, call + extract_delimited_string instead of xparse_dolparen, since completion + may call this for unterminated command substitutions. Fixes + (imperfectly) bug reported by Ingo Ruhnke + - skip_to_delim: if passed the SD_COMPLETE flag, pass the SX_COMPLETE + flag to skip_double_quoted + - char_is_quoted: pass SX_COMPLETE flag to skip_double_quoted + - unclosed_pair: pass SX_COMPLETE flag to skip_double_quoted + + 8/9 + --- +execute_cmd.c + - time_command: catch longjmps to top_level and print command timing + statistics even after a jump to top_level. Fixes issue reported by + Sam Watkins + + 8/10 + ---- +config-top.h + - OPENLOG_OPTS: if SYSLOG_HISTORY is defined, define to LOG_PID, so + each message is tagged with the pid + +bashhist.h + - bash_syslog_history: the first time it's called, call openlog with + OPENLOG_OPTS and SYSLOG_FACILITY + + 8/11 + ---- +doc/{bash.1,bashref.texi} + - GROUPS,FUNCNAME: change description to note that assignments are + silently ignored, but do not return an error (which would constitute + an assignment error and cause posix mode shells to abort). Problem + pointed out by Grzegorz Bajson + + 8/12 + ---- +subst.c + - parameter_brace_expand_indir: if the value of the indirectly expanded + variable isn't something that the shell would expand if it were inside + ${}, error out right away before calling parameter_brace_expand_word. + Fixes problem reported by isabella parakiss + - parameter_brace_expand: handle returning &expand_wdesc_error or + &expand_wdesc_fatal from parameter_brace_expand_indir in case it does + that someday + + 8/13 + ---- +jobs.c + - {save,restore}_pipeline: saved_pipeline now a linked list of pipelines, + new ones allocated in save_pipeline and freed in restore_pipeline. + This allow multiple nested calls to save_pipeline (e.g., in traps + and then in process substitution). Fix for bug reported by isabella + parakiss + +print_cmd.c + - named_function_string: if printing a function with the same name as a + reserved word, add the `function ' keyword before the name to avoid + parsing problems when trying to reuse it as input. Fix for bug + reported by isabella parakiss + + 8/14 + ---- +lib/readline/text.c + - rl_insert: when optimizing typeahead, make sure we set rl_last_func + ourselves if we set pending input, since the mainline code path + won't set rl_last_func if input is pending. Fixes bug reported by + Hiroo Hayashi + + 8/15 + ---- +builtins/type.def + - describe_command: if using the short description (CDESC_SHORTDESC) in + posix mode, describe posix special builtins as such. Requested by + Stephane Chazelas + +builtins/enable.def + - BASH_LOADABLES_PATH: a colon-separated list of directories where bash + looks for loadable builtins specified as arguments to `enable -f' + +doc/{bash.1,bashref.texi} + - BASH_LOADABLES_PATH: document new shell variable + +configure.ac,Makefile.in,builtins/Makefile.in + - loadablesdir: set in configure, substitute into Makefiles. Reserved + for future use + + 8/18 + ---- +subst.c + - shell_expand_word_list: if make_internal_declare fails, make sure to + propagate that error return back and make the assignment statement + fail. Fixes seg fault reported by Sergey Tselikh + + 8/20 + ---- +builtins/declare.def + - declare_internal: made a slight tweak to the warning message about + quoted compound assignments by printing it only if the array (indexed + or assoc) does not already exist + + 8/21 + ---- +braces.c + - mkseq: call strvec_dispose before throw_to_top_level if we saw SIGINT + to avoid a memory leak + +trap.c + - maybe_set_return_trap: set the RETURN trap to string if it's not + already trapped, in the same way as the debug and error traps + +execute_cmd.c + - execute_function: use maybe_set_return_trap to allow functions to set + return traps that persist across calls even if function tracing is + enabled + +lib/readline/input.c + - rl_gather_tyi: make sure errno reset to 0 after select call, for + ioctl and read + - rl_gather_tyi: if read returns -1/EIO, return -1 + - rl_read_key: if rl_gather_tyi returns -1/EIO, return READERR if in + RL_STATE_READCMD (reading command in readline_internal_char), EOF + if not (like rl_getc). Continue to return '\n' on other errors; + rl_done = 1 in any case. Fix for issue reported by + Lubomir Rintel + +lib/readline/{misc,text,vi_mode}.c + - fix return values from rl_read_key to handle < 0 + + 8/22 + ---- + +parse.y + - parsing_redirection: macro that expands to true if the last read + token (always passed as an argument) is a redirection token that + will leave us reading a word that's the target of the redirection + - command_token_position: make sure that even if the parser state + indicates we are reading a simple command (PST_REDIRLIST), we do + not perform alias expansion on a WORD that is part of a redirection, + using parsing_redirection() to do so. Fixes but reported to Red Hat + by Robert Alm Nilsson + https://bugzilla.redhat.com/show_bug.cgi?id=795795 + +builtins/declare.def + - declare_internal: only print the warning now if the variable is not + already an array or if we are not creating an array with -a or -A, + cuts down the spurious warnings + - declare_internal: even if the rhs of the assignment looks like a + compound array, if we're not assigning to an existing array or we're + not creating an array, make it an array subscript assignment. This + means things like declare a[1]='(foo)' and a[1]='(foo)' behave + identically + +builtins/help.def + - wdispcolumn: change use of displen and add new dispchars variable to + deal with locales where each wide character does not take up one + column position. Fix for bug reported by Mingye (Arthur) Wang + + + 8/23 + ---- +sig.c + - sigint_sighandler: if we get a SIGINT while this_shell_builtin == + wait_builtin, perform the special handling only if wait_intr_flag + is non-zero, don't just use it to set wait_sigint_received. This + makes sure we run bashline_set_event_hook. Fixes bug reported by + isabella parakiss + + 8/25 + ---- +subst.h + - SD_HISTEXP: new flag for skip_to_delim, indicates we are looking for + the history expansion character (special double quote handling) + - skip_to_delim: handle SD_HISTEXP flag, changes double quote handling + to be similar to history library: don't call skip_double_quote, make + sure single quotes aren't special in double quotes, but continue to + skip over $(), ${}, and other similar constructs + + 8/27 + ---- +support/bash.pc.in + - new file, pkgconfig template for bash, installed to support nascent + loadable builtins dev environment + +examples/loadables/Makefile.inc + - new file, example Makefile with correct definitions for loadable + builtin development + +configure.ac + - headersdir: directory where headers get installed to support loadable + builtin development + - examples/loadables/Makefile.inc, support/bash.pc: create + +Makefile.in + - INSTALLED_HEADERS, INSTALLED_BUILTINS_HEADERS, INSTALLED_INCFILES, + CREATED_HEADERS: new variables holding names of include files to + install into $(headersdir) for loadable builtin development + - install-headers,install-headers-dirs: new targets to support + installing headers into $(headersdir) and subdirectories for loadable + builtin development + - uninstall-headers: target to uninistall headers in $(headersdir) + - uninstall: call uninstall-headers whether or not install-headers + was done; add uninstall in examples/loadables + - install: add install in examples/loadables + - clean: add clean in examples/loadables + +examples/loadables/Makefile.in + - install-supported, install-unsupported: new targets, make install + chooses one based on $(SHOBJ_STATUS) + - install-supported: now cds to the top level build directory and + installs the header files + - install-supported: now installs Makefile.inc to $(loadablesdir) as + an example + - uninstall-supported,uninistall-unsupported: uninstall targets, + make uninstall chooses one based on $(SHOBJ_STATUS) + + 8/31 + ---- +lib/glob/Makefile.in + - CPPFLAGS: move after ${INCLUDES} so library-specific include paths + take precedence. This is what the other parts of the shell do. + Report from Poor Yorick + +builtins/read.def + - reset_alarm: cancel alarm before restoring signal handler to avoid + possible race condition. Report and fix from Oleg Popov + + +subst.c + - string_extract_verbatim: if SEPARATORS is "'", don't short-circuit + to string_extract_single_quoted unless the SX_NOCTLESC flag is set. + Callers expect this function to honor CTLESC, even to quote a single + quote. Fixes bug reported by isabella parakiss + and several others + + 9/2 + --- +include/chartypes.h + - TOCTRL: handle '?' by special-casing it to 0x7f. Fixes a problem + with $'\c?' reported by Helmut Karlowski + +redir.c + - write_here_string: don't word-split the here string document. The + bash documentation has always said this doesn't happen, even though + bash has done so for years, and other shells that implement here- + strings don't perform any word splitting. The practical effect is + that sequences of IFS characters are collapsed to spaces. Fixes + bug reported by Clint Hepner + + 9/3 + --- +doc/{bash.1,bashref.texi} + - add \? to the list of backslash escapes expanded by $'...' ANSI-C + quoting. It was expanded but not documented + +lib/readline/util.c + - _rl_audit_tty: updated from Red Hat patch + +lib/readline/readline.c + - HAVE_DECL_AUDIT_USER_TTY: correct #define check + + 9/13 + ---- +shell.c + - read_from_stdin: make sure value set to 1 appropriately if the shell + is reading from standard input, as Posix seems to specify (?) + +lib/readline/kill.c + - _rl_copy_to_kill_ring: don't assume that rl_kill_ring has been + allocated if _rl_last_command_was_kill is non-zero; make sure it's + non-null before indexing into it + + 9/15 + ---- +variables.c + - initialize_shell_variables: cope with a NULL env pointer. Fixes bug + reported by ziyunfei <446240525@qq.com> + + 9/16 + ---- +builtins/exec.def + - exec_builtin: if -c is supplied, pass an empty array instead of a NULL + pointer to shell_execve + +variables.c + - set_pwd: only believe $PWD if it begins with a slash; try to + canonicalize it and set it to physical path if canonicalization fails. + Reported by ziyunfei <446240525@qq.com> + + 9/17 + ---- +subst.c + - do_compound_assignment: make sure to dispose of word list generated + by expand_compound_array_assignment; fixes memory leak reported in + https://bugzilla.redhat.com/show_bug.cgi?id=1264101 + +variables.c + - adjust_shell_level: clamp the value of shell_level at 1000 and reset + there, instead of > 1000, since the itos replacement code doesn't + handle the value 1000. Fixes bug reported by ziyunfei + <446240525@qq.com> + +shell.h,parse.y + - save_parser_state,restore_parser_state: now save and restore + redir_stack, short-circuiting if need_here_doc == 0. If we save a + non-zero value for need_here_doc, we have to make sure there is + something valid for gather_here_documents to work on. Fixes bug + reported by Brian Carpenter + + 9/18 + ---- +array.c + - array_to_assign: use ansic_shouldquote to check whether each element + value contains non-printable characters and use ansic_quote to + generate the value instead of using sh_double_quote unconditionally + +assoc.c + - assoc_to_assign: if either the key or the value of an associative + array element contains non-printable characters (ansic_shouldquote + returns true), use ansic_quote to quote them instead of using double + quotes unconditionally + + 9/19 + ---- +subst.c + - pat_subst: handle REP being NULL. Fixes bug reported by Brian + Carpenter + +builtins/evalstring.c + - parse_string: if we get a longjmp to top_level with DISCARD as the + code (in which case we are going to go on), return -DISCARD to our + caller (always xparse_dolparen) after doing our own cleanup instead + of calling jump_to_top_level + +parse.y + - xparse_dolparen: if parse_string returns < 0, do the appropriate + cleanup and then jump_to_top_level with the negative of the return + value. This allows us to do the appropriate parser cleanup in + case we're not going to exit the shell. Fixes bug reported by Brian + Carpenter + +subst.c + - extract_delimited_string: if a recursive call to one of the extract_ + functions or a call to ADVANCE_CHAR leaves i past the end of the + string, cut the loop off at the end of the string. Fixes bug + reported by Brian Carpenter + + 9/20 + ---- +subst.c + - get_var_and_type: return appropriate values if variable indirection + results in a NULL variable. Fixes bug reported by Brian Carpenter + + +lib/readline/history.c + - history_get_time: handle strtol overflows caused by malicious + modifications to timestamps in the history file. Fixes issue + reported by rens@endoria.net + + 9/21 + ---- +lib/readline/rlconf.h + - ENABLE_AUDIT_TTY_SUPPORT: now undefined (off) by default + + 9/24 + ---- +jobs.c + - waitchld: if we get a SIGINT while waiting for a child to exit, but + the kernel doesn't interrupt the waitpid(2) call, assume the child + caught SIGINT if it exited for some reason other than SIGINT. Fix + suggested by Stephane Chazelas + +input.c + - make_buffered_stream: use B_TEXT in buffered stream flags instead + of (typo) O_TEXT. Report and fix from Eric Blake + + 9/27 + ---- +execute_cmd.c + - shell_execve: call reset_parser before calling initialize_subshell, + which calls delete_all_aliases. reset_parser wants to free the + pushed string list, which has pointers back into the alias table + (use after free) + - execute_simple_command: if we fork for an async command, make sure + the child process increments shell_level before performing any + word expansions, so $BASH_SUBSHELL is incremented. Fixes issue + reported by ziyunfei <446240525@qq.com> + + 10/1 + ---- +builtins/kill.def + - kill_builtin: make -L equivalent to -l for compatibility with other + (Linux) versions of kill + +doc/{bash.1,bashref.texi} + - kill: document new `-L' option + + 10/2 + ---- +[bash-4.4-beta frozen] + + 10/5 + ---- +doc/{bash.1,bashref.texi} + - LC_TIME: document that the shell recognizes it and calls setlocale + when it changes; and that the shell uses it for time formatting + + 10/6 + ---- +subst.c + - skip_single_quoted: now takes an additional `flags' argument, like + skip_double_quoted; changed callers + - skip_single_quoted: now pays attention to SX_COMPLETE flag, allows + backslash to escape single quote, like $'...' allows + - skip_to_delim: added case where we are completing and we are + skipping over a $'...' string to call skip_single_quoted with + SX_COMPLETE flag to allow backslash to quote single quote. Fixes + bug reported by Daniel Colascione + - char_is_quoted: make analogous changes to handle $'...' so we can + accommodate $'ab \' cd' + + 10/11 + ----- +subst.c,bashjmp.h + - no_longjmp_on_fatal_error: now global so other parts of the shell can + use it + +arrayfunc.c + - expand_array_index: if no_longjmp_on_fatal_error is non-zero, don't + longjmp to top_level, just return 0. Fixes bug reported by + isabella parakiss + +subst.c + - CQ_RETURN: restore old value of no_longjmp_on_fatal_error (oldjmp); + make sure all callers (skip_matched_pair, skip_to_delim, + char_is_quoted) save no_longjmp_on_fatal_error to oldjmp before + setting it to 1 + +expr.c + - expr_streval: if longjmping after an unbound variable error, jump + back to expr toplevel (evalbuf) if no_longjmp_on_fatal_error is set + in an interactive shell + +variables.c + - push_func_var: if pushing an array variable, such as when a variable + in the temporary environment is promoted to an array by mapfile when + the shell is in posix mode (so variable assignments preceding special + builtins or shell functions persist in the shell environment after + the builtin returns), make sure to copy the array or hash table so + the variable is duplicated correctly. Fixes seg fault reported by + Linda Walsh + + 10/13 + ----- +variables.c + - initialize_shell_variables: add call to sv_shcompat, so BASH_COMPAT + can be set in the initial environment + +execute_cmd.c + - execute_function: set loop_level to 0 only if shell_compatibility_level + is greater than bash-4.3; this was kind of an incompatible change. + Report from Carlos Pita + +COMPAT,doc/{bash.1,bashref.texi} + - compat43: added loop_level changes to description + + 10/15 + ----- +lib/sh/casemod.c,lib/readline/display.c + - make sure mb_cur_max variable is defined outside of HANDLE_MULTIBYTE + if it's used outside HANDLE_MULTIBYTE. Fixes from Greg Wooledge + + +support/Makefile.in + - bash.pc: remove as part of distclean, not clean. Report from Andreas + Schwab + + 10/17 + ----- +subst.c + - array_var_assignment: make sure to call quote_string or quote_escapes + on the assignment string, so spaces in the assignment survive word + splitting. Fixes bug reported by isabella parakiss + + + 10/20 + ----- +doc/{bash.1,bashref.texi} + - word splitting: make sure that newline is listed as one of the IFS + whitespace characters. Fixes omission reported by ziyunfei + <446240525@qq.com> + +lib/readline/histfile.c + - history_do_write: make sure that we only create and use the tempfile + if the history file exists and is a regular file. Reported several + times, most recent check the result of a report from + + + 10/22 + ----- +jobs.c + - delete_all_jobs: if running_only == 0, we are eventually going to + clear the bgpids list, so don't bother to add pids to it in + delete_job (call with DEL_NOBGPID flag if running_only == 0) + + 10/24 + ----- +jobs.[ch] + - bgpids: new implementation from a patch from John Fremlin + , uses an array for the list of the last CHILD_MAX + terminated background pids, and a separate hash table to search it. + The storage can be freed as a unit, and the size of the hash table + (currently 4096) is independent of the size of the bgpids table + +subst.c + - inherit_errexit: new variable to control whether or not command + substitution inherits the -e (errexit) option. Disabled by default + +general.c + - posix_initialize: set inherit_errexit = 1 when Posix mode is enabled + +builtins/shopt.def + - inherit_errexit: new shell option, tracks value of inherit_errexit, + allows command substitution to inherit the setting of errexit without + posix mode. From a request and patch submitted by Christoph Gysin + + +{version,version2}.c + - use #if HAVE_SNPRINTF instead of #if defined in case configure + decides to #define it to 0. Fixes problem reported by Klaus Ziegler + + +configure.ac + - when checking for sys/resource.h, make sure to include + for the benefit of both old systems that require it and new versions + of autoconf that require a header file to compile to report its + presence. Reported by Klaus Ziegler + + 10/26 + ----- +subst.h + - SD_ARITHEXP: new flag value for skip_to_delim, supports parsing + arithmetic expressions in parameter expansions + +subst.c + - skip_to_delim: handle SD_ARITHEXP flag by skipping parentheses for + subexpressions and allowing ?: expression to not terminate an + arithmetic expression delimited by `:' + - skiparith: just call skip_to_delim with the SD_ARITHEXP option and + the right delimiter string and return the right result. Fixes bug + reported by + +include/shmbchar.h + - strip out everything except what is needed to support is_basic and + similar functions, since the mbchar_t typedef apparently conflicts + with some AIX-specific type definition. Problem reported by + Michael Felt + + 10/27 + ----- +builtins/{set,ulimit}.def + - {set,ulimit}_builtin: make sure that --help is treated the same as + -? and prints a message and returns. Fixes bug reported by ziyunfei + <446240525@qq.com> + +builtins/*.def + - make sure to consistently use builtin_help() instead of mix of that + function and builtin_usage() + + 10/29 + ----- +doc/{bash.1,bashref.texi} + - BASH_CMDS, BASH_ALIASES: note that removing elements from these + array variables is not currently reflected in the command hash + table and alias list, respectively. Reported by isabella parakiss + + + 10/30 + ----- +eval.c + - reader_loop: if PS0 is set in an interactive shell, expand and + display it after reading a (complete) command but before executing + it. This differs from the DEBUG trap because the DEBUG trap is + executed once for each simple command (and some others, like each + time through a for loop). From a patch submitted by Dan Stromberg + + +parse.y + - prompt_again: set ps0_prompt from $PS0 in an interactive shell + +doc/{bash.1,bashref.texi} + - PS0: document new prompt string + + 11/3 + ---- +subst.c + - cond_expand_node: if special > 0, remove quoted nulls from the word + list, since no word splitting takes place. Fixes bug reported by + Corentin Peuvrel + + 11/4 + ---- +doc/{bash.1,builtins.texi} + - inherit_errexit: add to shopt description; modify Posix mode + description + + 11/9 + ---- +lib/readline/util.c + - rl_tilde_expand: fix out-of-bounds read caused when this function + is invoked with rl_point == 0. Bug reported by Hanno Böck + + + 11/11 + ----- +{nojobs,jobs}.c + - get_original_tty_job_signals: force the original signal disposition + for SIGTSTP/SIGTTIN/SIGTTOU to SIG_DFL in interactive shells. This + will force child processes to get SIG_DFL even if the shell is + started with those signals ignored. From a bug report from + Keith Thompson + + 11/13 + ----- +make_cmd.c + - make_function_def: if a function is being defined without a source + file, and the shell has not been initialized, assume that the + function is being imported from the environment and set the + source_file struct member to "environment". Set to "main" if the + shell has been initialized. Fixes bug reported on savannah by + Arno-Can Uestuensoez + https://savannah.gnu.org/support/index.php?108903 + +subst.c + - skip_to_delim: if the shell is in posix mode (posixly_correct != 0) + and performing history expansion ((flags & SD_HISTEXP) != 0), allow + double quotes to quote the history expansion character. TENTATIVE + CHANGE, inspired by + https://savannah.gnu.org/support/index.php?108491 + + 11/14 + ----- +jobs.c + - wait_for: modify change from 4/23 to only give the terminal to + shell_pgrp if not running in the background and subshell_environment + indicates we're not in a pipeline and not an async command. Fixes + bug reported by konsolebox + + 11/16 + ----- +doc/{bash.1,bashref.texi} + - document new posix-mode behavior of not giving ! special meaning + within double quotes, even if histexpand is enabled + + 11/17 + ----- +builtins/evalfile.c + - fc_execute_file: pass FEVAL_BUILTIN flag to _evalfile so it returns + the value of parse_and_execute after executing the commands in the + file. Fixes bug reported by Chris Marusich + + 11/20 + ----- +subst.c + - process_substitute: don't unconditionally set pipeline_pgrp to + shell_pgrp; do that only if pipeline_pgrp == 0 (we haven't forked + yet) or if we know we haven't forked for a command, a pipeline, + or an async command. Fixes bug reported by + + as https://savannah.gnu.org/support/index.php?108593 + + 11/24 + ----- +variables.c + - set_pwd: inherit the value of OLDPWD from the initial environment + if it names a directory. From a report from John Wiersba + + +builtins/set.def + - -T: fix help text to note that the DEBUG and RETURN traps are both + inherited if this is set. Report from Grisha Levin + + +doc/{bash.1,bashref.texi} + - HISTIGNORE,GLOBIGNORE: note that the pattern matching is subject to + the setting of the `extglob' variable. Clarification raised by + Aharon Robbins + +builtins/jobs.def,doc/{bash.1,bashref.texi} + - disown: add text to synopsis making it clear that disown takes a + pid argument. From a report from Matthew Stanfield + + +findcmd.c,doc/{bash.1,bashref.texi} + - EXECIGNORE: change pattern matching to use FNMATCH_EXTFLAG like other + IGNORE variables. From a report from Aharon Robbins + +trap.c + - _run_trap_internal: make sure to catch and use return values supplied + as arguments to `return'; instead of just catching return, make sure + we use return_catch_value as well. Fixes bug reported by + Grisha Levit , affects RETURN, DEBUG, ERROR + traps + + 11/30 + ----- +lib/readline/display.c + - rl_redisplay: fix code that deals with prompts that contain + multibyte characters whose physical length is longer than the screen + width (so the prompt line wraps) to deal with invisible characters + in the prompt and set the inv_lbreaks offsets correctly and set + lpos appropriately + - _rl_move_cursor_relative: always called with either visible line or + invisible line. Decide whether we are being called with the invisible + line (or a portion thereof) as the DATA argument; make sure to account + for invisible characters in the last line of the prompt by offsetting + the desired buffer offset (NEW) by where DATA starts in invisible line + and checking whether that is past the last invisible character in + the prompt + - _rl_move_cursor_relative: do the same for the visible line by using + the visible line lbreaks array instead of _rl_screenwidth, since + that fails in the presence of multibyte characters (buffer offset + vs. physical screen position). These fix bug with prompts with + multibyte characters and invisible characters that are longer than + the screen width reported by Ryo Furue + + 12/1 + ---- +parse.y,make_cmd.c + - here_doc_first_line: new variable, set to non-zero to indicate the + first line of possibly multiple here documents associated with the + current command. Set in parse.y:gather_here_documents() before + reading any here documents, set to 0 after reading the first line + of any here document in make_cmd.c:make_here_document(). + +parse.y + - history_delimiting_chars: if parser_state indicates we are reading + a here document, don't use current_command_line_count to see whether + or not we're on the first line of a here document -- it can be fooled + by multi-line commands (or even backslash-escaped newlines). Use + here_doc_first_line to check that directly. Fixes bug reported by + Geoffrey Allott + +shell.h,parse.y + - save and restore here_doc_first_line as part of the shell's parser + state + +lib/sh/tmpfile.c + - use ANSI-C rand() interface if random() not available. Fixes problem + with linking on (ancient) Solaris 2.4 reported by Klaus Ziegler + + + 12/2 + ---- +aclocal.m4 + - RL_LIB_READLINE_VERSION: if cross-compiling, assume current version + of readline if cross-compiling bash while using an external readline + library. Fix from Barry Davis + +execute_cmd.c + - execute_builtin: save and restore value of builtin_ignoring_errexit + instead of assuming we can set it back to 0 -- the ignore-errexit + cases might be nested + - execute_builtin: after a builtin executes and eval_unwind is set, + set exit_immediately_on_error to 0 if builtin_ignoring_errexit is + set, and back to the value of errexit otherwise, just like the + code that sets -e does. Fixes short-circuiting bug reported by + Marcin Swigon + + 12/5 + ---- +builtins/setattr.def + - set_or_show_attributes: instead of using a fixed string for the + options argument to `declare', which results in export adding the + readonly attribute, build the option string dynamically like in + subst.c:shell_expand_word_list() + - set_or_show_attributes: don't add the -r option to declare if the + attribute passed as an argument doesn't include att_readonly; add + -x if the attribute includes att_exported + - set_or_show_attributes: add the -g option to declare so readonly + and export in functions that go through this code path don't create + local variables. Part of fix for bug reported by ziyunfei + <446240525@qq.com> + +execute_cmd.c + - make_internal_declare: if we have an assignment builtin that isn't + supposed to create local variables (export/readonly), make sure to + add the W_ASSNGLOBAL flag to each assignment statement word. + Part of fix for bug reported by ziyunfei <446240525@qq.com> where + readonly can create local variables when invoked with a compound + array assignment as an argument within a shell function + +subst.c + - make_internal_declare: added third argument: command name. Not used + in any useful way yet + - do_compound_assignment: handle attempted assignments to readonly + variables and print error messages, like bind_variable does and the + callers expect. This means that assignments to readonly array + variables can't go through a code path that allows them to fail + silently + +doc/Makefile.in + - uninstall: run install-info --delete after removing the installed + info file to update the directory file + +execute_cmd.c + - execute_disk_command: since we still (and have always) perform + redirections in child processes, we need to mark that state so + we know that we're in a child process. subshell_performing_redirections + is the new variable; non-zero when executing do_redirections() + +subst.c + - process_substitute: if we are executing process substitution in a + redirection expansion context (expanding_redir == 1), the child + process should not have access to any temporary environment the + parent has. Call flush_tempenv() in the child process to get rid + of it. Fix for bug reported by Clint Hepner + + 12/9 + ---- +jobs.c + - waitchld: if in posix mode and attempting to let SIGCHLD interrupt the + wait builtin, make sure wait_intr_flag is non-zero before trying to + longjmp to wait_intr_buf. Fixes bug reported by Aharon Robbins + + + 12/10 + ----- +lib/readline/display.c + - update_line: if a prompt containing invisible characters changes, + and the change is within the prompt string, we need to redraw the + entire prompt. After that redraw, if the cursor position is after + the first index where the old and new lines differ, we can short- + circuit the update if the line length stays the same + - update_line: if we redraw the entire prompt string because the prompt + contains invisible characters and the first difference is in the + middle of the prompt, we possibly need to adjust our idea of the + first differing character in the old and new lines. We punt and do + a dumb update in this case. Fixes bug with dynamic vi-mode mode + strings containing invisible characters reported by Dylan Cali + + + 12/11 + ----- +lib/readline/display.c + - update_line: if we move up to a new screen line, we need to recompute + the number of invisible characters on the new current line + (visible_wrap_offset). Fixes bug reported to bug-readline by + Per Bothner + - update_line: update code that attempts to compute where we are in + the new line buffer. Fixes `vt100' bug reported to bug-readline by + Per Bothner + + 12/18 + ----- +execute_cmd.c + - execute_function: unwind-protect and restore BASH_ARGC and BASH_ARGV + - restore_funcarray_state: now global + +execute_cmd.h + - make func_array_state type global, add extern function declaration + for restore_funcarray_state + +builtins/evalfile.c + - _evalfile: use restore_funcarray_state and pop_args as unwind-protects + to restore BASH_{SOURCE,LINENO,ARGC,ARGV} and FUNCNAME on interrupts. + Fixes bug reported back on 11/10 by Grisha Levit + + + 12/20 + ----- +lib/readline/isearch.c + - _rl_isearch_dispatch: after removing the only character from the + search string with DEL, leaving the search string empty, don't match + the previous line if we didn't have a match before + + 12/22 + ----- +bashhist.c + - enable_history_list,remember_on_history: initialize to 0 instead of 1 + +shell.c + - init_interactive,init_interactive_script: set enable_history_list and + remember_on_history to 1 (defaults) + + 12/23 + ----- +variables.c + - initialize_shell_variables: don't inherit PS4 from the environment + if the shell is running with euid == 0; just reset it to `+ '. This + is a known potential vulnerability, since PS4 expansion performs + command substitution in the root shell's context before displaying + it. Discussion started by up201407890@alunos.dcc.fc.up.pt + +bashhist.c + - bash_history_reinit: initialize remember_on_history to the value of + enable_history_list (set -o history). Fixes bug reported by + Stephane Chazelas with command-line + option `-o history' not having any effect + + 12/28 + ----- +lib/readline/{history.h,histfile.c} + - history_file_version: new int variable, reserved for future use + - history_multiline_entries: new int variable, can be set by the + calling application to enable reading multi-line history entries + from the history file (currently undocumented) + +lib/readline/history.c + - _hs_append_history_line: new function, append a line passed as an + argument to a specified history entry, used to create multi-line + history entries + +lib/readline/histfile.c + - read_history_range: implement a heuristic that temporarily sets the + history comment character if the first line read from the history + file looks like it has is a timestamp (#[:digit:]) so we can read + timestamps from the history file properly. Originally reported + back in March 2015 by Christoph Anton Mitterer + - read_history_range: make sure history_multiline_entries is non-zero + if the history file looks like it has timestamps + - read_history_range: if we think we have a history file with timestamps + and we read more than one non-timestamp consecutive history lines, + assume they are part of a single multi-line history entry and paste + them together using _hs_append_history_line. Feature most recently + requested by james harvey , also suggested + by Christoph Anton Mitterer + +examples/loadables/setpgid.c + - setpgid: new loadable builtin, originally contributed by Jason + Vas Dias + + 12/29 + ----- +bashhist.c + - bash_history_inhibit_expansion: fix cases where a history expansion + should be skipped because it's in a command or process substitution + but there is another history expansion preceding the substitution + on the command line. Don't let the previous history expansion fool + the function into saying the command substitution history expansion + should be performed + +builtins/evalstring.c + - parse_prologue: always unwind-protect history_expansion_inhibited, + since history expansion can be enabled in non-interactive shells, + and calling eval once in a non-interactive shell inhibits history + expansion forever even if `set -o histexpand' was run before the + eval + +builtins/common.h + - SEVAL_NOHISTEXP: new flag for parse_and_execute/parse_string; means + to not perform history expansion (decouple from SEVAL_NOHIST, which + now means to not remember commands on history); changed all callers + that had SEVAL_NOHIST to have SEVAL_NOHIST|SEVAL_NOHISTEXP + +builtins/evalstring.c + - parse_prologue: instead of calling bash_history_disable, set + remember_on_history to 0 if SEVAL_NOHIST and history_expansion_inhibited + to 1 if SEVAL_NOHISTEXP + + 12/30 + ----- +subst.c + - skip_to_histexp: new function, a stripped-down version of skip_to_delim. + Used to skip to the next unquoted instance of the history expansion + character, handles peculiar quoting and command/process substitution + requirements. Better fix for bug reported by + Zigmund.Ozean@zig-home.localdomain back in January, prompted by report + from Keith Thompson + +bashhist.c + - bash_history_inhibit_expansion: use skip_to_histexp instead of + skip_to_delim + +subst.c + - parameter_brace_expand_rhs: if the rhs of an expansion is "$@" and + IFS is null, we need to separate the (quoted) positional parameters + in the returned word with a space, and mark the word as needing to + be split on spaces (W_SPLITSPACE). Fix for issues reported back in + October 2014 as the result of an austin-group discussion, and just + re-reported by Martijn Dekker + + 1/4/2016 + -------- +execute_cmd.c + - execute_simple_command: if autocd is set, invoke a function named + `cd' if one exists, instead of the shell builtin. Feature requested + by transl8czech@gmail.com + +builtins/mkbuiltins.c + - if a command's short description is the same as its name (e.g., `true'), + don't mark the short doc to be translated. Report and fix from + Benno Schulenberg + + 1/6 + --- +subst.c + - command_substitute,process_substitute: before replacing the file + descriptor underlying stdout (fd 1), make sure to purge any pending + stdio output that hasn't been written successfully, even after a + call to fflush(). Fixes bug reported by cks@cs.toronto.edu + + 1/7 + --- +builtins/{echo,printf}.def + - echo_builtin,printf_builtin: don't use terminate_immediately; use + calls to QUIT in the body of the print loop after writes and flushes. + Fixes problem with running the signal handler and exit trap in a + signal context and other bug reported by cks@cs.toronto.edu + +builtins/common.c + - sh_chkwrite: put in calls to QUIT to catch signals that interrupt + writes + +shell.c + - get_current_user_info: protect endpwent() with #ifdef HAVE_GETPWENT. + Fixes bug reported by pb + + 1/8 + --- +lib/readline/bind.c + - _rl_init_file_error: now a varargs function so it can take format + strings and arguments and pass them to vfprintf + - rl_parse_and_bind: print a warning if we encounter a key binding + string with one or more hyphens but we don't find a valid modifier + (`control', `meta', etc.). Prompted by a report from Andrew Kurn + + - rl_parse_and_bind: improve several existing error messages now that + _rl_init_file_error takes a variable number of arguments + - rl_variable_bind: print error message upon encountering unknown + variable + + 1/10 + ---- +lib/readline/bind.c + - rl_parse_and_bind: if a `bare' keybinding is supplied without any + terminating `:' or whitespace separating it from the command to be + bound, signal an error + + 1/11 + ---- +subst.c + - process_substitute: when compiled without job control (JOB_CONTROL not + defined), make sure we call stop_making_children like we do in the job + control code branch, so already_making_children is reset to 0. This + is what command substitution does. Fixes bug reported by Alastair + Hughes + + 1/12 + ---- +execute_cmd.c + - execute_in_subshell: if a user subshell (`(command)') or other shell + compound command has an input pipe, note for later by setting + stdin_redir. This will inhibit the implicit redirection of standard + input from /dev/null for async commands executed as part of this + subshell. Fixes bug reported by Martin D Kealey + - execute_simple_command: if the shell forks to execute this command + because it has an input pipe, set stdin_redir to inhibit later redirection + from /dev/null for async commands + + 1/13 + ---- +execute_cmd.c + - HASH_BANG_BUFSIZE: use #define for size of buffer used in + READ_SAMPLE_BUF instead of straight constant 80 + - HASH_BANG_BUFSIZ: increase to 128 because Linux allows 128 chars in + exec header. Reported by Ludovic Courtès + +configure.ac + - remove support for purify and purecoverage + - change release level to `rc1' + + 1/15 + ---- +builtins/enable.def + - dyn_load_builtin: fix missing argument to builtin_error if load function + returns an error. Fix from Aharon Robbins + + 1/18 + ---- +builtins/history.def + - histtime: display a better error message for invalid timestamps; use + existing `??' string for empty/missing timestamps or invalid history + entries. Suggestion from Reuben Thomas + + 1/21 + ---- +lib/readline/text.c + - rl_insert: when trying to optimize typeahead, make sure to reset the + key sequence and key sequence length when we read a character that is + not bound to self-insert. Bug report from Geir Hauge + + + 1/25 + ---- +doc/{bash.1,bashref.texi} + - word splitting: add example showing how -d'' is equivalent to -d + after word splitting and null argument removal + + 1/27 + ---- +doc/{bash.1,bashref.texi} + - read: modify description to make it more clear that the line is split + using the same rules as word splitting, and use `delimiters' instead + of `separators', which people read the wrong way + + 2/2 + --- +variables.c + - initialize_shell_variables: allow FUNCNEST to set funcnest_max when + imported from the environment. Inspired by + https://bugzilla.redhat.com/show_bug.cgi?id=1274553 + + 2/11 + ---- +bashhist.c + - bash_history_inhibit_expansion: function should be compiled in only if + BANG_HISTORY is defined. Report from isabella parakiss + + +[bash-4.4-rc1 frozen] + + 2/15 + ---- +lib/readline/text.c + - rl_refresh_line: call rl_redraw_prompt_last_line instead of + rl_forced_update_display to avoid redrawing all lines of a multiline + prompt (overwriting the last line of the multiline prompt in the + process). Report from Hugh Davenport + + 2/18 + ---- +subst.c + - parameter_brace_expand: when processing ${!name[@]}, make sure to + free `name' before returning the list of keys to avoid a memory leak. + Fixes bug reported by Emilio PastorMira + + 2/19 + ---- +trap.c + - free_trap_strings: when freeing the `special' traps (NSIG to BASH_NSIG), + check whether or not the `signal' is trapped, as it would be if the + subshell inherited it (errtrace) and don't free the trap string in that + case. Fixes bug reported by Jan Klötzke + + 2/21 + ---- +lib/sh/netconn.c + - isnetconn: return false if getpeername fails with errno == EBADF. + Bug and fix from Andrew Gregory + +builtins/shopt.def + - parse_bashopts: when reading BASHOPTS from the environment, make + sure to call any set functions associated with a variable, instead + of just setting the value to 1. Report and fix from + Vehlow, Jörg + + 2/22 + ---- +lib/readline/complete.c + - rl_display_match_list: don't bother calling strrchr to check the + return value from printable_part() if rl_filename_completion_desired + is non-zero, since in that case printable_part just returns its + argument. Fixes git completion issue reported by + Dilyan Palauzov + - _rl_colored_completion_prefix: default is now 0, testing is complete + + 2/23 + ---- +variables.c + - assign_hashcmd: if the shell is restricted, reject attempts to add + pathnames containing slashes to the hash table, as the hash builtin + does. Fixes bug reported to savannah by Sylvain Beucler as + https://savannah.gnu.org/support/?108969 + + 2/24 + ---- +subst.c + - NEED_FPURGE_DECL: need it before externs.h included, since fpurge + is now used in this file. Fixes warning reported by Mike + Frysinger + - skip_double_quoted: add missing argument to declaration + +parse.y + - shell_getc: in call to internal_warning, use %lu to print an argument + cast explicitly to unsigned long. Fixes warning reported by Mike + Frysinger + + 2/27 + ---- +parse.y + - decode_prompt_string: quote result of \s expansion in case shell has + been invoked with a pathname like '$(id)'. Inspired by report from + Travis Garrell + - decode_prompt_string: quote result of \h and \H expansions in the + (unlikely) case that the hostname has been changed to something + malicious including a command substitution. From report from + Travis Garrell + +builtins/getopts.def + - getopts_unbind_variable: new static function, just calls unbind_variable + for now. Placeholder for any future work to do something special if + OPTARG is readonly. Based on discussion started by Robert Elz + + +lib/readline/vi_mode.c + - rl_vi_unix_word_rubout: new function, implements ^W as Posix specifies + it for vi mode, using whitespace and punctuation characters as word + boundaries. Prompted by question from Carlos Pita + + +lib/readline/vi_keymap.c + - bind rl_vi_unix_word_rubout to ^W by default in both insert and + command mode + +lib/readline/rltty.c + - _rl_bind_tty_special_chars: if in vi mode, bind the WERASE character + to rl_vi_unix_word_rubout + +lib/readline/funmap.c + - vi-unix-word-rubout is new bindable name for rl_vi_unix_word_rubout + +lib/readline/readline.h + - rl_vi_unix_word_rubout: new extern declaration + + 2/28 + ---- +doc/bash.1 + - document readline blink-matching-paren variable + - document readline completion-display-width variable + - document readline completion-map-case variable + - note that the default value of history-size depends on the value of + the HISTSIZE variable. All from a message from Branden Robinson + + +doc/bash.1,lib/readline/doc/{readline.3,rluser.texi} + - convert-meta: modify the description to note that readline will turn + the default to off if the locale contains eight-bit characters + - input-meta: modify the description to note that readline will turn + the default to on if the locale contains eight-bit characters + - output-meta: modify the description to note that readline will turn + the default to on if the locale contains eight-bit characters. From + a message from Branden Robinson + + 3/6 + --- +examples/loadables/Makefile.in + - install-dev: make installdirs a prerequisite; don't rely on the + install-supported target to create it first. Bug with parallel + install (`make -j 4 install') reported by Chris Staub + + + 3/12 + ---- +lib/readline/display.c: + - rl_clear_visible_line: clear all screen lines occupied by the current + visible readline line. Inspired by report from Lauri Ranta + + +lib/readline/readline.h + - rl_clear_visible_line: extern declaration + +lib/readline/doc/rltech.texi + - rl_clear_visible_line: add documentation + + 3/19 + ---- +findcmd.c + - file_status: add inadvertently-dropped test for EXECIGNORE to the + `other' bits check. The check was in the original patch + - search_for_command: if the file should not be considered executable + because it's in the EXECIGNORE blacklist, don't set file_to_lose_on, + since the attempt to execute the last-ditch path will circumvent the + EXECIGNORE setting. Fixes bug reported by Dennis Williamson + + + 3/28 + ---- +lib/readline/display.c + - rl_redisplay: when computing where the cursor should go (and the + physical cursor position) after displaying the prompt, don't adjust + the cursor position by wadjust if there are no multibyte chars in + the prompt. lpos is already a physical cursor position; _rl_screenwidth + is the physical screen width, and we're not calling _rl_col_width and + don't need to take invisible characters into account again. Fixes + bug reported by Andreas Schwab + + 4/1 + --- +parse.y + - parse_comsub: when we read `esac' followed by a break character, + turn on the LEX_RESWDOK flag because we can now read another case + statement or other compound command. Fixes bug reported by + Christian Franke , original version + of patch from Piotr Grzybowski + - parse_comsub: leave the reserved-word-ok flag set for four-char + reserved words (then/else/elif/done/time) that can be followed by + reserved words; set lex_rwlen to 0 so we know to start reading a + new one + + 4/7 + --- +builtins/{alias,complete,jobs}.def + - {alias,compopt,disown}: add missing `CASE_HELPOPT;' so --help option + prints help longdoc instead of builtin_usage() + + 4/8 + --- +arrayfunc.c + - assign_array_var_from_word_list: use bind_array_var_internal instead + of inline code, so value conversions happen on assignment (case + modification, arithmetic evaluation, etc). Fixes bug reported by + Geir Hauge + + 4/9 + --- +shell.c + - main: change the logic that determines whether or not bash is running + under an emacs terminal emulator so it works with future versions of + emacs, which will change to use only $INSIDE_EMACS. Report and fix + from Paul Eggert + +lib/glob/sm_loop.c + - EXT: if we see ?(pat), we can match 0 or 1 times, so if we don't + match, we should consume the extglob pattern and go on to attempt + to match the rest of the pattern against the string. Fixes bug + reported by Isabella Parakiss + - GMATCH: in case `*', don't short-circuit and match anything if the + * is the last character in the pattern until after we check the + special cases for matching a `.'. Fixes bugs reported back on 3/23 + by Isabella Parakiss + + 4/13 + ---- +bashhist.c + - hc_erasedups: fix memory leak by freeing history entry returned by + remove_history. Bug and fix from Seiichi Ishitsuka + + + 4/19 + ---- +config-top.h + - CD_COMPLAINS: now settable in config-top.h; enables (fatal) error + messages if cd is given multiple directory arguments + + 4/20 + ---- +execute_cmd.c + - coproc_setvars: refuse to create variables with names that are not + valid identifiers. Suggestion from Piotr Grzybowski + + +rltty.c + - rl_tty_set_echoing: interface to set _rl_echoing_p, returning old + value. Inspired by gdb use of _rl_echoing_p when switching + between terminal and curses modes described by Doug Evans + + +bashline.c + - bash_execute_unix_command: use rl_clear_visible_line instead of + erasing current line on the screen, inspired by same report from + 3/12. Still tentative change + +configure.ac + - update release status to rc2, may skip this and go directly to + release + + 4/21 + ---- +arrayfunc.c + - convert_var_to_array: make sure that the newly-converted array + variable is not marked as being an associative array. Fixes bug + reported by Grisha Levit + - convert_var_to_assoc: make sure that the newly-converted associative + array variable is not marked as being an indexed array + + 4/22 + ---- +builtins/evalstring.c + - should_suppress_fork: don't suppress the fork if there are any traps + set, since that requires that we hang around to react to a signal or + collect the command's exit status and run something. Fixes bug + reported by Brian Vandenberg + +histexpand.c + - history_tokenize_word: handle >| as a single token. Fix from + Piotr Grzybowski from a report from + idallen@idallen-fibe.dyndns.org + + 4/24 + ---- +execute_cmd. + - coproc_setvars: don't overwrite readonly variables used as coproc + names. From a report from Grisha Levit + +histexpand.c + - history_tokenize_word: handle strings of digits before redirections + beginning with `<' or `>' as part of the redirection word; handle + strings of digits following `<&' or `>&' as part of the redirection + word. Inspired by patch from Piotr Grzybowski + from a report from idallen@idallen-fibe.dyndns.org + +lib/readline/complete.c + - rl_display_match_list: if the common prefix is longer than any of + the possible matches, set the length of the common prefix to 0 so + the entire match gets printed for each match + - rl_display_match_list: make sure to output at least one space + between each displayed match, even if the displayed length is + longer than our computed max + - fnprint: if the length of the prefix (prefix_bytes) is greater than + or equal to the length of the string to be printed (print_len), make + sure to set the prefix length to 0 so the entire string is printed. + From a report from Grisha Levit + + 4/25 + ---- +subst.c + - command_substitute: update the conditions under which we give the + terminal to pipeline_pgrp with give_terminal_to to the same ones + where wait_for uses to decide whether to give the terminal back to + shell_pgrp. This code exists to undo the work wait_for does; it + has to give the terminal back to pipeline_pgrp only under those + conditions when wait_for gives it back to the shell pgrp. Fix for + bug reported by Paulo Bardes + + 4/26 + ---- +bashline.c + - bash_filename_stat_hook: temporarily disable the `nounset' shell + option around calls to expand_prompt_string so we don't get error + messages during completion. Fixes issue reported by Eric Pruitt + + + 4/27 + ---- +doc/{bash.1,bashref.texi} + - extdebug: clarify that having this option enabled at shell startup + acts identically to --debugger. From a report from Grisha Levit + + +jobs.[ch] + - wait_for_single_pid: now takes additional `int flags' argument + +{jobs,execute_cmd}.c,builtins/wait.def + - wait_for_single_pid: changed callers to add extra argument + +jobs.c + - wait_for_single_pid: if (flags & 1) == 0, don't print the error + message if PID isn't found; changed execute_pipeline call when + lastpipe is set + + 4/28 + ---- +general.c + - bash_tilde_expand: try not setting interrupt_immediately or + terminate_immediately; see what happens with networked password + databases + + 4/29 + ---- +subst.c + - parameter_brace_expand, parameter_brace_expand_rhs: now take an + additional `pflags' argument from its caller so we can pass + state + - parameter_brace_expand_rhs: if expand_string_for_rhs returns a + quoted null, but l_hasdollat is set to 1, meaning we saw a quoted + "$@" of some form, we need to turn off special handling of "$@" + so something like "${@-${@-$@}}" expands to an empty string like + Posix says it should. Fixes bug reported by Grisha Levit + + + 5/1 + --- +variables.c + - bind_variable_internal: if we have a nameref variable with a valid + array reference that is invalid for assignment (e.g., a[*]), and + assign_array_element returns NULL, short-circuit and return NULL. + Fixes bug reported by Grisha Levit + +general.[ch] + - valid_nameref_value: new function, return 1 if passed argument is + a valid variable name argument for a nameref variable: a valid + identifier, a valid array reference, or a valid positional + parameter. Second argument indicates whether the value is to be + used for an assignment; in this case, return an error if the name + consists of all digits + +builtins/declare.def + - declare_internal: disallow values for nameref variables that don't + pass the tests in valid_nameref_value. Part of fix for bug + reported by Grisha Levit + +variables.c + - bind_variable_internal: if trying to assign a value to a nameref + variable, throw an error if valid_nameref_value fails (with a second + argument of 1). More fixes for bug reported by Grisha Levit + + + 5/2 + --- +builtins/declare.def + - declare_internal: don't allow nameref attribute to be applied to an + existing readonly variable; it can be used to circumvent readonly + value. Fix for bug reported by Grisha Levit + +variables.[ch] + - find_variable_last_nameref, find_global_variable_last_nameref: takes + a new flags argument. If flags is non-zero, and we find a nameref + variable that is unset (has no value), return that variable instead + of NULL. + +{variables,execute_cmd,arrayfunc,subst}.c,builtins/{declare,set}.def + - find_variable_last_nameref, find_global_variable_last_nameref: change + callers to add flags argument (initially 0) + + 5/3 + --- +variables.c + - bind_variable_internal: make sure we run the value of a namref + variable through valid_nameref_value before doing the assignment. + This can go away if we stop allowing namerefs to refer to positional + parameters + +execute_cmd.c + - execute_select_command: if bind_variable returns NULL, handle it as + an error, as if attempting assignment to a readonly variable + - execute_for_command: use 1 as second argument to + find_variable_last_nameref, so it will return an invisible nameref + to assign for each variable in the list + - execute_for_command: if the current word in the list is an invalid + identifier and the loop variable is a nameref, handle it as an error, + as if attempting assignment to a readonly variable + + 5/4 + --- +variables.c + - bind_int_variable: add warning if assigning an int to a nameref + variable + - assign_in_env: if assigning a variable in the temporary environment + that is a namref, throw an error if trying to assign an invalid + value + - bind_variable_value: use valid_nameref_value instead of calls to + legal_identifier and valid_array_reference + +execute_cmd.c + - coproc_setvars: if we have a nameref variable as the coproc name, but + it can't be assigned to for some reason, remove the nameref attribute + and issue a warning that we are doing so + - coproc_setvars: don't allow assignment to a nameref variable with an + invalid variable name, using same code as find_or_make_array_variable + +general.c + - valid_nameref_value: disallow values consisting solely of digits, + like the positional parameters + +builtins/declare.def + - declare_internal: don't call valid_nameref_value on the existing value + of a variable that's being converted to a nameref -- that value is + going to be thrown away and we've already checked the new value + - declare_internal: call bind_variable_value with the ASS_NAMEREF flag + if we're assigning to an existing nameref variable (for instance, + `declare -n x ; declare x=42') + + 5/5 + --- +variables.c + - make_local_variable: if we are being asked to create a local copy of + a nameref variable from a prior scope (checked by looking up + using find_variable_noref), use the nameref variable, not the variable + it references (which we find using find_variable). Bug report from + Grisha Levit ; fix by Piotr Grzybowski + + +builtins/declare.def + - declare_internal: if asked to do the same thing as above (difference + is declare -n r=foo in previous case; declare -n r in this one), + don't follow reference var from a previous context. Create a new + local variable (using make_local_variable) and inherit attributes + from previous scope's nameref as above + + 5/6 + --- +builtins/declare.def + - declare_internal: if we are assigning a value to an existing + invisible nameref variable, validate value early so we don't end up + removing the variable after the assignment fails + +builtins/shopt.def + - toggle_shopts: don't call set_bashopts here unless $BASHOPTS exists, + since we don't want to set it up before it gets read from the + environment. Keeping BASHOPTS read-only should keep users from + unsetting it. Fix from Grisha Levit + - shopt_set_debug_mode: make sure error_trace_mode reflects the setting + of extdebug. This one is tentative. Fix from Grisha Levit + + - shopt_set_debug_mode: call set_shellopts after setting error_trace_mode + or function_trace_mode. Fix from Grisha Levit + +shell.c + - start_debugger: make sure that function_trace_mode and error_trace_mode + reflect the value of debugging_mode, so they are both disabled if we + disable debugging mode because we can't find the debugger start file. + Fix from Grisha Levit + - start_debugger: set $SHELLOPTS and $BASHOPTS to the option values are + reflected if we change or set them here. Fix from Grisha Levit + + +builtins/set.def + - reset_shell_options: add reset values for: posix, nolog, pipefail. + Fix from Grisha Levit + +builtins/shopt.def + - reset_shopt_options: add reset values for: autocd, checkjobs, + complete_fullquote, dirspell, failglob, globstar, gnu_errfmt, + huponexit, inherit_errexit, interactive_comments, lastpipe, + no_empty_cmd_completion, progcomp. Fix from Grisha Levit + + - reset_shopt_options: make sure the following options have the right + defaults based on #defines: checkjobs, checkwinsize, direxpand, + extglob, globasciiranges. Fix from Grisha Levit + + +flags.c + - reset_shell_flags: add missing flags, re-initialize history_expansion + based on STRICT_POSIX + + 5/8 + --- +lib/readline/histexpand.c + - history_expand: if any expansion returns 1 from history_expand_internal, + indicating that :p was supplied, make it apply to the entire line + like tcsh and csh. Fixes bug reported by Dean Stanton + + +variables.[ch] + - ifsname: move define to variables.h + +execute_cmd.c + - execute_for_command: check whether or not the word in the for command + is IFS; call setifs every time the variable is assigned a value. + Fixes bug report from Grisha Levit + + 5/16 + ---- +general.c + - valid_nameref_value: explicitly handle name == 0 and *name == 0 right + away to save calls to legal_identifier + +builtins/declare.def + - declare_internal: if trying to set nameref attribute on a variable + with a null value, flag as invalid assignment, just as if running + `declare -n r=""'. Fixes bug report from Grisha Levit + + - declare_internal: when creating a variable with a temporary value + (""), use ASS_FORCE in the assignment flags to bypass name validity + checks on nameref variable names + +variables.c + - bind_variable_internal: don't call valid_nameref_value if we're + forcing assignment with (flags & ASS_FORCE) + +builtins/read.def + - read_builtin: handle bind_variable returning NULL when setting REPLY. + Report and fix from Grisha Levit + +builtins/setattr.def + - set_var_attribute: handle bind_variable returning NULL + +lib/sh/tmpfile.c + - sh_seedrand(): call srandom() to seed the random number generator + - sh_mktmpname, sh_mktmpfd: if we have random(), assume we have + srandom() and seed the random number generator. Still looking for + better value to see random number generator with + +variables.c + - check_unbind_variable: use internal_error instead of builtin_error + +{execute_cmd,variables}.c + - fix some places where bind_variable could return NULL and it was not + checked. Fix from Piotr Grzybowski + + 5/17 + ---- +arrayfunc.c + - convert_var_to_{array,assoc}: make sure to turn off nameref attribute, + since namerefs can't be arrays + +execute_cmd.c + - coproc_setvars: if the coproc name names a nameref, resolve the + nameref and use it as the name of the coproc. Suggested by Grisha + Levit + +subst.c + - command_substitute: don't bother calling QUIT after calling + reset_signal_handlers in the child, kill the child with SIGINT in + case we just reset the signal handler to SIG_DFL and we should just + exit instead of throwing to top level. Fixes bug reported by + Grisha Levit + + 5/18 + ---- +variables.c + - find_variable_nameref_for_create: find a nameref variable whose value + doesn't resolve to an existing variable and see whether or not that + value is appropriate for a new variable to be created + - find_variable_nameref_for_assignment: find a nameref variable whose + value doesn't resolve to an existing variable and see whether or not + that value is appropriate for a new variable to be created. + Difference between _assignment and _create is that _assignment + allows the nameref value to be a subscripted array reference + +builtins/setattr.def + - set_var_attribute: if variable lookup doesn't return anything, check + for a nameref and make sure that any reference value is something we + should be working on here, using find_variable_nameref_for_create(). + If it fails, error out and return, otherwise it's probably a reference + to a variable that hasn't been set yet, so let bind_variable take care + of that. Report from Grisha Levit + +arrayfunc.c + - bind_array_variable: if find_shell_variable returns NULL, check for a + nameref using find_variable_nameref_for_create and create a new array + variable with the value if it returns a valid nameref variable. + Makes `unset var; declare -n ref=var ; ref[0]=foo' work right. + Report from Grisha Levit + + 5/19 + ---- +variables.[ch] + - unbind_variable_noref: unset a variable NAME without following any + nameref chain. If the first instance of the variable with that name + is a nameref, just unset that nameref variable. + +builtins/getopts.def + - getopts_unbind_variable: if OPTARG is going to be unbound, use + unbind_variable_noref to unbind that name even if it is a nameref + variable. Issue raised by Grisha Levit + +execute_cmd.c + - coproc_unsetvars: use unbind_variable_noref in case someone sets the + coproc _PID variable as a nameref pointing to something read-only or + strange. Issue raised by Grisha Levit + +builtins/set.def + - set_ignoreeof: use unbind_variable_noref to unset "IGNOREEOF" and + "ignoreeof" + - set_posix_mode: use unbind_variable_noref to unset "POSIXLY_CORRECT" + +variables.c + - make_vers_array: use unbind_variable_noref to unset "BASH_VERSINFO" + +lib/sh/shmatch.c + - sh_regmatch: use unbind_variable_noref to unset "BASH_REMATCH" + +bashline.c + - bash_execute_unix_command: use check_unbind_variable to unset + READLINE_LINE and READLINE_POINT + +pcomplete.c + - unbind_compfunc_variables: use unbind_variable_noref to unset + COMP_LINE, COMP_POINT, COMP_WORDS, COMP_CWORD, COMP_TYPE, COMP_KEY + - gen_shell_function_matches: use unbind_variable_noref to unset + COMPREPLY + +config-top.h + - USE_MKTEMP/USE_MKSTEMP: define by default to use libc version of + mktemp and mkstemp in lib/sh/tmpfile.c. Recommended by Mike + Frysinger to fix a FreeBSD problem + +configure.ac,config.h.in + - mkstemp: check for mkstemp, define HAVE_MKSTEMP if available + +config-bot.h + - USE_MKSTEMP: #undef if HAVE_MKSTEMP not defined + + 5/22 + ---- +variables.c + - assign_in_env: if appending to a variable's value, make sure we call + make_variable_value with the empty string if expand_assignment_string_to_string + returns NULL, as do_assignment_internal does. Fixes bug with + `str=''; val=foo ; val+=str printenv val' reported by Grisha Levit + + - assign_in_env: if assigning to a nameref variable in the temporary + environment, and the nameref has a valid value for assignment (even + if the target variable is not set), resolve the nameref and create + a variable in the temporary environment named by the nameref's value. + If the nameref variable is invisible or isn't set to a valid value + for assignment, just create a regular temporary variable with the + nameref's name. This provides a degree of ksh93 compatibility. + Suggested by Grisha Levit + - find_variable_nameref_context,find_variable_last_nameref_context: + instead of returning NULL when detecting a loop, return a + distinguished value: &nameref_maxloop_value + - bind_variable: catch nameref_maxloop_value so we can do different + things based on whether or not we get it. Right now we don't do + anything different, but we could + + 5/24 + ---- +lib/readline/display.c + - update_line,_rl_move_cursor_relative: save value of MB_CUR_MAX in a + variable and use it throughout the functions instead of recomputing it + every time (which possibly costs a function call) + + 5/25 + ---- +builtins/declare.def + - declare_internal: only check whether the value being assigned to a + nameref variable is a valid identifier if we're not appending to an + existing value. Suggested by Grisha Levit + - declare_internal: add a couple of more checks on nameref names: + o make sure `declare -n x[3]=y' is an error + o nameref variable self-references now produce a warning when + in function scope + o nameref variable self-references using subscripted arrays + (a=a[0]) now produce warnings at function scope and errors at + global scope + + 5/29 + ---- +builtins/declare.def + - declare_internal: use name of readonly variable when calling sh_readonly + instead of name passed as argument to declare in case we've followed + a nameref chain + - declare_internal: when turning off attributes on a nameref variable + after following the nameref chain and turning them off on the target + variable, don't allow the readonly attribute to be removed. This is + primarily intended to turn off the nameref attribute. Issue pointed + out by Grisha Levit + - declare_internal: if we are attempting to modify an existing global + nameref variable, and the -n option is supplied, operate on the + nameref variable itself, not the variable it references + +doc/{bash.1,bashref.texi} + - change the descriptions of namerefs and declare -n slightly to note + that using the -n option to declare will operate on the nameref + variable itself rather than the variable it references + +variables.c + - bind_variable_internal: if trying to assign to a read-only variable, + print the error message using the variable's name instead of the + name passed to bind_variable in case we followed a nameref + +builtins/declare.def + - declare_internal: when we're creating a (possibly invisible) variable + as part of another operation, assigning NULL, make sure to use + ASS_FORCE to avoid warning messages from any existing nameref + variables we follow + - declare_internal: allow the nameref attribute to be removed from a + readonly nameref variable without a value but do not allow it to be + removed from a readonly nameref variable that has a value, even if it + doesn't reference an existing variable. This distinction is for ksh93 + compatibility. Pointed out by Grisha Levit + + 5/31 + ---- +builtins/declare.def + - declare_internal: if the call to bind_variable_value fails for some + reason, make sure to restore the nameref attribute to flags_on and + flags_off before calling NEXT_VARIABLE + +subst.c + - make_internal_declare: handle += append op + - shell_expand_word_list: when transforming assignment statement + arguments to `declare', make sure to handle += append op to avoid + passing invalid identifiers to declare. Report by Grisha Levit + + + 6/1 + --- +builtins/declare.def + - declare_internal: if a nameref assignment fails, only call delete_var + to delete the variable if we created it in declare_internal in the + first place + +general.c + - check_selfref: new function, checks a NAME against a VALUE for nameref + self-reference + +general.h + - check_selfref: extern declaration + +builtins/declare.def + - declare_internal: call check_selfref to determine whether a given NAME + and VALUE constitute an invalid nameref variable self-reference + +variables.c + - bind_variable_internal: call check_selfref to determine whether a + given NAME and VALUE constitute an invalid nameref variable self- + reference + + 6/2 + --- +parse.y + - clear_shell_input_line: new function, clears contents of shell_input_line + and sets index to 0, but doesn't free it + +externs.h + - clear_shell_input_line: extern declaration + +builtins/evalstring.c + - parse_and_execute: call clear_shell_input_line after setting input to + string to be executed. Fixes problem with command substitution and + multi-line aliases reported by Grisha Levit + +eval.c + - parse_command: only execute PROMPT_COMMAND if the shell is not + currently expanding an alias; use the same tests as parse.y:SHOULD_PROMPT + and parse.y:prompt_again() use to decide whether or not to print a + prompt. Fixes problems with PROMPT_COMMAND and multi-line aliases + reported by Grisha Levit + +builtins/set.def + - unset_builtin: changes to fix three problems reported by Grisha + Levit : + o if -n is supplied, we should not try to unset a function if + a variable isn't found + o unsetting namerefs whose values are array references does + not work + o unset -n n[0], where n is a nameref, would unset the + referenced variable instead of `n' + +redir.c + - redir_varvalue: handle case where nameref var points to subscripted + array reference. Reported by Grisha Levit + +variables.c + - bind_variable_value: make sure to call check_selfref only if aflags + includes ASS_NAMEREF and not ASS_FORCE. Reported by Grisha Levit + + +general.c + - valid_nameref_value: now understands a FLAGS value of 2 to mean that + the name will be used to create a variable, so only legal_identifier + matters + +arrayfunc.c + - find_or_make_array_variable: call valid_nameref_value with FLAGS value + of 2 to indicate we will be creating a variable. Fixes mapfile issue + reported by Grisha Levit + + 6/5 + --- +builtins/declare.def + - declare_internal: only pass ASS_FORCE as part of assignment flags to + assignments concerning arrays + - declare_internal: when at the global scope, if we resolve a nameref + and commit to using the new name, go back to to the beginning of the + loop and use the new name in the checks and variable references. + Make sure we construct the new name as a straight substitution of + the nameref value into the old name, including array subscripts and + rebuilding the correct values for `offset' and `value', since they + are relative to the original value of name. + Fixes several issues with checking use of subscripted array variables + as nameref values + - declare_internal: when calling assign_array_element, make sure to + pass ASS_APPEND if aflags includes it, so things like + declare -a var; var[1]=1; declare var[1]+=4 + append to the value appropriately and var[1] ends up being `14' + +arrayfunc.c + - valid_array_reference: make sure the array reference is properly + terminated after the first subscript; return invalid if there is + anything following the closing `]' + + 6/12 + ---- +variables.c + - bind_variable_internal: if asked to perform an array subscript + assignment on a nameref variable, display a warning and remove the + nameref attribute (as bash-4.3 did). Reported by Dan Douglas + + + 6/14 + ---- +test.c + - posixtest: handle four-argument case where argv[1] == '(' and + argv[4] == ')' by performing two-argument test on $2 and $3. + Reported by Joerg Schilling + + 6/15 + ---- +variables.c + - sv_ignoreeof: make sure ignoreeof is set only if IGNOREEOF is set and + has a value (no `local IGNOREEOF'). Reported by Grisha Levit + + - sv_strict_posix: make sure posixly_correct is set only if + POSIXLY_CORRECT is set and has a value. Reported by Grisha Levit + + + 6/16 + ---- +builtins/declare.def + - declare_internal: analogous to 6/12 change; when performing an array + subscript assignment on a nameref, display a warning, remove the + nameref attribute, and go on + + 6/21 + ---- +execute_cmd.c + - shell_execve: make sure errno is (re)set appropriately before + returning error value on exec format error + + 6/23 + ---- +subst.c + - param_expand: when expanding $* in a context where splitting is not + desired (pflags & PF_ASSIGNRHS), make sure to quote the word and the + included separators. Reported by Dan Douglas + + 6/30 + ---- +configure.ac + - release version is now `beta2' + +execute_cmd.c + - execute_simple_command: even if already_making_children is non-zero, + don't call wait_for if last_made_pid == NO_PID. Indirectly inspired + by report from Nicolas Vivet + + 7/2 + --- +subst.c + - expand_word_internal: when adding an IFS character to the accumulated + string, don't quote it if word expansion is not going to be + performed ((word->flags & (W_NOSPLIT|W_NOSPLIT2)) == 0) in the + default case. This was already the case everwhere else, when we did + `goto add_ifs_character;'. Fixes bug reported by Ibrahim M. Ghazal + + +subst.[ch],arrayfunc.c + - string_list_dollar_at: now takes a new third argument, currently + reserved for future use; changed callers and declaration + + 7/7 + --- +[bash-4.4-beta2 frozen] + + 7/9 + --- +bashline.c + - check_redir: make sure that index is > 0 before checking previous + char; fixes out of bounds read reported by Hanno Böck + + + 7/16 + ---- +subst.c + - parameter_brace_expand: if ${array[@]} or ${array[*]} is supplied + with an unset (or empty) array, and -u is enabled, don't make it + an unbound variable error, like $@ or $* when there are no + positional parameters. Based on report from Ian Allen + + +lib/readline/signals.c + - rl_pending_signal(): return the number of any signal readline has + caught but is waiting to handle + +lib/readline/callback.c + - rl_persistent_signal_handlers: new variable, restores readline-6.2 + signal handler semantics: installed at rl_callback_handler_install + time and removed with rl_clear_signals when a complete line has + been read + - _rl_callback_newline: call rl_set_signals if rl_persistent_signal_handlers + is non-zero + - rl_callback_read_char: install signal handlers with rl_set_signals + if rl_persistent_signal_handlers is 0 (the default) + - CALLBACK_READ_RETURN: uninstall signal handlers with rl_clear_signals + only if rl_persistent_signal_handlers is 0 (the default) + +lib/readline/readline.h + - rl_pending_signal: new extern declaration + - rl_persistent_signal_handlers: new extern declaration + + 7/19 + ---- +execute_cmd.c + - execute_while_or_until: make sure we decrement `continuing' the way + we decrement `breaking' if the loop test indicates we will be + breaking out of the loop. That keeps `until continue' from + keeping `continuing' set to 1. Reported by Dan Douglas + + + 7/20 + ---- +trap.c + - run_pending_traps,_run_trap_internal: save and restore temporary_env, + set temporary_env to 0 before trap runs so traps don't inherit a + command's temporary env. Fixes bug with IFS assignment in tempenv + and trap reported by Andriy Martynets + +jobs.c + - run_sigchld_trap: save and restore temporary_env, set temporary_env + to 0 before trap runs so traps don't inherit a command's temporary + env (see above) + + 7/21 + ---- +execute_cmd.c + - execute_function: unwind-protect function_line_number, in case we + are executing a function inside another function. Reported by + Grisha Levit in context of evaled functions + and DEBUG traps + - execute_arith_for_command,execute_arith_command,execute_simple_command, + execute_cond_command: make sure line_number doesn't go < 0 when + adjusting it by function_line_number + + 7/23 + ---- +subst.c,command.h + - move the PF_ constants to command.h so other files can see them, now + that PF_ASSIGNRHS has meaning to string_list_dollar_at + +arrayfunc.h + - AV_ASSIGNRHS: new flag, indicate that ${a[@]} is being expanded on + the RHS of an assignment statement + +arrayfunc.c + - array_value_internal: if AV_ASSIGNRHS passed for ${a[@]}, pass + PF_ASSIGNRHS to string_list_dollar_at to support args separated by + spaces even if $IFS does not have the default value. Reported by + Dan Douglas + +subst.c + - string_list_dollar_at: if FLAGS argument includes PF_ASSIGNRHS, obey + rules for $@ on the RHS of an assignment statement: expand to + postitional parameters separated by spaces no matter what the first + character of $IFS is. Reported by Dan Douglas + - parameter_brace_expand_word: pass AV_ASSIGNRHS as flags value to + array_value if PF_ASSIGNRHS is set and we are expanding an array + variable subscripted by @ or * + - param_expand: pass pflags to string_list_dollar_at in case it contains + PF_ASSIGNRHS + - expand_word_internal: if we have an assignment statement argument to + a declaration builtin (W_ASSIGNARG), turn on W_ASSIGNRHS when we see + the `=' to enable special $@ behavior + - expand_word_internal: if W_ASSIGNARG enabled in word flags, pass that + flag and W_ASSIGNRHS to recursive call to expand_word_internal when + expanding double-quoted string; handles "$@" when IFS is not the + default value and word splitting will not be performed + +subst.c + - expand_word_internal: change case that handles '' (single-quoted + empty string) to only discard it if we will not be performing word + splitting (W_NOSPLIT|W_NOSPLIT2), since we need to add a quoted null + argument if the subsequent characters will cause word splitting. + This is how "" (double-quoted empty string) is handled after a bug + fix back in August 2010. Reported by Grisha Levit + , fix for Posix interp 888 + + 7/27 + ---- +subst.c + - param_expand: change fix from 6/23 (expanding $* in a context where + word splitting is not performed) to make sure that $* expands to + something before trying to quote the string. Bug and fix from + Andreas Schwab + +lib/readline/bind.c + - _rl_get_string_variable_value: fix a cut-and-paste error that caused + the emacs mode string to be displayed for both vi insert and command + mode strings. Report and fix from Steve Jones + + 7/28 + ---- +lib/readline/display.c + - update_line: we can't use PROMPT_ENDING_INDEX unless we're testing + against _rl_last_c_pos; if we are testing buffer indices, we need to + use prompt_last_invisible directly. Fixes mode string redisplay issue + with short prompt strings reported by Steve Jones + + 8/4 + --- +nojobs.c + - without_job_control: new function, resets child state that's + eventually used to decide whether or not to wait_for children + +execute_cmd.c + - initialize_subshell: call without_job_control in both the + JOB_CONTROL and no job control paths so we can reset the state in + subshells that will not cause them to wait_for children + inappropriately. Fixes bug reported by Dan Cross + + 8/5 + --- +configure.ac + - release version is now `rc2' + +bashline.c + - command_word_completion_function: if direxpand is set, make sure to + run hint_text through bash_directory_completion_hook, since + readline will do that and we want to be able to match the results + readline returns. Fixes bug reported by Pat Somaru + + +command.h + - W_COMPLETE: new flag word value + - PF_COMPLETE: new flags value for param_expand + +subst.h + - SX_STRIPDQ: new flag, used for string_extract_double_quoted + +bashline.c + - bash_filename_stat_hook,bash_directory_completion_hook: pass W_COMPLETE + flag to expand_prompt_string + +subst.c + - expand_word_internal: if W_COMPLETE in word->flags, pass PF_COMPLETE + to param_expand + - param_expand: if PF_COMPLETE in pflags, pass SX_COMPLETE to + extract_command_subst. This allows `"$(echo ~/' to perform + completion successfully + - string_extract_double_quoted: turn third argument into a flags arg, + old STRIPDQ is now set if flags&SX_STRIPDQ + - string_extract_double_quoted: changed callers, if third argument was + 1, pass SX_STRIPDQ instead + - expand_word_internal: if W_COMPLETE in word->flags, pass SX_COMPLETE + in flags to string_extract_double_quoted for case '"' + - string_extract_double_quoted: if SX_COMPLETE in flags, pass it to + extract_command_subst + - expand_word_internal: if W_COMPLETE in word->flags, make sure W_COMPLETE + is in temp word passed to recursive call to expand_word_internal to + expand double-quoted string. Fixes bug reported by John Passaro + + + 8/9 + --- +[bash-4.4-rc2 frozen] + + 8/10 + ---- +subst.c + - sub_append_string: use size_t variable to store string length to + avoid integer overflow. Report from Siteshwar Vashisht + + - sub_append_string: `size' argument is now pointer to size_t; changed + istring_index in expand_word_internal to accommodate change + +lib/sh/ufuncs.c + - include "posixselect.h" if HAVE_SELECT is defined, make sure that + fd_set and the rest are defined + + 8/11 + ---- +lib/readline/histexpand.c + - history_tokenize_word: use ISDIGIT instead of isdigit for more + argument checking + - "chardefs.h": include for ISDIGIT define and . Fix from + Mike Frysinger + +lib/sh/eaccess.c,externs.h + - sh_eaccess: first argument now const char * + - sh_stataccess,sh_euidaccess: first argument now const char *, since + sh_stat and sh_eaccess call them. + Fix from Mike Frysinger + +lib/glob/glob.c + - sh_eaccess: change local prototype + +general.[ch] + - all_digits,legal_identifier,valid_nameref_value,importable_function_name, + exportable_function_name,check_binary_file,file_exists,file_isdir, + file_iswdir,same_file,make_absolute,valid_nameref_value: first + argument (always identifier or filename) is now a `const char *'; + some second filename arguments now `const char *'. + Fix from Mike Frysinger + +configure.ac,config.h.in + - uintptr_t: make sure it's defined to an integer type wide enough to + hold a pointer + +lib/sh/tmpfile.c + - sh_seedrand: use `uintptr_t' to cast pointer value to int value, + instead of allowing truncation to take place, since srandom takes + an `unsigned int'. + Fix from Mike Frysinger + +arrayfunc.[ch] + - valid_array_reference,array_variable_name,array_variable_part, + array_value_internal,array_value,get_array_value: first argument + (always variable name) now a `const char *' + Fix from Mike Frysinger + + 8/19 + ---- +print_cmd.c + - xtrace_print_word_list: if (xtflags & 2), don't try to quote the + words in the LIST argument. Intended to be used in places where + the list has not yet been expanded + - xtrace_print_for_command_head: call xtrace_print_word_list with + flags argument of 2. Fixes issue reported by Aharon Robbins + + - xtrace_print_select_command_head: call xtrace_print_word_list with + flags argument of 2 + + 8/21 + ---- +lib/sh/netopen.c + - netopen: fix memory leak by freeing allocated path before error + return. Fix from Dmitry Goncharov + +doc/{bash.1,bashref.texi} + - change conditional commands description to make it clearer that + bash doesn't emulate /dev/fd if the OS provides it + + 8/22 + ---- +braces.c + - expand_amble: free partial and tem on failure to allocate memory + for merged partial+result strvec. Fix from Dmitry Goncharov + + + 8/23 + ---- +jobs.c + - wait_for: don't call get_tty_state when a job finishes if we're + running it as part of programmable completion. We test + rl_readline_state. Fixes bug reported by Jaro Punta + + + 8/24 + ---- +subst.c + - pat_subst: fix memory leak (mstr). Fix from Dmitry Goncharov + + - split_at_delims: fix memory leak (d2). Fix from Dmitry Goncharov + + + 8/26 + ---- +subst.c + - match_upattern,match_wpattern: make sure that a trailing `*' is + not escaped (preceded by an odd number of backslashes) before we + append a `*' when checking whether a pattern matches anywhere in + the string + +lib/readline/{input,signals}.c + - protect instances of SIGQUIT with #ifdef SIGQUIT; apparently + MinGW doesn't define it + - protect instances of SIGHUP with #ifdef SIGHUP; apparently + MinGW doesn't define it. From a report from Simon Sobisch + + +xmalloc.o + - allocerr: only try to find the break and report it if we're using + the bash malloc; there's no guarantee that any other malloc is + using sbrk() + +doc/{bash.1,bashref.texi} + - quote removal: add paragraph mentioning quote removal to beginning + of expansions section, referencing later paragraph. Report from + Michel Lanne + + 8/30 + ---- +lib/readline/input.c + - protect instances of SIGALRM and SIGWINCH with #ifdef; apparently + MinGW doesn't define them. From a report from Simon Sobisch + + +subst.c + - SPECIAL_VAR: make sure name is not the empty string before going on, + empty strings can result in unitialized reads + - CHECK_STRING_OVERRUN: semi-general macro to use in *extract* and + similar functions to to check whether a function called to parse an + embedded construct (like a backquoted command substitution) doesn't + consume the entire string because it's unterminated + - skip_double_quoted: make sure other extraction functions don't + consume the entire string (which they can if the construct is + unterminated) before incrementing the index and going on. Uses + CHECK_STRING_OVERRUN + - extract_dollar_brace_string: check for unterminated embedded + constructs consuming the entire string with CHECK_STRING_OVERRUN ('`') + - skip_matched_pair: use CHECK_STRING_OVERRUN to make sure unterminated + embedded "`", $(, ${ don't cause out-of-bounds reads + +[bash-4.4 frozen] diff --git a/CWRU/misc/bison b/CWRU/misc/bison new file mode 100755 index 0000000..58aae79 --- /dev/null +++ b/CWRU/misc/bison @@ -0,0 +1,26 @@ +#! /bin/sh +# +# bison -- just call yacc +# + +# Copyright (C) 1996-2002 Free Software Foundation, Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, 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, see . +# + +if [ "$1" = '-y' ]; then + shift +fi + +exec /usr/bin/yacc ${1+"$@"} diff --git a/CWRU/misc/errlist.c b/CWRU/misc/errlist.c new file mode 100644 index 0000000..53c368d --- /dev/null +++ b/CWRU/misc/errlist.c @@ -0,0 +1,57 @@ +/* + * If necessary, link with lib/sh/libsh.a + */ + +/* Copyright (C) 1998-2009 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 3 of the License, 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. If not, see . +*/ + +#include +#include + +extern char *strerror(); + +extern int sys_nerr; + +int +main(c, v) +int c; +char **v; +{ + int i, n; + + if (c == 1) { + for (i = 1; i < sys_nerr; i++) + printf("%d --> %s\n", i, strerror(i)); + } else { + for (i = 1; i < c; i++) { + n = atoi(v[i]); + printf("%d --> %s\n", n, strerror(n)); + } + } + exit (0); +} + +programming_error(a, b) +char *a; +int b; +{ +} + +fatal_error() +{ +} diff --git a/CWRU/misc/hpux10-dlfcn.h b/CWRU/misc/hpux10-dlfcn.h new file mode 100644 index 0000000..49d4428 --- /dev/null +++ b/CWRU/misc/hpux10-dlfcn.h @@ -0,0 +1,63 @@ +/* + * HPUX 10.x stubs to implement dl* in terms of shl* + * + * Not needed for later versions; HPUX 11.x has dlopen() and friends. + * + * configure also needs to be faked out. You can create a dummy libdl.a + * with stub entries for dlopen, dlclose, dlsym, and dlerror: + * + * int dlopen() { return(0);} + * int dlclose() { return(0);} + * int dlsym() { return(0);} + * int dlerror() { return(0);} + * + * This has not been tested; I just read the manual page and coded this up. + * + * According to the ld manual page, you need to link bash with -dld and add + * the -E flag to LOCAL_LDFLAGS. + */ + +/* Copyright (C) 1998-2009 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 3 of the License, 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. If not, see . +*/ + +#if !defined (__HPUX10_DLFCN_H__) + +#define __HPUX10_DLFCN_H__ + +#include +#include + +#ifndef errno +extern int errno; +#endif + +#define RTLD_LAZY BIND_DEFERRED +#define RTLD_NOW BIND_IMMEDIATE +#define RTLD_GLOBAL DYNAMIC_PATH + +char *bash_global_sym_addr; + +#define dlopen(file,mode) (void *)shl_load((file), (mode), 0L) + +#define dlclose(handle) shl_unload((shl_t)(handle)) + +#define dlsym(handle,name) (bash_global_sym_addr=0,shl_findsym((shl_t *)&(handle),name,TYPE_UNDEFINED,&bash_global_sym_addr), (void *)bash_global_sym_addr) + +#define dlerror() strerror(errno) + +#endif /* __HPUX10_DLFCN_H__ */ diff --git a/CWRU/misc/open-files.c b/CWRU/misc/open-files.c new file mode 100644 index 0000000..6a55577 --- /dev/null +++ b/CWRU/misc/open-files.c @@ -0,0 +1,39 @@ +/* open-files -- report files a process has open */ + +/* Copyright (C) 1989-2009 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 3 of the License, 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. If not, see . +*/ + +#include +#include +#include + +#include +#include + +#include + +main() +{ + register int i; + + for (i = 0; i < getdtablesize(); i++) { + if (fcntl(i, F_GETFD, 0) != -1) + fprintf(stderr, "fd %d: open\n", i); + } + exit(0); +} diff --git a/CWRU/misc/sigs.c b/CWRU/misc/sigs.c new file mode 100644 index 0000000..bae93f8 --- /dev/null +++ b/CWRU/misc/sigs.c @@ -0,0 +1,47 @@ +/* sigs - print signal dispositions for a process */ + +/* Copyright (C) 1990-2010 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 3 of the License, 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. If not, see . +*/ + +#include +#include + +extern const char * const sys_siglist[]; + +typedef void sighandler(); + +main(argc, argv) +int argc; +char **argv; +{ + register int i; + sighandler *h; + + for (i = 1; i < NSIG; i++) { + h = signal(i, SIG_DFL); + if (h != SIG_DFL) { + if (h == SIG_IGN) + fprintf(stderr, "%d: ignored (%s)\n", i, sys_siglist[i]); + else + fprintf(stderr, "%d: caught (%s)\n", i, sys_siglist[i]); + } + } + exit(0); +} + + diff --git a/CWRU/misc/sigstat.c b/CWRU/misc/sigstat.c new file mode 100644 index 0000000..9135baa --- /dev/null +++ b/CWRU/misc/sigstat.c @@ -0,0 +1,226 @@ +/* + * sigstat - print out useful information about signal arguments + * + * Chet Ramey + * chet@po.cwru.edu + */ + +/* Copyright (C) 1991-2009 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 3 of the License, 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. If not, see . +*/ + +#include +#include +#include + +extern char *strrchr(); +static char *signames[NSIG]; + +char *progname; + +void sigstat(); + +main(argc, argv) +int argc; +char **argv; +{ + register int i; + char *t; + + if (t = strrchr(argv[0], '/')) + progname = ++t; + else + progname = argv[0]; + init_signames(); + if (argc == 1) { + for (i = 1; i < NSIG; i++) + sigstat(i); + exit(0); + } + for (i = 1; i < argc; i++) + sigstat(atoi(argv[i])); + exit(0); +} + +void +sigstat(sig) +int sig; +{ + struct sigaction oact; + char *signame; + sigset_t set, oset; + int blocked; + + if (sig < 0 || sig >= NSIG) { + fprintf(stderr, "%s: %d: signal out of range\n", progname, sig); + return; + } + signame = signames[sig]; + sigemptyset(&oset); + sigprocmask(SIG_BLOCK, (sigset_t *)NULL, &oset); + if (sigismember(&oset, sig)) + printf("%s: signal is blocked\n", signame); + sigaction(sig, (struct sigaction *)NULL, &oact); + if (oact.sa_handler == SIG_IGN) + printf("%s: signal is ignored\n", signame); + else if (oact.sa_handler == SIG_DFL) + printf("%s: signal is defaulted\n", signame); + else + printf("%s: signal is trapped (?)\n", signame); +} + +init_signames() +{ + register int i; + bzero(signames, sizeof(signames)); + +#if defined (SIGHUP) /* hangup */ + signames[SIGHUP] = "SIGHUP"; +#endif +#if defined (SIGINT) /* interrupt */ + signames[SIGINT] = "SIGINT"; +#endif +#if defined (SIGQUIT) /* quit */ + signames[SIGQUIT] = "SIGQUIT"; +#endif +#if defined (SIGILL) /* illegal instruction (not reset when caught) */ + signames[SIGILL] = "SIGILL"; +#endif +#if defined (SIGTRAP) /* trace trap (not reset when caught) */ + signames[SIGTRAP] = "SIGTRAP"; +#endif +#if defined (SIGABRT) /* */ + signames[SIGABRT] = "SIGABRT"; +#endif +#if defined (SIGIOT) /* IOT instruction */ + signames[SIGIOT] = "SIGIOT"; +#endif +#if defined (SIGEMT) /* EMT instruction */ + signames[SIGEMT] = "SIGEMT"; +#endif +#if defined (SIGFPE) /* floating point exception */ + signames[SIGFPE] = "SIGFPE"; +#endif +#if defined (SIGKILL) /* kill (cannot be caught or ignored) */ + signames[SIGKILL] = "SIGKILL"; +#endif +#if defined (SIGBUS) /* bus error */ + signames[SIGBUS] = "SIGBUS"; +#endif +#if defined (SIGSEGV) /* segmentation violation */ + signames[SIGSEGV] = "SIGSEGV"; +#endif +#if defined (SIGSYS) /* bad argument to system call */ + signames[SIGSYS] = "SIGSYS"; +#endif +#if defined (SIGPIPE) /* write on a pipe with no one to read it */ + signames[SIGPIPE] = "SIGPIPE"; +#endif +#if defined (SIGALRM) /* alarm clock */ + signames[SIGALRM] = "SIGALRM"; +#endif +#if defined (SIGTERM) /* software termination signal from kill */ + signames[SIGTERM] = "SIGTERM"; +#endif +#if defined (SIGCLD) /* Like SIGCHLD. */ + signames[SIGCLD] = "SIGCLD"; +#endif +#if defined (SIGPWR) /* Magic thing for some machines. */ + signames[SIGPWR] = "SIGPWR"; +#endif +#if defined (SIGPOLL) /* For keyboard input? */ + signames[SIGPOLL] = "SIGPOLL"; +#endif +#if defined (SIGURG) /* urgent condition on IO channel */ + signames[SIGURG] = "SIGURG"; +#endif +#if defined (SIGSTOP) /* sendable stop signal not from tty */ + signames[SIGSTOP] = "SIGSTOP"; +#endif +#if defined (SIGTSTP) /* stop signal from tty */ + signames[SIGTSTP] = "SIGTSTP"; +#endif +#if defined (SIGCONT) /* continue a stopped process */ + signames[SIGCONT] = "SIGCONT"; +#endif +#if defined (SIGCHLD) /* to parent on child stop or exit */ + signames[SIGCHLD] = "SIGCHLD"; +#endif +#if defined (SIGTTIN) /* to readers pgrp upon background tty read */ + signames[SIGTTIN] = "SIGTTIN"; +#endif +#if defined (SIGTTOU) /* like TTIN for output if (tp->t_local<OSTOP) */ + signames[SIGTTOU] = "SIGTTOU"; +#endif +#if defined (SIGIO) /* input/output possible signal */ + signames[SIGIO] = "SIGIO"; +#endif +#if defined (SIGXCPU) /* exceeded CPU time limit */ + signames[SIGXCPU] = "SIGXCPU"; +#endif +#if defined (SIGXFSZ) /* exceeded file size limit */ + signames[SIGXFSZ] = "SIGXFSZ"; +#endif +#if defined (SIGVTALRM) /* virtual time alarm */ + signames[SIGVTALRM] = "SIGVTALRM"; +#endif +#if defined (SIGPROF) /* profiling time alarm */ + signames[SIGPROF] = "SIGPROF"; +#endif +#if defined (SIGWINCH) /* window changed */ + signames[SIGWINCH] = "SIGWINCH"; +#endif +#if defined (SIGLOST) /* resource lost (eg, record-lock lost) */ + signames[SIGLOST] = "SIGLOST"; +#endif +#if defined (SIGUSR1) /* user defined signal 1 */ + signames[SIGUSR1] = "SIGUSR1"; +#endif +#if defined (SIGUSR2) /* user defined signal 2 */ + signames[SIGUSR2] = "SIGUSR2"; +#endif +#if defined (SIGMSG) /* HFT input data pending */ + signames[SIGMSG] = "SIGMSG"; +#endif +#if defined (SIGPWR) /* power failure imminent (save your data) */ + signames[SIGPWR] = "SIGPWR"; +#endif +#if defined (SIGDANGER) /* system crash imminent */ + signames[SIGDANGER] = "SIGDANGER"; +#endif +#if defined (SIGMIGRATE) /* migrate process to another CPU */ + signames[SIGMIGRATE] = "SIGMIGRATE"; +#endif +#if defined (SIGPRE) /* programming error */ + signames[SIGPRE] = "SIGPRE"; +#endif +#if defined (SIGGRANT) /* HFT monitor mode granted */ + signames[SIGGRANT] = "SIGGRANT"; +#endif +#if defined (SIGRETRACT) /* HFT monitor mode retracted */ + signames[SIGRETRACT] = "SIGRETRACT"; +#endif +#if defined (SIGSOUND) /* HFT sound sequence has completed */ + signames[SIGSOUND] = "SIGSOUND"; +#endif + + for (i = 0; i < NSIG; i++) + if (signames[i] == (char *)NULL) { + signames[i] = (char *)malloc (16);; + sprintf (signames[i], "signal %d", i); + } +} diff --git a/CWRU/sh-redir-hack b/CWRU/sh-redir-hack new file mode 100644 index 0000000..413b297 --- /dev/null +++ b/CWRU/sh-redir-hack @@ -0,0 +1,15 @@ +Add to `subshell' production in parse.y and recompile -DREDIRECTION_HACK to +get `< xx (command)' sh compatibility. + + | redirections '(' list ')' + { +#if defined (REDIRECTION_HACK) + /* XXX - C News sh compatibility hack - XXX */ + $3->redirects = $1; + $3->flags |= CMD_WANT_SUBSHELL; + $$ = $3; +#else + yyerror (); + YYABORT; +#endif + } diff --git a/ChangeLog b/ChangeLog new file mode 120000 index 0000000..12c9a28 --- /dev/null +++ b/ChangeLog @@ -0,0 +1 @@ +CWRU/changelog \ No newline at end of file diff --git a/INSTALL b/INSTALL new file mode 100644 index 0000000..c60d591 --- /dev/null +++ b/INSTALL @@ -0,0 +1,439 @@ +Basic Installation +================== + +These are installation instructions for Bash. + +The simplest way to compile Bash is: + + 1. 'cd' to the directory containing the source code and type + './configure' to configure Bash for your system. If you're using + 'csh' on an old version of System V, you might need to type 'sh + ./configure' instead to prevent 'csh' from trying to execute + 'configure' itself. + + Running 'configure' takes some time. While running, it prints + messages telling which features it is checking for. + + 2. Type 'make' to compile Bash and build the 'bashbug' bug reporting + script. + + 3. Optionally, type 'make tests' to run the Bash test suite. + + 4. Type 'make install' to install 'bash' and 'bashbug'. This will + also install the manual pages and Info file. + +The 'configure' shell script attempts to guess correct values for +various system-dependent variables used during compilation. It uses +those values to create a 'Makefile' in each directory of the package +(the top directory, the 'builtins', 'doc', and 'support' directories, +each directory under 'lib', and several others). It also creates a +'config.h' file containing system-dependent definitions. Finally, it +creates a shell script named 'config.status' that you can run in the +future to recreate the current configuration, a file 'config.cache' that +saves the results of its tests to speed up reconfiguring, and a file +'config.log' containing compiler output (useful mainly for debugging +'configure'). If at some point '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 'configure' +script understands, type + + bash-2.04$ ./configure --help + +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 'configure' could check whether or not to do them, and mail +diffs or instructions to so they can be +considered for the next release. + +The file 'configure.ac' is used to create 'configure' by a program +called Autoconf. You only need 'configure.ac' if you want to change it +or regenerate 'configure' using a newer version of Autoconf. If you do +this, make sure you are using Autoconf version 2.50 or newer. + +You can remove the program binaries and object files from the source +code directory by typing 'make clean'. To also remove the files that +'configure' created (so you can compile Bash for a different kind of +computer), type 'make distclean'. + +Next: Compiling For Multiple Architectures, Prev: Basic Installation, Up: Installing Bash + +Compilers and Options +===================== + +Some systems require unusual options for compilation or linking that the +'configure' script does not know about. You can give '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: + + CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure + +On systems that have the 'env' program, you can do it like this: + + env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure + +The configuration process uses GCC to build Bash if it is available. + +Next: Installation Names, Prev: Compilers and Options, Up: Installing Bash + +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 'make' that supports +the 'VPATH' variable, such as GNU 'make'. 'cd' to the directory where +you want the object files and executables to go and run the 'configure' +script from the source directory. You may need to supply the +'--srcdir=PATH' argument to tell 'configure' where the source files are. +'configure' automatically checks for the source code in the directory +that 'configure' is in and in '..'. + +If you have to use a 'make' that does not supports the '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 +'make distclean' before reconfiguring for another architecture. + +Alternatively, if your system supports symbolic links, you can use the +'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 '/usr/gnu/src/bash-2.0': + + bash /usr/gnu/src/bash-2.0/support/mkclone -s /usr/gnu/src/bash-2.0 . + +The '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. + +Next: Specifying the System Type, Prev: Compiling For Multiple Architectures, Up: Installing Bash + +Installation Names +================== + +By default, 'make install' will install into '/usr/local/bin', +'/usr/local/man', etc. You can specify an installation prefix other +than '/usr/local' by giving 'configure' the option '--prefix=PATH', or +by specifying a value for the 'DESTDIR' 'make' variable when running +'make install'. + +You can specify separate installation prefixes for architecture-specific +files and architecture-independent files. If you give 'configure' the +option '--exec-prefix=PATH', 'make install' will use PATH as the prefix +for installing programs and libraries. Documentation and other data +files will still use the regular prefix. + +Next: Sharing Defaults, Prev: Installation Names, Up: Installing Bash + +Specifying the System Type +========================== + +There may be some features 'configure' can not figure out automatically, +but need to determine by the type of host Bash will run on. Usually +'configure' can figure that out, but if it prints a message saying it +can not guess the host type, give it the '--host=TYPE' option. 'TYPE' +can either be a short name for the system type, such as 'sun4', or a +canonical name with three fields: 'CPU-COMPANY-SYSTEM' (e.g., +'i386-unknown-freebsd4.2'). + +See the file 'support/config.sub' for the possible values of each field. + +Next: Operation Controls, Prev: Specifying the System Type, Up: Installing Bash + +Sharing Defaults +================ + +If you want to set default values for 'configure' scripts to share, you +can create a site shell script called 'config.site' that gives default +values for variables like 'CC', 'cache_file', and 'prefix'. 'configure' +looks for 'PREFIX/share/config.site' if it exists, then +'PREFIX/etc/config.site' if it exists. Or, you can set the +'CONFIG_SITE' environment variable to the location of the site script. +A warning: the Bash 'configure' looks for a site script, but not all +'configure' scripts do. + +Next: Optional Features, Prev: Sharing Defaults, Up: Installing Bash + +Operation Controls +================== + +'configure' recognizes the following options to control how it operates. + +'--cache-file=FILE' + Use and save the results of the tests in FILE instead of + './config.cache'. Set FILE to '/dev/null' to disable caching, for + debugging 'configure'. + +'--help' + Print a summary of the options to 'configure', and exit. + +'--quiet' +'--silent' +'-q' + Do not print messages saying which checks are being made. + +'--srcdir=DIR' + Look for the Bash source code in directory DIR. Usually + 'configure' can determine that directory automatically. + +'--version' + Print the version of Autoconf used to generate the 'configure' + script, and exit. + +'configure' also accepts some other, not widely used, boilerplate +options. 'configure --help' prints the complete list. + +Prev: Operation Controls, Up: Installing Bash + +Optional Features +================= + +The Bash 'configure' has a number of '--enable-FEATURE' options, where +FEATURE indicates an optional part of Bash. There are also several +'--with-PACKAGE' options, where PACKAGE is something like 'bash-malloc' +or 'purify'. To turn off the default use of a package, use +'--without-PACKAGE'. To configure Bash without a feature that is +enabled by default, use '--disable-FEATURE'. + +Here is a complete list of the '--enable-' and '--with-' options that +the Bash 'configure' recognizes. + +'--with-afs' + Define if you are using the Andrew File System from Transarc. + +'--with-bash-malloc' + Use the Bash version of 'malloc' in the directory 'lib/malloc'. + This is not the same 'malloc' that appears in GNU libc, but an + older version originally derived from the 4.2 BSD 'malloc'. This + 'malloc' is very fast, but wastes some space on each allocation. + This option is enabled by default. The 'NOTES' file contains a + list of systems for which this should be turned off, and + 'configure' disables this option automatically for a number of + systems. + +'--with-curses' + Use the curses library instead of the termcap library. This should + be supplied if your system has an inadequate or incomplete termcap + database. + +'--with-gnu-malloc' + A synonym for '--with-bash-malloc'. + +'--with-installed-readline[=PREFIX]' + Define this to make Bash link with a locally-installed version of + Readline rather than the version in 'lib/readline'. This works + only with Readline 5.0 and later versions. If PREFIX is 'yes' or + not supplied, 'configure' uses the values of the make variables + 'includedir' and 'libdir', which are subdirectories of 'prefix' by + default, to find the installed version of Readline if it is not in + the standard system include and library directories. If PREFIX is + 'no', Bash links with the version in 'lib/readline'. If PREFIX is + set to any other value, 'configure' treats it as a directory + pathname and looks for the installed version of Readline in + subdirectories of that directory (include files in PREFIX/'include' + and the library in PREFIX/'lib'). + +'--with-purify' + Define this to use the Purify memory allocation checker from + Rational Software. + +'--enable-minimal-config' + This produces a shell with minimal features, close to the + historical Bourne shell. + +There are several '--enable-' options that alter how Bash is compiled +and linked, rather than changing run-time features. + +'--enable-largefile' + Enable support for large files + (http://www.sas.com/standards/large_file/x_open.20Mar96.html) if + the operating system requires special compiler options to build + programs which can access large files. This is enabled by default, + if the operating system provides large file support. + +'--enable-profiling' + This builds a Bash binary that produces profiling information to be + processed by 'gprof' each time it is executed. + +'--enable-static-link' + This causes Bash to be linked statically, if 'gcc' is being used. + This could be used to build a version to use as root's shell. + +The '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 'enable-FEATURE'. + +All of the following options except for 'disabled-builtins', +'direxpand-default', and 'xpg-echo-default' are enabled by default, +unless the operating system does not provide the necessary support. + +'--enable-alias' + Allow alias expansion and include the 'alias' and 'unalias' + builtins (*note Aliases::). + +'--enable-arith-for-command' + Include support for the alternate form of the 'for' command that + behaves like the C language 'for' statement (*note Looping + Constructs::). + +'--enable-array-variables' + Include support for one-dimensional array shell variables (*note + Arrays::). + +'--enable-bang-history' + Include support for 'csh'-like history substitution (*note History + Interaction::). + +'--enable-brace-expansion' + Include 'csh'-like brace expansion ( 'b{a,b}c' ==> 'bac bbc' ). + See *note Brace Expansion::, for a complete description. + +'--enable-casemod-attributes' + Include support for case-modifying attributes in the 'declare' + builtin and assignment statements. Variables with the UPPERCASE + attribute, for example, will have their values converted to + uppercase upon assignment. + +'--enable-casemod-expansion' + Include support for case-modifying word expansions. + +'--enable-command-timing' + Include support for recognizing 'time' as a reserved word and for + displaying timing statistics for the pipeline following 'time' + (*note Pipelines::). This allows pipelines as well as shell + builtins and functions to be timed. + +'--enable-cond-command' + Include support for the '[[' conditional command. (*note + Conditional Constructs::). + +'--enable-cond-regexp' + Include support for matching POSIX regular expressions using the + '=~' binary operator in the '[[' conditional command. (*note + Conditional Constructs::). + +'--enable-coprocesses' + Include support for coprocesses and the 'coproc' reserved word + (*note Pipelines::). + +'--enable-debugger' + Include support for the bash debugger (distributed separately). + +'--enable-direxpand-default' + Cause the 'direxpand' shell option (*note The Shopt Builtin::) to + be enabled by default when the shell starts. It is normally + disabled by default. + +'--enable-directory-stack' + Include support for a 'csh'-like directory stack and the 'pushd', + 'popd', and 'dirs' builtins (*note The Directory Stack::). + +'--enable-disabled-builtins' + Allow builtin commands to be invoked via 'builtin xxx' even after + 'xxx' has been disabled using 'enable -n xxx'. See *note Bash + Builtins::, for details of the 'builtin' and 'enable' builtin + commands. + +'--enable-dparen-arithmetic' + Include support for the '((...))' command (*note Conditional + Constructs::). + +'--enable-extended-glob' + Include support for the extended pattern matching features + described above under *note Pattern Matching::. + +'--enable-extended-glob-default' + Set the default value of the EXTGLOB shell option described above + under *note The Shopt Builtin:: to be enabled. + +'--enable-function-import' + Include support for importing function definitions exported by + another instance of the shell from the environment. This option is + enabled by default. + +'--enable-glob-asciirange-default' + Set the default value of the GLOBASCIIRANGES shell option described + above under *note The Shopt Builtin:: to be enabled. This controls + the behavior of character ranges when used in pattern matching + bracket expressions. + +'--enable-help-builtin' + Include the 'help' builtin, which displays help on shell builtins + and variables (*note Bash Builtins::). + +'--enable-history' + Include command history and the 'fc' and 'history' builtin commands + (*note Bash History Facilities::). + +'--enable-job-control' + This enables the job control features (*note Job Control::), if the + operating system supports them. + +'--enable-multibyte' + This enables support for multibyte characters if the operating + system provides the necessary support. + +'--enable-net-redirections' + This enables the special handling of filenames of the form + '/dev/tcp/HOST/PORT' and '/dev/udp/HOST/PORT' when used in + redirections (*note Redirections::). + +'--enable-process-substitution' + This enables process substitution (*note Process Substitution::) if + the operating system provides the necessary support. + +'--enable-progcomp' + Enable the programmable completion facilities (*note Programmable + Completion::). If Readline is not enabled, this option has no + effect. + +'--enable-prompt-string-decoding' + Turn on the interpretation of a number of backslash-escaped + characters in the '$PS1', '$PS2', '$PS3', and '$PS4' prompt + strings. See *note Controlling the Prompt::, for a complete list + of prompt string escape sequences. + +'--enable-readline' + Include support for command-line editing and history with the Bash + version of the Readline library (*note Command Line Editing::). + +'--enable-restricted' + Include support for a "restricted shell". If this is enabled, + Bash, when called as 'rbash', enters a restricted mode. See *note + The Restricted Shell::, for a description of restricted mode. + +'--enable-select' + Include the 'select' compound command, which allows the generation + of simple menus (*note Conditional Constructs::). + +'--enable-separate-helpfiles' + Use external files for the documentation displayed by the 'help' + builtin instead of storing the text internally. + +'--enable-single-help-strings' + Store the text displayed by the '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. + +'--enable-strict-posix-default' + Make Bash POSIX-conformant by default (*note Bash POSIX Mode::). + +'--enable-usg-echo-default' + A synonym for '--enable-xpg-echo-default'. + +'--enable-xpg-echo-default' + Make the 'echo' builtin expand backslash-escaped characters by + default, without requiring the '-e' option. This sets the default + value of the 'xpg_echo' shell option to 'on', which makes the Bash + 'echo' behave more like the version specified in the Single Unix + Specification, version 3. *Note Bash Builtins::, for a description + of the escape sequences that 'echo' recognizes. + +The file 'config-top.h' contains C Preprocessor '#define' statements for +options which are not settable from '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. diff --git a/MANIFEST b/MANIFEST new file mode 100644 index 0000000..a306b6f --- /dev/null +++ b/MANIFEST @@ -0,0 +1,1372 @@ +# +# Master distribution manifest for bash +# +# +# Filename type +# +CWRU d +CWRU/misc d +builtins d +cross-build d +doc d +examples d +#examples/obashdb d +examples/complete d +examples/functions d +examples/scripts d +#examples/scripts.v2 d +#examples/scripts.noah d +examples/startup-files d +#examples/startup-files/apple d +examples/misc d +examples/loadables d +examples/loadables/perl d +include d +lib d +lib/glob d +lib/glob/doc d +lib/intl d +lib/malloc d +lib/readline d +lib/readline/doc d +lib/readline/examples d +lib/sh d +lib/termcap d +lib/tilde d +m4 d +po d +support d +tests d +tests/misc d +ABOUT-NLS f +ChangeLog s CWRU/changelog +CHANGES f +COMPAT f +COPYING f +INSTALL f +MANIFEST f +NEWS f +NOTES f +POSIX f +README f +RBASH f +AUTHORS f +Y2K f +configure.ac f +configure f 755 +Makefile.in f +config-top.h f +config-bot.h f +config.h.in f +aclocal.m4 f +array.c f +arrayfunc.c f +assoc.c f +eval.c f +print_cmd.c f +general.c f +list.c f +locale.c f +stringlib.c f +variables.c f +make_cmd.c f +copy_cmd.c f +unwind_prot.c f +dispose_cmd.c f +bashhist.c f +hashcmd.c f +hashlib.c f +parse.y f +pathexp.c f +subst.c f +shell.c f +trap.c f +sig.c f +siglist.c f +version.c f +flags.c f +jobs.c f +input.c f +mailcheck.c f +test.c f +expr.c f +alias.c f +execute_cmd.c f +findcmd.c f +redir.c f +bashline.c f +braces.c f +bracecomp.c f +nojobs.c f +error.c f +xmalloc.c f +pcomplete.c f +pcomplib.c f +mksyntax.c f +alias.h f +builtins.h f +bashhist.h f +bashline.h f +conftypes.h f +patchlevel.h f +variables.h f +array.h f +arrayfunc.h f +assoc.h f +jobs.h f +findcmd.h f +hashlib.h f +quit.h f +flags.h f +shell.h f +syntax.h f +pathexp.h f +parser.h f +pcomplete.h f +sig.h f +test.h f +trap.h f +general.h f +unwind_prot.h f +input.h f +error.h f +command.h f +externs.h f +siglist.h f +subst.h f +dispose_cmd.h f +hashcmd.h f +bashansi.h f +bashjmp.h f +bashintl.h f +make_cmd.h f +execute_cmd.h f +redir.h f +bashtypes.h f +mailcheck.h f +xmalloc.h f +y.tab.c f +y.tab.h f +parser-built f +pathnames.h.in f +builtins/Makefile.in f +builtins/alias.def f +builtins/bind.def f +builtins/break.def f +builtins/builtin.def f +builtins/caller.def f +builtins/cd.def f +builtins/colon.def f +builtins/command.def f +builtins/complete.def f +builtins/common.c f +builtins/declare.def f +builtins/echo.def f +builtins/enable.def f +builtins/eval.def f +builtins/evalfile.c f +builtins/evalstring.c f +builtins/exec.def f +builtins/exit.def f +builtins/fc.def f +builtins/fg_bg.def f +builtins/gen-helpfiles.c f +builtins/getopt.c f +builtins/getopt.h f +builtins/getopts.def f +builtins/hash.def f +builtins/help.def f +builtins/let.def f +builtins/history.def f +builtins/jobs.def f +builtins/kill.def f +builtins/mapfile.def f +builtins/mkbuiltins.c f +builtins/printf.def f +builtins/pushd.def f +builtins/read.def f +builtins/reserved.def f +builtins/return.def f +builtins/set.def f +builtins/setattr.def f +builtins/shift.def f +builtins/shopt.def f +builtins/source.def f +builtins/suspend.def f +builtins/test.def f +builtins/times.def f +builtins/trap.def f +builtins/type.def f +builtins/ulimit.def f +builtins/umask.def f +builtins/wait.def f +builtins/psize.c f +builtins/psize.sh f +builtins/inlib.def f +builtins/bashgetopt.c f +builtins/common.h f +builtins/bashgetopt.h f +cross-build/cygwin32.cache f +cross-build/x86-beos.cache f +cross-build/opennt.cache f +include/ansi_stdlib.h f +include/chartypes.h f +include/filecntl.h f +include/gettext.h f +include/maxpath.h f +include/memalloc.h f +include/ocache.h f +include/posixdir.h f +include/posixjmp.h f +include/posixselect.h f +include/posixstat.h f +include/posixtime.h f +include/posixwait.h f +include/shmbchar.h f +include/shmbutil.h f +include/shtty.h f +include/stat-time.h f +include/stdc.h f +include/systimes.h f +include/typemax.h f +include/unionwait.h f +lib/glob/Makefile.in f +lib/glob/sm_loop.c f +lib/glob/smatch.c f +lib/glob/strmatch.c f +lib/glob/strmatch.h f +lib/glob/glob.c f +lib/glob/glob.h f +lib/glob/glob_loop.c f +lib/glob/gmisc.c f +lib/glob/xmbsrtowcs.c f +lib/glob/collsyms.h f +lib/glob/doc/Makefile f +lib/glob/doc/glob.texi f +lib/glob/ndir.h f +lib/intl/ChangeLog f +lib/intl/Makefile.in f +lib/intl/VERSION f +lib/intl/bindtextdom.c f +lib/intl/config.charset f +lib/intl/dcgettext.c f +lib/intl/dcigettext.c f +lib/intl/dcngettext.c f +lib/intl/dgettext.c f +lib/intl/dngettext.c f +lib/intl/eval-plural.h f +lib/intl/explodename.c f +lib/intl/finddomain.c f +lib/intl/gettext.c f +lib/intl/gettextP.h f +lib/intl/gmo.h f +lib/intl/hash-string.h f +lib/intl/intl-compat.c f +lib/intl/l10nflist.c f +lib/intl/libgnuintl.h.in f +lib/intl/loadinfo.h f +lib/intl/loadmsgcat.c f +lib/intl/localcharset.c f +lib/intl/localcharset.h f +lib/intl/locale.alias f +lib/intl/localealias.c f +lib/intl/localename.c f +lib/intl/log.c f +lib/intl/ngettext.c f +lib/intl/os2compat.c f +lib/intl/os2compat.h f +lib/intl/osdep.c f +lib/intl/plural-exp.c f +lib/intl/plural-exp.h f +lib/intl/plural.c f +lib/intl/plural.y f +lib/intl/ref-add.sin f +lib/intl/ref-del.sin f +lib/intl/relocatable.c f +lib/intl/relocatable.h f +lib/intl/textdomain.c f +lib/malloc/Makefile.in f +lib/malloc/getpagesize.h f +lib/malloc/imalloc.h f +lib/malloc/mstats.h f +lib/malloc/shmalloc.h f +lib/malloc/table.h f +lib/malloc/watch.h f +lib/malloc/alloca.c f +lib/malloc/malloc.c f +lib/malloc/stats.c f +lib/malloc/table.c f +lib/malloc/trace.c f +lib/malloc/watch.c f +lib/malloc/xmalloc.c f +lib/malloc/xleaktrace f 755 +lib/malloc/stub.c f +lib/malloc/i386-alloca.s f +lib/malloc/x386-alloca.s f +lib/readline/COPYING f +lib/readline/Makefile.in f +lib/readline/ChangeLog f +lib/readline/README f +lib/readline/STANDALONE f +lib/readline/readline.c f +lib/readline/vi_mode.c f +lib/readline/emacs_keymap.c f +lib/readline/vi_keymap.c f +lib/readline/history.c f +lib/readline/histexpand.c f +lib/readline/histsearch.c f +lib/readline/histfile.c f +lib/readline/funmap.c f +lib/readline/keymaps.c f +lib/readline/util.c f +lib/readline/terminal.c f +lib/readline/xfree.c f +lib/readline/xmalloc.c f +lib/readline/search.c f +lib/readline/isearch.c f +lib/readline/parens.c f +lib/readline/rltty.c f +lib/readline/compat.c f +lib/readline/complete.c f +lib/readline/bind.c f +lib/readline/display.c f +lib/readline/signals.c f +lib/readline/kill.c f +lib/readline/text.c f +lib/readline/undo.c f +lib/readline/macro.c f +lib/readline/input.c f +lib/readline/callback.c f +lib/readline/mbutil.c f +lib/readline/misc.c f +lib/readline/nls.c f +lib/readline/shell.c f +lib/readline/colors.c f +lib/readline/parse-colors.c f +lib/readline/savestring.c f +lib/readline/tilde.c f +lib/readline/tilde.h f +lib/readline/rldefs.h f +lib/readline/rlconf.h f +lib/readline/rlmbutil.h f +lib/readline/rlshell.h f +lib/readline/rltty.h f +lib/readline/rltypedefs.h f +lib/readline/rlwinsize.h f +lib/readline/readline.h f +lib/readline/tcap.h f +lib/readline/keymaps.h f +lib/readline/history.h f +lib/readline/histlib.h f +lib/readline/chardefs.h f +lib/readline/posixdir.h f +lib/readline/posixjmp.h f +lib/readline/posixselect.h f +lib/readline/posixstat.h f +lib/readline/ansi_stdlib.h f +lib/readline/rlstdc.h f +lib/readline/rlprivate.h f +lib/readline/colors.h f +lib/readline/parse-colors.h f +lib/readline/xmalloc.h f +lib/readline/doc/Makefile f +lib/readline/doc/version.texi f +lib/readline/doc/rlman.texi f +lib/readline/doc/rltech.texi f +lib/readline/doc/rluser.texi f +lib/readline/doc/rluserman.texi f +lib/readline/doc/history.texi f +lib/readline/doc/hstech.texi f +lib/readline/doc/hsuser.texi f +lib/readline/doc/fdl.texi f +lib/readline/examples/Makefile f +lib/readline/examples/excallback.c f +lib/readline/examples/fileman.c f +lib/readline/examples/manexamp.c f +lib/readline/examples/histexamp.c f +lib/readline/examples/rltest.c f +lib/readline/examples/rl-callbacktest.c f +lib/readline/examples/rl.c f +lib/readline/examples/rlcat.c f +lib/readline/examples/Inputrc f +lib/sh/Makefile.in f +lib/sh/casemod.c f +lib/sh/clktck.c f +lib/sh/clock.c f +lib/sh/dprintf.c f +lib/sh/eaccess.c f +lib/sh/fmtullong.c f +lib/sh/fmtulong.c f +lib/sh/fmtumax.c f +lib/sh/fnxform.c f +lib/sh/fpurge.c f +lib/sh/getcwd.c f +lib/sh/getenv.c f +lib/sh/inet_aton.c f +lib/sh/input_avail.c f +lib/sh/itos.c f +lib/sh/mailstat.c f +lib/sh/makepath.c f +lib/sh/mbscasecmp.c f +lib/sh/mbschr.c f +lib/sh/mbscmp.c f +lib/sh/memset.c f +lib/sh/mktime.c f +lib/sh/netconn.c f +lib/sh/netopen.c f +lib/sh/oslib.c f +lib/sh/pathcanon.c f +lib/sh/pathphys.c f +lib/sh/rename.c f +lib/sh/setlinebuf.c f +lib/sh/shmatch.c f +lib/sh/shmbchar.c f +lib/sh/shquote.c f +lib/sh/shtty.c f +lib/sh/snprintf.c f +lib/sh/spell.c f +lib/sh/strcasecmp.c f +lib/sh/strcasestr.c f +lib/sh/strchrnul.c f +lib/sh/strdup.c f +lib/sh/strerror.c f +lib/sh/strftime.c f +lib/sh/stringlist.c f +lib/sh/stringvec.c f +lib/sh/strnlen.c f +lib/sh/strpbrk.c f +lib/sh/strstr.c f +lib/sh/strtod.c f +lib/sh/strtoimax.c f +lib/sh/strtol.c f +lib/sh/strtoll.c f +lib/sh/strtoul.c f +lib/sh/strtoull.c f +lib/sh/strtoumax.c f +lib/sh/strtrans.c f +lib/sh/times.c f +lib/sh/timeval.c f +lib/sh/tmpfile.c f +lib/sh/uconvert.c f +lib/sh/ufuncs.c f +lib/sh/unicode.c f +lib/sh/vprint.c f +lib/sh/wcsdup.c f +lib/sh/wcsnwidth.c f +lib/sh/wcswidth.c f +lib/sh/winsize.c f +lib/sh/zcatfd.c f +lib/sh/zgetline.c f +lib/sh/zmapfd.c f +lib/sh/zread.c f +lib/sh/zwrite.c f +lib/termcap/Makefile.in f +lib/termcap/ltcap.h f +lib/termcap/termcap.c f +lib/termcap/termcap.h f +lib/termcap/tparam.c f +lib/termcap/version.c f +lib/tilde/README f +lib/tilde/Makefile.in f +lib/tilde/tilde.c f +lib/tilde/tilde.h f +lib/tilde/shell.c f +m4/stat-time.m4 f +m4/timespec.m4 f +po/LINGUAS f +po/Makefile.in.in f +po/Makevars f +po/POTFILES.in f +po/README f +po/Rules-builtins f +po/Rules-quot f +po/bash.pot f +po/boldquot.sed f +po/en@boldquot.gmo f +po/en@boldquot.header f +po/en@boldquot.po f +po/en@quot.gmo f +po/en@quot.header f +po/en@quot.po f +po/af.gmo f +po/af.po f +po/bg.gmo f +po/bg.po f +po/ca.gmo f +po/ca.po f +po/cs.gmo f +po/cs.po f +po/da.gmo f +po/da.po f +po/de.gmo f +po/de.po f +po/el.gmo f +po/el.po f +po/eo.gmo f +po/eo.po f +po/es.gmo f +po/es.po f +po/et.gmo f +po/et.po f +po/fi.gmo f +po/fi.po f +po/fr.gmo f +po/fr.po f +po/ga.gmo f +po/ga.po f +po/gl.gmo f +po/gl.po f +po/hr.gmo f +po/hr.po f +po/hu.gmo f +po/hu.po f +po/id.gmo f +po/id.po f +po/it.gmo f +po/it.po f +po/ja.gmo f +po/ja.po f +po/lt.gmo f +po/lt.po f +po/nl.gmo f +po/nb.po f +po/nb.gmo f +po/nl.po f +po/pl.gmo f +po/pl.po f +po/pt_BR.gmo f +po/pt_BR.po f +po/ro.gmo f +po/ro.po f +po/ru.gmo f +po/ru.po f +po/sk.gmo f +po/sk.po f +po/sl.gmo f +po/sr.po f +po/sr.gmo f +po/sl.po f +po/sv.gmo f +po/sv.po f +po/tr.gmo f +po/tr.po f +po/uk.gmo f +po/uk.po f +po/vi.gmo f +po/vi.po f +po/zh_CN.gmo f +po/zh_CN.po f +po/zh_TW.gmo f +po/zh_TW.po f +po/insert-header.sin f +po/quot.sed f +po/remove-potcdate.sin f +CWRU/misc/open-files.c f +CWRU/misc/sigs.c f +CWRU/misc/sigstat.c f +CWRU/misc/bison f +CWRU/misc/errlist.c f +CWRU/misc/hpux10-dlfcn.h f +CWRU/PLATFORMS f +CWRU/README f +CWRU/changelog f +CWRU/sh-redir-hack f +doc/FAQ f +doc/Makefile.in f +doc/bash.1 f +doc/bashbug.1 f +doc/builtins.1 f +doc/rbash.1 f +doc/README f +doc/INTRO f +doc/texinfo.tex f +doc/bashref.texi f +doc/version.texi f +doc/bashref.info f +doc/bash.info f +doc/article.ms f +doc/htmlpost.sh f 755 +doc/infopost.sh f 755 +doc/fdl.texi f +doc/fdl.txt f +# +doc/article.ps f +doc/rose94.ps f +doc/bash.ps f +doc/bashbug.ps f +doc/builtins.ps f +doc/rbash.ps f +doc/bashref.ps f +doc/bashref.dvi f +doc/bash.0 f +doc/bashbug.0 f +doc/builtins.0 f +doc/rbash.0 f +doc/article.txt f +doc/bash.html f +doc/bashref.html f +doc/article.pdf f +doc/bash.pdf f +doc/bashref.pdf f +doc/rose94.pdf f +doc/aosa-bash.pdf f +doc/aosa-bash-full.pdf f +# +support/Makefile.in f +support/bash.pc.in f +support/bashversion.c f +support/checkbashisms f 755 +support/config.guess f +support/config.rpath f 755 +support/config.sub f +support/printenv.sh f 755 +support/printenv.c f +support/bash.xbm f +support/missing f 755 +support/mkclone f 755 +support/mkconffiles f 755 +support/mkdirs f 755 +support/mkinstalldirs f 755 +support/mkversion.sh f 755 +support/mksignames.c f +support/signames.c f +support/bashbug.sh f +support/man2html.c f +support/recho.c f +support/zecho.c f +support/xcase.c f +support/SYMLINKS f +support/fixlinks f 755 +support/install.sh f 755 +support/texi2dvi f 755 +support/texi2html f 755 +support/xenix-link.sh f 755 +support/shobj-conf f 755 +support/rlvers.sh f 755 +examples/INDEX.txt f +examples/INDEX.html f +#examples/obashdb/PERMISSION f +#examples/obashdb/README f +#examples/obashdb/bashdb f +#examples/obashdb/bashdb.el f +examples/complete/bash_completion f +examples/complete/cdfunc f +examples/complete/complete-examples f +#examples/complete/complete.ianmac f +#examples/complete/complete2.ianmac f +#examples/complete/complete.freebsd f +#examples/complete/complete.gnu-longopt f +examples/complete/bashcc-1.0.1.tar.gz f +examples/loadables/README f +examples/loadables/template.c f +examples/loadables/loadables.h f +examples/loadables/Makefile.in f +examples/loadables/Makefile.inc.in f +examples/loadables/necho.c f +examples/loadables/hello.c f +examples/loadables/print.c f +examples/loadables/realpath.c f +examples/loadables/setpgid.c f +examples/loadables/sleep.c f +examples/loadables/strftime.c f +examples/loadables/truefalse.c f +#examples/loadables/getconf.h f +#examples/loadables/getconf.c f +examples/loadables/finfo.c f +examples/loadables/cat.c f +#examples/loadables/cut.c f +examples/loadables/logname.c f +examples/loadables/basename.c f +examples/loadables/dirname.c f +examples/loadables/tty.c f +examples/loadables/pathchk.c f +examples/loadables/tee.c f +examples/loadables/rmdir.c f +examples/loadables/head.c f +examples/loadables/printenv.c f +examples/loadables/push.c f +examples/loadables/id.c f +examples/loadables/whoami.c f +examples/loadables/uname.c f +examples/loadables/sync.c f +examples/loadables/mkdir.c f +examples/loadables/ln.c f +examples/loadables/mypid.c f +examples/loadables/unlink.c f +examples/loadables/perl/Makefile.in f +examples/loadables/perl/README f +examples/loadables/perl/bperl.c f +examples/loadables/perl/iperl.c f +#examples/loadables/sprintf.c f +#examples/loadables/xtitle.c f +examples/functions/array-stuff f +examples/functions/array-to-string f +examples/functions/autoload f +examples/functions/autoload.v2 f +examples/functions/autoload.v3 f +examples/functions/basename f +#examples/functions/basename2 f +#examples/functions/coproc.bash f +#examples/functions/coshell.README f +#examples/functions/coshell.bash f +examples/functions/csh-compat f +#examples/functions/dirfuncs f +examples/functions/dirname f +examples/functions/dirstack f +#examples/functions/emptydir f +examples/functions/exitstat f +examples/functions/external f +examples/functions/fact f +examples/functions/fstty f +examples/functions/func f +#examples/functions/gethtml f +#examples/functions/getoptx.bash f +examples/functions/inetaddr f +examples/functions/inpath f +#examples/functions/isnum.bash f +examples/functions/isnum2 f +examples/functions/isvalidip f +#examples/functions/jdate.bash f +#examples/functions/jj.bash f +#examples/functions/keep f +examples/functions/ksh-cd f +examples/functions/ksh-compat-test f +examples/functions/kshenv f +examples/functions/login f +#examples/functions/lowercase f +#examples/functions/manpage f +#examples/functions/mhfold f +#examples/functions/newdirstack.bsh f +examples/functions/notify.bash f +#examples/functions/pathfuncs f +#examples/functions/recurse f +#examples/functions/repeat2 f +#examples/functions/repeat3 f +examples/functions/seq f +examples/functions/seq2 f +examples/functions/shcat f +examples/functions/shcat2 f +examples/functions/sort-pos-params f +#examples/functions/sqroot f +examples/functions/substr f +examples/functions/substr2 f +#examples/functions/term f +examples/functions/whatis f +examples/functions/whence f +examples/functions/which f +#examples/functions/xalias.bash f +#examples/functions/xfind.bash f +#examples/scripts/adventure.sh f +#examples/scripts/bash-hexdump.sh f +#examples/scripts/bcsh.sh f +examples/scripts/cat.sh f +examples/scripts/center f +#examples/scripts/dd-ex.sh f +#examples/scripts/fixfiles.bash f +#examples/scripts/hanoi.bash f +examples/scripts/inpath f +#examples/scripts/krand.bash f +#examples/scripts/line-input.bash f +#examples/scripts/nohup.bash f +#examples/scripts/precedence f +#examples/scripts/randomcard.bash f +#examples/scripts/scrollbar f +#examples/scripts/scrollbar2 f +#examples/scripts/self-repro f +#examples/scripts/showperm.bash f +examples/scripts/shprompt f +examples/scripts/spin.bash f +#examples/scripts/timeout f +#examples/scripts/timeout2 f +#examples/scripts/timeout3 f +#examples/scripts/vtree2 f +#examples/scripts/vtree3 f +#examples/scripts/vtree3a f +#examples/scripts/websrv.sh f +examples/scripts/xterm_title f +examples/scripts/zprintf f +examples/startup-files/README f +examples/startup-files/Bashrc.bfox f +examples/startup-files/Bash_aliases f +examples/startup-files/Bash_profile f +examples/startup-files/bash-profile f +examples/startup-files/bashrc f +#examples/startup-files/apple/README f +#examples/startup-files/apple/aliases f +#examples/startup-files/apple/bash.defaults f +#examples/startup-files/apple/environment f +#examples/startup-files/apple/login f +#examples/startup-files/apple/logout f +#examples/startup-files/apple/rc f +#examples/misc/suncmd.termcap f +examples/misc/aliasconv.sh f +examples/misc/aliasconv.bash f +examples/misc/cshtobash f +tests/README f +tests/COPYRIGHT f +tests/test-glue-functions f +tests/alias.tests f +tests/alias1.sub f +tests/alias2.sub f +tests/alias.right f +tests/appendop.tests f +tests/appendop1.sub f +tests/appendop2.sub f +tests/appendop.right f +tests/arith-for.tests f +tests/arith-for.right f +tests/arith.tests f +tests/arith.right f +tests/arith1.sub f +tests/arith2.sub f +tests/arith3.sub f +tests/arith4.sub f +tests/arith5.sub f +tests/arith6.sub f +tests/arith7.sub f +tests/array.tests f +tests/array.right f +tests/array1.sub f +tests/array2.sub f +tests/array3.sub f +tests/array4.sub f +tests/array5.sub f +tests/array6.sub f +tests/array7.sub f +tests/array8.sub f +tests/array9.sub f +tests/array10.sub f +tests/array11.sub f +tests/array12.sub f +tests/array13.sub f +tests/array14.sub f +tests/array15.sub f +tests/array16.sub f +tests/array17.sub f +tests/array18.sub f +tests/array19.sub f +tests/array20.sub f +tests/array21.sub f +tests/array-at-star f +tests/array2.right f +tests/assoc.tests f +tests/assoc.right f +tests/assoc1.sub f +tests/assoc2.sub f +tests/assoc3.sub f +tests/assoc4.sub f +tests/assoc5.sub f +tests/assoc6.sub f +tests/assoc7.sub f +tests/assoc8.sub f +tests/attr.tests f +tests/attr.right f +tests/attr1.sub f +tests/attr2.sub f +tests/braces.tests f +tests/braces.right f +tests/builtins.tests f +tests/builtins.right f +tests/builtins1.sub f +tests/builtins2.sub f +tests/builtins3.sub f +tests/builtins4.sub f +tests/builtins5.sub f +tests/builtins6.sub f +tests/source1.sub f +tests/source2.sub f +tests/source3.sub f +tests/source4.sub f +tests/source5.sub f +tests/source6.sub f +tests/source7.sub f +tests/case.tests f +tests/case.right f +tests/case1.sub f +tests/casemod.tests f +tests/casemod.right f +tests/comsub.tests f +tests/comsub.right f +tests/comsub1.sub f +tests/comsub2.sub f +tests/comsub3.sub f +tests/comsub-eof.tests f +tests/comsub-eof0.sub f +tests/comsub-eof1.sub f +tests/comsub-eof2.sub f +tests/comsub-eof3.sub f +tests/comsub-eof4.sub f +tests/comsub-eof5.sub f +tests/comsub-eof.right f +tests/comsub-posix.tests f +tests/comsub-posix.right f +tests/comsub-posix1.sub f +tests/comsub-posix2.sub f +tests/comsub-posix3.sub f +tests/cond.tests f +tests/cond.right f +tests/cond-regexp1.sub f +tests/cond-regexp2.sub f +tests/cond-regexp3.sub f +tests/coproc.tests f +tests/coproc.right f +tests/cprint.tests f +tests/cprint.right f +tests/dbg-support.right f +tests/dbg-support.sub f +tests/dbg-support.tests f +tests/dbg-support2.right f +tests/dbg-support2.tests f +tests/dbg-support3.sub f +tests/dollar-at-star f +tests/dollar-at-star1.sub f +tests/dollar-at-star2.sub f +tests/dollar-at-star3.sub f +tests/dollar-at-star4.sub f +tests/dollar-at-star5.sub f +tests/dollar-at-star6.sub f +tests/dollar-at-star7.sub f +tests/dollar-at-star8.sub f +tests/dollar-at1.sub f +tests/dollar-at2.sub f +tests/dollar-at3.sub f +tests/dollar-at4.sub f +tests/dollar-at5.sub f +tests/dollar-at6.sub f +tests/dollar-star1.sub f +tests/dollar-star2.sub f +tests/dollar-star3.sub f +tests/dollar-star4.sub f +tests/dollar-star5.sub f +tests/dollar-star6.sub f +tests/dollar-star7.sub f +tests/dollar.right f +tests/dstack.tests f +tests/dstack.right f +tests/dstack2.tests f +tests/dstack2.right f +tests/errors.tests f +tests/errors.right f +tests/errors1.sub f +tests/errors2.sub f +tests/errors3.sub f +tests/errors4.sub f +tests/errors5.sub f +tests/errors6.sub f +tests/execscript f +tests/exec.right f +tests/exec1.sub f 755 +tests/exec2.sub f +tests/exec3.sub f +tests/exec4.sub f +tests/exec5.sub f +tests/exec6.sub f +tests/exec7.sub f +tests/exec8.sub f +tests/exec9.sub f +tests/exec10.sub f +tests/exec11.sub f +tests/exec12.sub f +tests/exec13.sub f +tests/exp.tests f +tests/exp.right f +tests/exp1.sub f +tests/exp2.sub f +tests/exp3.sub f +tests/exp4.sub f +tests/exp5.sub f +tests/exp6.sub f +tests/exp7.sub f +tests/exp8.sub f +tests/exp9.sub f +tests/exportfunc.tests f +tests/exportfunc.right f +tests/exportfunc1.sub f +tests/exportfunc2.sub f +tests/exportfunc3.sub f +tests/extglob.tests f +tests/extglob.right f +tests/extglob1.sub f +tests/extglob1a.sub f +tests/extglob2.sub f +tests/extglob2.tests f +tests/extglob2.right f +tests/extglob3.sub f +tests/extglob3.tests f +tests/extglob3.right f +tests/extglob4.sub f +tests/func.tests f +tests/func.right f +tests/func1.sub f +tests/func2.sub f +tests/func3.sub f +tests/func4.sub f +tests/getopts.tests f +tests/getopts.right f +tests/getopts1.sub f +tests/getopts2.sub f +tests/getopts3.sub f +tests/getopts4.sub f +tests/getopts5.sub f +tests/getopts6.sub f +tests/getopts7.sub f +tests/getopts8.sub f +tests/getopts9.sub f +tests/getopts10.sub f +tests/glob.tests f +tests/glob1.sub f +tests/glob.right f +tests/globstar.tests f +tests/globstar.right f +tests/globstar1.sub f +tests/globstar2.sub f +tests/heredoc.tests f +tests/heredoc.right f +tests/heredoc1.sub f +tests/heredoc2.sub f +tests/heredoc3.sub f +tests/herestr.tests f +tests/herestr.right f +tests/herestr1.sub f +tests/histexp.tests f +tests/histexp1.sub f +tests/histexp2.sub f +tests/histexp3.sub f +tests/histexp4.sub f +tests/histexp.right f +tests/history.tests f +tests/history.right f +tests/history.list f 444 +tests/history1.sub f +tests/history2.sub f +tests/ifs.tests f +tests/ifs.right f +tests/ifs-posix.tests f +tests/ifs-posix.right f +tests/input-line.sh f +tests/input-line.sub f +tests/input.right f +tests/intl.tests f +tests/intl1.sub f +tests/intl2.sub f +tests/intl3.sub f +tests/intl.right f +tests/iquote.tests f +tests/iquote.right f +tests/iquote1.sub f +tests/invert.tests f +tests/invert.right f +tests/jobs.tests f +tests/jobs1.sub f +tests/jobs2.sub f +tests/jobs3.sub f +tests/jobs4.sub f +tests/jobs5.sub f +tests/jobs.right f +tests/lastpipe.right f +tests/lastpipe.tests f +tests/lastpipe1.sub f +tests/lastpipe2.sub f +tests/mapfile.data f +tests/mapfile.right f +tests/mapfile.tests f +tests/mapfile1.sub f +tests/mapfile2.sub f +tests/more-exp.tests f +tests/more-exp.right f +tests/nameref.tests f +tests/nameref1.sub f +tests/nameref2.sub f +tests/nameref3.sub f +tests/nameref4.sub f +tests/nameref5.sub f +tests/nameref6.sub f +tests/nameref7.sub f +tests/nameref8.sub f +tests/nameref9.sub f +tests/nameref10.sub f +tests/nameref11.sub f +tests/nameref12.sub f +tests/nameref13.sub f +tests/nameref14.sub f +tests/nameref15.sub f +tests/nameref16.sub f +tests/nameref17.sub f +tests/nameref18.sub f +tests/nameref.right f +tests/new-exp.tests f +tests/new-exp1.sub f +tests/new-exp2.sub f +tests/new-exp3.sub f +tests/new-exp4.sub f +tests/new-exp5.sub f +tests/new-exp6.sub f +tests/new-exp7.sub f +tests/new-exp8.sub f +tests/new-exp9.sub f +tests/new-exp10.sub f +tests/new-exp.right f +tests/nquote.tests f +tests/nquote.right f +tests/nquote1.sub f +tests/nquote2.sub f +tests/nquote3.sub f +tests/nquote1.tests f +tests/nquote1.right f +tests/nquote2.tests f +tests/nquote2.right f +tests/nquote3.tests f +tests/nquote3.right f +tests/nquote4.tests f +tests/nquote4.right f +tests/nquote5.tests f +tests/nquote5.right f +tests/parser.tests f +tests/parser.right f +tests/parser1.sub f +tests/posix2.tests f +tests/posix2.right f +tests/posixexp.tests f +tests/posixexp.right f +tests/posixexp1.sub f +tests/posixexp2.sub f +tests/posixexp2.tests f +tests/posixexp2.right f +tests/posixpat.tests f +tests/posixpat.right f +tests/posixpipe.tests f +tests/posixpipe.right f +tests/prec.right f +tests/precedence f +tests/printf.tests f +tests/printf.right f +tests/printf1.sub f +tests/printf2.sub f +tests/printf3.sub f +tests/printf4.sub f +tests/quote.tests f +tests/quote.right f +tests/quote1.sub f +tests/read.tests f +tests/read.right f +tests/read1.sub f +tests/read2.sub f +tests/read3.sub f +tests/read4.sub f +tests/read5.sub f +tests/read6.sub f +tests/redir.tests f +tests/redir.right f +tests/redir1.sub f +tests/redir2.sub f +tests/redir3.sub f +tests/redir3.in1 f +tests/redir3.in2 f +tests/redir4.sub f +tests/redir4.in1 f +tests/redir5.sub f +tests/redir6.sub f +tests/redir7.sub f +tests/redir8.sub f +tests/redir9.sub f +tests/redir10.sub f +tests/redir11.sub f +tests/redir12.sub f +tests/rhs-exp.tests f +tests/rhs-exp.right f +tests/rhs-exp1.sub f +tests/rsh.tests f +tests/rsh.right f +tests/run-all f +tests/run-minimal f +tests/run-alias f +tests/run-appendop f +tests/run-arith-for f +tests/run-arith f +tests/run-array f +tests/run-array2 f +tests/run-assoc f +tests/run-attr f +tests/run-braces f +tests/run-builtins f +tests/run-case f +tests/run-casemod f +tests/run-comsub f +tests/run-comsub-eof f +tests/run-comsub-posix f +tests/run-cond f +tests/run-coproc f +tests/run-cprint f +tests/run-dbg-support f +tests/run-dbg-support2 f +tests/run-dirstack f +tests/run-dollars f +tests/run-errors f +tests/run-execscript f +tests/run-exp-tests f +tests/run-exportfunc f +tests/run-extglob f +tests/run-extglob2 f +tests/run-extglob3 f +tests/run-func f +tests/run-getopts f +tests/run-glob-test f +tests/run-globstar f +tests/run-heredoc f +tests/run-herestr f +tests/run-histexpand f +tests/run-history f +tests/run-ifs f +tests/run-ifs-posix f +tests/run-input-test f +tests/run-intl f +tests/run-iquote f +tests/run-invert f +tests/run-jobs f +tests/run-lastpipe f +tests/run-mapfile f +tests/run-more-exp f +tests/run-nameref f +tests/run-new-exp f +tests/run-nquote f +tests/run-nquote1 f +tests/run-nquote2 f +tests/run-nquote3 f +tests/run-nquote4 f +tests/run-nquote5 f +tests/run-parser f +tests/run-posix2 f +tests/run-posixexp f +tests/run-posixexp2 f +tests/run-posixpat f +tests/run-posixpipe f +tests/run-precedence f +tests/run-printf f +tests/run-quote f +tests/run-read f +tests/run-redir f +tests/run-rhs-exp f +tests/run-rsh f +tests/run-set-e f +tests/run-set-x f +tests/run-shopt f +tests/run-strip f +tests/run-test f +tests/run-tilde f +tests/run-tilde2 f +tests/run-trap f +tests/run-type f +tests/run-varenv f +tests/run-vredir f +tests/set-e.tests f +tests/set-e1.sub f +tests/set-e2.sub f +tests/set-e3.sub f +tests/set-e3a.sub f +tests/set-e.right f +tests/set-x.tests f +tests/set-x1.sub f +tests/set-x.right f +tests/shopt.tests f +tests/shopt.right f +tests/strip.tests f +tests/strip.right f +tests/test.tests f +tests/test.right f +tests/tilde.tests f +tests/tilde.right f +tests/tilde2.tests f +tests/tilde2.right f +tests/trap.tests f +tests/trap.right f +tests/trap1.sub f 755 +tests/trap2.sub f 755 +tests/trap2a.sub f 755 +tests/trap3.sub f +tests/trap4.sub f +tests/trap5.sub f +tests/type.tests f +tests/type.right f +tests/type1.sub f +tests/type2.sub f +tests/type3.sub f +tests/type4.sub f +tests/unicode1.sub f +tests/unicode2.sub f +tests/unicode3.sub f +tests/varenv.right f +tests/varenv.sh f +tests/varenv1.sub f +tests/varenv2.sub f +tests/varenv3.sub f +tests/varenv4.sub f +tests/varenv5.sub f +tests/varenv6.sub f +tests/varenv7.sub f +tests/varenv8.sub f +tests/version f +tests/version.mini f +tests/vredir.tests f +tests/vredir.right f +tests/vredir1.sub f +tests/vredir2.sub f +tests/vredir3.sub f +tests/vredir4.sub f +tests/vredir5.sub f +tests/vredir6.sub f +tests/vredir7.sub f +tests/misc/dev-tcp.tests f +tests/misc/perf-script f +tests/misc/perftest f +tests/misc/read-nchars.tests f +tests/misc/redir-t2.sh f +tests/misc/run-r2.sh f +tests/misc/sigint-1.sh f +tests/misc/sigint-2.sh f +tests/misc/sigint-3.sh f +tests/misc/sigint-4.sh f +tests/misc/test-minus-e.1 f +tests/misc/test-minus-e.2 f +tests/misc/wait-bg.tests f +#examples/scripts.v2/PERMISSION f +#examples/scripts.v2/README f +#examples/scripts.v2/arc2tarz f +#examples/scripts.v2/bashrand f +#examples/scripts.v2/cal2day.bash f +#examples/scripts.v2/cdhist.bash f +#examples/scripts.v2/corename f +#examples/scripts.v2/fman f +#examples/scripts.v2/frcp f +#examples/scripts.v2/lowercase f +#examples/scripts.v2/ncp f +#examples/scripts.v2/newext f +#examples/scripts.v2/nmv f +#examples/scripts.v2/pages f +#examples/scripts.v2/pf f +#examples/scripts.v2/ren f +#examples/scripts.v2/rename f +#examples/scripts.v2/repeat f +#examples/scripts.v2/untar f +#examples/scripts.v2/uudec f +#examples/scripts.v2/uuenc f +#examples/scripts.v2/vtree f +#examples/scripts.v2/where f +#examples/scripts.v2/pmtop f +#examples/scripts.v2/shprof f +#examples/scripts.noah/PERMISSION f +#examples/scripts.noah/README f +#examples/scripts.noah/aref.bash f +#examples/scripts.noah/bash.sub.bash f +#examples/scripts.noah/bash_version.bash f +#examples/scripts.noah/meta.bash f +#examples/scripts.noah/mktmp.bash f +#examples/scripts.noah/number.bash f +#examples/scripts.noah/prompt.bash f +#examples/scripts.noah/remap_keys.bash f +#examples/scripts.noah/require.bash f +#examples/scripts.noah/send_mail.bash f +#examples/scripts.noah/shcat.bash f +#examples/scripts.noah/source.bash f +#examples/scripts.noah/string.bash f +#examples/scripts.noah/stty.bash f +#examples/scripts.noah/y_or_n_p.bash f diff --git a/Makefile.in b/Makefile.in new file mode 100644 index 0000000..c7b62bc --- /dev/null +++ b/Makefile.in @@ -0,0 +1,1623 @@ +# Makefile for bash-4.4, version 4.18 +# +# Copyright (C) 1996-2015 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 3 of the License, 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, see . + +# 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@ + +PACKAGE_TARNAME = @PACKAGE_TARNAME@ + +# Include some boilerplate Gnu makefile definitions. +prefix = @prefix@ + +exec_prefix = @exec_prefix@ + +datarootdir = @datarootdir@ + +bindir = @bindir@ +libdir = @libdir@ +infodir = @infodir@ +includedir = @includedir@ +datadir = @datadir@ +localedir = @localedir@ + +loadablesdir = @loadablesdir@ +headersdir = @headersdir@ + +docdir = @docdir@ + +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, run the make as `make PURIFY=purify' +#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_FOR_BUILD@ $(LOCAL_LDFLAGS) $(CFLAGS_FOR_BUILD) + +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}/strchrnul.c \ + ${SH_LIBSRC}/strcasecmp.c ${SH_LIBSRC}/strdup.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}/strcasestr.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}/mbschr.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 ${SH_LIBSRC}/fpurge.c \ + ${SH_LIBSRC}/zgetline.c ${SH_LIBSRC}/mbscmp.c \ + ${SH_LIBSRC}/casemod.c ${SH_LIBSRC}/uconvert.c \ + ${SH_LIBSRC}/ufuncs.c ${SH_LIBSRC}/dprintf.c \ + ${SH_LIBSRC}/input_avail.c ${SH_LIBSRC}/mbscasecmp.c \ + ${SH_LIBSRC}/fnxform.c ${SH_LIBSRC}/unicode.c \ + ${SH_LIBSRC}/wcswidth.c ${SH_LIBSRC}/wcsnwidth.c \ + ${SH_LIBSRC}/shmbchar.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)/colors.h $(RL_LIBSRC)/parse-colors.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)/colors.c $(RL_LIBSRC)/parse-colors.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 \ + $(RL_LIBDIR)/colors.o $(RL_LIBDIR)/parse-colors.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)/gmisc.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 \ + $(GLOB_LIBDIR)/gmisc.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@ + +# libiconv +LIBICONV = @LIBICONV@ + +# 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 = $(GLOB_LIB) $(SHLIB_LIB) $(READLINE_LIB) $(HISTORY_LIB) $(TERMCAP_LIB) \ + $(TILDE_LIB) $(MALLOC_LIB) $(INTL_LIB) $(LIBICONV) $(LOCAL_LIBS) + +LIBDEP = $(GLOB_DEP) $(SHLIB_DEP) $(INTL_DEP) $(READLINE_DEP) $(HISTORY_DEP) $(TERMCAP_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 assoc.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 assoc.h \ + $(BASHINCFILES) + +SOURCES = $(CSOURCES) $(HSOURCES) $(BUILTIN_DEFS) + +# headers in top-level source directory that get installed by install-headers +INSTALLED_HEADERS = shell.h bashjmp.h command.h syntax.h general.h error.h \ + variables.h array.h assoc.h arrayfunc.h quit.h dispose_cmd.h \ + make_cmd.h subst.h sig.h externs.h builtins.h \ + bashtypes.h xmalloc.h config-top.h config-bot.h \ + bashintl.h bashansi.h bashjmp.h alias.h hashlib.h \ + conftypes.h unwind_prot.h jobs.h siglist.h +INSTALLED_BUILTINS_HEADERS = bashgetopt.h common.h getopt.h +INSTALLED_INCFILES = posixstat.h ansi_stdlib.h filecntl.h posixdir.h \ + memalloc.h stdc.h posixjmp.h posixwait.h posixtime.h systimes.h \ + unionwait.h maxpath.h shtty.h typemax.h ocache.h chartypes.h gettext.h \ + posixstat.h shmbchar.h shmbutil.h stat-time.h + +# 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 assoc.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 \ + $(DEFSRC)/mapfile.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 $(DEFDIR)/mapfile.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) xcase$(EXEEXT) +CREATED_SUPPORT = signames.h recho$(EXEEXT) zecho$(EXEEXT) printenv$(EXEEXT) \ + tests/recho$(EXEEXT) tests/zecho$(EXEEXT) \ + tests/printenv$(EXEEXT) xcase$(EXEEXT) tests/xcase$(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 config.status.lineno +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/Makefile.inc \ + examples/loadables/perl/Makefile support/Makefile \ + lib/intl/Makefile po/Makefile po/Makefile.in +CREATED_HEADERS = signames.h config.h pathnames.h version.h y.tab.h \ + ${DEFDIR}/builtext.h + +OTHER_DOCS = $(srcdir)/CHANGES $(srcdir)/COMPAT $(srcdir)/NEWS $(srcdir)/POSIX \ + $(srcdir)/RBASH $(srcdir)/README +OTHER_INSTALLED_DOCS = CHANGES COMPAT NEWS POSIX RBASH README + +LOADABLES_DIR = ${top_builddir}/examples/loadables + +# Keep GNU Make from exporting the entire environment for small machines. +.NOEXPORT: + +.made: $(Program) bashbug $(SDIR)/man2html$(EXEEXT) + @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 patchlevel.h + $(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) ${LDFLAGS_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.h 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: 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 + +y.tab.h: y.tab.c + @true + + +# Subdirs will often times want version.h, so they'll change back up to +# the top level and try to create it. This causes parallel build issues +# so just force top level sanity before we descend. +$(LIBDEP): .build +#$(LIBDEP): version.h + +$(READLINE_LIBRARY): config.h $(READLINE_SOURCE) + @echo making $@ in ${RL_LIBDIR} + @( { test "${RL_LIBDIR}" = "${libdir}" && exit 0; } || \ + cd ${RL_LIBDIR} && $(MAKE) $(MFLAGS) DEBUG=${DEBUG} libreadline.a) || exit 1 + +$(HISTORY_LIBRARY): config.h $(HISTORY_SOURCE) $(READLINE_DEP) + @echo making $@ in ${HIST_LIBDIR} + @( { test "${HIST_LIBDIR}" = "${libdir}" && exit 0; } || \ + cd ${HIST_LIBDIR} && $(MAKE) $(MFLAGS) DEBUG=${DEBUG} 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_DEP} + +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) ${LDFLAGS_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} ${LDFLAGS_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 $(DEFDIR)/builtext.h version.h + @(cd $(DEFDIR) && $(MAKE) $(MFLAGS) DEBUG=${DEBUG} targets ) || 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 + +$(SDIR)/man2html$(EXEEXT): ${SUPPORT_SRC}/man2html.c + @(cd $(SDIR) && $(MAKE) $(MFLAGS) all ) || 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.ac $(srcdir)/aclocal.m4 $(srcdir)/config.h.in + cd $(srcdir) && autoconf + +# for chet +reconfig: force + sh $(srcdir)/configure -C + +loadables: + cd $(LOADABLES_DIR) && $(MAKE) $(MFLAGS) all + +#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: + +# unused +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) + @${SHELL} $(SUPPORT_SRC)mkinstalldirs $(DESTDIR)$(docdir) + -( cd $(PO_DIR) ; $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ ) + +install: .made installdirs + $(INSTALL_PROGRAM) $(INSTALLMODE) $(Program) $(DESTDIR)$(bindir)/$(Program) + $(INSTALL_SCRIPT) $(INSTALLMODE2) bashbug $(DESTDIR)$(bindir)/bashbug + $(INSTALL_DATA) $(OTHER_DOCS) $(DESTDIR)$(docdir) + -( 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) $@ ) + -( cd $(LOADABLES_DIR) && $(MAKE) $(MFLAGS) DESTDIR=$(DESTDIR) $@ ) + +install-strip: + $(MAKE) $(MFLAGS) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' \ + prefix=${prefix} exec_prefix=${exec_prefix} \ + DESTDIR=$(DESTDIR) install + +install-headers-dirs: + @${SHELL} $(SUPPORT_SRC)mkinstalldirs $(DESTDIR)$(headersdir) + @${SHELL} $(SUPPORT_SRC)mkinstalldirs $(DESTDIR)$(headersdir)/builtins + @${SHELL} $(SUPPORT_SRC)mkinstalldirs $(DESTDIR)$(headersdir)/include + @${SHELL} $(SUPPORT_SRC)mkinstalldirs $(DESTDIR)$(libdir)/pkgconfig + +install-headers: install-headers-dirs + @for hf in $(INSTALLED_HEADERS) ; do \ + ${INSTALL_DATA} $(srcdir)/"$$hf" $(DESTDIR)$(headersdir)/$$hf; \ + done + @for hf in $(INSTALLED_INCFILES) ; do \ + ${INSTALL_DATA} $(BASHINCDIR)/"$$hf" $(DESTDIR)$(headersdir)/include/$$hf; \ + done + @for hf in $(INSTALLED_BUILTINS_HEADERS) ; do \ + ${INSTALL_DATA} $(BUILTIN_SRCDIR)/"$$hf" $(DESTDIR)$(headersdir)/builtins/$$hf; \ + done + @for hf in $(CREATED_HEADERS) ; do \ + ${INSTALL_DATA} $(BUILD_DIR)/"$$hf" $(DESTDIR)$(headersdir)/$$hf; \ + done + $(INSTALL_DATA) $(SDIR)/bash.pc $(DESTDIR)$(libdir)/pkgconfig/bash.pc + +uninstall-headers: + -( cd $(DESTDIR)$(headersdir) && $(RM) $(INSTALLED_HEADERS) ) + -( cd $(DESTDIR)$(headersdir)/include && $(RM) $(INSTALLED_INCFILES) ) + -( cd $(DESTDIR)$(headersdir)/builtins && $(RM) $(INSTALLED_BUILTINS_HEADERS) ) + -( cd $(DESTDIR)$(headersdir) && $(RM) $(CREATED_HEADERS) ) + -( $(RM) $(DESTDIR)$(libdir)/pkgconfig/bash.pc ) + +uninstall: .made + $(RM) $(DESTDIR)$(bindir)/$(Program) $(DESTDIR)$(bindir)/bashbug + -( cd $(DESTDIR)$(docdir) && ${RM} ${OTHER_INSTALLED_DOCS} ) + -( 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) $@ ) + -( cd $(LOADABLES_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) $@ ) + -( cd $(LOADABLES_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) $@ ) + -( cd $(LOADABLES_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) $@ ) + -( cd $(LOADABLES_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) $@ ) + -( cd $(LOADABLES_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) ${LDFLAGS_FOR_BUILD} -o $@ $(SUPPORT_SRC)recho.c ${LIBS_FOR_BUILD} + +zecho$(EXEEXT): $(SUPPORT_SRC)zecho.c + @$(CC_FOR_BUILD) $(CCFLAGS_FOR_BUILD) ${LDFLAGS_FOR_BUILD} -o $@ $(SUPPORT_SRC)zecho.c ${LIBS_FOR_BUILD} + +printenv$(EXEEXT): $(SUPPORT_SRC)printenv.c + @$(CC_FOR_BUILD) $(CCFLAGS_FOR_BUILD) ${LDFLAGS_FOR_BUILD} -o $@ $(SUPPORT_SRC)printenv.c ${LIBS_FOR_BUILD} + +xcase$(EXEEXT): $(SUPPORT_SRC)xcase.c + @$(CC_FOR_BUILD) $(CCFLAGS_FOR_BUILD) ${LDFLAGS_FOR_BUILD} -o $@ $(SUPPORT_SRC)xcase.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} -t $(PACKAGE_VERSION) + +xdist: force + ( cd $(DOCDIR) && $(MAKE) $(MFLAGS) $@ ) + ( cd po && $(MAKE) $(MFLAGS) $@ ) + +depend: depends + +depends: force + $(Program) $(SUPPORT_SRC)mkdep -c ${CC} -- ${CCFLAGS} ${CSOURCES} + +#### PRIVATE TARGETS #### +hashtest: hashlib.c + $(CC) -DTEST_HASHING $(CCFLAGS) $(TEST_NBUCKETS) -o $@ $(srcdir)/hashlib.c xmalloc.o $(INTL_LIB) + +############################ DEPENDENCIES ############################### + +# Files that depend on the definitions in config-top.h, which are not meant +# to be changed +bashhist.o: config-top.h +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 +execute_cmd.o: $(DEFSRC)/getopt.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 pathnames.h hashlib.h +hashcmd.o: quit.h sig.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 +input.o: quit.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 sig.h siglist.h syntax.h dispose_cmd.h parser.h +make_cmd.o: ${BASHINCDIR}/shmbutil.h ${BASHINCDIR}/shmbchar.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 ${BASHINCDIR}/shmbchar.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: ${BASHINCDIR}/shmbutil.h ${BASHINCDIR}/shmbchar.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 bashline.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 +sig.o: ${DEFDIR}/builtext.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 parser.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 ${BASHINCDIR}/shmbchar.h +subst.o: ${DEFDIR}/builtext.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 jobs.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 assoc.h +variables.o: version.h $(DEFDIR)/builtext.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: execute_cmd.h 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 +nojobs.o: $(DEFDIR)/builtext.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 pathexp.h +arrayfunc.o: $(DEFSRC)/common.h +arrayfunc.o: ${BASHINCDIR}/shmbutil.h ${BASHINCDIR}/shmbchar.h +assoc.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h +assoc.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h +assoc.o: command.h ${BASHINCDIR}/stdc.h error.h +assoc.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h +assoc.o: assoc.h hashlib.h +assoc.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h +assoc.o: make_cmd.h subst.h sig.h pathnames.h externs.h +assoc.o: $(DEFSRC)/common.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 ${BASHINCDIR}/shmbchar.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 +pcomplete.o: ${BASHINCDIR}/shmbutil.h ${BASHINCDIR}/shmbchar.h +pcomplete.o: ${DEFDIR}/builtext.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 +bashline.o: ${BASHINCDIR}/shmbutil.h ${BASHINCDIR}/shmbchar.h +bracecomp.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h +bracecomp.o: shell.h syntax.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h +bracecomp.o: command.h ${BASHINCDIR}/stdc.h error.h +bracecomp.o: general.h xmalloc.h bashtypes.h variables.h arrayfunc.h conftypes.h +bracecomp.o: array.h hashlib.h alias.h builtins.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: ${BASHINCDIR}/shmbutil.h ${BASHINCDIR}/shmbchar.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 +y.tab.o: 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 pathnames.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 pathnames.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 pathnames.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/break.o: pathnames.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/builtin.o: pathnames.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 pathnames.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 pathnames.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 pathnames.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 pathnames.h flags.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/echo.o: pathnames.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 pathnames.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/eval.o: pathnames.h +builtins/exec.o: bashtypes.h pathnames.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/exec.o: pathnames.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/exit.o: pathnames.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 pathnames.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/fg_bg.o: pathnames.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/getopts.o: pathnames.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/hash.o: pathnames.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 pathnames.h +builtins/history.o: bashtypes.h pathnames.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/inlib.o: pathnames.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/jobs.o: pathnames.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/kill.o: pathnames.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/let.o: pathnames.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}/shmbutil.h ${BASHINCDIR}/shmbchar.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 pathnames.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/read.o: ${BASHINCDIR}/shmbutil.h ${BASHINCDIR}/shmbchar.h +builtins/read.o: pathnames.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/return.o: pathnames.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/set.o: pathnames.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/setattr.o: pathnames.h flags.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/shift.o: pathnames.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 pathnames.h +builtins/shopt.o: bashhist.h bashline.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/source.o: pathnames.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/suspend.o: pathnames.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 pathnames.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/times.o: pathnames.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/trap.o: pathnames.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/type.o: pathnames.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/ulimit.o: pathnames.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 pathnames.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 pathnames.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 pathnames.h general.h +builtins/complete.o: bashtypes.h ${BASHINCDIR}/chartypes.h xmalloc.h +builtins/complete.o: pcomplete.h +builtins/complete.o: ${DEFSRC}/common.h ${DEFSRC}/bashgetopt.h +builtins/mapfile.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h xmalloc.h ${BASHINCDIR}/maxpath.h +builtins/mapfile.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h +builtins/mapfile.o: shell.h syntax.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h arrayfunc.h conftypes.h +builtins/mapfile.o: pathnames.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/mapfile.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +builtins/mkbuiltins.o: ${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/mapfile.o: $(DEFSRC)/mapfile.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/NEWS b/NEWS new file mode 100644 index 0000000..931dc84 --- /dev/null +++ b/NEWS @@ -0,0 +1,2039 @@ +This is a terse description of the new features added to bash-4.4 since +the release of bash-4.3. As always, the manual page (doc/bash.1) is +the place to look for complete descriptions. + +1. New Features in Bash + +a. There is now a settable configuration #define that will cause the shell + to exit if the shell is running setuid without the -p option and setuid + to the real uid fails. + +b. Command and process substitutions now turn off the `-v' option when + executing, as other shells seem to do. + +c. The default value for the `checkhash' shell option may now be set at + compile time with a #define. + +d. The `mapfile' builtin now has a -d option to use an arbitrary character + as the record delimiter, and a -t option to strip the delimiter as + supplied with -d. + +e. The maximum number of nested recursive calls to `eval' is now settable in + config-top.h; the default is no limit. + +f. The `-p' option to declare and similar builtins will display attributes for + named variables even when those variables have not been assigned values + (which are technically unset). + +g. The maximum number of nested recursive calls to `source' is now settable + in config-top.h; the default is no limit. + +h. All builtin commands recognize the `--help' option and print a usage + summary. + +i. Bash does not allow function names containing `/' and `=' to be exported. + +j. The `ulimit' builtin has new -k (kqueues) and -P (pseudoterminals) options. + +k. The shell now allows `time ; othercommand' to time null commands. + +l. There is a new `--enable-function-import' configuration option to allow + importing shell functions from the environment; import is enabled by + default. + +m. `printf -v var ""' will now set `var' to the empty string, as if `var=""' + had been executed. + +n. GLOBIGNORE, the pattern substitution word expansion, and programmable + completion match filtering now honor the value of the `nocasematch' option. + +o. There is a new ${parameter@spec} family of operators to transform the + value of `parameter'. + +p. Bash no longer attempts to perform compound assignment if a variable on the + rhs of an assignment statement argument to `declare' has the form of a + compound assignment (e.g., w='(word)' ; declare foo=$w); compound + assignments are accepted if the variable was already declared as an array, + but with a warning. + +q. The declare builtin no longer displays array variables using the compound + assignment syntax with quotes; that will generate warnings when re-used as + input, and isn't necessary. + +r. Executing the rhs of && and || will no longer cause the shell to fork if + it's not necessary. + +s. The `local' builtin takes a new argument: `-', which will cause it to save + and the single-letter shell options and restore their previous values at + function return. + +t. `complete' and `compgen' have a new `-o nosort' option, which forces + readline to not sort the completion matches. + +u. Bash now allows waiting for the most recent process substitution, since it + appears as $!. + +v. The `unset' builtin now unsets a scalar variable if it is subscripted with + a `0', analogous to the ${var[0]} expansion. + +w. `set -i' is no longer valid, as in other shells. + +x. BASH_SUBSHELL is now updated for process substitution and group commands + in pipelines, and is available with the same value when running any exit + trap. + +y. Bash now checks $INSIDE_EMACS as well as $EMACS when deciding whether or + not bash is being run in a GNU Emacs shell window. + +z. Bash now treats SIGINT received when running a non-builtin command in a + loop the way it has traditionally treated running a builtin command: + running any trap handler and breaking out of the loop. + +aa. New variable: EXECIGNORE; a colon-separate list of patterns that will + cause matching filenames to be ignored when searching for commands. + +bb. Aliases whose value ends in a shell metacharacter now expand in a way to + allow them to be `pasted' to the next token, which can potentially change + the meaning of a command (e.g., turning `&' into `&&'). + +cc. `make install' now installs the example loadable builtins and a set of + bash headers to use when developing new loadable builtins. + +dd. `enable -f' now attempts to call functions named BUILTIN_builtin_load when + loading BUILTIN, and BUILTIN_builtin_unload when deleting it. This allows + loadable builtins to run initialization and cleanup code. + +ee. There is a new BASH_LOADABLES_PATH variable containing a list of directories + where the `enable -f' command looks for shared objects containing loadable + builtins. + +ff. The `complete_fullquote' option to `shopt' changes filename completion to + quote all shell metacharacters in filenames and directory names. + +gg. The `kill' builtin now has a `-L' option, equivalent to `-l', for + compatibility with Linux standalone versions of kill. + +hh. BASH_COMPAT and FUNCNEST can be inherited and set from the shell's initial + environment. + +ii. inherit_errexit: a new `shopt' option that, when set, causes command + substitutions to inherit the -e option. By default, those subshells disable + -e. It's enabled as part of turning on posix mode. + +jj. New prompt string: PS0. Expanded and displayed by interactive shells after + reading a complete command but before executing it. + +kk. Interactive shells now behave as if SIGTSTP/SIGTTIN/SIGTTOU are set to + SIG_DFL when the shell is started, so they are set to SIG_DFL in child + processes. + +ll. Posix-mode shells now allow double quotes to quote the history expansion + character. + +mm. OLDPWD can be inherited from the environment if it names a directory. + +nn. Shells running as root no longer inherit PS4 from the environment, closing + a security hole involving PS4 expansion performing command substitution. + +oo. If executing an implicit `cd' when the `autocd' option is set, bash will + now invoke a function named `cd' if one exists before executing the `cd' + builtin. + +pp. Value conversions (arithmetic expansions, case modification, etc.) now + happen when assigning elements of an array using compound assignment. + +qq. There is a new option settable in config-top.h that makes multiple + directory arguments to `cd' a fatal error. + +rr. Bash now uses mktemp() when creating internal temporary files; it produces + a warning at build time on many Linux systems. + +2. New Features in Readline + +a. The history truncation code now uses the same error recovery mechansim as + the history writing code, and restores the old version of the history file + on error. The error recovery mechanism handles symlinked history files. + +b. There is a new bindable variable, `enable-bracketed-paste', which enables + support for a terminal's bracketed paste mode. + +c. The editing mode indicators can now be strings and are user-settable + (new `emacs-mode-string', `vi-cmd-mode-string' and `vi-ins-mode-string' + variables). Mode strings can contain invisible character sequences. + Setting mode strings to null strings restores the defaults. + +d. Prompt expansion adds the mode string to the last line of a multi-line + prompt (one with embedded newlines). + +e. There is a new bindable variable, `colored-completion-prefix', which, if + set, causes the common prefix of a set of possible completions to be + displayed in color. + +f. There is a new bindable command `vi-yank-pop', a vi-mode version of emacs- + mode yank-pop. + +g. The redisplay code underwent several efficiency improvements for multibyte + locales. + +h. The insert-char function attempts to batch-insert all pending typeahead + that maps to self-insert, as long as it is coming from the terminal. + +i. rl_callback_sigcleanup: a new application function that can clean up and + unset any state set by readline's callback mode. Intended to be used + after a signal. + +j. If an incremental search string has its last character removed with DEL, the + resulting empty search string no longer matches the previous line. + +k. If readline reads a history file that begins with `#' (or the value of + the history comment character) and has enabled history timestamps, the + history entries are assumed to be delimited by timestamps. This allows + multi-line history entries. + +l. Readline now throws an error if it parses a key binding without a + terminating `:' or whitespace. + +m. The default binding for ^W in vi mode now uses word boundaries specified + by Posix (vi-unix-word-rubout is bindable command name). + +n. rl_clear_visible_line: new application-callable function; clears all + screen lines occupied by the current visible readline line. + +o. rl_tty_set_echoing: application-callable function that controls whether + or not readline thinks it is echoing terminal output. + +p. Handle >| and strings of digits preceding and following redirection + specifications as single tokens when tokenizing the line for history + expansion. + +q. Fixed a bug with displaying completions when the prefix display length + is greater than the length of the completions to be displayed. + +r. The :p history modifier now applies to the entire line, so any expansion + specifying :p causes the line to be printed instead of expanded. + +s. New application-callable function: rl_pending_signal(): returns the signal + number of any signal readline has caught but not yet handled. + +t. New application-settable variable: rl_persistent_signal_handlers: if set + to a non-zero value, readline will enable the readline-6.2 signal handler + behavior in callback mode: handlers are installed when + rl_callback_handler_install is called and removed removed when a complete + line has been read. + +------------------------------------------------------------------------------- +This is a terse description of the new features added to bash-4.3 since +the release of bash-4.2. As always, the manual page (doc/bash.1) is +the place to look for complete descriptions. + +1. New Features in Bash + +a. The `helptopic' completion action now maps to all the help topics, not just + the shell builtins. + +b. The `help' builtin no longer does prefix substring matching first, so + `help read' does not match `readonly', but will do it if exact string + matching fails. + +c. The shell can be compiled to not display a message about processes that + terminate due to SIGTERM. + +d. Non-interactive shells now react to the setting of checkwinsize and set + LINES and COLUMNS after a foreground job exits. + +e. There is a new shell option, `globasciiranges', which, when set to on, + forces globbing range comparisons to use character ordering as if they + were run in the C locale. + +f. There is a new shell option, `direxpand', which makes filename completion + expand variables in directory names in the way bash-4.1 did. + +g. In Posix mode, the `command' builtin does not change whether or not a + builtin it shadows is treated as an assignment builtin. + +h. The `return' and `exit' builtins accept negative exit status arguments. + +i. The word completion code checks whether or not a filename containing a + shell variable expands to a directory name and appends `/' to the word + as appropriate. The same code expands shell variables in command names + when performing command completion. + +j. In Posix mode, it is now an error to attempt to define a shell function + with the same name as a Posix special builtin. + +k. When compiled for strict Posix conformance, history expansion is disabled + by default. + +l. The history expansion character (!) does not cause history expansion when + followed by the closing quote in a double-quoted string. + +m. `complete' and its siblings compgen/compopt now takes a new `-o noquote' + option to inhibit quoting of the completions. + +n. Setting HISTSIZE to a value less than zero causes the history list to be + unlimited (setting it 0 zero disables the history list). + +o. Setting HISTFILESIZE to a value less than zero causes the history file size + to be unlimited (setting it to 0 causes the history file to be truncated + to zero size). + +p. The `read' builtin now skips NUL bytes in the input. + +q. There is a new `bind -X' option to print all key sequences bound to Unix + commands. + +r. When in Posix mode, `read' is interruptible by a trapped signal. After + running the trap handler, read returns 128+signal and throws away any + partially-read input. + +s. The command completion code skips whitespace and assignment statements + before looking for the command name word to be completed. + +t. The build process has a new mechanism for constructing separate help files + that better reflects the current set of compilation options. + +u. The -nt and -ot options to test now work with files with nanosecond + timestamp resolution. + +v. The shell saves the command history in any shell for which history is + enabled and HISTFILE is set, not just interactive shells. + +w. The shell has `nameref' variables and new -n(/+n) options to declare and + unset to use them, and a `test -R' option to test for them. + +x. The shell now allows assigning, referencing, and unsetting elements of + indexed arrays using negative subscripts (a[-1]=2, echo ${a[-1]}) which + count back from the last element of the array. + +y. The {x} operators to the [[ conditional command now do string + comparison according to the current locale if the compatibility level + is greater than 40. + +r. Programmable completion now uses the completion for `b' instead of `a' + when completion is attempted on a line like: a $(b c. + +s. Force extglob on temporarily when parsing the pattern argument to + the == and != operators to the [[ command, for compatibility. + +t. Changed the behavior of interrupting the wait builtin when a SIGCHLD is + received and a trap on SIGCHLD is set to be Posix-mode only. + +u. The read builtin has a new `-N nchars' option, which reads exactly NCHARS + characters, ignoring delimiters like newline. + +v. The mapfile/readarray builtin no longer stores the commands it invokes via + callbacks in the history list. + +w. There is a new `compat40' shopt option. + +2. New Features in Readline + +a. New bindable function: menu-complete-backward. + +b. In the vi insertion keymap, C-n is now bound to menu-complete by default, + and C-p to menu-complete-backward. + +c. When in vi command mode, repeatedly hitting ESC now does nothing, even + when ESC introduces a bound key sequence. This is closer to how + historical vi behaves. + +d. New bindable function: skip-csi-sequence. Can be used as a default to + consume key sequences generated by keys like Home and End without having + to bind all keys. + +e. New application-settable function: rl_filename_rewrite_hook. Can be used + to rewite or modify filenames read from the file system before they are + compared to the word to be completed. + +f. New bindable variable: skip-completed-text, active when completing in the + middle of a word. If enabled, it means that characters in the completion + that match characters in the remainder of the word are "skipped" rather + than inserted into the line. + +g. The pre-readline-6.0 version of menu completion is available as + "old-menu-complete" for users who do not like the readline-6.0 version. + +h. New bindable variable: echo-control-characters. If enabled, and the + tty ECHOCTL bit is set, controls the echoing of characters corresponding + to keyboard-generated signals. + +i. New bindable variable: enable-meta-key. Controls whether or not readline + sends the smm/rmm sequences if the terminal indicates it has a meta key + that enables eight-bit characters. + +------------------------------------------------------------------------------- +This is a terse description of the new features added to bash-4.0 since +the release of bash-3.2. As always, the manual page (doc/bash.1) is +the place to look for complete descriptions. + +1. New Features in Bash + +a. When using substring expansion on the positional parameters, a starting + index of 0 now causes $0 to be prefixed to the list. + +b. The `help' builtin now prints its columns with entries sorted vertically + rather than horizontally. + +c. There is a new variable, $BASHPID, which always returns the process id of + the current shell. + +d. There is a new `autocd' option that, when enabled, causes bash to attempt + to `cd' to a directory name that is supplied as the first word of a + simple command. + +e. There is a new `checkjobs' option that causes the shell to check for and + report any running or stopped jobs at exit. + +f. The programmable completion code exports a new COMP_TYPE variable, set to + a character describing the type of completion being attempted. + +g. The programmable completion code exports a new COMP_KEY variable, set to + the character that caused the completion to be invoked (e.g., TAB). + +h. If creation of a child process fails due to insufficient resources, bash + will try again several times before reporting failure. + +i. The programmable completion code now uses the same set of characters as + readline when breaking the command line into a list of words. + +j. The block multiplier for the ulimit -c and -f options is now 512 when in + Posix mode, as Posix specifies. + +k. Changed the behavior of the read builtin to save any partial input received + in the specified variable when the read builtin times out. This also + results in variables specified as arguments to read to be set to the empty + string when there is no input available. When the read builtin times out, + it returns an exit status greater than 128. + +l. The shell now has the notion of a `compatibility level', controlled by + new variables settable by `shopt'. Setting this variable currently + restores the bash-3.1 behavior when processing quoted strings on the rhs + of the `=~' operator to the `[[' command. + +m. The `ulimit' builtin now has new -b (socket buffer size) and -T (number + of threads) options. + +n. The -p option to `declare' now displays all variable values and attributes + (or function values and attributes if used with -f). + +o. There is a new `compopt' builtin that allows completion functions to modify + completion options for existing completions or the completion currently + being executed. + +p. The `read' builtin has a new -i option which inserts text into the reply + buffer when using readline. + +q. A new `-E' option to the complete builtin allows control of the default + behavior for completion on an empty line. + +r. There is now limited support for completing command name words containing + globbing characters. + +s. Changed format of internal help documentation for all builtins to roughly + follow man page format. + +t. The `help' builtin now has a new -d option, to display a short description, + and a -m option, to print help information in a man page-like format. + +u. There is a new `mapfile' builtin to populate an array with lines from a + given file. The name `readarray' is a synonym. + +v. If a command is not found, the shell attempts to execute a shell function + named `command_not_found_handle', supplying the command words as the + function arguments. + +w. There is a new shell option: `globstar'. When enabled, the globbing code + treats `**' specially -- it matches all directories (and files within + them, when appropriate) recursively. + +x. There is a new shell option: `dirspell'. When enabled, the filename + completion code performs spelling correction on directory names during + completion. + +y. The `-t' option to the `read' builtin now supports fractional timeout + values. + +z. Brace expansion now allows zero-padding of expanded numeric values and + will add the proper number of zeroes to make sure all values contain the + same number of digits. + +aa. There is a new bash-specific bindable readline function: `dabbrev-expand'. + It uses menu completion on a set of words taken from the history list. + +bb. The command assigned to a key sequence with `bind -x' now sets two new + variables in the environment of the executed command: READLINE_LINE_BUFFER + and READLINE_POINT. The command can change the current readline line + and cursor position by modifying READLINE_LINE_BUFFER and READLINE_POINT, + respectively. + +cc. There is a new &>> redirection operator, which appends the standard output + and standard error to the named file. + +dd. The parser now understands `|&' as a synonym for `2>&1 |', which redirects + the standard error for a command through a pipe. + +ee. The new `;&' case statement action list terminator causes execution to + continue with the action associated with the next pattern in the + statement rather than terminating the command. + +ff. The new `;;&' case statement action list terminator causes the shell to + test the next set of patterns after completing execution of the current + action, rather than terminating the command. + +gg. The shell understands a new variable: PROMPT_DIRTRIM. When set to an + integer value greater than zero, prompt expansion of \w and \W will + retain only that number of trailing pathname components and replace + the intervening characters with `...'. + +hh. There are new case-modifying word expansions: uppercase (^[^]) and + lowercase (,[,]). They can work on either the first character or + array element, or globally. They accept an optional shell pattern + that determines which characters to modify. There is an optionally- + configured feature to include capitalization operators. + +ii. The shell provides associative array variables, with the appropriate + support to create, delete, assign values to, and expand them. + +jj. The `declare' builtin now has new -l (convert value to lowercase upon + assignment) and -u (convert value to uppercase upon assignment) options. + There is an optionally-configurable -c option to capitalize a value at + assignment. + +kk. There is a new `coproc' reserved word that specifies a coprocess: an + asynchronous command run with two pipes connected to the creating shell. + Coprocs can be named. The input and output file descriptors and the + PID of the coprocess are available to the calling shell in variables + with coproc-specific names. + +ll. A value of 0 for the -t option to `read' now returns success if there is + input available to be read from the specified file descriptor. + +mm. CDPATH and GLOBIGNORE are ignored when the shell is running in privileged + mode. + +nn. New bindable readline functions shell-forward-word and shell-backward-word, + which move forward and backward words delimited by shell metacharacters + and honor shell quoting. + +oo. New bindable readline functions shell-backward-kill-word and shell-kill-word + which kill words backward and forward, but use the same word boundaries + as shell-forward-word and shell-backward-word. + +2. New Features in Readline + +a. A new variable, rl_sort_completion_matches; allows applications to inhibit + match list sorting (but beware: some things don't work right if + applications do this). + +b. A new variable, rl_completion_invoking_key; allows applications to discover + the key that invoked rl_complete or rl_menu_complete. + +c. The functions rl_block_sigint and rl_release_sigint are now public and + available to calling applications who want to protect critical sections + (like redisplay). + +d. The functions rl_save_state and rl_restore_state are now public and + available to calling applications; documented rest of readline's state + flag values. + +e. A new user-settable variable, `history-size', allows setting the maximum + number of entries in the history list. + +f. There is a new implementation of menu completion, with several improvements + over the old; the most notable improvement is a better `completions + browsing' mode. + +g. The menu completion code now uses the rl_menu_completion_entry_function + variable, allowing applications to provide their own menu completion + generators. + +h. There is support for replacing a prefix of a pathname with a `...' when + displaying possible completions. This is controllable by setting the + `completion-prefix-display-length' variable. Matches with a common prefix + longer than this value have the common prefix replaced with `...'. + +i. There is a new `revert-all-at-newline' variable. If enabled, readline will + undo all outstanding changes to all history lines when `accept-line' is + executed. + +j. If the kernel supports it, readline displays special characters + corresponding to a keyboard-generated signal when the signal is received. + +------------------------------------------------------------------------------- +This is a terse description of the new features added to bash-3.2 since +the release of bash-3.1. As always, the manual page (doc/bash.1) is +the place to look for complete descriptions. + +1. New Features in Bash + +a. Changed the parameter pattern replacement functions to not anchor the + pattern at the beginning of the string if doing global replacement - that + combination doesn't make any sense. + +b. When running in `word expansion only' mode (--wordexp option), inhibit + process substitution. + +c. Loadable builtins now work on MacOS X 10.[34]. + +d. Shells running in posix mode no longer set $HOME, as POSIX requires. + +e. The code that checks for binary files being executed as shell scripts now + checks only for NUL rather than any non-printing character. + +f. Quoting the string argument to the [[ command's =~ operator now forces + string matching, as with the other pattern-matching operators. + +2. New Features in Readline + +a. Calling applications can now set the keyboard timeout to 0, allowing + poll-like behavior. + +b. The value of SYS_INPUTRC (configurable at compilation time) is now used as + the default last-ditch startup file. + +c. The history file reading functions now allow windows-like \r\n line + terminators. + +------------------------------------------------------------------------------- +This is a terse description of the new features added to bash-3.1 since +the release of bash-3.0. As always, the manual page (doc/bash.1) is +the place to look for complete descriptions. + +1. New Features in Bash + +a. Bash now understands LC_TIME as a special variable so that time display + tracks the current locale. + +b. BASH_ARGC, BASH_ARGV, BASH_SOURCE, and BASH_LINENO are no longer created + as `invisible' variables and may not be unset. + +c. In POSIX mode, if `xpg_echo' option is enabled, the `echo' builtin doesn't + try to interpret any options at all, as POSIX requires. + +d. The `bg' builtin now accepts multiple arguments, as POSIX seems to specify. + +e. Fixed vi-mode word completion and glob expansion to perform tilde + expansion. + +f. The `**' mathematic exponentiation operator is now right-associative. + +g. The `ulimit' builtin has new options: -i (max number of pending signals), + -q (max size of POSIX message queues), and -x (max number of file locks). + +h. A bare `%' once again expands to the current job when used as a job + specifier. + +i. The `+=' assignment operator (append to the value of a string or array) is + now supported for assignment statements and arguments to builtin commands + that accept assignment statements. + +j. BASH_COMMAND now preserves its value when a DEBUG trap is executed. + +k. The `gnu_errfmt' option is enabled automatically if the shell is running + in an emacs terminal window. + +l. New configuration option: --single-help-strings. Causes long help text + to be written as a single string; intended to ease translation. + +m. The COMP_WORDBREAKS variable now causes the list of word break characters + to be emptied when the variable is unset. + +n. An unquoted expansion of $* when $IFS is empty now causes the positional + parameters to be concatenated if the expansion doesn't undergo word + splitting. + +o. Bash now inherits $_ from the environment if it appears there at startup. + +p. New shell option: nocasematch. If non-zero, shell pattern matching ignores + case when used by `case' and `[[' commands. + +q. The `printf' builtin takes a new option: -v var. That causes the output + to be placed into var instead of on stdout. + +r. By default, the shell no longer reports processes dying from SIGPIPE. + +s. Bash now sets the extern variable `environ' to the export environment it + creates, so C library functions that call getenv() (and can't use the + shell-provided replacement) get current values of environment variables. + +t. A new configuration option, `--enable-strict-posix-default', which will + build bash to be POSIX conforming by default. + +u. If compiled for strict POSIX conformance, LINES and COLUMNS may now + override the true terminal size. + +2. New Features in Readline + +a. The key sequence sent by the keypad `delete' key is now automatically + bound to delete-char. + +b. A negative argument to menu-complete now cycles backward through the + completion list. + +c. A new bindable readline variable: bind-tty-special-chars. If non-zero, + readline will bind the terminal special characters to their readline + equivalents when it's called (on by default). + +d. New bindable command: vi-rubout. Saves deleted text for possible + reinsertion, as with any vi-mode `text modification' command; `X' is bound + to this in vi command mode. + +e. A new external application-controllable variable that allows the LINES + and COLUMNS environment variables to set the window size regardless of + what the kernel returns: rl_prefer_env_winsize + +------------------------------------------------------------------------------- +This is a terse description of the new features added to bash-3.0 since +the release of bash-2.05b. As always, the manual page (doc/bash.1) is +the place to look for complete descriptions. + +1. New Features in Bash + +a. ANSI string expansion now implements the \x{hexdigits} escape. + +b. There is a new loadable `strftime' builtin. + +c. New variable, COMP_WORDBREAKS, which controls the readline completer's + idea of word break characters. + +d. The `type' builtin no longer reports on aliases unless alias expansion + will actually be performed. + +e. HISTCONTROL is now a colon-separated list of values, which permits + more extensibility and backwards compatibility. + +f. HISTCONTROL may now include the `erasedups' option, which causes all lines + matching a line being added to be removed from the history list. + +g. `configure' has a new `--enable-multibyte' argument that permits multibyte + character support to be disabled even on systems that support it. + +h. New variables to support the bash debugger: BASH_ARGC, BASH_ARGV, + BASH_SOURCE, BASH_LINENO, BASH_SUBSHELL, BASH_EXECUTION_STRING, + BASH_COMMAND + +i. FUNCNAME has been changed to support the debugger: it's now an array + variable. + +j. for, case, select, arithmetic commands now keep line number information + for the debugger. + +k. There is a new `RETURN' trap executed when a function or sourced script + returns (not inherited child processes; inherited by command substitution + if function tracing is enabled and the debugger is active). + +l. New invocation option: --debugger. Enables debugging and turns on new + `extdebug' shell option. + +m. New `functrace' and `errtrace' options to `set -o' cause DEBUG and ERR + traps, respectively, to be inherited by shell functions. Equivalent to + `set -T' and `set -E' respectively. The `functrace' option also controls + whether or not the DEBUG trap is inherited by sourced scripts. + +n. The DEBUG trap is run before binding the variable and running the action + list in a `for' command, binding the selection variable and running the + query in a `select' command, and before attempting a match in a `case' + command. + +o. New `--enable-debugger' option to `configure' to compile in the debugger + support code. + +p. `declare -F' now prints out extra line number and source file information + if the `extdebug' option is set. + +q. If `extdebug' is enabled, a non-zero return value from a DEBUG trap causes + the next command to be skipped, and a return value of 2 while in a + function or sourced script forces a `return'. + +r. New `caller' builtin to provide a call stack for the bash debugger. + +s. The DEBUG trap is run just before the first command in a function body is + executed, for the debugger. + +t. `for', `select', and `case' command heads are printed when `set -x' is + enabled. + +u. There is a new {x..y} brace expansion, which is shorthand for {x.x+1, + x+2,...,y}. x and y can be integers or single characters; the sequence + may ascend or descend; the increment is always 1. + +v. New ksh93-like ${!array[@]} expansion, expands to all the keys (indices) + of array. + +w. New `force_fignore' shopt option; if enabled, suffixes specified by + FIGNORE cause words to be ignored when performing word completion even + if they're the only possibilities. + +x. New `gnu_errfmt' shopt option; if enabled, error messages follow the `gnu + style' (filename:lineno:message) format. + +y. New `-o bashdefault' option to complete and compgen; if set, causes the + whole set of bash completions to be performed if the compspec doesn't + result in a match. + +z. New `-o plusdirs' option to complete and compgen; if set, causes directory + name completion to be performed and the results added to the rest of the + possible completions. + +aa. `kill' is available as a builtin even when the shell is built without + job control. + +bb. New HISTTIMEFORMAT variable; value is a format string to pass to + strftime(3). If set and not null, the `history' builtin prints out + timestamp information according to the specified format when displaying + history entries. If set, bash tells the history library to write out + timestamp information when the history file is written. + +cc. The [[ ... ]] command has a new binary `=~' operator that performs + extended regular expression (egrep-like) matching. + +dd. `configure' has a new `--enable-cond-regexp' option (enabled by default) + to enable the =~ operator and regexp matching in [[ ... ]]. + +ee. Subexpressions matched by the =~ operator are placed in the new + BASH_REMATCH array variable. + +ff. New `failglob' option that causes an expansion error when pathname + expansion fails to produce a match. + +gg. New `set -o pipefail' option that causes a pipeline to return a failure + status if any of the processes in the pipeline fail, not just the last + one. + +hh. printf builtin understands two new escape sequences: \" and \?. + +ii. `echo -e' understands two new escape sequences: \" and \?. + +jj. The GNU `gettext' package and libintl have been integrated; the shell's + messages can be translated into different languages. + +kk. The `\W' prompt expansion now abbreviates $HOME as `~', like `\w'. + +ll. The error message printed when bash cannot open a shell script supplied + as argument 1 now includes the name of the shell, to better identify + the error as coming from bash. + +mm. The parameter pattern removal and substitution expansions are now much + faster and more efficient when using multibyte characters. + +nn. The `jobs', `kill', and `wait' builtins now accept job control notation + even if job control is not enabled. + +oo. The historical behavior of `trap' that allows a missing `action' argument + to cause each specified signal's handling to be reset to its default is + now only supported when `trap' is given a single non-option argument. + +2. New Features in Readline + +a. History expansion has a new `a' modifier equivalent to the `g' modifier + for compatibility with the BSD csh. + +b. History expansion has a new `G' modifier equivalent to the BSD csh `g' + modifier, which performs a substitution once per word. + +c. All non-incremental search operations may now undo the operation of + replacing the current line with the history line. + +d. The text inserted by an `a' command in vi mode can be reinserted with + `.'. + +e. New bindable variable, `show-all-if-unmodified'. If set, the readline + completer will list possible completions immediately if there is more + than one completion and partial completion cannot be performed. + +f. There is a new application-callable `free_history_entry()' function. + +g. History list entries now contain timestamp information; the history file + functions know how to read and write timestamp information associated + with each entry. + +h. Four new key binding functions have been added: + + rl_bind_key_if_unbound() + rl_bind_key_if_unbound_in_map() + rl_bind_keyseq_if_unbound() + rl_bind_keyseq_if_unbound_in_map() + +i. New application variable, rl_completion_quote_character, set to any + quote character readline finds before it calls the application completion + function. + +j. New application variable, rl_completion_suppress_quote, settable by an + application completion function. If set to non-zero, readline does not + attempt to append a closing quote to a completed word. + +k. New application variable, rl_completion_found_quote, set to a non-zero + value if readline determines that the word to be completed is quoted. + Set before readline calls any application completion function. + +l. New function hook, rl_completion_word_break_hook, called when readline + needs to break a line into words when completion is attempted. Allows + the word break characters to vary based on position in the line. + +m. New bindable command: unix-filename-rubout. Does the same thing as + unix-word-rubout, but adds `/' to the set of word delimiters. + +n. When listing completions, directories have a `/' appended if the + `mark-directories' option has been enabled. + +------------------------------------------------------------------------------- +This is a terse description of the new features added to bash-2.05b since +the release of bash-2.05a. As always, the manual page (doc/bash.1) is +the place to look for complete descriptions. + +1. New Features in Bash + +a. If set, TMOUT is the default timeout for the `read' builtin. + +b. `type' has two new options: `-f' suppresses shell function lookup, and + `-P' forces a $PATH search. + +c. New code to handle multibyte characters. + +d. `select' was changed to be more ksh-compatible, in that the menu is + reprinted each time through the loop only if REPLY is set to NULL. + The previous behavior is available as a compile-time option. + +e. `complete -d' and `complete -o dirnames' now force a slash to be + appended to names which are symlinks to directories. + +f. There is now a bindable edit-and-execute-command readline command, + like the vi-mode `v' command, bound to C-xC-e in emacs mode. + +g. Added support for ksh93-like [:word:] character class in pattern matching. + +h. The $'...' quoting construct now expands \cX to Control-X. + +i. A new \D{...} prompt expansion; passes the `...' to strftime and inserts + the result into the expanded prompt. + +j. The shell now performs arithmetic in the largest integer size the + machine supports (intmax_t), instead of long. + +k. If a numeric argument is supplied to one of the bash globbing completion + functions, a `*' is appended to the word before expansion is attempted. + +l. The bash globbing completion functions now allow completions to be listed + with double tabs or if `show-all-if-ambiguous' is set. + +m. New `-o nospace' option for `complete' and `compgen' builtins; suppresses + readline's appending a space to the completed word. + +n. New `here-string' redirection operator: <<< word. + +o. When displaying variables, function attributes and definitions are shown + separately, allowing them to be re-used as input (attempting to re-use + the old output would result in syntax errors). + +p. There is a new configuration option `--enable-mem-scramble', controls + bash malloc behavior of writing garbage characters into memory at + allocation and free time. + +q. The `complete' and `compgen' builtins now have a new `-s/-A service' + option to complete on names from /etc/services. + +r. `read' has a new `-u fd' option to read from a specified file descriptor. + +s. Fix the completion code so that expansion errors in a directory name + don't cause a longjmp back to the command loop. + +t. Fixed word completion inside command substitution to work a little more + intuitively. + +u. The `printf' %q format specifier now uses $'...' quoting to print the + argument if it contains non-printing characters. + +v. The `declare' and `typeset' builtins have a new `-t' option. When applied + to functions, it causes the DEBUG trap to be inherited by the named + function. Currently has no effect on variables. + +w. The DEBUG trap is now run *before* simple commands, ((...)) commands, + [[...]] conditional commands, and for ((...)) loops. + +x. The expansion of $LINENO inside a shell function is only relative to the + function start if the shell is interactive -- if the shell is running a + script, $LINENO expands to the line number in the script. This is as + POSIX-2001 requires. + +y. The bash debugger in examples/bashdb has been modified to work with the + new DEBUG trap semantics, the command set has been made more gdb-like, + and the changes to $LINENO make debugging functions work better. Code + from Gary Vaughan. + +z. New [n]<&word- and [n]>&word- redirections from ksh93 -- move fds (dup + and close). + +aa. There is a new `-l' invocation option, equivalent to `--login'. + +bb. The `hash' builtin has a new `-l' option to list contents in a reusable + format, and a `-d' option to remove a name from the hash table. + +cc. There is now support for placing the long help text into separate files + installed into ${datadir}/bash. Not enabled by default; can be turned + on with `--enable-separate-helpfiles' option to configure. + +dd. All builtins that take operands accept a `--' pseudo-option, except + `echo'. + +ee. The `echo' builtin now accepts \0xxx (zero to three octal digits following + the `0') in addition to \xxx (one to three octal digits) for SUSv3/XPG6/ + POSIX.1-2001 compliance. + + +2. New Features in Readline + +a. Support for key `subsequences': allows, e.g., ESC and ESC-a to both + be bound to readline functions. Now the arrow keys may be used in vi + insert mode. + +b. When listing completions, and the number of lines displayed is more than + the screen length, readline uses an internal pager to display the results. + This is controlled by the `page-completions' variable (default on). + +c. New code to handle editing and displaying multibyte characters. + +d. The behavior introduced in bash-2.05a of deciding whether or not to + append a slash to a completed name that is a symlink to a directory has + been made optional, controlled by the `mark-symlinked-directories' + variable (default is the 2.05a behavior). + +e. The `insert-comment' command now acts as a toggle if given a numeric + argument: if the first characters on the line don't specify a + comment, insert one; if they do, delete the comment text + +f. New application-settable completion variable: + rl_completion_mark_symlink_dirs, allows an application's completion + function to temporarily override the user's preference for appending + slashes to names which are symlinks to directories. + +g. New function available to application completion functions: + rl_completion_mode, to tell how the completion function was invoked + and decide which argument to supply to rl_complete_internal (to list + completions, etc.). + +h. Readline now has an overwrite mode, toggled by the `overwrite-mode' + bindable command, which could be bound to `Insert'. + +i. New application-settable completion variable: + rl_completion_suppress_append, inhibits appending of + rl_completion_append_character to completed words. + +j. New key bindings when reading an incremental search string: ^W yanks + the currently-matched word out of the current line into the search + string; ^Y yanks the rest of the current line into the search string, + DEL or ^H deletes characters from the search string. + +------------------------------------------------------------------------------- +This is a terse description of the new features added to bash-2.05a since +the release of bash-2.05. As always, the manual page (doc/bash.1) is +the place to look for complete descriptions. + +1. New Features in Bash + +a. Added support for DESTDIR installation root prefix, so you can do a + `make install DESTDIR=bash-root' and do easier binary packaging. + +b. Added support for builtin printf "'" flag character as per latest POSIX + drafts. + +c. Support for POSIX.2 printf(1) length specifiers `j', `t', and `z' (from + ISO C99). + +d. New autoconf macro, RL_LIB_READLINE_VERSION, for use by other applications + (bash doesn't use very much of what it returns). + +e. `set [-+]o nolog' is recognized as required by the latest POSIX drafts, + but ignored. + +f. New read-only `shopt' option: login_shell. Set to non-zero value if the + shell is a login shell. + +g. New `\A' prompt string escape sequence; expands to time in 24 HH:MM format. + +h. New `-A group/-g' option to complete and compgen; does group name + completion. + +i. New `-t' option to `hash' to list hash values for each filename argument. + +j. New [-+]O invocation option to set and unset `shopt' options at startup. + +k. configure's `--with-installed-readline' option now takes an optional + `=PATH' suffix to set the root of the tree where readline is installed + to PATH. + +l. The ksh-like `ERR' trap has been added. The `ERR' trap will be run + whenever the shell would have exited if the -e option were enabled. + It is not inherited by shell functions. + +m. `readonly', `export', and `declare' now print variables which have been + given attributes but not set by assigning a value as just a command and + a variable name (like `export foo') when listing, as the latest POSIX + drafts require. + +n. `bashbug' now requires that the subject be changed from the default. + +o. configure has a new `--enable-largefile' option, like other GNU utilities. + +p. `for' loops now allow empty word lists after `in', like the latest POSIX + drafts require. + +q. The builtin `ulimit' now takes two new non-numeric arguments: `hard', + meaning the current hard limit, and `soft', meaning the current soft + limit, in addition to `unlimited' + +r. `ulimit' now prints the option letter associated with a particular + resource when printing more than one limit. + +s. `ulimit' prints `hard' or `soft' when a value is not `unlimited' but is + one of RLIM_SAVED_MAX or RLIM_SAVED_CUR, respectively. + +t. The `printf' builtin now handles the %a and %A conversions if they're + implemented by printf(3). + +u. The `printf' builtin now handles the %F conversion (just about like %f). + +v. The `printf' builtin now handles the %n conversion like printf(3). The + corresponding argument is the name of a shell variable to which the + value is assigned. + +2. New Features in Readline + +a. Added extern declaration for rl_get_termcap to readline.h, making it a + public function (it was always there, just not in readline.h). + +b. New #defines in readline.h: RL_READLINE_VERSION, currently 0x0402, + RL_VERSION_MAJOR, currently 4, and RL_VERSION_MINOR, currently 2. + +c. New readline variable: rl_readline_version, mirrors RL_READLINE_VERSION. + +d. New bindable boolean readline variable: match-hidden-files. Controls + completion of files beginning with a `.' (on Unix). Enabled by default. + +e. The history expansion code now allows any character to terminate a + `:first-' modifier, like csh. + +f. New bindable variable `history-preserve-point'. If set, the history + code attempts to place the user at the same location on each history + line retrived with previous-history or next-history. + +------------------------------------------------------------------------------- +This is a terse description of the new features added to bash-2.05 since +the release of bash-2.04. As always, the manual page (doc/bash.1) is +the place to look for complete descriptions. + +1. New Features in Bash + +a. Added a new `--init-file' invocation argument as a synonym for `--rcfile', + per the new GNU coding standards. + +b. The /dev/tcp and /dev/udp redirections now accept service names as well as + port numbers. + +c. `complete' and `compgen' now take a `-o value' option, which controls some + of the aspects of that compspec. Valid values are: + + default - perform bash default completion if programmable + completion produces no matches + dirnames - perform directory name completion if programmable + completion produces no matches + filenames - tell readline that the compspec produces filenames, + so it can do things like append slashes to + directory names and suppress trailing spaces + +d. A new loadable builtin, realpath, which canonicalizes and expands symlinks + in pathname arguments. + +e. When `set' is called without options, it prints function defintions in a + way that allows them to be reused as input. This affects `declare' and + `declare -p' as well. This only happens when the shell is not in POSIX + mode, since POSIX.2 forbids this behavior. + +f. Bash-2.05 once again honors the current locale setting when processing + ranges within pattern matching bracket expressions (e.g., [A-Z]). + +2. New Features in Readline + +a. The blink timeout for paren matching is now settable by applications, + via the rl_set_paren_blink_timeout() function. + +b. _rl_executing_macro has been renamed to rl_executing_macro, which means + it's now part of the public interface. + +c. Readline has a new variable, rl_readline_state, which is a bitmap that + encapsulates the current state of the library; intended for use by + callbacks and hook functions. + +d. New application-callable function rl_set_prompt(const char *prompt): + expands its prompt string argument and sets rl_prompt to the result. + +e. New application-callable function rl_set_screen_size(int rows, int cols): + public method for applications to set readline's idea of the screen + dimensions. + +f. New function, rl_get_screen_size (int *rows, int *columns), returns + readline's idea of the screen dimensions. + +g. The timeout in rl_gather_tyi (readline keyboard input polling function) + is now settable via a function (rl_set_keyboard_input_timeout()). + +h. Renamed the max_input_history variable to history_max_entries; the old + variable is maintained for backwards compatibility. + +i. The list of characters that separate words for the history tokenizer is + now settable with a variable: history_word_delimiters. The default + value is as before. + +------------------------------------------------------------------------------- +This is a terse description of the new features added to bash-2.04 since +the release of bash-2.03. As always, the manual page (doc/bash.1) is +the place to look for complete descriptions. + +1. New Features in Bash + +a. The history builtin has a `-d offset' option to delete the history entry + at position `offset'. + +b. The prompt expansion code has two new escape sequences: \j, the number of + active jobs; and \l, the basename of the shell's tty device name. + +c. The `bind' builtin has a new `-x' option to bind key sequences to shell + commands. + +d. There is a new shell option, no_empty_command_completion, which, when + enabled, disables command completion when TAB is typed on an empty line. + +e. The `help' builtin has a `-s' option to just print a builtin's usage + synopsis. + +f. There are several new arithmetic operators: id++, id-- (variable + post-increment/decrement), ++id, --id (variable pre-increment/decrement), + expr1 , expr2 (comma operator). + +g. There is a new ksh-93 style arithmetic for command: + for ((expr1 ; expr2; expr3 )); do list; done + +h. The `read' builtin has a number of new options: + -t timeout only wait timeout seconds for input + -n nchars only read nchars from input instead of a full line + -d delim read until delim rather than newline + -s don't echo input chars as they are read + +i. The redirection code now handles several filenames specially: + /dev/fd/N, /dev/stdin, /dev/stdout, and /dev/stderr, whether or + not they are present in the file system. + +j. The redirection code now recognizes pathnames of the form + /dev/tcp/host/port and /dev/udp/host/port, and tries to open a socket + of the appropriate type to the specified port on the specified host. + +k. The ksh-93 ${!prefix*} expansion, which expands to the names of all + shell variables with prefix PREFIX, has been implemented. + +l. There is a new dynamic variable, FUNCNAME, which expands to the name of + a currently-executing function. Assignments to FUNCNAME have no effect. + +m. The GROUPS variable is no longer readonly; assignments to it are silently + discarded. This means it can be unset. + +n. A new programmable completion facility, with two new builtin commands: + complete and compgen. + +o. configure has a new option, `--enable-progcomp', to compile in the + programmable completion features (enabled by default). + +p. `shopt' has a new option, `progcomp', to enable and disable programmable + completion at runtime. + +q. Unsetting HOSTFILE now clears the list of hostnames used for completion. + +r. configure has a new option, `--enable-bash-malloc', replacing the old + `--with-gnu-malloc' (which is still present for backwards compatibility). + +s. There is a new manual page describing rbash, the restricted shell. + +t. `bashbug' has new `--help' and `--version' options. + +u. `shopt' has a new `xpg_echo' option, which controls the behavior of + `echo' with respect to backslash-escaped characters at runtime. + +v. If NON_INTERACTIVE_LOGIN_SHELLS is defined, all login shells read the + startup files, even if they are not interactive. + +w. The LC_NUMERIC variable is now treated specially, and used to set the + LC_NUMERIC locale category for number formatting, e.g., when `printf' + displays floating-point numbers. + +2. New features in Readline + +a. Parentheses matching is now always compiled into readline, and enabled + or disabled when the value of the `blink-matching-paren' variable is + changed. + +b. MS-DOS systems now use ~/_inputrc as the last-ditch inputrc filename. + +c. MS-DOS systems now use ~/_history as the default history file. + +d. history-search-{forward,backward} now leave the point at the end of the + line when the string to search for is empty, like + {reverse,forward}-search-history. + +e. history-search-{forward,backward} now leave the last history line found + in the readline buffer if the second or subsequent search fails. + +f. New function for use by applications: rl_on_new_line_with_prompt, used + when an application displays the prompt itself before calling readline(). + +g. New variable for use by applications: rl_already_prompted. An application + that displays the prompt itself before calling readline() must set this to + a non-zero value. + +h. A new variable, rl_gnu_readline_p, always 1. The intent is that an + application can verify whether or not it is linked with the `real' + readline library or some substitute. + +------------------------------------------------------------------------------- +This is a terse description of the new features added to bash-2.03 since +the release of bash-2.02. As always, the manual page (doc/bash.1) is +the place to look for complete descriptions. + +1. New Features in Bash + +a. New `shopt' option, `restricted_shell', indicating whether or not the + shell was started in restricted mode, for use in startup files. + +b. Filename generation is now performed on the words between ( and ) in + array assignments (which it probably should have done all along). + +c. OLDPWD is now auto-exported, as POSIX.2 seems to require. + +d. ENV and BASH_ENV are read-only variables in a restricted shell. + +e. A change was made to the startup file code so that any shell begun with + the `--login' option, even non-interactive shells, will source the login + shell startup files. + +2. New Features in Readline + +a. Many changes to the signal handling: + o Readline now catches SIGQUIT and cleans up the tty before returning; + o A new variable, rl_catch_signals, is available to application writers + to indicate to readline whether or not it should install its own + signal handlers for SIGINT, SIGTERM, SIGQUIT, SIGALRM, SIGTSTP, + SIGTTIN, and SIGTTOU; + o A new variable, rl_catch_sigwinch, is available to application + writers to indicate to readline whether or not it should install its + own signal handler for SIGWINCH, which will chain to the calling + applications's SIGWINCH handler, if one is installed; + o There is a new function, rl_free_line_state, for application signal + handlers to call to free up the state associated with the current + line after receiving a signal; + o There is a new function, rl_cleanup_after_signal, to clean up the + display and terminal state after receiving a signal; + o There is a new function, rl_reset_after_signal, to reinitialize the + terminal and display state after an application signal handler + returns and readline continues + +b. There is a new function, rl_resize_terminal, to reset readline's idea of + the screen size after a SIGWINCH. + +c. New public functions: rl_save_prompt and rl_restore_prompt. These were + previously private functions with a `_' prefix. + +d. New function hook: rl_pre_input_hook, called just before readline starts + reading input, after initialization. + +e. New function hook: rl_display_matches_hook, called when readline would + display the list of completion matches. The new function + rl_display_match_list is what readline uses internally, and is available + for use by application functions called via this hook. + +f. New bindable function, delete-char-or-list, like tcsh. + +g. A new variable, rl_erase_empty_line, which, if set by an application using + readline, will cause readline to erase, prompt and all, lines on which the + only thing typed was a newline. + +h. New bindable variable: `isearch-terminators'. + +i. New bindable function: `forward-backward-delete-char' (unbound by default). + +------------------------------------------------------------------------------- +This is a terse description of the new features added to bash-2.02 since +the release of bash-2.01.1. As always, the manual page (doc/bash.1) is +the place to look for complete descriptions. + +1. New Features in Bash + +a. A new version of malloc, based on the older GNU malloc, that has many + changes, is more page-based, is more conservative with memory usage, + and does not `orphan' large blocks when they are freed. + +b. A new version of gmalloc, based on the old GLIBC malloc, with many + changes and range checking included by default. + +c. A new implementation of fnmatch(3) that includes full POSIX.2 Basic + Regular Expression matching, including character classes, collating + symbols, equivalence classes, and support for case-insensitive pattern + matching. + +d. ksh-88 egrep-style extended pattern matching ([@+*?!](patlist)) has been + implemented, controlled by a new `shopt' option, `extglob'. + +e. There is a new ksh-like `[[' compound command, which implements + extended `test' functionality. + +f. There is a new `printf' builtin, implemented according to the POSIX.2 + specification. + +g. There is a new feature for command substitution: $(< filename) now expands + to the contents of `filename', with any trailing newlines removed + (equivalent to $(cat filename)). + +h. There are new tilde prefixes which expand to directories from the + directory stack. + +i. There is a new `**' arithmetic operator to do exponentiation. + +j. There are new configuration options to control how bash is linked: + `--enable-profiling', to allow bash to be profiled with gprof, and + `--enable-static-link', to allow bash to be linked statically. + +k. There is a new configuration option, `--enable-cond-command', which + controls whether or not the `[[' command is included. It is on by + default. + +l. There is a new configuration option, `--enable-extended-glob', which + controls whether or not the ksh extended globbing feature is included. + It is enabled by default. + +m. There is a new configuration #define in config.h.top that, when enabled, + will cause all login shells to source /etc/profile and one of the user- + specific login shell startup files, whether or not the shell is + interactive. + +n. There is a new invocation option, `--dump-po-strings', to dump + a shell script's translatable strings ($"...") in GNU `po' format. + +o. There is a new `shopt' option, `nocaseglob', to enable case-insensitive + pattern matching when globbing filenames and using the `case' construct. + +p. There is a new `shopt' option, `huponexit', which, when enabled, causes + the shell to send SIGHUP to all jobs when an interactive login shell + exits. + +q. `bind' has a new `-u' option, which takes a readline function name as an + argument and unbinds all key sequences bound to that function in a + specified keymap. + +r. `disown' now has `-a' and `-r' options, to limit operation to all jobs + and running jobs, respectively. + +s. The `shopt' `-p' option now causes output to be displayed in a reusable + format. + +t. `test' has a new `-N' option, which returns true if the filename argument + has been modified since it was last accessed. + +u. `umask' now has a `-p' option to print output in a reusable format. + +v. A new escape sequence, `\xNNN', has been added to the `echo -e' and $'...' + translation code. It expands to the character whose ascii code is NNN + in hexadecimal. + +w. The prompt string expansion code has a new `\r' escape sequence. + +x. The shell may now be cross-compiled for the CYGWIN32 environment on + a Unix machine. + +2. New Features in Readline + +a. There is now an option for `iterative' yank-last-arg handline, so a user + can keep entering `M-.', yanking the last argument of successive history + lines. + +b. New variable, `print-completions-horizontally', which causes completion + matches to be displayed across the screen (like `ls -x') rather than up + and down the screen (like `ls'). + +c. New variable, `completion-ignore-case', which causes filename completion + and matching to be performed case-insensitively. + +d. There is a new bindable command, `magic-space', which causes history + expansion to be performed on the current readline buffer and a space to + be inserted into the result. + +e. There is a new bindable command, `menu-complete', which enables tcsh-like + menu completion (successive executions of menu-complete insert a single + completion match, cycling through the list of possible completions). + +f. There is a new bindable command, `paste-from-clipboard', for use on Win32 + systems, to insert the text from the Win32 clipboard into the editing + buffer. + +g. The key sequence translation code now understands printf-style backslash + escape sequences, including \NNN octal escapes. These escape sequences + may be used in key sequence definitions or macro values. + +h. An `$include' inputrc file parser directive has been added. + +------------------------------------------------------------------------------- +This is a terse description of the new features added to bash-2.01 since +the release of bash-2.0. As always, the manual page (doc/bash.1) is the +place to look for complete descriptions. + +1. New Features in Bash + +a. There is a new builtin array variable: GROUPS, the set of groups to which + the user belongs. This is used by the test suite. + +2. New Features in Readline + +a. If a key sequence bound to `universal-argument' is read while reading a + numeric argument started with `universal-argument', it terminates the + argument but is otherwise ignored. This provides a way to insert multiple + instances of a digit string, and is how GNU emacs does it. + +------------------------------------------------------------------------------- +This is a terse description of the new features added to bash-2.0 since +the release of bash-1.14.7. As always, the manual page (doc/bash.1) is +the place to look for complete descriptions. + +1. New Features in Bash + +a. There is a new invocation option, -D, that dumps translatable strings + in a script. + +b. The `long' invocation options must now be prefixed with `--'. + +c. New long invocation options: --dump-strings, --help, --verbose + +d. The `nolineediting' invocation option was renamed to `noediting'. + +e. The `nobraceexpansion' and `quiet' long invocation options were removed. + +f. The `--help' and `--version' long options now work as the GNU coding + standards specify. + +g. If invoked as `sh', bash now enters posix mode after reading the + startup files, and reads and executes commands from the file named + by $ENV if interactive (as POSIX.2 specifies). A login shell invoked + as `sh' reads $ENV after /etc/profile and ~/.profile. + +h. There is a new reserved word, `time', for timing pipelines, builtin + commands, and shell functions. It uses the value of the TIMEFORMAT + variable as a format string describing how to print the timing + statistics. + +i. The $'...' quoting syntax expands ANSI-C escapes in ... and leaves the + result single-quoted. + +j. The $"..." quoting syntax performs locale-specific translation of ... + and leaves the result double-quoted. + +k. LINENO now works correctly in functions. + +l. New variables: DIRSTACK, PIPESTATUS, BASH_VERSINFO, HOSTNAME, SHELLOPTS, + MACHTYPE. The first three are array variables. + +m. The BASH_VERSION and BASH_VERSINFO variables now include the shell's + `release status' (alpha[N], beta[N], release). + +n. Some variables have been removed: MAIL_WARNING, notify, history_control, + command_oriented_history, glob_dot_filenames, allow_null_glob_expansion, + nolinks, hostname_completion_file, noclobber, no_exit_on_failed_exec, and + cdable_vars. Most of them are now implemented with the new `shopt' + builtin; others were already implemented by `set'. + +o. Bash now uses some new variables: LC_ALL, LC_MESSAGES, LC_CTYPE, + LC_COLLATE, LANG, GLOBIGNORE, HISTIGNORE. + +p. The shell now supports integer-indexed arrays of unlimited length, + with a new compound assignment syntax and changes to the appropriate + builtin commands (declare/typeset, read, readonly, etc.). The array + index may be an arithmetic expression. + +q. ${!var}: indirect variable expansion, equivalent to eval \${$var}. + +r. ${paramter:offset[:length]}: variable substring extraction. + +s. ${parameter/pattern[/[/]string]}: variable pattern substitution. + +t. The $[...] arithmetic expansion syntax is no longer supported, in + favor of $((...)). + +u. Aliases can now be expanded in shell scripts with a shell option + (shopt expand_aliases). + +v. History and history expansion can now be used in scripts with + set -o history and set -H. + +w. All builtins now return an exit status of 2 for incorrect usage. + +x. Interactive shells resend SIGHUP to all running or stopped children + if (and only if) they exit due to a SIGHUP. + +y. New prompting expansions: \a, \e, \H, \T, \@, \v, \V. + +z. Variable expansion in prompt strings is now controllable via a shell + option (shopt promptvars). + +aa. Bash now defaults to using command-oriented history. + +bb. The history file ($HISTFILE) is now truncated to $HISTFILESIZE after + being written. + +cc. The POSIX.2 conditional arithmetic evaluation syntax (expr ? expr : expr) + has been implemented. + +dd. Each builtin now accepts `--' to signify the end of the options, except + as documented (echo, etc.). + +ee. All builtins use -p to display values in a re-readable format where + appropriate, except as documented (echo, type, etc.). + +ff. The `alias' builtin has a new -p option. + +gg. Changes to the `bind' builtin: + o has new options: -psPSVr. + o the `-d' option was renamed to `-p' + o the `-v' option now dumps variables; the old `-v' is now `-P' + +hh. The `bye' synonym for `exit' was removed. + +ii. The -L and -P options to `cd' and `pwd' have been documented. + +jj. The `cd' builtin now does spelling correction on the directory name + by default. This is settable with a shell option (shopt cdspell). + +kk. The `declare' builtin has new options: -a, -F, -p. + +ll. The `dirs' builtin has new options: -c, -p, -v. + +mm. The new `disown' builtin removes jobs from the shell's jobs table + or inhibits the resending of SIGHUP when the shell receives a + SIGHUP. + +nn. The `echo' builtin has a new escape character: \e. + +oo. The `enable' builtin can now load new builtins dynamically from shared + objects on systems with the dlopen/dlsym interface. There are a number + of examples in the examples/loadables directory. There are also + new options: -d, -f, -s, -p. + +pp. The `-all' option to `enable' was removed in favor of `-a'. + +qq. The `exec' builtin has new options: -l, -c, -a. + +rr. The `hash' builtin has a new option: -p. + +ss. The `history' builtin has new options: -c, -p, -s. + +tt. The `jobs' builtin has new options: -r, -s. + +uu. The `kill' builtin has new options: -n signum, -l signame. + +vv. The `pushd' and `popd' builtins have a new option: -n. + +ww. The `read' builtin has new options: -p prompt, -e, -a. + +xx. The `readonly' builtin has a new -a option, and the -n option was removed. + +yy. Changes to the `set' builtin: + o new options: -B, -o keyword, -o onecmd, -o history + o options removed: -l, -d, -o nohash + o options changed: +o, -h, -o hashall + o now displays variables in a format that can be re-read as input + +zz. The new `shopt' builtin controls shell optional behavior previously + done by setting and unsetting certain shell variables. + +aaa. The `test' builtin has new operators: -o option, s1 == s2, s1 < s2, + and s1 > s2, where s1 and s2 are strings. + +bbb. There is a new trap, DEBUG, executed after every simple command. + +ccc. The `trap' builtin has a new -p option. + +ddd. The `ulimit' builtin has a new -l option on 4.4BSD-based systems. + +eee. The PS1, PS2, PATH, and IFS variables may now be unset. + +fff. The restricted shell mode has been expanded and is now documented. + +ggg. Security improvements: + o functions are not imported from the environment if running setuid + or with -p + o no startup files are sourced if running setuid or with -p + +hhh. The documentation has been overhauled: the texinfo manual was + expanded, and HTML versions of the man page and texinfo manual + are included. + +iii. Changes to Posix mode: + o Command lookup now finds special builtins before shell functions. + o Failure of a special builtin causes a non-interactive shell to + exit. Failures are defined in the POSIX.2 specification. + o If the `cd' builtin finds a directory to change to using $CDPATH, + the value assigned to PWD when `cd' completes does not contain + any symbolic links. + o A non-interactive shell exits if a variable assignment error + occurs when no command name follows the assignment statements. + o A non-interactive shell exits if the interation variable in a + `for' statement or the selection variable in a `select' statement + is read-only or another variable assignment error occurs. + o The `<>' redirection operator now opens a file for both stdin and + stdout by default, not just when in posix mode. + o Assignment statements preceding special builtins now persist in + the shell's environment when the builtin completes. + + Posix mode is now completely POSIX.2-compliant (modulo bugs). When + invoked as sh, bash should be completely POSIX.2-compliant. + +jjj. The default value of PS1 is now "\s-\v\$ ". + +kkk. The ksh-like ((...)) arithmetic command syntax has been implemented. + This is exactly equivalent to `let "..."'. + +lll. Integer constants have been extended to base 64. + +mmm. The `ulimit' builtin now sets both hard and soft limits and reports the + soft limit by default. + +2. New Features in Readline + +a. New variables: enable-keypad, input-meta (new name for meta-flag), + mark-directories, visible-stats (now documented), disable-completion, + comment-begin. + +b. New bindable commands: kill-region, copy-region-as-kill, + copy-backward-word, copy-forward-word, set-mark, exchange-point-and-mark, + character-search, character-search-backward, insert-comment, + glob-expand-word, glob-list-expansions, dump-variables, dump-macros. + +c. New emacs keybindings: delete-horizontal-space (M-\), + insert-completions (M-*), possible-completions (M-=). + +d. The history-search-backward and history-search-forward commands were + modified to be the same as previous-line and next-line if point is at + the start of the line. + +e. More file types are available for the visible-stats mode. + +3. Changes of interest in the Bash implementation + +a. There is a new autoconf-based configuration mechanism. + +b. More things have been moved from Posix mode to standard shell behavior. + +c. The trace output (set -x) now inserts quotes where necessary so it can + be reused as input. + +d. There is a compile-time option for a system-wide interactive shell + startup file (disabled by default). + +e. The YACC grammar is smaller and tighter, and all 66 shift-reduce + conflicts are gone. Several parsing bugs have been fixed. + +f. Builtin option parsing has been regularized (using internal_getopt()), + with the exception of `echo', `type', and `set'. + +g. Builtins now return standard usage messages constructed from the + `short doc' used by the help builtin. + +h. Completion now quotes using backslashes by default, but honors + user-supplied quotes. + +i. The GNU libc malloc is available as a configure-time option. + +j. There are more internationalization features; bash uses gettext if + it is available. The $"..." translation syntax uses the current + locale and gettext. + +k. There is better reporting of job termination when the shell is not + interactive. + +l. The shell is somewhat more efficient: it uses a little less memory and + makes fewer system calls. + +4. Changes of interest in the Readline implementation + +a. There is now support for readline `callback' functions. + +b. There is now support for user-supplied input, redisplay, and terminal + preparation functions. + +c. Most of the shell-specific code in readline has been generalized or + removed. + +d. Most of the annoying redisplay bugs have been fixed, notably the problems + with incremental search and excessive redrawing when special characters + appear in the prompt string. + +e. There are new library functions and variables available to application + writers, most having to do with completion and quoting. + +f. The NEWLINE character (^J) is now treated as a search terminator by the + incremental search functions. +------------------------------------------------------------------------------- + +Copying and distribution of this file, with or without modification, +are permitted in any medium without royalty provided the copyright +notice and this notice are preserved. This file is offered as-is, +without any warranty. diff --git a/NOTES b/NOTES new file mode 100644 index 0000000..414e773 --- /dev/null +++ b/NOTES @@ -0,0 +1,352 @@ +Platform-Specific Configuration and Operation Notes [somewhat dated] +==================================================================== + +1. configure --without-gnu-malloc on: + + alpha running OSF/1, Linux, or NetBSD (malloc needs 8-byte alignment; + bash malloc has 8-byte alignment now, but I have no alphas to test on) + + next running NeXT/OS; machines running Openstep + + all machines running SunOS YP code: SunOS4, SunOS5, HP/UX, if you + have problems with username completion or tilde expansion for + usernames found via YP/NIS + + linux (optional, but don't do it if you're using Doug Lea's malloc) + + QNX 4.2 + other OSF/1 machines (KSR/1, HP, IBM AIX/ESA) + AIX + sparc SVR4, SVR4.2 (ICL reference port) + DG/UX + Cray + Haiku OS + + NetBSD/sparc (malloc needs 8-byte alignment; bash malloc has 8-byte + alignment now, but I have no NetBSD machines to test on) + + BSD/OS 2.1, 3.x if you want to use loadable builtins + + Motorola m68k machines running System V.3. There is a file descriptor + leak caused by using the bash malloc because closedir(3) needs to read + freed memory to find the file descriptor to close + +2. Configure using shlicc2 on BSD/OS 2.1 and BSD/OS 3.x to use loadable + builtins + +3. Bash cannot be built in a directory separate from the source directory + using configure --srcdir=... unless the version of `make' you're using + does $VPATH handling right. The script support/mkclone can be used to + create a `build tree' using symlinks to get around this. + +4. I've had reports that username completion (as well as tilde expansion + and \u prompt expansion) does not work on IRIX 5.3 when linking with + -lnsl. This is only a problem when you're running NIS, since + apparently -lnsl supports only /etc/passwd and not the NIS functions + for retrieving usernames and passwords. Editing the Makefile after + configure runs and removing the `-lnsl' from the assignment to `LIBS' + fixes the problem. + +5. There is a problem with the `makewhatis' script in older (pre-7.0) + versions of Red Hat Linux. Running `makewhatis' with bash-2.0 or + later versions results in error messages like this: + + /usr/sbin/makewhatis: cd: manpath: No such file or directory + /usr/sbin/makewhatis: manpath/whatis: No such file or directory + chmod: manpath/whatis: No such file or directory + /usr/sbin/makewhatis: cd: catpath: No such file or directory + /usr/sbin/makewhatis: catpath/whatis: No such file or directory + chmod: catpath/whatis: No such file or directory + + The problem is with `makewhatis'. Red Hat (and possibly other + Linux distributors) uses a construct like this in the code: + + eval path=$"$pages"path + + to do indirect variable expansion. This `happened to work' in + bash-1.14 and previous versions, but that was more an accident + of implementation than anything else -- it was never supported + and certainly is not portable. + + Bash-2.0 has a new feature that gives a new meaning to $"...". + This is explained more completely in item 1 in the COMPAT file. + + The three lines in the `makewhatis' script that need to be changed + look like this: + + eval $topath=$"$topath":$name + [...] + eval path=$"$pages"path + [...] + eval path=$"$pages"path + + The portable way to write this code is + + eval $topath="\$$topath":$name + eval path="\$$pages"path + eval path="\$$pages"path + + You could also experiment with another new bash feature: ${!var}. + This does indirect variable expansion, making the use of eval + unnecessary. + +6. There is a problem with syslogd on many Linux distributions (Red Hat + and Slackware are two that I have received reports about). syslogd + sends a SIGINT to its parent process, which is waiting for the daemon + to finish its initialization. The parent process then dies due to + the SIGINT, and bash reports it, causing unexpected console output + while the system is booting that looks something like + + starting daemons: syslogd/etc/rc.d/rc.M: line 29: 38 Interrupt ${NET}/syslogd + + Bash-2.0 reports events such as processes dying in scripts due to + signals when the standard output is a tty. Bash-1.14.x and previous + versions did not report such events. + + This should probably be reported as a bug to whatever Linux distributor + people see the problem on. In my opinion, syslogd should be changed to + use some other method of communication, or the wrapper function (which + appeared to be `daemon' when I looked at it some time ago) or script + (which appeared to be `syslog') should catch SIGINT, since it's an + expected event, and exit cleanly. + +7. Several people have reported that `dip' (a program for SLIP/PPP + on Linux) does not work with bash-2.0 installed as /bin/sh. + + I don't run any Linux boxes myself, and do not have the dip + code handy to look at, but the `problem' with bash-2.0, as + it has been related to me, is that bash requires the `-p' + option to be supplied at invocation if it is to run setuid + or setgid. + + This means, among other things, that setuid or setgid programs + which call system(3) (a horrendously bad practice in any case) + relinquish their setuid/setgid status in the child that's forked + to execute /bin/sh. + + The following is an *unofficial* patch to bash-2.0 that causes it + to not require `-p' to run setuid or setgid if invoked as `sh'. + It has been reported to work on Linux. It will make your system + vulnerable to bogus system(3) calls in setuid executables. + +--- ../bash-2.0.orig/shell.c Wed Dec 18 14:16:30 1996 ++++ shell.c Fri Mar 7 13:12:03 1997 +@@ -347,7 +347,7 @@ + if (posixly_correct) + posix_initialize (posixly_correct); + +- if (running_setuid && privileged_mode == 0) ++ if (running_setuid && privileged_mode == 0 && act_like_sh == 0) + disable_priv_mode (); + + /* Need to get the argument to a -c option processed in the + +8. Some people have asked about binding all of the keys in a PC-keyboard- + style numeric keypad to readline functions. Here's something I + received from the gnu-win32 list that may help. Insert the following + lines into ~/.inputrc: + +# home key +"\e[1~":beginning-of-line +# insert key +"\e[2~":kill-whole-line +# del key +"\e[3~":delete-char +# end key +"\e[4~":end-of-line +# pgup key +"\e[5~":history-search-forward +# pgdn key +"\e[6~":history-search-backward + +9. Hints for building under Minix 2.0 (Contributed by Terry R. McConnell, + ) + + The version of /bin/sh distributed with Minix is not up to the job of + running the configure script. The easiest solution is to swap /bin/sh + with /usr/bin/ash. Then use chmem(1) to increase the memory allocated + to /bin/sh. The following settings are known to work: + + text data bss stack memory + 63552 9440 3304 65536 141832 /bin/sh + + If you have problems with make or yacc it may be worthwhile first to + install the GNU versions of these utilities before attempting to build + bash. (As of this writing, all of these utilities are available for the + i386 as pre-built binaries via anonymous ftp at math.syr.edu in the + pub/mcconnell/minix directory. Note that the GNU version of yacc is called + bison.) + + Unless you want to see lots of warnings about old-style declarations, + do LOCAL_CFLAGS=-wo; export LOCAL_CFLAGS before running configure. + (These warnings are harmless, but annoying.) + + configure will insist that you supply a host type. For example, do + ./configure --host=i386-pc-minix. + + Minix does not support the system calls required for a proper + implementation of ulimit(). The `ulimit' builtin will not be available. + + Configure will fail to notice that many things like uid_t are indeed + typedef'd in , because it uses egrep for this purpose + and minix has no egrep. You could try making a link /usr/bin/egrep --> + /usr/bin/grep. Better is to install the GNU version of grep in + /usr/local/bin and make the link /usr/local/bin/egrep -->/usr/local/bin/grep. + (These must be hard links, of course, since Minix does not support + symbolic links.) + + You will see many warnings of the form: + warning: unknown s_type: 98 + I have no idea what this means, but it doesn't seem to matter. + +10. If you do not have /usr/ccs/bin in your PATH when building on SunOS 5.x + (Solaris 2), the configure script will be unable to find `ar' and + `ranlib' (of course, ranlib is unnecessary). Make sure your $PATH + includes /usr/ccs/bin on SunOS 5.x. This generally manifests itself + with libraries not being built and make reporting errors like + `cr: not found' when library construction is attempted. + +11. Building a statically-linked bash on Solaris 2.5.x, 2.6, 7, or 8 is + complicated. + + It's not possible to build a completely statically-linked binary, since + part of the C library depends on dynamic linking. The following recipe + assumes that you're using gcc and the Solaris ld (/usr/ccs/bin/ld) on + Solaris 2.5.x or 2.6: + + configure --enable-static-link + make STATIC_LD= LOCAL_LIBS='-Wl,-B,dynamic -ldl -Wl,-B,static' + + This should result in a bash binary that depends only on libdl.so: + + thor(2)$ ldd bash + libdl.so.1 => /usr/lib/libdl.so.1 + + If you're using the Sun C Compiler (Sun WorkShop C Compiler version + 4.2 was what I used), you should be able to get away with using + + configure --enable-static-link + make STATIC_LD= LOCAL_LIBS='-B dynamic -ldl -B static' + + If you want to completely remove any dependence on /usr, perhaps + to put a copy of bash in /sbin and have it available when /usr is + not mounted, force the build process to use the shared dl.so library + in /etc/lib. + + For gcc, this would be something like + + configure --enable-static-link + make STATIC_LD= LOCAL_LIBS='-Wl,-B,dynamic -Wl,-R/etc/lib -ldl -Wl,-B,static' + + For Sun's WS4.2 cc + + configure --enable-static-link + make STATIC_LD= LOCAL_LIBS='-B dynamic -R/etc/lib -ldl -B static' + + seems to work, at least on Solaris 2.5.1: + + thor(2)$ ldd bash + libdl.so.1 => /etc/lib/libdl.so.1 + + On Solaris 7 (Solaris 8, using the version of gcc on the free software + CD-ROM), the following recipe appears to work for gcc: + + configure --enable-static-link + make STATIC_LD='-Wl,-Bstatic' LOCAL_LIBS='-Wl,-Bdynamic -Wl,-R/etc/lib -ldl -Wl,-Bstatic' + + thor.ins.cwru.edu(2)$ ldd bash + libdl.so.1 => /etc/lib/libdl.so.1 + + Make the analogous changes if you are running Sun's C Compiler. + + I have received word that adding -L/etc/lib (or the equivalent + -Wl,-L/etc/lib) might also be necessary, in addition to the -R/etc/lib. + + On later versions of Solaris, it may be necessary to add -lnsl before + -ldl; statically-linked versions of bash using libnsl are not guaranteed + to work correctly on future versions of Solaris. + +12. Configuring bash to build it in a cross environment. Currently only + two native versions can be compiled this way, cygwin32 and x86 BeOS. + For BeOS, you would configure it like this: + + export RANLIB=i586-beos-ranlib + export AR=i586-beos-ar + export CC=i586-beos-gcc + configure i586-beos + + Similarly for cygwin32. + +13. Bash-2.05 has reverted to the bash-2.03 behavior of honoring the current + locale setting when processing ranges within pattern matching bracket + expressions ([A-Z]). This is what POSIX.2 and SUSv2 specify. + + The behavior of the matcher in bash-2.05 depends on the current LC_COLLATE + setting. Setting this variable to `C' or `POSIX' will result in the + traditional behavior ([A-Z] matches all uppercase ASCII characters). + Many other locales, including the en_US locale (the default on many US + versions of Linux) collate the upper and lower case letters like this: + + AaBb...Zz + + which means that [A-Z] matches every letter except `z'. + + The portable way to specify upper case letters is [:upper:] instead of + A-Z; lower case may be specified as [:lower:] instead of a-z. + + Look at the manual pages for setlocale(3), strcoll(3), and, if it is + present, locale(1). If you have locale(1), you can use it to find + your current locale information even if you do not have any of the + LC_ variables set. + + My advice is to put + + export LC_COLLATE=C + + into /etc/profile and inspect any shell scripts run from cron for + constructs like [A-Z]. This will prevent things like + + rm [A-Z]* + + from removing every file in the current directory except those beginning + with `z' and still allow individual users to change the collation order. + Users may put the above command into their own profiles as well, of course. + +14. Building on Interix (nee OpenNT), which Microsoft bought from Softway + Systems and has seemingly abandoned (thanks to Kevin Moore for this item). + + 1. cp cross-build/opennt.cache config.cache + + 2. If desired, edit pathnames.h to set the values of SYS_PROFILE and + DEFAULT_HOSTS_FILE appropriately. + + 3. export CONFIG_SHELL=$INTERIX_ROOT/bin/sh + + 4. ./configure --prefix=$INTERIX_ROOT/usr/local (or wherever you + want it). + + 5. make; make install; enjoy + +15. Configure with `CC=xlc' if you don't have gcc on AIX 4.2 and later + versions. `xlc' running in `cc' mode has trouble compiling error.c. + +16. Configure --disable-multibyte on NetBSD versions (1.4 through at least + 1.6.1) that include wctype.h but do not define wctype_t. + +17. Do NOT use bison-1.75. It builds a non-working parser. The most + obvious effect is that constructs like "for i; do echo $i; done" don't + loop over the positional parameters. + +18. I have received reports that using -O2 with the MIPSpro results in a + binary that fails in strange ways. Using -O1 seems to work. + +19. There is special handling to ensure the shell links against static + versions of the included readline and history libraries on Mac OS X; + Apple ships inadequate dynamic libreadline and libhistory "replacements" + as standard libraries. + +20. If you're on a system like SGI Irix, and you get an error about not + being able to refer to a dynamic symbol + (ld: non-dynamic relocations refer to dynamic symbol PC), add + -DNEED_EXTERN_PC to the LOCAL_CFLAGS variable in lib/readline/Makefile.in + and rebuild. diff --git a/POSIX b/POSIX new file mode 100644 index 0000000..84ab6be --- /dev/null +++ b/POSIX @@ -0,0 +1,228 @@ +6.11 Bash POSIX Mode +==================== + +Starting Bash with the '--posix' command-line option or executing 'set +-o posix' while Bash is running will cause Bash to conform more closely +to the POSIX standard by changing the behavior to match that specified +by POSIX in areas where the Bash default differs. + +When invoked as 'sh', Bash enters POSIX mode after reading the startup +files. + +The following list is what's changed when 'POSIX mode' is in effect: + + 1. When a command in the hash table no longer exists, Bash will + re-search '$PATH' to find the new location. This is also available + with 'shopt -s checkhash'. + + 2. The message printed by the job control code and builtins when a job + exits with a non-zero status is 'Done(status)'. + + 3. The message printed by the job control code and builtins when a job + is stopped is 'Stopped(SIGNAME)', where SIGNAME is, for example, + 'SIGTSTP'. + + 4. Alias expansion is always enabled, even in non-interactive shells. + + 5. Reserved words appearing in a context where reserved words are + recognized do not undergo alias expansion. + + 6. The POSIX 'PS1' and 'PS2' expansions of '!' to the history number + and '!!' to '!' are enabled, and parameter expansion is performed + on the values of 'PS1' and 'PS2' regardless of the setting of the + 'promptvars' option. + + 7. The POSIX startup files are executed ('$ENV') rather than the + normal Bash files. + + 8. Tilde expansion is only performed on assignments preceding a + command name, rather than on all assignment statements on the line. + + 9. The default history file is '~/.sh_history' (this is the default + value of '$HISTFILE'). + + 10. Redirection operators do not perform filename expansion on the + word in the redirection unless the shell is interactive. + + 11. Redirection operators do not perform word splitting on the word in + the redirection. + + 12. Function names must be valid shell '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. + + 13. Function names may not be the same as one of the POSIX special + builtins. + + 14. POSIX special builtins are found before shell functions during + command lookup. + + 15. Literal tildes that appear as the first character in elements of + the 'PATH' variable are not expanded as described above under *note + Tilde Expansion::. + + 16. The 'time' reserved word may be used by itself as a command. When + used in this way, it displays timing statistics for the shell and + its completed children. The 'TIMEFORMAT' variable controls the + format of the timing information. + + 17. When parsing and expanding a ${...} expansion that appears within + double quotes, single quotes are no longer special and cannot be + used to quote a closing brace or other special character, unless + the operator is one of those defined to perform pattern removal. + In this case, they do not have to appear as matched pairs. + + 18. The parser does not recognize 'time' as a reserved word if the + next token begins with a '-'. + + 19. The '!' character does not introduce history expansion within a + double-quoted string, even if the 'histexpand' option is enabled. + + 20. If a 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. + + 21. 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. + + 22. A non-interactive shell exits with an error status if a variable + assignment error occurs in an assignment statement preceding a + special builtin, but not with any other simple command. + + 23. A non-interactive shell exits with an error status if the + iteration variable in a 'for' statement or the selection variable + in a 'select' statement is a readonly variable. + + 24. Non-interactive shells exit if FILENAME in '.' FILENAME is not + found. + + 25. Non-interactive shells exit if a syntax error in an arithmetic + expansion results in an invalid expression. + + 26. Non-interactive shells exit on word expansion errors. + + 27. Non-interactive shells exit if there is a syntax error in a script + read with the '.' or 'source' builtins, or in a string processed by + the 'eval' builtin. + + 28. Process substitution is not available. + + 29. While variable indirection is available, it may not be applied to + the '#' and '?' special parameters. + + 30. Assignment statements preceding POSIX special builtins persist in + the shell environment after the builtin completes. + + 31. Assignment statements preceding shell function calls persist in + the shell environment after the function returns, as if a POSIX + special builtin command had been executed. + + 32. The 'command' builtin does not prevent builtins that take + assignment statements as arguments from expanding them as + assignment statements; when not in POSIX mode, assignment builtins + lose their assignment statement expansion properties when preceded + by 'command'. + + 33. The '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. + + 34. The output of 'kill -l' prints all the signal names on a single + line, separated by spaces, without the 'SIG' prefix. + + 35. The 'kill' builtin does not accept signal names with a 'SIG' + prefix. + + 36. The 'export' and 'readonly' builtin commands display their output + in the format required by POSIX. + + 37. The 'trap' builtin displays signal names without the leading + 'SIG'. + + 38. The '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 '-' as the first argument. + + 39. The '.' and 'source' builtins do not search the current directory + for the filename argument if it is not found by searching 'PATH'. + + 40. Enabling POSIX mode has the effect of setting the + 'inherit_errexit' option, so subshells spawned to execute command + substitutions inherit the value of the '-e' option from the parent + shell. When the 'inherit_errexit' option is not enabled, Bash + clears the '-e' option in such subshells. + + 41. When the 'alias' builtin displays alias definitions, it does not + display them with a leading 'alias ' unless the '-p' option is + supplied. + + 42. When the 'set' builtin is invoked without options, it does not + display shell function names and definitions. + + 43. When the 'set' builtin is invoked without options, it displays + variable values without quotes, unless they contain shell + metacharacters, even if the result contains nonprinting characters. + + 44. When the 'cd' builtin is invoked in LOGICAL mode, and the pathname + constructed from '$PWD' and the directory name supplied as an + argument does not refer to an existing directory, 'cd' will fail + instead of falling back to PHYSICAL mode. + + 45. The '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 '-P' option. + + 46. When listing the history, the 'fc' builtin does not include an + indication of whether or not a history entry has been modified. + + 47. The default editor used by 'fc' is 'ed'. + + 48. The 'type' and '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 '$PATH'. + + 49. The 'vi' editing mode will invoke the 'vi' editor directly when + the 'v' command is run, instead of checking '$VISUAL' and + '$EDITOR'. + + 50. When the 'xpg_echo' option is enabled, Bash does not attempt to + interpret any arguments to 'echo' as options. Each argument is + displayed, after escape characters are converted. + + 51. The 'ulimit' builtin uses a block size of 512 bytes for the '-c' + and '-f' options. + + 52. The arrival of 'SIGCHLD' when a trap is set on 'SIGCHLD' does not + interrupt the 'wait' builtin and cause it to return immediately. + The trap command is run once for each child that exits. + + 53. The 'read' builtin may be interrupted by a signal for which a trap + has been set. If Bash receives a trapped signal while executing + 'read', the trap handler executes and 'read' returns an exit status + greater than 128. + + 54. Bash removes an exited background process's status from the list + of such statuses after the 'wait' builtin is used to obtain it. + +There is other POSIX behavior that Bash does not implement by default +even when in POSIX mode. Specifically: + + 1. The 'fc' builtin checks '$EDITOR' as a program to edit history + entries if 'FCEDIT' is unset, rather than defaulting directly to + 'ed'. 'fc' uses 'ed' if 'EDITOR' is unset. + + 2. As noted above, Bash requires the 'xpg_echo' option to be enabled + for the 'echo' builtin to be fully conformant. + +Bash can be configured to be POSIX-conformant by default, by specifying +the '--enable-strict-posix-default' to 'configure' when building (*note +Optional Features::). + diff --git a/RBASH b/RBASH new file mode 100644 index 0000000..9478fc6 --- /dev/null +++ b/RBASH @@ -0,0 +1,37 @@ +6.10 The Restricted Shell +========================= + +If Bash is started with the name 'rbash', or the '--restricted' or '-r' +option is supplied at invocation, the shell becomes restricted. A +restricted shell is used to set up an environment more controlled than +the standard shell. A restricted shell behaves identically to 'bash' +with the exception that the following are disallowed or not performed: + + * Changing directories with the 'cd' builtin. + * Setting or unsetting the values of the 'SHELL', 'PATH', 'ENV', or + 'BASH_ENV' variables. + * Specifying command names containing slashes. + * Specifying a filename containing a slash as an argument to the '.' + builtin command. + * Specifying a filename containing a slash as an argument to the '-p' + option to the 'hash' builtin command. + * Importing function definitions from the shell environment at + startup. + * Parsing the value of 'SHELLOPTS' from the shell environment at + startup. + * Redirecting output using the '>', '>|', '<>', '>&', '&>', and '>>' + redirection operators. + * Using the 'exec' builtin to replace the shell with another command. + * Adding or deleting builtin commands with the '-f' and '-d' options + to the 'enable' builtin. + * Using the 'enable' builtin command to enable disabled shell + builtins. + * Specifying the '-p' option to the 'command' builtin. + * Turning off restricted mode with 'set +r' or 'set +o restricted'. + +These restrictions are enforced after any startup files are read. + +When a command that is found to be a shell script is executed (*note +Shell Scripts::), 'rbash' turns off any restrictions in the shell +spawned to execute the script. + diff --git a/README b/README new file mode 100644 index 0000000..ad87aa8 --- /dev/null +++ b/README @@ -0,0 +1,99 @@ +Introduction +============ + +This is GNU Bash, version 4.4. Bash is the GNU Project's Bourne +Again SHell, a complete implementation of the POSIX shell spec, +but also with interactive command line editing, job control on +architectures that support it, csh-like features such as history +substitution and brace expansion, and a slew of other features. +For more information on the features of Bash that are new to this +type of shell, see the file `doc/bashref.texi'. There is also a +large Unix-style man page. The man page is the definitive description +of the shell's features. + +See the file POSIX for a discussion of how the Bash defaults differ +from the POSIX spec and a description of the Bash `posix mode'. + +There are some user-visible incompatibilities between this version +of Bash and previous widely-distributed versions, bash-4.2 and +bash-4.3. For details, see the file COMPAT. The NEWS file tersely +lists features that are new in this release. + +Bash is free software, distributed under the terms of the [GNU] General +Public License as published by the Free Software Foundation, +version 3 of the License (or any later version). For more information, +see the file COPYING. + +A number of frequently-asked questions are answered in the file +`doc/FAQ'. + +To compile Bash, type `./configure', then `make'. Bash auto-configures +the build process, so no further intervention should be necessary. Bash +builds with `gcc' by default if it is available. If you want to use `cc' +instead, type + + CC=cc ./configure + +if you are using a Bourne-style shell. If you are not, the following +may work: + + env CC=cc ./configure + +Read the file INSTALL in this directory for more information about how +to customize and control the build process. The file NOTES contains +platform-specific installation and configuration information. + +If you are a csh user and wish to convert your csh aliases to Bash +aliases, you may wish to use the script `examples/misc/alias-conv.sh' +as a starting point. The script `examples/misc/cshtobash' is a +more ambitious script that attempts to do a more complete job. + +Reporting Bugs +============== + +Bug reports for bash should be sent to: + + bug-bash@gnu.org + +using the `bashbug' program that is built and installed at the same +time as bash. + +The discussion list `bug-bash@gnu.org' often contains information +about new ports of Bash, or discussions of new features or behavior +changes that people would like. This mailing list is also available +as a usenet newsgroup: gnu.bash.bug. + +When you send a bug report, please use the `bashbug' program that is +built at the same time as bash. If bash fails to build, try building +bashbug directly with `make bashbug'. If you cannot build `bashbug', +please send mail to bug-bash@gnu.org with the following information: + + * the version number and release status of Bash (e.g., 2.05a-release) + * the machine and OS that it is running on (you may run + `bashversion -l' from the bash build directory for this information) + * a list of the compilation flags or the contents of `config.h', if + appropriate + * a description of the bug + * a recipe for recreating the bug reliably + * a fix for the bug if you have one! + +The `bashbug' program includes much of this automatically. + +Questions and requests for help with bash and bash programming may be +sent to the help-bash@gnu.org mailing list. + +If you would like to contact the Bash maintainers directly, send mail +to bash-maintainers@gnu.org. + +While the Bash maintainers do not promise to fix all bugs, we would +like this shell to be the best that we can make it. + +Enjoy! + +Chet Ramey +chet.ramey@case.edu + +Copying and distribution of this file, with or without modification, +are permitted in any medium without royalty provided the copyright +notice and this notice are preserved. This file is offered as-is, +without any warranty. diff --git a/Y2K b/Y2K new file mode 100644 index 0000000..d12e352 --- /dev/null +++ b/Y2K @@ -0,0 +1,4 @@ +Since Bash does not manipulate date strings, it is Y2K-safe. + +The only thing that Bash does with date strings is manipulate the string +returned by ctime(3) or strftime(3) in the prompt customization code. diff --git a/aclocal.m4 b/aclocal.m4 new file mode 100644 index 0000000..d3bac07 --- /dev/null +++ b/aclocal.m4 @@ -0,0 +1,4197 @@ +dnl +dnl Bash specific tests +dnl +dnl Some derived from PDKSH 5.1.3 autoconf tests +dnl + +AC_DEFUN(BASH_C_LONG_LONG, +[AC_CACHE_CHECK(for long long, ac_cv_c_long_long, +[if test "$GCC" = yes; then + ac_cv_c_long_long=yes +else +AC_TRY_RUN([ +int +main() +{ +long long foo = 0; +exit(sizeof(long long) < sizeof(long)); +} +], ac_cv_c_long_long=yes, ac_cv_c_long_long=no) +fi]) +if test $ac_cv_c_long_long = yes; then + AC_DEFINE(HAVE_LONG_LONG, 1, [Define if the `long long' type works.]) +fi +]) + +dnl +dnl This is very similar to AC_C_LONG_DOUBLE, with the fix for IRIX +dnl (< changed to <=) added. +dnl +AC_DEFUN(BASH_C_LONG_DOUBLE, +[AC_CACHE_CHECK(for long double, ac_cv_c_long_double, +[if test "$GCC" = yes; then + ac_cv_c_long_double=yes +else +AC_TRY_RUN([ +int +main() +{ + /* The Stardent Vistra knows sizeof(long double), but does not + support it. */ + long double foo = 0.0; + /* On Ultrix 4.3 cc, long double is 4 and double is 8. */ + /* On IRIX 5.3, the compiler converts long double to double with a warning, + but compiles this successfully. */ + exit(sizeof(long double) <= sizeof(double)); +} +], ac_cv_c_long_double=yes, ac_cv_c_long_double=no) +fi]) +if test $ac_cv_c_long_double = yes; then + AC_DEFINE(HAVE_LONG_DOUBLE, 1, [Define if the `long double' type works.]) +fi +]) + +dnl +dnl Check for . This is separated out so that it can be +dnl AC_REQUIREd. +dnl +dnl BASH_HEADER_INTTYPES +AC_DEFUN(BASH_HEADER_INTTYPES, +[ + AC_CHECK_HEADERS(inttypes.h) +]) + +dnl +dnl check for typedef'd symbols in header files, but allow the caller to +dnl specify the include files to be checked in addition to the default +dnl +dnl BASH_CHECK_TYPE(TYPE, HEADERS, DEFAULT[, VALUE-IF-FOUND]) +AC_DEFUN(BASH_CHECK_TYPE, +[ +AC_REQUIRE([AC_HEADER_STDC])dnl +AC_REQUIRE([BASH_HEADER_INTTYPES]) +AC_MSG_CHECKING(for $1) +AC_CACHE_VAL(bash_cv_type_$1, +[AC_EGREP_CPP($1, [#include +#if STDC_HEADERS +#include +#include +#endif +#if HAVE_INTTYPES_H +#include +#endif +#if HAVE_STDINT_H +#include +#endif +$2 +], bash_cv_type_$1=yes, bash_cv_type_$1=no)]) +AC_MSG_RESULT($bash_cv_type_$1) +ifelse($#, 4, [if test $bash_cv_type_$1 = yes; then + AC_DEFINE($4) + fi]) +if test $bash_cv_type_$1 = no; then + AC_DEFINE_UNQUOTED($1, $3) +fi +]) + +dnl +dnl BASH_CHECK_DECL(FUNC) +dnl +dnl Check for a declaration of FUNC in stdlib.h and inttypes.h like +dnl AC_CHECK_DECL +dnl +AC_DEFUN(BASH_CHECK_DECL, +[ +AC_REQUIRE([AC_HEADER_STDC]) +AC_REQUIRE([BASH_HEADER_INTTYPES]) +AC_CACHE_CHECK([for declaration of $1], bash_cv_decl_$1, +[AC_TRY_LINK( +[ +#if STDC_HEADERS +# include +#endif +#if HAVE_INTTYPES_H +# include +#endif +], +[return !$1;], +bash_cv_decl_$1=yes, bash_cv_decl_$1=no)]) +bash_tr_func=HAVE_DECL_`echo $1 | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` +if test $bash_cv_decl_$1 = yes; then + AC_DEFINE_UNQUOTED($bash_tr_func, 1) +else + AC_DEFINE_UNQUOTED($bash_tr_func, 0) +fi +]) + +AC_DEFUN(BASH_DECL_PRINTF, +[AC_MSG_CHECKING(for declaration of printf in ) +AC_CACHE_VAL(bash_cv_printf_declared, +[AC_TRY_RUN([ +#include +#ifdef __STDC__ +typedef int (*_bashfunc)(const char *, ...); +#else +typedef int (*_bashfunc)(); +#endif +main() +{ +_bashfunc pf; +pf = (_bashfunc) printf; +exit(pf == 0); +} +], bash_cv_printf_declared=yes, bash_cv_printf_declared=no, + [AC_MSG_WARN(cannot check printf declaration if cross compiling -- defaulting to yes) + bash_cv_printf_declared=yes] +)]) +AC_MSG_RESULT($bash_cv_printf_declared) +if test $bash_cv_printf_declared = yes; then +AC_DEFINE(PRINTF_DECLARED) +fi +]) + +AC_DEFUN(BASH_DECL_SBRK, +[AC_MSG_CHECKING(for declaration of sbrk in ) +AC_CACHE_VAL(bash_cv_sbrk_declared, +[AC_EGREP_HEADER(sbrk, unistd.h, + bash_cv_sbrk_declared=yes, bash_cv_sbrk_declared=no)]) +AC_MSG_RESULT($bash_cv_sbrk_declared) +if test $bash_cv_sbrk_declared = yes; then +AC_DEFINE(SBRK_DECLARED) +fi +]) + +dnl +dnl Check for sys_siglist[] or _sys_siglist[] +dnl +AC_DEFUN(BASH_DECL_UNDER_SYS_SIGLIST, +[AC_MSG_CHECKING([for _sys_siglist in signal.h or unistd.h]) +AC_CACHE_VAL(bash_cv_decl_under_sys_siglist, +[AC_TRY_COMPILE([ +#include +#include +#ifdef HAVE_UNISTD_H +#include +#endif], [ char *msg = _sys_siglist[2]; ], + bash_cv_decl_under_sys_siglist=yes, bash_cv_decl_under_sys_siglist=no, + [AC_MSG_WARN(cannot check for _sys_siglist[] if cross compiling -- defaulting to no)])])dnl +AC_MSG_RESULT($bash_cv_decl_under_sys_siglist) +if test $bash_cv_decl_under_sys_siglist = yes; then +AC_DEFINE(UNDER_SYS_SIGLIST_DECLARED) +fi +]) + +AC_DEFUN(BASH_UNDER_SYS_SIGLIST, +[AC_REQUIRE([BASH_DECL_UNDER_SYS_SIGLIST]) +AC_MSG_CHECKING([for _sys_siglist in system C library]) +AC_CACHE_VAL(bash_cv_under_sys_siglist, +[AC_TRY_RUN([ +#include +#include +#ifdef HAVE_UNISTD_H +#include +#endif +#ifndef UNDER_SYS_SIGLIST_DECLARED +extern char *_sys_siglist[]; +#endif +main() +{ +char *msg = (char *)_sys_siglist[2]; +exit(msg == 0); +}], + bash_cv_under_sys_siglist=yes, bash_cv_under_sys_siglist=no, + [AC_MSG_WARN(cannot check for _sys_siglist[] if cross compiling -- defaulting to no) + bash_cv_under_sys_siglist=no])]) +AC_MSG_RESULT($bash_cv_under_sys_siglist) +if test $bash_cv_under_sys_siglist = yes; then +AC_DEFINE(HAVE_UNDER_SYS_SIGLIST) +fi +]) + +AC_DEFUN(BASH_SYS_SIGLIST, +[AC_REQUIRE([AC_DECL_SYS_SIGLIST]) +AC_MSG_CHECKING([for sys_siglist in system C library]) +AC_CACHE_VAL(bash_cv_sys_siglist, +[AC_TRY_RUN([ +#include +#include +#ifdef HAVE_UNISTD_H +#include +#endif +#if !HAVE_DECL_SYS_SIGLIST +extern char *sys_siglist[]; +#endif +main() +{ +char *msg = sys_siglist[2]; +exit(msg == 0); +}], + bash_cv_sys_siglist=yes, bash_cv_sys_siglist=no, + [AC_MSG_WARN(cannot check for sys_siglist if cross compiling -- defaulting to no) + bash_cv_sys_siglist=no])]) +AC_MSG_RESULT($bash_cv_sys_siglist) +if test $bash_cv_sys_siglist = yes; then +AC_DEFINE(HAVE_SYS_SIGLIST) +fi +]) + +dnl Check for the various permutations of sys_siglist and make sure we +dnl compile in siglist.o if they're not defined +AC_DEFUN(BASH_CHECK_SYS_SIGLIST, [ +AC_REQUIRE([BASH_SYS_SIGLIST]) +AC_REQUIRE([BASH_DECL_UNDER_SYS_SIGLIST]) +AC_REQUIRE([BASH_FUNC_STRSIGNAL]) +if test "$bash_cv_sys_siglist" = no && test "$bash_cv_under_sys_siglist" = no && test "$bash_cv_have_strsignal" = no; then + SIGLIST_O=siglist.o +else + SIGLIST_O= +fi +AC_SUBST([SIGLIST_O]) +]) + +dnl Check for sys_errlist[] and sys_nerr, check for declaration +AC_DEFUN(BASH_SYS_ERRLIST, +[AC_MSG_CHECKING([for sys_errlist and sys_nerr]) +AC_CACHE_VAL(bash_cv_sys_errlist, +[AC_TRY_LINK([#include ], +[extern char *sys_errlist[]; + extern int sys_nerr; + char *msg = sys_errlist[sys_nerr - 1];], + bash_cv_sys_errlist=yes, bash_cv_sys_errlist=no)])dnl +AC_MSG_RESULT($bash_cv_sys_errlist) +if test $bash_cv_sys_errlist = yes; then +AC_DEFINE(HAVE_SYS_ERRLIST) +fi +]) + +dnl +dnl Check if dup2() does not clear the close on exec flag +dnl +AC_DEFUN(BASH_FUNC_DUP2_CLOEXEC_CHECK, +[AC_MSG_CHECKING(if dup2 fails to clear the close-on-exec flag) +AC_CACHE_VAL(bash_cv_dup2_broken, +[AC_TRY_RUN([ +#include +#include +main() +{ + int fd1, fd2, fl; + fd1 = open("/dev/null", 2); + if (fcntl(fd1, 2, 1) < 0) + exit(1); + fd2 = dup2(fd1, 1); + if (fd2 < 0) + exit(2); + fl = fcntl(fd2, 1, 0); + /* fl will be 1 if dup2 did not reset the close-on-exec flag. */ + exit(fl != 1); +} +], bash_cv_dup2_broken=yes, bash_cv_dup2_broken=no, + [AC_MSG_WARN(cannot check dup2 if cross compiling -- defaulting to no) + bash_cv_dup2_broken=no]) +]) +AC_MSG_RESULT($bash_cv_dup2_broken) +if test $bash_cv_dup2_broken = yes; then +AC_DEFINE(DUP2_BROKEN) +fi +]) + +AC_DEFUN(BASH_FUNC_STRSIGNAL, +[AC_MSG_CHECKING([for the existence of strsignal]) +AC_CACHE_VAL(bash_cv_have_strsignal, +[AC_TRY_LINK([#include +#include ], +[char *s = (char *)strsignal(2);], + bash_cv_have_strsignal=yes, bash_cv_have_strsignal=no)]) +AC_MSG_RESULT($bash_cv_have_strsignal) +if test $bash_cv_have_strsignal = yes; then +AC_DEFINE(HAVE_STRSIGNAL) +fi +]) + +dnl Check to see if opendir will open non-directories (not a nice thing) +AC_DEFUN(BASH_FUNC_OPENDIR_CHECK, +[AC_REQUIRE([AC_HEADER_DIRENT])dnl +AC_MSG_CHECKING(if opendir() opens non-directories) +AC_CACHE_VAL(bash_cv_opendir_not_robust, +[AC_TRY_RUN([ +#include +#include +#include +#ifdef HAVE_UNISTD_H +# include +#endif /* HAVE_UNISTD_H */ +#if defined(HAVE_DIRENT_H) +# include +#else +# define dirent direct +# ifdef HAVE_SYS_NDIR_H +# include +# endif /* SYSNDIR */ +# ifdef HAVE_SYS_DIR_H +# include +# endif /* SYSDIR */ +# ifdef HAVE_NDIR_H +# include +# endif +#endif /* HAVE_DIRENT_H */ +main() +{ +DIR *dir; +int fd, err; +err = mkdir("bash-aclocal", 0700); +if (err < 0) { + perror("mkdir"); + exit(1); +} +unlink("bash-aclocal/not_a_directory"); +fd = open("bash-aclocal/not_a_directory", O_WRONLY|O_CREAT|O_EXCL, 0666); +write(fd, "\n", 1); +close(fd); +dir = opendir("bash-aclocal/not_a_directory"); +unlink("bash-aclocal/not_a_directory"); +rmdir("bash-aclocal"); +exit (dir == 0); +}], bash_cv_opendir_not_robust=yes,bash_cv_opendir_not_robust=no, + [AC_MSG_WARN(cannot check opendir if cross compiling -- defaulting to no) + bash_cv_opendir_not_robust=no] +)]) +AC_MSG_RESULT($bash_cv_opendir_not_robust) +if test $bash_cv_opendir_not_robust = yes; then +AC_DEFINE(OPENDIR_NOT_ROBUST) +fi +]) + +dnl +AC_DEFUN(BASH_TYPE_SIGHANDLER, +[AC_MSG_CHECKING([whether signal handlers are of type void]) +AC_CACHE_VAL(bash_cv_void_sighandler, +[AC_TRY_COMPILE([#include +#include +#ifdef signal +#undef signal +#endif +#ifdef __cplusplus +extern "C" +#endif +void (*signal ()) ();], +[int i;], bash_cv_void_sighandler=yes, bash_cv_void_sighandler=no)])dnl +AC_MSG_RESULT($bash_cv_void_sighandler) +if test $bash_cv_void_sighandler = yes; then +AC_DEFINE(VOID_SIGHANDLER) +fi +]) + +dnl +dnl A signed 16-bit integer quantity +dnl +AC_DEFUN(BASH_TYPE_BITS16_T, +[ +if test "$ac_cv_sizeof_short" = 2; then + AC_CHECK_TYPE(bits16_t, short) +elif test "$ac_cv_sizeof_char" = 2; then + AC_CHECK_TYPE(bits16_t, char) +else + AC_CHECK_TYPE(bits16_t, short) +fi +]) + +dnl +dnl An unsigned 16-bit integer quantity +dnl +AC_DEFUN(BASH_TYPE_U_BITS16_T, +[ +if test "$ac_cv_sizeof_short" = 2; then + AC_CHECK_TYPE(u_bits16_t, unsigned short) +elif test "$ac_cv_sizeof_char" = 2; then + AC_CHECK_TYPE(u_bits16_t, unsigned char) +else + AC_CHECK_TYPE(u_bits16_t, unsigned short) +fi +]) + +dnl +dnl A signed 32-bit integer quantity +dnl +AC_DEFUN(BASH_TYPE_BITS32_T, +[ +if test "$ac_cv_sizeof_int" = 4; then + AC_CHECK_TYPE(bits32_t, int) +elif test "$ac_cv_sizeof_long" = 4; then + AC_CHECK_TYPE(bits32_t, long) +else + AC_CHECK_TYPE(bits32_t, int) +fi +]) + +dnl +dnl An unsigned 32-bit integer quantity +dnl +AC_DEFUN(BASH_TYPE_U_BITS32_T, +[ +if test "$ac_cv_sizeof_int" = 4; then + AC_CHECK_TYPE(u_bits32_t, unsigned int) +elif test "$ac_cv_sizeof_long" = 4; then + AC_CHECK_TYPE(u_bits32_t, unsigned long) +else + AC_CHECK_TYPE(u_bits32_t, unsigned int) +fi +]) + +AC_DEFUN(BASH_TYPE_PTRDIFF_T, +[ +if test "$ac_cv_sizeof_int" = "$ac_cv_sizeof_char_p"; then + AC_CHECK_TYPE(ptrdiff_t, int) +elif test "$ac_cv_sizeof_long" = "$ac_cv_sizeof_char_p"; then + AC_CHECK_TYPE(ptrdiff_t, long) +elif test "$ac_cv_type_long_long" = yes && test "$ac_cv_sizeof_long_long" = "$ac_cv_sizeof_char_p"; then + AC_CHECK_TYPE(ptrdiff_t, [long long]) +else + AC_CHECK_TYPE(ptrdiff_t, int) +fi +]) + +dnl +dnl A signed 64-bit quantity +dnl +AC_DEFUN(BASH_TYPE_BITS64_T, +[ +if test "$ac_cv_sizeof_char_p" = 8; then + AC_CHECK_TYPE(bits64_t, char *) +elif test "$ac_cv_sizeof_double" = 8; then + AC_CHECK_TYPE(bits64_t, double) +elif test -n "$ac_cv_type_long_long" && test "$ac_cv_sizeof_long_long" = 8; then + AC_CHECK_TYPE(bits64_t, [long long]) +elif test "$ac_cv_sizeof_long" = 8; then + AC_CHECK_TYPE(bits64_t, long) +else + AC_CHECK_TYPE(bits64_t, double) +fi +]) + +AC_DEFUN(BASH_TYPE_LONG_LONG, +[ +AC_CACHE_CHECK([for long long], bash_cv_type_long_long, +[AC_TRY_LINK([ +long long ll = 1; int i = 63;], +[ +long long llm = (long long) -1; +return ll << i | ll >> i | llm / ll | llm % ll; +], bash_cv_type_long_long='long long', bash_cv_type_long_long='long')]) +if test "$bash_cv_type_long_long" = 'long long'; then + AC_DEFINE(HAVE_LONG_LONG, 1) +fi +]) + +AC_DEFUN(BASH_TYPE_UNSIGNED_LONG_LONG, +[ +AC_CACHE_CHECK([for unsigned long long], bash_cv_type_unsigned_long_long, +[AC_TRY_LINK([ +unsigned long long ull = 1; int i = 63;], +[ +unsigned long long ullmax = (unsigned long long) -1; +return ull << i | ull >> i | ullmax / ull | ullmax % ull; +], bash_cv_type_unsigned_long_long='unsigned long long', + bash_cv_type_unsigned_long_long='unsigned long')]) +if test "$bash_cv_type_unsigned_long_long" = 'unsigned long long'; then + AC_DEFINE(HAVE_UNSIGNED_LONG_LONG, 1) +fi +]) + +dnl +dnl Type of struct rlimit fields: some systems (OSF/1, NetBSD, RISC/os 5.0) +dnl have a rlim_t, others (4.4BSD based systems) use quad_t, others use +dnl long and still others use int (HP-UX 9.01, SunOS 4.1.3). To simplify +dnl matters, this just checks for rlim_t, quad_t, or long. +dnl +AC_DEFUN(BASH_TYPE_RLIMIT, +[AC_MSG_CHECKING(for size and type of struct rlimit fields) +AC_CACHE_VAL(bash_cv_type_rlimit, +[AC_TRY_COMPILE([#include +#include ], +[rlim_t xxx;], bash_cv_type_rlimit=rlim_t,[ +AC_TRY_RUN([ +#include +#include +#include +main() +{ +#ifdef HAVE_QUAD_T + struct rlimit rl; + if (sizeof(rl.rlim_cur) == sizeof(quad_t)) + exit(0); +#endif + exit(1); +}], bash_cv_type_rlimit=quad_t, bash_cv_type_rlimit=long, + [AC_MSG_WARN(cannot check quad_t if cross compiling -- defaulting to long) + bash_cv_type_rlimit=long])]) +]) +AC_MSG_RESULT($bash_cv_type_rlimit) +if test $bash_cv_type_rlimit = quad_t; then +AC_DEFINE(RLIMTYPE, quad_t) +elif test $bash_cv_type_rlimit = rlim_t; then +AC_DEFINE(RLIMTYPE, rlim_t) +fi +]) + +AC_DEFUN(BASH_TYPE_SIG_ATOMIC_T, +[AC_CACHE_CHECK([for sig_atomic_t in signal.h], ac_cv_have_sig_atomic_t, +[AC_TRY_LINK([ +#include +],[ sig_atomic_t x; ], +ac_cv_have_sig_atomic_t=yes, ac_cv_have_sig_atomic_t=no)]) +if test "$ac_cv_have_sig_atomic_t" = "no" +then + AC_CHECK_TYPE(sig_atomic_t,int) +fi +]) + +AC_DEFUN(BASH_FUNC_LSTAT, +[dnl Cannot use AC_CHECK_FUNCS(lstat) because Linux defines lstat() as an +dnl inline function in . +AC_CACHE_CHECK([for lstat], bash_cv_func_lstat, +[AC_TRY_LINK([ +#include +#include +],[ lstat(".",(struct stat *)0); ], +bash_cv_func_lstat=yes, bash_cv_func_lstat=no)]) +if test $bash_cv_func_lstat = yes; then + AC_DEFINE(HAVE_LSTAT) +fi +]) + +AC_DEFUN(BASH_FUNC_INET_ATON, +[ +AC_CACHE_CHECK([for inet_aton], bash_cv_func_inet_aton, +[AC_TRY_LINK([ +#include +#include +#include +struct in_addr ap;], [ inet_aton("127.0.0.1", &ap); ], +bash_cv_func_inet_aton=yes, bash_cv_func_inet_aton=no)]) +if test $bash_cv_func_inet_aton = yes; then + AC_DEFINE(HAVE_INET_ATON) +else + AC_LIBOBJ(inet_aton) +fi +]) + +AC_DEFUN(BASH_FUNC_GETENV, +[AC_MSG_CHECKING(to see if getenv can be redefined) +AC_CACHE_VAL(bash_cv_getenv_redef, +[AC_TRY_RUN([ +#ifdef HAVE_UNISTD_H +# include +#endif +#ifndef __STDC__ +# ifndef const +# define const +# endif +#endif +char * +getenv (name) +#if defined (__linux__) || defined (__bsdi__) || defined (convex) + const char *name; +#else + char const *name; +#endif /* !__linux__ && !__bsdi__ && !convex */ +{ +return "42"; +} +main() +{ +char *s; +/* The next allows this program to run, but does not allow bash to link + when it redefines getenv. I'm not really interested in figuring out + why not. */ +#if defined (NeXT) +exit(1); +#endif +s = getenv("ABCDE"); +exit(s == 0); /* force optimizer to leave getenv in */ +} +], bash_cv_getenv_redef=yes, bash_cv_getenv_redef=no, + [AC_MSG_WARN(cannot check getenv redefinition if cross compiling -- defaulting to yes) + bash_cv_getenv_redef=yes] +)]) +AC_MSG_RESULT($bash_cv_getenv_redef) +if test $bash_cv_getenv_redef = yes; then +AC_DEFINE(CAN_REDEFINE_GETENV) +fi +]) + +# We should check for putenv before calling this +AC_DEFUN(BASH_FUNC_STD_PUTENV, +[ +AC_REQUIRE([AC_HEADER_STDC]) +AC_REQUIRE([AC_C_PROTOTYPES]) +AC_CACHE_CHECK([for standard-conformant putenv declaration], bash_cv_std_putenv, +[AC_TRY_LINK([ +#if STDC_HEADERS +#include +#include +#endif +#ifndef __STDC__ +# ifndef const +# define const +# endif +#endif +#ifdef PROTOTYPES +extern int putenv (char *); +#else +extern int putenv (); +#endif +], +[return (putenv == 0);], +bash_cv_std_putenv=yes, bash_cv_std_putenv=no +)]) +if test $bash_cv_std_putenv = yes; then +AC_DEFINE(HAVE_STD_PUTENV) +fi +]) + +# We should check for unsetenv before calling this +AC_DEFUN(BASH_FUNC_STD_UNSETENV, +[ +AC_REQUIRE([AC_HEADER_STDC]) +AC_REQUIRE([AC_C_PROTOTYPES]) +AC_CACHE_CHECK([for standard-conformant unsetenv declaration], bash_cv_std_unsetenv, +[AC_TRY_LINK([ +#if STDC_HEADERS +#include +#include +#endif +#ifndef __STDC__ +# ifndef const +# define const +# endif +#endif +#ifdef PROTOTYPES +extern int unsetenv (const char *); +#else +extern int unsetenv (); +#endif +], +[return (unsetenv == 0);], +bash_cv_std_unsetenv=yes, bash_cv_std_unsetenv=no +)]) +if test $bash_cv_std_unsetenv = yes; then +AC_DEFINE(HAVE_STD_UNSETENV) +fi +]) + +AC_DEFUN(BASH_FUNC_ULIMIT_MAXFDS, +[AC_MSG_CHECKING(whether ulimit can substitute for getdtablesize) +AC_CACHE_VAL(bash_cv_ulimit_maxfds, +[AC_TRY_RUN([ +main() +{ +long maxfds = ulimit(4, 0L); +exit (maxfds == -1L); +} +], bash_cv_ulimit_maxfds=yes, bash_cv_ulimit_maxfds=no, + [AC_MSG_WARN(cannot check ulimit if cross compiling -- defaulting to no) + bash_cv_ulimit_maxfds=no] +)]) +AC_MSG_RESULT($bash_cv_ulimit_maxfds) +if test $bash_cv_ulimit_maxfds = yes; then +AC_DEFINE(ULIMIT_MAXFDS) +fi +]) + +AC_DEFUN(BASH_FUNC_GETCWD, +[AC_MSG_CHECKING([if getcwd() will dynamically allocate memory with 0 size]) +AC_CACHE_VAL(bash_cv_getcwd_malloc, +[AC_TRY_RUN([ +#include +#ifdef HAVE_UNISTD_H +#include +#endif + +main() +{ + char *xpwd; + xpwd = getcwd(0, 0); + exit (xpwd == 0); +} +], bash_cv_getcwd_malloc=yes, bash_cv_getcwd_malloc=no, + [AC_MSG_WARN(cannot check whether getcwd allocates memory when cross-compiling -- defaulting to no) + bash_cv_getcwd_malloc=no] +)]) +AC_MSG_RESULT($bash_cv_getcwd_malloc) +if test $bash_cv_getcwd_malloc = no; then +AC_DEFINE(GETCWD_BROKEN) +AC_LIBOBJ(getcwd) +fi +]) + +dnl +dnl This needs BASH_CHECK_SOCKLIB, but since that's not called on every +dnl system, we can't use AC_PREREQ +dnl +AC_DEFUN(BASH_FUNC_GETHOSTBYNAME, +[if test "X$bash_cv_have_gethostbyname" = "X"; then +_bash_needmsg=yes +else +AC_MSG_CHECKING(for gethostbyname in socket library) +_bash_needmsg= +fi +AC_CACHE_VAL(bash_cv_have_gethostbyname, +[AC_TRY_LINK([#include ], +[ struct hostent *hp; + hp = gethostbyname("localhost"); +], bash_cv_have_gethostbyname=yes, bash_cv_have_gethostbyname=no)] +) +if test "X$_bash_needmsg" = Xyes; then + AC_MSG_CHECKING(for gethostbyname in socket library) +fi +AC_MSG_RESULT($bash_cv_have_gethostbyname) +if test "$bash_cv_have_gethostbyname" = yes; then +AC_DEFINE(HAVE_GETHOSTBYNAME) +fi +]) + +AC_DEFUN(BASH_FUNC_FNMATCH_EXTMATCH, +[AC_MSG_CHECKING(if fnmatch does extended pattern matching with FNM_EXTMATCH) +AC_CACHE_VAL(bash_cv_fnm_extmatch, +[AC_TRY_RUN([ +#include + +main() +{ +#ifdef FNM_EXTMATCH + exit (0); +#else + exit (1); +#endif +} +], bash_cv_fnm_extmatch=yes, bash_cv_fnm_extmatch=no, + [AC_MSG_WARN(cannot check FNM_EXTMATCH if cross compiling -- defaulting to no) + bash_cv_fnm_extmatch=no]) +]) +AC_MSG_RESULT($bash_cv_fnm_extmatch) +if test $bash_cv_fnm_extmatch = yes; then +AC_DEFINE(HAVE_LIBC_FNM_EXTMATCH) +fi +]) + +AC_DEFUN(BASH_FUNC_POSIX_SETJMP, +[AC_REQUIRE([BASH_SYS_SIGNAL_VINTAGE]) +AC_MSG_CHECKING(for presence of POSIX-style sigsetjmp/siglongjmp) +AC_CACHE_VAL(bash_cv_func_sigsetjmp, +[AC_TRY_RUN([ +#ifdef HAVE_UNISTD_H +#include +#endif +#include +#include +#include + +main() +{ +#if !defined (_POSIX_VERSION) || !defined (HAVE_POSIX_SIGNALS) +exit (1); +#else + +int code; +sigset_t set, oset; +sigjmp_buf xx; + +/* get the mask */ +sigemptyset(&set); +sigemptyset(&oset); +sigprocmask(SIG_BLOCK, (sigset_t *)NULL, &set); +sigprocmask(SIG_BLOCK, (sigset_t *)NULL, &oset); + +/* save it */ +code = sigsetjmp(xx, 1); +if (code) + exit(0); /* could get sigmask and compare to oset here. */ + +/* change it */ +sigaddset(&set, SIGINT); +sigprocmask(SIG_BLOCK, &set, (sigset_t *)NULL); + +/* and siglongjmp */ +siglongjmp(xx, 10); +exit(1); +#endif +}], bash_cv_func_sigsetjmp=present, bash_cv_func_sigsetjmp=missing, + [AC_MSG_WARN(cannot check for sigsetjmp/siglongjmp if cross-compiling -- defaulting to missing) + bash_cv_func_sigsetjmp=missing] +)]) +AC_MSG_RESULT($bash_cv_func_sigsetjmp) +if test $bash_cv_func_sigsetjmp = present; then +AC_DEFINE(HAVE_POSIX_SIGSETJMP) +fi +]) + +AC_DEFUN(BASH_FUNC_STRCOLL, +[ +AC_MSG_CHECKING(whether or not strcoll and strcmp differ) +AC_CACHE_VAL(bash_cv_func_strcoll_broken, +[AC_TRY_RUN([ +#include +#if defined (HAVE_LOCALE_H) +#include +#endif + +main(c, v) +int c; +char *v[]; +{ + int r1, r2; + char *deflocale, *defcoll; + +#ifdef HAVE_SETLOCALE + deflocale = setlocale(LC_ALL, ""); + defcoll = setlocale(LC_COLLATE, ""); +#endif + +#ifdef HAVE_STRCOLL + /* These two values are taken from tests/glob-test. */ + r1 = strcoll("abd", "aXd"); +#else + r1 = 0; +#endif + r2 = strcmp("abd", "aXd"); + + /* These two should both be greater than 0. It is permissible for + a system to return different values, as long as the sign is the + same. */ + + /* Exit with 1 (failure) if these two values are both > 0, since + this tests whether strcoll(3) is broken with respect to strcmp(3) + in the default locale. */ + exit (r1 > 0 && r2 > 0); +} +], bash_cv_func_strcoll_broken=yes, bash_cv_func_strcoll_broken=no, + [AC_MSG_WARN(cannot check strcoll if cross compiling -- defaulting to no) + bash_cv_func_strcoll_broken=no] +)]) +AC_MSG_RESULT($bash_cv_func_strcoll_broken) +if test $bash_cv_func_strcoll_broken = yes; then +AC_DEFINE(STRCOLL_BROKEN) +fi +]) + +AC_DEFUN(BASH_FUNC_PRINTF_A_FORMAT, +[AC_MSG_CHECKING([for printf floating point output in hex notation]) +AC_CACHE_VAL(bash_cv_printf_a_format, +[AC_TRY_RUN([ +#include +#include + +int +main() +{ + double y = 0.0; + char abuf[1024]; + + sprintf(abuf, "%A", y); + exit(strchr(abuf, 'P') == (char *)0); +} +], bash_cv_printf_a_format=yes, bash_cv_printf_a_format=no, + [AC_MSG_WARN(cannot check printf if cross compiling -- defaulting to no) + bash_cv_printf_a_format=no] +)]) +AC_MSG_RESULT($bash_cv_printf_a_format) +if test $bash_cv_printf_a_format = yes; then +AC_DEFINE(HAVE_PRINTF_A_FORMAT) +fi +]) + +AC_DEFUN(BASH_STRUCT_TERMIOS_LDISC, +[ +AC_CHECK_MEMBER(struct termios.c_line, AC_DEFINE(TERMIOS_LDISC), ,[ +#include +#include +]) +]) + +AC_DEFUN(BASH_STRUCT_TERMIO_LDISC, +[ +AC_CHECK_MEMBER(struct termio.c_line, AC_DEFINE(TERMIO_LDISC), ,[ +#include +#include +]) +]) + +dnl +dnl Like AC_STRUCT_ST_BLOCKS, but doesn't muck with LIBOBJS +dnl +dnl sets bash_cv_struct_stat_st_blocks +dnl +dnl unused for now; we'll see how AC_CHECK_MEMBERS works +dnl +AC_DEFUN(BASH_STRUCT_ST_BLOCKS, +[ +AC_MSG_CHECKING([for struct stat.st_blocks]) +AC_CACHE_VAL(bash_cv_struct_stat_st_blocks, +[AC_TRY_COMPILE( +[ +#include +#include +], +[ +main() +{ +static struct stat a; +if (a.st_blocks) return 0; +return 0; +} +], bash_cv_struct_stat_st_blocks=yes, bash_cv_struct_stat_st_blocks=no) +]) +AC_MSG_RESULT($bash_cv_struct_stat_st_blocks) +if test "$bash_cv_struct_stat_st_blocks" = "yes"; then +AC_DEFINE(HAVE_STRUCT_STAT_ST_BLOCKS) +fi +]) + +AC_DEFUN([BASH_CHECK_LIB_TERMCAP], +[ +if test "X$bash_cv_termcap_lib" = "X"; then +_bash_needmsg=yes +else +AC_MSG_CHECKING(which library has the termcap functions) +_bash_needmsg= +fi +AC_CACHE_VAL(bash_cv_termcap_lib, +[AC_CHECK_FUNC(tgetent, bash_cv_termcap_lib=libc, + [AC_CHECK_LIB(termcap, tgetent, bash_cv_termcap_lib=libtermcap, + [AC_CHECK_LIB(tinfo, tgetent, bash_cv_termcap_lib=libtinfo, + [AC_CHECK_LIB(curses, tgetent, bash_cv_termcap_lib=libcurses, + [AC_CHECK_LIB(ncurses, tgetent, bash_cv_termcap_lib=libncurses, + bash_cv_termcap_lib=gnutermcap)])])])])]) +if test "X$_bash_needmsg" = "Xyes"; then +AC_MSG_CHECKING(which library has the termcap functions) +fi +AC_MSG_RESULT(using $bash_cv_termcap_lib) +if test $bash_cv_termcap_lib = gnutermcap && test -z "$prefer_curses"; then +LDFLAGS="$LDFLAGS -L./lib/termcap" +TERMCAP_LIB="./lib/termcap/libtermcap.a" +TERMCAP_DEP="./lib/termcap/libtermcap.a" +elif test $bash_cv_termcap_lib = libtermcap && test -z "$prefer_curses"; then +TERMCAP_LIB=-ltermcap +TERMCAP_DEP= +elif test $bash_cv_termcap_lib = libtinfo; then +TERMCAP_LIB=-ltinfo +TERMCAP_DEP= +elif test $bash_cv_termcap_lib = libncurses; then +TERMCAP_LIB=-lncurses +TERMCAP_DEP= +elif test $bash_cv_termcap_lib = libc; then +TERMCAP_LIB= +TERMCAP_DEP= +else +TERMCAP_LIB=-lcurses +TERMCAP_DEP= +fi +]) + +dnl +dnl Check for the presence of getpeername in libsocket. +dnl If libsocket is present, check for libnsl and add it to LIBS if +dnl it's there, since most systems with libsocket require linking +dnl with libnsl as well. This should only be called if getpeername +dnl was not found in libc. +dnl +dnl NOTE: IF WE FIND GETPEERNAME, WE ASSUME THAT WE HAVE BIND/CONNECT +dnl AS WELL +dnl +AC_DEFUN(BASH_CHECK_LIB_SOCKET, +[ +if test "X$bash_cv_have_socklib" = "X"; then +_bash_needmsg= +else +AC_MSG_CHECKING(for socket library) +_bash_needmsg=yes +fi +AC_CACHE_VAL(bash_cv_have_socklib, +[AC_CHECK_LIB(socket, getpeername, + bash_cv_have_socklib=yes, bash_cv_have_socklib=no, -lnsl)]) +if test "X$_bash_needmsg" = Xyes; then + AC_MSG_RESULT($bash_cv_have_socklib) + _bash_needmsg= +fi +if test $bash_cv_have_socklib = yes; then + # check for libnsl, add it to LIBS if present + if test "X$bash_cv_have_libnsl" = "X"; then + _bash_needmsg= + else + AC_MSG_CHECKING(for libnsl) + _bash_needmsg=yes + fi + AC_CACHE_VAL(bash_cv_have_libnsl, + [AC_CHECK_LIB(nsl, t_open, + bash_cv_have_libnsl=yes, bash_cv_have_libnsl=no)]) + if test "X$_bash_needmsg" = Xyes; then + AC_MSG_RESULT($bash_cv_have_libnsl) + _bash_needmsg= + fi + if test $bash_cv_have_libnsl = yes; then + LIBS="-lsocket -lnsl $LIBS" + else + LIBS="-lsocket $LIBS" + fi + AC_DEFINE(HAVE_LIBSOCKET) + AC_DEFINE(HAVE_GETPEERNAME) +fi +]) + +AC_DEFUN(BASH_STRUCT_DIRENT_D_INO, +[AC_REQUIRE([AC_HEADER_DIRENT]) +AC_MSG_CHECKING(for struct dirent.d_ino) +AC_CACHE_VAL(bash_cv_dirent_has_dino, +[AC_TRY_COMPILE([ +#include +#include +#ifdef HAVE_UNISTD_H +# include +#endif /* HAVE_UNISTD_H */ +#if defined(HAVE_DIRENT_H) +# include +#else +# define dirent direct +# ifdef HAVE_SYS_NDIR_H +# include +# endif /* SYSNDIR */ +# ifdef HAVE_SYS_DIR_H +# include +# endif /* SYSDIR */ +# ifdef HAVE_NDIR_H +# include +# endif +#endif /* HAVE_DIRENT_H */ +],[ +struct dirent d; int z; z = d.d_ino; +], bash_cv_dirent_has_dino=yes, bash_cv_dirent_has_dino=no)]) +AC_MSG_RESULT($bash_cv_dirent_has_dino) +if test $bash_cv_dirent_has_dino = yes; then +AC_DEFINE(HAVE_STRUCT_DIRENT_D_INO) +fi +]) + +AC_DEFUN(BASH_STRUCT_DIRENT_D_FILENO, +[AC_REQUIRE([AC_HEADER_DIRENT]) +AC_MSG_CHECKING(for struct dirent.d_fileno) +AC_CACHE_VAL(bash_cv_dirent_has_d_fileno, +[AC_TRY_COMPILE([ +#include +#include +#ifdef HAVE_UNISTD_H +# include +#endif /* HAVE_UNISTD_H */ +#if defined(HAVE_DIRENT_H) +# include +#else +# define dirent direct +# ifdef HAVE_SYS_NDIR_H +# include +# endif /* SYSNDIR */ +# ifdef HAVE_SYS_DIR_H +# include +# endif /* SYSDIR */ +# ifdef HAVE_NDIR_H +# include +# endif +#endif /* HAVE_DIRENT_H */ +],[ +struct dirent d; int z; z = d.d_fileno; +], bash_cv_dirent_has_d_fileno=yes, bash_cv_dirent_has_d_fileno=no)]) +AC_MSG_RESULT($bash_cv_dirent_has_d_fileno) +if test $bash_cv_dirent_has_d_fileno = yes; then +AC_DEFINE(HAVE_STRUCT_DIRENT_D_FILENO) +fi +]) + +AC_DEFUN(BASH_STRUCT_DIRENT_D_NAMLEN, +[AC_REQUIRE([AC_HEADER_DIRENT]) +AC_MSG_CHECKING(for struct dirent.d_namlen) +AC_CACHE_VAL(bash_cv_dirent_has_d_namlen, +[AC_TRY_COMPILE([ +#include +#include +#ifdef HAVE_UNISTD_H +# include +#endif /* HAVE_UNISTD_H */ +#if defined(HAVE_DIRENT_H) +# include +#else +# define dirent direct +# ifdef HAVE_SYS_NDIR_H +# include +# endif /* SYSNDIR */ +# ifdef HAVE_SYS_DIR_H +# include +# endif /* SYSDIR */ +# ifdef HAVE_NDIR_H +# include +# endif +#endif /* HAVE_DIRENT_H */ +],[ +struct dirent d; int z; z = d.d_namlen; +], bash_cv_dirent_has_d_namlen=yes, bash_cv_dirent_has_d_namlen=no)]) +AC_MSG_RESULT($bash_cv_dirent_has_d_namlen) +if test $bash_cv_dirent_has_d_namlen = yes; then +AC_DEFINE(HAVE_STRUCT_DIRENT_D_NAMLEN) +fi +]) + +AC_DEFUN(BASH_STRUCT_TIMEVAL, +[AC_MSG_CHECKING(for struct timeval in sys/time.h and time.h) +AC_CACHE_VAL(bash_cv_struct_timeval, +[ +AC_EGREP_HEADER(struct timeval, sys/time.h, + bash_cv_struct_timeval=yes, + AC_EGREP_HEADER(struct timeval, time.h, + bash_cv_struct_timeval=yes, + bash_cv_struct_timeval=no)) +]) +AC_MSG_RESULT($bash_cv_struct_timeval) +if test $bash_cv_struct_timeval = yes; then + AC_DEFINE(HAVE_TIMEVAL) +fi +]) + +AC_DEFUN(BASH_STRUCT_TIMEZONE, +[AC_MSG_CHECKING(for struct timezone in sys/time.h and time.h) +AC_CACHE_VAL(bash_cv_struct_timezone, +[ +AC_EGREP_HEADER(struct timezone, sys/time.h, + bash_cv_struct_timezone=yes, + AC_EGREP_HEADER(struct timezone, time.h, + bash_cv_struct_timezone=yes, + bash_cv_struct_timezone=no)) +]) +AC_MSG_RESULT($bash_cv_struct_timezone) +if test $bash_cv_struct_timezone = yes; then + AC_DEFINE(HAVE_STRUCT_TIMEZONE) +fi +]) + +AC_DEFUN(BASH_STRUCT_WINSIZE, +[AC_MSG_CHECKING(for struct winsize in sys/ioctl.h and termios.h) +AC_CACHE_VAL(bash_cv_struct_winsize_header, +[AC_TRY_COMPILE([#include +#include ], [struct winsize x;], + bash_cv_struct_winsize_header=ioctl_h, + [AC_TRY_COMPILE([#include +#include ], [struct winsize x;], + bash_cv_struct_winsize_header=termios_h, bash_cv_struct_winsize_header=other) +])]) +if test $bash_cv_struct_winsize_header = ioctl_h; then + AC_MSG_RESULT(sys/ioctl.h) + AC_DEFINE(STRUCT_WINSIZE_IN_SYS_IOCTL) +elif test $bash_cv_struct_winsize_header = termios_h; then + AC_MSG_RESULT(termios.h) + AC_DEFINE(STRUCT_WINSIZE_IN_TERMIOS) +else + AC_MSG_RESULT(not found) +fi +]) + +dnl Check type of signal routines (posix, 4.2bsd, 4.1bsd or v7) +AC_DEFUN(BASH_SYS_SIGNAL_VINTAGE, +[AC_REQUIRE([AC_TYPE_SIGNAL]) +AC_MSG_CHECKING(for type of signal functions) +AC_CACHE_VAL(bash_cv_signal_vintage, +[ + AC_TRY_LINK([#include ],[ + sigset_t ss; + struct sigaction sa; + sigemptyset(&ss); sigsuspend(&ss); + sigaction(SIGINT, &sa, (struct sigaction *) 0); + sigprocmask(SIG_BLOCK, &ss, (sigset_t *) 0); + ], bash_cv_signal_vintage=posix, + [ + AC_TRY_LINK([#include ], [ + int mask = sigmask(SIGINT); + sigsetmask(mask); sigblock(mask); sigpause(mask); + ], bash_cv_signal_vintage=4.2bsd, + [ + AC_TRY_LINK([ + #include + RETSIGTYPE foo() { }], [ + int mask = sigmask(SIGINT); + sigset(SIGINT, foo); sigrelse(SIGINT); + sighold(SIGINT); sigpause(SIGINT); + ], bash_cv_signal_vintage=svr3, bash_cv_signal_vintage=v7 + )] + )] +) +]) +AC_MSG_RESULT($bash_cv_signal_vintage) +if test "$bash_cv_signal_vintage" = posix; then +AC_DEFINE(HAVE_POSIX_SIGNALS) +elif test "$bash_cv_signal_vintage" = "4.2bsd"; then +AC_DEFINE(HAVE_BSD_SIGNALS) +elif test "$bash_cv_signal_vintage" = svr3; then +AC_DEFINE(HAVE_USG_SIGHOLD) +fi +]) + +dnl Check if the pgrp of setpgrp() can't be the pid of a zombie process. +AC_DEFUN(BASH_SYS_PGRP_SYNC, +[AC_REQUIRE([AC_FUNC_GETPGRP]) +AC_MSG_CHECKING(whether pgrps need synchronization) +AC_CACHE_VAL(bash_cv_pgrp_pipe, +[AC_TRY_RUN([ +#ifdef HAVE_UNISTD_H +# include +#endif +main() +{ +# ifdef GETPGRP_VOID +# define getpgID() getpgrp() +# else +# define getpgID() getpgrp(0) +# define setpgid(x,y) setpgrp(x,y) +# endif + int pid1, pid2, fds[2]; + int status; + char ok; + + switch (pid1 = fork()) { + case -1: + exit(1); + case 0: + setpgid(0, getpid()); + exit(0); + } + setpgid(pid1, pid1); + + sleep(2); /* let first child die */ + + if (pipe(fds) < 0) + exit(2); + + switch (pid2 = fork()) { + case -1: + exit(3); + case 0: + setpgid(0, pid1); + ok = getpgID() == pid1; + write(fds[1], &ok, 1); + exit(0); + } + setpgid(pid2, pid1); + + close(fds[1]); + if (read(fds[0], &ok, 1) != 1) + exit(4); + wait(&status); + wait(&status); + exit(ok ? 0 : 5); +} +], bash_cv_pgrp_pipe=no,bash_cv_pgrp_pipe=yes, + [AC_MSG_WARN(cannot check pgrp synchronization if cross compiling -- defaulting to no) + bash_cv_pgrp_pipe=no]) +]) +AC_MSG_RESULT($bash_cv_pgrp_pipe) +if test $bash_cv_pgrp_pipe = yes; then +AC_DEFINE(PGRP_PIPE) +fi +]) + +AC_DEFUN(BASH_SYS_REINSTALL_SIGHANDLERS, +[AC_REQUIRE([AC_TYPE_SIGNAL]) +AC_REQUIRE([BASH_SYS_SIGNAL_VINTAGE]) +AC_MSG_CHECKING([if signal handlers must be reinstalled when invoked]) +AC_CACHE_VAL(bash_cv_must_reinstall_sighandlers, +[AC_TRY_RUN([ +#include +#ifdef HAVE_UNISTD_H +#include +#endif + +typedef RETSIGTYPE sigfunc(); + +int nsigint; + +#ifdef HAVE_POSIX_SIGNALS +sigfunc * +set_signal_handler(sig, handler) + int sig; + sigfunc *handler; +{ + struct sigaction act, oact; + act.sa_handler = handler; + act.sa_flags = 0; + sigemptyset (&act.sa_mask); + sigemptyset (&oact.sa_mask); + sigaction (sig, &act, &oact); + return (oact.sa_handler); +} +#else +#define set_signal_handler(s, h) signal(s, h) +#endif + +RETSIGTYPE +sigint(s) +int s; +{ + nsigint++; +} + +main() +{ + nsigint = 0; + set_signal_handler(SIGINT, sigint); + kill((int)getpid(), SIGINT); + kill((int)getpid(), SIGINT); + exit(nsigint != 2); +} +], bash_cv_must_reinstall_sighandlers=no, bash_cv_must_reinstall_sighandlers=yes, + [AC_MSG_WARN(cannot check signal handling if cross compiling -- defaulting to no) + bash_cv_must_reinstall_sighandlers=no] +)]) +AC_MSG_RESULT($bash_cv_must_reinstall_sighandlers) +if test $bash_cv_must_reinstall_sighandlers = yes; then +AC_DEFINE(MUST_REINSTALL_SIGHANDLERS) +fi +]) + +dnl check that some necessary job control definitions are present +AC_DEFUN(BASH_SYS_JOB_CONTROL_MISSING, +[AC_REQUIRE([BASH_SYS_SIGNAL_VINTAGE]) +AC_MSG_CHECKING(for presence of necessary job control definitions) +AC_CACHE_VAL(bash_cv_job_control_missing, +[AC_TRY_RUN([ +#include +#ifdef HAVE_SYS_WAIT_H +#include +#endif +#ifdef HAVE_UNISTD_H +#include +#endif +#include + +/* Add more tests in here as appropriate. */ +main() +{ +/* signal type */ +#if !defined (HAVE_POSIX_SIGNALS) && !defined (HAVE_BSD_SIGNALS) +exit(1); +#endif + +/* signals and tty control. */ +#if !defined (SIGTSTP) || !defined (SIGSTOP) || !defined (SIGCONT) +exit (1); +#endif + +/* process control */ +#if !defined (WNOHANG) || !defined (WUNTRACED) +exit(1); +#endif + +/* Posix systems have tcgetpgrp and waitpid. */ +#if defined (_POSIX_VERSION) && !defined (HAVE_TCGETPGRP) +exit(1); +#endif + +#if defined (_POSIX_VERSION) && !defined (HAVE_WAITPID) +exit(1); +#endif + +/* Other systems have TIOCSPGRP/TIOCGPRGP and wait3. */ +#if !defined (_POSIX_VERSION) && !defined (HAVE_WAIT3) +exit(1); +#endif + +exit(0); +}], bash_cv_job_control_missing=present, bash_cv_job_control_missing=missing, + [AC_MSG_WARN(cannot check job control if cross-compiling -- defaulting to missing) + bash_cv_job_control_missing=missing] +)]) +AC_MSG_RESULT($bash_cv_job_control_missing) +if test $bash_cv_job_control_missing = missing; then +AC_DEFINE(JOB_CONTROL_MISSING) +fi +]) + +dnl check whether named pipes are present +dnl this requires a previous check for mkfifo, but that is awkward to specify +AC_DEFUN(BASH_SYS_NAMED_PIPES, +[AC_MSG_CHECKING(for presence of named pipes) +AC_CACHE_VAL(bash_cv_sys_named_pipes, +[AC_TRY_RUN([ +#include +#include +#ifdef HAVE_UNISTD_H +#include +#endif + +/* Add more tests in here as appropriate. */ +main() +{ +int fd, err; + +#if defined (HAVE_MKFIFO) +exit (0); +#endif + +#if !defined (S_IFIFO) && (defined (_POSIX_VERSION) && !defined (S_ISFIFO)) +exit (1); +#endif + +#if defined (NeXT) +exit (1); +#endif +err = mkdir("bash-aclocal", 0700); +if (err < 0) { + perror ("mkdir"); + exit(1); +} +fd = mknod ("bash-aclocal/sh-np-autoconf", 0666 | S_IFIFO, 0); +if (fd == -1) { + rmdir ("bash-aclocal"); + exit (1); +} +close(fd); +unlink ("bash-aclocal/sh-np-autoconf"); +rmdir ("bash-aclocal"); +exit(0); +}], bash_cv_sys_named_pipes=present, bash_cv_sys_named_pipes=missing, + [AC_MSG_WARN(cannot check for named pipes if cross-compiling -- defaulting to missing) + bash_cv_sys_named_pipes=missing] +)]) +AC_MSG_RESULT($bash_cv_sys_named_pipes) +if test $bash_cv_sys_named_pipes = missing; then +AC_DEFINE(NAMED_PIPES_MISSING) +fi +]) + +AC_DEFUN(BASH_SYS_DEFAULT_MAIL_DIR, +[AC_MSG_CHECKING(for default mail directory) +AC_CACHE_VAL(bash_cv_mail_dir, +[if test -d /var/mail; then + bash_cv_mail_dir=/var/mail + elif test -d /var/spool/mail; then + bash_cv_mail_dir=/var/spool/mail + elif test -d /usr/mail; then + bash_cv_mail_dir=/usr/mail + elif test -d /usr/spool/mail; then + bash_cv_mail_dir=/usr/spool/mail + else + bash_cv_mail_dir=unknown + fi +]) +AC_MSG_RESULT($bash_cv_mail_dir) +AC_DEFINE_UNQUOTED(DEFAULT_MAIL_DIRECTORY, "$bash_cv_mail_dir") +]) + +AC_DEFUN(BASH_HAVE_TIOCGWINSZ, +[AC_MSG_CHECKING(for TIOCGWINSZ in sys/ioctl.h) +AC_CACHE_VAL(bash_cv_tiocgwinsz_in_ioctl, +[AC_TRY_COMPILE([#include +#include ], [int x = TIOCGWINSZ;], + bash_cv_tiocgwinsz_in_ioctl=yes,bash_cv_tiocgwinsz_in_ioctl=no)]) +AC_MSG_RESULT($bash_cv_tiocgwinsz_in_ioctl) +if test $bash_cv_tiocgwinsz_in_ioctl = yes; then +AC_DEFINE(GWINSZ_IN_SYS_IOCTL) +fi +]) + +AC_DEFUN(BASH_HAVE_TIOCSTAT, +[AC_MSG_CHECKING(for TIOCSTAT in sys/ioctl.h) +AC_CACHE_VAL(bash_cv_tiocstat_in_ioctl, +[AC_TRY_COMPILE([#include +#include ], [int x = TIOCSTAT;], + bash_cv_tiocstat_in_ioctl=yes,bash_cv_tiocstat_in_ioctl=no)]) +AC_MSG_RESULT($bash_cv_tiocstat_in_ioctl) +if test $bash_cv_tiocstat_in_ioctl = yes; then +AC_DEFINE(TIOCSTAT_IN_SYS_IOCTL) +fi +]) + +AC_DEFUN(BASH_HAVE_FIONREAD, +[AC_MSG_CHECKING(for FIONREAD in sys/ioctl.h) +AC_CACHE_VAL(bash_cv_fionread_in_ioctl, +[AC_TRY_COMPILE([#include +#include ], [int x = FIONREAD;], + bash_cv_fionread_in_ioctl=yes,bash_cv_fionread_in_ioctl=no)]) +AC_MSG_RESULT($bash_cv_fionread_in_ioctl) +if test $bash_cv_fionread_in_ioctl = yes; then +AC_DEFINE(FIONREAD_IN_SYS_IOCTL) +fi +]) + +dnl +dnl See if speed_t is declared in . Some versions of linux +dnl require a definition of speed_t each time is included, +dnl but you can only get speed_t if you include (on some +dnl versions) or (on others). +dnl +AC_DEFUN(BASH_CHECK_SPEED_T, +[AC_MSG_CHECKING(for speed_t in sys/types.h) +AC_CACHE_VAL(bash_cv_speed_t_in_sys_types, +[AC_TRY_COMPILE([#include ], [speed_t x;], + bash_cv_speed_t_in_sys_types=yes,bash_cv_speed_t_in_sys_types=no)]) +AC_MSG_RESULT($bash_cv_speed_t_in_sys_types) +if test $bash_cv_speed_t_in_sys_types = yes; then +AC_DEFINE(SPEED_T_IN_SYS_TYPES) +fi +]) + +AC_DEFUN(BASH_CHECK_GETPW_FUNCS, +[AC_MSG_CHECKING(whether getpw functions are declared in pwd.h) +AC_CACHE_VAL(bash_cv_getpw_declared, +[AC_EGREP_CPP(getpwuid, +[ +#include +#ifdef HAVE_UNISTD_H +# include +#endif +#include +], +bash_cv_getpw_declared=yes,bash_cv_getpw_declared=no)]) +AC_MSG_RESULT($bash_cv_getpw_declared) +if test $bash_cv_getpw_declared = yes; then +AC_DEFINE(HAVE_GETPW_DECLS) +fi +]) + +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 && (exec test -r /dev/fd/0 < /dev/null) ; then +# check for systems like FreeBSD 5 that only provide /dev/fd/[012] + if (exec test -r /dev/fd/3 3 +#include +], +[ + int f; + f = RLIMIT_DATA; +], bash_cv_kernel_rlimit=no, +[AC_TRY_COMPILE([ +#include +#define _KERNEL +#include +#undef _KERNEL +], +[ + int f; + f = RLIMIT_DATA; +], bash_cv_kernel_rlimit=yes, bash_cv_kernel_rlimit=no)] +)]) +AC_MSG_RESULT($bash_cv_kernel_rlimit) +if test $bash_cv_kernel_rlimit = yes; then +AC_DEFINE(RLIMIT_NEEDS_KERNEL) +fi +]) + +dnl +dnl Check for 64-bit off_t -- used for malloc alignment +dnl +dnl C does not allow duplicate case labels, so the compile will fail if +dnl sizeof(off_t) is > 4. +dnl +AC_DEFUN(BASH_CHECK_OFF_T_64, +[AC_CACHE_CHECK(for 64-bit off_t, bash_cv_off_t_64, +AC_TRY_COMPILE([ +#ifdef HAVE_UNISTD_H +#include +#endif +#include +],[ +switch (0) case 0: case (sizeof (off_t) <= 4):; +], bash_cv_off_t_64=no, bash_cv_off_t_64=yes)) +if test $bash_cv_off_t_64 = yes; then + AC_DEFINE(HAVE_OFF_T_64) +fi]) + +AC_DEFUN(BASH_CHECK_RTSIGS, +[AC_MSG_CHECKING(for unusable real-time signals due to large values) +AC_CACHE_VAL(bash_cv_unusable_rtsigs, +[AC_TRY_RUN([ +#include +#include + +#ifndef NSIG +# define NSIG 64 +#endif + +main () +{ + int n_sigs = 2 * NSIG; +#ifdef SIGRTMIN + int rtmin = SIGRTMIN; +#else + int rtmin = 0; +#endif + + exit(rtmin < n_sigs); +}], bash_cv_unusable_rtsigs=yes, bash_cv_unusable_rtsigs=no, + [AC_MSG_WARN(cannot check real-time signals if cross compiling -- defaulting to yes) + bash_cv_unusable_rtsigs=yes] +)]) +AC_MSG_RESULT($bash_cv_unusable_rtsigs) +if test $bash_cv_unusable_rtsigs = yes; then +AC_DEFINE(UNUSABLE_RT_SIGNALS) +fi +]) + +dnl +dnl check for availability of multibyte characters and functions +dnl +dnl geez, I wish I didn't have to check for all of this stuff separately +dnl +AC_DEFUN(BASH_CHECK_MULTIBYTE, +[ +AC_CHECK_HEADERS(wctype.h) +AC_CHECK_HEADERS(wchar.h) +AC_CHECK_HEADERS(langinfo.h) + +AC_CHECK_HEADERS(mbstr.h) + +AC_CHECK_FUNC(mbrlen, AC_DEFINE(HAVE_MBRLEN)) +AC_CHECK_FUNC(mbscasecmp, AC_DEFINE(HAVE_MBSCMP)) +AC_CHECK_FUNC(mbscmp, AC_DEFINE(HAVE_MBSCMP)) +AC_CHECK_FUNC(mbsnrtowcs, AC_DEFINE(HAVE_MBSNRTOWCS)) +AC_CHECK_FUNC(mbsrtowcs, AC_DEFINE(HAVE_MBSRTOWCS)) + +AC_REPLACE_FUNCS(mbschr) + +AC_CHECK_FUNC(wcrtomb, AC_DEFINE(HAVE_WCRTOMB)) +AC_CHECK_FUNC(wcscoll, AC_DEFINE(HAVE_WCSCOLL)) +AC_CHECK_FUNC(wcsdup, AC_DEFINE(HAVE_WCSDUP)) +AC_CHECK_FUNC(wcwidth, AC_DEFINE(HAVE_WCWIDTH)) +AC_CHECK_FUNC(wctype, AC_DEFINE(HAVE_WCTYPE)) + +AC_REPLACE_FUNCS(wcswidth) + +dnl checks for both mbrtowc and mbstate_t +AC_FUNC_MBRTOWC +if test $ac_cv_func_mbrtowc = yes; then + AC_DEFINE(HAVE_MBSTATE_T) +fi + +AC_CHECK_FUNCS(iswlower iswupper towlower towupper iswctype) + +AC_CACHE_CHECK([for nl_langinfo and CODESET], bash_cv_langinfo_codeset, +[AC_TRY_LINK( +[#include ], +[char* cs = nl_langinfo(CODESET);], +bash_cv_langinfo_codeset=yes, bash_cv_langinfo_codeset=no)]) +if test $bash_cv_langinfo_codeset = yes; then + AC_DEFINE(HAVE_LANGINFO_CODESET) +fi + +dnl check for wchar_t in +AC_CACHE_CHECK([for wchar_t in wchar.h], bash_cv_type_wchar_t, +[AC_TRY_COMPILE( +[#include +], +[ + wchar_t foo; + foo = 0; +], bash_cv_type_wchar_t=yes, bash_cv_type_wchar_t=no)]) +if test $bash_cv_type_wchar_t = yes; then + AC_DEFINE(HAVE_WCHAR_T, 1, [systems should define this type here]) +fi + +dnl check for wctype_t in +AC_CACHE_CHECK([for wctype_t in wctype.h], bash_cv_type_wctype_t, +[AC_TRY_COMPILE( +[#include ], +[ + wctype_t foo; + foo = 0; +], bash_cv_type_wctype_t=yes, bash_cv_type_wctype_t=no)]) +if test $bash_cv_type_wctype_t = yes; then + AC_DEFINE(HAVE_WCTYPE_T, 1, [systems should define this type here]) +fi + +dnl check for wint_t in +AC_CACHE_CHECK([for wint_t in wctype.h], bash_cv_type_wint_t, +[AC_TRY_COMPILE( +[#include ], +[ + wint_t foo; + foo = 0; +], bash_cv_type_wint_t=yes, bash_cv_type_wint_t=no)]) +if test $bash_cv_type_wint_t = yes; then + AC_DEFINE(HAVE_WINT_T, 1, [systems should define this type here]) +fi + +dnl check for broken wcwidth +AC_CACHE_CHECK([for wcwidth broken with unicode combining characters], +bash_cv_wcwidth_broken, +[AC_TRY_RUN([ +#include +#include +#include + +#include +#include + +main(c, v) +int c; +char **v; +{ + int w; + + setlocale(LC_ALL, "en_US.UTF-8"); + w = wcwidth (0x0301); + exit (w == 0); /* exit 0 if wcwidth broken */ +} +], +bash_cv_wcwidth_broken=yes, bash_cv_wcwidth_broken=no, bash_cv_wcwidth_broken=no)]) +if test "$bash_cv_wcwidth_broken" = yes; then + AC_DEFINE(WCWIDTH_BROKEN, 1, [wcwidth is usually not broken]) +fi + +if test "$am_cv_func_iconv" = yes; then + OLDLIBS="$LIBS" + LIBS="$LIBS $LIBINTL $LIBICONV" + AC_CHECK_FUNCS(locale_charset) + LIBS="$OLDLIBS" +fi + +]) + +dnl need: prefix exec_prefix libdir includedir CC TERMCAP_LIB +dnl require: +dnl AC_PROG_CC +dnl BASH_CHECK_LIB_TERMCAP + +AC_DEFUN([RL_LIB_READLINE_VERSION], +[ +AC_REQUIRE([BASH_CHECK_LIB_TERMCAP]) + +AC_MSG_CHECKING([version of installed readline library]) + +# What a pain in the ass this is. + +# save cpp and ld options +_save_CFLAGS="$CFLAGS" +_save_LDFLAGS="$LDFLAGS" +_save_LIBS="$LIBS" + +# Don't set ac_cv_rl_prefix if the caller has already assigned a value. This +# allows the caller to do something like $_rl_prefix=$withval if the user +# specifies --with-installed-readline=PREFIX as an argument to configure + +if test -z "$ac_cv_rl_prefix"; then +test "x$prefix" = xNONE && ac_cv_rl_prefix=$ac_default_prefix || ac_cv_rl_prefix=${prefix} +fi + +eval ac_cv_rl_includedir=${ac_cv_rl_prefix}/include +eval ac_cv_rl_libdir=${ac_cv_rl_prefix}/lib + +LIBS="$LIBS -lreadline ${TERMCAP_LIB}" +CFLAGS="$CFLAGS -I${ac_cv_rl_includedir}" +LDFLAGS="$LDFLAGS -L${ac_cv_rl_libdir}" + +AC_CACHE_VAL(ac_cv_rl_version, +[AC_TRY_RUN([ +#include +#include + +extern int rl_gnu_readline_p; + +main() +{ + FILE *fp; + fp = fopen("conftest.rlv", "w"); + if (fp == 0) + exit(1); + if (rl_gnu_readline_p != 1) + fprintf(fp, "0.0\n"); + else + fprintf(fp, "%s\n", rl_library_version ? rl_library_version : "0.0"); + fclose(fp); + exit(0); +} +], +ac_cv_rl_version=`cat conftest.rlv`, +ac_cv_rl_version='0.0', +ac_cv_rl_version='6.3')]) + +CFLAGS="$_save_CFLAGS" +LDFLAGS="$_save_LDFLAGS" +LIBS="$_save_LIBS" + +RL_MAJOR=0 +RL_MINOR=0 + +# ( +case "$ac_cv_rl_version" in +2*|3*|4*|5*|6*|7*|8*|9*) + RL_MAJOR=`echo $ac_cv_rl_version | sed 's:\..*$::'` + RL_MINOR=`echo $ac_cv_rl_version | sed -e 's:^.*\.::' -e 's:[[a-zA-Z]]*$::'` + ;; +esac + +# ((( +case $RL_MAJOR in +[[0-9][0-9]]) _RL_MAJOR=$RL_MAJOR ;; +[[0-9]]) _RL_MAJOR=0$RL_MAJOR ;; +*) _RL_MAJOR=00 ;; +esac + +# ((( +case $RL_MINOR in +[[0-9][0-9]]) _RL_MINOR=$RL_MINOR ;; +[[0-9]]) _RL_MINOR=0$RL_MINOR ;; +*) _RL_MINOR=00 ;; +esac + +RL_VERSION="0x${_RL_MAJOR}${_RL_MINOR}" + +# Readline versions greater than 4.2 have these defines in readline.h + +if test $ac_cv_rl_version = '0.0' ; then + AC_MSG_WARN([Could not test version of installed readline library.]) +elif test $RL_MAJOR -gt 4 || { test $RL_MAJOR = 4 && test $RL_MINOR -gt 2 ; } ; then + # set these for use by the caller + RL_PREFIX=$ac_cv_rl_prefix + RL_LIBDIR=$ac_cv_rl_libdir + RL_INCLUDEDIR=$ac_cv_rl_includedir + AC_MSG_RESULT($ac_cv_rl_version) +else + +AC_DEFINE_UNQUOTED(RL_READLINE_VERSION, $RL_VERSION, [encoded version of the installed readline library]) +AC_DEFINE_UNQUOTED(RL_VERSION_MAJOR, $RL_MAJOR, [major version of installed readline library]) +AC_DEFINE_UNQUOTED(RL_VERSION_MINOR, $RL_MINOR, [minor version of installed readline library]) + +AC_SUBST(RL_VERSION) +AC_SUBST(RL_MAJOR) +AC_SUBST(RL_MINOR) + +# set these for use by the caller +RL_PREFIX=$ac_cv_rl_prefix +RL_LIBDIR=$ac_cv_rl_libdir +RL_INCLUDEDIR=$ac_cv_rl_includedir + +AC_MSG_RESULT($ac_cv_rl_version) + +fi +]) + +AC_DEFUN(BASH_FUNC_CTYPE_NONASCII, +[ +AC_MSG_CHECKING(whether the ctype macros accept non-ascii characters) +AC_CACHE_VAL(bash_cv_func_ctype_nonascii, +[AC_TRY_RUN([ +#ifdef HAVE_LOCALE_H +#include +#endif +#include +#include + +main(c, v) +int c; +char *v[]; +{ + char *deflocale; + unsigned char x; + int r1, r2; + +#ifdef HAVE_SETLOCALE + /* We take a shot here. If that locale is not known, try the + system default. We try this one because '\342' (226) is + known to be a printable character in that locale. */ + deflocale = setlocale(LC_ALL, "en_US.ISO8859-1"); + if (deflocale == 0) + deflocale = setlocale(LC_ALL, ""); +#endif + + x = '\342'; + r1 = isprint(x); + x -= 128; + r2 = isprint(x); + exit (r1 == 0 || r2 == 0); +} +], bash_cv_func_ctype_nonascii=yes, bash_cv_func_ctype_nonascii=no, + [AC_MSG_WARN(cannot check ctype macros if cross compiling -- defaulting to no) + bash_cv_func_ctype_nonascii=no] +)]) +AC_MSG_RESULT($bash_cv_func_ctype_nonascii) +if test $bash_cv_func_ctype_nonascii = yes; then +AC_DEFINE(CTYPE_NON_ASCII) +fi +]) + +AC_DEFUN(BASH_CHECK_WCONTINUED, +[ +AC_MSG_CHECKING(whether WCONTINUED flag to waitpid is unavailable or available but broken) +AC_CACHE_VAL(bash_cv_wcontinued_broken, +[AC_TRY_RUN([ +#include +#include +#include +#include + +#ifndef errno +extern int errno; +#endif +main() +{ + int x; + + x = waitpid(-1, (int *)0, WNOHANG|WCONTINUED); + if (x == -1 && errno == EINVAL) + exit (1); + else + exit (0); +} +], bash_cv_wcontinued_broken=no,bash_cv_wcontinued_broken=yes, + [AC_MSG_WARN(cannot check WCONTINUED if cross compiling -- defaulting to no) + bash_cv_wcontinued_broken=no] +)]) +AC_MSG_RESULT($bash_cv_wcontinued_broken) +if test $bash_cv_wcontinued_broken = yes; then +AC_DEFINE(WCONTINUED_BROKEN) +fi +]) + +dnl +dnl tests added for bashdb +dnl + + +AC_DEFUN([AM_PATH_LISPDIR], + [AC_ARG_WITH(lispdir, AC_HELP_STRING([--with-lispdir], [override the default lisp directory]), + [ lispdir="$withval" + AC_MSG_CHECKING([where .elc files should go]) + AC_MSG_RESULT([$lispdir])], + [ + # If set to t, that means we are running in a shell under Emacs. + # If you have an Emacs named "t", then use the full path. + test x"$EMACS" = xt && EMACS= + AC_CHECK_PROGS(EMACS, emacs xemacs, no) + if test $EMACS != "no"; then + if test x${lispdir+set} != xset; then + AC_CACHE_CHECK([where .elc files should go], [am_cv_lispdir], [dnl + am_cv_lispdir=`$EMACS -batch -q -eval '(while load-path (princ (concat (car load-path) "\n")) (setq load-path (cdr load-path)))' | sed -n -e 's,/$,,' -e '/.*\/lib\/\(x\?emacs\/site-lisp\)$/{s,,${libdir}/\1,;p;q;}' -e '/.*\/share\/\(x\?emacs\/site-lisp\)$/{s,,${datadir}/\1,;p;q;}'` + if test -z "$am_cv_lispdir"; then + am_cv_lispdir='${datadir}/emacs/site-lisp' + fi + ]) + lispdir="$am_cv_lispdir" + fi + fi + ]) + AC_SUBST(lispdir) +]) + +dnl +dnl tests added for gettext +dnl +# codeset.m4 serial AM1 (gettext-0.10.40) +dnl Copyright (C) 2000-2002 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. + +dnl From Bruno Haible. + +AC_DEFUN([AM_LANGINFO_CODESET], +[ + AC_CACHE_CHECK([for nl_langinfo and CODESET], am_cv_langinfo_codeset, + [AC_TRY_LINK([#include ], + [char* cs = nl_langinfo(CODESET);], + am_cv_langinfo_codeset=yes, + am_cv_langinfo_codeset=no) + ]) + if test $am_cv_langinfo_codeset = yes; then + AC_DEFINE(HAVE_LANGINFO_CODESET, 1, + [Define if you have and nl_langinfo(CODESET).]) + fi +]) +# gettext.m4 serial 20 (gettext-0.12) +dnl Copyright (C) 1995-2003 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. +dnl +dnl This file can can be used in projects which are not available under +dnl the GNU General Public License or the GNU Library General Public +dnl License but which still want to provide support for the GNU gettext +dnl functionality. +dnl Please note that the actual code of the GNU gettext library is covered +dnl by the GNU Library General Public License, and the rest of the GNU +dnl gettext package package is covered by the GNU General Public License. +dnl They are *not* in the public domain. + +dnl Authors: +dnl Ulrich Drepper , 1995-2000. +dnl Bruno Haible , 2000-2003. + +dnl Macro to add for using GNU gettext. + +dnl Usage: AM_GNU_GETTEXT([INTLSYMBOL], [NEEDSYMBOL], [INTLDIR]). +dnl INTLSYMBOL can be one of 'external', 'no-libtool', 'use-libtool'. The +dnl default (if it is not specified or empty) is 'no-libtool'. +dnl INTLSYMBOL should be 'external' for packages with no intl directory, +dnl and 'no-libtool' or 'use-libtool' for packages with an intl directory. +dnl If INTLSYMBOL is 'use-libtool', then a libtool library +dnl $(top_builddir)/intl/libintl.la will be created (shared and/or static, +dnl depending on --{enable,disable}-{shared,static} and on the presence of +dnl AM-DISABLE-SHARED). If INTLSYMBOL is 'no-libtool', a static library +dnl $(top_builddir)/intl/libintl.a will be created. +dnl If NEEDSYMBOL is specified and is 'need-ngettext', then GNU gettext +dnl implementations (in libc or libintl) without the ngettext() function +dnl will be ignored. If NEEDSYMBOL is specified and is +dnl 'need-formatstring-macros', then GNU gettext implementations that don't +dnl support the ISO C 99 formatstring macros will be ignored. +dnl INTLDIR is used to find the intl libraries. If empty, +dnl the value `$(top_builddir)/intl/' is used. +dnl +dnl The result of the configuration is one of three cases: +dnl 1) GNU gettext, as included in the intl subdirectory, will be compiled +dnl and used. +dnl Catalog format: GNU --> install in $(datadir) +dnl Catalog extension: .mo after installation, .gmo in source tree +dnl 2) GNU gettext has been found in the system's C library. +dnl Catalog format: GNU --> install in $(datadir) +dnl Catalog extension: .mo after installation, .gmo in source tree +dnl 3) No internationalization, always use English msgid. +dnl Catalog format: none +dnl Catalog extension: none +dnl If INTLSYMBOL is 'external', only cases 2 and 3 can occur. +dnl The use of .gmo is historical (it was needed to avoid overwriting the +dnl GNU format catalogs when building on a platform with an X/Open gettext), +dnl but we keep it in order not to force irrelevant filename changes on the +dnl maintainers. +dnl +AC_DEFUN([AM_GNU_GETTEXT], +[ + dnl Argument checking. + ifelse([$1], [], , [ifelse([$1], [external], , [ifelse([$1], [no-libtool], , [ifelse([$1], [use-libtool], , + [errprint([ERROR: invalid first argument to AM_GNU_GETTEXT +])])])])]) + ifelse([$2], [], , [ifelse([$2], [need-ngettext], , [ifelse([$2], [need-formatstring-macros], , + [errprint([ERROR: invalid second argument to AM_GNU_GETTEXT +])])])]) + define(gt_included_intl, ifelse([$1], [external], [no], [yes])) + define(gt_libtool_suffix_prefix, ifelse([$1], [use-libtool], [l], [])) + + AC_REQUIRE([AM_PO_SUBDIRS])dnl + ifelse(gt_included_intl, yes, [ + AC_REQUIRE([AM_INTL_SUBDIR])dnl + ]) + + dnl Prerequisites of AC_LIB_LINKFLAGS_BODY. + AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) + AC_REQUIRE([AC_LIB_RPATH]) + + dnl Sometimes libintl requires libiconv, so first search for libiconv. + dnl Ideally we would do this search only after the + dnl if test "$USE_NLS" = "yes"; then + dnl if test "$gt_cv_func_gnugettext_libc" != "yes"; then + dnl tests. But if configure.in invokes AM_ICONV after AM_GNU_GETTEXT + dnl the configure script would need to contain the same shell code + dnl again, outside any 'if'. There are two solutions: + dnl - Invoke AM_ICONV_LINKFLAGS_BODY here, outside any 'if'. + dnl - Control the expansions in more detail using AC_PROVIDE_IFELSE. + dnl Since AC_PROVIDE_IFELSE is only in autoconf >= 2.52 and not + dnl documented, we avoid it. + ifelse(gt_included_intl, yes, , [ + AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY]) + ]) + + dnl Set USE_NLS. + AM_NLS + + ifelse(gt_included_intl, yes, [ + BUILD_INCLUDED_LIBINTL=no + USE_INCLUDED_LIBINTL=no + ]) + LIBINTL= + LTLIBINTL= + POSUB= + + dnl If we use NLS figure out what method + if test "$USE_NLS" = "yes"; then + gt_use_preinstalled_gnugettext=no + ifelse(gt_included_intl, yes, [ + AC_MSG_CHECKING([whether included gettext is requested]) + AC_ARG_WITH(included-gettext, + [ --with-included-gettext use the GNU gettext library included here], + nls_cv_force_use_gnu_gettext=$withval, + nls_cv_force_use_gnu_gettext=no) + AC_MSG_RESULT($nls_cv_force_use_gnu_gettext) + + nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext" + if test "$nls_cv_force_use_gnu_gettext" != "yes"; then + ]) + dnl User does not insist on using GNU NLS library. Figure out what + dnl to use. If GNU gettext is available we use this. Else we have + dnl to fall back to GNU NLS library. + + dnl Add a version number to the cache macros. + define([gt_api_version], ifelse([$2], [need-formatstring-macros], 3, ifelse([$2], [need-ngettext], 2, 1))) + define([gt_cv_func_gnugettext_libc], [gt_cv_func_gnugettext]gt_api_version[_libc]) + define([gt_cv_func_gnugettext_libintl], [gt_cv_func_gnugettext]gt_api_version[_libintl]) + + AC_CACHE_CHECK([for GNU gettext in libc], gt_cv_func_gnugettext_libc, + [AC_TRY_LINK([#include +]ifelse([$2], [need-formatstring-macros], +[#ifndef __GNU_GETTEXT_SUPPORTED_REVISION +#define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1) +#endif +changequote(,)dnl +typedef int array [2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1]; +changequote([,])dnl +], [])[extern int _nl_msg_cat_cntr; +extern int *_nl_domain_bindings;], + [bindtextdomain ("", ""); +return (int) gettext ("")]ifelse([$2], [need-ngettext], [ + (int) ngettext ("", "", 0)], [])[ + _nl_msg_cat_cntr + *_nl_domain_bindings], + gt_cv_func_gnugettext_libc=yes, + gt_cv_func_gnugettext_libc=no)]) + + if test "$gt_cv_func_gnugettext_libc" != "yes"; then + dnl Sometimes libintl requires libiconv, so first search for libiconv. + ifelse(gt_included_intl, yes, , [ + AM_ICONV_LINK + ]) + dnl Search for libintl and define LIBINTL, LTLIBINTL and INCINTL + dnl accordingly. Don't use AC_LIB_LINKFLAGS_BODY([intl],[iconv]) + dnl because that would add "-liconv" to LIBINTL and LTLIBINTL + dnl even if libiconv doesn't exist. + AC_LIB_LINKFLAGS_BODY([intl]) + AC_CACHE_CHECK([for GNU gettext in libintl], + gt_cv_func_gnugettext_libintl, + [gt_save_CPPFLAGS="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS $INCINTL" + gt_save_LIBS="$LIBS" + LIBS="$LIBS $LIBINTL" + dnl Now see whether libintl exists and does not depend on libiconv. + AC_TRY_LINK([#include +]ifelse([$2], [need-formatstring-macros], +[#ifndef __GNU_GETTEXT_SUPPORTED_REVISION +#define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1) +#endif +changequote(,)dnl +typedef int array [2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1]; +changequote([,])dnl +], [])[extern int _nl_msg_cat_cntr; +extern +#ifdef __cplusplus +"C" +#endif +const char *_nl_expand_alias ();], + [bindtextdomain ("", ""); +return (int) gettext ("")]ifelse([$2], [need-ngettext], [ + (int) ngettext ("", "", 0)], [])[ + _nl_msg_cat_cntr + *_nl_expand_alias (0)], + gt_cv_func_gnugettext_libintl=yes, + gt_cv_func_gnugettext_libintl=no) + dnl Now see whether libintl exists and depends on libiconv. + if test "$gt_cv_func_gnugettext_libintl" != yes && test -n "$LIBICONV"; then + LIBS="$LIBS $LIBICONV" + AC_TRY_LINK([#include +]ifelse([$2], [need-formatstring-macros], +[#ifndef __GNU_GETTEXT_SUPPORTED_REVISION +#define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1) +#endif +changequote(,)dnl +typedef int array [2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1]; +changequote([,])dnl +], [])[extern int _nl_msg_cat_cntr; +extern +#ifdef __cplusplus +"C" +#endif +const char *_nl_expand_alias ();], + [bindtextdomain ("", ""); +return (int) gettext ("")]ifelse([$2], [need-ngettext], [ + (int) ngettext ("", "", 0)], [])[ + _nl_msg_cat_cntr + *_nl_expand_alias (0)], + [LIBINTL="$LIBINTL $LIBICONV" + LTLIBINTL="$LTLIBINTL $LTLIBICONV" + gt_cv_func_gnugettext_libintl=yes + ]) + fi + CPPFLAGS="$gt_save_CPPFLAGS" + LIBS="$gt_save_LIBS"]) + fi + + dnl If an already present or preinstalled GNU gettext() is found, + dnl use it. But if this macro is used in GNU gettext, and GNU + dnl gettext is already preinstalled in libintl, we update this + dnl libintl. (Cf. the install rule in intl/Makefile.in.) + if test "$gt_cv_func_gnugettext_libc" = "yes" \ + || { test "$gt_cv_func_gnugettext_libintl" = "yes" \ + && test "$PACKAGE" != gettext-runtime \ + && test "$PACKAGE" != gettext-tools; }; then + gt_use_preinstalled_gnugettext=yes + else + dnl Reset the values set by searching for libintl. + LIBINTL= + LTLIBINTL= + INCINTL= + fi + + ifelse(gt_included_intl, yes, [ + if test "$gt_use_preinstalled_gnugettext" != "yes"; then + dnl GNU gettext is not found in the C library. + dnl Fall back on included GNU gettext library. + nls_cv_use_gnu_gettext=yes + fi + fi + + if test "$nls_cv_use_gnu_gettext" = "yes"; then + dnl Mark actions used to generate GNU NLS library. + BUILD_INCLUDED_LIBINTL=yes + USE_INCLUDED_LIBINTL=yes + LIBINTL="ifelse([$3],[],\${top_builddir}/intl,[$3])/libintl.[]gt_libtool_suffix_prefix[]a $LIBICONV" + LTLIBINTL="ifelse([$3],[],\${top_builddir}/intl,[$3])/libintl.[]gt_libtool_suffix_prefix[]a $LTLIBICONV" + LIBS=`echo " $LIBS " | sed -e 's/ -lintl / /' -e 's/^ //' -e 's/ $//'` + fi + + if test "$gt_use_preinstalled_gnugettext" = "yes" \ + || test "$nls_cv_use_gnu_gettext" = "yes"; then + dnl Mark actions to use GNU gettext tools. + CATOBJEXT=.gmo + fi + ]) + + if test "$gt_use_preinstalled_gnugettext" = "yes" \ + || test "$nls_cv_use_gnu_gettext" = "yes"; then + AC_DEFINE(ENABLE_NLS, 1, + [Define to 1 if translation of program messages to the user's native language + is requested.]) + else + USE_NLS=no + fi + fi + + AC_MSG_CHECKING([whether to use NLS]) + AC_MSG_RESULT([$USE_NLS]) + if test "$USE_NLS" = "yes"; then + AC_MSG_CHECKING([where the gettext function comes from]) + if test "$gt_use_preinstalled_gnugettext" = "yes"; then + if test "$gt_cv_func_gnugettext_libintl" = "yes"; then + gt_source="external libintl" + else + gt_source="libc" + fi + else + gt_source="included intl directory" + fi + AC_MSG_RESULT([$gt_source]) + fi + + if test "$USE_NLS" = "yes"; then + + if test "$gt_use_preinstalled_gnugettext" = "yes"; then + if test "$gt_cv_func_gnugettext_libintl" = "yes"; then + AC_MSG_CHECKING([how to link with libintl]) + AC_MSG_RESULT([$LIBINTL]) + AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCINTL]) + fi + + dnl For backward compatibility. Some packages may be using this. + AC_DEFINE(HAVE_GETTEXT, 1, + [Define if the GNU gettext() function is already present or preinstalled.]) + AC_DEFINE(HAVE_DCGETTEXT, 1, + [Define if the GNU dcgettext() function is already present or preinstalled.]) + fi + + dnl We need to process the po/ directory. + POSUB=po + fi + + ifelse(gt_included_intl, yes, [ + dnl If this is used in GNU gettext we have to set BUILD_INCLUDED_LIBINTL + dnl to 'yes' because some of the testsuite requires it. + if test "$PACKAGE" = gettext-runtime || test "$PACKAGE" = gettext-tools; then + BUILD_INCLUDED_LIBINTL=yes + fi + + dnl Make all variables we use known to autoconf. + AC_SUBST(BUILD_INCLUDED_LIBINTL) + AC_SUBST(USE_INCLUDED_LIBINTL) + AC_SUBST(CATOBJEXT) + + dnl For backward compatibility. Some configure.ins may be using this. + nls_cv_header_intl= + nls_cv_header_libgt= + + dnl For backward compatibility. Some Makefiles may be using this. + DATADIRNAME=share + AC_SUBST(DATADIRNAME) + + dnl For backward compatibility. Some Makefiles may be using this. + INSTOBJEXT=.mo + AC_SUBST(INSTOBJEXT) + + dnl For backward compatibility. Some Makefiles may be using this. + GENCAT=gencat + AC_SUBST(GENCAT) + + dnl For backward compatibility. Some Makefiles may be using this. + if test "$USE_INCLUDED_LIBINTL" = yes; then + INTLOBJS="\$(GETTOBJS)" + fi + AC_SUBST(INTLOBJS) + + dnl Enable libtool support if the surrounding package wishes it. + INTL_LIBTOOL_SUFFIX_PREFIX=gt_libtool_suffix_prefix + AC_SUBST(INTL_LIBTOOL_SUFFIX_PREFIX) + ]) + + dnl For backward compatibility. Some Makefiles may be using this. + INTLLIBS="$LIBINTL" + AC_SUBST(INTLLIBS) + + dnl Make all documented variables known to autoconf. + AC_SUBST(LIBINTL) + AC_SUBST(LTLIBINTL) + AC_SUBST(POSUB) +]) + + +dnl Checks for all prerequisites of the intl subdirectory, +dnl except for INTL_LIBTOOL_SUFFIX_PREFIX (and possibly LIBTOOL), INTLOBJS, +dnl USE_INCLUDED_LIBINTL, BUILD_INCLUDED_LIBINTL. +AC_DEFUN([AM_INTL_SUBDIR], +[ + AC_REQUIRE([AC_PROG_INSTALL])dnl + AC_REQUIRE([AM_MKINSTALLDIRS])dnl + AC_REQUIRE([AC_PROG_CC])dnl + AC_REQUIRE([AC_CANONICAL_HOST])dnl + AC_REQUIRE([AC_PROG_RANLIB])dnl + AC_REQUIRE([AC_ISC_POSIX])dnl + AC_REQUIRE([AC_HEADER_STDC])dnl + AC_REQUIRE([AC_C_CONST])dnl + AC_REQUIRE([AC_C_INLINE])dnl + AC_REQUIRE([AC_TYPE_OFF_T])dnl + AC_REQUIRE([AC_TYPE_SIZE_T])dnl + AC_REQUIRE([AC_FUNC_ALLOCA])dnl + AC_REQUIRE([AC_FUNC_MMAP])dnl + AC_REQUIRE([jm_GLIBC21])dnl + AC_REQUIRE([gt_INTDIV0])dnl + AC_REQUIRE([jm_AC_TYPE_UINTMAX_T])dnl + AC_REQUIRE([gt_HEADER_INTTYPES_H])dnl + AC_REQUIRE([gt_INTTYPES_PRI])dnl + + 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 localeconv stpcpy \ +strcasecmp strdup strtoul tsearch __argz_count __argz_stringify __argz_next \ +__fsetlocking]) + + AM_ICONV + AM_LANGINFO_CODESET + if test $ac_cv_header_locale_h = yes; then + AM_LC_MESSAGES + fi + + dnl intl/plural.c is generated from intl/plural.y. It requires bison, + dnl because plural.y uses bison specific features. It requires at least + dnl bison-1.26 because earlier versions generate a plural.c that doesn't + dnl compile. + dnl bison is only needed for the maintainer (who touches plural.y). But in + dnl order to avoid separate Makefiles or --enable-maintainer-mode, we put + dnl the rule in general Makefile. Now, some people carelessly touch the + dnl files or have a broken "make" program, hence the plural.c rule will + dnl sometimes fire. To avoid an error, defines BISON to ":" if it is not + dnl present or too old. + AC_CHECK_PROGS([INTLBISON], [bison]) + if test -z "$INTLBISON"; then + ac_verc_fail=yes + else + dnl Found it, now check the version. + AC_MSG_CHECKING([version of bison]) +changequote(<<,>>)dnl + ac_prog_version=`$INTLBISON --version 2>&1 | sed -n 's/^.*GNU Bison.* \([0-9]*\.[0-9.]*\).*$/\1/p'` + case $ac_prog_version in + '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;; + 1.2[6-9]* | 1.[3-9][0-9]* | [2-9].*) +changequote([,])dnl + ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;; + *) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;; + esac + AC_MSG_RESULT([$ac_prog_version]) + fi + if test $ac_verc_fail = yes; then + INTLBISON=: + fi +]) + + +dnl Usage: AM_GNU_GETTEXT_VERSION([gettext-version]) +AC_DEFUN([AM_GNU_GETTEXT_VERSION], []) +# glibc21.m4 serial 2 (fileutils-4.1.3, gettext-0.10.40) +dnl Copyright (C) 2000-2002 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. + +# Test for the GNU C Library, version 2.1 or newer. +# From Bruno Haible. + +AC_DEFUN([jm_GLIBC21], + [ + AC_CACHE_CHECK(whether we are using the GNU C Library 2.1 or newer, + ac_cv_gnu_library_2_1, + [AC_EGREP_CPP([Lucky GNU user], + [ +#include +#ifdef __GNU_LIBRARY__ + #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2) + Lucky GNU user + #endif +#endif + ], + ac_cv_gnu_library_2_1=yes, + ac_cv_gnu_library_2_1=no) + ] + ) + AC_SUBST(GLIBC21) + GLIBC21="$ac_cv_gnu_library_2_1" + ] +) +# iconv.m4 serial AM4 (gettext-0.11.3) +dnl Copyright (C) 2000-2002 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. + +dnl From Bruno Haible. + +AC_DEFUN([AM_ICONV_LINKFLAGS_BODY], +[ + dnl Prerequisites of AC_LIB_LINKFLAGS_BODY. + AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) + AC_REQUIRE([AC_LIB_RPATH]) + + dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV + dnl accordingly. + AC_LIB_LINKFLAGS_BODY([iconv]) +]) + +AC_DEFUN([AM_ICONV_LINK], +[ + dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and + dnl those with the standalone portable GNU libiconv installed). + + dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV + dnl accordingly. + AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY]) + + dnl Add $INCICONV to CPPFLAGS before performing the following checks, + dnl because if the user has installed libiconv and not disabled its use + dnl via --without-libiconv-prefix, he wants to use it. The first + dnl AC_TRY_LINK will then fail, the second AC_TRY_LINK will succeed. + am_save_CPPFLAGS="$CPPFLAGS" + AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCICONV]) + + AC_CACHE_CHECK(for iconv, am_cv_func_iconv, [ + am_cv_func_iconv="no, consider installing GNU libiconv" + am_cv_lib_iconv=no + AC_TRY_LINK([#include +#include ], + [iconv_t cd = iconv_open("",""); + iconv(cd,NULL,NULL,NULL,NULL); + iconv_close(cd);], + am_cv_func_iconv=yes) + if test "$am_cv_func_iconv" != yes; then + am_save_LIBS="$LIBS" + LIBS="$LIBS $LIBICONV" + AC_TRY_LINK([#include +#include ], + [iconv_t cd = iconv_open("",""); + iconv(cd,NULL,NULL,NULL,NULL); + iconv_close(cd);], + am_cv_lib_iconv=yes + am_cv_func_iconv=yes) + LIBS="$am_save_LIBS" + fi + ]) + if test "$am_cv_func_iconv" = yes; then + AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.]) + fi + if test "$am_cv_lib_iconv" = yes; then + AC_MSG_CHECKING([how to link with libiconv]) + AC_MSG_RESULT([$LIBICONV]) + else + dnl If $LIBICONV didn't lead to a usable library, we don't need $INCICONV + dnl either. + CPPFLAGS="$am_save_CPPFLAGS" + LIBICONV= + LTLIBICONV= + fi + AC_SUBST(LIBICONV) + AC_SUBST(LTLIBICONV) +]) + +AC_DEFUN([AM_ICONV], +[ + AM_ICONV_LINK + if test "$am_cv_func_iconv" = yes; then + AC_MSG_CHECKING([for iconv declaration]) + AC_CACHE_VAL(am_cv_proto_iconv, [ + AC_TRY_COMPILE([ +#include +#include +extern +#ifdef __cplusplus +"C" +#endif +#if defined(__STDC__) || defined(__cplusplus) +size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft); +#else +size_t iconv(); +#endif +], [], am_cv_proto_iconv_arg1="", am_cv_proto_iconv_arg1="const") + am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"]) + am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'` + AC_MSG_RESULT([$]{ac_t:- + }[$]am_cv_proto_iconv) + AC_DEFINE_UNQUOTED(ICONV_CONST, $am_cv_proto_iconv_arg1, + [Define as const if the declaration of iconv() needs const.]) + fi +]) +# intdiv0.m4 serial 1 (gettext-0.11.3) +dnl Copyright (C) 2002 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. + +dnl From Bruno Haible. + +AC_DEFUN([gt_INTDIV0], +[ + AC_REQUIRE([AC_PROG_CC])dnl + AC_REQUIRE([AC_CANONICAL_HOST])dnl + + AC_CACHE_CHECK([whether integer division by zero raises SIGFPE], + gt_cv_int_divbyzero_sigfpe, + [ + AC_TRY_RUN([ +#include +#include + +static void +#ifdef __cplusplus +sigfpe_handler (int sig) +#else +sigfpe_handler (sig) int sig; +#endif +{ + /* Exit with code 0 if SIGFPE, with code 1 if any other signal. */ + exit (sig != SIGFPE); +} + +int x = 1; +int y = 0; +int z; +int nan; + +int main () +{ + signal (SIGFPE, sigfpe_handler); +/* IRIX and AIX (when "xlc -qcheck" is used) yield signal SIGTRAP. */ +#if (defined (__sgi) || defined (_AIX)) && defined (SIGTRAP) + signal (SIGTRAP, sigfpe_handler); +#endif +/* Linux/SPARC yields signal SIGILL. */ +#if defined (__sparc__) && defined (__linux__) + signal (SIGILL, sigfpe_handler); +#endif + + z = x / y; + nan = y / y; + exit (1); +} +], gt_cv_int_divbyzero_sigfpe=yes, gt_cv_int_divbyzero_sigfpe=no, + [ + # Guess based on the CPU. + case "$host_cpu" in + alpha* | i[34567]86 | m68k | s390*) + gt_cv_int_divbyzero_sigfpe="guessing yes";; + *) + gt_cv_int_divbyzero_sigfpe="guessing no";; + esac + ]) + ]) + case "$gt_cv_int_divbyzero_sigfpe" in + *yes) value=1;; + *) value=0;; + esac + AC_DEFINE_UNQUOTED(INTDIV0_RAISES_SIGFPE, $value, + [Define if integer division by zero raises signal SIGFPE.]) +]) +# inttypes.m4 serial 1 (gettext-0.11.4) +dnl Copyright (C) 1997-2002 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. + +dnl From Paul Eggert. + +# Define HAVE_INTTYPES_H if exists and doesn't clash with +# . + +AC_DEFUN([gt_HEADER_INTTYPES_H], +[ + AC_CACHE_CHECK([for inttypes.h], gt_cv_header_inttypes_h, + [ + AC_TRY_COMPILE( + [#include +#include ], + [], gt_cv_header_inttypes_h=yes, gt_cv_header_inttypes_h=no) + ]) + if test $gt_cv_header_inttypes_h = yes; then + AC_DEFINE_UNQUOTED(HAVE_INTTYPES_H, 1, + [Define if exists and doesn't clash with .]) + fi +]) +# inttypes_h.m4 serial 5 (gettext-0.12) +dnl Copyright (C) 1997-2003 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. + +dnl From Paul Eggert. + +# Define HAVE_INTTYPES_H_WITH_UINTMAX if exists, +# doesn't clash with , and declares uintmax_t. + +AC_DEFUN([jm_AC_HEADER_INTTYPES_H], +[ + AC_CACHE_CHECK([for inttypes.h], jm_ac_cv_header_inttypes_h, + [AC_TRY_COMPILE( + [#include +#include ], + [uintmax_t i = (uintmax_t) -1;], + jm_ac_cv_header_inttypes_h=yes, + jm_ac_cv_header_inttypes_h=no)]) + if test $jm_ac_cv_header_inttypes_h = yes; then + AC_DEFINE_UNQUOTED(HAVE_INTTYPES_H_WITH_UINTMAX, 1, + [Define if exists, doesn't clash with , + and declares uintmax_t. ]) + fi +]) +# inttypes-pri.m4 serial 1 (gettext-0.11.4) +dnl Copyright (C) 1997-2002 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. + +dnl From Bruno Haible. + +# Define PRI_MACROS_BROKEN if exists and defines the PRI* +# macros to non-string values. This is the case on AIX 4.3.3. + +AC_DEFUN([gt_INTTYPES_PRI], +[ + AC_REQUIRE([gt_HEADER_INTTYPES_H]) + if test $gt_cv_header_inttypes_h = yes; then + AC_CACHE_CHECK([whether the inttypes.h PRIxNN macros are broken], + gt_cv_inttypes_pri_broken, + [ + AC_TRY_COMPILE([#include +#ifdef PRId32 +char *p = PRId32; +#endif +], [], gt_cv_inttypes_pri_broken=no, gt_cv_inttypes_pri_broken=yes) + ]) + fi + if test "$gt_cv_inttypes_pri_broken" = yes; then + AC_DEFINE_UNQUOTED(PRI_MACROS_BROKEN, 1, + [Define if exists and defines unusable PRI* macros.]) + fi +]) +# isc-posix.m4 serial 2 (gettext-0.11.2) +dnl Copyright (C) 1995-2002 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. + +# This file is not needed with autoconf-2.53 and newer. Remove it in 2005. + +# This test replaces the one in autoconf. +# Currently this macro should have the same name as the autoconf macro +# because gettext's gettext.m4 (distributed in the automake package) +# still uses it. Otherwise, the use in gettext.m4 makes autoheader +# give these diagnostics: +# configure.in:556: AC_TRY_COMPILE was called before AC_ISC_POSIX +# configure.in:556: AC_TRY_RUN was called before AC_ISC_POSIX + +undefine([AC_ISC_POSIX]) + +AC_DEFUN([AC_ISC_POSIX], + [ + dnl This test replaces the obsolescent AC_ISC_POSIX kludge. + AC_CHECK_LIB(cposix, strerror, [LIBS="$LIBS -lcposix"]) + ] +) +# lcmessage.m4 serial 3 (gettext-0.11.3) +dnl Copyright (C) 1995-2002 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. +dnl +dnl This file can can be used in projects which are not available under +dnl the GNU General Public License or the GNU Library General Public +dnl License but which still want to provide support for the GNU gettext +dnl functionality. +dnl Please note that the actual code of the GNU gettext library is covered +dnl by the GNU Library General Public License, and the rest of the GNU +dnl gettext package package is covered by the GNU General Public License. +dnl They are *not* in the public domain. + +dnl Authors: +dnl Ulrich Drepper , 1995. + +# Check whether LC_MESSAGES is available in . + +AC_DEFUN([AM_LC_MESSAGES], +[ + AC_CACHE_CHECK([for LC_MESSAGES], am_cv_val_LC_MESSAGES, + [AC_TRY_LINK([#include ], [return LC_MESSAGES], + am_cv_val_LC_MESSAGES=yes, am_cv_val_LC_MESSAGES=no)]) + if test $am_cv_val_LC_MESSAGES = yes; then + AC_DEFINE(HAVE_LC_MESSAGES, 1, + [Define if your file defines LC_MESSAGES.]) + fi +]) +# lib-ld.m4 serial 2 (gettext-0.12) +dnl Copyright (C) 1996-2003 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. + +dnl Subroutines of libtool.m4, +dnl with replacements s/AC_/AC_LIB/ and s/lt_cv/acl_cv/ to avoid collision +dnl with libtool.m4. + +dnl From libtool-1.4. Sets the variable with_gnu_ld to yes or no. +AC_DEFUN([AC_LIB_PROG_LD_GNU], +[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], acl_cv_prog_gnu_ld, +[# I'd rather use --version here, but apparently some GNU ld's only accept -v. +if $LD -v 2>&1 &5; then + acl_cv_prog_gnu_ld=yes +else + acl_cv_prog_gnu_ld=no +fi]) +with_gnu_ld=$acl_cv_prog_gnu_ld +]) + +dnl From libtool-1.4. Sets the variable LD. +AC_DEFUN([AC_LIB_PROG_LD], +[AC_ARG_WITH(gnu-ld, +[ --with-gnu-ld assume the C compiler uses GNU ld [default=no]], +test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no) +AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([AC_CANONICAL_HOST])dnl +# Prepare PATH_SEPARATOR. +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh +fi +ac_prog=ld +if test "$GCC" = yes; then + # Check if gcc -print-prog-name=ld gives a path. + AC_MSG_CHECKING([for ld used by GCC]) + case $host in + *-*-mingw*) + # gcc leaves a trailing carriage return which upsets mingw + ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; + *) + ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; + esac + case $ac_prog in + # Accept absolute paths. + [[\\/]* | [A-Za-z]:[\\/]*)] + [re_direlt='/[^/][^/]*/\.\./'] + # Canonicalize the path of ld + ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'` + while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do + ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"` + done + test -z "$LD" && LD="$ac_prog" + ;; + "") + # If it fails, then pretend we aren't using GCC. + ac_prog=ld + ;; + *) + # If it is relative, then search for the first ld in PATH. + with_gnu_ld=unknown + ;; + esac +elif test "$with_gnu_ld" = yes; then + AC_MSG_CHECKING([for GNU ld]) +else + AC_MSG_CHECKING([for non-GNU ld]) +fi +AC_CACHE_VAL(acl_cv_path_LD, +[if test -z "$LD"; then + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}" + for ac_dir in $PATH; do + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then + acl_cv_path_LD="$ac_dir/$ac_prog" + # Check to see if the program is GNU ld. I'd rather use --version, + # but apparently some GNU ld's only accept -v. + # Break only if it was the GNU/non-GNU ld that we prefer. + if "$acl_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then + test "$with_gnu_ld" != no && break + else + test "$with_gnu_ld" != yes && break + fi + fi + done + IFS="$ac_save_ifs" +else + acl_cv_path_LD="$LD" # Let the user override the test with a path. +fi]) +LD="$acl_cv_path_LD" +if test -n "$LD"; then + AC_MSG_RESULT($LD) +else + AC_MSG_RESULT(no) +fi +test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH]) +AC_LIB_PROG_LD_GNU +]) +# lib-link.m4 serial 4 (gettext-0.12) +dnl Copyright (C) 2001-2003 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. + +dnl From Bruno Haible. + +dnl AC_LIB_LINKFLAGS(name [, dependencies]) searches for libname and +dnl the libraries corresponding to explicit and implicit dependencies. +dnl Sets and AC_SUBSTs the LIB${NAME} and LTLIB${NAME} variables and +dnl augments the CPPFLAGS variable. +AC_DEFUN([AC_LIB_LINKFLAGS], +[ + AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) + AC_REQUIRE([AC_LIB_RPATH]) + define([Name],[translit([$1],[./-], [___])]) + define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], + [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) + AC_CACHE_CHECK([how to link with lib[]$1], [ac_cv_lib[]Name[]_libs], [ + AC_LIB_LINKFLAGS_BODY([$1], [$2]) + ac_cv_lib[]Name[]_libs="$LIB[]NAME" + ac_cv_lib[]Name[]_ltlibs="$LTLIB[]NAME" + ac_cv_lib[]Name[]_cppflags="$INC[]NAME" + ]) + LIB[]NAME="$ac_cv_lib[]Name[]_libs" + LTLIB[]NAME="$ac_cv_lib[]Name[]_ltlibs" + INC[]NAME="$ac_cv_lib[]Name[]_cppflags" + AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME) + AC_SUBST([LIB]NAME) + AC_SUBST([LTLIB]NAME) + dnl Also set HAVE_LIB[]NAME so that AC_LIB_HAVE_LINKFLAGS can reuse the + dnl results of this search when this library appears as a dependency. + HAVE_LIB[]NAME=yes + undefine([Name]) + undefine([NAME]) +]) + +dnl AC_LIB_HAVE_LINKFLAGS(name, dependencies, includes, testcode) +dnl searches for libname and the libraries corresponding to explicit and +dnl implicit dependencies, together with the specified include files and +dnl the ability to compile and link the specified testcode. If found, it +dnl sets and AC_SUBSTs HAVE_LIB${NAME}=yes and the LIB${NAME} and +dnl LTLIB${NAME} variables and augments the CPPFLAGS variable, and +dnl #defines HAVE_LIB${NAME} to 1. Otherwise, it sets and AC_SUBSTs +dnl HAVE_LIB${NAME}=no and LIB${NAME} and LTLIB${NAME} to empty. +AC_DEFUN([AC_LIB_HAVE_LINKFLAGS], +[ + AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) + AC_REQUIRE([AC_LIB_RPATH]) + define([Name],[translit([$1],[./-], [___])]) + define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], + [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) + + dnl Search for lib[]Name and define LIB[]NAME, LTLIB[]NAME and INC[]NAME + dnl accordingly. + AC_LIB_LINKFLAGS_BODY([$1], [$2]) + + dnl Add $INC[]NAME to CPPFLAGS before performing the following checks, + dnl because if the user has installed lib[]Name and not disabled its use + dnl via --without-lib[]Name-prefix, he wants to use it. + ac_save_CPPFLAGS="$CPPFLAGS" + AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME) + + AC_CACHE_CHECK([for lib[]$1], [ac_cv_lib[]Name], [ + ac_save_LIBS="$LIBS" + LIBS="$LIBS $LIB[]NAME" + AC_TRY_LINK([$3], [$4], [ac_cv_lib[]Name=yes], [ac_cv_lib[]Name=no]) + LIBS="$ac_save_LIBS" + ]) + if test "$ac_cv_lib[]Name" = yes; then + HAVE_LIB[]NAME=yes + AC_DEFINE([HAVE_LIB]NAME, 1, [Define if you have the $1 library.]) + AC_MSG_CHECKING([how to link with lib[]$1]) + AC_MSG_RESULT([$LIB[]NAME]) + else + HAVE_LIB[]NAME=no + dnl If $LIB[]NAME didn't lead to a usable library, we don't need + dnl $INC[]NAME either. + CPPFLAGS="$ac_save_CPPFLAGS" + LIB[]NAME= + LTLIB[]NAME= + fi + AC_SUBST([HAVE_LIB]NAME) + AC_SUBST([LIB]NAME) + AC_SUBST([LTLIB]NAME) + undefine([Name]) + undefine([NAME]) +]) + +dnl Determine the platform dependent parameters needed to use rpath: +dnl libext, shlibext, hardcode_libdir_flag_spec, hardcode_libdir_separator, +dnl hardcode_direct, hardcode_minus_L. +AC_DEFUN([AC_LIB_RPATH], +[ + AC_REQUIRE([AC_PROG_CC]) dnl we use $CC, $GCC, $LDFLAGS + AC_REQUIRE([AC_LIB_PROG_LD]) dnl we use $LD, $with_gnu_ld + AC_REQUIRE([AC_CANONICAL_HOST]) dnl we use $host + AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT]) dnl we use $ac_aux_dir + AC_CACHE_CHECK([for shared library run path origin], acl_cv_rpath, [ + CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \ + ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh + . ./conftest.sh + rm -f ./conftest.sh + acl_cv_rpath=done + ]) + wl="$acl_cv_wl" + libext="$acl_cv_libext" + shlibext="$acl_cv_shlibext" + hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec" + hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator" + hardcode_direct="$acl_cv_hardcode_direct" + hardcode_minus_L="$acl_cv_hardcode_minus_L" + dnl Determine whether the user wants rpath handling at all. + AC_ARG_ENABLE(rpath, + [ --disable-rpath do not hardcode runtime library paths], + :, enable_rpath=yes) +]) + +dnl AC_LIB_LINKFLAGS_BODY(name [, dependencies]) searches for libname and +dnl the libraries corresponding to explicit and implicit dependencies. +dnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables. +AC_DEFUN([AC_LIB_LINKFLAGS_BODY], +[ + define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], + [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) + dnl By default, look in $includedir and $libdir. + use_additional=yes + AC_LIB_WITH_FINAL_PREFIX([ + eval additional_includedir=\"$includedir\" + eval additional_libdir=\"$libdir\" + ]) + AC_LIB_ARG_WITH([lib$1-prefix], +[ --with-lib$1-prefix[=DIR] search for lib$1 in DIR/include and DIR/lib + --without-lib$1-prefix don't search for lib$1 in includedir and libdir], +[ + if test "X$withval" = "Xno"; then + use_additional=no + else + if test "X$withval" = "X"; then + AC_LIB_WITH_FINAL_PREFIX([ + eval additional_includedir=\"$includedir\" + eval additional_libdir=\"$libdir\" + ]) + else + additional_includedir="$withval/include" + additional_libdir="$withval/lib" + fi + fi +]) + dnl Search the library and its dependencies in $additional_libdir and + dnl $LDFLAGS. Using breadth-first-seach. + LIB[]NAME= + LTLIB[]NAME= + INC[]NAME= + rpathdirs= + ltrpathdirs= + names_already_handled= + names_next_round='$1 $2' + while test -n "$names_next_round"; do + names_this_round="$names_next_round" + names_next_round= + for name in $names_this_round; do + already_handled= + for n in $names_already_handled; do + if test "$n" = "$name"; then + already_handled=yes + break + fi + done + if test -z "$already_handled"; then + names_already_handled="$names_already_handled $name" + dnl See if it was already located by an earlier AC_LIB_LINKFLAGS + dnl or AC_LIB_HAVE_LINKFLAGS call. + uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'` + eval value=\"\$HAVE_LIB$uppername\" + if test -n "$value"; then + if test "$value" = yes; then + eval value=\"\$LIB$uppername\" + test -z "$value" || LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$value" + eval value=\"\$LTLIB$uppername\" + test -z "$value" || LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$value" + else + dnl An earlier call to AC_LIB_HAVE_LINKFLAGS has determined + dnl that this library doesn't exist. So just drop it. + : + fi + else + dnl Search the library lib$name in $additional_libdir and $LDFLAGS + dnl and the already constructed $LIBNAME/$LTLIBNAME. + found_dir= + found_la= + found_so= + found_a= + if test $use_additional = yes; then + if test "X$prefer_shared" = "Xyes" && test -n "$shlibext" && test -f "$additional_libdir/lib$name.$shlibext"; then + found_dir="$additional_libdir" + found_so="$additional_libdir/lib$name.$shlibext" + if test -f "$additional_libdir/lib$name.la"; then + found_la="$additional_libdir/lib$name.la" + fi + else + if test -f "$additional_libdir/lib$name.$libext"; then + found_dir="$additional_libdir" + found_a="$additional_libdir/lib$name.$libext" + if test -f "$additional_libdir/lib$name.la"; then + found_la="$additional_libdir/lib$name.la" + fi + fi + fi + fi + if test "X$found_dir" = "X"; then + for x in $LDFLAGS $LTLIB[]NAME; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + case "$x" in + -L*) + dir=`echo "X$x" | sed -e 's/^X-L//'` + if test "X$prefer_shared" = "Xyes" && test -n "$shlibext" && test -f "$dir/lib$name.$shlibext"; then + found_dir="$dir" + found_so="$dir/lib$name.$shlibext" + if test -f "$dir/lib$name.la"; then + found_la="$dir/lib$name.la" + fi + else + if test -f "$dir/lib$name.$libext"; then + found_dir="$dir" + found_a="$dir/lib$name.$libext" + if test -f "$dir/lib$name.la"; then + found_la="$dir/lib$name.la" + fi + fi + fi + ;; + esac + if test "X$found_dir" != "X"; then + break + fi + done + fi + if test "X$found_dir" != "X"; then + dnl Found the library. + LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$found_dir -l$name" + if test "X$found_so" != "X"; then + dnl Linking with a shared library. We attempt to hardcode its + dnl directory into the executable's runpath, unless it's the + dnl standard /usr/lib. + if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/lib"; then + dnl No hardcoding is needed. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" + else + dnl Use an explicit option to hardcode DIR into the resulting + dnl binary. + dnl Potentially add DIR to ltrpathdirs. + dnl The ltrpathdirs will be appended to $LTLIBNAME at the end. + haveit= + for x in $ltrpathdirs; do + if test "X$x" = "X$found_dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + ltrpathdirs="$ltrpathdirs $found_dir" + fi + dnl The hardcoding into $LIBNAME is system dependent. + if test "$hardcode_direct" = yes; then + dnl Using DIR/libNAME.so during linking hardcodes DIR into the + dnl resulting binary. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" + else + if test -n "$hardcode_libdir_flag_spec" && test "$hardcode_minus_L" = no; then + dnl Use an explicit option to hardcode DIR into the resulting + dnl binary. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" + dnl Potentially add DIR to rpathdirs. + dnl The rpathdirs will be appended to $LIBNAME at the end. + haveit= + for x in $rpathdirs; do + if test "X$x" = "X$found_dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + rpathdirs="$rpathdirs $found_dir" + fi + else + dnl Rely on "-L$found_dir". + dnl But don't add it if it's already contained in the LDFLAGS + dnl or the already constructed $LIBNAME + haveit= + for x in $LDFLAGS $LIB[]NAME; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + if test "X$x" = "X-L$found_dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir" + fi + if test "$hardcode_minus_L" != no; then + dnl FIXME: Not sure whether we should use + dnl "-L$found_dir -l$name" or "-L$found_dir $found_so" + dnl here. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" + else + dnl We cannot use $hardcode_runpath_var and LD_RUN_PATH + dnl here, because this doesn't fit in flags passed to the + dnl compiler. So give up. No hardcoding. This affects only + dnl very old systems. + dnl FIXME: Not sure whether we should use + dnl "-L$found_dir -l$name" or "-L$found_dir $found_so" + dnl here. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name" + fi + fi + fi + fi + else + if test "X$found_a" != "X"; then + dnl Linking with a static library. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_a" + else + dnl We shouldn't come here, but anyway it's good to have a + dnl fallback. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir -l$name" + fi + fi + dnl Assume the include files are nearby. + additional_includedir= + case "$found_dir" in + */lib | */lib/) + basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e 's,/lib/*$,,'` + additional_includedir="$basedir/include" + ;; + esac + if test "X$additional_includedir" != "X"; then + dnl Potentially add $additional_includedir to $INCNAME. + dnl But don't add it + dnl 1. if it's the standard /usr/include, + dnl 2. if it's /usr/local/include and we are using GCC on Linux, + dnl 3. if it's already present in $CPPFLAGS or the already + dnl constructed $INCNAME, + dnl 4. if it doesn't exist as a directory. + if test "X$additional_includedir" != "X/usr/include"; then + haveit= + if test "X$additional_includedir" = "X/usr/local/include"; then + if test -n "$GCC"; then + case $host_os in + linux*) haveit=yes;; + esac + fi + fi + if test -z "$haveit"; then + for x in $CPPFLAGS $INC[]NAME; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + if test "X$x" = "X-I$additional_includedir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test -d "$additional_includedir"; then + dnl Really add $additional_includedir to $INCNAME. + INC[]NAME="${INC[]NAME}${INC[]NAME:+ }-I$additional_includedir" + fi + fi + fi + fi + fi + dnl Look for dependencies. + if test -n "$found_la"; then + dnl Read the .la file. It defines the variables + dnl dlname, library_names, old_library, dependency_libs, current, + dnl age, revision, installed, dlopen, dlpreopen, libdir. + save_libdir="$libdir" + case "$found_la" in + */* | *\\*) . "$found_la" ;; + *) . "./$found_la" ;; + esac + libdir="$save_libdir" + dnl We use only dependency_libs. + for dep in $dependency_libs; do + case "$dep" in + -L*) + additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'` + dnl Potentially add $additional_libdir to $LIBNAME and $LTLIBNAME. + dnl But don't add it + dnl 1. if it's the standard /usr/lib, + dnl 2. if it's /usr/local/lib and we are using GCC on Linux, + dnl 3. if it's already present in $LDFLAGS or the already + dnl constructed $LIBNAME, + dnl 4. if it doesn't exist as a directory. + if test "X$additional_libdir" != "X/usr/lib"; then + haveit= + if test "X$additional_libdir" = "X/usr/local/lib"; then + if test -n "$GCC"; then + case $host_os in + linux*) haveit=yes;; + esac + fi + fi + if test -z "$haveit"; then + haveit= + for x in $LDFLAGS $LIB[]NAME; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + if test "X$x" = "X-L$additional_libdir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test -d "$additional_libdir"; then + dnl Really add $additional_libdir to $LIBNAME. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$additional_libdir" + fi + fi + haveit= + for x in $LDFLAGS $LTLIB[]NAME; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + if test "X$x" = "X-L$additional_libdir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test -d "$additional_libdir"; then + dnl Really add $additional_libdir to $LTLIBNAME. + LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$additional_libdir" + fi + fi + fi + fi + ;; + -R*) + dir=`echo "X$dep" | sed -e 's/^X-R//'` + if test "$enable_rpath" != no; then + dnl Potentially add DIR to rpathdirs. + dnl The rpathdirs will be appended to $LIBNAME at the end. + haveit= + for x in $rpathdirs; do + if test "X$x" = "X$dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + rpathdirs="$rpathdirs $dir" + fi + dnl Potentially add DIR to ltrpathdirs. + dnl The ltrpathdirs will be appended to $LTLIBNAME at the end. + haveit= + for x in $ltrpathdirs; do + if test "X$x" = "X$dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + ltrpathdirs="$ltrpathdirs $dir" + fi + fi + ;; + -l*) + dnl Handle this in the next round. + names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'` + ;; + *.la) + dnl Handle this in the next round. Throw away the .la's + dnl directory; it is already contained in a preceding -L + dnl option. + names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'` + ;; + *) + dnl Most likely an immediate library name. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$dep" + LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$dep" + ;; + esac + done + fi + else + dnl Didn't find the library; assume it is in the system directories + dnl known to the linker and runtime loader. (All the system + dnl directories known to the linker should also be known to the + dnl runtime loader, otherwise the system is severely misconfigured.) + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name" + LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-l$name" + fi + fi + fi + done + done + if test "X$rpathdirs" != "X"; then + if test -n "$hardcode_libdir_separator"; then + dnl Weird platform: only the last -rpath option counts, the user must + dnl pass all path elements in one option. We can arrange that for a + dnl single library, but not when more than one $LIBNAMEs are used. + alldirs= + for found_dir in $rpathdirs; do + alldirs="${alldirs}${alldirs:+$hardcode_libdir_separator}$found_dir" + done + dnl Note: hardcode_libdir_flag_spec uses $libdir and $wl. + acl_save_libdir="$libdir" + libdir="$alldirs" + eval flag=\"$hardcode_libdir_flag_spec\" + libdir="$acl_save_libdir" + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag" + else + dnl The -rpath options are cumulative. + for found_dir in $rpathdirs; do + acl_save_libdir="$libdir" + libdir="$found_dir" + eval flag=\"$hardcode_libdir_flag_spec\" + libdir="$acl_save_libdir" + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag" + done + fi + fi + if test "X$ltrpathdirs" != "X"; then + dnl When using libtool, the option that works for both libraries and + dnl executables is -R. The -R options are cumulative. + for found_dir in $ltrpathdirs; do + LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-R$found_dir" + done + fi +]) + +dnl AC_LIB_APPENDTOVAR(VAR, CONTENTS) appends the elements of CONTENTS to VAR, +dnl unless already present in VAR. +dnl Works only for CPPFLAGS, not for LIB* variables because that sometimes +dnl contains two or three consecutive elements that belong together. +AC_DEFUN([AC_LIB_APPENDTOVAR], +[ + for element in [$2]; do + haveit= + for x in $[$1]; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + if test "X$x" = "X$element"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + [$1]="${[$1]}${[$1]:+ }$element" + fi + done +]) +# lib-prefix.m4 serial 2 (gettext-0.12) +dnl Copyright (C) 2001-2003 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. + +dnl From Bruno Haible. + +dnl AC_LIB_ARG_WITH is synonymous to AC_ARG_WITH in autoconf-2.13, and +dnl similar to AC_ARG_WITH in autoconf 2.52...2.57 except that is doesn't +dnl require excessive bracketing. +ifdef([AC_HELP_STRING], +[AC_DEFUN([AC_LIB_ARG_WITH], [AC_ARG_WITH([$1],[[$2]],[$3],[$4])])], +[AC_DEFUN([AC_LIB_ARG_WITH], [AC_ARG_WITH([$1],[$2],[$3],[$4])])]) + +dnl AC_LIB_PREFIX adds to the CPPFLAGS and LDFLAGS the flags that are needed +dnl to access previously installed libraries. The basic assumption is that +dnl a user will want packages to use other packages he previously installed +dnl with the same --prefix option. +dnl This macro is not needed if only AC_LIB_LINKFLAGS is used to locate +dnl libraries, but is otherwise very convenient. +AC_DEFUN([AC_LIB_PREFIX], +[ + AC_BEFORE([$0], [AC_LIB_LINKFLAGS]) + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([AC_CANONICAL_HOST]) + AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) + dnl By default, look in $includedir and $libdir. + use_additional=yes + AC_LIB_WITH_FINAL_PREFIX([ + eval additional_includedir=\"$includedir\" + eval additional_libdir=\"$libdir\" + ]) + AC_LIB_ARG_WITH([lib-prefix], +[ --with-lib-prefix[=DIR] search for libraries in DIR/include and DIR/lib + --without-lib-prefix don't search for libraries in includedir and libdir], +[ + if test "X$withval" = "Xno"; then + use_additional=no + else + if test "X$withval" = "X"; then + AC_LIB_WITH_FINAL_PREFIX([ + eval additional_includedir=\"$includedir\" + eval additional_libdir=\"$libdir\" + ]) + else + additional_includedir="$withval/include" + additional_libdir="$withval/lib" + fi + fi +]) + if test $use_additional = yes; then + dnl Potentially add $additional_includedir to $CPPFLAGS. + dnl But don't add it + dnl 1. if it's the standard /usr/include, + dnl 2. if it's already present in $CPPFLAGS, + dnl 3. if it's /usr/local/include and we are using GCC on Linux, + dnl 4. if it doesn't exist as a directory. + if test "X$additional_includedir" != "X/usr/include"; then + haveit= + for x in $CPPFLAGS; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + if test "X$x" = "X-I$additional_includedir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test "X$additional_includedir" = "X/usr/local/include"; then + if test -n "$GCC"; then + case $host_os in + linux*) haveit=yes;; + esac + fi + fi + if test -z "$haveit"; then + if test -d "$additional_includedir"; then + dnl Really add $additional_includedir to $CPPFLAGS. + CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }-I$additional_includedir" + fi + fi + fi + fi + dnl Potentially add $additional_libdir to $LDFLAGS. + dnl But don't add it + dnl 1. if it's the standard /usr/lib, + dnl 2. if it's already present in $LDFLAGS, + dnl 3. if it's /usr/local/lib and we are using GCC on Linux, + dnl 4. if it doesn't exist as a directory. + if test "X$additional_libdir" != "X/usr/lib"; then + haveit= + for x in $LDFLAGS; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + if test "X$x" = "X-L$additional_libdir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test "X$additional_libdir" = "X/usr/local/lib"; then + if test -n "$GCC"; then + case $host_os in + linux*) haveit=yes;; + esac + fi + fi + if test -z "$haveit"; then + if test -d "$additional_libdir"; then + dnl Really add $additional_libdir to $LDFLAGS. + LDFLAGS="${LDFLAGS}${LDFLAGS:+ }-L$additional_libdir" + fi + fi + fi + fi + fi +]) + +dnl AC_LIB_PREPARE_PREFIX creates variables acl_final_prefix, +dnl acl_final_exec_prefix, containing the values to which $prefix and +dnl $exec_prefix will expand at the end of the configure script. +AC_DEFUN([AC_LIB_PREPARE_PREFIX], +[ + dnl Unfortunately, prefix and exec_prefix get only finally determined + dnl at the end of configure. + if test "X$prefix" = "XNONE"; then + acl_final_prefix="$ac_default_prefix" + else + acl_final_prefix="$prefix" + fi + if test "X$exec_prefix" = "XNONE"; then + acl_final_exec_prefix='${prefix}' + else + acl_final_exec_prefix="$exec_prefix" + fi + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + eval acl_final_exec_prefix=\"$acl_final_exec_prefix\" + prefix="$acl_save_prefix" +]) + +dnl AC_LIB_WITH_FINAL_PREFIX([statement]) evaluates statement, with the +dnl variables prefix and exec_prefix bound to the values they will have +dnl at the end of the configure script. +AC_DEFUN([AC_LIB_WITH_FINAL_PREFIX], +[ + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + $1 + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" +]) +# nls.m4 serial 1 (gettext-0.12) +dnl Copyright (C) 1995-2003 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. +dnl +dnl This file can can be used in projects which are not available under +dnl the GNU General Public License or the GNU Library General Public +dnl License but which still want to provide support for the GNU gettext +dnl functionality. +dnl Please note that the actual code of the GNU gettext library is covered +dnl by the GNU Library General Public License, and the rest of the GNU +dnl gettext package package is covered by the GNU General Public License. +dnl They are *not* in the public domain. + +dnl Authors: +dnl Ulrich Drepper , 1995-2000. +dnl Bruno Haible , 2000-2003. + +AC_DEFUN([AM_NLS], +[ + AC_MSG_CHECKING([whether NLS is requested]) + dnl Default is enabled NLS + AC_ARG_ENABLE(nls, + [ --disable-nls do not use Native Language Support], + USE_NLS=$enableval, USE_NLS=yes) + AC_MSG_RESULT($USE_NLS) + AC_SUBST(USE_NLS) +]) + +AC_DEFUN([AM_MKINSTALLDIRS], +[ + dnl If the AC_CONFIG_AUX_DIR macro for autoconf is used we possibly + dnl find the mkinstalldirs script in another subdir but $(top_srcdir). + dnl Try to locate it. + MKINSTALLDIRS= + if test -n "$ac_aux_dir"; then + case "$ac_aux_dir" in + /*) MKINSTALLDIRS="$ac_aux_dir/mkinstalldirs" ;; + *) MKINSTALLDIRS="\$(top_builddir)/$ac_aux_dir/mkinstalldirs" ;; + esac + fi + if test -z "$MKINSTALLDIRS"; then + MKINSTALLDIRS="\$(top_srcdir)/mkinstalldirs" + fi + AC_SUBST(MKINSTALLDIRS) +]) +# po.m4 serial 1 (gettext-0.12) +dnl Copyright (C) 1995-2003 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. +dnl +dnl This file can can be used in projects which are not available under +dnl the GNU General Public License or the GNU Library General Public +dnl License but which still want to provide support for the GNU gettext +dnl functionality. +dnl Please note that the actual code of the GNU gettext library is covered +dnl by the GNU Library General Public License, and the rest of the GNU +dnl gettext package package is covered by the GNU General Public License. +dnl They are *not* in the public domain. + +dnl Authors: +dnl Ulrich Drepper , 1995-2000. +dnl Bruno Haible , 2000-2003. + +dnl Checks for all prerequisites of the po subdirectory. +AC_DEFUN([AM_PO_SUBDIRS], +[ + AC_REQUIRE([AC_PROG_MAKE_SET])dnl + AC_REQUIRE([AC_PROG_INSTALL])dnl + AC_REQUIRE([AM_MKINSTALLDIRS])dnl + AC_REQUIRE([AM_NLS])dnl + + dnl Perform the following tests also if --disable-nls has been given, + dnl because they are needed for "make dist" to work. + + dnl Search for GNU msgfmt in the PATH. + dnl The first test excludes Solaris msgfmt and early GNU msgfmt versions. + dnl The second test excludes FreeBSD msgfmt. + AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt, + [$ac_dir/$ac_word --statistics /dev/null >/dev/null 2>&1 && + (if $ac_dir/$ac_word --statistics /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi)], + :) + AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT) + + dnl Search for GNU xgettext 0.12 or newer in the PATH. + dnl The first test excludes Solaris xgettext and early GNU xgettext versions. + dnl The second test excludes FreeBSD xgettext. + AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext, + [$ac_dir/$ac_word --omit-header --copyright-holder= --msgid-bugs-address= /dev/null >/dev/null 2>&1 && + (if $ac_dir/$ac_word --omit-header --copyright-holder= --msgid-bugs-address= /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi)], + :) + dnl Remove leftover from FreeBSD xgettext call. + rm -f messages.po + + dnl Search for GNU msgmerge 0.11 or newer in the PATH. + AM_PATH_PROG_WITH_TEST(MSGMERGE, msgmerge, + [$ac_dir/$ac_word --update -q /dev/null /dev/null >/dev/null 2>&1], :) + + dnl This could go away some day; the PATH_PROG_WITH_TEST already does it. + dnl Test whether we really found GNU msgfmt. + if test "$GMSGFMT" != ":"; then + dnl If it is no GNU msgfmt we define it as : so that the + dnl Makefiles still can work. + if $GMSGFMT --statistics /dev/null >/dev/null 2>&1 && + (if $GMSGFMT --statistics /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi); then + : ; + else + GMSGFMT=`echo "$GMSGFMT" | sed -e 's,^.*/,,'` + AC_MSG_RESULT( + [found $GMSGFMT program is not GNU msgfmt; ignore it]) + GMSGFMT=":" + fi + fi + + dnl This could go away some day; the PATH_PROG_WITH_TEST already does it. + dnl Test whether we really found GNU xgettext. + if test "$XGETTEXT" != ":"; then + dnl If it is no GNU xgettext we define it as : so that the + dnl Makefiles still can work. + if $XGETTEXT --omit-header --copyright-holder= --msgid-bugs-address= /dev/null >/dev/null 2>&1 && + (if $XGETTEXT --omit-header --copyright-holder= --msgid-bugs-address= /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi); then + : ; + else + AC_MSG_RESULT( + [found xgettext program is not GNU xgettext; ignore it]) + XGETTEXT=":" + fi + dnl Remove leftover from FreeBSD xgettext call. + rm -f messages.po + fi + + AC_OUTPUT_COMMANDS([ + for ac_file in $CONFIG_FILES; do + # Support "outfile[:infile[:infile...]]" + case "$ac_file" in + *:*) ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; + esac + # PO directories have a Makefile.in generated from Makefile.in.in. + case "$ac_file" in */Makefile.in) + # Adjust a relative srcdir. + ac_dir=`echo "$ac_file"|sed 's%/[^/][^/]*$%%'` + ac_dir_suffix="/`echo "$ac_dir"|sed 's%^\./%%'`" + ac_dots=`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'` + # In autoconf-2.13 it is called $ac_given_srcdir. + # In autoconf-2.50 it is called $srcdir. + test -n "$ac_given_srcdir" || ac_given_srcdir="$srcdir" + case "$ac_given_srcdir" in + .) top_srcdir=`echo $ac_dots|sed 's%/$%%'` ;; + /*) top_srcdir="$ac_given_srcdir" ;; + *) top_srcdir="$ac_dots$ac_given_srcdir" ;; + esac + if test -f "$ac_given_srcdir/$ac_dir/POTFILES.in"; then + rm -f "$ac_dir/POTFILES" + test -n "$as_me" && echo "$as_me: creating $ac_dir/POTFILES" || echo "creating $ac_dir/POTFILES" + cat "$ac_given_srcdir/$ac_dir/POTFILES.in" | sed -e "/^#/d" -e "/^[ ]*\$/d" -e "s,.*, $top_srcdir/& \\\\," | sed -e "\$s/\(.*\) \\\\/\1/" > "$ac_dir/POTFILES" + POMAKEFILEDEPS="POTFILES.in" + # ALL_LINGUAS, POFILES, GMOFILES, UPDATEPOFILES, DUMMYPOFILES depend + # on $ac_dir but don't depend on user-specified configuration + # parameters. + if test -f "$ac_given_srcdir/$ac_dir/LINGUAS"; then + # The LINGUAS file contains the set of available languages. + if test -n "$OBSOLETE_ALL_LINGUAS"; then + test -n "$as_me" && echo "$as_me: setting ALL_LINGUAS in configure.in is obsolete" || echo "setting ALL_LINGUAS in configure.in is obsolete" + fi + ALL_LINGUAS_=`sed -e "/^#/d" "$ac_given_srcdir/$ac_dir/LINGUAS"` + # Hide the ALL_LINGUAS assigment from automake. + eval 'ALL_LINGUAS''=$ALL_LINGUAS_' + POMAKEFILEDEPS="$POMAKEFILEDEPS LINGUAS" + else + # The set of available languages was given in configure.in. + eval 'ALL_LINGUAS''=$OBSOLETE_ALL_LINGUAS' + fi + case "$ac_given_srcdir" in + .) srcdirpre= ;; + *) srcdirpre='$(srcdir)/' ;; + esac + POFILES= + GMOFILES= + UPDATEPOFILES= + DUMMYPOFILES= + for lang in $ALL_LINGUAS; do + POFILES="$POFILES $srcdirpre$lang.po" + GMOFILES="$GMOFILES $srcdirpre$lang.gmo" + UPDATEPOFILES="$UPDATEPOFILES $lang.po-update" + DUMMYPOFILES="$DUMMYPOFILES $lang.nop" + done + # CATALOGS depends on both $ac_dir and the user's LINGUAS + # environment variable. + INST_LINGUAS= + if test -n "$ALL_LINGUAS"; then + for presentlang in $ALL_LINGUAS; do + useit=no + if test "%UNSET%" != "$LINGUAS"; then + desiredlanguages="$LINGUAS" + else + desiredlanguages="$ALL_LINGUAS" + fi + for desiredlang in $desiredlanguages; do + # Use the presentlang catalog if desiredlang is + # a. equal to presentlang, or + # b. a variant of presentlang (because in this case, + # presentlang can be used as a fallback for messages + # which are not translated in the desiredlang catalog). + case "$desiredlang" in + "$presentlang"*) useit=yes;; + esac + done + if test $useit = yes; then + INST_LINGUAS="$INST_LINGUAS $presentlang" + fi + done + fi + CATALOGS= + if test -n "$INST_LINGUAS"; then + for lang in $INST_LINGUAS; do + CATALOGS="$CATALOGS $lang.gmo" + done + fi + test -n "$as_me" && echo "$as_me: creating $ac_dir/Makefile" || echo "creating $ac_dir/Makefile" + sed -e "/^POTFILES =/r $ac_dir/POTFILES" -e "/^# Makevars/r $ac_given_srcdir/$ac_dir/Makevars" -e "s|@POFILES@|$POFILES|g" -e "s|@GMOFILES@|$GMOFILES|g" -e "s|@UPDATEPOFILES@|$UPDATEPOFILES|g" -e "s|@DUMMYPOFILES@|$DUMMYPOFILES|g" -e "s|@CATALOGS@|$CATALOGS|g" -e "s|@POMAKEFILEDEPS@|$POMAKEFILEDEPS|g" "$ac_dir/Makefile.in" > "$ac_dir/Makefile" + for f in "$ac_given_srcdir/$ac_dir"/Rules-*; do + if test -f "$f"; then + case "$f" in + *.orig | *.bak | *~) ;; + *) cat "$f" >> "$ac_dir/Makefile" ;; + esac + fi + done + fi + ;; + esac + done], + [# Capture the value of obsolete ALL_LINGUAS because we need it to compute + # POFILES, GMOFILES, UPDATEPOFILES, DUMMYPOFILES, CATALOGS. But hide it + # from automake. + eval 'OBSOLETE_ALL_LINGUAS''="$ALL_LINGUAS"' + # Capture the value of LINGUAS because we need it to compute CATALOGS. + LINGUAS="${LINGUAS-%UNSET%}" + ]) +]) +# progtest.m4 serial 3 (gettext-0.12) +dnl Copyright (C) 1996-2003 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. +dnl +dnl This file can can be used in projects which are not available under +dnl the GNU General Public License or the GNU Library General Public +dnl License but which still want to provide support for the GNU gettext +dnl functionality. +dnl Please note that the actual code of the GNU gettext library is covered +dnl by the GNU Library General Public License, and the rest of the GNU +dnl gettext package package is covered by the GNU General Public License. +dnl They are *not* in the public domain. + +dnl Authors: +dnl Ulrich Drepper , 1996. + +# Search path for a program which passes the given test. + +dnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR, +dnl TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]]) +AC_DEFUN([AM_PATH_PROG_WITH_TEST], +[ +# Prepare PATH_SEPARATOR. +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh +fi + +# Find out how to test for executable files. Don't use a zero-byte file, +# as systems may use methods other than mode bits to determine executability. +cat >conf$$.file <<_ASEOF +#! /bin/sh +exit 0 +_ASEOF +chmod +x conf$$.file +if test -x conf$$.file >/dev/null 2>&1; then + ac_executable_p="test -x" +else + ac_executable_p="test -f" +fi +rm -f conf$$.file + +# Extract the first word of "$2", so it can be a program name with args. +set dummy $2; ac_word=[$]2 +AC_MSG_CHECKING([for $ac_word]) +AC_CACHE_VAL(ac_cv_path_$1, +[case "[$]$1" in + [[\\/]]* | ?:[[\\/]]*) + ac_cv_path_$1="[$]$1" # Let the user override the test with a path. + ;; + *) + ac_save_IFS="$IFS"; IFS=$PATH_SEPARATOR + for ac_dir in ifelse([$5], , $PATH, [$5]); do + IFS="$ac_save_IFS" + test -z "$ac_dir" && ac_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $ac_executable_p "$ac_dir/$ac_word$ac_exec_ext"; then + if [$3]; then + ac_cv_path_$1="$ac_dir/$ac_word$ac_exec_ext" + break 2 + fi + fi + done + done + IFS="$ac_save_IFS" +dnl If no 4th arg is given, leave the cache variable unset, +dnl so AC_PATH_PROGS will keep looking. +ifelse([$4], , , [ test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4" +])dnl + ;; +esac])dnl +$1="$ac_cv_path_$1" +if test ifelse([$4], , [-n "[$]$1"], ["[$]$1" != "$4"]); then + AC_MSG_RESULT([$]$1) +else + AC_MSG_RESULT(no) +fi +AC_SUBST($1)dnl +]) +# stdint_h.m4 serial 3 (gettext-0.12) +dnl Copyright (C) 1997-2003 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. + +dnl From Paul Eggert. + +# Define HAVE_STDINT_H_WITH_UINTMAX if exists, +# doesn't clash with , and declares uintmax_t. + +AC_DEFUN([jm_AC_HEADER_STDINT_H], +[ + AC_CACHE_CHECK([for stdint.h], jm_ac_cv_header_stdint_h, + [AC_TRY_COMPILE( + [#include +#include ], + [uintmax_t i = (uintmax_t) -1;], + jm_ac_cv_header_stdint_h=yes, + jm_ac_cv_header_stdint_h=no)]) + if test $jm_ac_cv_header_stdint_h = yes; then + AC_DEFINE_UNQUOTED(HAVE_STDINT_H_WITH_UINTMAX, 1, + [Define if exists, doesn't clash with , + and declares uintmax_t. ]) + fi +]) +# uintmax_t.m4 serial 7 (gettext-0.12) +dnl Copyright (C) 1997-2003 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. + +dnl From Paul Eggert. + +AC_PREREQ(2.13) + +# Define uintmax_t to 'unsigned long' or 'unsigned long long' +# if it is not already defined in or . + +AC_DEFUN([jm_AC_TYPE_UINTMAX_T], +[ + AC_REQUIRE([jm_AC_HEADER_INTTYPES_H]) + AC_REQUIRE([jm_AC_HEADER_STDINT_H]) + if test $jm_ac_cv_header_inttypes_h = no && test $jm_ac_cv_header_stdint_h = no; then + AC_REQUIRE([jm_AC_TYPE_UNSIGNED_LONG_LONG]) + test $ac_cv_type_unsigned_long_long = yes \ + && ac_type='unsigned long long' \ + || ac_type='unsigned long' + AC_DEFINE_UNQUOTED(uintmax_t, $ac_type, + [Define to unsigned long or unsigned long long + if and don't define.]) + else + AC_DEFINE(HAVE_UINTMAX_T, 1, + [Define if you have the 'uintmax_t' type in or .]) + fi +]) +# ulonglong.m4 serial 2 (fileutils-4.0.32, gettext-0.10.40) +dnl Copyright (C) 1999-2002 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. + +dnl From Paul Eggert. + +AC_DEFUN([jm_AC_TYPE_UNSIGNED_LONG_LONG], +[ + AC_CACHE_CHECK([for unsigned long long], ac_cv_type_unsigned_long_long, + [AC_TRY_LINK([unsigned long long ull = 1; int i = 63;], + [unsigned long long ullmax = (unsigned long long) -1; + return ull << i | ull >> i | ullmax / ull | ullmax % ull;], + ac_cv_type_unsigned_long_long=yes, + ac_cv_type_unsigned_long_long=no)]) + if test $ac_cv_type_unsigned_long_long = yes; then + AC_DEFINE(HAVE_UNSIGNED_LONG_LONG, 1, + [Define if you have the unsigned long long type.]) + fi +]) + +dnl From gnulib +AC_DEFUN([BASH_FUNC_FPURGE], +[ + AC_CHECK_FUNCS_ONCE([fpurge]) + AC_CHECK_FUNCS_ONCE([__fpurge]) + AC_CHECK_DECLS([fpurge], , , [#include ]) +]) + +AC_DEFUN([BASH_FUNC_SNPRINTF], +[ + AC_CHECK_FUNCS_ONCE([snprintf]) + if test X$ac_cv_func_snprintf = Xyes; then + AC_CACHE_CHECK([for standard-conformant snprintf], [bash_cv_func_snprintf], + [AC_TRY_RUN([ +#include + +main() +{ + int n; + n = snprintf (0, 0, "%s", "0123456"); + exit(n != 7); +} +], bash_cv_func_snprintf=yes, bash_cv_func_snprintf=no, + [AC_MSG_WARN([cannot check standard snprintf if cross-compiling]) + bash_cv_func_snprintf=yes] +)]) + if test $bash_cv_func_snprintf = no; then + ac_cv_func_snprintf=no + fi + fi + if test $ac_cv_func_snprintf = no; then + AC_DEFINE(HAVE_SNPRINTF, 0, + [Define if you have a standard-conformant snprintf function.]) + fi +]) + +AC_DEFUN([BASH_FUNC_VSNPRINTF], +[ + AC_CHECK_FUNCS_ONCE([vsnprintf]) + if test X$ac_cv_func_vsnprintf = Xyes; then + AC_CACHE_CHECK([for standard-conformant vsnprintf], [bash_cv_func_vsnprintf], + [AC_TRY_RUN([ +#if HAVE_STDARG_H +#include +#else +#include +#endif +#include +#include + +static int +#if HAVE_STDARG_H +foo(const char *fmt, ...) +#else +foo(format, va_alist) + const char *format; + va_dcl +#endif +{ + va_list args; + int n; + +#if HAVE_STDARG_H + va_start(args, fmt); +#else + va_start(args); +#endif + n = vsnprintf(0, 0, fmt, args); + va_end (args); + return n; +} + +main() +{ + int n; + n = foo("%s", "0123456"); + exit(n != 7); +} +], bash_cv_func_vsnprintf=yes, bash_cv_func_vsnprintf=no, + [AC_MSG_WARN([cannot check standard vsnprintf if cross-compiling]) + bash_cv_func_vsnprintf=yes] +)]) + if test $bash_cv_func_vsnprintf = no; then + ac_cv_func_vsnprintf=no + fi + fi + if test $ac_cv_func_vsnprintf = no; then + AC_DEFINE(HAVE_VSNPRINTF, 0, + [Define if you have a standard-conformant vsnprintf function.]) + fi +]) + +AC_DEFUN(BASH_STRUCT_WEXITSTATUS_OFFSET, +[AC_MSG_CHECKING(for offset of exit status in return status from wait) +AC_CACHE_VAL(bash_cv_wexitstatus_offset, +[AC_TRY_RUN([ +#include +#include + +#include + +main(c, v) + int c; + char **v; +{ + pid_t pid, p; + int s, i, n; + + s = 0; + pid = fork(); + if (pid == 0) + exit (42); + + /* wait for the process */ + p = wait(&s); + if (p != pid) + exit (255); + + /* crack s */ + for (i = 0; i < (sizeof(s) - 8); i++) + { + n = (s >> i) & 0xff; + if (n == 42) + exit (i); + } + + exit (254); +} +], bash_cv_wexitstatus_offset=0, bash_cv_wexitstatus_offset=$?, + [AC_MSG_WARN(cannot check WEXITSTATUS offset if cross compiling -- defaulting to 0) + bash_cv_wexitstatus_offset=0] +)]) +if test "$bash_cv_wexitstatus_offset" -gt 32 ; then + AC_MSG_WARN(bad exit status from test program -- defaulting to 0) + bash_cv_wexitstatus_offset=0 +fi +AC_MSG_RESULT($bash_cv_wexitstatus_offset) +AC_DEFINE_UNQUOTED([WEXITSTATUS_OFFSET], [$bash_cv_wexitstatus_offset], [Offset of exit status in wait status word]) +]) diff --git a/alias.c b/alias.c new file mode 100644 index 0000000..8b3f228 --- /dev/null +++ b/alias.c @@ -0,0 +1,584 @@ +/* alias.c -- Not a full alias, but just the kind that we use in the + shell. Csh style alias is somewhere else (`over there, in a box'). */ + +/* Copyright (C) 1987-2015 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 3 of the License, 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. If not, see . +*/ + +#include "config.h" + +#if defined (ALIAS) + +#if defined (HAVE_UNISTD_H) +# ifdef _MINIX +# include +# endif +# include +#endif + +#include +#include "chartypes.h" +#include "bashansi.h" +#include "command.h" +#include "general.h" +#include "externs.h" +#include "alias.h" + +#if defined (PROGRAMMABLE_COMPLETION) +# include "pcomplete.h" +#endif + +#if defined (HAVE_MBSTR_H) && defined (HAVE_MBSCHR) +# include /* mbschr */ +#endif + +#define ALIAS_HASH_BUCKETS 64 /* must be power of two */ + +typedef int sh_alias_map_func_t __P((alias_t *)); + +static void free_alias_data __P((PTR_T)); +static alias_t **map_over_aliases __P((sh_alias_map_func_t *)); +static void sort_aliases __P((alias_t **)); +static int qsort_alias_compare __P((alias_t **, alias_t **)); + +#if defined (READLINE) +static int skipquotes __P((char *, int)); +static int skipws __P((char *, int)); +static int rd_token __P((char *, int)); +#endif + +/* Non-zero means expand all words on the line. Otherwise, expand + after first expansion if the expansion ends in a space. */ +int alias_expand_all = 0; + +/* The list of aliases that we have. */ +HASH_TABLE *aliases = (HASH_TABLE *)NULL; + +void +initialize_aliases () +{ + if (aliases == 0) + aliases = hash_create (ALIAS_HASH_BUCKETS); +} + +/* Scan the list of aliases looking for one with NAME. Return NULL + if the alias doesn't exist, else a pointer to the alias_t. */ +alias_t * +find_alias (name) + char *name; +{ + BUCKET_CONTENTS *al; + + if (aliases == 0) + return ((alias_t *)NULL); + + al = hash_search (name, aliases, 0); + return (al ? (alias_t *)al->data : (alias_t *)NULL); +} + +/* Return the value of the alias for NAME, or NULL if there is none. */ +char * +get_alias_value (name) + char *name; +{ + alias_t *alias; + + if (aliases == 0) + return ((char *)NULL); + + alias = find_alias (name); + return (alias ? alias->value : (char *)NULL); +} + +/* Make a new alias from NAME and VALUE. If NAME can be found, + then replace its value. */ +void +add_alias (name, value) + char *name, *value; +{ + BUCKET_CONTENTS *elt; + alias_t *temp; + int n; + + if (aliases == 0) + { + initialize_aliases (); + temp = (alias_t *)NULL; + } + else + temp = find_alias (name); + + if (temp) + { + free (temp->value); + temp->value = savestring (value); + temp->flags &= ~AL_EXPANDNEXT; + n = value[strlen (value) - 1]; + if (n == ' ' || n == '\t') + temp->flags |= AL_EXPANDNEXT; + } + else + { + temp = (alias_t *)xmalloc (sizeof (alias_t)); + temp->name = savestring (name); + temp->value = savestring (value); + temp->flags = 0; + + n = value[strlen (value) - 1]; + if (n == ' ' || n == '\t') + temp->flags |= AL_EXPANDNEXT; + + elt = hash_insert (savestring (name), aliases, HASH_NOSRCH); + elt->data = temp; +#if defined (PROGRAMMABLE_COMPLETION) + set_itemlist_dirty (&it_aliases); +#endif + } +} + +/* Delete a single alias structure. */ +static void +free_alias_data (data) + PTR_T data; +{ + register alias_t *a; + + a = (alias_t *)data; + free (a->value); + free (a->name); + free (data); +} + +/* Remove the alias with name NAME from the alias table. Returns + the number of aliases left in the table, or -1 if the alias didn't + exist. */ +int +remove_alias (name) + char *name; +{ + BUCKET_CONTENTS *elt; + + if (aliases == 0) + return (-1); + + elt = hash_remove (name, aliases, 0); + if (elt) + { + free_alias_data (elt->data); + free (elt->key); /* alias name */ + free (elt); /* XXX */ +#if defined (PROGRAMMABLE_COMPLETION) + set_itemlist_dirty (&it_aliases); +#endif + return (aliases->nentries); + } + return (-1); +} + +/* Delete all aliases. */ +void +delete_all_aliases () +{ + if (aliases == 0) + return; + + hash_flush (aliases, free_alias_data); + hash_dispose (aliases); + aliases = (HASH_TABLE *)NULL; +#if defined (PROGRAMMABLE_COMPLETION) + set_itemlist_dirty (&it_aliases); +#endif +} + +/* Return an array of aliases that satisfy the conditions tested by FUNCTION. + If FUNCTION is NULL, return all aliases. */ +static alias_t ** +map_over_aliases (function) + sh_alias_map_func_t *function; +{ + register int i; + register BUCKET_CONTENTS *tlist; + alias_t *alias, **list; + int list_index; + + i = HASH_ENTRIES (aliases); + if (i == 0) + return ((alias_t **)NULL); + + list = (alias_t **)xmalloc ((i + 1) * sizeof (alias_t *)); + for (i = list_index = 0; i < aliases->nbuckets; i++) + { + for (tlist = hash_items (i, aliases); tlist; tlist = tlist->next) + { + alias = (alias_t *)tlist->data; + + if (!function || (*function) (alias)) + { + list[list_index++] = alias; + list[list_index] = (alias_t *)NULL; + } + } + } + return (list); +} + +static void +sort_aliases (array) + alias_t **array; +{ + qsort (array, strvec_len ((char **)array), sizeof (alias_t *), (QSFUNC *)qsort_alias_compare); +} + +static int +qsort_alias_compare (as1, as2) + alias_t **as1, **as2; +{ + int result; + + if ((result = (*as1)->name[0] - (*as2)->name[0]) == 0) + result = strcmp ((*as1)->name, (*as2)->name); + + return (result); +} + +/* Return a sorted list of all defined aliases */ +alias_t ** +all_aliases () +{ + alias_t **list; + + if (aliases == 0 || HASH_ENTRIES (aliases) == 0) + return ((alias_t **)NULL); + + list = map_over_aliases ((sh_alias_map_func_t *)NULL); + if (list) + sort_aliases (list); + return (list); +} + +char * +alias_expand_word (s) + char *s; +{ + alias_t *r; + + r = find_alias (s); + return (r ? savestring (r->value) : (char *)NULL); +} + +/* Readline support functions -- expand all aliases in a line. */ + +#if defined (READLINE) + +/* Return non-zero if CHARACTER is a member of the class of characters + that are self-delimiting in the shell (this really means that these + characters delimit tokens). */ +#define self_delimiting(character) (member ((character), " \t\n\r;|&()")) + +/* Return non-zero if CHARACTER is a member of the class of characters + that delimit commands in the shell. */ +#define command_separator(character) (member ((character), "\r\n;|&(")) + +/* If this is 1, we are checking the next token read for alias expansion + because it is the first word in a command. */ +static int command_word; + +/* This is for skipping quoted strings in alias expansions. */ +#define quote_char(c) (((c) == '\'') || ((c) == '"')) + +/* Consume a quoted string from STRING, starting at string[START] (so + string[START] is the opening quote character), and return the index + of the closing quote character matching the opening quote character. + This handles single matching pairs of unquoted quotes; it could afford + to be a little smarter... This skips words between balanced pairs of + quotes, words where the first character is quoted with a `\', and other + backslash-escaped characters. */ + +static int +skipquotes (string, start) + char *string; + int start; +{ + register int i; + int delimiter = string[start]; + + /* i starts at START + 1 because string[START] is the opening quote + character. */ + for (i = start + 1 ; string[i] ; i++) + { + if (string[i] == '\\') + { + i++; /* skip backslash-quoted quote characters, too */ + if (string[i] == 0) + break; + continue; + } + + if (string[i] == delimiter) + return i; + } + return (i); +} + +/* Skip the white space and any quoted characters in STRING, starting at + START. Return the new index into STRING, after zero or more characters + have been skipped. */ +static int +skipws (string, start) + char *string; + int start; +{ + register int i; + int pass_next, backslash_quoted_word; + unsigned char peekc; + + /* skip quoted strings, in ' or ", and words in which a character is quoted + with a `\'. */ + i = backslash_quoted_word = pass_next = 0; + + /* Skip leading whitespace (or separator characters), and quoted words. + But save it in the output. */ + + for (i = start; string[i]; i++) + { + if (pass_next) + { + pass_next = 0; + continue; + } + + if (whitespace (string[i])) + { + backslash_quoted_word = 0; /* we are no longer in a backslash-quoted word */ + continue; + } + + if (string[i] == '\\') + { + peekc = string[i+1]; + if (peekc == 0) + break; + if (ISLETTER (peekc)) + backslash_quoted_word++; /* this is a backslash-quoted word */ + else + pass_next++; + continue; + } + + /* This only handles single pairs of non-escaped quotes. This + overloads backslash_quoted_word to also mean that a word like + ""f is being scanned, so that the quotes will inhibit any expansion + of the word. */ + if (quote_char(string[i])) + { + i = skipquotes (string, i); + /* This could be a line that contains a single quote character, + in which case skipquotes () terminates with string[i] == '\0' + (the end of the string). Check for that here. */ + if (string[i] == '\0') + break; + + peekc = string[i + 1]; + if (ISLETTER (peekc)) + backslash_quoted_word++; + continue; + } + + /* If we're in the middle of some kind of quoted word, let it + pass through. */ + if (backslash_quoted_word) + continue; + + /* If this character is a shell command separator, then set a hint for + alias_expand that the next token is the first word in a command. */ + + if (command_separator (string[i])) + { + command_word++; + continue; + } + break; + } + return (i); +} + +/* Characters that may appear in a token. Basically, anything except white + space and a token separator. */ +#define token_char(c) (!((whitespace (string[i]) || self_delimiting (string[i])))) + +/* Read from START in STRING until the next separator character, and return + the index of that separator. Skip backslash-quoted characters. Call + skipquotes () for quoted strings in the middle or at the end of tokens, + so all characters show up (e.g. foo'' and foo""bar) */ +static int +rd_token (string, start) + char *string; + int start; +{ + register int i; + + /* From here to next separator character is a token. */ + for (i = start; string[i] && token_char (string[i]); i++) + { + if (string[i] == '\\') + { + i++; /* skip backslash-escaped character */ + if (string[i] == 0) + break; + continue; + } + + /* If this character is a quote character, we want to call skipquotes + to get the whole quoted portion as part of this word. That word + will not generally match an alias, even if te unquoted word would + have. The presence of the quotes in the token serves then to + inhibit expansion. */ + if (quote_char (string[i])) + { + i = skipquotes (string, i); + /* This could be a line that contains a single quote character, + in which case skipquotes () terminates with string[i] == '\0' + (the end of the string). Check for that here. */ + if (string[i] == '\0') + break; + + /* Now string[i] is the matching quote character, and the + quoted portion of the token has been scanned. */ + continue; + } + } + return (i); +} + +/* Return a new line, with any aliases substituted. */ +char * +alias_expand (string) + char *string; +{ + register int i, j, start; + char *line, *token; + int line_len, tl, real_start, expand_next, expand_this_token; + alias_t *alias; + + line_len = strlen (string) + 1; + line = (char *)xmalloc (line_len); + token = (char *)xmalloc (line_len); + + line[0] = i = 0; + expand_next = 0; + command_word = 1; /* initialized to expand the first word on the line */ + + /* Each time through the loop we find the next word in line. If it + has an alias, substitute the alias value. If the value ends in ` ', + then try again with the next word. Else, if there is no value, or if + the value does not end in space, we are done. */ + + for (;;) + { + + token[0] = 0; + start = i; + + /* Skip white space and quoted characters */ + i = skipws (string, start); + + if (start == i && string[i] == '\0') + { + free (token); + return (line); + } + + /* copy the just-skipped characters into the output string, + expanding it if there is not enough room. */ + j = strlen (line); + tl = i - start; /* number of characters just skipped */ + RESIZE_MALLOCED_BUFFER (line, j, (tl + 1), line_len, (tl + 50)); + strncpy (line + j, string + start, tl); + line[j + tl] = '\0'; + + real_start = i; + + command_word = command_word || (command_separator (string[i])); + expand_this_token = (command_word || expand_next); + expand_next = 0; + + /* Read the next token, and copy it into TOKEN. */ + start = i; + i = rd_token (string, start); + + tl = i - start; /* token length */ + + /* If tl == 0, but we're not at the end of the string, then we have a + single-character token, probably a delimiter */ + if (tl == 0 && string[i] != '\0') + { + tl = 1; + i++; /* move past it */ + } + + strncpy (token, string + start, tl); + token [tl] = '\0'; + + /* If there is a backslash-escaped character quoted in TOKEN, + then we don't do alias expansion. This should check for all + other quoting characters, too. */ + if (mbschr (token, '\\')) + expand_this_token = 0; + + /* If we should be expanding here, if we are expanding all words, or if + we are in a location in the string where an expansion is supposed to + take place, see if this word has a substitution. If it does, then do + the expansion. Note that we defer the alias value lookup until we + are sure we are expanding this token. */ + + if ((token[0]) && + (expand_this_token || alias_expand_all) && + (alias = find_alias (token))) + { + char *v; + int vlen, llen; + + v = alias->value; + vlen = strlen (v); + llen = strlen (line); + + /* +3 because we possibly add one more character below. */ + RESIZE_MALLOCED_BUFFER (line, llen, (vlen + 3), line_len, (vlen + 50)); + + strcpy (line + llen, v); + + if ((expand_this_token && vlen && whitespace (v[vlen - 1])) || + alias_expand_all) + expand_next = 1; + } + else + { + int llen, tlen; + + llen = strlen (line); + tlen = i - real_start; /* tlen == strlen(token) */ + + RESIZE_MALLOCED_BUFFER (line, llen, (tlen + 1), line_len, (llen + tlen + 50)); + + strncpy (line + llen, string + real_start, tlen); + line[llen + tlen] = '\0'; + } + command_word = 0; + } +} +#endif /* READLINE */ +#endif /* ALIAS */ diff --git a/alias.h b/alias.h new file mode 100644 index 0000000..4d0075f --- /dev/null +++ b/alias.h @@ -0,0 +1,70 @@ +/* alias.h -- structure definitions. */ + +/* Copyright (C) 1987-2009 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 3 of the License, 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. If not, see . +*/ + +#if !defined (_ALIAS_H_) +#define _ALIAS_H_ + +#include "stdc.h" + +#include "hashlib.h" + +typedef struct alias { + char *name; + char *value; + char flags; +} alias_t; + +/* Values for `flags' member of struct alias. */ +#define AL_EXPANDNEXT 0x1 +#define AL_BEINGEXPANDED 0x2 + +/* The list of known aliases. */ +extern HASH_TABLE *aliases; + +extern void initialize_aliases __P((void)); + +/* Scan the list of aliases looking for one with NAME. Return NULL + if the alias doesn't exist, else a pointer to the alias. */ +extern alias_t *find_alias __P((char *)); + +/* Return the value of the alias for NAME, or NULL if there is none. */ +extern char *get_alias_value __P((char *)); + +/* Make a new alias from NAME and VALUE. If NAME can be found, + then replace its value. */ +extern void add_alias __P((char *, char *)); + +/* Remove the alias with name NAME from the alias list. Returns + the index of the removed alias, or -1 if the alias didn't exist. */ +extern int remove_alias __P((char *)); + +/* Remove all aliases. */ +extern void delete_all_aliases __P((void)); + +/* Return an array of all defined aliases. */ +extern alias_t **all_aliases __P((void)); + +/* Expand a single word for aliases. */ +extern char *alias_expand_word __P((char *)); + +/* Return a new line, with any aliases expanded. */ +extern char *alias_expand __P((char *)); + +#endif /* _ALIAS_H_ */ diff --git a/array.c b/array.c new file mode 100644 index 0000000..6a6db77 --- /dev/null +++ b/array.c @@ -0,0 +1,1154 @@ +/* + * array.c - functions to create, destroy, access, and manipulate arrays + * of strings. + * + * Arrays are sparse doubly-linked lists. An element's index is stored + * with it. + * + * Chet Ramey + * chet@ins.cwru.edu + */ + +/* Copyright (C) 1997-2009 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 3 of the License, 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. If not, see . +*/ + +#include "config.h" + +#if defined (ARRAY_VARS) + +#if defined (HAVE_UNISTD_H) +# ifdef _MINIX +# include +# endif +# include +#endif + +#include +#include "bashansi.h" + +#include "shell.h" +#include "array.h" +#include "builtins/common.h" + +#define ADD_BEFORE(ae, new) \ + do { \ + ae->prev->next = new; \ + new->prev = ae->prev; \ + ae->prev = new; \ + new->next = ae; \ + } while(0) + +static char *array_to_string_internal __P((ARRAY_ELEMENT *, ARRAY_ELEMENT *, char *, int)); + +/* lastref should be moved into the array structure so each array can be + optimized separately */ + +static ARRAY *lastarray = 0; +static ARRAY_ELEMENT *lastref = 0; + +#define IS_LASTREF(a) (lastarray && (a) == lastarray) + +#define LASTREF_START(a, i) \ + (IS_LASTREF(a) && i >= element_index(lastref)) ? lastref \ + : element_forw(a->head) + +#define INVALIDATE_LASTREF(a) \ +do { \ + if ((a) == lastarray) { \ + lastarray = 0; \ + lastref = 0; \ + } \ +} while (0) + +#define SET_LASTREF(a, e) \ +do { \ + lastarray = (a); \ + lastref = (e); \ +} while (0) + +#define UNSET_LASTREF() \ +do { \ + lastarray = 0; \ + lastref = 0; \ +} while (0) + +ARRAY * +array_create() +{ + ARRAY *r; + ARRAY_ELEMENT *head; + + r =(ARRAY *)xmalloc(sizeof(ARRAY)); + r->type = array_indexed; + r->max_index = -1; + r->num_elements = 0; + head = array_create_element(-1, (char *)NULL); /* dummy head */ + head->prev = head->next = head; + r->head = head; + return(r); +} + +void +array_flush (a) +ARRAY *a; +{ + register ARRAY_ELEMENT *r, *r1; + + if (a == 0) + return; + for (r = element_forw(a->head); r != a->head; ) { + r1 = element_forw(r); + array_dispose_element(r); + r = r1; + } + a->head->next = a->head->prev = a->head; + a->max_index = -1; + a->num_elements = 0; + INVALIDATE_LASTREF(a); +} + +void +array_dispose(a) +ARRAY *a; +{ + if (a == 0) + return; + array_flush (a); + array_dispose_element(a->head); + free(a); +} + +ARRAY * +array_copy(a) +ARRAY *a; +{ + ARRAY *a1; + ARRAY_ELEMENT *ae, *new; + + if (a == 0) + return((ARRAY *) NULL); + a1 = array_create(); + a1->type = a->type; + a1->max_index = a->max_index; + a1->num_elements = a->num_elements; + for (ae = element_forw(a->head); ae != a->head; ae = element_forw(ae)) { + new = array_create_element(element_index(ae), element_value(ae)); + ADD_BEFORE(a1->head, new); + } + return(a1); +} + +/* + * Make and return a new array composed of the elements in array A from + * S to E, inclusive. + */ +ARRAY * +array_slice(array, s, e) +ARRAY *array; +ARRAY_ELEMENT *s, *e; +{ + ARRAY *a; + ARRAY_ELEMENT *p, *n; + int i; + arrayind_t mi; + + a = array_create (); + a->type = array->type; + + for (mi = 0, p = s, i = 0; p != e; p = element_forw(p), i++) { + n = array_create_element (element_index(p), element_value(p)); + ADD_BEFORE(a->head, n); + mi = element_index(n); + } + a->num_elements = i; + a->max_index = mi; + return a; +} + +/* + * Walk the array, calling FUNC once for each element, with the array + * element as the argument. + */ +void +array_walk(a, func, udata) +ARRAY *a; +sh_ae_map_func_t *func; +void *udata; +{ + register ARRAY_ELEMENT *ae; + + if (a == 0 || array_empty(a)) + return; + for (ae = element_forw(a->head); ae != a->head; ae = element_forw(ae)) + if ((*func)(ae, udata) < 0) + return; +} + +/* + * Shift the array A N elements to the left. Delete the first N elements + * and subtract N from the indices of the remaining elements. If FLAGS + * does not include AS_DISPOSE, this returns a singly-linked null-terminated + * list of elements so the caller can dispose of the chain. If FLAGS + * includes AS_DISPOSE, this function disposes of the shifted-out elements + * and returns NULL. + */ +ARRAY_ELEMENT * +array_shift(a, n, flags) +ARRAY *a; +int n, flags; +{ + register ARRAY_ELEMENT *ae, *ret; + register int i; + + if (a == 0 || array_empty(a) || n <= 0) + return ((ARRAY_ELEMENT *)NULL); + + INVALIDATE_LASTREF(a); + for (i = 0, ret = ae = element_forw(a->head); ae != a->head && i < n; ae = element_forw(ae), i++) + ; + if (ae == a->head) { + /* Easy case; shifting out all of the elements */ + if (flags & AS_DISPOSE) { + array_flush (a); + return ((ARRAY_ELEMENT *)NULL); + } + for (ae = ret; element_forw(ae) != a->head; ae = element_forw(ae)) + ; + element_forw(ae) = (ARRAY_ELEMENT *)NULL; + a->head->next = a->head->prev = a->head; + a->max_index = -1; + a->num_elements = 0; + return ret; + } + /* + * ae now points to the list of elements we want to retain. + * ret points to the list we want to either destroy or return. + */ + ae->prev->next = (ARRAY_ELEMENT *)NULL; /* null-terminate RET */ + + a->head->next = ae; /* slice RET out of the array */ + ae->prev = a->head; + + for ( ; ae != a->head; ae = element_forw(ae)) + element_index(ae) -= n; /* renumber retained indices */ + + a->num_elements -= n; /* modify bookkeeping information */ + a->max_index = element_index(a->head->prev); + + if (flags & AS_DISPOSE) { + for (ae = ret; ae; ) { + ret = element_forw(ae); + array_dispose_element(ae); + ae = ret; + } + return ((ARRAY_ELEMENT *)NULL); + } + + return ret; +} + +/* + * Shift array A right N indices. If S is non-null, it becomes the value of + * the new element 0. Returns the number of elements in the array after the + * shift. + */ +int +array_rshift (a, n, s) +ARRAY *a; +int n; +char *s; +{ + register ARRAY_ELEMENT *ae, *new; + + if (a == 0 || (array_empty(a) && s == 0)) + return 0; + else if (n <= 0) + return (a->num_elements); + + ae = element_forw(a->head); + if (s) { + new = array_create_element(0, s); + ADD_BEFORE(ae, new); + a->num_elements++; + if (array_num_elements(a) == 1) { /* array was empty */ + a->max_index = 0; + return 1; + } + } + + /* + * Renumber all elements in the array except the one we just added. + */ + for ( ; ae != a->head; ae = element_forw(ae)) + element_index(ae) += n; + + a->max_index = element_index(a->head->prev); + + INVALIDATE_LASTREF(a); + return (a->num_elements); +} + +ARRAY_ELEMENT * +array_unshift_element(a) +ARRAY *a; +{ + return (array_shift (a, 1, 0)); +} + +int +array_shift_element(a, v) +ARRAY *a; +char *v; +{ + return (array_rshift (a, 1, v)); +} + +ARRAY * +array_quote(array) +ARRAY *array; +{ + ARRAY_ELEMENT *a; + char *t; + + if (array == 0 || array_head(array) == 0 || array_empty(array)) + return (ARRAY *)NULL; + for (a = element_forw(array->head); a != array->head; a = element_forw(a)) { + t = quote_string (a->value); + FREE(a->value); + a->value = t; + } + return array; +} + +ARRAY * +array_quote_escapes(array) +ARRAY *array; +{ + ARRAY_ELEMENT *a; + char *t; + + if (array == 0 || array_head(array) == 0 || array_empty(array)) + return (ARRAY *)NULL; + for (a = element_forw(array->head); a != array->head; a = element_forw(a)) { + t = quote_escapes (a->value); + FREE(a->value); + a->value = t; + } + return array; +} + +ARRAY * +array_dequote(array) +ARRAY *array; +{ + ARRAY_ELEMENT *a; + char *t; + + if (array == 0 || array_head(array) == 0 || array_empty(array)) + return (ARRAY *)NULL; + for (a = element_forw(array->head); a != array->head; a = element_forw(a)) { + t = dequote_string (a->value); + FREE(a->value); + a->value = t; + } + return array; +} + +ARRAY * +array_dequote_escapes(array) +ARRAY *array; +{ + ARRAY_ELEMENT *a; + char *t; + + if (array == 0 || array_head(array) == 0 || array_empty(array)) + return (ARRAY *)NULL; + for (a = element_forw(array->head); a != array->head; a = element_forw(a)) { + t = dequote_escapes (a->value); + FREE(a->value); + a->value = t; + } + return array; +} + +ARRAY * +array_remove_quoted_nulls(array) +ARRAY *array; +{ + ARRAY_ELEMENT *a; + char *t; + + if (array == 0 || array_head(array) == 0 || array_empty(array)) + return (ARRAY *)NULL; + for (a = element_forw(array->head); a != array->head; a = element_forw(a)) + a->value = remove_quoted_nulls (a->value); + return array; +} + +/* + * Return a string whose elements are the members of array A beginning at + * index START and spanning NELEM members. Null elements are counted. + * Since arrays are sparse, unset array elements are not counted. + */ +char * +array_subrange (a, start, nelem, starsub, quoted) +ARRAY *a; +arrayind_t start, nelem; +int starsub, quoted; +{ + ARRAY *a2; + ARRAY_ELEMENT *h, *p; + arrayind_t i; + char *ifs, *sifs, *t; + int slen; + + p = a ? array_head (a) : 0; + if (p == 0 || array_empty (a) || start > array_max_index(a)) + return ((char *)NULL); + + /* + * Find element with index START. If START corresponds to an unset + * element (arrays can be sparse), use the first element whose index + * is >= START. If START is < 0, we count START indices back from + * the end of A (not elements, even with sparse arrays -- START is an + * index). + */ + for (p = element_forw(p); p != array_head(a) && start > element_index(p); p = element_forw(p)) + ; + + if (p == a->head) + return ((char *)NULL); + + /* Starting at P, take NELEM elements, inclusive. */ + for (i = 0, h = p; p != a->head && i < nelem; i++, p = element_forw(p)) + ; + + a2 = array_slice(a, h, p); + + if (quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT)) + array_quote(a2); + else + array_quote_escapes(a2); + + if (starsub && (quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT))) { + /* ${array[*]} */ + array_remove_quoted_nulls (a2); + sifs = ifs_firstchar ((int *)NULL); + t = array_to_string (a2, sifs, 0); + free (sifs); + } else if (quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT)) { + /* ${array[@]} */ + sifs = ifs_firstchar (&slen); + ifs = getifs (); + if (ifs == 0 || *ifs == 0) { + if (slen < 2) + sifs = xrealloc(sifs, 2); + sifs[0] = ' '; + sifs[1] = '\0'; + } + t = array_to_string (a2, sifs, 0); + free (sifs); + } else + t = array_to_string (a2, " ", 0); + array_dispose(a2); + + return t; +} + +char * +array_patsub (a, pat, rep, mflags) +ARRAY *a; +char *pat, *rep; +int mflags; +{ + ARRAY *a2; + ARRAY_ELEMENT *e; + char *t, *sifs, *ifs; + int slen; + + if (a == 0 || array_head(a) == 0 || array_empty(a)) + return ((char *)NULL); + + a2 = array_copy(a); + for (e = element_forw(a2->head); e != a2->head; e = element_forw(e)) { + t = pat_subst(element_value(e), pat, rep, mflags); + FREE(element_value(e)); + e->value = t; + } + + if (mflags & MATCH_QUOTED) + array_quote(a2); + else + array_quote_escapes(a2); + + if (mflags & MATCH_STARSUB) { + array_remove_quoted_nulls (a2); + sifs = ifs_firstchar((int *)NULL); + t = array_to_string (a2, sifs, 0); + free(sifs); + } else if (mflags & MATCH_QUOTED) { + /* ${array[@]} */ + sifs = ifs_firstchar (&slen); + ifs = getifs (); + if (ifs == 0 || *ifs == 0) { + if (slen < 2) + sifs = xrealloc (sifs, 2); + sifs[0] = ' '; + sifs[1] = '\0'; + } + t = array_to_string (a2, sifs, 0); + free(sifs); + } else + t = array_to_string (a2, " ", 0); + array_dispose (a2); + + return t; +} + +char * +array_modcase (a, pat, modop, mflags) +ARRAY *a; +char *pat; +int modop; +int mflags; +{ + ARRAY *a2; + ARRAY_ELEMENT *e; + char *t, *sifs, *ifs; + int slen; + + if (a == 0 || array_head(a) == 0 || array_empty(a)) + return ((char *)NULL); + + a2 = array_copy(a); + for (e = element_forw(a2->head); e != a2->head; e = element_forw(e)) { + t = sh_modcase(element_value(e), pat, modop); + FREE(element_value(e)); + e->value = t; + } + + if (mflags & MATCH_QUOTED) + array_quote(a2); + else + array_quote_escapes(a2); + + if (mflags & MATCH_STARSUB) { + array_remove_quoted_nulls (a2); + sifs = ifs_firstchar((int *)NULL); + t = array_to_string (a2, sifs, 0); + free(sifs); + } else if (mflags & MATCH_QUOTED) { + /* ${array[@]} */ + sifs = ifs_firstchar (&slen); + ifs = getifs (); + if (ifs == 0 || *ifs == 0) { + if (slen < 2) + sifs = xrealloc (sifs, 2); + sifs[0] = ' '; + sifs[1] = '\0'; + } + t = array_to_string (a2, sifs, 0); + free(sifs); + } else + t = array_to_string (a2, " ", 0); + array_dispose (a2); + + return t; +} +/* + * Allocate and return a new array element with index INDEX and value + * VALUE. + */ +ARRAY_ELEMENT * +array_create_element(indx, value) +arrayind_t indx; +char *value; +{ + ARRAY_ELEMENT *r; + + r = (ARRAY_ELEMENT *)xmalloc(sizeof(ARRAY_ELEMENT)); + r->ind = indx; + r->value = value ? savestring(value) : (char *)NULL; + r->next = r->prev = (ARRAY_ELEMENT *) NULL; + return(r); +} + +#ifdef INCLUDE_UNUSED +ARRAY_ELEMENT * +array_copy_element(ae) +ARRAY_ELEMENT *ae; +{ + return(ae ? array_create_element(element_index(ae), element_value(ae)) + : (ARRAY_ELEMENT *) NULL); +} +#endif + +void +array_dispose_element(ae) +ARRAY_ELEMENT *ae; +{ + if (ae) { + FREE(ae->value); + free(ae); + } +} + +/* + * Add a new element with index I and value V to array A (a[i] = v). + */ +int +array_insert(a, i, v) +ARRAY *a; +arrayind_t i; +char *v; +{ + register ARRAY_ELEMENT *new, *ae, *start; + + if (a == 0) + return(-1); + new = array_create_element(i, v); + if (i > array_max_index(a)) { + /* + * Hook onto the end. This also works for an empty array. + * Fast path for the common case of allocating arrays + * sequentially. + */ + ADD_BEFORE(a->head, new); + a->max_index = i; + a->num_elements++; + SET_LASTREF(a, new); + return(0); + } +#if OPTIMIZE_SEQUENTIAL_ARRAY_ASSIGNMENT + /* + * Otherwise we search for the spot to insert it. The lastref + * handle optimizes the case of sequential or almost-sequential + * assignments that are not at the end of the array. + */ + start = LASTREF_START(a, i); +#else + start = element_forw(ae->head); +#endif + for (ae = start; ae != a->head; ae = element_forw(ae)) { + if (element_index(ae) == i) { + /* + * Replacing an existing element. + */ + array_dispose_element(new); + free(element_value(ae)); + ae->value = v ? savestring(v) : (char *)NULL; + SET_LASTREF(a, ae); + return(0); + } else if (element_index(ae) > i) { + ADD_BEFORE(ae, new); + a->num_elements++; + SET_LASTREF(a, new); + return(0); + } + } + array_dispose_element(new); + INVALIDATE_LASTREF(a); + return (-1); /* problem */ +} + +/* + * Delete the element with index I from array A and return it so the + * caller can dispose of it. + */ +ARRAY_ELEMENT * +array_remove(a, i) +ARRAY *a; +arrayind_t i; +{ + register ARRAY_ELEMENT *ae, *start; + + if (a == 0 || array_empty(a)) + return((ARRAY_ELEMENT *) NULL); + start = LASTREF_START(a, i); + for (ae = start; ae != a->head; ae = element_forw(ae)) + if (element_index(ae) == i) { + ae->next->prev = ae->prev; + ae->prev->next = ae->next; + a->num_elements--; + if (i == array_max_index(a)) + a->max_index = element_index(ae->prev); +#if 0 + INVALIDATE_LASTREF(a); +#else + if (ae->next != a->head) + SET_LASTREF(a, ae->next); + else if (ae->prev != a->head) + SET_LASTREF(a, ae->prev); + else + INVALIDATE_LASTREF(a); +#endif + return(ae); + } + return((ARRAY_ELEMENT *) NULL); +} + +/* + * Return the value of a[i]. + */ +char * +array_reference(a, i) +ARRAY *a; +arrayind_t i; +{ + register ARRAY_ELEMENT *ae, *start; + + if (a == 0 || array_empty(a)) + return((char *) NULL); + if (i > array_max_index(a)) + return((char *)NULL); /* Keep roving pointer into array to optimize sequential access */ + start = LASTREF_START(a, i); + for (ae = start; ae != a->head; ae = element_forw(ae)) + if (element_index(ae) == i) { + SET_LASTREF(a, ae); + return(element_value(ae)); + } + UNSET_LASTREF(); /* XXX SET_LASTREF(a, start) ? */ + return((char *) NULL); +} + +/* Convenience routines for the shell to translate to and from the form used + by the rest of the code. */ + +WORD_LIST * +array_to_word_list(a) +ARRAY *a; +{ + WORD_LIST *list; + ARRAY_ELEMENT *ae; + + if (a == 0 || array_empty(a)) + return((WORD_LIST *)NULL); + list = (WORD_LIST *)NULL; + for (ae = element_forw(a->head); ae != a->head; ae = element_forw(ae)) + list = make_word_list (make_bare_word(element_value(ae)), list); + return (REVERSE_LIST(list, WORD_LIST *)); +} + +ARRAY * +array_from_word_list (list) +WORD_LIST *list; +{ + ARRAY *a; + + if (list == 0) + return((ARRAY *)NULL); + a = array_create(); + return (array_assign_list (a, list)); +} + +WORD_LIST * +array_keys_to_word_list(a) +ARRAY *a; +{ + WORD_LIST *list; + ARRAY_ELEMENT *ae; + char *t; + + if (a == 0 || array_empty(a)) + return((WORD_LIST *)NULL); + list = (WORD_LIST *)NULL; + for (ae = element_forw(a->head); ae != a->head; ae = element_forw(ae)) { + t = itos(element_index(ae)); + list = make_word_list (make_bare_word(t), list); + free(t); + } + return (REVERSE_LIST(list, WORD_LIST *)); +} + +ARRAY * +array_assign_list (array, list) +ARRAY *array; +WORD_LIST *list; +{ + register WORD_LIST *l; + register arrayind_t i; + + for (l = list, i = 0; l; l = l->next, i++) + array_insert(array, i, l->word->word); + return array; +} + +char ** +array_to_argv (a) +ARRAY *a; +{ + char **ret, *t; + int i; + ARRAY_ELEMENT *ae; + + if (a == 0 || array_empty(a)) + return ((char **)NULL); + ret = strvec_create (array_num_elements (a) + 1); + i = 0; + for (ae = element_forw(a->head); ae != a->head; ae = element_forw(ae)) { + t = element_value (ae); + ret[i++] = t ? savestring (t) : (char *)NULL; + } + ret[i] = (char *)NULL; + return (ret); +} + +/* + * Return a string that is the concatenation of the elements in A from START + * to END, separated by SEP. + */ +static char * +array_to_string_internal (start, end, sep, quoted) +ARRAY_ELEMENT *start, *end; +char *sep; +int quoted; +{ + char *result, *t; + ARRAY_ELEMENT *ae; + int slen, rsize, rlen, reg; + + if (start == end) /* XXX - should not happen */ + return ((char *)NULL); + + slen = strlen(sep); + result = NULL; + for (rsize = rlen = 0, ae = start; ae != end; ae = element_forw(ae)) { + if (rsize == 0) + result = (char *)xmalloc (rsize = 64); + if (element_value(ae)) { + t = quoted ? quote_string(element_value(ae)) : element_value(ae); + reg = strlen(t); + RESIZE_MALLOCED_BUFFER (result, rlen, (reg + slen + 2), + rsize, rsize); + strcpy(result + rlen, t); + rlen += reg; + if (quoted) + free(t); + /* + * Add a separator only after non-null elements. + */ + if (element_forw(ae) != end) { + strcpy(result + rlen, sep); + rlen += slen; + } + } + } + if (result) + result[rlen] = '\0'; /* XXX */ + return(result); +} + +char * +array_to_assign (a, quoted) +ARRAY *a; +int quoted; +{ + char *result, *valstr, *is; + char indstr[INT_STRLEN_BOUND(intmax_t) + 1]; + ARRAY_ELEMENT *ae; + int rsize, rlen, elen; + + if (a == 0 || array_empty (a)) + return((char *)NULL); + + result = (char *)xmalloc (rsize = 128); + result[0] = '('; + rlen = 1; + + for (ae = element_forw(a->head); ae != a->head; ae = element_forw(ae)) { + is = inttostr (element_index(ae), indstr, sizeof(indstr)); + valstr = element_value (ae) ? + (ansic_shouldquote (element_value (ae)) ? + ansic_quote (element_value(ae), 0, (int *)0) : + sh_double_quote (element_value (ae))) + : (char *)NULL; + elen = STRLEN (is) + 8 + STRLEN (valstr); + RESIZE_MALLOCED_BUFFER (result, rlen, (elen + 1), rsize, rsize); + + result[rlen++] = '['; + strcpy (result + rlen, is); + rlen += STRLEN (is); + result[rlen++] = ']'; + result[rlen++] = '='; + if (valstr) { + strcpy (result + rlen, valstr); + rlen += STRLEN (valstr); + } + + if (element_forw(ae) != a->head) + result[rlen++] = ' '; + + FREE (valstr); + } + RESIZE_MALLOCED_BUFFER (result, rlen, 1, rsize, 8); + result[rlen++] = ')'; + result[rlen] = '\0'; + if (quoted) { + /* This is not as efficient as it could be... */ + valstr = sh_single_quote (result); + free (result); + result = valstr; + } + return(result); +} + +char * +array_to_string (a, sep, quoted) +ARRAY *a; +char *sep; +int quoted; +{ + if (a == 0) + return((char *)NULL); + if (array_empty(a)) + return(savestring("")); + return (array_to_string_internal (element_forw(a->head), a->head, sep, quoted)); +} + +#if defined (INCLUDE_UNUSED) || defined (TEST_ARRAY) +/* + * Return an array consisting of elements in S, separated by SEP + */ +ARRAY * +array_from_string(s, sep) +char *s, *sep; +{ + ARRAY *a; + WORD_LIST *w; + + if (s == 0) + return((ARRAY *)NULL); + w = list_string (s, sep, 0); + if (w == 0) + return((ARRAY *)NULL); + a = array_from_word_list (w); + return (a); +} +#endif + +#if defined (TEST_ARRAY) +/* + * To make a running version, compile -DTEST_ARRAY and link with: + * xmalloc.o syntax.o lib/malloc/libmalloc.a lib/sh/libsh.a + */ +int interrupt_immediately = 0; + +int +signal_is_trapped(s) +int s; +{ + return 0; +} + +void +fatal_error(const char *s, ...) +{ + fprintf(stderr, "array_test: fatal memory error\n"); + abort(); +} + +void +programming_error(const char *s, ...) +{ + fprintf(stderr, "array_test: fatal programming error\n"); + abort(); +} + +WORD_DESC * +make_bare_word (s) +const char *s; +{ + WORD_DESC *w; + + w = (WORD_DESC *)xmalloc(sizeof(WORD_DESC)); + w->word = s ? savestring(s) : savestring (""); + w->flags = 0; + return w; +} + +WORD_LIST * +make_word_list(x, l) +WORD_DESC *x; +WORD_LIST *l; +{ + WORD_LIST *w; + + w = (WORD_LIST *)xmalloc(sizeof(WORD_LIST)); + w->word = x; + w->next = l; + return w; +} + +WORD_LIST * +list_string(s, t, i) +char *s, *t; +int i; +{ + char *r, *a; + WORD_LIST *wl; + + if (s == 0) + return (WORD_LIST *)NULL; + r = savestring(s); + wl = (WORD_LIST *)NULL; + a = strtok(r, t); + while (a) { + wl = make_word_list (make_bare_word(a), wl); + a = strtok((char *)NULL, t); + } + return (REVERSE_LIST (wl, WORD_LIST *)); +} + +GENERIC_LIST * +list_reverse (list) +GENERIC_LIST *list; +{ + register GENERIC_LIST *next, *prev; + + for (prev = 0; list; ) { + next = list->next; + list->next = prev; + prev = list; + list = next; + } + return prev; +} + +char * +pat_subst(s, t, u, i) +char *s, *t, *u; +int i; +{ + return ((char *)NULL); +} + +char * +quote_string(s) +char *s; +{ + return savestring(s); +} + +print_element(ae) +ARRAY_ELEMENT *ae; +{ + char lbuf[INT_STRLEN_BOUND (intmax_t) + 1]; + + printf("array[%s] = %s\n", + inttostr (element_index(ae), lbuf, sizeof (lbuf)), + element_value(ae)); +} + +print_array(a) +ARRAY *a; +{ + printf("\n"); + array_walk(a, print_element, (void *)NULL); +} + +main() +{ + ARRAY *a, *new_a, *copy_of_a; + ARRAY_ELEMENT *ae, *aew; + char *s; + + a = array_create(); + array_insert(a, 1, "one"); + array_insert(a, 7, "seven"); + array_insert(a, 4, "four"); + array_insert(a, 1029, "one thousand twenty-nine"); + array_insert(a, 12, "twelve"); + array_insert(a, 42, "forty-two"); + print_array(a); + s = array_to_string (a, " ", 0); + printf("s = %s\n", s); + copy_of_a = array_from_string(s, " "); + printf("copy_of_a:"); + print_array(copy_of_a); + array_dispose(copy_of_a); + printf("\n"); + free(s); + ae = array_remove(a, 4); + array_dispose_element(ae); + ae = array_remove(a, 1029); + array_dispose_element(ae); + array_insert(a, 16, "sixteen"); + print_array(a); + s = array_to_string (a, " ", 0); + printf("s = %s\n", s); + copy_of_a = array_from_string(s, " "); + printf("copy_of_a:"); + print_array(copy_of_a); + array_dispose(copy_of_a); + printf("\n"); + free(s); + array_insert(a, 2, "two"); + array_insert(a, 1029, "new one thousand twenty-nine"); + array_insert(a, 0, "zero"); + array_insert(a, 134, ""); + print_array(a); + s = array_to_string (a, ":", 0); + printf("s = %s\n", s); + copy_of_a = array_from_string(s, ":"); + printf("copy_of_a:"); + print_array(copy_of_a); + array_dispose(copy_of_a); + printf("\n"); + free(s); + new_a = array_copy(a); + print_array(new_a); + s = array_to_string (new_a, ":", 0); + printf("s = %s\n", s); + copy_of_a = array_from_string(s, ":"); + free(s); + printf("copy_of_a:"); + print_array(copy_of_a); + array_shift(copy_of_a, 2, AS_DISPOSE); + printf("copy_of_a shifted by two:"); + print_array(copy_of_a); + ae = array_shift(copy_of_a, 2, 0); + printf("copy_of_a shifted by two:"); + print_array(copy_of_a); + for ( ; ae; ) { + aew = element_forw(ae); + array_dispose_element(ae); + ae = aew; + } + array_rshift(copy_of_a, 1, (char *)0); + printf("copy_of_a rshift by 1:"); + print_array(copy_of_a); + array_rshift(copy_of_a, 2, "new element zero"); + printf("copy_of_a rshift again by 2 with new element zero:"); + print_array(copy_of_a); + s = array_to_assign(copy_of_a, 0); + printf("copy_of_a=%s\n", s); + free(s); + ae = array_shift(copy_of_a, array_num_elements(copy_of_a), 0); + for ( ; ae; ) { + aew = element_forw(ae); + array_dispose_element(ae); + ae = aew; + } + array_dispose(copy_of_a); + printf("\n"); + array_dispose(a); + array_dispose(new_a); +} + +#endif /* TEST_ARRAY */ +#endif /* ARRAY_VARS */ diff --git a/array.h b/array.h new file mode 100644 index 0000000..fb4f789 --- /dev/null +++ b/array.h @@ -0,0 +1,119 @@ +/* array.h -- definitions for the interface exported by array.c that allows + the rest of the shell to manipulate array variables. */ + +/* Copyright (C) 1997-2009 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 3 of the License, 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. If not, see . +*/ + + +#ifndef _ARRAY_H_ +#define _ARRAY_H_ + +#include "stdc.h" + +typedef intmax_t arrayind_t; + +enum atype {array_indexed, array_assoc}; + +typedef struct array { + enum atype type; + arrayind_t max_index; + int num_elements; + struct array_element *head; +} ARRAY; + +typedef struct array_element { + arrayind_t ind; + char *value; + struct array_element *next, *prev; +} ARRAY_ELEMENT; + +typedef int sh_ae_map_func_t __P((ARRAY_ELEMENT *, void *)); + +/* Basic operations on entire arrays */ +extern ARRAY *array_create __P((void)); +extern void array_flush __P((ARRAY *)); +extern void array_dispose __P((ARRAY *)); +extern ARRAY *array_copy __P((ARRAY *)); +extern ARRAY *array_slice __P((ARRAY *, ARRAY_ELEMENT *, ARRAY_ELEMENT *)); +extern void array_walk __P((ARRAY *, sh_ae_map_func_t *, void *)); + +extern ARRAY_ELEMENT *array_shift __P((ARRAY *, int, int)); +extern int array_rshift __P((ARRAY *, int, char *)); +extern ARRAY_ELEMENT *array_unshift_element __P((ARRAY *)); +extern int array_shift_element __P((ARRAY *, char *)); + +extern ARRAY *array_quote __P((ARRAY *)); +extern ARRAY *array_quote_escapes __P((ARRAY *)); +extern ARRAY *array_dequote __P((ARRAY *)); +extern ARRAY *array_dequote_escapes __P((ARRAY *)); +extern ARRAY *array_remove_quoted_nulls __P((ARRAY *)); + +extern char *array_subrange __P((ARRAY *, arrayind_t, arrayind_t, int, int)); +extern char *array_patsub __P((ARRAY *, char *, char *, int)); +extern char *array_modcase __P((ARRAY *, char *, int, int)); + +/* Basic operations on array elements. */ +extern ARRAY_ELEMENT *array_create_element __P((arrayind_t, char *)); +extern ARRAY_ELEMENT *array_copy_element __P((ARRAY_ELEMENT *)); +extern void array_dispose_element __P((ARRAY_ELEMENT *)); + +extern int array_insert __P((ARRAY *, arrayind_t, char *)); +extern ARRAY_ELEMENT *array_remove __P((ARRAY *, arrayind_t)); +extern char *array_reference __P((ARRAY *, arrayind_t)); + +/* Converting to and from arrays */ +extern WORD_LIST *array_to_word_list __P((ARRAY *)); +extern ARRAY *array_from_word_list __P((WORD_LIST *)); +extern WORD_LIST *array_keys_to_word_list __P((ARRAY *)); + +extern ARRAY *array_assign_list __P((ARRAY *, WORD_LIST *)); + +extern char **array_to_argv __P((ARRAY *)); + +extern char *array_to_assign __P((ARRAY *, int)); +extern char *array_to_string __P((ARRAY *, char *, int)); +extern ARRAY *array_from_string __P((char *, char *)); + +/* Flags for array_shift */ +#define AS_DISPOSE 0x01 + +#define array_num_elements(a) ((a)->num_elements) +#define array_max_index(a) ((a)->max_index) +#define array_head(a) ((a)->head) +#define array_empty(a) ((a)->num_elements == 0) + +#define element_value(ae) ((ae)->value) +#define element_index(ae) ((ae)->ind) +#define element_forw(ae) ((ae)->next) +#define element_back(ae) ((ae)->prev) + +/* Convenience */ +#define array_push(a,v) \ + do { array_rshift ((a), 1, (v)); } while (0) +#define array_pop(a) \ + do { array_dispose_element (array_shift ((a), 1, 0)); } while (0) + +#define GET_ARRAY_FROM_VAR(n, v, a) \ + do { \ + (v) = find_variable (n); \ + (a) = ((v) && array_p ((v))) ? array_cell (v) : (ARRAY *)0; \ + } while (0) + +#define ALL_ELEMENT_SUB(c) ((c) == '@' || (c) == '*') + +#endif /* _ARRAY_H_ */ diff --git a/arrayfunc.c b/arrayfunc.c new file mode 100644 index 0000000..47c595e --- /dev/null +++ b/arrayfunc.c @@ -0,0 +1,1215 @@ +/* arrayfunc.c -- High-level array functions used by other parts of the shell. */ + +/* Copyright (C) 2001-2016 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 3 of the License, 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. If not, see . +*/ + +#include "config.h" + +#if defined (ARRAY_VARS) + +#if defined (HAVE_UNISTD_H) +# include +#endif +#include + +#include "bashintl.h" + +#include "shell.h" +#include "pathexp.h" + +#include "shmbutil.h" +#if defined (HAVE_MBSTR_H) && defined (HAVE_MBSCHR) +# include /* mbschr */ +#endif + +#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 *, char *, int)); +static SHELL_VAR *assign_array_element_internal __P((SHELL_VAR *, char *, char *, char *, int, char *, int)); + +static char *quote_assign __P((const char *)); +static void quote_array_assignment_chars __P((WORD_LIST *)); +static char *array_value_internal __P((const char *, int, int, int *, arrayind_t *)); + +/* Standard error message to use when encountering an invalid array subscript */ +const char * const 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); + + /* Make sure it's not marked as an associative array any more */ + VUNSETATTR (var, att_assoc); + + /* Since namerefs can't be array variables, turn off nameref attribute */ + VUNSETATTR (var, att_nameref); + + return var; +} + +/* Convert a shell variable to an array variable. The original value is + saved as array[0]. */ +SHELL_VAR * +convert_var_to_assoc (var) + SHELL_VAR *var; +{ + char *oldval; + HASH_TABLE *hash; + + oldval = value_cell (var); + hash = assoc_create (0); + if (oldval) + assoc_insert (hash, savestring ("0"), oldval); + + FREE (value_cell (var)); + var_setassoc (var, hash); + + /* 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_assoc); + VUNSETATTR (var, att_invisible); + + /* Make sure it's not marked as an indexed array any more */ + VUNSETATTR (var, att_array); + + /* Since namerefs can't be array variables, turn off nameref attribute */ + VUNSETATTR (var, att_nameref); + + return var; +} + +char * +make_array_variable_value (entry, ind, key, value, flags) + SHELL_VAR *entry; + arrayind_t ind; + char *key; + 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); + if (assoc_p (entry)) + newval = assoc_reference (assoc_cell (entry), key); + else + 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_assoc|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); + + return newval; +} + +static SHELL_VAR * +bind_array_var_internal (entry, ind, key, value, flags) + SHELL_VAR *entry; + arrayind_t ind; + char *key; + char *value; + int flags; +{ + char *newval; + + newval = make_array_variable_value (entry, ind, key, value, flags); + + if (entry->assign_func) + (*entry->assign_func) (entry, newval, ind, key); + else if (assoc_p (entry)) + assoc_insert (assoc_cell (entry), key, newval); + else + array_insert (array_cell (entry), ind, newval); + FREE (newval); + + VUNSETATTR (entry, att_invisible); /* no longer invisible */ + 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 = find_shell_variable (name); + + if (entry == (SHELL_VAR *) 0) + { + /* Is NAME a nameref variable that points to an unset variable? */ + entry = find_variable_nameref_for_create (name, 0); + if (entry == INVALID_NAMEREF_VALUE) + return ((SHELL_VAR *)0); + if (entry && nameref_p (entry)) + entry = make_new_array_variable (nameref_cell (entry)); + } + if (entry == (SHELL_VAR *) 0) + entry = make_new_array_variable (name); + else if ((readonly_p (entry) && (flags&ASS_FORCE) == 0) || 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, 0, value, flags)); +} + +SHELL_VAR * +bind_array_element (entry, ind, value, flags) + SHELL_VAR *entry; + arrayind_t ind; + char *value; + int flags; +{ + return (bind_array_var_internal (entry, ind, 0, value, flags)); +} + +SHELL_VAR * +bind_assoc_variable (entry, name, key, value, flags) + SHELL_VAR *entry; + char *name; + char *key; + char *value; + int flags; +{ + SHELL_VAR *dentry; + char *newval; + + if ((readonly_p (entry) && (flags&ASS_FORCE) == 0) || noassign_p (entry)) + { + if (readonly_p (entry)) + err_readonly (name); + return (entry); + } + + return (bind_array_var_internal (entry, 0, key, 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; + int sublen; + SHELL_VAR *entry, *nv; + + 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); + } + + entry = find_variable (vname); + entry = assign_array_element_internal (entry, name, vname, sub, sublen, value, flags); + + free (vname); + return entry; +} + +static SHELL_VAR * +assign_array_element_internal (entry, name, vname, sub, sublen, value, flags) + SHELL_VAR *entry; + char *name; /* only used for error messages */ + char *vname; + char *sub; + int sublen; + char *value; + int flags; +{ + char *akey; + arrayind_t ind; + + if (entry && assoc_p (entry)) + { + sub[sublen-1] = '\0'; + akey = expand_assignment_string_to_string (sub, 0); /* [ */ + sub[sublen-1] = ']'; + if (akey == 0 || *akey == 0) + { + err_badarraysub (name); + FREE (akey); + return ((SHELL_VAR *)NULL); + } + entry = bind_assoc_variable (entry, vname, akey, value, flags); + } + else + { + ind = array_expand_index (entry, sub, sublen); + /* negative subscripts to indexed arrays count back from end */ + if (entry && ind < 0) + ind = (array_p (entry) ? array_max_index (array_cell (entry)) : 0) + 1 + ind; + if (ind < 0) + { + err_badarraysub (name); + return ((SHELL_VAR *)NULL); + } + entry = bind_array_variable (vname, ind, value, flags); + } + + 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 FLAGS&1 is non-zero, an existing + variable is checked for the readonly or noassign attribute in preparation + for assignment (e.g., by the `read' builtin). If FLAGS&2 is non-zero, we + create an associative array. */ +SHELL_VAR * +find_or_make_array_variable (name, flags) + char *name; + int flags; +{ + SHELL_VAR *var; + + var = find_variable (name); + if (var == 0) + { + /* See if we have a nameref pointing to a variable that hasn't been + created yet. */ + var = find_variable_last_nameref (name, 1); + if (var && nameref_p (var) && invisible_p (var)) + { + internal_warning (_("%s: removing nameref attribute"), name); + VUNSETATTR (var, att_nameref); + } + if (var && nameref_p (var)) + { + if (valid_nameref_value (nameref_cell (var), 2) == 0) + { + sh_invalidid (nameref_cell (var)); + return ((SHELL_VAR *)NULL); + } + var = (flags & 2) ? make_new_assoc_variable (nameref_cell (var)) : make_new_array_variable (nameref_cell (var)); + } + } + + if (var == 0) + var = (flags & 2) ? make_new_assoc_variable (name) : make_new_array_variable (name); + else if ((flags & 1) && (readonly_p (var) || noassign_p (var))) + { + if (readonly_p (var)) + err_readonly (name); + return ((SHELL_VAR *)NULL); + } + else if ((flags & 2) && array_p (var)) + { + last_command_exit_value = 1; + report_error (_("%s: cannot convert indexed to associative array"), name); + return ((SHELL_VAR *)NULL); + } + else if (array_p (var) == 0 && assoc_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; + int vflags; + + vflags = 1; + if (flags & ASS_MKASSOC) + vflags |= 2; + + var = find_or_make_array_variable (name, vflags); + 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++) + bind_array_var_internal (var, i, 0, l->word->word, flags & ~ASS_APPEND); + + VUNSETATTR (var, att_invisible); /* no longer invisible */ + + return var; +} + +WORD_LIST * +expand_compound_array_assignment (var, value, flags) + SHELL_VAR *var; + char *value; + int flags; +{ + WORD_LIST *list, *nlist; + WORD_LIST *hd, *tl, *t, *n; + char *val; + int ni; + + /* This condition is true when invoked from the declare builtin with a + command like + declare -a d='([1]="" [2]="bdef" [5]="hello world" "test")' */ + 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 (var && assoc_p (var)) + { + if (val != value) + free (val); + return list; + } + + /* If we're using [subscript]=value, we need to quote each [ and ] to + prevent unwanted filename expansion. This doesn't need to be done + for associative array expansion, since that uses a different expansion + function (see assign_compound_array_list below). */ + 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; +} + +/* Callers ensure that VAR is not NULL */ +void +assign_compound_array_list (var, nlist, flags) + SHELL_VAR *var; + WORD_LIST *nlist; + int flags; +{ + ARRAY *a; + HASH_TABLE *h; + WORD_LIST *list; + char *w, *val, *nval, *savecmd; + int len, iflags, free_val; + arrayind_t ind, last_ind; + char *akey; + + a = (var && array_p (var)) ? array_cell (var) : (ARRAY *)0; + h = (var && assoc_p (var)) ? assoc_cell (var) : (HASH_TABLE *)0; + + akey = (char *)0; + ind = 0; + + /* Now that we are ready to assign values to the array, kill the existing + value. */ + if ((flags & ASS_APPEND) == 0) + { + if (a && array_p (var)) + array_flush (a); + else if (h && assoc_p (var)) + assoc_flush (h); + } + + last_ind = (a && (flags & ASS_APPEND)) ? array_max_index (a) + 1 : 0; + + for (list = nlist; list; list = list->next) + { + /* Don't allow var+=(values) to make assignments in VALUES append to + existing values by default. */ + iflags = flags & ~ASS_APPEND; + w = list->word->word; + + /* We have a word of the form [ind]=value */ + if ((list->word->flags & W_ASSIGNMENT) && w[0] == '[') + { + /* Don't have to handle embedded quotes specially any more, since + associative array subscripts have not been expanded yet (see + above). */ + len = skipsubscript (w, 0, 0); + + /* XXX - changes for `+=' */ + if (w[len] != ']' || (w[len+1] != '=' && (w[len+1] != '+' || w[len+2] != '='))) + { + if (assoc_p (var)) + { + err_badarraysub (w); + continue; + } + nval = make_variable_value (var, w, flags); + if (var->assign_func) + (*var->assign_func) (var, nval, last_ind, 0); + 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) + { + last_command_exit_value = 1; + if (assoc_p (var)) + report_error (_("%s: invalid associative array key"), w); + else + report_error (_("%s: cannot assign to non-numeric index"), w); + continue; + } + + if (array_p (var)) + { + ind = array_expand_index (var, w + 1, len); + /* negative subscripts to indexed arrays count back from end */ + if (ind < 0) + ind = array_max_index (array_cell (var)) + 1 + ind; + if (ind < 0) + { + err_badarraysub (w); + continue; + } + + last_ind = ind; + } + else if (assoc_p (var)) + { + /* This is not performed above, see expand_compound_array_assignment */ + w[len] = '\0'; /*[*/ + akey = expand_assignment_string_to_string (w+1, 0); + w[len] = ']'; + /* And we need to expand the value also, see below */ + if (akey == 0 || *akey == 0) + { + err_badarraysub (w); + FREE (akey); + continue; + } + } + + /* 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 if (assoc_p (var)) + { + last_command_exit_value = 1; + report_error (_("%s: %s: must use subscript when assigning associative array"), var->name, w); + continue; + } + else /* No [ind]=value, just a stray `=' */ + { + ind = last_ind; + val = w; + } + + free_val = 0; + /* See above; we need to expand the value here */ + if (assoc_p (var)) + { + val = expand_assignment_string_to_string (val, 0); + if (val == 0) + { + val = (char *)xmalloc (1); + val[0] = '\0'; /* like do_assignment_internal */ + } + free_val = 1; + } + + savecmd = this_command_name; + if (integer_p (var)) + this_command_name = (char *)NULL; /* no command name for errors */ + bind_array_var_internal (var, ind, akey, val, iflags); + last_ind++; + this_command_name = savecmd; + + if (free_val) + free (val); + } +} + +/* 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 (var, value, flags); + assign_compound_array_list (var, nlist, flags); + + if (nlist) + dispose_words (nlist); + + if (var) + VUNSETATTR (var, att_invisible); /* no longer invisible */ + + return (var); +} + +/* Quote globbing chars and characters in $IFS before the `=' in an assignment + statement (usually a compound array assignment) to protect them from + unwanted filename expansion or word splitting. */ +static char * +quote_assign (string) + const char *string; +{ + size_t slen; + int saw_eq; + char *temp, *t, *subs; + const char *s, *send; + int ss, se; + DECLARE_MBSTATE; + + slen = strlen (string); + send = string + slen; + + t = temp = (char *)xmalloc (slen * 2 + 1); + saw_eq = 0; + for (s = string; *s; ) + { + if (*s == '=') + saw_eq = 1; + if (saw_eq == 0 && *s == '[') /* looks like a subscript */ + { + ss = s - string; + se = skipsubscript (string, ss, 0); + subs = substring (s, ss, se); + *t++ = '\\'; + strcpy (t, subs); + t += se - ss; + *t++ = '\\'; + *t++ = ']'; + s += se + 1; + free (subs); + continue; + } + if (saw_eq == 0 && (glob_char_p (s) || isifs (*s))) + *t++ = '\\'; + + COPY_CHAR_P (t, s, send); + } + *t = '\0'; + return temp; +} + +/* For each word in a compound array assignment, if the word looks like + [ind]=value, quote globbing chars and characters in $IFS before the `='. */ +static void +quote_array_assignment_chars (list) + WORD_LIST *list; +{ + char *nword; + 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 hasn't been recognized as an assignment or + doesn't look like [ind]=value */ + if ((l->word->flags & W_ASSIGNMENT) == 0) + continue; + if (l->word->word[0] != '[' || mbschr (l->word->word, '=') == 0) /* ] */ + continue; + + nword = quote_assign (l->word->word); + free (l->word->word); + l->word->word = nword; + l->word->flags |= W_NOGLOB; /* XXX - W_NOSPLIT also? */ + } +} + +/* skipsubscript moved to subst.c to use private functions. 2009/02/24. */ + +/* 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; + char *akey; + ARRAY_ELEMENT *ae; + + len = skipsubscript (sub, 0, (var && assoc_p(var))); + 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) + { + if (array_p (var) || assoc_p (var)) + { + unbind_variable (var->name); /* XXX -- {array,assoc}_flush ? */ + return (0); + } + else + return -2; /* don't allow this to unset scalar variables */ + } + + if (assoc_p (var)) + { + akey = expand_assignment_string_to_string (sub, 0); /* [ */ + if (akey == 0 || *akey == 0) + { + builtin_error ("[%s]: %s", sub, _(bash_badsub_errmsg)); + FREE (akey); + return -1; + } + assoc_remove (assoc_cell (var), akey); + free (akey); + } + else if (array_p (var)) + { + ind = array_expand_index (var, sub, len+1); + /* negative subscripts to indexed arrays count back from end */ + if (ind < 0) + ind = array_max_index (array_cell (var)) + 1 + ind; + 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); + } + else /* array_p (var) == 0 && assoc_p (var) == 0 */ + { + akey = this_command_name; + ind = array_expand_index (var, sub, len+1); + this_command_name = akey; + if (ind == 0) + { + unbind_variable (var->name); + return (0); + } + else + return -2; /* any subscript other than 0 is invalid with scalar variables */ + } + + 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); + } +} + +/* Format and output an associative array assignment in compound form + VAR=(VALUES), suitable for re-use as input. */ +void +print_assoc_assignment (var, quoted) + SHELL_VAR *var; + int quoted; +{ + char *vstr; + + vstr = assoc_to_assign (assoc_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, flags) + const char *name; + int flags; +{ + char *t; + int r, len; + + t = mbschr (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, 0); + if (t[len] != ']' || len == 1) + return 0; + if (t[len+1] != '\0') + 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 (var, s, len) + SHELL_VAR *var; + char *s; + int len; +{ + char *exp, *t, *savecmd; + int expok; + arrayind_t val; + + exp = (char *)xmalloc (len); + strncpy (exp, s, len - 1); + exp[len - 1] = '\0'; + t = expand_arith_string (exp, Q_DOUBLE_QUOTES|Q_ARITH|Q_ARRAYSUB); /* XXX - Q_ARRAYSUB for future use */ + savecmd = this_command_name; + this_command_name = (char *)NULL; + val = evalexp (t, &expok); + this_command_name = savecmd; + free (t); + free (exp); + if (expok == 0) + { + last_command_exit_value = EXECUTION_FAILURE; + + if (no_longjmp_on_fatal_error) + return 0; + top_level_cleanup (); + 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) + const char *s; + char **subp; + int *lenp; +{ + char *t, *ret; + int ind, ni; + + t = mbschr (s, '['); + if (t == 0) + { + if (subp) + *subp = t; + if (lenp) + *lenp = 0; + return ((char *)NULL); + } + ind = t - s; + ni = skipsubscript (s, ind, 0); + 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) + const char *s; + char **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); /* XXX - handle namerefs here? */ + + free (t); + return var; /* now return invisible variables; caller must handle */ +} + +#define INDEX_ERROR() \ + do \ + { \ + if (var) \ + err_badarraysub (var->name); \ + else \ + { \ + t[-1] = '\0'; \ + err_badarraysub (s); \ + t[-1] = '['; /* ] */\ + } \ + return ((char *)NULL); \ + } \ + while (0) + +/* 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[*], 2 if the + reference is name[@], and 0 otherwise. */ +static char * +array_value_internal (s, quoted, flags, rtype, indp) + const char *s; + int quoted, flags, *rtype; + arrayind_t *indp; +{ + int len; + arrayind_t ind; + char *akey; + 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 */ + + /* [ */ + akey = 0; + if (ALL_ELEMENT_SUB (t[0]) && t[1] == ']') + { + if (rtype) + *rtype = (t[0] == '*') ? 1 : 2; + if ((flags & AV_ALLOWALL) == 0) + { + err_badarraysub (s); + return ((char *)NULL); + } + else if (var == 0 || value_cell (var) == 0) /* XXX - check for invisible_p(var) ? */ + return ((char *)NULL); + else if (array_p (var) == 0 && assoc_p (var) == 0) + l = add_string_to_list (value_cell (var), (WORD_LIST *)NULL); + else if (assoc_p (var)) + { + l = assoc_to_word_list (assoc_cell (var)); + if (l == (WORD_LIST *)NULL) + return ((char *)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); /* XXX - leak here */ + free (temp); + } + else /* ${name[@]} or unquoted ${name[*]} */ + /* XXX - bash-4.4/bash-5.0 test AV_ASSIGNRHS and pass PF_ASSIGNRHS */ + retval = string_list_dollar_at (l, quoted, (flags & AV_ASSIGNRHS) ? PF_ASSIGNRHS : 0); /* XXX - leak here */ + + dispose_words (l); + } + else + { + if (rtype) + *rtype = 0; + if (var == 0 || array_p (var) || assoc_p (var) == 0) + { + if ((flags & AV_USEIND) == 0 || indp == 0) + { + ind = array_expand_index (var, t, len); + if (ind < 0) + { + /* negative subscripts to indexed arrays count back from end */ + if (var && array_p (var)) + ind = array_max_index (array_cell (var)) + 1 + ind; + if (ind < 0) + INDEX_ERROR(); + } + if (indp) + *indp = ind; + } + else if (indp) + ind = *indp; + } + else if (assoc_p (var)) + { + t[len - 1] = '\0'; + akey = expand_assignment_string_to_string (t, 0); /* [ */ + t[len - 1] = ']'; + if (akey == 0 || *akey == 0) + { + FREE (akey); + INDEX_ERROR(); + } + } + + if (var == 0 || value_cell (var) == 0) /* XXX - check invisible_p(var) ? */ + { + FREE (akey); + return ((char *)NULL); + } + if (array_p (var) == 0 && assoc_p (var) == 0) + return (ind == 0 ? value_cell (var) : (char *)NULL); + else if (assoc_p (var)) + { + retval = assoc_reference (assoc_cell (var), akey); + free (akey); + } + else + 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, flags, rtype, indp) + const char *s; + int quoted, flags, *rtype; + arrayind_t *indp; +{ + return (array_value_internal (s, quoted, flags|AV_ALLOWALL, rtype, indp)); +} + +/* Return the value of the array indexing expression S as a single string. + If (FLAGS & AV_ALLOWALL) 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, flags, rtype, indp) + const char *s; + int flags, *rtype; + arrayind_t *indp; +{ + return (array_value_internal (s, 0, flags, rtype, indp)); +} + +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 (var_isset (var) == 0 || invisible_p (var)) + return (char *)NULL; + + if (array_p (var) == 0 && assoc_p (var) == 0) + l = add_string_to_list ("0", (WORD_LIST *)NULL); + else if (assoc_p (var)) + l = assoc_keys_to_word_list (assoc_cell (var)); + 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, 0); + + dispose_words (l); + return retval; +} +#endif /* ARRAY_VARS */ diff --git a/arrayfunc.h b/arrayfunc.h new file mode 100644 index 0000000..5ee2759 --- /dev/null +++ b/arrayfunc.h @@ -0,0 +1,80 @@ +/* arrayfunc.h -- declarations for miscellaneous array functions in arrayfunc.c */ + +/* Copyright (C) 2001-2010 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 3 of the License, 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. If not, see . +*/ + +#if !defined (_ARRAYFUNC_H_) +#define _ARRAYFUNC_H_ + +/* Must include variables.h before including this file. */ + +#if defined (ARRAY_VARS) + +/* Flags for array_value_internal and callers array_value/get_array_value */ +#define AV_ALLOWALL 0x001 +#define AV_QUOTED 0x002 +#define AV_USEIND 0x004 +#define AV_USEVAL 0x008 /* XXX - should move this */ +#define AV_ASSIGNRHS 0x010 /* no splitting, special case ${a[@]} */ + +extern SHELL_VAR *convert_var_to_array __P((SHELL_VAR *)); +extern SHELL_VAR *convert_var_to_assoc __P((SHELL_VAR *)); + +extern char *make_array_variable_value __P((SHELL_VAR *, arrayind_t, char *, char *, int)); + +extern SHELL_VAR *bind_array_variable __P((char *, arrayind_t, char *, int)); +extern SHELL_VAR *bind_array_element __P((SHELL_VAR *, arrayind_t, char *, int)); +extern SHELL_VAR *assign_array_element __P((char *, char *, int)); + +extern SHELL_VAR *bind_assoc_variable __P((SHELL_VAR *, char *, char *, char *, int)); + +extern SHELL_VAR *find_or_make_array_variable __P((char *, int)); + +extern SHELL_VAR *assign_array_from_string __P((char *, char *, int)); +extern SHELL_VAR *assign_array_var_from_word_list __P((SHELL_VAR *, WORD_LIST *, int)); + +extern WORD_LIST *expand_compound_array_assignment __P((SHELL_VAR *, char *, int)); +extern void assign_compound_array_list __P((SHELL_VAR *, WORD_LIST *, int)); +extern SHELL_VAR *assign_array_var_from_string __P((SHELL_VAR *, char *, int)); + +extern int unbind_array_element __P((SHELL_VAR *, char *)); +extern int skipsubscript __P((const char *, int, int)); + +extern void print_array_assignment __P((SHELL_VAR *, int)); +extern void print_assoc_assignment __P((SHELL_VAR *, int)); + +extern arrayind_t array_expand_index __P((SHELL_VAR *, char *, int)); +extern int valid_array_reference __P((const char *, int)); +extern char *array_value __P((const char *, int, int, int *, arrayind_t *)); +extern char *get_array_value __P((const char *, int, int *, arrayind_t *)); + +extern char *array_keys __P((char *, int)); + +extern char *array_variable_name __P((const char *, char **, int *)); +extern SHELL_VAR *array_variable_part __P((const char *, char **, int *)); + +#else + +#define AV_ALLOWALL 0 +#define AV_QUOTED 0 +#define AV_USEIND 0 +#define AV_ASSIGNRHS 0 + +#endif + +#endif /* !_ARRAYFUNC_H_ */ diff --git a/assoc.c b/assoc.c new file mode 100644 index 0000000..84a387c --- /dev/null +++ b/assoc.c @@ -0,0 +1,566 @@ +/* + * assoc.c - functions to manipulate associative arrays + * + * Associative arrays are standard shell hash tables. + * + * Chet Ramey + * chet@ins.cwru.edu + */ + +/* Copyright (C) 2008,2009,2011 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 3 of the License, 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. If not, see . +*/ + +#include "config.h" + +#if defined (ARRAY_VARS) + +#if defined (HAVE_UNISTD_H) +# ifdef _MINIX +# include +# endif +# include +#endif + +#include +#include "bashansi.h" + +#include "shell.h" +#include "array.h" +#include "assoc.h" +#include "builtins/common.h" + +static WORD_LIST *assoc_to_word_list_internal __P((HASH_TABLE *, int)); + +/* assoc_create == hash_create */ + +void +assoc_dispose (hash) + HASH_TABLE *hash; +{ + if (hash) + { + hash_flush (hash, 0); + hash_dispose (hash); + } +} + +void +assoc_flush (hash) + HASH_TABLE *hash; +{ + hash_flush (hash, 0); +} + +int +assoc_insert (hash, key, value) + HASH_TABLE *hash; + char *key; + char *value; +{ + BUCKET_CONTENTS *b; + + b = hash_search (key, hash, HASH_CREATE); + if (b == 0) + return -1; + /* If we are overwriting an existing element's value, we're not going to + use the key. Nothing in the array assignment code path frees the key + string, so we can free it here to avoid a memory leak. */ + if (b->key != key) + free (key); + FREE (b->data); + b->data = value ? savestring (value) : (char *)0; + return (0); +} + +/* Like assoc_insert, but returns b->data instead of freeing it */ +PTR_T +assoc_replace (hash, key, value) + HASH_TABLE *hash; + char *key; + char *value; +{ + BUCKET_CONTENTS *b; + PTR_T t; + + b = hash_search (key, hash, HASH_CREATE); + if (b == 0) + return (PTR_T)0; + /* If we are overwriting an existing element's value, we're not going to + use the key. Nothing in the array assignment code path frees the key + string, so we can free it here to avoid a memory leak. */ + if (b->key != key) + free (key); + t = b->data; + b->data = value ? savestring (value) : (char *)0; + return t; +} + +void +assoc_remove (hash, string) + HASH_TABLE *hash; + char *string; +{ + BUCKET_CONTENTS *b; + + b = hash_remove (string, hash, 0); + if (b) + { + free ((char *)b->data); + free (b->key); + free (b); + } +} + +char * +assoc_reference (hash, string) + HASH_TABLE *hash; + char *string; +{ + BUCKET_CONTENTS *b; + + if (hash == 0) + return (char *)0; + + b = hash_search (string, hash, 0); + return (b ? (char *)b->data : 0); +} + +/* Quote the data associated with each element of the hash table ASSOC, + using quote_string */ +HASH_TABLE * +assoc_quote (h) + HASH_TABLE *h; +{ + int i; + BUCKET_CONTENTS *tlist; + char *t; + + if (h == 0 || assoc_empty (h)) + return ((HASH_TABLE *)NULL); + + for (i = 0; i < h->nbuckets; i++) + for (tlist = hash_items (i, h); tlist; tlist = tlist->next) + { + t = quote_string ((char *)tlist->data); + FREE (tlist->data); + tlist->data = t; + } + + return h; +} + +/* Quote escape characters in the data associated with each element + of the hash table ASSOC, using quote_escapes */ +HASH_TABLE * +assoc_quote_escapes (h) + HASH_TABLE *h; +{ + int i; + BUCKET_CONTENTS *tlist; + char *t; + + if (h == 0 || assoc_empty (h)) + return ((HASH_TABLE *)NULL); + + for (i = 0; i < h->nbuckets; i++) + for (tlist = hash_items (i, h); tlist; tlist = tlist->next) + { + t = quote_escapes ((char *)tlist->data); + FREE (tlist->data); + tlist->data = t; + } + + return h; +} + +HASH_TABLE * +assoc_dequote (h) + HASH_TABLE *h; +{ + int i; + BUCKET_CONTENTS *tlist; + char *t; + + if (h == 0 || assoc_empty (h)) + return ((HASH_TABLE *)NULL); + + for (i = 0; i < h->nbuckets; i++) + for (tlist = hash_items (i, h); tlist; tlist = tlist->next) + { + t = dequote_string ((char *)tlist->data); + FREE (tlist->data); + tlist->data = t; + } + + return h; +} + +HASH_TABLE * +assoc_dequote_escapes (h) + HASH_TABLE *h; +{ + int i; + BUCKET_CONTENTS *tlist; + char *t; + + if (h == 0 || assoc_empty (h)) + return ((HASH_TABLE *)NULL); + + for (i = 0; i < h->nbuckets; i++) + for (tlist = hash_items (i, h); tlist; tlist = tlist->next) + { + t = dequote_escapes ((char *)tlist->data); + FREE (tlist->data); + tlist->data = t; + } + + return h; +} + +HASH_TABLE * +assoc_remove_quoted_nulls (h) + HASH_TABLE *h; +{ + int i; + BUCKET_CONTENTS *tlist; + char *t; + + if (h == 0 || assoc_empty (h)) + return ((HASH_TABLE *)NULL); + + for (i = 0; i < h->nbuckets; i++) + for (tlist = hash_items (i, h); tlist; tlist = tlist->next) + { + t = remove_quoted_nulls ((char *)tlist->data); + tlist->data = t; + } + + return h; +} + +/* + * Return a string whose elements are the members of array H beginning at + * the STARTth element and spanning NELEM members. Null elements are counted. + */ +char * +assoc_subrange (hash, start, nelem, starsub, quoted) +HASH_TABLE *hash; +arrayind_t start, nelem; +int starsub, quoted; +{ + WORD_LIST *l, *save, *h, *t; + int i, j; + char *ret; + + if (assoc_empty (hash)) + return ((char *)NULL); + + save = l = assoc_to_word_list (hash); + if (save == 0) + return ((char *)NULL); + + for (i = 1; l && i < start; i++) + l = l->next; + if (l == 0) + { + dispose_words (save); + return ((char *)NULL); + } + for (j = 0,h = t = l; l && j < nelem; j++) + { + t = l; + l = l->next; + } + + t->next = (WORD_LIST *)NULL; + + ret = string_list_pos_params (starsub ? '*' : '@', h, quoted); + + if (t != l) + t->next = l; + + dispose_words (save); + return (ret); + +} + +char * +assoc_patsub (h, pat, rep, mflags) + HASH_TABLE *h; + char *pat, *rep; + int mflags; +{ + BUCKET_CONTENTS *tlist; + int i, slen; + HASH_TABLE *h2; + char *t, *sifs, *ifs; + + if (h == 0 || assoc_empty (h)) + return ((char *)NULL); + + h2 = assoc_copy (h); + for (i = 0; i < h2->nbuckets; i++) + for (tlist = hash_items (i, h2); tlist; tlist = tlist->next) + { + t = pat_subst ((char *)tlist->data, pat, rep, mflags); + FREE (tlist->data); + tlist->data = t; + } + + if (mflags & MATCH_QUOTED) + assoc_quote (h2); + else + assoc_quote_escapes (h2); + + if (mflags & MATCH_STARSUB) + { + assoc_remove_quoted_nulls (h2); + sifs = ifs_firstchar ((int *)NULL); + t = assoc_to_string (h2, sifs, 0); + free (sifs); + } + else if (mflags & MATCH_QUOTED) + { + /* ${array[@]} */ + sifs = ifs_firstchar (&slen); + ifs = getifs (); + if (ifs == 0 || *ifs == 0) + { + if (slen < 2) + sifs = xrealloc (sifs, 2); + sifs[0] = ' '; + sifs[1] = '\0'; + } + t = assoc_to_string (h2, sifs, 0); + free(sifs); + } + else + t = assoc_to_string (h2, " ", 0); + + assoc_dispose (h2); + + return t; +} + +char * +assoc_modcase (h, pat, modop, mflags) + HASH_TABLE *h; + char *pat; + int modop; + int mflags; +{ + BUCKET_CONTENTS *tlist; + int i, slen; + HASH_TABLE *h2; + char *t, *sifs, *ifs; + + if (h == 0 || assoc_empty (h)) + return ((char *)NULL); + + h2 = assoc_copy (h); + for (i = 0; i < h2->nbuckets; i++) + for (tlist = hash_items (i, h2); tlist; tlist = tlist->next) + { + t = sh_modcase ((char *)tlist->data, pat, modop); + FREE (tlist->data); + tlist->data = t; + } + + if (mflags & MATCH_QUOTED) + assoc_quote (h2); + else + assoc_quote_escapes (h2); + + if (mflags & MATCH_STARSUB) + { + assoc_remove_quoted_nulls (h2); + sifs = ifs_firstchar ((int *)NULL); + t = assoc_to_string (h2, sifs, 0); + free (sifs); + } + else if (mflags & MATCH_QUOTED) + { + /* ${array[@]} */ + sifs = ifs_firstchar (&slen); + ifs = getifs (); + if (ifs == 0 || *ifs == 0) + { + if (slen < 2) + sifs = xrealloc (sifs, 2); + sifs[0] = ' '; + sifs[1] = '\0'; + } + t = assoc_to_string (h2, sifs, 0); + free(sifs); + } + else + t = assoc_to_string (h2, " ", 0); + + assoc_dispose (h2); + + return t; +} + +char * +assoc_to_assign (hash, quoted) + HASH_TABLE *hash; + int quoted; +{ + char *ret; + char *istr, *vstr; + int i, rsize, rlen, elen; + BUCKET_CONTENTS *tlist; + + if (hash == 0 || assoc_empty (hash)) + return (char *)0; + + ret = xmalloc (rsize = 128); + ret[0] = '('; + rlen = 1; + + for (i = 0; i < hash->nbuckets; i++) + for (tlist = hash_items (i, hash); tlist; tlist = tlist->next) + { + if (ansic_shouldquote (tlist->key)) + istr = ansic_quote (tlist->key, 0, (int *)0); + else if (sh_contains_shell_metas (tlist->key)) + istr = sh_double_quote (tlist->key); + else if (ALL_ELEMENT_SUB (tlist->key[0]) && tlist->key[1] == '\0') + istr = sh_double_quote (tlist->key); + else + istr = tlist->key; + + vstr = tlist->data ? (ansic_shouldquote ((char *)tlist->data) ? + ansic_quote ((char *)tlist->data, 0, (int *)0) : + sh_double_quote ((char *)tlist->data)) + : (char *)0; + + elen = STRLEN (istr) + 8 + STRLEN (vstr); + RESIZE_MALLOCED_BUFFER (ret, rlen, (elen+1), rsize, rsize); + + ret[rlen++] = '['; + strcpy (ret+rlen, istr); + rlen += STRLEN (istr); + ret[rlen++] = ']'; + ret[rlen++] = '='; + if (vstr) + { + strcpy (ret + rlen, vstr); + rlen += STRLEN (vstr); + } + ret[rlen++] = ' '; + + + if (istr != tlist->key) + FREE (istr); + + FREE (vstr); + } + + RESIZE_MALLOCED_BUFFER (ret, rlen, 1, rsize, 8); + ret[rlen++] = ')'; + ret[rlen] = '\0'; + + if (quoted) + { + vstr = sh_single_quote (ret); + free (ret); + ret = vstr; + } + + return ret; +} + +static WORD_LIST * +assoc_to_word_list_internal (h, t) + HASH_TABLE *h; + int t; +{ + WORD_LIST *list; + int i; + BUCKET_CONTENTS *tlist; + char *w; + + if (h == 0 || assoc_empty (h)) + return((WORD_LIST *)NULL); + list = (WORD_LIST *)NULL; + + for (i = 0; i < h->nbuckets; i++) + for (tlist = hash_items (i, h); tlist; tlist = tlist->next) + { + w = (t == 0) ? (char *)tlist->data : (char *)tlist->key; + list = make_word_list (make_bare_word(w), list); + } + return (REVERSE_LIST(list, WORD_LIST *)); +} + +WORD_LIST * +assoc_to_word_list (h) + HASH_TABLE *h; +{ + return (assoc_to_word_list_internal (h, 0)); +} + +WORD_LIST * +assoc_keys_to_word_list (h) + HASH_TABLE *h; +{ + return (assoc_to_word_list_internal (h, 1)); +} + +char * +assoc_to_string (h, sep, quoted) + HASH_TABLE *h; + char *sep; + int quoted; +{ + BUCKET_CONTENTS *tlist; + int i; + char *result, *t, *w; + WORD_LIST *list, *l; + + if (h == 0) + return ((char *)NULL); + if (assoc_empty (h)) + return (savestring ("")); + + result = NULL; + l = list = NULL; + /* This might be better implemented directly, but it's simple to implement + by converting to a word list first, possibly quoting the data, then + using list_string */ + for (i = 0; i < h->nbuckets; i++) + for (tlist = hash_items (i, h); tlist; tlist = tlist->next) + { + w = (char *)tlist->data; + if (w == 0) + continue; + t = quoted ? quote_string (w) : savestring (w); + list = make_word_list (make_bare_word(t), list); + FREE (t); + } + + l = REVERSE_LIST(list, WORD_LIST *); + + result = l ? string_list_internal (l, sep) : savestring (""); + dispose_words (l); + + return result; +} + +#endif /* ARRAY_VARS */ diff --git a/assoc.h b/assoc.h new file mode 100644 index 0000000..db8383b --- /dev/null +++ b/assoc.h @@ -0,0 +1,62 @@ +/* assoc.h -- definitions for the interface exported by assoc.c that allows + the rest of the shell to manipulate associative array variables. */ + +/* Copyright (C) 2008,2009 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 3 of the License, 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. If not, see . +*/ + +#ifndef _ASSOC_H_ +#define _ASSOC_H_ + +#include "stdc.h" +#include "hashlib.h" + +#define assoc_empty(h) ((h)->nentries == 0) +#define assoc_num_elements(h) ((h)->nentries) + +#define assoc_create(n) (hash_create((n))) + +#define assoc_copy(h) (hash_copy((h), 0)) + +#define assoc_walk(h, f) (hash_walk((h), (f)) + +extern void assoc_dispose __P((HASH_TABLE *)); +extern void assoc_flush __P((HASH_TABLE *)); + +extern int assoc_insert __P((HASH_TABLE *, char *, char *)); +extern PTR_T assoc_replace __P((HASH_TABLE *, char *, char *)); +extern void assoc_remove __P((HASH_TABLE *, char *)); + +extern char *assoc_reference __P((HASH_TABLE *, char *)); + +extern char *assoc_subrange __P((HASH_TABLE *, arrayind_t, arrayind_t, int, int)); +extern char *assoc_patsub __P((HASH_TABLE *, char *, char *, int)); +extern char *assoc_modcase __P((HASH_TABLE *, char *, int, int)); + +extern HASH_TABLE *assoc_quote __P((HASH_TABLE *)); +extern HASH_TABLE *assoc_quote_escapes __P((HASH_TABLE *)); +extern HASH_TABLE *assoc_dequote __P((HASH_TABLE *)); +extern HASH_TABLE *assoc_dequote_escapes __P((HASH_TABLE *)); +extern HASH_TABLE *assoc_remove_quoted_nulls __P((HASH_TABLE *)); + +extern char *assoc_to_assign __P((HASH_TABLE *, int)); + +extern WORD_LIST *assoc_to_word_list __P((HASH_TABLE *)); +extern WORD_LIST *assoc_keys_to_word_list __P((HASH_TABLE *)); + +extern char *assoc_to_string __P((HASH_TABLE *, char *, int)); +#endif /* _ASSOC_H_ */ diff --git a/bashansi.h b/bashansi.h new file mode 100644 index 0000000..2c33937 --- /dev/null +++ b/bashansi.h @@ -0,0 +1,41 @@ +/* bashansi.h -- Typically included information required by picky compilers. */ + +/* Copyright (C) 1993-2009 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 3 of the License, 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. If not, see . +*/ + +#if !defined (_BASHANSI_H_) +#define _BASHANSI_H_ + +#if defined (HAVE_STRING_H) +# if ! defined (STDC_HEADERS) && defined (HAVE_MEMORY_H) +# include +# endif +# include +#endif /* !HAVE_STRING_H */ + +#if defined (HAVE_STRINGS_H) +# include +#endif /* !HAVE_STRINGS_H */ + +#if defined (HAVE_STDLIB_H) +# include +#else +# include "ansi_stdlib.h" +#endif /* !HAVE_STDLIB_H */ + +#endif /* !_BASHANSI_H_ */ diff --git a/bashhist.c b/bashhist.c new file mode 100644 index 0000000..9979f99 --- /dev/null +++ b/bashhist.c @@ -0,0 +1,978 @@ +/* bashhist.c -- bash interface to the GNU history library. */ + +/* Copyright (C) 1993-2015 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 3 of the License, 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. If not, see . +*/ + +#include "config.h" + +#if defined (HISTORY) + +#if defined (HAVE_UNISTD_H) +# ifdef _MINIX + # include +# endif +# include +#endif + +#include "bashtypes.h" +#include +#include +#include "bashansi.h" +#include "posixstat.h" +#include "filecntl.h" + +#include "bashintl.h" + +#if defined (SYSLOG_HISTORY) +# include +#endif + +#include "shell.h" +#include "flags.h" +#include "input.h" +#include "parser.h" /* for the struct dstack stuff. */ +#include "pathexp.h" /* for the struct ignorevar stuff */ +#include "bashhist.h" /* matching prototypes and declarations */ +#include "builtins/common.h" + +#include +#include +#include + +#if defined (READLINE) +# include "bashline.h" +extern int rl_done, rl_dispatching; /* should really include readline.h */ +#endif + +#if !defined (errno) +extern int errno; +#endif + +static int histignore_item_func __P((struct ign *)); +static int check_history_control __P((char *)); +static void hc_erasedups __P((char *)); +static void really_add_history __P((char *)); + +static struct ignorevar histignore = +{ + "HISTIGNORE", + (struct ign *)0, + 0, + (char *)0, + (sh_iv_item_func_t *)histignore_item_func, +}; + +#define HIGN_EXPAND 0x01 + +/* Declarations of bash history variables. */ +/* Non-zero means to remember lines typed to the shell on the history + list. This is different than the user-controlled behaviour; this + becomes zero when we read lines from a file, for example. */ +int remember_on_history = 0; +int enable_history_list = 0; /* value for `set -o history' */ + +/* The number of lines that Bash has added to this history session. The + difference between the number of the top element in the history list + (offset from history_base) and the number of lines in the history file. + Appending this session's history to the history file resets this to 0. */ +int history_lines_this_session; + +/* The number of lines that Bash has read from the history file. */ +int history_lines_in_file; + +#if defined (BANG_HISTORY) +/* Non-zero means do no history expansion on this line, regardless + of what history_expansion says. */ +int history_expansion_inhibited; +/* If non-zero, double quotes can quote the history expansion character. */ +int double_quotes_inhibit_history_expansion = 0; +#endif + +/* With the old default, every line was saved in the history individually. + I.e., if the user enters: + bash$ for i in a b c + > do + > echo $i + > done + Each line will be individually saved in the history. + bash$ history + 10 for i in a b c + 11 do + 12 echo $i + 13 done + 14 history + If the variable command_oriented_history is set, multiple lines + which form one command will be saved as one history entry. + bash$ for i in a b c + > do + > echo $i + > done + bash$ history + 10 for i in a b c + do + echo $i + done + 11 history + The user can then recall the whole command all at once instead + of just being able to recall one line at a time. + + This is now enabled by default. + */ +int command_oriented_history = 1; + +/* Set to 1 if the first line of a possibly-multi-line command was saved + in the history list. Managed by maybe_add_history(), but global so + the history-manipluating builtins can see it. */ +int current_command_first_line_saved = 0; + +/* Non-zero means to store newlines in the history list when using + command_oriented_history rather than trying to use semicolons. */ +int literal_history; + +/* Non-zero means to append the history to the history file at shell + exit, even if the history has been stifled. */ +int force_append_history; + +/* A nit for picking at history saving. Flags have the following values: + + Value == 0 means save all lines parsed by the shell on the history. + Value & HC_IGNSPACE means save all lines that do not start with a space. + Value & HC_IGNDUPS means save all lines that do not match the last + line saved. + Value & HC_ERASEDUPS means to remove all other matching lines from the + history list before saving the latest line. */ +int history_control; + +/* Set to 1 if the last command was added to the history list successfully + as a separate history entry; set to 0 if the line was ignored or added + to a previous entry as part of command-oriented-history processing. */ +int hist_last_line_added; + +/* Set to 1 if builtins/history.def:push_history added the last history + entry. */ +int hist_last_line_pushed; + +#if defined (READLINE) +/* If non-zero, and readline is being used, the user is offered the + chance to re-edit a failed history expansion. */ +int history_reediting; + +/* If non-zero, and readline is being used, don't directly execute a + line with history substitution. Reload it into the editing buffer + instead and let the user further edit and confirm with a newline. */ +int hist_verify; + +#endif /* READLINE */ + +/* Non-zero means to not save function definitions in the history list. */ +int dont_save_function_defs; + +/* Variables declared in other files used here. */ +extern int current_command_line_count; + +extern struct dstack dstack; +extern int parser_state; + +#if defined (BANG_HISTORY) +static int bash_history_inhibit_expansion __P((char *, int)); +#endif +#if defined (READLINE) +static void re_edit __P((char *)); +#endif +static int history_expansion_p __P((char *)); +static int shell_comment __P((char *)); +static int should_expand __P((char *)); +static HIST_ENTRY *last_history_entry __P((void)); +static char *expand_histignore_pattern __P((char *)); +static int history_should_ignore __P((char *)); + +#if defined (BANG_HISTORY) +/* Is the history expansion starting at string[i] one that should not + be expanded? */ +static int +bash_history_inhibit_expansion (string, i) + char *string; + int i; +{ + int t; + char hx[2]; + + hx[0] = history_expansion_char; + hx[1] = '\0'; + + /* The shell uses ! as a pattern negation character in globbing [...] + expressions, so let those pass without expansion. */ + if (i > 0 && (string[i - 1] == '[') && member (']', string + i + 1)) + return (1); + /* The shell uses ! as the indirect expansion character, so let those + expansions pass as well. */ + else if (i > 1 && string[i - 1] == '{' && string[i - 2] == '$' && + member ('}', string + i + 1)) + return (1); + /* The shell uses $! as a defined parameter expansion. */ + else if (i > 1 && string[i - 1] == '$' && string[i] == '!') + return (1); +#if defined (EXTENDED_GLOB) + else if (extended_glob && i > 1 && string[i+1] == '(' && member (')', string + i + 2)) + return (1); +#endif + + /* Make sure the history expansion should not be skipped by quoting or + command/process substitution. */ + else if ((t = skip_to_histexp (string, 0, hx, SD_NOJMP|SD_HISTEXP)) > 0) + { + /* Skip instances of history expansion appearing on the line before + this one. */ + while (t < i) + { + t = skip_to_histexp (string, t+1, hx, SD_NOJMP|SD_HISTEXP); + if (t <= 0) + return 0; + } + return (t > i); + } + else + return (0); +} +#endif + +void +bash_initialize_history () +{ + history_quotes_inhibit_expansion = 1; + history_search_delimiter_chars = ";&()|<>"; +#if defined (BANG_HISTORY) + history_inhibit_expansion_function = bash_history_inhibit_expansion; + sv_histchars ("histchars"); +#endif +} + +void +bash_history_reinit (interact) + int interact; +{ +#if defined (BANG_HISTORY) + history_expansion = interact != 0; + history_expansion_inhibited = 1; /* XXX */ + history_inhibit_expansion_function = bash_history_inhibit_expansion; +#endif + remember_on_history = enable_history_list; +} + +void +bash_history_disable () +{ + remember_on_history = 0; +#if defined (BANG_HISTORY) + history_expansion_inhibited = 1; +#endif +} + +void +bash_history_enable () +{ + remember_on_history = enable_history_list = 1; +#if defined (BANG_HISTORY) + history_expansion_inhibited = 0; + history_inhibit_expansion_function = bash_history_inhibit_expansion; +#endif + sv_history_control ("HISTCONTROL"); + sv_histignore ("HISTIGNORE"); +} + +/* Load the history list from the history file. */ +void +load_history () +{ + char *hf; + + /* Truncate history file for interactive shells which desire it. + Note that the history file is automatically truncated to the + size of HISTSIZE if the user does not explicitly set the size + differently. */ + set_if_not ("HISTSIZE", "500"); + sv_histsize ("HISTSIZE"); + + set_if_not ("HISTFILESIZE", get_string_value ("HISTSIZE")); + sv_histsize ("HISTFILESIZE"); + + /* Read the history in HISTFILE into the history list. */ + hf = get_string_value ("HISTFILE"); + + if (hf && *hf && file_exists (hf)) + { + read_history (hf); + /* We have read all of the lines from the history file, even if we + read more lines than $HISTSIZE. Remember the total number of lines + we read so we don't count the last N lines as new over and over + again. */ + history_lines_in_file = history_lines_read_from_file; + using_history (); + /* history_lines_in_file = where_history () + history_base - 1; */ + } +} + +void +bash_clear_history () +{ + clear_history (); + history_lines_this_session = 0; + /* XXX - reset history_lines_read_from_file? */ +} + +/* Delete and free the history list entry at offset I. */ +int +bash_delete_histent (i) + int i; +{ + HIST_ENTRY *discard; + + discard = remove_history (i); + if (discard) + free_history_entry (discard); + history_lines_this_session--; + + return 1; +} + +int +bash_delete_last_history () +{ + register int i; + HIST_ENTRY **hlist, *histent; + int r; + + hlist = history_list (); + if (hlist == NULL) + return 0; + + for (i = 0; hlist[i]; i++) + ; + i--; + + /* History_get () takes a parameter that must be offset by history_base. */ + histent = history_get (history_base + i); /* Don't free this */ + if (histent == NULL) + return 0; + + r = bash_delete_histent (i); + + if (where_history () > history_length) + history_set_pos (history_length); + + return r; +} + +#ifdef INCLUDE_UNUSED +/* Write the existing history out to the history file. */ +void +save_history () +{ + char *hf; + int r; + + hf = get_string_value ("HISTFILE"); + if (hf && *hf && file_exists (hf)) + { + /* Append only the lines that occurred this session to + the history file. */ + using_history (); + + if (history_lines_this_session <= where_history () || force_append_history) + r = append_history (history_lines_this_session, hf); + else + r = write_history (hf); + sv_histsize ("HISTFILESIZE"); + } +} +#endif + +int +maybe_append_history (filename) + char *filename; +{ + int fd, result; + struct stat buf; + + result = EXECUTION_SUCCESS; + if (history_lines_this_session > 0 && (history_lines_this_session <= where_history ())) + { + /* If the filename was supplied, then create it if necessary. */ + if (stat (filename, &buf) == -1 && errno == ENOENT) + { + fd = open (filename, O_WRONLY|O_CREAT, 0600); + if (fd < 0) + { + builtin_error (_("%s: cannot create: %s"), filename, strerror (errno)); + return (EXECUTION_FAILURE); + } + close (fd); + } + result = append_history (history_lines_this_session, filename); + /* Pretend we already read these lines from the file because we just + added them */ + history_lines_in_file += history_lines_this_session; + history_lines_this_session = 0; + } + else + history_lines_this_session = 0; /* reset if > where_history() */ + + return (result); +} + +/* If this is an interactive shell, then append the lines executed + this session to the history file. */ +int +maybe_save_shell_history () +{ + int result; + char *hf; + + result = 0; + if (history_lines_this_session > 0) + { + hf = get_string_value ("HISTFILE"); + + if (hf && *hf) + { + /* If the file doesn't exist, then create it. */ + if (file_exists (hf) == 0) + { + int file; + file = open (hf, O_CREAT | O_TRUNC | O_WRONLY, 0600); + if (file != -1) + close (file); + } + + /* Now actually append the lines if the history hasn't been + stifled. If the history has been stifled, rewrite the + history file. */ + using_history (); + if (history_lines_this_session <= where_history () || force_append_history) + { + result = append_history (history_lines_this_session, hf); + history_lines_in_file += history_lines_this_session; + } + else + { + result = write_history (hf); + history_lines_in_file = history_lines_written_to_file; + /* history_lines_in_file = where_history () + history_base - 1; */ + } + history_lines_this_session = 0; + + sv_histsize ("HISTFILESIZE"); + } + } + return (result); +} + +#if defined (READLINE) +/* Tell readline () that we have some text for it to edit. */ +static void +re_edit (text) + char *text; +{ + if (bash_input.type == st_stdin) + bash_re_edit (text); +} +#endif /* READLINE */ + +/* Return 1 if this line needs history expansion. */ +static int +history_expansion_p (line) + char *line; +{ + register char *s; + + for (s = line; *s; s++) + if (*s == history_expansion_char || *s == history_subst_char) + return 1; + return 0; +} + +/* Do pre-processing on LINE. If PRINT_CHANGES is non-zero, then + print the results of expanding the line if there were any changes. + If there is an error, return NULL, otherwise the expanded line is + returned. If ADDIT is non-zero the line is added to the history + list after history expansion. ADDIT is just a suggestion; + REMEMBER_ON_HISTORY can veto, and does. + Right now this does history expansion. */ +char * +pre_process_line (line, print_changes, addit) + char *line; + int print_changes, addit; +{ + char *history_value; + char *return_value; + int expanded; + + return_value = line; + expanded = 0; + +# if defined (BANG_HISTORY) + /* History expand the line. If this results in no errors, then + add that line to the history if ADDIT is non-zero. */ + if (!history_expansion_inhibited && history_expansion && history_expansion_p (line)) + { + expanded = history_expand (line, &history_value); + + if (expanded) + { + if (print_changes) + { + if (expanded < 0) + internal_error ("%s", history_value); +#if defined (READLINE) + else if (hist_verify == 0 || expanded == 2) +#else + else +#endif + fprintf (stderr, "%s\n", history_value); + } + + /* If there was an error, return NULL. */ + if (expanded < 0 || expanded == 2) /* 2 == print only */ + { +# if defined (READLINE) + if (expanded == 2 && rl_dispatching == 0 && *history_value) +# else + if (expanded == 2 && *history_value) +# endif /* !READLINE */ + maybe_add_history (history_value); + + free (history_value); + +# if defined (READLINE) + /* New hack. We can allow the user to edit the + failed history expansion. */ + if (history_reediting && expanded < 0 && rl_done) + re_edit (line); +# endif /* READLINE */ + return ((char *)NULL); + } + +# if defined (READLINE) + if (hist_verify && expanded == 1) + { + re_edit (history_value); + free (history_value); + return ((char *)NULL); + } +# endif + } + + /* Let other expansions know that return_value can be free'ed, + and that a line has been added to the history list. Note + that we only add lines that have something in them. */ + expanded = 1; + return_value = history_value; + } +# endif /* BANG_HISTORY */ + + if (addit && remember_on_history && *return_value) + maybe_add_history (return_value); + +#if 0 + if (expanded == 0) + return_value = savestring (line); +#endif + + return (return_value); +} + +/* Return 1 if the first non-whitespace character in LINE is a `#', indicating + * that the line is a shell comment. */ +static int +shell_comment (line) + char *line; +{ + char *p; + + for (p = line; p && *p && whitespace (*p); p++) + ; + return (p && *p == '#'); +} + +#ifdef INCLUDE_UNUSED +/* Remove shell comments from LINE. A `#' and anything after it is a comment. + This isn't really useful yet, since it doesn't handle quoting. */ +static char * +filter_comments (line) + char *line; +{ + char *p; + + for (p = line; p && *p && *p != '#'; p++) + ; + if (p && *p == '#') + *p = '\0'; + return (line); +} +#endif + +/* Check LINE against what HISTCONTROL says to do. Returns 1 if the line + should be saved; 0 if it should be discarded. */ +static int +check_history_control (line) + char *line; +{ + HIST_ENTRY *temp; + int r; + + if (history_control == 0) + return 1; + + /* ignorespace or ignoreboth */ + if ((history_control & HC_IGNSPACE) && *line == ' ') + return 0; + + /* ignoredups or ignoreboth */ + if (history_control & HC_IGNDUPS) + { + using_history (); + temp = previous_history (); + + r = (temp == 0 || STREQ (temp->line, line) == 0); + + using_history (); + + if (r == 0) + return r; + } + + return 1; +} + +/* Remove all entries matching LINE from the history list. Triggered when + HISTCONTROL includes `erasedups'. */ +static void +hc_erasedups (line) + char *line; +{ + HIST_ENTRY *temp; + int r; + + using_history (); + while (temp = previous_history ()) + { + if (STREQ (temp->line, line)) + { + r = where_history (); + temp = remove_history (r); + if (temp) + free_history_entry (temp); + } + } + using_history (); +} + +/* Add LINE to the history list, handling possibly multi-line compound + commands. We note whether or not we save the first line of each command + (which is usually the entire command and history entry), and don't add + the second and subsequent lines of a multi-line compound command if we + didn't save the first line. We don't usually save shell comment lines in + compound commands in the history, because they could have the effect of + commenting out the rest of the command when the entire command is saved as + a single history entry (when COMMAND_ORIENTED_HISTORY is enabled). If + LITERAL_HISTORY is set, we're saving lines in the history with embedded + newlines, so it's OK to save comment lines. If we're collecting the body + of a here-document, we should act as if literal_history is enabled, because + we want to save the entire contents of the here-document as it was + entered. We also make sure to save multiple-line quoted strings or other + constructs. */ +void +maybe_add_history (line) + char *line; +{ + hist_last_line_added = 0; + + /* Don't use the value of history_control to affect the second + and subsequent lines of a multi-line command (old code did + this only when command_oriented_history is enabled). */ + if (current_command_line_count > 1) + { + if (current_command_first_line_saved && + ((parser_state & PST_HEREDOC) || literal_history || dstack.delimiter_depth != 0 || shell_comment (line) == 0)) + bash_add_history (line); + return; + } + + /* This is the first line of a (possible multi-line) command. Note whether + or not we should save the first line and remember it. */ + current_command_first_line_saved = check_add_history (line, 0); +} + +/* Just check LINE against HISTCONTROL and HISTIGNORE and add it to the + history if it's OK. Used by `history -s' as well as maybe_add_history(). + Returns 1 if the line was saved in the history, 0 otherwise. */ +int +check_add_history (line, force) + char *line; + int force; +{ + if (check_history_control (line) && history_should_ignore (line) == 0) + { + /* We're committed to saving the line. If the user has requested it, + remove other matching lines from the history. */ + if (history_control & HC_ERASEDUPS) + hc_erasedups (line); + + if (force) + { + really_add_history (line); + using_history (); + } + else + bash_add_history (line); + return 1; + } + return 0; +} + +#if defined (SYSLOG_HISTORY) +#define SYSLOG_MAXLEN 600 + +extern char *shell_name; + +#ifndef OPENLOG_OPTS +#define OPENLOG_OPTS 0 +#endif + +void +bash_syslog_history (line) + const char *line; +{ + char trunc[SYSLOG_MAXLEN]; + static int first = 1; + + if (first) + { + openlog (shell_name, OPENLOG_OPTS, SYSLOG_FACILITY); + first = 0; + } + + if (strlen(line) < SYSLOG_MAXLEN) + syslog (SYSLOG_FACILITY|SYSLOG_LEVEL, "HISTORY: PID=%d UID=%d %s", getpid(), current_user.uid, line); + else + { + strncpy (trunc, line, SYSLOG_MAXLEN); + trunc[SYSLOG_MAXLEN - 1] = '\0'; + syslog (SYSLOG_FACILITY|SYSLOG_LEVEL, "HISTORY (TRUNCATED): PID=%d UID=%d %s", getpid(), current_user.uid, trunc); + } +} +#endif + +/* Add a line to the history list. + The variable COMMAND_ORIENTED_HISTORY controls the style of history + remembering; when non-zero, and LINE is not the first line of a + complete parser construct, append LINE to the last history line instead + of adding it as a new line. */ +void +bash_add_history (line) + char *line; +{ + int add_it, offset, curlen; + HIST_ENTRY *current, *old; + char *chars_to_add, *new_line; + + add_it = 1; + if (command_oriented_history && current_command_line_count > 1) + { + /* The second and subsequent lines of a here document have the trailing + newline preserved. We don't want to add extra newlines here, but we + do want to add one after the first line (which is the command that + contains the here-doc specifier). parse.y:history_delimiting_chars() + does the right thing to take care of this for us. We don't want to + add extra newlines if the user chooses to enable literal_history, + so we have to duplicate some of what that function does here. */ + if ((parser_state & PST_HEREDOC) && literal_history && current_command_line_count > 2 && line[strlen (line) - 1] == '\n') + chars_to_add = ""; + else + chars_to_add = literal_history ? "\n" : history_delimiting_chars (line); + + using_history (); + current = previous_history (); + + if (current) + { + /* If the previous line ended with an escaped newline (escaped + with backslash, but otherwise unquoted), then remove the quoted + newline, since that is what happens when the line is parsed. */ + curlen = strlen (current->line); + + if (dstack.delimiter_depth == 0 && current->line[curlen - 1] == '\\' && + current->line[curlen - 2] != '\\') + { + current->line[curlen - 1] = '\0'; + curlen--; + chars_to_add = ""; + } + + /* If we're not in some kind of quoted construct, the current history + entry ends with a newline, and we're going to add a semicolon, + don't. In some cases, it results in a syntax error (e.g., before + a close brace), and it should not be needed. */ + if (dstack.delimiter_depth == 0 && current->line[curlen - 1] == '\n' && *chars_to_add == ';') + chars_to_add++; + + new_line = (char *)xmalloc (1 + + curlen + + strlen (line) + + strlen (chars_to_add)); + sprintf (new_line, "%s%s%s", current->line, chars_to_add, line); + offset = where_history (); + old = replace_history_entry (offset, new_line, current->data); + free (new_line); + + if (old) + free_history_entry (old); + + add_it = 0; + } + } + + if (add_it) + really_add_history (line); + +#if defined (SYSLOG_HISTORY) + bash_syslog_history (line); +#endif + + using_history (); +} + +static void +really_add_history (line) + char *line; +{ + hist_last_line_added = 1; + hist_last_line_pushed = 0; + add_history (line); + history_lines_this_session++; +} + +int +history_number () +{ + using_history (); + return (remember_on_history ? history_base + where_history () : 1); +} + +static int +should_expand (s) + char *s; +{ + char *p; + + for (p = s; p && *p; p++) + { + if (*p == '\\') + p++; + else if (*p == '&') + return 1; + } + return 0; +} + +static int +histignore_item_func (ign) + struct ign *ign; +{ + if (should_expand (ign->val)) + ign->flags |= HIGN_EXPAND; + return (0); +} + +void +setup_history_ignore (varname) + char *varname; +{ + setup_ignore_patterns (&histignore); +} + +static HIST_ENTRY * +last_history_entry () +{ + HIST_ENTRY *he; + + using_history (); + he = previous_history (); + using_history (); + return he; +} + +char * +last_history_line () +{ + HIST_ENTRY *he; + + he = last_history_entry (); + if (he == 0) + return ((char *)NULL); + return he->line; +} + +static char * +expand_histignore_pattern (pat) + char *pat; +{ + HIST_ENTRY *phe; + char *ret; + + phe = last_history_entry (); + + if (phe == (HIST_ENTRY *)0) + return (savestring (pat)); + + ret = strcreplace (pat, '&', phe->line, 1); + + return ret; +} + +/* Return 1 if we should not put LINE into the history according to the + patterns in HISTIGNORE. */ +static int +history_should_ignore (line) + char *line; +{ + register int i, match; + char *npat; + + if (histignore.num_ignores == 0) + return 0; + + for (i = match = 0; i < histignore.num_ignores; i++) + { + if (histignore.ignores[i].flags & HIGN_EXPAND) + npat = expand_histignore_pattern (histignore.ignores[i].val); + else + npat = histignore.ignores[i].val; + + match = strmatch (npat, line, FNMATCH_EXTFLAG) != FNM_NOMATCH; + + if (histignore.ignores[i].flags & HIGN_EXPAND) + free (npat); + + if (match) + break; + } + + return match; +} +#endif /* HISTORY */ diff --git a/bashhist.h b/bashhist.h new file mode 100644 index 0000000..c44e7c6 --- /dev/null +++ b/bashhist.h @@ -0,0 +1,71 @@ +/* bashhist.h -- interface to the bash history functions in bashhist.c. */ + +/* Copyright (C) 1993-2009 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 3 of the License, 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. If not, see . +*/ + +#if !defined (_BASHHIST_H_) +#define _BASHHIST_H_ + +#include "stdc.h" + +/* Flag values for history_control */ +#define HC_IGNSPACE 0x01 +#define HC_IGNDUPS 0x02 +#define HC_ERASEDUPS 0x04 + +#define HC_IGNBOTH (HC_IGNSPACE|HC_IGNDUPS) + +extern int remember_on_history; +extern int enable_history_list; /* value for `set -o history' */ +extern int literal_history; /* controlled by `shopt lithist' */ +extern int force_append_history; +extern int history_lines_this_session; +extern int history_lines_in_file; +extern int history_expansion; +extern int history_control; +extern int command_oriented_history; +extern int current_command_first_line_saved; +extern int hist_last_line_added; +extern int hist_last_line_pushed; + +# if defined (BANG_HISTORY) +extern int history_expansion_inhibited; +# endif /* BANG_HISTORY */ + +extern void bash_initialize_history __P((void)); +extern void bash_history_reinit __P((int)); +extern void bash_history_disable __P((void)); +extern void bash_history_enable __P((void)); +extern void bash_clear_history __P((void)); +extern int bash_delete_histent __P((int)); +extern int bash_delete_last_history __P((void)); +extern void load_history __P((void)); +extern void save_history __P((void)); +extern int maybe_append_history __P((char *)); +extern int maybe_save_shell_history __P((void)); +extern char *pre_process_line __P((char *, int, int)); +extern void maybe_add_history __P((char *)); +extern void bash_add_history __P((char *)); +extern int check_add_history __P((char *, int)); +extern int history_number __P((void)); + +extern void setup_history_ignore __P((char *)); + +extern char *last_history_line __P((void)); + +#endif /* _BASHHIST_H_ */ diff --git a/bashintl.h b/bashintl.h new file mode 100644 index 0000000..7e6b83f --- /dev/null +++ b/bashintl.h @@ -0,0 +1,50 @@ +/* bashintl.h -- Internationalization functions and defines. */ + +/* Copyright (C) 1996-2009 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 3 of the License, 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. If not, see . +*/ + +#if !defined (_BASHINTL_H_) +#define _BASHINTL_H_ + +#if defined (BUILDTOOL) +# undef ENABLE_NLS +# define ENABLE_NLS 0 +#endif + +/* Include this *after* config.h */ +#include "gettext.h" + +#if defined (HAVE_LOCALE_H) +# include +#endif + +#define _(msgid) gettext(msgid) +#define N_(msgid) msgid +#define D_(d, msgid) dgettext(d, msgid) + +#define P_(m1, m2, n) ngettext(m1, m2, n) + +#if defined (HAVE_SETLOCALE) && !defined (LC_ALL) +# undef HAVE_SETLOCALE +#endif + +#if !defined (HAVE_SETLOCALE) +# define setlocale(cat, loc) +#endif + +#endif /* !_BASHINTL_H_ */ diff --git a/bashjmp.h b/bashjmp.h new file mode 100644 index 0000000..79152fe --- /dev/null +++ b/bashjmp.h @@ -0,0 +1,45 @@ +/* bashjmp.h -- wrapper for setjmp.h with necessary bash definitions. */ + +/* Copyright (C) 1987-2009 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 3 of the License, 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. If not, see . +*/ + +#ifndef _BASHJMP_H_ +#define _BASHJMP_H_ + +#include "posixjmp.h" + +extern procenv_t top_level; +extern procenv_t subshell_top_level; +extern procenv_t return_catch; /* used by `return' builtin */ + +extern int no_longjmp_on_fatal_error; + +#define SHFUNC_RETURN() sh_longjmp (return_catch, 1) + +#define COPY_PROCENV(old, save) \ + xbcopy ((char *)old, (char *)save, sizeof (procenv_t)); + +/* Values for the second argument to longjmp/siglongjmp. */ +#define NOT_JUMPED 0 /* Not returning from a longjmp. */ +#define FORCE_EOF 1 /* We want to stop parsing. */ +#define DISCARD 2 /* Discard current command. */ +#define EXITPROG 3 /* Unconditionally exit the program now. */ +#define ERREXIT 4 /* Exit due to error condition */ +#define SIGEXIT 5 /* Exit due to fatal terminating signal */ + +#endif /* _BASHJMP_H_ */ diff --git a/bashline.c b/bashline.c new file mode 100644 index 0000000..f4fe9f1 --- /dev/null +++ b/bashline.c @@ -0,0 +1,4340 @@ +/* bashline.c -- Bash's interface to the readline library. */ + +/* Copyright (C) 1987-2016 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 3 of the License, 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. If not, see . +*/ + +#include "config.h" + +#if defined (READLINE) + +#include "bashtypes.h" +#include "posixstat.h" + +#if defined (HAVE_UNISTD_H) +# include +#endif + +#if defined (HAVE_GRP_H) +# include +#endif + +#if defined (HAVE_NETDB_H) +# include +#endif + +#include + +#include +#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 "shmbutil.h" +#include "trap.h" +#include "flags.h" + +#if defined (HAVE_MBSTR_H) && defined (HAVE_MBSCHR) +# include /* mbschr */ +#endif + +#include "builtins/common.h" + +#include +#include +#include + +#include + +#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 + +#define RL_BOOLEAN_VARIABLE_VALUE(s) ((s)[0] == 'o' && (s)[1] == 'n' && (s)[2] == '\0') + +#if defined (BRACE_COMPLETION) +extern int bash_brace_completion __P((int, int)); +#endif /* BRACE_COMPLETION */ + +/* To avoid including curses.h/term.h/termcap.h and that whole mess. */ +#ifdef _MINIX +extern int tputs __P((const char *string, int nlines, void (*outx)(int))); +#else +extern int tputs __P((const char *string, int nlines, int (*outx)(int))); +#endif + +/* 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 + +static int bash_forward_shellword __P((int, int)); +static int bash_backward_shellword __P((int, int)); +static int bash_kill_shellword __P((int, int)); +static int bash_backward_kill_shellword __P((int, int)); + +/* Helper functions for Readline. */ +static char *restore_tilde __P((char *, char *)); +static char *maybe_restore_tilde __P((char *, char *)); + +static char *bash_filename_rewrite_hook __P((char *, int)); + +static void bash_directory_expansion __P((char **)); +static int bash_filename_stat_hook __P((char **)); +static int bash_command_name_stat_hook __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 int executable_completion __P((const char *, int)); + +static rl_icppfunc_t *save_directory_hook __P((void)); +static void restore_directory_hook __P((rl_icppfunc_t)); + +static int directory_exists __P((const char *)); + +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 int bash_dabbrev_expand __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 void set_filename_bstab __P((const char *)); +static char *bash_quote_filename __P((char *, int, char *)); + +#ifdef _MINIX +static void putx __P((int)); +#else +static int putx __P((int)); +#endif +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 + +static int bash_event_hook __P((void)); + +#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, int *, 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, saved_command_line_count; +extern int last_command_exit_value; +extern int array_needs_making; +extern int posixly_correct, no_symbolic_links; +extern int sigalrm_seen; +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; + +/* Perform spelling correction on directory names during word completion */ +int dircomplete_spelling = 0; + +/* Expand directory names during word/filename completion. */ +#if DIRCOMPLETE_EXPAND_DEFAULT +int dircomplete_expand = 1; +int dircomplete_expand_relpath = 1; +#else +int dircomplete_expand = 0; +int dircomplete_expand_relpath = 0; +#endif + +/* When non-zero, perform `normal' shell quoting on completed filenames + even when the completed name contains a directory name with a shell + variable referene, so dollar signs in a filename get quoted appropriately. + Set to zero to remove dollar sign (and braces or parens as needed) from + the set of characters that will be quoted. */ +int complete_fullquote = 1; + +static char *bash_completer_word_break_characters = " \t\n\"'@><=;|&(:"; +static char *bash_nohostname_word_break_characters = " \t\n\"'><=;|&(:"; +/* )) */ + +static const char *default_filename_quote_characters = " \t\n\\\"'@<>=;|&()#$`?*[!:{~"; /*}*/ +static char *custom_filename_quote_characters = 0; +static char filename_bstab[256]; + +static rl_hook_func_t *old_rl_startup_hook = (rl_hook_func_t *)NULL; + +static int dot_in_path = 0; + +/* Set to non-zero when dabbrev-expand is running */ +static int dabbrev_expand_active = 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 +} + +void +reset_completer_word_break_chars () +{ + rl_completer_word_break_characters = perform_hostname_completion ? savestring (bash_completer_word_break_characters) : savestring (bash_nohostname_word_break_characters); +} + +/* 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 + + rl_add_defun ("shell-forward-word", bash_forward_shellword, -1); + rl_add_defun ("shell-backward-word", bash_backward_shellword, -1); + rl_add_defun ("shell-kill-word", bash_kill_shellword, -1); + rl_add_defun ("shell-backward-kill-word", bash_backward_kill_shellword, -1); + +#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); + rl_add_defun ("dabbrev-expand", bash_dabbrev_expand, -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. */ + set_directory_hook (); + + rl_filename_rewrite_hook = bash_filename_rewrite_hook; + + rl_filename_stat_hook = bash_filename_stat_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 = default_filename_quote_characters; + set_filename_bstab (rl_filename_quote_characters); + + 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 + + bash_readline_initialized = 1; +} + +void +bashline_reinitialize () +{ + bash_readline_initialized = 0; +} + +void +bashline_set_event_hook () +{ + rl_signal_event_hook = bash_event_hook; +} + +void +bashline_reset_event_hook () +{ + rl_signal_event_hook = 0; +} + +/* 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_reset () +{ + tilde_initialize (); + rl_attempted_completion_function = attempt_shell_completion; + rl_completion_entry_function = NULL; + rl_ignore_some_completions_function = filename_completion_ignore; + rl_filename_quote_characters = default_filename_quote_characters; + set_filename_bstab (rl_filename_quote_characters); + + set_directory_hook (); + rl_filename_stat_hook = bash_filename_stat_hook; + + bashline_reset_event_hook (); + + rl_sort_completion_matches = 1; +} + +/* 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 = hostname_list_initialized = 0; +} + +/* Return a NULL terminated list of hostnames which begin with TEXT. + Initialize the hostname list the first time if necessary. + 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 last_saved_history_line = -1; + +#define HISTORY_FULL() (history_is_stifled () && history_length >= history_max_entries) + +static int +set_saved_history () +{ + /* XXX - compensate for assumption that history was `shuffled' if it was + actually not. */ + if (HISTORY_FULL () && + hist_last_line_added == 0 && + saved_history_line_to_use < history_length - 1) + saved_history_line_to_use++; + + if (saved_history_line_to_use >= 0) + { + rl_get_previous_history (history_length - saved_history_line_to_use, 0); + last_saved_history_line = saved_history_line_to_use; + } + 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_FULL () || (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, *metaval; + int r, rrs, metaflag; + sh_parser_state_t ps; + + rrs = rl_readline_state; + saved_command_line_count = 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'). */ + /* This breaks down when using command-oriented history and are not + finished with the command, so we should not ignore the last command */ + using_history (); + current_command_line_count++; /* for rl_newline above */ + bash_add_history (rl_line_buffer); + current_command_line_count = 0; /* for dummy history entry */ + bash_add_history (""); + history_lines_this_session++; + using_history (); + command = savestring (edit_command); + } + + metaval = rl_variable_value ("input-meta"); + metaflag = RL_BOOLEAN_VARIABLE_VALUE (metaval); + + if (rl_deprep_term_function) + (*rl_deprep_term_function) (); + save_parser_state (&ps); + r = parse_and_execute (command, (editing_mode == VI_EDITING_MODE) ? "v" : "C-xC-e", SEVAL_NOHIST); + restore_parser_state (&ps); + if (rl_prep_term_function) + (*rl_prep_term_function) (metaflag); + + current_command_line_count = saved_command_line_count; + + /* 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 + +/* Bindable commands that move `shell-words': that is, sequences of + non-unquoted-metacharacters. */ + +#define WORDDELIM(c) (shellmeta(c) || shellblank(c)) + +static int +bash_forward_shellword (count, key) + int count, key; +{ + size_t slen; + int sindex, c, p; + DECLARE_MBSTATE; + + if (count < 0) + return (bash_backward_shellword (-count, key)); + + /* The tricky part of this is deciding whether or not the first character + we're on is an unquoted metacharacter. Not completely handled yet. */ + /* XXX - need to test this stuff with backslash-escaped shell + metacharacters and unclosed single- and double-quoted strings. */ + + p = rl_point; + slen = rl_end; + + while (count) + { + if (p == rl_end) + { + rl_point = rl_end; + return 0; + } + + /* Are we in a quoted string? If we are, move to the end of the quoted + string and continue the outer loop. We only want quoted strings, not + backslash-escaped characters, but char_is_quoted doesn't + differentiate. */ + if (char_is_quoted (rl_line_buffer, p) && p > 0 && rl_line_buffer[p-1] != '\\') + { + do + ADVANCE_CHAR (rl_line_buffer, slen, p); + while (p < rl_end && char_is_quoted (rl_line_buffer, p)); + count--; + continue; + } + + /* Rest of code assumes we are not in a quoted string. */ + /* Move forward until we hit a non-metacharacter. */ + while (p < rl_end && (c = rl_line_buffer[p]) && WORDDELIM (c)) + { + switch (c) + { + default: + ADVANCE_CHAR (rl_line_buffer, slen, p); + continue; /* straight back to loop, don't increment p */ + case '\\': + if (p < rl_end && rl_line_buffer[p]) + ADVANCE_CHAR (rl_line_buffer, slen, p); + break; + case '\'': + p = skip_to_delim (rl_line_buffer, ++p, "'", SD_NOJMP); + break; + case '"': + p = skip_to_delim (rl_line_buffer, ++p, "\"", SD_NOJMP); + break; + } + + if (p < rl_end) + p++; + } + + if (rl_line_buffer[p] == 0 || p == rl_end) + { + rl_point = rl_end; + rl_ding (); + return 0; + } + + /* Now move forward until we hit a non-quoted metacharacter or EOL */ + while (p < rl_end && (c = rl_line_buffer[p]) && WORDDELIM (c) == 0) + { + switch (c) + { + default: + ADVANCE_CHAR (rl_line_buffer, slen, p); + continue; /* straight back to loop, don't increment p */ + case '\\': + if (p < rl_end && rl_line_buffer[p]) + ADVANCE_CHAR (rl_line_buffer, slen, p); + break; + case '\'': + p = skip_to_delim (rl_line_buffer, ++p, "'", SD_NOJMP); + break; + case '"': + p = skip_to_delim (rl_line_buffer, ++p, "\"", SD_NOJMP); + break; + } + + if (p < rl_end) + p++; + } + + if (p == rl_end || rl_line_buffer[p] == 0) + { + rl_point = rl_end; + return (0); + } + + count--; + } + + rl_point = p; + return (0); +} + +static int +bash_backward_shellword (count, key) + int count, key; +{ + size_t slen; + int sindex, c, p; + DECLARE_MBSTATE; + + if (count < 0) + return (bash_forward_shellword (-count, key)); + + p = rl_point; + slen = rl_end; + + while (count) + { + if (p == 0) + { + rl_point = 0; + return 0; + } + + /* Move backward until we hit a non-metacharacter. */ + while (p > 0) + { + c = rl_line_buffer[p]; + if (WORDDELIM (c) && char_is_quoted (rl_line_buffer, p) == 0) + BACKUP_CHAR (rl_line_buffer, slen, p); + break; + } + + if (p == 0) + { + rl_point = 0; + return 0; + } + + /* Now move backward until we hit a metacharacter or BOL. */ + while (p > 0) + { + c = rl_line_buffer[p]; + if (WORDDELIM (c) && char_is_quoted (rl_line_buffer, p) == 0) + break; + BACKUP_CHAR (rl_line_buffer, slen, p); + } + + count--; + } + + rl_point = p; + return 0; +} + +static int +bash_kill_shellword (count, key) + int count, key; +{ + int p; + + if (count < 0) + return (bash_backward_kill_shellword (-count, key)); + + p = rl_point; + bash_forward_shellword (count, key); + + if (rl_point != p) + rl_kill_text (p, rl_point); + + rl_point = p; + if (rl_editing_mode == 1) /* 1 == emacs_mode */ + rl_mark = rl_point; + + return 0; +} + +static int +bash_backward_kill_shellword (count, key) + int count, key; +{ + int p; + + if (count < 0) + return (bash_kill_shellword (-count, key)); + + p = rl_point; + bash_backward_shellword (count, key); + + if (rl_point != p) + rl_kill_text (p, rl_point); + + if (rl_editing_mode == 1) /* 1 == emacs_mode */ + rl_mark = rl_point; + + return 0; +} + + +/* **************************************************************** */ +/* */ +/* How To Do Shell Completion */ +/* */ +/* **************************************************************** */ + +#define COMMAND_SEPARATORS ";|&{(`" +/* )} */ +#define COMMAND_SEPARATORS_PLUS_WS ";|&{(` \t" +/* )} */ + +/* check for redirections and other character combinations that are not + 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 = (ti > 0) ? rl_line_buffer[ti - 1] : 0; + + if ((this_char == '&' && (prev_char == '<' || prev_char == '>')) || + (this_char == '|' && prev_char == '>')) + return (1); + else if (this_char == '{' && prev_char == '$') /*}*/ + return (1); +#if 0 /* Not yet */ + else if (this_char == '(' && prev_char == '$') /*)*/ + return (1); + else if (this_char == '(' && prev_char == '<') /*)*/ + return (1); +#if defined (EXTENDED_GLOB) + else if (extended_glob && this_char == '(' && prev_char == '!') /*)*/ + return (1); +#endif +#endif + else if (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, ns; + + os = 0; + /* Flags == SD_NOJMP only because we want to skip over command substitutions + in assignment statements. Have to test whether this affects `standalone' + command substitutions as individual words. */ + while (((s = skip_to_delim (rl_line_buffer, os, COMMAND_SEPARATORS, SD_NOJMP|SD_COMPLETE/*|SD_NOSKIPCMD*/)) <= start) && + rl_line_buffer[s]) + { + /* Handle >| token crudely; treat as > not | */ + if (rl_line_buffer[s] == '|' && rl_line_buffer[s-1] == '>') + { + ns = skip_to_delim (rl_line_buffer, s+1, COMMAND_SEPARATORS, SD_NOJMP|SD_COMPLETE/*|SD_NOSKIPCMD*/); + if (ns > start || rl_line_buffer[ns] == 0) + return os; + os = ns+1; + continue; + } + 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, SD_NOJMP|SD_COMPLETE); + return e; +} + +static char * +find_cmd_name (start, sp, ep) + int start; + int *sp, *ep; +{ + 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", SD_NOJMP|SD_COMPLETE); + + name = substring (rl_line_buffer, s, e); + + if (sp) + *sp = s; + if (ep) + *ep = 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 */ + +/* Try and catch completion attempts that are syntax errors or otherwise + invalid. */ +static int +invalid_completion (text, ind) + const char *text; + int ind; +{ + int pind; + + /* If we don't catch these here, the next clause will */ + if (ind > 0 && rl_line_buffer[ind] == '(' && /*)*/ + member (rl_line_buffer[ind-1], "$<>")) + return 0; + + pind = ind - 1; + while (pind > 0 && whitespace (rl_line_buffer[pind])) + pind--; + /* If we have only whitespace preceding a paren, it's valid */ + if (ind >= 0 && pind <= 0 && rl_line_buffer[ind] == '(') /*)*/ + return 0; + /* Flag the invalid completions, which are mostly syntax errors */ + if (ind > 0 && rl_line_buffer[ind] == '(' && /*)*/ + member (rl_line_buffer[pind], COMMAND_SEPARATORS) == 0) + return 1; + + return 0; +} + +/* 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; +#if defined (PROGRAMMABLE_COMPLETION) + int have_progcomps, was_assignment; +#endif + + command_separator_chars = COMMAND_SEPARATORS; + matches = (char **)NULL; + rl_ignore_some_completions_function = filename_completion_ignore; + + rl_filename_quote_characters = default_filename_quote_characters; + set_filename_bstab (rl_filename_quote_characters); + set_directory_hook (); + rl_filename_stat_hook = bash_filename_stat_hook; + + rl_sort_completion_matches = 1; /* sort by default */ + + /* 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 (parser_in_command_position ()) + 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. */ + } + + if (in_command_position && invalid_completion (text, ti)) + { + rl_attempted_completion_over = 1; + return ((char **)NULL); + } + + /* 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. Don't bother if readline found a single quote and we are + completing on the substring. */ + if (*text == '`' && rl_completion_quote_character != '\'' && + (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. */ + have_progcomps = prog_completion_enabled && (progcomp_size () > 0); + if (matches == 0 && (in_command_position == 0 || text[0] == '\0') && + current_prompt_string == ps1_prompt) + { + int s, e, s1, e1, os, foundcs; + char *n; + + /* XXX - don't free the members */ + if (prog_complete_matches) + free (prog_complete_matches); + prog_complete_matches = (char **)NULL; + + os = start; + n = 0; + was_assignment = 0; + s = find_cmd_start (os); + e = find_cmd_end (end); + do + { + /* Don't read past the end of rl_line_buffer */ + if (s > rl_end) + { + s1 = s = e1; + break; + } + /* Or past point if point is within an assignment statement */ + else if (was_assignment && s > rl_point) + { + s1 = s = e1; + break; + } + /* Skip over assignment statements preceding a command name. If we + don't find a command name at all, we can perform command name + completion. If we find a partial command name, we should perform + command name completion on it. */ + FREE (n); + n = find_cmd_name (s, &s1, &e1); + s = e1 + 1; + } + while (was_assignment = assignment (n, 0)); + s = s1; /* reset to index where name begins */ + + /* s == index of where command name begins (reset above) + e == end of current command, may be end of line + s1 = index of where command name begins + e1 == index of where command name ends + start == index of where word to be completed begins + end == index of where word to be completed ends + if (s == start) we are doing command word completion for sure + if (e1 == end) we are at the end of the command name and completing it */ + if (start == 0 && end == 0 && e != 0 && text[0] == '\0') /* beginning of non-empty line */ + foundcs = 0; + else if (start == end && start == s1 && e != 0 && e1 > end) /* beginning of command name, leading whitespace */ + foundcs = 0; + else if (e == 0 && e == s && text[0] == '\0' && have_progcomps) /* beginning of empty line */ + prog_complete_matches = programmable_completions ("_EmptycmD_", text, s, e, &foundcs); + else if (start == end && text[0] == '\0' && s1 > start && whitespace (rl_line_buffer[start])) + foundcs = 0; /* whitespace before command name */ + else if (e > s && was_assignment == 0 && e1 == end && rl_line_buffer[e] == 0 && whitespace (rl_line_buffer[e-1]) == 0) + { + /* not assignment statement, but still want to perform command + completion if we are composing command word. */ + foundcs = 0; + in_command_position = s == start && STREQ (n, text); /* XXX */ + } + else if (e > s && was_assignment == 0 && have_progcomps) + { + prog_complete_matches = programmable_completions (n, text, s, e, &foundcs); + /* command completion if programmable completion fails */ + in_command_position = s == start && STREQ (n, text); /* XXX */ + } + /* empty command name following command separator */ + else if (s >= e && n[0] == '\0' && text[0] == '\0' && start > 0 && + was_assignment == 0 && member (rl_line_buffer[start-1], COMMAND_SEPARATORS)) + { + foundcs = 0; + in_command_position = 1; + } + else if (s >= e && n[0] == '\0' && text[0] == '\0' && start > 0) + { + foundcs = 0; /* empty command name following assignments */ + in_command_position = was_assignment; + } + else if (s == start && e == end && STREQ (n, text) && start > 0) + { + foundcs = 0; /* partial command name following assignments */ + in_command_position = 1; + } + 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 or + compopt. */ + if (foundcs) + { + pcomp_set_readline_variables (foundcs, 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, *t; + + 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 a single match, see if it expands to a directory name and append + a slash if it does. This requires us to expand the variable name, + so we don't want to display errors if the variable is unset. This + can happen with dynamic variables whose value has never been + requested. */ + if (matches && matches[0] && matches[1] == 0) + { + t = savestring (matches[0]); + bash_filename_stat_hook (&t); + /* doesn't use test_for_directory because that performs tilde + expansion */ + if (file_isdir (t)) + rl_completion_append_character = '/'; + free (t); + } + } + } + + /* If the word starts in `~', and there is no slash in the word, then + try completing this word as a username. */ + if (matches == 0 && *text == '~' && mbschr (text, '/') == 0) + 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 == 0 && 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; + } + else if (matches && matches[1] && rl_completion_type == '!') + { + rl_completion_suppress_append = 1; + rl_filename_completion_desired = 0; + } + } + + return (matches); +} + +static int +bash_command_name_stat_hook (name) + char **name; +{ + char *cname, *result; + + /* If it's not something we're going to look up in $PATH, just call the + normal filename stat hook. */ + if (absolute_program (*name)) + return (bash_filename_stat_hook (name)); + + cname = *name; + /* XXX - we could do something here with converting aliases, builtins, + and functions into something that came out as executable, but we don't. */ + result = search_for_command (cname, 0); + if (result) + { + *name = result; + return 1; + } + return 0; +} + +static int +executable_completion (filename, searching_path) + const char *filename; + int searching_path; +{ + char *f; + int r; + + f = savestring (filename); + bash_directory_completion_hook (&f); + + r = searching_path ? executable_file (f) : executable_or_directory (f); + free (f); + return r; +} + +/* 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 *fnhint = (char *)NULL; + static char *dequoted_hint = (char *)NULL; + static char *directory_part = (char *)NULL; + static char **glob_matches = (char **)NULL; + static int path_index, hint_len, dequoted_len, istate, igncase; + static int mapping_over, local_index, searching_path, hint_is_dir; + static int old_glob_ignore_case, globpat; + static SHELL_VAR **varlist = (SHELL_VAR **)NULL; +#if defined (ALIAS) + static alias_t **alias_list = (alias_t **)NULL; +#endif /* ALIAS */ + char *temp, *cval; + + /* We have to map over the possibilities for command words. If we have + no state, then make one just for that purpose. */ + if (state == 0) + { + rl_filename_stat_hook = bash_command_name_stat_hook; + + 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 = RL_BOOLEAN_VARIABLE_VALUE (temp); + + if (glob_matches) + { + free (glob_matches); + glob_matches = (char **)NULL; + } + + globpat = glob_pattern_p (hint_text); + + /* 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 (globpat || absolute_program (hint_text)) + { + /* Perform tilde expansion on what's passed, so we don't end up + passing filenames with tildes directly to stat(). The rest of + the shell doesn't do variable expansion on the word following + the tilde, so we don't do it here even if direxpand is set. */ + if (*hint_text == '~') + { + hint = bash_tilde_expand (hint_text, 0); + directory_part = savestring (hint_text); + temp = strchr (directory_part, '/'); + if (temp) + *temp = 0; + else + { + free (directory_part); + directory_part = (char *)NULL; + } + } + else if (dircomplete_expand) + { + hint = savestring (hint_text); + bash_directory_completion_hook (&hint); + } + 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); + + fnhint = filename_hint = savestring (hint); + + istate = 0; + + if (globpat) + { + mapping_over = 5; + goto globword; + } + else + { + if (dircomplete_expand && path_dot_or_dotdot (filename_hint)) + { + dircomplete_expand = 0; + set_directory_hook (); + dircomplete_expand = 1; + } + mapping_over = 4; + 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++; + } + +globword: + /* Limited support for completing command words with globbing chars. Only + a single match (multiple matches that end up reducing the number of + characters in the common prefix are bad) will ever be returned on + regular completion. */ + if (globpat) + { + if (state == 0) + { + glob_ignore_case = igncase; + glob_matches = shell_glob_filename (hint); + glob_ignore_case = old_glob_ignore_case; + + if (GLOB_FAILED (glob_matches) || glob_matches == 0) + { + glob_matches = (char **)NULL; + return ((char *)NULL); + } + + local_index = 0; + + if (glob_matches[1] && rl_completion_type == TAB) /* multiple matches are bad */ + return ((char *)NULL); + } + + while (val = glob_matches[local_index++]) + { + if (executable_or_directory (val)) + { + if (*hint_text == '~' && directory_part) + { + temp = maybe_restore_tilde (val, directory_part); + free (val); + val = temp; + } + return (val); + } + free (val); + } + + glob_ignore_case = old_glob_ignore_case; + return ((char *)NULL); + } + + /* 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 == 0) + { + char *current_path; + + /* Get the next directory from the path. If there is none, then we + are all done. */ + if (path == 0 || path[path_index] == 0 || + (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 (fnhint && fnhint != filename_hint) + free (fnhint); + if (filename_hint) + free (filename_hint); + + filename_hint = sh_makepath (current_path, hint, 0); + /* Need a quoted version (though it doesn't matter much in most + cases) because rl_filename_completion_function dequotes the + filename it gets, assuming that it's been quoted as part of + the input line buffer. */ + if (strpbrk (filename_hint, "\"'\\")) + fnhint = sh_backslash_quote (filename_hint, filename_bstab, 0); + else + fnhint = filename_hint; + free (current_path); /* XXX */ + } + + inner: + val = rl_filename_completion_function (fnhint, istate); + if (mapping_over == 4 && dircomplete_expand) + set_directory_hook (); + + 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 (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 == '~') + temp = maybe_restore_tilde (val, directory_part); + 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 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 0 + /* If we're not searching $PATH and we have a relative pathname, we + need to re-canonicalize it before testing whether or not it's an + executable or a directory so the shell treats .. relative to $PWD + according to the physical/logical option. The shell already + canonicalizes the directory name in order to tell readline where + to look, so not doing it here will be inconsistent. */ + /* XXX -- currently not used -- will introduce more inconsistency, + since shell does not canonicalize ../foo before passing it to + shell_execve(). */ + if (match && searching_path == 0 && *val == '.') + { + char *t, *t1; + + t = get_working_directory ("command-word-completion"); + t1 = make_absolute (val, t); + free (t); + cval = sh_canonpath (t1, PATH_CHECKDOTDOT|PATH_CHECKEXISTS); + } + else +#endif + cval = val; + + if (match && executable_completion ((searching_path ? val : cval), searching_path)) + { + if (cval != val) + free (cval); + free (val); + val = ""; /* So it won't be NULL. */ + return (temp); + } + else + { + if (freetemp) + free (temp); + if (cval != val) + free (cval); + 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 == 0 || matches[cmd_index] == 0) + { + 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 . + 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. NAME undergoes tilde expansion. */ +static int +test_for_directory (name) + const char *name; +{ + char *fn; + int r; + + fn = bash_tilde_expand (name, 0); + r = file_isdir (fn); + free (fn); + + return (r); +} + +/* 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; +} + +/* Replace a tilde-prefix in VAL with a `~', assuming the user typed it. VAL + is an expanded filename. DIRECTORY_PART is the tilde-prefix portion + of the un-tilde-expanded version of VAL (what the user typed). */ +static char * +restore_tilde (val, directory_part) + char *val, *directory_part; +{ + int l, vl, dl2, xl; + char *dh2, *expdir, *ret; + + vl = strlen (val); + + /* We need to duplicate the expansions readline performs on the directory + portion before passing it to our completion function. */ + dh2 = directory_part ? bash_dequote_filename (directory_part, 0) : 0; + bash_directory_expansion (&dh2); + dl2 = strlen (dh2); + + expdir = bash_tilde_expand (directory_part, 0); + xl = strlen (expdir); + free (expdir); + + /* + dh2 = unexpanded but dequoted tilde-prefix + dl2 = length of tilde-prefix + expdir = tilde-expanded tilde-prefix + xl = length of expanded tilde-prefix + l = length of remainder after tilde-prefix + */ + l = (vl - xl) + 1; + + ret = (char *)xmalloc (dl2 + 2 + l); + strcpy (ret, dh2); + strcpy (ret + dl2, val + xl); + + free (dh2); + return (ret); +} + +static char * +maybe_restore_tilde (val, directory_part) + char *val, *directory_part; +{ + rl_icppfunc_t *save; + char *ret; + + save = (dircomplete_expand == 0) ? save_directory_hook () : (rl_icppfunc_t *)0; + ret = restore_tilde (val, directory_part); + if (save) + restore_directory_hook (save); + return ret; +} + +/* 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)) + { + free (*dirname); + *dirname = d; + } + else 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; + } +} + +/* If necessary, rewrite directory entry */ +static char * +bash_filename_rewrite_hook (fname, fnlen) + char *fname; + int fnlen; +{ + char *conv; + + conv = fnx_fromfs (fname, fnlen); + if (conv != fname) + conv = savestring (conv); + return conv; +} + +/* Functions to save and restore the appropriate directory hook */ +/* This is not static so the shopt code can call it */ +void +set_directory_hook () +{ + if (dircomplete_expand) + { + rl_directory_completion_hook = bash_directory_completion_hook; + rl_directory_rewrite_hook = (rl_icppfunc_t *)0; + } + else + { + rl_directory_rewrite_hook = bash_directory_completion_hook; + rl_directory_completion_hook = (rl_icppfunc_t *)0; + } +} + +static rl_icppfunc_t * +save_directory_hook () +{ + rl_icppfunc_t *ret; + + if (dircomplete_expand) + { + ret = rl_directory_completion_hook; + rl_directory_completion_hook = (rl_icppfunc_t *)NULL; + } + else + { + ret = rl_directory_rewrite_hook; + rl_directory_rewrite_hook = (rl_icppfunc_t *)NULL; + } + + return ret; +} + +static void +restore_directory_hook (hookf) + rl_icppfunc_t *hookf; +{ + if (dircomplete_expand) + rl_directory_completion_hook = hookf; + else + rl_directory_rewrite_hook = hookf; +} + +/* Check whether not the (dequoted) version of DIRNAME, with any trailing slash + removed, exists. */ +static int +directory_exists (dirname) + const char *dirname; +{ + char *new_dirname; + int dirlen, r; + struct stat sb; + + /* First, dequote the directory name */ + new_dirname = bash_dequote_filename ((char *)dirname, rl_completion_quote_character); + dirlen = STRLEN (new_dirname); + if (new_dirname[dirlen - 1] == '/') + new_dirname[dirlen - 1] = '\0'; +#if defined (HAVE_LSTAT) + r = lstat (new_dirname, &sb) == 0; +#else + r = stat (new_dirname, &sb) == 0; +#endif + free (new_dirname); + return (r); +} + +/* Expand a filename before the readline completion code passes it to stat(2). + The filename will already have had tilde expansion performed. */ +static int +bash_filename_stat_hook (dirname) + char **dirname; +{ + char *local_dirname, *new_dirname, *t; + int should_expand_dirname, return_value; + int global_nounset; + WORD_LIST *wl; + struct stat sb; + + local_dirname = *dirname; + should_expand_dirname = return_value = 0; + if (t = mbschr (local_dirname, '$')) + should_expand_dirname = '$'; + else if (t = mbschr (local_dirname, '`')) /* XXX */ + should_expand_dirname = '`'; + + if (should_expand_dirname && directory_exists (local_dirname)) + should_expand_dirname = 0; + + if (should_expand_dirname) + { + new_dirname = savestring (local_dirname); + /* no error messages, and expand_prompt_string doesn't longjmp so we don't + have to worry about restoring this setting. */ + global_nounset = unbound_vars_is_error; + unbound_vars_is_error = 0; + wl = expand_prompt_string (new_dirname, 0, W_NOCOMSUB|W_COMPLETE); /* does the right thing */ + unbound_vars_is_error = global_nounset; + if (wl) + { + free (new_dirname); + new_dirname = string_list (wl); + /* Tell the completer we actually expanded something and change + *dirname only if we expanded to something non-null -- stat + behaves unpredictably when passed null or empty strings */ + if (new_dirname && *new_dirname) + { + free (local_dirname); /* XXX */ + local_dirname = *dirname = new_dirname; + return_value = STREQ (local_dirname, *dirname) == 0; + } + else + free (new_dirname); + dispose_words (wl); + } + else + free (new_dirname); + } + + /* This is very similar to the code in bash_directory_completion_hook below, + but without spelling correction and not worrying about whether or not + we change relative pathnames. */ + if (no_symbolic_links == 0 && (local_dirname[0] != '.' || local_dirname[1])) + { + char *temp1, *temp2; + + 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 return_value; + } + + free (local_dirname); + *dirname = temp2; + free (temp1); + } + + return (return_value); +} + +/* Handle symbolic link references and other directory name + expansions while hacking completion. This should return 1 if it modifies + the DIRNAME argument, 0 otherwise. It should make sure not to modify + DIRNAME if it returns 0. */ +static int +bash_directory_completion_hook (dirname) + char **dirname; +{ + char *local_dirname, *new_dirname, *t; + int return_value, should_expand_dirname, nextch, closer, changed; + size_t local_dirlen; + WORD_LIST *wl; + struct stat sb; + + return_value = should_expand_dirname = nextch = closer = 0; + local_dirname = *dirname; + + if (t = mbschr (local_dirname, '$')) + { + should_expand_dirname = '$'; + nextch = t[1]; + /* Deliberately does not handle the deprecated $[...] arithmetic + expansion syntax */ + if (nextch == '(') + closer = ')'; + else if (nextch == '{') + closer = '}'; + else + nextch = 0; + } + else if (local_dirname[0] == '~') + should_expand_dirname = '~'; + else + { + t = mbschr (local_dirname, '`'); + if (t && unclosed_pair (local_dirname, strlen (local_dirname), "`") == 0) + should_expand_dirname = '`'; + } + + if (should_expand_dirname && directory_exists (local_dirname)) + should_expand_dirname = 0; + + if (should_expand_dirname) + { + new_dirname = savestring (local_dirname); + wl = expand_prompt_string (new_dirname, 0, W_NOCOMSUB|W_COMPLETE); /* 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; + /* XXX - change rl_filename_quote_characters here based on + should_expand_dirname/nextch/closer. This is the only place + custom_filename_quote_characters is modified. */ + if (rl_filename_quote_characters && *rl_filename_quote_characters) + { + int i, j, c; + i = strlen (default_filename_quote_characters); + custom_filename_quote_characters = xrealloc (custom_filename_quote_characters, i+1); + for (i = j = 0; c = default_filename_quote_characters[i]; i++) + { + if (c == should_expand_dirname || c == nextch || c == closer) + continue; + custom_filename_quote_characters[j++] = c; + } + custom_filename_quote_characters[j] = '\0'; + rl_filename_quote_characters = custom_filename_quote_characters; + set_filename_bstab (rl_filename_quote_characters); + } + } + 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); + return_value = STREQ (local_dirname, new_dirname) == 0; + free (local_dirname); + local_dirname = *dirname = new_dirname; + } + + /* no_symbolic_links == 0 -> use (default) logical view of the file system. + local_dirname[0] == '.' && local_dirname[1] == '/' means files in the + current directory (./). + local_dirname[0] == '.' && local_dirname[1] == 0 means relative pathnames + in the current directory (e.g., lib/sh). + XXX - should we do spelling correction on these? */ + + /* This is test as it was in bash-4.2: skip relative pathnames in current + directory. Change test to + (local_dirname[0] != '.' || (local_dirname[1] && local_dirname[1] != '/')) + if we want to skip paths beginning with ./ also. */ + if (no_symbolic_links == 0 && (local_dirname[0] != '.' || local_dirname[1])) + { + char *temp1, *temp2; + int len1, len2; + + /* If we have a relative path + (local_dirname[0] != '/' && local_dirname[0] != '.') + that is canonical after appending it to the current directory, then + temp1 = temp2+'/' + That is, + strcmp (temp1, temp2) == 0 + after adding a slash to temp2 below. It should be safe to not + change those. + */ + t = get_working_directory ("symlink-hook"); + temp1 = make_absolute (local_dirname, t); + free (t); + temp2 = sh_canonpath (temp1, PATH_CHECKDOTDOT|PATH_CHECKEXISTS); + + /* Try spelling correction if initial canonicalization fails. Make + sure we are set to replace the directory name with the results so + subsequent directory checks don't fail. */ + if (temp2 == 0 && dircomplete_spelling && dircomplete_expand) + { + temp2 = dirspell (temp1); + if (temp2) + { + free (temp1); + temp1 = temp2; + temp2 = sh_canonpath (temp1, PATH_CHECKDOTDOT|PATH_CHECKEXISTS); + return_value |= temp2 != 0; + } + } + /* If we can't canonicalize, bail. */ + if (temp2 == 0) + { + free (temp1); + return return_value; + } + 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'; + } + } + + /* dircomplete_expand_relpath == 0 means we want to leave relative + pathnames that are unchanged by canonicalization alone. + *local_dirname != '/' && *local_dirname != '.' == relative pathname + (consistent with general.c:absolute_pathname()) + temp1 == temp2 (after appending a slash to temp2) means the pathname + is not changed by canonicalization as described above. */ + if (dircomplete_expand_relpath || ((local_dirname[0] != '/' && local_dirname[0] != '.') && STREQ (temp1, temp2) == 0)) + return_value |= STREQ (local_dirname, temp2) == 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++) + ; + for ( --i; i >= 0; 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. */ + if (dabbrev_expand_active == 0) + 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) + { + if (dabbrev_expand_active) /* This is kind of messy */ + rl_completion_suppress_append = 1; + 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; + rl_compignore_func_t *orig_ignore_func; + + orig_func = rl_completion_entry_function; + orig_attempt_func = rl_attempted_completion_function; + orig_ignore_func = rl_ignore_some_completions_function; + + rl_completion_entry_function = history_completion_generator; + rl_attempted_completion_function = (rl_completion_func_t *)NULL; + rl_ignore_some_completions_function = filename_completion_ignore; + + /* 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; + rl_ignore_some_completions_function = orig_ignore_func; + + return r; +} + +static int +bash_dabbrev_expand (count, key) + int count, key; +{ + int r, orig_suppress, orig_sort; + rl_compentry_func_t *orig_func; + rl_completion_func_t *orig_attempt_func; + rl_compignore_func_t *orig_ignore_func; + + orig_func = rl_menu_completion_entry_function; + orig_attempt_func = rl_attempted_completion_function; + orig_ignore_func = rl_ignore_some_completions_function; + orig_suppress = rl_completion_suppress_append; + orig_sort = rl_sort_completion_matches; + + rl_menu_completion_entry_function = history_completion_generator; + rl_attempted_completion_function = (rl_completion_func_t *)NULL; + rl_ignore_some_completions_function = filename_completion_ignore; + rl_filename_completion_desired = 0; + rl_completion_suppress_append = 1; + rl_sort_completion_matches = 0; + + /* XXX - use rl_completion_mode here? */ + dabbrev_expand_active = 1; + if (rl_last_func == bash_dabbrev_expand) + rl_last_func = rl_menu_complete; + r = rl_menu_complete (count, key); + dabbrev_expand_active = 0; + + rl_last_func = bash_dabbrev_expand; + rl_menu_completion_entry_function = orig_func; + rl_attempted_completion_function = orig_attempt_func; + rl_ignore_some_completions_function = orig_ignore_func; + rl_completion_suppress_append = orig_suppress; + rl_sort_completion_matches = orig_sort; + + 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; + rl_compignore_func_t *orig_ignore_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_ignore_func = rl_ignore_some_completions_function; + orig_rl_completer_word_break_characters = rl_completer_word_break_characters; + + orig_dir_func = save_directory_hook (); + + rl_completion_entry_function = rl_filename_completion_function; + rl_attempted_completion_function = (rl_completion_func_t *)NULL; + rl_ignore_some_completions_function = filename_completion_ignore; + 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_ignore_some_completions_function = orig_ignore_func; + rl_completer_word_break_characters = orig_rl_completer_word_break_characters; + + restore_directory_hook (orig_dir_func); + + 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; + rl_compignore_func_t *orig_ignore_func; + int r; + + orig_func = rl_completion_entry_function; + orig_attempt_func = rl_attempted_completion_function; + orig_ignore_func = rl_ignore_some_completions_function; + rl_completion_entry_function = generator; + rl_attempted_completion_function = NULL; + rl_ignore_some_completions_function = orig_ignore_func; + + r = rl_complete_internal (what_to_do); + + rl_completion_entry_function = orig_func; + rl_attempted_completion_function = orig_attempt_func; + rl_ignore_some_completions_function = orig_ignore_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-escaped characters to pass through unscathed. */ + if (*p == '\\') + { + /* Backslashes are preserved within single quotes. */ + if (quoted == '\'') + *r++ = *p; + /* Backslashes are preserved within double quotes unless the + character is one that is defined to be escaped */ + else if (quoted == '"' && ((sh_syntaxtab[p[1]] & CBSDQUOTE) == 0)) + *r++ = *p; + + *r++ = *++p; + if (*p == '\0') + return ret; /* XXX - was 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 (mbschr (rl_completer_word_break_characters, *s)) + *r++ = '\\'; + /* XXX -- check for standalone tildes here and backslash-quote them */ + if (s == text && *s == '~' && file_exists (text)) + *r++ = '\\'; + *r++ = *s; + } + *r = '\0'; + return ret; +} + +/* Use characters in STRING to populate the table of characters that should + be backslash-quoted. The table will be used for sh_backslash_quote from + this file. */ +static void +set_filename_bstab (string) + const char *string; +{ + const char *s; + + memset (filename_bstab, 0, sizeof (filename_bstab)); + for (s = string; s && *s; s++) + filename_bstab[*s] = 1; +} + +/* 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 && mbschr (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 && mbschr (s, '!')) + cs = COMPLETE_BSQUOTE; + + if (*qcp == '"' && history_expansion && cs == COMPLETE_DQUOTE && + history_expansion_inhibited == 0 && mbschr (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, complete_fullquote ? 0 : filename_bstab, 0); + 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. */ + if (rtext) + { + rlen = strlen (rtext); + ret = (char *)xmalloc (rlen + 1); + strcpy (ret, rtext); + } + else + { + ret = (char *)xmalloc (rlen = 1); + ret[0] = '\0'; + } + + /* 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; + +#ifdef _MINIX +static void +#else +static int +#endif +putx(c) + int c; +{ + int x; + x = putc (c, rl_outstream); +#ifndef _MINIX + return x; +#endif +} + +static int +bash_execute_unix_command (count, key) + int count; /* ignored */ + int key; +{ + Keymap ckmap; /* current keymap */ + Keymap xkmap; /* unix command executing keymap */ + rl_command_func_t *func; + int type; + register int i, r; + intmax_t mi; + sh_parser_state_t ps; + char *cmd, *value, *l, *l1, *ce; + SHELL_VAR *v; + char ibuf[INT_STRLEN_BOUND(int) + 1]; + + /* First, we need to find the right command to execute. This is tricky, + because we might have already indirected into another keymap, so we + have to walk cmd_xmap using the entire key sequence. */ + cmd = (char *)rl_function_of_keyseq (rl_executing_keyseq, cmd_xmap, &type); + + if (cmd == 0 || type != ISMACR) + { + rl_crlf (); + internal_error (_("bash_execute_unix_command: cannot find keymap for command")); + rl_forced_update_display (); + return 1; + } + + ce = rl_get_termcap ("ce"); + if (ce) /* clear current line */ + { +#if 0 + fprintf (rl_outstream, "\r"); + tputs (ce, 1, putx); +#else + rl_clear_visible_line (); +#endif + fflush (rl_outstream); + } + else + rl_crlf (); /* move to a new line */ + + v = bind_variable ("READLINE_LINE", rl_line_buffer, 0); + if (v) + VSETATTR (v, att_exported); + l = v ? value_cell (v) : 0; + value = inttostr (rl_point, ibuf, sizeof (ibuf)); + v = bind_int_variable ("READLINE_POINT", value); + if (v) + VSETATTR (v, att_exported); + array_needs_making = 1; + + save_parser_state (&ps); + r = parse_and_execute (cmd, "bash_execute_unix_command", SEVAL_NOHIST|SEVAL_NOFREE); + restore_parser_state (&ps); + + v = find_variable ("READLINE_LINE"); + l1 = v ? value_cell (v) : 0; + if (l1 != l) + maybe_make_readline_line (value_cell (v)); + v = find_variable ("READLINE_POINT"); + if (v && legal_number (value_cell (v), &mi)) + { + i = mi; + if (i != rl_point) + { + rl_point = i; + if (rl_point > rl_end) + rl_point = rl_end; + else if (rl_point < 0) + rl_point = 0; + } + } + + check_unbind_variable ("READLINE_LINE"); + check_unbind_variable ("READLINE_POINT"); + array_needs_making = 1; + + /* and restore the readline buffer and display after command execution. */ + /* If we clear the last line of the prompt above, redraw only that last + line. If the command returns 124, we redraw unconditionally as in + previous versions. */ + if (ce && r != 124) + rl_redraw_prompt_last_line (); + else + rl_forced_update_display (); + + return 0; +} + +int +print_unix_command_map () +{ + Keymap save; + + save = rl_get_keymap (); + rl_set_keymap (cmd_xmap); + rl_macro_dumper (1); + rl_set_keymap (save); + 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); + FREE (kseq); + return -1; + } + + i = isolate_sequence (line, i + 1, 0, &kstart); + if (i < 0) + { + FREE (kseq); + 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); + + free (kseq); + 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; + /* If rl_completion_found_quote != 0, rl_completion_matches will call the + filename dequoting function, causing the directory name to be dequoted + twice. */ + if (rl_dispatching && rl_completion_found_quote == 0) + dfn = bash_dequote_filename ((char *)text, qc); + else + dfn = (char *)text; + m1 = rl_completion_matches (dfn, rl_filename_completion_function); + if (dfn != text) + 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); +} + +/* This event hook is designed to be called after readline receives a signal + that interrupts read(2). It gives reasonable responsiveness to interrupts + and fatal signals without executing too much code in a signal handler + context. */ +static int +bash_event_hook () +{ + /* If we're going to longjmp to top_level, make sure we clean up readline. + check_signals will call QUIT, which will eventually longjmp to top_level, + calling run_interrupt_trap along the way. The check for sigalrm_seen is + to clean up the read builtin's state. */ + if (terminating_signal || interrupt_state || sigalrm_seen) + rl_cleanup_after_signal (); + bashline_reset_event_hook (); + check_signals_and_traps (); /* XXX */ + return 0; +} + +#endif /* READLINE */ diff --git a/bashline.h b/bashline.h new file mode 100644 index 0000000..d52dfdf --- /dev/null +++ b/bashline.h @@ -0,0 +1,57 @@ +/* bashline.h -- interface to the bash readline functions in bashline.c. */ + +/* Copyright (C) 1993-2009 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 3 of the License, 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. If not, see . +*/ + +#if !defined (_BASHLINE_H_) +#define _BASHLINE_H_ + +#include "stdc.h" + +extern int bash_readline_initialized; + +extern void posix_readline_initialize __P((int)); +extern void reset_completer_word_break_chars __P((void)); +extern int enable_hostname_completion __P((int)); +extern void initialize_readline __P((void)); +extern void bashline_reset __P((void)); +extern void bashline_reinitialize __P((void)); +extern int bash_re_edit __P((char *)); + +extern void bashline_set_event_hook __P((void)); +extern void bashline_reset_event_hook __P((void)); + +extern int bind_keyseq_to_unix_command __P((char *)); +extern int print_unix_command_map __P((void)); + +extern char **bash_default_completion __P((const char *, int, int, int, int)); + +void set_directory_hook __P((void)); + +/* Used by programmable completion code. */ +extern char *command_word_completion_function __P((const char *, int)); +extern char *bash_groupname_completion_function __P((const char *, int)); +extern char *bash_servicename_completion_function __P((const char *, int)); + +extern char **get_hostname_list __P((void)); +extern void clear_hostname_list __P((void)); + +extern char **bash_directory_completion_matches __P((const char *)); +extern char *bash_dequote_text __P((const char *)); + +#endif /* _BASHLINE_H_ */ diff --git a/bashtypes.h b/bashtypes.h new file mode 100644 index 0000000..01afef4 --- /dev/null +++ b/bashtypes.h @@ -0,0 +1,42 @@ +/* bashtypes.h -- Bash system types. */ + +/* Copyright (C) 1993-2009 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 3 of the License, 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. If not, see . +*/ + +#if !defined (_BASHTYPES_H_) +# define _BASHTYPES_H_ + +#if defined (CRAY) +# define word __word +#endif + +#include + +#if defined (CRAY) +# undef word +#endif + +#if defined (HAVE_INTTYPES_H) +# include +#endif + +#if HAVE_STDINT_H +# include +#endif + +#endif /* _BASHTYPES_H_ */ diff --git a/bracecomp.c b/bracecomp.c new file mode 100644 index 0000000..4fbca85 --- /dev/null +++ b/bracecomp.c @@ -0,0 +1,221 @@ +/* bracecomp.c -- Complete a filename with the possible completions enclosed + in csh-style braces such that the list of completions is available to the + shell. */ + +/* Original version by tromey@cns.caltech.edu, Fri Feb 7 1992. */ + +/* Copyright (C) 1993-2009 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 3 of the License, 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. If not, see . +*/ + +#include "config.h" + +#if defined (BRACE_EXPANSION) && defined (READLINE) + +#include + +#if defined (HAVE_UNISTD_H) +# ifdef _MINIX +# include +# endif +# include +#endif + +#include "bashansi.h" +#include "shmbutil.h" + +#include "shell.h" +#include + +static int _strcompare __P((char **, char **)); + +/* Find greatest common prefix of two strings. */ +static int +string_gcd (s1, s2) + char *s1, *s2; +{ + register int i; + + if (s1 == NULL || s2 == NULL) + return (0); + + for (i = 0; *s1 && *s2; ++s1, ++s2, ++i) + { + if (*s1 != *s2) + break; + } + + return (i); +} + +static char * +really_munge_braces (array, real_start, real_end, gcd_zero) + char **array; + int real_start, real_end, gcd_zero; +{ + int start, end, gcd; + char *result, *subterm, *x; + int result_size, flag, tlen; + + flag = 0; + + if (real_start == real_end) + { + x = array[real_start] ? sh_backslash_quote (array[real_start] + gcd_zero, 0, 0) + : sh_backslash_quote (array[0], 0, 0); + return x; + } + + result = (char *)xmalloc (result_size = 16); + *result = '\0'; + + for (start = real_start; start < real_end; start = end + 1) + { + gcd = strlen (array[start]); + for (end = start + 1; end < real_end; end++) + { + int temp; + + temp = string_gcd (array[start], array[end]); + + if (temp <= gcd_zero) + break; + + gcd = temp; + } + end--; + + if (gcd_zero == 0 && start == real_start && end != (real_end - 1)) + { + /* In this case, add in a leading '{', because we are at + top level, and there isn't a consistent prefix. */ + result_size += 1; + result = (char *)xrealloc (result, result_size); + result[0] = '{'; result[1] = '\0'; + flag++; + } + + /* Make sure we backslash quote every substring we insert into the + resultant brace expression. This is so the default filename + quoting function won't inappropriately quote the braces. */ + if (start == end) + { + x = savestring (array[start] + gcd_zero); + subterm = sh_backslash_quote (x, 0, 0); + free (x); + } + else + { + /* If there is more than one element in the subarray, + insert the (quoted) prefix and an opening brace. */ + tlen = gcd - gcd_zero; + x = (char *)xmalloc (tlen + 1); + strncpy (x, array[start] + gcd_zero, tlen); + x[tlen] = '\0'; + subterm = sh_backslash_quote (x, 0, 0); + free (x); + result_size += strlen (subterm) + 1; + result = (char *)xrealloc (result, result_size); + strcat (result, subterm); + free (subterm); + strcat (result, "{"); + subterm = really_munge_braces (array, start, end + 1, gcd); + subterm[strlen (subterm) - 1] = '}'; + } + + result_size += strlen (subterm) + 1; + result = (char *)xrealloc (result, result_size); + strcat (result, subterm); + strcat (result, ","); + free (subterm); + } + + if (gcd_zero == 0) + result[strlen (result) - 1] = flag ? '}' : '\0'; + return (result); +} + +static int +_strcompare (s1, s2) + char **s1, **s2; +{ + int result; + + result = **s1 - **s2; + if (result == 0) + result = strcmp (*s1, *s2); + + return result; +} + +static int +hack_braces_completion (names) + char **names; +{ + register int i; + char *temp; + + i = strvec_len (names); + if (MB_CUR_MAX > 1 && i > 2) + qsort (names+1, i-1, sizeof (char *), (QSFUNC *)_strcompare); + + temp = really_munge_braces (names, 1, i, 0); + + for (i = 0; names[i]; ++i) + { + free (names[i]); + names[i] = NULL; + } + names[0] = temp; + return 0; +} + +/* We handle quoting ourselves within hack_braces_completion, so we turn off + rl_filename_quoting_desired and rl_filename_quoting_function. */ +int +bash_brace_completion (count, ignore) + int count, ignore; +{ + rl_compignore_func_t *orig_ignore_func; + rl_compentry_func_t *orig_entry_func; + rl_quote_func_t *orig_quoting_func; + rl_completion_func_t *orig_attempt_func; + int orig_quoting_desired, r; + + orig_ignore_func = rl_ignore_some_completions_function; + orig_attempt_func = rl_attempted_completion_function; + orig_entry_func = rl_completion_entry_function; + orig_quoting_func = rl_filename_quoting_function; + orig_quoting_desired = rl_filename_quoting_desired; + + rl_completion_entry_function = rl_filename_completion_function; + rl_attempted_completion_function = (rl_completion_func_t *)NULL; + rl_ignore_some_completions_function = hack_braces_completion; + rl_filename_quoting_function = (rl_quote_func_t *)NULL; + rl_filename_quoting_desired = 0; + + r = rl_complete_internal (TAB); + + rl_ignore_some_completions_function = orig_ignore_func; + rl_attempted_completion_function = orig_attempt_func; + rl_completion_entry_function = orig_entry_func; + rl_filename_quoting_function = orig_quoting_func; + rl_filename_quoting_desired = orig_quoting_desired; + + return r; +} +#endif /* BRACE_EXPANSION && READLINE */ diff --git a/braces.c b/braces.c new file mode 100644 index 0000000..7f31dd5 --- /dev/null +++ b/braces.c @@ -0,0 +1,875 @@ +/* braces.c -- code for doing word expansion in curly braces. */ + +/* Copyright (C) 1987-2012 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 3 of the License, 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. If not, see . +*/ + +/* 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 +# endif +# include +#endif + +#include + +#include "bashansi.h" +#include "bashintl.h" + +#if defined (SHELL) +# include "shell.h" +#else +# if defined (TEST) +typedef char *WORD_DESC; +typedef char **WORD_LIST; +#define _(X) X +# endif /* TEST */ +#endif /* SHELL */ + +#include "typemax.h" /* INTMAX_MIN, INTMAX_MAX */ +#include "general.h" +#include "shmbutil.h" +#include "chartypes.h" + +#ifndef errno +extern int errno; +#endif + +#define brace_whitespace(c) (!(c) || (c) == ' ' || (c) == '\t' || (c) == '\n') + +#define BRACE_SEQ_SPECIFIER ".." + +extern int asprintf __P((char **, const char *, ...)) __attribute__((__format__ (printf, 2, 3))); + +extern int last_command_exit_value; + +/* 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. */ +static const 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((intmax_t, intmax_t, intmax_t, 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); + if (i > 0) + 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); + last_command_exit_value = 1; + 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 if (text[i + 1]) + { + /* If the sequence expansion fails (e.g., because the integers + overflow), but there is more in the string, try and process + the rest of the string, which may contain additional brace + expansions. Treat the unexpanded sequence term as a simple + string (including the braces). */ + tack = strvec_create (2); + tack[0] = savestring (text+start-1); + tack[0][i-start+2] = '\0'; + tack[1] = (char *)0; + 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); + if (tack != result) + strvec_dispose (tack); + + postamble = text + i + 1; + + if (postamble && *postamble) + { + tack = brace_expand (postamble); + result = array_concat (result, tack); + if (tack != result) + 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, **tresult; + char *tem; + int start, i, c; + +#if defined (SHELL) + DECLARE_MBSTATE; +#endif + + 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); + + tresult = strvec_mresize (result, lp + lr + 1); + if (tresult == 0) + { + internal_error (_("brace expansion: cannot allocate memory for %s"), tem); + free (tem); + strvec_dispose (partial); + strvec_dispose (result); + result = (char **)NULL; + return result; + } + else + result = tresult; + + for (j = 0; j < lp; j++) + result[lr + j] = partial[j]; + + result[lr + j] = (char *)NULL; + free (partial); + } + free (tem); +#if defined (SHELL) + ADVANCE_CHAR (text, tlen, i); +#else + i++; +#endif + start = i; + } + return (result); +} + +#define ST_BAD 0 +#define ST_INT 1 +#define ST_CHAR 2 +#define ST_ZINT 3 + +#ifndef sh_imaxabs +# define sh_imaxabs(x) (((x) >= 0) ? (x) : -(x)) +#endif + +/* Handle signed arithmetic overflow and underflow. Have to do it this way + to avoid compilers optimizing out simpler overflow checks. */ + +/* Make sure that a+b does not exceed MAXV or is smaller than MINV (if b < 0). + Assumes that b > 0 if a > 0 and b < 0 if a < 0 */ +#define ADDOVERFLOW(a,b,minv,maxv) \ + ((((a) > 0) && ((b) > ((maxv) - (a)))) || \ + (((a) < 0) && ((b) < ((minv) - (a))))) + +/* Make sure that a-b is not smaller than MINV or exceeds MAXV (if b < 0). + Assumes that b > 0 if a > 0 and b < 0 if a < 0 */ +#define SUBOVERFLOW(a,b,minv,maxv) \ + ((((b) > 0) && ((a) < ((minv) + (b)))) || \ + (((b) < 0) && ((a) > ((maxv) + (b))))) + +static char ** +mkseq (start, end, incr, type, width) + intmax_t start, end, incr; + int type, width; +{ + intmax_t n, prevn; + int i, j, nelem; + char **result, *t; + + if (incr == 0) + incr = 1; + + if (start > end && incr > 0) + incr = -incr; + else if (start < end && incr < 0) + { + if (incr == INTMAX_MIN) /* Don't use -INTMAX_MIN */ + return ((char **)NULL); + incr = -incr; + } + + /* Check that end-start will not overflow INTMAX_MIN, INTMAX_MAX. The +3 + and -2, not strictly necessary, are there because of the way the number + of elements and value passed to strvec_create() are calculated below. */ + if (SUBOVERFLOW (end, start, INTMAX_MIN+3, INTMAX_MAX-2)) + return ((char **)NULL); + + prevn = sh_imaxabs (end - start); + /* Need to check this way in case INT_MAX == INTMAX_MAX */ + if (INT_MAX == INTMAX_MAX && (ADDOVERFLOW (prevn, 2, INT_MIN, INT_MAX))) + return ((char **)NULL); + /* Make sure the assignment to nelem below doesn't end up <= 0 due to + intmax_t overflow */ + else if (ADDOVERFLOW ((prevn/sh_imaxabs(incr)), 1, INTMAX_MIN, INTMAX_MAX)) + return ((char **)NULL); + + /* XXX - TOFIX: potentially allocating a lot of extra memory if + imaxabs(incr) != 1 */ + /* Instead of a simple nelem = prevn + 1, something like: + nelem = (prevn / imaxabs(incr)) + 1; + would work */ + nelem = (prevn / sh_imaxabs(incr)) + 1; + if (nelem > INT_MAX - 2) /* Don't overflow int */ + return ((char **)NULL); + result = strvec_mcreate (nelem + 1); + if (result == 0) + { + internal_error (_("brace expansion: failed to allocate memory for %d elements"), nelem); + return ((char **)NULL); + } + + /* Make sure we go through the loop at least once, so {3..3} prints `3' */ + i = 0; + n = start; + do + { +#if defined (SHELL) + if (ISINTERRUPT) + { + strvec_dispose (result); + result = (char **)NULL; + } + QUIT; +#endif + if (type == ST_INT) + result[i++] = t = itos (n); + else if (type == ST_ZINT) + { + int len, arg; + arg = n; + len = asprintf (&t, "%0*d", width, arg); + result[i++] = t; + } + else + { + if (t = (char *)malloc (2)) + { + t[0] = n; + t[1] = '\0'; + } + result[i++] = t; + } + + /* We failed to allocate memory for this number, so we bail. */ + if (t == 0) + { + char *p, lbuf[INT_STRLEN_BOUND(intmax_t) + 1]; + + /* Easier to do this than mess around with various intmax_t printf + formats (%ld? %lld? %jd?) and PRIdMAX. */ + p = inttostr (n, lbuf, sizeof (lbuf)); + internal_error (_("brace expansion: failed to allocate memory for `%s'"), p); + strvec_dispose (result); + return ((char **)NULL); + } + + /* Handle overflow and underflow of n+incr */ + if (ADDOVERFLOW (n, incr, INTMAX_MIN, INTMAX_MAX)) + break; + + n += incr; + + if ((incr < 0 && n < end) || (incr > 0 && n > end)) + break; + } + 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_l, rhs_l, width; + intmax_t lhs_v, rhs_v, incr; + intmax_t tl, tr; + char **result, *ep, *oep; + + t = strstr (text, BRACE_SEQ_SPECIFIER); + if (t == 0) + return ((char **)NULL); + + lhs_l = t - text; /* index of start of BRACE_SEQ_SPECIFIER */ + lhs = substring (text, 0, lhs_l); + rhs = substring (text, lhs_l + 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); + + /* Decide on rhs and whether or not it looks like the user specified + an increment */ + ep = 0; + if (ISDIGIT (rhs[0]) || ((rhs[0] == '+' || rhs[0] == '-') && ISDIGIT (rhs[1]))) + { + rhs_t = ST_INT; + errno = 0; + tr = strtoimax (rhs, &ep, 10); + if (errno == ERANGE || (ep && *ep != 0 && *ep != '.')) + rhs_t = ST_BAD; /* invalid */ + } + else if (ISALPHA (rhs[0]) && (rhs[1] == 0 || rhs[1] == '.')) + { + rhs_t = ST_CHAR; + ep = rhs + 1; + } + else + { + rhs_t = ST_BAD; + ep = 0; + } + + incr = 1; + if (rhs_t != ST_BAD) + { + oep = ep; + errno = 0; + if (ep && *ep == '.' && ep[1] == '.' && ep[2]) + incr = strtoimax (ep + 2, &ep, 10); + if (*ep != 0 || errno == ERANGE) + rhs_t = ST_BAD; /* invalid incr or overflow */ + tlen -= ep - oep; + } + + 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]; + width = 1; + } + else + { + lhs_v = tl; /* integer truncation */ + rhs_v = tr; + + /* Decide whether or not the terms need zero-padding */ + rhs_l = tlen - lhs_l - sizeof (BRACE_SEQ_SPECIFIER) + 1; + width = 0; + if (lhs_l > 1 && lhs[0] == '0') + width = lhs_l, lhs_t = ST_ZINT; + if (lhs_l > 2 && lhs[0] == '-' && lhs[1] == '0') + width = lhs_l, lhs_t = ST_ZINT; + if (rhs_l > 1 && rhs[0] == '0' && width < rhs_l) + width = rhs_l, lhs_t = ST_ZINT; + if (rhs_l > 2 && rhs[0] == '-' && rhs[1] == '0' && width < rhs_l) + width = rhs_l, lhs_t = ST_ZINT; + + if (width < lhs_l && lhs_t == ST_ZINT) + width = lhs_l; + if (width < rhs_l && lhs_t == ST_ZINT) + width = rhs_l; + } + + result = mkseq (lhs_v, rhs_v, incr, lhs_t, width); + + 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; +#if defined (SHELL) + ADVANCE_CHAR (text, tlen, i); +#else + i++; +#endif + 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; +#if defined (SHELL) + /* The shell allows quoted command substitutions */ + if (quoted == '"' && c == '$' && text[i+1] == '(') /*)*/ + goto comsub; +#endif +#if defined (SHELL) + ADVANCE_CHAR (text, tlen, i); +#else + i++; +#endif + continue; + } + + if (c == '"' || c == '\'' || c == '`') + { + quoted = c; + i++; + continue; + } + +#if defined (SHELL) + /* Pass new-style command and process substitutions through unchanged. */ + if ((c == '$' || c == '<' || c == '>') && text[i+1] == '(') /* ) */ + { +comsub: + si = i + 2; + t = extract_command_subst (text, &si, 0); + 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 + +#if defined (SHELL) + ADVANCE_CHAR (text, tlen, i); +#else + i++; +#endif + } + + *indx = i; + return (c); +} + +/* Return 1 if ARR has any non-empty-string members. Used to short-circuit + in array_concat() below. */ +static int +degenerate_array (arr) + char **arr; +{ + register int i; + + for (i = 0; arr[i]; i++) + if (arr[i][0] != '\0') + return 0; + return 1; +} + +/* 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 (arr2); /* XXX - see if we can get away without copying? */ + + if (arr2 == 0) + return (arr1); /* XXX - caller expects us to free arr1 */ + + /* We can only short-circuit if the array consists of a single null element; + otherwise we need to replicate the contents of the other array and + prefix (or append, below) an empty element to each one. */ + if (arr1[0] && arr1[0][0] == 0 && arr1[1] == 0) + { + strvec_dispose (arr1); + return (arr2); /* XXX - use flags to see if we can avoid copying here */ + } + + if (arr2[0] && arr2[0][0] == 0 && arr2[1] == 0) + return (arr1); /* XXX - rather than copying and freeing it */ + + 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 + +void * +xmalloc(n) + size_t n; +{ + return (malloc (n)); +} + +void * +xrealloc(p, n) + void *p; + size_t n; +{ + return (realloc (p, n)); +} + +int +internal_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]); + + strvec_dispose (result); + } +} + +/* + * Local variables: + * compile-command: "gcc -g -Bstatic -DTEST -o brace_expand braces.c general.o" + * end: + */ + +#endif /* TEST */ +#endif /* BRACE_EXPANSION */ diff --git a/builtins.h b/builtins.h new file mode 100644 index 0000000..0cfea18 --- /dev/null +++ b/builtins.h @@ -0,0 +1,62 @@ +/* builtins.h -- What a builtin looks like, and where to find them. */ + +/* Copyright (C) 1987-2009 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 3 of the License, 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. If not, see . +*/ + +#include "config.h" + +#if defined (HAVE_UNISTD_H) +# ifdef _MINIX +# include +# endif +# include +#endif + +#include "command.h" +#include "general.h" + +#if defined (ALIAS) +#include "alias.h" +#endif + +/* Flags describing various things about a builtin. */ +#define BUILTIN_ENABLED 0x01 /* This builtin is enabled. */ +#define BUILTIN_DELETED 0x02 /* This has been deleted with enable -d. */ +#define STATIC_BUILTIN 0x04 /* This builtin is not dynamically loaded. */ +#define SPECIAL_BUILTIN 0x08 /* This is a Posix `special' builtin. */ +#define ASSIGNMENT_BUILTIN 0x10 /* This builtin takes assignment statements. */ +#define POSIX_BUILTIN 0x20 /* This builtins is special in the Posix command search order. */ +#define LOCALVAR_BUILTIN 0x40 /* This builtin creates local variables */ + +#define BASE_INDENT 4 + +/* The thing that we build the array of builtins out of. */ +struct builtin { + char *name; /* The name that the user types. */ + sh_builtin_func_t *function; /* The address of the invoked function. */ + int flags; /* One of the #defines above. */ + char * const *long_doc; /* NULL terminated array of strings. */ + const char *short_doc; /* Short version of documentation. */ + char *handle; /* for future use */ +}; + +/* Found in builtins.c, created by builtins/mkbuiltins. */ +extern int num_shell_builtins; /* Number of shell builtins. */ +extern struct builtin static_shell_builtins[]; +extern struct builtin *shell_builtins; +extern struct builtin *current_builtin; diff --git a/builtins/Makefile.in b/builtins/Makefile.in new file mode 100644 index 0000000..bbb96c3 --- /dev/null +++ b/builtins/Makefile.in @@ -0,0 +1,694 @@ +# This Makefile for building libbuiltins.a is in -*- text -*- for Emacs. +# +# Copyright (C) 1996-2015 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 3 of the License, 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, see . + +PACKAGE = @PACKAGE_NAME@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_VERSION = @PACKAGE_VERSION@ + +# +SHELL = @MAKE_SHELL@ +RANLIB = @RANLIB@ +CC = @CC@ +CC_FOR_BUILD = @CC_FOR_BUILD@ +AR = @AR@ +ARFLAGS = @ARFLAGS@ +RM = rm -f +CP = cp + +EXEEXT = @EXEEXT@ + +prefix = @prefix@ + +srcdir = @srcdir@ +VPATH = @srcdir@ +topdir = @top_srcdir@ + +datarootdir = @datarootdir@ + +includedir = @includedir@ +datadir = @datadir@ +localedir = @localedir@ + +loadablesdir = @loadablesdir@ + +# Support an alternate destination root directory for package building +DESTDIR = + +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +BUILD_DIR = @BUILD_DIR@ + +LIBBUILD = ${BUILD_DIR}/lib + +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} +DEFS = @DEFS@ +LOCAL_DEFS = @LOCAL_DEFS@ + +LIBS = @LIBS@ +LDFLAGS = @LDFLAGS@ $(LOCAL_LDFLAGS) $(CFLAGS) +LDFLAGS_FOR_BUILD = @LDFLAGS_FOR_BUILD@ $(LOCAL_LDFLAGS) $(CFLAGS_FOR_BUILD) +LOCAL_LDFLAGS = @LOCAL_LDFLAGS@ +LIBS_FOR_BUILD = @LIBS_FOR_BUILD@ +#LIBS_FOR_BUILD = $(LIBS) + +BASHINCDIR = ${topdir}/include + +RL_INCLUDEDIR = @RL_INCLUDEDIR@ + +INTL_LIBSRC = ${topdir}/lib/intl +INTL_BUILDDIR = ${LIBBUILD}/intl +INTL_LIBDIR = ${INTL_BUILDDIR} +INTL_LIBRARY = ${INTL_BUILDDIR}/libintl.a +INTL_INC = @INTL_INC@ +INTL_DEP = @INTL_DEP@ +LIBINTL_H = @LIBINTL_H@ + +HELPDIR = @HELPDIR@ +MKDIRS = ${topdir}/support/mkdirs + +HELPFILES_TARGET = @HELPFILES_TARGET@ + +INCLUDES = -I. -I.. @RL_INCLUDE@ -I$(topdir) -I$(BASHINCDIR) -I$(topdir)/lib -I$(srcdir) ${INTL_INC} + +BASE_CCFLAGS = ${PROFILE_FLAGS} $(DEFS) $(LOCAL_DEFS) $(SYSTEM_FLAGS) \ + ${INCLUDES} $(LOCAL_CFLAGS) + +CCFLAGS = $(BASE_CCFLAGS) $(CPPFLAGS) $(CFLAGS) + +CCFLAGS_FOR_BUILD = $(BASE_CCFLAGS) $(CPPFLAGS_FOR_BUILD) $(CFLAGS_FOR_BUILD) + +GCC_LINT_FLAGS = -Wall -Wshadow -Wpointer-arith -Wcast-qual \ + -Wcast-align -Wstrict-prototypes -Wconversion \ + -Wmissing-prototypes -Wtraditional -Wredundant-decls -pedantic + +MKBUILTINS = mkbuiltins$(EXEEXT) +DIRECTDEFINE = -D $(srcdir) +HELPDIRDEFINE = @HELPDIRDEFINE@ +HELPSTRINGS = @HELPSTRINGS@ + +# xxx this is bad style +RL_LIBSRC = $(topdir)/lib/readline + +.SUFFIXES: +.SUFFIXES: .def .c .o +# How to make a .o file from a .def file. +.def.o: + $(RM) $@ + ./$(MKBUILTINS) $(DIRECTDEFINE) $< + $(CC) -c $(CCFLAGS) $*.c || ( $(RM) $*.c ; exit 1 ) + $(RM) $*.c + +# How to make a .c file from a .def file. +.def.c: + $(RM) $@ + ./$(MKBUILTINS) $(DIRECTDEFINE) $< + +# default rule for making a .o file from a .c file +.c.o: + $(RM) $@ + $(CC) -c $(CCFLAGS) $< + +DEFSRC = $(srcdir)/alias.def $(srcdir)/bind.def $(srcdir)/break.def \ + $(srcdir)/builtin.def $(srcdir)/caller.def \ + $(srcdir)/cd.def $(srcdir)/colon.def \ + $(srcdir)/command.def $(srcdir)/declare.def $(srcdir)/echo.def \ + $(srcdir)/enable.def $(srcdir)/eval.def $(srcdir)/getopts.def \ + $(srcdir)/exec.def $(srcdir)/exit.def $(srcdir)/fc.def \ + $(srcdir)/fg_bg.def $(srcdir)/hash.def $(srcdir)/help.def \ + $(srcdir)/history.def $(srcdir)/jobs.def $(srcdir)/kill.def \ + $(srcdir)/let.def $(srcdir)/read.def $(srcdir)/return.def \ + $(srcdir)/set.def $(srcdir)/setattr.def $(srcdir)/shift.def \ + $(srcdir)/source.def $(srcdir)/suspend.def $(srcdir)/test.def \ + $(srcdir)/times.def $(srcdir)/trap.def $(srcdir)/type.def \ + $(srcdir)/ulimit.def $(srcdir)/umask.def $(srcdir)/wait.def \ + $(srcdir)/reserved.def $(srcdir)/pushd.def $(srcdir)/shopt.def \ + $(srcdir)/printf.def $(srcdir)/complete.def $(srcdir)/mapfile.def + +STATIC_SOURCE = common.c evalstring.c evalfile.c getopt.c bashgetopt.c \ + getopt.h + +OFILES = builtins.o \ + alias.o bind.o break.o builtin.o caller.o cd.o colon.o command.o \ + common.o declare.o echo.o enable.o eval.o evalfile.o \ + evalstring.o exec.o exit.o fc.o fg_bg.o hash.o help.o history.o \ + jobs.o kill.o let.o mapfile.o \ + pushd.o read.o return.o set.o setattr.o shift.o source.o \ + suspend.o test.o times.o trap.o type.o ulimit.o umask.o \ + wait.o getopts.o shopt.o printf.o getopt.o bashgetopt.o complete.o + +CREATED_FILES = builtext.h builtins.c psize.aux pipesize.h tmpbuiltins.c \ + tmpbuiltins.h +CREATED_OBJECTS = tmpbuiltins.o gen-helpfiles.o mkbuiltins.o + +all: $(MKBUILTINS) libbuiltins.a $(HELPFILES_TARGET) +targets: libbuiltins.a $(HELPFILES_TARGET) + +libbuiltins.a: $(MKBUILTINS) $(OFILES) builtins.o + $(RM) $@ + $(AR) $(ARFLAGS) $@ $(OFILES) + -$(RANLIB) $@ + +tmpbuiltins.c: $(MKBUILTINS) $(DEFSRC) + ./$(MKBUILTINS) -externfile tmpbuiltins.h -structfile $@ \ + -noproduction -nofunctions \ + $(DIRECTDEFINE) $(HELPSTRINGS) $(DEFSRC) + +tmpbuiltins.h: tmpbuiltins.c + +gen-helpfiles.o: ../config.h +gen-helpfiles.o: gen-helpfiles.c + $(RM) $@ + $(CC_FOR_BUILD) -c $(CCFLAGS_FOR_BUILD) $< + +gen-helpfiles: tmpbuiltins.o gen-helpfiles.o + $(CC_FOR_BUILD) ${CCFLAGS_FOR_BUILD} $(LDFLAGS_FOR_BUILD) -o $@ gen-helpfiles.o tmpbuiltins.o $(LIBS_FOR_BUILD) + +builtext.h builtins.c: $(MKBUILTINS) $(DEFSRC) + @-if test -f builtins.c; then mv -f builtins.c old-builtins.c; fi + @-if test -f builtext.h; then mv -f builtext.h old-builtext.h; fi + ./$(MKBUILTINS) -externfile builtext.h -structfile builtins.c \ + -noproduction $(DIRECTDEFINE) $(HELPDIRDEFINE) $(HELPSTRINGS) $(DEFSRC) + @-if cmp -s old-builtext.h builtext.h 2>/dev/null; then \ + mv old-builtext.h builtext.h; \ + else \ + $(RM) old-builtext.h; \ + fi + @-if cmp -s old-builtins.c builtins.c 2>/dev/null; then \ + mv old-builtins.c builtins.c; \ + else \ + $(RM) old-builtins.c; \ + fi + +helpdoc: gen-helpfiles + ./gen-helpfiles ${HELPDIRDEFINE} + +install-help: + @-if test -n "${HELPDIR}" && test -d helpfiles ; then \ + test -d $(DESTDIR)${HELPDIR} || ${SHELL} ${MKDIRS} $(DESTDIR)$(HELPDIR) ;\ + ( for f in helpfiles/*; do \ + echo installing $$f; \ + ${INSTALL_DATA} $$f $(DESTDIR)$(HELPDIR); \ + done; ) ; \ + fi + +install: @HELPINSTALL@ + +mkbuiltins.o: ../config.h +mkbuiltins.o: mkbuiltins.c + $(RM) $@ + $(CC_FOR_BUILD) -c $(CCFLAGS_FOR_BUILD) $< + +mkbuiltins$(EXEEXT): mkbuiltins.o + $(CC_FOR_BUILD) $(LDFLAGS_FOR_BUILD) -o $(MKBUILTINS) mkbuiltins.o $(LIBS_FOR_BUILD) + +# rules for deficient makes, like SunOS +mkbuiltins.o: mkbuiltins.c +builtins.o: builtins.c +common.o: common.c +bashgetopt.o: bashgetopt.c +getopt.o: getopt.c +evalstring.o: evalstring.c +evalfile.o: evalfile.c + +tmpbuiltins.o: tmpbuiltins.c +gen-helpfiles.o: gen-helpfiles.c + +ulimit.o: pipesize.h + +pipesize.h: psize.aux + $(SHELL) $(srcdir)/psize.sh > $@ + +# Technically this is wrong; the pipe size should be for the target system, +# not the build host. +psize.aux: psize.c + $(CC_FOR_BUILD) $(CCFLAGS_FOR_BUILD) ${LDFLAGS_FOR_BUILD} -o $@ $(srcdir)/psize.c + +documentation: builtins.texi + +builtins.texi: $(MKBUILTINS) + ./$(MKBUILTINS) -documentonly $(DEFSRC) + +clean: + $(RM) $(OFILES) $(CREATED_FILES) libbuiltins.a + $(RM) $(MKBUILTINS) gen-helpfiles $(CREATED_OBJECTS) + -test -d helpfiles && $(RM) -r helpfiles + +mostlyclean: + $(RM) $(OFILES) libbuiltins.a + +distclean maintainer-clean: clean + $(RM) Makefile + +$(OFILES): $(MKBUILTINS) ../config.h + +../version.h: ../config.h ../Makefile Makefile + -( cd ${BUILD_DIR} && ${MAKE} ${MFLAGS} version.h ) + +# maintainer special - for now +po: builtins.c + xgettext -L C -o $(topdir)/po/builtins.pot --keyword='N_' builtins.c 2>/dev/null + +${LIBINTL_H}: + @echo making $@ in ${INTL_BUILDDIR} + @(cd ${INTL_BUILDDIR} && \ + $(MAKE) $(MFLAGS) libintl.h) || exit 1 + +# dependencies + +alias.o: alias.def +bind.o: bind.def +break.o: break.def +builtin.o: builtin.def +caller.o: caller.def +cd.o: cd.def +colon.o: colon.def +command.o: command.def +declare.o: declare.def +echo.o: echo.def +enable.o: enable.def +eval.o: eval.def +exec.o: exec.def +exit.o: exit.def +fc.o: fc.def +fg_bg.o: fg_bg.def +hash.o: hash.def +help.o: help.def +history.o: history.def +jobs.o: jobs.def +kill.o: kill.def +let.o: let.def +mapfile.o: mapfile.def +printf.o: printf.def +pushd.o: pushd.def +read.o: read.def +return.o: return.def +set.o: set.def +setattr.o: setattr.def +shift.o: shift.def +shopt.o: shopt.def +source.o: source.def +suspend.o: suspend.def +test.o: test.def +times.o: times.def +trap.o: trap.def +type.o: type.def +ulimit.o: ulimit.def +umask.o: umask.def +wait.o: wait.def +getopts.o: getopts.def +reserved.o: reserved.def +complete.o: complete.def + +# C files +bashgetopt.o: ../config.h $(topdir)/bashansi.h $(BASHINCDIR)/ansi_stdlib.h +bashgetopt.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/bashjmp.h +bashgetopt.o: $(topdir)/command.h $(topdir)/general.h $(topdir)/xmalloc.h $(topdir)/error.h +bashgetopt.o: $(topdir)/variables.h $(topdir)/conftypes.h $(topdir)/quit.h $(BASHINCDIR)/maxpath.h +bashgetopt.o: $(topdir)/unwind_prot.h $(topdir)/dispose_cmd.h +bashgetopt.o: $(topdir)/make_cmd.h $(topdir)/subst.h $(topdir)/sig.h +bashgetopt.o: ../pathnames.h $(topdir)/externs.h $(srcdir)/common.h +bashgetopt.o: $(BASHINCDIR)/chartypes.h +common.o: $(topdir)/bashtypes.h $(BASHINCDIR)/posixstat.h $(topdir)/bashansi.h $(BASHINCDIR)/ansi_stdlib.h +common.o: $(topdir)/shell.h $(topdir)/syntax.h ../config.h $(topdir)/bashjmp.h $(BASHINCDIR)/posixjmp.h +common.o: $(topdir)/sig.h $(topdir)/command.h +common.o: $(topdir)/general.h $(topdir)/xmalloc.h $(BASHINCDIR)/stdc.h $(BASHINCDIR)/memalloc.h +common.o: $(topdir)/variables.h $(topdir)/conftypes.h $(topdir)/input.h +common.o: $(topdir)/siglist.h $(topdir)/bashhist.h $(topdir)/quit.h +common.o: $(topdir)/unwind_prot.h $(BASHINCDIR)/maxpath.h $(topdir)/jobs.h +common.o: $(topdir)/builtins.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h +common.o: $(topdir)/subst.h $(topdir)/execute_cmd.h $(topdir)/error.h +common.o: $(topdir)/externs.h ../pathnames.h ./builtext.h +common.o: $(BASHINCDIR)/chartypes.h +evalfile.o: $(topdir)/bashtypes.h $(BASHINCDIR)/posixstat.h ${BASHINCDIR}/filecntl.h +evalfile.o: $(topdir)/bashansi.h $(BASHINCDIR)/ansi_stdlib.h +evalfile.o: $(topdir)/shell.h $(topdir)/syntax.h ../config.h $(topdir)/bashjmp.h +evalfile.o: $(topdir)/command.h $(topdir)/general.h $(topdir)/xmalloc.h $(topdir)/error.h +evalfile.o: $(topdir)/variables.h $(topdir)/conftypes.h $(topdir)/quit.h $(BASHINCDIR)/maxpath.h +evalfile.o: $(topdir)/unwind_prot.h $(topdir)/dispose_cmd.h +evalfile.o: $(topdir)/make_cmd.h $(topdir)/subst.h $(topdir)/sig.h +evalfile.o: ../pathnames.h $(topdir)/externs.h +evalfile.o: $(topdir)/jobs.h $(topdir)/builtins.h $(topdir)/flags.h +evalfile.o: $(topdir)/input.h $(topdir)/execute_cmd.h +evalfile.o: $(topdir)/bashhist.h $(srcdir)/common.h +evalstring.o: ../config.h $(topdir)/bashansi.h $(BASHINCDIR)/ansi_stdlib.h +evalstring.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/bashjmp.h $(BASHINCDIR)/posixjmp.h +evalstring.o: $(topdir)/sig.h $(topdir)/command.h $(topdir)/siglist.h +evalstring.o: $(BASHINCDIR)/memalloc.h $(topdir)/variables.h $(topdir)/conftypes.h $(topdir)/input.h +evalstring.o: $(topdir)/quit.h $(topdir)/unwind_prot.h +evalstring.o: $(BASHINCDIR)/maxpath.h $(topdir)/jobs.h $(topdir)/builtins.h +evalstring.o: $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/subst.h +evalstring.o: $(topdir)/externs.h $(topdir)/jobs.h $(topdir)/builtins.h +evalstring.o: $(topdir)/flags.h $(topdir)/input.h $(topdir)/execute_cmd.h +evalstring.o: $(topdir)/bashhist.h $(srcdir)/common.h +evalstring.o: $(topdir)/trap.h $(topdir)/redir.h ../pathnames.h +#evalstring.o: $(topdir)/y.tab.h +getopt.o: ../config.h $(BASHINCDIR)/memalloc.h +getopt.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/bashjmp.h $(topdir)/command.h +getopt.o: $(topdir)/general.h $(topdir)/xmalloc.h $(topdir)/error.h $(topdir)/variables.h $(topdir)/conftypes.h +getopt.o: $(topdir)/quit.h $(BASHINCDIR)/maxpath.h $(topdir)/unwind_prot.h +getopt.o: $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/subst.h +getopt.o: $(topdir)/sig.h ../pathnames.h $(topdir)/externs.h +getopt.o: $(srcdir)/getopt.h +mkbuiltins.o: ../config.h $(topdir)/bashtypes.h $(BASHINCDIR)/posixstat.h +mkbuiltins.o: ${BASHINCDIR}/filecntl.h +mkbuiltins.o: $(topdir)/bashansi.h $(BASHINCDIR)/ansi_stdlib.h + +# def files +alias.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h +alias.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h $(BASHINCDIR)/maxpath.h +alias.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h +alias.o: $(topdir)/subst.h $(topdir)/externs.h $(srcdir)/common.h +alias.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h +alias.o: ../pathnames.h +bind.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h $(topdir)/error.h +bind.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h +bind.o: $(topdir)/subst.h $(topdir)/externs.h $(srcdir)/bashgetopt.h +bind.o: $(topdir)/general.h $(topdir)/xmalloc.h $(BASHINCDIR)/maxpath.h $(topdir)/bashline.h +bind.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h +bind.o: ../pathnames.h +break.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h +break.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h +break.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h +break.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h +break.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h +break.o: ../pathnames.h +builtin.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h +builtin.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h $(topdir)/externs.h +builtin.o: $(topdir)/quit.h $(srcdir)/common.h $(BASHINCDIR)/maxpath.h $(topdir)/sig.h +builtin.o: $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/subst.h +builtin.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h +builtin.o: $(srcdir)/bashgetopt.h ../pathnames.h +caller.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h $(topdir)/error.h +caller.o: $(topdir)/general.h $(topdir)/xmalloc.h $(topdir)/quit.h $(topdir)/dispose_cmd.h +caller.o: $(topdir)/make_cmd.h $(topdir)/subst.h $(topdir)/externs.h $(topdir)/sig.h +caller.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h +caller.o: $(srcdir)/common.h $(BASHINCDIR)/maxpath.h ./builtext.h +caller.o: ${BASHINCDIR}/chartypes.h $(topdir)/bashtypes.h ../pathnames.h +cd.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h $(topdir)/error.h +cd.o: $(topdir)/general.h $(topdir)/xmalloc.h $(topdir)/quit.h $(topdir)/dispose_cmd.h +cd.o: $(topdir)/make_cmd.h $(topdir)/subst.h $(topdir)/externs.h +cd.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h +cd.o: $(srcdir)/common.h $(BASHINCDIR)/maxpath.h ../pathnames.h +cd.o: $(topdir)/sig.h +command.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h +command.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h $(topdir)/externs.h +command.o: $(topdir)/quit.h $(srcdir)/bashgetopt.h $(BASHINCDIR)/maxpath.h +command.o: $(topdir)/sig.h +command.o: $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/subst.h +command.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h +command.o: ../pathnames.h +declare.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h +declare.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h +declare.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h +declare.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h +declare.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h +declare.o: $(topdir)/arrayfunc.h $(srcdir)/bashgetopt.h $(topdir)/flags.h +declare.o: ./builtext.h ../pathnames.h +echo.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h $(topdir)/error.h +echo.o: $(topdir)/general.h $(topdir)/xmalloc.h $(topdir)/subst.h $(topdir)/externs.h +echo.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h +echo.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h +echo.o: $(BASHINCDIR)/maxpath.h ../pathnames.h +enable.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h +enable.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h +enable.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h +enable.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/sig.h +enable.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h +enable.o: $(BASHINCDIR)/maxpath.h ../pathnames.h +enable.o: $(topdir)/pcomplete.h +eval.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h +eval.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h +eval.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h +eval.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/sig.h +eval.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h +eval.o: $(BASHINCDIR)/maxpath.h ../pathnames.h +exec.o: $(topdir)/bashtypes.h +exec.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h +exec.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h +exec.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h +exec.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/flags.h +exec.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h +exec.o: $(srcdir)/common.h $(topdir)/execute_cmd.h $(BASHINCDIR)/maxpath.h +exec.o: $(topdir)/findcmd.h $(topdir)/jobs.h ../pathnames.h +exit.o: $(topdir)/bashtypes.h +exit.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h +exit.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h +exit.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h +exit.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/jobs.h +exit.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h +exit.o: $(BASHINCDIR)/maxpath.h ./builtext.h ../pathnames.h +fc.o: $(topdir)/bashtypes.h $(BASHINCDIR)/posixstat.h +fc.o: $(topdir)/builtins.h $(topdir)/command.h $(srcdir)/bashgetopt.h +fc.o: $(topdir)/bashhist.h +fc.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h $(topdir)/error.h +fc.o: $(topdir)/general.h $(topdir)/xmalloc.h $(BASHINCDIR)/maxpath.h +fc.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h +fc.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/shell.h $(topdir)/syntax.h +fc.o: $(topdir)/flags.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h +fc.o: $(topdir)/bashansi.h $(BASHINCDIR)/ansi_stdlib.h $(BASHINCDIR)/chartypes.h +fc.o: ../pathnames.h +fg_bg.o: $(topdir)/bashtypes.h $(srcdir)/bashgetopt.h +fg_bg.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h +fg_bg.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h +fg_bg.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h +fg_bg.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h +fg_bg.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h +fg_bg.o: $(topdir)/jobs.h ../pathnames.h +getopts.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h +getopts.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h +getopts.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h +getopts.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h +getopts.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h +getopts.o: ../pathnames.h +hash.o: $(topdir)/builtins.h $(topdir)/command.h $(topdir)/quit.h +hash.o: $(topdir)/findcmd.h $(topdir)/hashlib.h $(topdir)/sig.h +hash.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h +hash.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h +hash.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h +hash.o: $(srcdir)/common.h $(BASHINCDIR)/maxpath.h ../pathnames.h +help.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h +help.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h +help.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h +help.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h +help.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h +help.o: ${srcdir}/common.h $(topdir)/sig.h ../pathnames.h +history.o: $(topdir)/bashtypes.h +history.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h +history.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h +history.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h +history.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/sig.h +history.o: ${BASHINCDIR}/filecntl.h $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h +history.o: $(topdir)/variables.h $(topdir)/conftypes.h $(topdir)/bashhist.h $(BASHINCDIR)/maxpath.h +history.o: ../pathnames.h +inlib.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h +inlib.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h +inlib.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h +inlib.o: $(BASHINCDIR)/maxpath.h $(topdir)/subst.h $(topdir)/externs.h +inlib.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h ../pathnames.h +jobs.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h $(topdir)/error.h +jobs.o: $(topdir)/general.h $(topdir)/xmalloc.h $(topdir)/quit.h $(srcdir)/bashgetopt.h +jobs.o: $(BASHINCDIR)/maxpath.h $(topdir)/externs.h $(topdir)/jobs.h +jobs.o: $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/subst.h +jobs.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h +jobs.o: $(topdir)/sig.h ../pathnames.h +kill.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h $(topdir)/error.h +kill.o: $(topdir)/general.h $(topdir)/xmalloc.h $(topdir)/subst.h $(topdir)/externs.h +kill.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h +kill.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/trap.h $(topdir)/unwind_prot.h +kill.o: $(topdir)/variables.h $(topdir)/conftypes.h $(BASHINCDIR)/maxpath.h +kill.o: $(topdir)/jobs.h ../pathnames.h +let.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h +let.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h +let.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h +let.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h +let.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h +let.o: ../pathnames.h +printf.o: ../config.h $(BASHINCDIR)/memalloc.h $(topdir)/bashjmp.h +printf.o: $(topdir)/command.h $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h +printf.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h +printf.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/sig.h +printf.o: ../pathnames.h $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h +printf.o: $(topdir)/variables.h $(topdir)/conftypes.h $(BASHINCDIR)/stdc.h $(srcdir)/bashgetopt.h +printf.o: $(topdir)/bashtypes.h ${srcdir}/common.h $(BASHINCDIR)/chartypes.h +printf.o: ${BASHINCDIR}/shmbutil.h ${BASHINCDIR}/shmbchar.h +printf.o: ../pathnames.h +pushd.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h +pushd.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h +pushd.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h +pushd.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/sig.h +pushd.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h +pushd.o: $(BASHINCDIR)/maxpath.h $(srcdir)/common.h ./builtext.h +pushd.o: ../pathnames.h +read.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h +read.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h +read.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h +read.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h +read.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h +read.o: $(BASHINCDIR)/shtty.h $(topdir)/sig.h +read.o: ${BASHINCDIR}/shmbutil.h ${BASHINCDIR}/shmbchar.h +read.o: $(topdir)/arrayfunc.h ../pathnames.h +return.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h +return.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h +return.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h +return.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h +return.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h +return.o: ../pathnames.h +set.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h +set.o: $(topdir)/general.h $(topdir)/xmalloc.h $(topdir)/subst.h $(topdir)/externs.h +set.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h +set.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h +set.o: $(BASHINCDIR)/maxpath.h $(topdir)/error.h $(topdir)/sig.h +set.o: $(topdir)/arrayfunc.h ../pathnames.h +setattr.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h +setattr.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h $(BASHINCDIR)/maxpath.h +setattr.o: $(topdir)/quit.h $(srcdir)/common.h $(srcdir)/bashgetopt.h +setattr.o: $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/subst.h +setattr.o: $(topdir)/externs.h $(topdir)/flags.h $(topdir)/sig.h +setattr.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h +setattr.o: $(topdir)/arrayfunc.h ../pathnames.h +shift.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h +shift.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h +shift.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h +shift.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h +shift.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h +shift.o: ../pathnames.h +shopt.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h +shopt.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h +shopt.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h +shopt.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h +shopt.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h +shopt.o: $(srcdir)/common.h $(srcdir)/bashgetopt.h ../pathnames.h +shopt.o: $(topdir)/bashhist.h $(topdir)/bashline.h $(topdir)/sig.h +source.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h +source.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h $(topdir)/findcmd.h +source.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h +source.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h +source.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h +source.o: $(srcdir)/bashgetopt.h $(topdir)/flags.h $(topdir)/trap.h +source.o: ../pathnames.h +suspend.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h +suspend.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h +suspend.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h +suspend.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h +suspend.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h +suspend.o: $(topdir)/jobs.h ../pathnames.h +test.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h +test.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h +test.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h +test.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h +test.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h +test.o: $(topdir)/test.h ../pathnames.h +times.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h +times.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h +times.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h +times.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h +times.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h +times.o: $(BASHINCDIR)/posixtime.h ../pathnames.h +trap.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h +trap.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h $(topdir)/externs.h +trap.o: $(topdir)/quit.h $(srcdir)/common.h $(BASHINCDIR)/maxpath.h $(topdir)/sig.h +trap.o: $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/subst.h +trap.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h +trap.o: $(topdir)/findcmd.h ../pathnames.h +type.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h +type.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h +type.o: $(topdir)/quit.h $(srcdir)/common.h $(BASHINCDIR)/maxpath.h $(topdir)/sig.h +type.o: $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/subst.h +type.o: $(topdir)/externs.h $(topdir)/hashcmd.h ../pathnames.h +type.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h +ulimit.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h +ulimit.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h +ulimit.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h +ulimit.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h +ulimit.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h +ulimit.o: ../pathnames.h +umask.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h +umask.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h +umask.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h +umask.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h +umask.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h +umask.o: $(BASHINCDIR)/chartypes.h ../pathnames.h +wait.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h +wait.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h +wait.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h +wait.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h +wait.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/unwind_prot.h $(topdir)/variables.h $(topdir)/conftypes.h +wait.o: $(topdir)/jobs.h $(topdir)/sig.h +wait.o: $(BASHINCDIR)/chartypes.h ../pathnames.h + +complete.o: ../config.h ../pathnames.h +complete.o: ${topdir}/shell.h $(topdir)/syntax.h ${topdir}/bashjmp.h ${BASHINCDIR}/posixjmp.h ${topdir}/sig.h +complete.o: ${topdir}/unwind_prot.h ${topdir}/variables.h +complete.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h +complete.o: ${topdir}/bashtypes.h ${topdir}/bashansi.h ${BASHINCDIR}/ansi_stdlib.h +complete.o: ${topdir}/builtins.h ${topdir}/general.h +complete.o: ${topdir}/bashtypes.h ${BASHINCDIR}/chartypes.h ${topdir}/xmalloc.h +complete.o: ${topdir}/pcomplete.h +complete.o: ${srcdir}/common.h ${srcdir}/bashgetopt.h +mapfile.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h +mapfile.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/xmalloc.h +mapfile.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/sig.h +mapfile.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h +mapfile.o: $(topdir)/shell.h $(topdir)/syntax.h $(topdir)/variables.h $(topdir)/conftypes.h +mapfile.o: $(topdir)/arrayfunc.h ../pathnames.h + +#bind.o: $(RL_LIBSRC)chardefs.h $(RL_LIBSRC)readline.h $(RL_LIBSRC)keymaps.h + +# libintl dependencies +bind.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +break.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +caller.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +cd.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +common.c: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +complete.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +declare.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +enable.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +evalfile.c: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +exec.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +exit.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +fc.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +fg_bg.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +getopt.c: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +hash.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +help.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +history.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +inlib.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +jobs.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +kill.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +let.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +mapfile.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +mkbuiltins.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +printf.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +pushd.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +read.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +return.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +set.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +setattr.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +shift.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +shopt.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +source.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +suspend.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +type.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +ulimit.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h +umask.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h diff --git a/builtins/alias.def b/builtins/alias.def new file mode 100644 index 0000000..5080024 --- /dev/null +++ b/builtins/alias.def @@ -0,0 +1,243 @@ +This file is alias.def, from which is created alias.c +It implements the builtins "alias" and "unalias" in Bash. + +Copyright (C) 1987-2015 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 3 of the License, 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. If not, see . + +$BUILTIN alias +$FUNCTION alias_builtin +$DEPENDS_ON ALIAS +$PRODUCES alias.c +$SHORT_DOC alias [-p] [name[=value] ... ] +Define or display aliases. + +Without arguments, `alias' prints the list of aliases in the reusable +form `alias NAME=VALUE' on standard output. + +Otherwise, an alias is defined for each NAME whose VALUE is given. +A trailing space in VALUE causes the next word to be checked for +alias substitution when the alias is expanded. + +Options: + -p print all defined aliases in a reusable format + +Exit Status: +alias returns true unless a NAME is supplied for which no alias has been +defined. +$END + +#include + +#if defined (ALIAS) + +#if defined (HAVE_UNISTD_H) +# ifdef _MINIX +# include +# endif +# include +#endif + +# include "../bashansi.h" +# include "../bashintl.h" + +# include +# include "../shell.h" +# include "../alias.h" +# include "common.h" +# include "bashgetopt.h" + +/* Flags for print_alias */ +#define AL_REUSABLE 0x01 + +static void print_alias __P((alias_t *, int)); + +extern int posixly_correct; + +/* Hack the alias command in a Korn shell way. */ +int +alias_builtin (list) + WORD_LIST *list; +{ + int any_failed, offset, pflag, dflags; + alias_t **alias_list, *t; + char *name, *value; + + dflags = posixly_correct ? 0 : AL_REUSABLE; + pflag = 0; + reset_internal_getopt (); + while ((offset = internal_getopt (list, "p")) != -1) + { + switch (offset) + { + case 'p': + pflag = 1; + dflags |= AL_REUSABLE; + break; + CASE_HELPOPT; + default: + builtin_usage (); + return (EX_USAGE); + } + } + + list = loptend; + + if (list == 0 || pflag) + { + if (aliases == 0) + return (EXECUTION_SUCCESS); + + alias_list = all_aliases (); + + if (alias_list == 0) + return (EXECUTION_SUCCESS); + + for (offset = 0; alias_list[offset]; offset++) + print_alias (alias_list[offset], dflags); + + free (alias_list); /* XXX - Do not free the strings. */ + + if (list == 0) + return (sh_chkwrite (EXECUTION_SUCCESS)); + } + + any_failed = 0; + while (list) + { + name = list->word->word; + + for (offset = 0; name[offset] && name[offset] != '='; offset++) + ; + + if (offset && name[offset] == '=') + { + name[offset] = '\0'; + value = name + offset + 1; + + if (legal_alias_name (name, 0) == 0) + { + builtin_error (_("`%s': invalid alias name"), name); + any_failed++; + } + else + add_alias (name, value); + } + else + { + t = find_alias (name); + if (t) + print_alias (t, dflags); + else + { + sh_notfound (name); + any_failed++; + } + } + list = list->next; + } + + return (any_failed ? EXECUTION_FAILURE : EXECUTION_SUCCESS); +} +#endif /* ALIAS */ + +$BUILTIN unalias +$FUNCTION unalias_builtin +$DEPENDS_ON ALIAS +$SHORT_DOC unalias [-a] name [name ...] +Remove each NAME from the list of defined aliases. + +Options: + -a remove all alias definitions + +Return success unless a NAME is not an existing alias. +$END + +#if defined (ALIAS) +/* Remove aliases named in LIST from the aliases database. */ +int +unalias_builtin (list) + register WORD_LIST *list; +{ + register alias_t *alias; + int opt, aflag; + + aflag = 0; + reset_internal_getopt (); + while ((opt = internal_getopt (list, "a")) != -1) + { + switch (opt) + { + case 'a': + aflag = 1; + break; + CASE_HELPOPT; + default: + builtin_usage (); + return (EX_USAGE); + } + } + + list = loptend; + + if (aflag) + { + delete_all_aliases (); + return (EXECUTION_SUCCESS); + } + + if (list == 0) + { + builtin_usage (); + return (EX_USAGE); + } + + aflag = 0; + while (list) + { + alias = find_alias (list->word->word); + + if (alias) + remove_alias (alias->name); + else + { + sh_notfound (list->word->word); + aflag++; + } + + list = list->next; + } + + return (aflag ? EXECUTION_FAILURE : EXECUTION_SUCCESS); +} + +/* Output ALIAS in such a way as to allow it to be read back in. */ +static void +print_alias (alias, flags) + alias_t *alias; + int flags; +{ + char *value; + + value = sh_single_quote (alias->value); + if (flags & AL_REUSABLE) + printf ("alias %s", (alias->name && alias->name[0] == '-') ? "-- " : ""); + printf ("%s=%s\n", alias->name, value); + free (value); + + fflush (stdout); +} +#endif /* ALIAS */ diff --git a/builtins/bashgetopt.c b/builtins/bashgetopt.c new file mode 100644 index 0000000..405ced4 --- /dev/null +++ b/builtins/bashgetopt.c @@ -0,0 +1,181 @@ +/* bashgetopt.c -- `getopt' for use by the builtins. */ + +/* Copyright (C) 1992-2002 Free Software Foundation, Inc. + + This file is part of GNU Bash, the Bourne Again SHell. + + Bash is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, 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. If not, see . +*/ + +#include + +#if defined (HAVE_UNISTD_H) +# include +#endif + +#include "../bashansi.h" +#include +#include + +#include "../shell.h" +#include "common.h" + +#include "bashgetopt.h" + +#define ISOPT(s) (((*(s) == '-') || (plus && *(s) == '+')) && (s)[1]) +#define NOTOPT(s) (((*(s) != '-') && (!plus || *(s) != '+')) || (s)[1] == '\0') + +static int sp; + +char *list_optarg; +int list_optopt; +int list_opttype; + +static WORD_LIST *lhead = (WORD_LIST *)NULL; +WORD_LIST *lcurrent = (WORD_LIST *)NULL; +WORD_LIST *loptend; /* Points to the first non-option argument in the list */ + +int +internal_getopt(list, opts) +WORD_LIST *list; +char *opts; +{ + register int c; + register char *cp; + int plus; /* nonzero means to handle +option */ + static char errstr[3] = { '-', '\0', '\0' }; + + plus = *opts == '+'; + if (plus) + opts++; + + if (list == 0) { + list_optarg = (char *)NULL; + loptend = (WORD_LIST *)NULL; /* No non-option arguments */ + return -1; + } + + if (list != lhead || lhead == 0) { + /* Hmmm.... called with a different word list. Reset. */ + sp = 1; + lcurrent = lhead = list; + loptend = (WORD_LIST *)NULL; + } + + if (sp == 1) { + if (lcurrent == 0 || NOTOPT(lcurrent->word->word)) { + lhead = (WORD_LIST *)NULL; + loptend = lcurrent; + return(-1); + } else if (ISHELP (lcurrent->word->word)) { + lhead = (WORD_LIST *)NULL; + loptend = lcurrent; + return (GETOPT_HELP); + } else if (lcurrent->word->word[0] == '-' && + lcurrent->word->word[1] == '-' && + lcurrent->word->word[2] == 0) { + lhead = (WORD_LIST *)NULL; + loptend = lcurrent->next; + return(-1); + } + errstr[0] = list_opttype = lcurrent->word->word[0]; + } + + list_optopt = c = lcurrent->word->word[sp]; + + if (c == ':' || (cp = strchr(opts, c)) == NULL) { + errstr[1] = c; + sh_invalidopt (errstr); + if (lcurrent->word->word[++sp] == '\0') { + lcurrent = lcurrent->next; + sp = 1; + } + list_optarg = NULL; + if (lcurrent) + loptend = lcurrent->next; + return('?'); + } + + if (*++cp == ':' || *cp == ';') { + /* `:': Option requires an argument. */ + /* `;': option argument may be missing */ + /* We allow -l2 as equivalent to -l 2 */ + if (lcurrent->word->word[sp+1]) { + list_optarg = lcurrent->word->word + sp + 1; + lcurrent = lcurrent->next; + /* If the specifier is `;', don't set optarg if the next + argument looks like another option. */ +#if 0 + } else if (lcurrent->next && (*cp == ':' || lcurrent->next->word->word[0] != '-')) { +#else + } else if (lcurrent->next && (*cp == ':' || NOTOPT(lcurrent->next->word->word))) { +#endif + lcurrent = lcurrent->next; + list_optarg = lcurrent->word->word; + lcurrent = lcurrent->next; + } else if (*cp == ';') { + list_optarg = (char *)NULL; + lcurrent = lcurrent->next; + } else { /* lcurrent->next == NULL */ + errstr[1] = c; + sh_needarg (errstr); + sp = 1; + list_optarg = (char *)NULL; + return('?'); + } + sp = 1; + } else if (*cp == '#') { + /* option requires a numeric argument */ + if (lcurrent->word->word[sp+1]) { + if (DIGIT(lcurrent->word->word[sp+1])) { + list_optarg = lcurrent->word->word + sp + 1; + lcurrent = lcurrent->next; + } else + list_optarg = (char *)NULL; + } else { + if (lcurrent->next && legal_number(lcurrent->next->word->word, (intmax_t *)0)) { + lcurrent = lcurrent->next; + list_optarg = lcurrent->word->word; + lcurrent = lcurrent->next; + } else { + errstr[1] = c; + sh_neednumarg (errstr); + sp = 1; + list_optarg = (char *)NULL; + return ('?'); + } + } + + } else { + /* No argument, just return the option. */ + if (lcurrent->word->word[++sp] == '\0') { + sp = 1; + lcurrent = lcurrent->next; + } + list_optarg = (char *)NULL; + } + + return(c); +} + +/* + * reset_internal_getopt -- force the in[ft]ernal getopt to reset + */ + +void +reset_internal_getopt () +{ + lhead = lcurrent = loptend = (WORD_LIST *)NULL; + sp = 1; +} diff --git a/builtins/bashgetopt.h b/builtins/bashgetopt.h new file mode 100644 index 0000000..6637b42 --- /dev/null +++ b/builtins/bashgetopt.h @@ -0,0 +1,42 @@ +/* bashgetopt.h -- extern declarations for stuff defined in bashgetopt.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 3 of the License, 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. If not, see . +*/ + +/* See getopt.h for the explanation of these variables. */ + +#if !defined (__BASH_GETOPT_H) +# define __BASH_GETOPT_H + +#include + +#define GETOPT_EOF -1 +#define GETOPT_HELP -99 + +extern char *list_optarg; + +extern int list_optopt; +extern int list_opttype; + +extern WORD_LIST *lcurrent; +extern WORD_LIST *loptend; + +extern int internal_getopt __P((WORD_LIST *, char *)); +extern void reset_internal_getopt __P((void)); + +#endif /* !__BASH_GETOPT_H */ diff --git a/builtins/bind.def b/builtins/bind.def new file mode 100644 index 0000000..649d73f --- /dev/null +++ b/builtins/bind.def @@ -0,0 +1,345 @@ +This file is bind.def, from which is created bind.c. +It implements the builtin "bind" in Bash. + +Copyright (C) 1987-2015 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 3 of the License, 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. If not, see . + +$PRODUCES bind.c + +#include + +$BUILTIN bind +$DEPENDS_ON READLINE +$FUNCTION bind_builtin +$SHORT_DOC bind [-lpsvPSVX] [-m keymap] [-f filename] [-q name] [-u name] [-r keyseq] [-x keyseq:shell-command] [keyseq:readline-function or readline-command] +Set Readline key bindings and variables. + +Bind a key sequence to a Readline function or a macro, or set a +Readline variable. The non-option argument syntax is equivalent to +that found in ~/.inputrc, but must be passed as a single argument: +e.g., bind '"\C-x\C-r": re-read-init-file'. + +Options: + -m keymap Use KEYMAP as the keymap for the duration of this + command. Acceptable keymap names are emacs, + emacs-standard, emacs-meta, emacs-ctlx, vi, vi-move, + vi-command, and vi-insert. + -l List names of functions. + -P List function names and bindings. + -p List functions and bindings in a form that can be + reused as input. + -S List key sequences that invoke macros and their values + -s List key sequences that invoke macros and their values + in a form that can be reused as input. + -V List variable names and values + -v List variable names and values in a form that can + be reused as input. + -q function-name Query about which keys invoke the named function. + -u function-name Unbind all keys which are bound to the named function. + -r keyseq Remove the binding for KEYSEQ. + -f filename Read key bindings from FILENAME. + -x keyseq:shell-command Cause SHELL-COMMAND to be executed when + KEYSEQ is entered. + -X List key sequences bound with -x and associated commands + in a form that can be reused as input. + +Exit Status: +bind returns 0 unless an unrecognized option is given or an error occurs. +$END + +#if defined (READLINE) + +#if defined (HAVE_UNISTD_H) +# ifdef _MINIX +# include +# endif +# include +#endif + +#include +#include +#if !defined (errno) +extern int errno; +#endif /* !errno */ + +#include +#include + +#include "../bashintl.h" + +#include "../shell.h" +#include "../bashline.h" +#include "bashgetopt.h" +#include "common.h" + +static int query_bindings __P((char *)); +static int unbind_command __P((char *)); + +extern int no_line_editing; + +#define BIND_RETURN(x) do { return_code = x; goto bind_exit; } while (0) + +#define LFLAG 0x0001 +#define PFLAG 0x0002 +#define FFLAG 0x0004 +#define VFLAG 0x0008 +#define QFLAG 0x0010 +#define MFLAG 0x0020 +#define RFLAG 0x0040 +#define PPFLAG 0x0080 +#define VVFLAG 0x0100 +#define SFLAG 0x0200 +#define SSFLAG 0x0400 +#define UFLAG 0x0800 +#define XFLAG 0x1000 +#define XXFLAG 0x2000 + +int +bind_builtin (list) + WORD_LIST *list; +{ + int return_code; + Keymap kmap, saved_keymap; + int flags, opt; + char *initfile, *map_name, *fun_name, *unbind_name, *remove_seq, *cmd_seq, *t; + + if (no_line_editing) + { +#if 0 + builtin_error (_("line editing not enabled")); + return (EXECUTION_FAILURE); +#else + builtin_warning (_("line editing not enabled")); +#endif + } + + kmap = saved_keymap = (Keymap) NULL; + flags = 0; + initfile = map_name = fun_name = unbind_name = remove_seq = cmd_seq = (char *)NULL; + return_code = EXECUTION_SUCCESS; + + if (bash_readline_initialized == 0) + initialize_readline (); + + begin_unwind_frame ("bind_builtin"); + unwind_protect_var (rl_outstream); + + rl_outstream = stdout; + + reset_internal_getopt (); + while ((opt = internal_getopt (list, "lvpVPsSXf:q:u:m:r:x:")) != -1) + { + switch (opt) + { + case 'l': + flags |= LFLAG; + break; + case 'v': + flags |= VFLAG; + break; + case 'p': + flags |= PFLAG; + break; + case 'f': + flags |= FFLAG; + initfile = list_optarg; + break; + case 'm': + flags |= MFLAG; + map_name = list_optarg; + break; + case 'q': + flags |= QFLAG; + fun_name = list_optarg; + break; + case 'u': + flags |= UFLAG; + unbind_name = list_optarg; + break; + case 'r': + flags |= RFLAG; + remove_seq = list_optarg; + break; + case 'V': + flags |= VVFLAG; + break; + case 'P': + flags |= PPFLAG; + break; + case 's': + flags |= SFLAG; + break; + case 'S': + flags |= SSFLAG; + break; + case 'x': + flags |= XFLAG; + cmd_seq = list_optarg; + break; + case 'X': + flags |= XXFLAG; + break; + CASE_HELPOPT; + default: + builtin_usage (); + BIND_RETURN (EX_USAGE); + } + } + + list = loptend; + + /* First, see if we need to install a special keymap for this + command. Then start on the arguments. */ + + if ((flags & MFLAG) && map_name) + { + kmap = rl_get_keymap_by_name (map_name); + if (kmap == 0) + { + builtin_error (_("`%s': invalid keymap name"), map_name); + BIND_RETURN (EXECUTION_FAILURE); + } + } + + if (kmap) + { + saved_keymap = rl_get_keymap (); + rl_set_keymap (kmap); + } + + /* XXX - we need to add exclusive use tests here. It doesn't make sense + to use some of these options together. */ + /* Now hack the option arguments */ + if (flags & LFLAG) + rl_list_funmap_names (); + + if (flags & PFLAG) + rl_function_dumper (1); + + if (flags & PPFLAG) + rl_function_dumper (0); + + if (flags & SFLAG) + rl_macro_dumper (1); + + if (flags & SSFLAG) + rl_macro_dumper (0); + + if (flags & VFLAG) + rl_variable_dumper (1); + + if (flags & VVFLAG) + rl_variable_dumper (0); + + if ((flags & FFLAG) && initfile) + { + if (rl_read_init_file (initfile) != 0) + { + t = printable_filename (initfile, 0); + builtin_error (_("%s: cannot read: %s"), t, strerror (errno)); + if (t != initfile) + free (t); + BIND_RETURN (EXECUTION_FAILURE); + } + } + + if ((flags & QFLAG) && fun_name) + return_code = query_bindings (fun_name); + + if ((flags & UFLAG) && unbind_name) + return_code = unbind_command (unbind_name); + + if ((flags & RFLAG) && remove_seq) + { + if (rl_bind_keyseq (remove_seq, (rl_command_func_t *)NULL) != 0) + { + builtin_error (_("`%s': cannot unbind"), remove_seq); + BIND_RETURN (EXECUTION_FAILURE); + } + } + + if (flags & XFLAG) + return_code = bind_keyseq_to_unix_command (cmd_seq); + + if (flags & XXFLAG) + return_code = print_unix_command_map (); + + /* Process the rest of the arguments as binding specifications. */ + while (list) + { + rl_parse_and_bind (list->word->word); + list = list->next; + } + + bind_exit: + if (saved_keymap) + rl_set_keymap (saved_keymap); + + run_unwind_frame ("bind_builtin"); + + return (sh_chkwrite (return_code)); +} + +static int +query_bindings (name) + char *name; +{ + rl_command_func_t *function; + char **keyseqs; + int j; + + function = rl_named_function (name); + if (function == 0) + { + builtin_error (_("`%s': unknown function name"), name); + return EXECUTION_FAILURE; + } + + keyseqs = rl_invoking_keyseqs (function); + + if (!keyseqs) + { + printf (_("%s is not bound to any keys.\n"), name); + return EXECUTION_FAILURE; + } + + printf (_("%s can be invoked via "), name); + for (j = 0; j < 5 && keyseqs[j]; j++) + printf ("\"%s\"%s", keyseqs[j], keyseqs[j + 1] ? ", " : ".\n"); + if (keyseqs[j]) + printf ("...\n"); + strvec_dispose (keyseqs); + return EXECUTION_SUCCESS; +} + +static int +unbind_command (name) + char *name; +{ + rl_command_func_t *function; + + function = rl_named_function (name); + if (function == 0) + { + builtin_error (_("`%s': unknown function name"), name); + return EXECUTION_FAILURE; + } + + rl_unbind_function_in_map (function, rl_get_keymap ()); + return EXECUTION_SUCCESS; +} +#endif /* READLINE */ diff --git a/builtins/break.def b/builtins/break.def new file mode 100644 index 0000000..bdc1182 --- /dev/null +++ b/builtins/break.def @@ -0,0 +1,145 @@ +This file is break.def, from which is created break.c. +It implements the builtins "break" and "continue" in Bash. + +Copyright (C) 1987-2009 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 3 of the License, 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. If not, see . + +$PRODUCES break.c + +$BUILTIN break +$FUNCTION break_builtin +$SHORT_DOC break [n] +Exit for, while, or until loops. + +Exit a FOR, WHILE or UNTIL loop. If N is specified, break N enclosing +loops. + +Exit Status: +The exit status is 0 unless N is not greater than or equal to 1. +$END +#include + +#if defined (HAVE_UNISTD_H) +# ifdef _MINIX +# include +# endif +# include +#endif + +#include "../bashintl.h" + +#include "../shell.h" +#include "common.h" + +extern char *this_command_name; +extern int posixly_correct; + +static int check_loop_level __P((void)); + +/* The depth of while's and until's. */ +int loop_level = 0; + +/* Non-zero when a "break" instruction is encountered. */ +int breaking = 0; + +/* Non-zero when we have encountered a continue instruction. */ +int continuing = 0; + +/* Set up to break x levels, where x defaults to 1, but can be specified + as the first argument. */ +int +break_builtin (list) + WORD_LIST *list; +{ + intmax_t newbreak; + + CHECK_HELPOPT (list); + + if (check_loop_level () == 0) + return (EXECUTION_SUCCESS); + + (void)get_numeric_arg (list, 1, &newbreak); + + if (newbreak <= 0) + { + sh_erange (list->word->word, _("loop count")); + breaking = loop_level; + return (EXECUTION_FAILURE); + } + + if (newbreak > loop_level) + newbreak = loop_level; + + breaking = newbreak; + + return (EXECUTION_SUCCESS); +} + +$BUILTIN continue +$FUNCTION continue_builtin +$SHORT_DOC continue [n] +Resume for, while, or until loops. + +Resumes the next iteration of the enclosing FOR, WHILE or UNTIL loop. +If N is specified, resumes the Nth enclosing loop. + +Exit Status: +The exit status is 0 unless N is not greater than or equal to 1. +$END + +/* Set up to continue x levels, where x defaults to 1, but can be specified + as the first argument. */ +int +continue_builtin (list) + WORD_LIST *list; +{ + intmax_t newcont; + + CHECK_HELPOPT (list); + + if (check_loop_level () == 0) + return (EXECUTION_SUCCESS); + + (void)get_numeric_arg (list, 1, &newcont); + + if (newcont <= 0) + { + sh_erange (list->word->word, _("loop count")); + breaking = loop_level; + return (EXECUTION_FAILURE); + } + + if (newcont > loop_level) + newcont = loop_level; + + continuing = newcont; + + return (EXECUTION_SUCCESS); +} + +/* Return non-zero if a break or continue command would be okay. + Print an error message if break or continue is meaningless here. */ +static int +check_loop_level () +{ +#if defined (BREAK_COMPLAINS) + if (loop_level == 0 && posixly_correct == 0) + builtin_error (_("only meaningful in a `for', `while', or `until' loop")); +#endif /* BREAK_COMPLAINS */ + + return (loop_level); +} diff --git a/builtins/builtin.def b/builtins/builtin.def new file mode 100644 index 0000000..3e765e4 --- /dev/null +++ b/builtins/builtin.def @@ -0,0 +1,85 @@ +This file is builtin.def, from which is created builtin.c. +It implements the builtin "builtin" in Bash. + +Copyright (C) 1987-2009 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 3 of the License, 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. If not, see . + +$PRODUCES builtin.c + +$BUILTIN builtin +$FUNCTION builtin_builtin +$SHORT_DOC builtin [shell-builtin [arg ...]] +Execute shell builtins. + +Execute SHELL-BUILTIN with arguments ARGs without performing command +lookup. This is useful when you wish to reimplement a shell builtin +as a shell function, but need to execute the builtin within the function. + +Exit Status: +Returns the exit status of SHELL-BUILTIN, or false if SHELL-BUILTIN is +not a shell builtin.. +$END +#include + +#if defined (HAVE_UNISTD_H) +# ifdef _MINIX +# include +# endif +# include +#endif + +#include "../shell.h" +#include "common.h" +#include "bashgetopt.h" + +extern char *this_command_name; + +/* Run the command mentioned in list directly, without going through the + normal alias/function/builtin/filename lookup process. */ +int +builtin_builtin (list) + WORD_LIST *list; +{ + sh_builtin_func_t *function; + register char *command; + + if (no_options (list)) + return (EX_USAGE); + list = loptend; /* skip over possible `--' */ + + if (list == 0) + return (EXECUTION_SUCCESS); + + command = list->word->word; +#if defined (DISABLED_BUILTINS) + function = builtin_address (command); +#else /* !DISABLED_BUILTINS */ + function = find_shell_builtin (command); +#endif /* !DISABLED_BUILTINS */ + + if (!function) + { + sh_notbuiltin (command); + return (EXECUTION_FAILURE); + } + else + { + this_command_name = command; + list = list->next; + return ((*function) (list)); + } +} diff --git a/builtins/caller.def b/builtins/caller.def new file mode 100644 index 0000000..bf5eb96 --- /dev/null +++ b/builtins/caller.def @@ -0,0 +1,156 @@ +This file is caller.def, from which is created caller.c. It implements the +builtin "caller" in Bash. + +Copyright (C) 2002-2008 Rocky Bernstein for Free Software Foundation, Inc. +Copyright (C) 2008-2013 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 3 of the License, 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. If not, see . + +$PRODUCES caller.c + +$BUILTIN caller +$FUNCTION caller_builtin +$DEPENDS_ON DEBUGGER +$SHORT_DOC caller [expr] +Return the context of the current subroutine call. + +Without EXPR, returns "$line $filename". With EXPR, returns +"$line $subroutine $filename"; this extra information can be used to +provide a stack trace. + +The value of EXPR indicates how many call frames to go back before the +current one; the top frame is frame 0. + +Exit Status: +Returns 0 unless the shell is not executing a shell function or EXPR +is invalid. +$END + +#include +#include +#include "chartypes.h" +#include "bashtypes.h" + +#if defined (HAVE_UNISTD_H) +# ifdef _MINIX +# include +# endif +# include +#endif + +#include + +#include "../bashintl.h" + +#include "../shell.h" +#include "common.h" +#include "builtext.h" +#include "bashgetopt.h" + +#ifdef LOADABLE_BUILTIN +# include "builtins.h" +#endif + +#if !defined (errno) +extern int errno; +#endif /* !errno */ + +int +caller_builtin (list) + WORD_LIST *list; +{ +#if !defined (ARRAY_VARS) + printf ("1 NULL\n"); + return (EXECUTION_FAILURE); +#else + SHELL_VAR *funcname_v, *bash_source_v, *bash_lineno_v; + ARRAY *funcname_a, *bash_source_a, *bash_lineno_a; + char *funcname_s, *source_s, *lineno_s; + intmax_t num; + + CHECK_HELPOPT (list); + + GET_ARRAY_FROM_VAR ("FUNCNAME", funcname_v, funcname_a); + GET_ARRAY_FROM_VAR ("BASH_SOURCE", bash_source_v, bash_source_a); + GET_ARRAY_FROM_VAR ("BASH_LINENO", bash_lineno_v, bash_lineno_a); + + if (bash_lineno_a == 0 || array_empty (bash_lineno_a)) + return (EXECUTION_FAILURE); + + if (bash_source_a == 0 || array_empty (bash_source_a)) + return (EXECUTION_FAILURE); + + if (no_options (list)) + return (EX_USAGE); + list = loptend; /* skip over possible `--' */ + + /* If there is no argument list, then give short form: line filename. */ + if (list == 0) + { + lineno_s = array_reference (bash_lineno_a, 0); + source_s = array_reference (bash_source_a, 1); + printf("%s %s\n", lineno_s ? lineno_s : "NULL", source_s ? source_s : "NULL"); + return (EXECUTION_SUCCESS); + } + + if (funcname_a == 0 || array_empty (funcname_a)) + return (EXECUTION_FAILURE); + + if (legal_number (list->word->word, &num)) + { + lineno_s = array_reference (bash_lineno_a, num); + source_s = array_reference (bash_source_a, num+1); + funcname_s = array_reference (funcname_a, num+1); + + if (lineno_s == NULL|| source_s == NULL || funcname_s == NULL) + return (EXECUTION_FAILURE); + + printf("%s %s %s\n", lineno_s, funcname_s, source_s); + } + else + { + sh_invalidnum (list->word->word); + builtin_usage (); + return (EX_USAGE); + } + + return (EXECUTION_SUCCESS); +#endif +} + +#ifdef LOADABLE_BUILTIN +static char *caller_doc[] = { +N_("Returns the context of the current subroutine call.\n\ + \n\ + Without EXPR, returns "$line $filename". With EXPR, returns\n\ + "$line $subroutine $filename"; this extra information can be used to\n\ + provide a stack trace.\n\ + \n\ + The value of EXPR indicates how many call frames to go back before the\n\ + current one; the top frame is frame 0."), + (char *)NULL +}; + +struct builtin caller_struct = { + "caller", + caller_builtin, + BUILTIN_ENABLED, + caller_doc, + "caller [EXPR]", + 0 +}; + +#endif /* LOADABLE_BUILTIN */ diff --git a/builtins/cd.def b/builtins/cd.def new file mode 100644 index 0000000..421e819 --- /dev/null +++ b/builtins/cd.def @@ -0,0 +1,675 @@ +This file is cd.def, from which is created cd.c. It implements the +builtins "cd" and "pwd" in Bash. + +Copyright (C) 1987-2016 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 3 of the License, 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. If not, see . + +$PRODUCES cd.c +#include + +#if defined (HAVE_UNISTD_H) +# ifdef _MINIX +# include +# endif +# include +#endif + +#include "../bashtypes.h" +#include "posixdir.h" +#include "posixstat.h" +#if defined (HAVE_SYS_PARAM_H) +#include +#endif +#include + +#include + +#include "../bashansi.h" +#include "../bashintl.h" + +#include +#include + +#include "../shell.h" +#include "../flags.h" +#include "maxpath.h" +#include "common.h" +#include "bashgetopt.h" + +#if !defined (errno) +extern int errno; +#endif /* !errno */ + +extern int posixly_correct; +extern int array_needs_making; +extern const char * const bash_getcwd_errstr; + +static int bindpwd __P((int)); +static int setpwd __P((char *)); +static char *resetpwd __P((char *)); +static int change_to_directory __P((char *, int, int)); + +static int cdxattr __P((char *, char **)); +static void resetxattr __P((void)); + +/* Change this to 1 to get cd spelling correction by default. */ +int cdspelling = 0; + +int cdable_vars; + +static int eflag; /* file scope so bindpwd() can see it */ +static int xattrflag; /* O_XATTR support for openat */ +static int xattrfd = -1; + +$BUILTIN cd +$FUNCTION cd_builtin +$SHORT_DOC cd [-L|[-P [-e]] [-@]] [dir] +Change the shell working directory. + +Change the current directory to DIR. The default 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. 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, +the word is assumed to be a variable name. If that variable has a value, +its value is used for DIR. + +Options: + -L force symbolic links to be followed: resolve symbolic + links in DIR after processing instances of `..' + -P use the physical directory structure without following + symbolic links: resolve symbolic links in DIR before + processing instances of `..' + -e if the -P option is supplied, and the current working + directory cannot be determined successfully, exit with + a non-zero status +#if defined (O_XATTR) + -@ on systems that support it, present a file with extended + attributes as a directory containing the file attributes +#endif + +The default is to follow symbolic links, as if `-L' were specified. +`..' is processed by removing the immediately previous pathname component +back to a slash or the beginning of DIR. + +Exit Status: +Returns 0 if the directory is changed, and if $PWD is set successfully when +-P is used; non-zero otherwise. +$END + +/* Just set $PWD, don't change OLDPWD. Used by `pwd -P' in posix mode. */ +static int +setpwd (dirname) + char *dirname; +{ + int old_anm; + SHELL_VAR *tvar; + + old_anm = array_needs_making; + tvar = bind_variable ("PWD", dirname ? dirname : "", 0); + if (tvar && readonly_p (tvar)) + return EXECUTION_FAILURE; + if (tvar && old_anm == 0 && array_needs_making && exported_p (tvar)) + { + update_export_env_inplace ("PWD=", 4, dirname ? dirname : ""); + array_needs_making = 0; + } + return EXECUTION_SUCCESS; +} + +static int +bindpwd (no_symlinks) + int no_symlinks; +{ + char *dirname, *pwdvar; + int old_anm, r; + SHELL_VAR *tvar; + + r = sh_chkwrite (EXECUTION_SUCCESS); + +#define tcwd the_current_working_directory + dirname = tcwd ? (no_symlinks ? sh_physpath (tcwd, 0) : tcwd) + : get_working_directory ("cd"); +#undef tcwd + + old_anm = array_needs_making; + pwdvar = get_string_value ("PWD"); + + tvar = bind_variable ("OLDPWD", pwdvar, 0); + if (tvar && readonly_p (tvar)) + r = EXECUTION_FAILURE; + + if (old_anm == 0 && array_needs_making && exported_p (tvar)) + { + update_export_env_inplace ("OLDPWD=", 7, pwdvar); + array_needs_making = 0; + } + + if (setpwd (dirname) == EXECUTION_FAILURE) + r = EXECUTION_FAILURE; + if (dirname == 0 && eflag) + r = EXECUTION_FAILURE; + + if (dirname && dirname != the_current_working_directory) + free (dirname); + + return (r); +} + +/* Call get_working_directory to reset the value of + the_current_working_directory () */ +static char * +resetpwd (caller) + char *caller; +{ + char *tdir; + + FREE (the_current_working_directory); + the_current_working_directory = (char *)NULL; + tdir = get_working_directory (caller); + return (tdir); +} + +static int +cdxattr (dir, ndirp) + char *dir; /* don't assume we can always free DIR */ + char **ndirp; /* return new constructed directory name */ +{ +#if defined (O_XATTR) + int apfd, fd, r, e; + char buf[11+40+40]; /* construct new `fake' path for pwd */ + + apfd = openat (AT_FDCWD, dir, O_RDONLY|O_NONBLOCK); + if (apfd < 0) + return -1; + fd = openat (apfd, ".", O_XATTR); + e = errno; + close (apfd); /* ignore close error for now */ + errno = e; + if (fd < 0) + return -1; + r = fchdir (fd); /* assume fchdir exists everywhere with O_XATTR */ + if (r < 0) + { + close (fd); + return -1; + } + /* NFSv4 and ZFS extended attribute directories do not have names which are + visible in the standard Unix directory tree structure. To ensure we have + a valid name for $PWD, we synthesize one under /proc, but to keep that + path valid, we need to keep the file descriptor open as long as we are in + this directory. This imposes a certain structure on /proc. */ + if (ndirp) + { + sprintf (buf, "/proc/%d/fd/%d", getpid(), fd); + *ndirp = savestring (buf); + } + + if (xattrfd >= 0) + close (xattrfd); + xattrfd = fd; + + return r; +#else + return -1; +#endif +} + +/* Clean up the O_XATTR baggage. Currently only closes xattrfd */ +static void +resetxattr () +{ +#if defined (O_XATTR) + if (xattrfd >= 0) + { + close (xattrfd); + xattrfd = -1; + } +#else + xattrfd = -1; /* not strictly necessary */ +#endif +} + +#define LCD_DOVARS 0x001 +#define LCD_DOSPELL 0x002 +#define LCD_PRINTPATH 0x004 +#define LCD_FREEDIRNAME 0x008 + +/* This builtin is ultimately the way that all user-visible commands should + change the current working directory. It is called by cd_to_string (), + so the programming interface is simple, and it handles errors and + restrictions properly. */ +int +cd_builtin (list) + WORD_LIST *list; +{ + char *dirname, *cdpath, *path, *temp; + int path_index, no_symlinks, opt, lflag, e; + +#if defined (RESTRICTED_SHELL) + if (restricted) + { + sh_restricted ((char *)NULL); + return (EXECUTION_FAILURE); + } +#endif /* RESTRICTED_SHELL */ + + eflag = 0; + no_symlinks = no_symbolic_links; + xattrflag = 0; + reset_internal_getopt (); +#if defined (O_XATTR) + while ((opt = internal_getopt (list, "eLP@")) != -1) +#else + while ((opt = internal_getopt (list, "eLP")) != -1) +#endif + { + switch (opt) + { + case 'P': + no_symlinks = 1; + break; + case 'L': + no_symlinks = 0; + break; + case 'e': + eflag = 1; + break; +#if defined (O_XATTR) + case '@': + xattrflag = 1; + break; +#endif + CASE_HELPOPT; + default: + builtin_usage (); + return (EX_USAGE); + } + } + list = loptend; + + lflag = (cdable_vars ? LCD_DOVARS : 0) | + ((interactive && cdspelling) ? LCD_DOSPELL : 0); + if (eflag && no_symlinks == 0) + eflag = 0; + + if (list == 0) + { + /* `cd' without arguments is equivalent to `cd $HOME' */ + dirname = get_string_value ("HOME"); + + if (dirname == 0) + { + builtin_error (_("HOME not set")); + return (EXECUTION_FAILURE); + } + lflag = 0; + } +#if defined (CD_COMPLAINS) + else if (list->next) + { + builtin_error (_("too many arguments")); + return (EXECUTION_FAILURE); + } +#endif +#if 0 + else if (list->word->word[0] == '\0') + { + builtin_error (_("null directory")); + return (EXECUTION_FAILURE); + } +#endif + else if (list->word->word[0] == '-' && list->word->word[1] == '\0') + { + /* This is `cd -', equivalent to `cd $OLDPWD' */ + dirname = get_string_value ("OLDPWD"); + + if (dirname == 0) + { + builtin_error (_("OLDPWD not set")); + return (EXECUTION_FAILURE); + } +#if 0 + lflag = interactive ? LCD_PRINTPATH : 0; +#else + lflag = LCD_PRINTPATH; /* According to SUSv3 */ +#endif + } + else if (absolute_pathname (list->word->word)) + dirname = list->word->word; + else if (privileged_mode == 0 && (cdpath = get_string_value ("CDPATH"))) + { + dirname = list->word->word; + + /* Find directory in $CDPATH. */ + path_index = 0; + while (path = extract_colon_unit (cdpath, &path_index)) + { + /* OPT is 1 if the path element is non-empty */ + opt = path[0] != '\0'; + temp = sh_makepath (path, dirname, MP_DOTILDE); + free (path); + + if (change_to_directory (temp, no_symlinks, xattrflag)) + { + /* POSIX.2 says that if a nonempty directory from CDPATH + is used to find the directory to change to, the new + directory name is echoed to stdout, whether or not + the shell is interactive. */ + if (opt && (path = no_symlinks ? temp : the_current_working_directory)) + printf ("%s\n", path); + + free (temp); +#if 0 + /* Posix.2 says that after using CDPATH, the resultant + value of $PWD will not contain `.' or `..'. */ + return (bindpwd (posixly_correct || no_symlinks)); +#else + return (bindpwd (no_symlinks)); +#endif + } + else + free (temp); + } + +#if 0 + /* changed for bash-4.2 Posix cd description steps 5-6 */ + /* POSIX.2 says that if `.' does not appear in $CDPATH, we don't + try the current directory, so we just punt now with an error + message if POSIXLY_CORRECT is non-zero. The check for cdpath[0] + is so we don't mistakenly treat a CDPATH value of "" as not + specifying the current directory. */ + if (posixly_correct && cdpath[0]) + { + builtin_error ("%s: %s", dirname, strerror (ENOENT)); + return (EXECUTION_FAILURE); + } +#endif + } + else + dirname = list->word->word; + + /* When we get here, DIRNAME is the directory to change to. If we + chdir successfully, just return. */ + if (change_to_directory (dirname, no_symlinks, xattrflag)) + { + if (lflag & LCD_PRINTPATH) + printf ("%s\n", dirname); + return (bindpwd (no_symlinks)); + } + + /* If the user requests it, then perhaps this is the name of + a shell variable, whose value contains the directory to + change to. */ + if (lflag & LCD_DOVARS) + { + temp = get_string_value (dirname); + if (temp && change_to_directory (temp, no_symlinks, xattrflag)) + { + printf ("%s\n", temp); + return (bindpwd (no_symlinks)); + } + } + + /* If the user requests it, try to find a directory name similar in + spelling to the one requested, in case the user made a simple + typo. This is similar to the UNIX 8th and 9th Edition shells. */ + if (lflag & LCD_DOSPELL) + { + temp = dirspell (dirname); + if (temp && change_to_directory (temp, no_symlinks, xattrflag)) + { + printf ("%s\n", temp); + free (temp); + return (bindpwd (no_symlinks)); + } + else + FREE (temp); + } + + e = errno; + temp = printable_filename (dirname, 0); + builtin_error ("%s: %s", temp, strerror (e)); + if (temp != dirname) + free (temp); + return (EXECUTION_FAILURE); +} + +$BUILTIN pwd +$FUNCTION pwd_builtin +$SHORT_DOC pwd [-LP] +Print the name of the current working directory. + +Options: + -L print the value of $PWD if it names the current working + directory + -P print the physical directory, without any symbolic links + +By default, `pwd' behaves as if `-L' were specified. + +Exit Status: +Returns 0 unless an invalid option is given or the current directory +cannot be read. +$END + +/* Non-zero means that pwd always prints the physical directory, without + symbolic links. */ +static int verbatim_pwd; + +/* Print the name of the current working directory. */ +int +pwd_builtin (list) + WORD_LIST *list; +{ + char *directory; + int opt, pflag; + + verbatim_pwd = no_symbolic_links; + pflag = 0; + reset_internal_getopt (); + while ((opt = internal_getopt (list, "LP")) != -1) + { + switch (opt) + { + case 'P': + verbatim_pwd = pflag = 1; + break; + case 'L': + verbatim_pwd = 0; + break; + CASE_HELPOPT; + default: + builtin_usage (); + return (EX_USAGE); + } + } + list = loptend; + +#define tcwd the_current_working_directory + + directory = tcwd ? (verbatim_pwd ? sh_physpath (tcwd, 0) : tcwd) + : get_working_directory ("pwd"); + + /* Try again using getcwd() if canonicalization fails (for instance, if + the file system has changed state underneath bash). */ + if ((tcwd && directory == 0) || + (posixly_correct && same_file (".", tcwd, (struct stat *)0, (struct stat *)0) == 0)) + { + if (directory && directory != tcwd) + free (directory); + directory = resetpwd ("pwd"); + } + +#undef tcwd + + if (directory) + { + opt = EXECUTION_SUCCESS; + printf ("%s\n", directory); + /* This is dumb but posix-mandated. */ + if (posixly_correct && pflag) + opt = setpwd (directory); + if (directory != the_current_working_directory) + free (directory); + return (sh_chkwrite (opt)); + } + else + return (EXECUTION_FAILURE); +} + +/* Do the work of changing to the directory NEWDIR. Handle symbolic + link following, etc. This function *must* return with + the_current_working_directory either set to NULL (in which case + getcwd() will eventually be called), or set to a string corresponding + to the working directory. Return 1 on success, 0 on failure. */ + +static int +change_to_directory (newdir, nolinks, xattr) + char *newdir; + int nolinks, xattr; +{ + char *t, *tdir, *ndir; + int err, canon_failed, r, ndlen, dlen; + + tdir = (char *)NULL; + + if (the_current_working_directory == 0) + { + t = get_working_directory ("chdir"); + FREE (t); + } + + t = make_absolute (newdir, the_current_working_directory); + + /* TDIR is either the canonicalized absolute pathname of NEWDIR + (nolinks == 0) or the absolute physical pathname of NEWDIR + (nolinks != 0). */ + tdir = nolinks ? sh_physpath (t, 0) + : sh_canonpath (t, PATH_CHECKDOTDOT|PATH_CHECKEXISTS); + + ndlen = strlen (newdir); + dlen = strlen (t); + + /* Use the canonicalized version of NEWDIR, or, if canonicalization + failed, use the non-canonical form. */ + canon_failed = 0; + if (tdir && *tdir) + free (t); + else + { + FREE (tdir); + tdir = t; + canon_failed = 1; + } + + /* In POSIX mode, if we're resolving symlinks logically and sh_canonpath + returns NULL (because it checks the path, it will return NULL if the + resolved path doesn't exist), fail immediately. */ + if (posixly_correct && nolinks == 0 && canon_failed && (errno != ENAMETOOLONG || ndlen > PATH_MAX)) + { +#if defined ENAMETOOLONG + if (errno != ENOENT && errno != ENAMETOOLONG) +#else + if (errno != ENOENT) +#endif + errno = ENOTDIR; + free (tdir); + return (0); + } + +#if defined (O_XATTR) + if (xattrflag) + { + r = cdxattr (nolinks ? newdir : tdir, &ndir); + if (r >= 0) + { + canon_failed = 0; + free (tdir); + tdir = ndir; + } + else + { + err = errno; + free (tdir); + errno = err; + return (0); /* no xattr */ + } + } + else +#endif + { + r = chdir (nolinks ? newdir : tdir); + if (r >= 0) + resetxattr (); + } + + /* If the chdir succeeds, update the_current_working_directory. */ + if (r == 0) + { + /* If canonicalization failed, but the chdir succeeded, reset the + shell's idea of the_current_working_directory. */ + if (canon_failed) + { + t = resetpwd ("cd"); + if (t == 0) + set_working_directory (tdir); + else + free (t); + } + else + set_working_directory (tdir); + + free (tdir); + return (1); + } + + /* We failed to change to the appropriate directory name. If we tried + what the user passed (nolinks != 0), punt now. */ + if (nolinks) + { + free (tdir); + return (0); + } + + err = errno; + + /* We're not in physical mode (nolinks == 0), but we failed to change to + the canonicalized directory name (TDIR). Try what the user passed + verbatim. If we succeed, reinitialize the_current_working_directory. */ + if (chdir (newdir) == 0) + { + t = resetpwd ("cd"); + if (t == 0) + set_working_directory (tdir); + else + free (t); + + r = 1; + } + else + { + errno = err; + r = 0; + } + + free (tdir); + return r; +} diff --git a/builtins/colon.def b/builtins/colon.def new file mode 100644 index 0000000..4b78b30 --- /dev/null +++ b/builtins/colon.def @@ -0,0 +1,67 @@ +This file is colon.def, from which is created colon.c. +It implements the builtin ":" in Bash. + +Copyright (C) 1987-2009 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 3 of the License, 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. If not, see . + +$PRODUCES colon.c + +$BUILTIN : +$DOCNAME colon +$FUNCTION colon_builtin +$SHORT_DOC : +Null command. + +No effect; the command does nothing. + +Exit Status: +Always succeeds. +$END + +$BUILTIN true +$FUNCTION colon_builtin +$SHORT_DOC true +Return a successful result. + +Exit Status: +Always succeeds. +$END + +$BUILTIN false +$FUNCTION false_builtin +$SHORT_DOC false +Return an unsuccessful result. + +Exit Status: +Always fails. +$END + +/* Return a successful result. */ +int +colon_builtin (ignore) + char *ignore; +{ + return (0); +} + +/* Return an unsuccessful result. */ +int +false_builtin (ignore) + char *ignore; +{ + return (1); +} diff --git a/builtins/command.def b/builtins/command.def new file mode 100644 index 0000000..dcb510d --- /dev/null +++ b/builtins/command.def @@ -0,0 +1,163 @@ +This file is command.def, from which is created command.c. +It implements the builtin "command" in Bash. + +Copyright (C) 1987-2015 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 3 of the License, 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. If not, see . + +$PRODUCES command.c + +$BUILTIN command +$FUNCTION command_builtin +$SHORT_DOC command [-pVv] command [arg ...] +Execute a simple command or display information about commands. + +Runs COMMAND with ARGS suppressing shell function lookup, or display +information about the specified COMMANDs. Can be used to invoke commands +on disk when a function with the same name exists. + +Options: + -p use a default value for PATH that is guaranteed to find all of + the standard utilities + -v print a description of COMMAND similar to the `type' builtin + -V print a more verbose description of each COMMAND + +Exit Status: +Returns exit status of COMMAND, or failure if COMMAND is not found. +$END + +#include + +#if defined (HAVE_UNISTD_H) +# ifdef _MINIX +# include +# endif +# include +#endif + +#include "../bashansi.h" + +#include "../shell.h" +#include "../execute_cmd.h" +#include "../flags.h" +#include "bashgetopt.h" +#include "common.h" + +#if defined (_CS_PATH) && defined (HAVE_CONFSTR) && !HAVE_DECL_CONFSTR +extern size_t confstr __P((int, char *, size_t)); +#endif + +extern int subshell_environment; + +static void restore_path __P((char *)); + +/* Run the commands mentioned in LIST without paying attention to shell + functions. */ +int +command_builtin (list) + WORD_LIST *list; +{ + int result, verbose, use_standard_path, opt; + char *old_path, *standard_path; + COMMAND *command; + + verbose = use_standard_path = 0; + reset_internal_getopt (); + while ((opt = internal_getopt (list, "pvV")) != -1) + { + switch (opt) + { + case 'p': + use_standard_path = CDESC_STDPATH; + break; + case 'V': + verbose = CDESC_SHORTDESC|CDESC_ABSPATH; /* look in common.h for constants */ + break; + case 'v': + verbose = CDESC_REUSABLE; /* ditto */ + break; + CASE_HELPOPT; + default: + builtin_usage (); + return (EX_USAGE); + } + } + list = loptend; + + if (list == 0) + return (EXECUTION_SUCCESS); + +#if defined (RESTRICTED_SHELL) + if (use_standard_path && restricted) + { + sh_restricted ("-p"); + return (EXECUTION_FAILURE); + } +#endif + + if (verbose) + { + int found, any_found; + + for (any_found = 0; list; list = list->next) + { + found = describe_command (list->word->word, verbose|use_standard_path); + + if (found == 0 && verbose != CDESC_REUSABLE) + sh_notfound (list->word->word); + + any_found += found; + } + + return (any_found ? EXECUTION_SUCCESS : EXECUTION_FAILURE); + } + + begin_unwind_frame ("command_builtin"); + +#define COMMAND_BUILTIN_FLAGS (CMD_NO_FUNCTIONS | CMD_INHIBIT_EXPANSION | CMD_COMMAND_BUILTIN | (use_standard_path ? CMD_STDPATH : 0)) + + /* We don't want this to be reparsed (consider command echo 'foo &'), so + just make a simple_command structure and call execute_command with it. */ + command = make_bare_simple_command (); + command->value.Simple->words = (WORD_LIST *)copy_word_list (list); + command->value.Simple->redirects = (REDIRECT *)NULL; + command->flags |= COMMAND_BUILTIN_FLAGS; + command->value.Simple->flags |= COMMAND_BUILTIN_FLAGS; + + add_unwind_protect ((char *)dispose_command, command); + result = execute_command (command); + + run_unwind_frame ("command_builtin"); + + return (result); +} + +/* Restore the value of the $PATH variable after replacing it when + executing `command -p'. */ +static void +restore_path (var) + char *var; +{ + if (var) + { + bind_variable ("PATH", var, 0); + free (var); + } + else + unbind_variable ("PATH"); + + stupidly_hack_special_variables ("PATH"); +} diff --git a/builtins/common.c b/builtins/common.c new file mode 100644 index 0000000..b100ebe --- /dev/null +++ b/builtins/common.c @@ -0,0 +1,920 @@ +/* common.c - utility functions for all builtins */ + +/* Copyright (C) 1987-2016 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 3 of the License, 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. If not, see . +*/ + +#include + +#if defined (HAVE_UNISTD_H) +# ifdef _MINIX +# include +# endif +# include +#endif + +#include +#include +#include "../bashtypes.h" +#include "posixstat.h" +#include + +#include + +#if defined (PREFER_STDARG) +# include +#else +# include +#endif + +#include "../bashansi.h" +#include "../bashintl.h" + +#define NEED_FPURGE_DECL + +#include "../shell.h" +#include "maxpath.h" +#include "../flags.h" +#include "../jobs.h" +#include "../builtins.h" +#include "../input.h" +#include "../execute_cmd.h" +#include "../trap.h" +#include "bashgetopt.h" +#include "common.h" +#include "builtext.h" +#include + +#if defined (HISTORY) +# include "../bashhist.h" +#endif + +#if !defined (errno) +extern int errno; +#endif /* !errno */ + +extern int indirection_level, subshell_environment; +extern int line_number; +extern int last_command_exit_value; +extern int trap_saved_exit_value; +extern int running_trap; +extern int posixly_correct; +extern char *this_command_name, *shell_name; +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; +sh_builtin_func_t *this_shell_builtin = (sh_builtin_func_t *)NULL; + +/* **************************************************************** */ +/* */ +/* Error reporting, usage, and option processing */ +/* */ +/* **************************************************************** */ + +/* This is a lot like report_error (), but it is for shell builtins + instead of shell control structures, and it won't ever exit the + shell. */ + +static void +builtin_error_prolog () +{ + char *name; + + name = get_name_for_error (); + fprintf (stderr, "%s: ", name); + + if (interactive_shell == 0) + fprintf (stderr, _("line %d: "), executing_line_number ()); + + if (this_command_name && *this_command_name) + fprintf (stderr, "%s: ", this_command_name); +} + +void +#if defined (PREFER_STDARG) +builtin_error (const char *format, ...) +#else +builtin_error (format, va_alist) + const char *format; + va_dcl +#endif +{ + va_list args; + + builtin_error_prolog (); + + SH_VA_START (args, format); + + vfprintf (stderr, format, args); + va_end (args); + fprintf (stderr, "\n"); +} + +void +#if defined (PREFER_STDARG) +builtin_warning (const char *format, ...) +#else +builtin_warning (format, va_alist) + const char *format; + va_dcl +#endif +{ + va_list args; + + builtin_error_prolog (); + fprintf (stderr, _("warning: ")); + + SH_VA_START (args, format); + + vfprintf (stderr, format, args); + va_end (args); + fprintf (stderr, "\n"); +} + +/* Print a usage summary for the currently-executing builtin command. */ +void +builtin_usage () +{ + if (this_command_name && *this_command_name) + fprintf (stderr, _("%s: usage: "), this_command_name); + fprintf (stderr, "%s\n", _(current_builtin->short_doc)); + fflush (stderr); +} + +/* Return if LIST is NULL else barf and jump to top_level. Used by some + builtins that do not accept arguments. */ +void +no_args (list) + WORD_LIST *list; +{ + if (list) + { + builtin_error (_("too many arguments")); + top_level_cleanup (); + jump_to_top_level (DISCARD); + } +} + +/* Check that no options were given to the currently-executing builtin, + and return 0 if there were options. */ +int +no_options (list) + WORD_LIST *list; +{ + int opt; + + reset_internal_getopt (); + if ((opt = internal_getopt (list, "")) != -1) + { + if (opt == GETOPT_HELP) + { + builtin_help (); + return (2); + } + builtin_usage (); + return (1); + } + return (0); +} + +void +sh_needarg (s) + char *s; +{ + builtin_error (_("%s: option requires an argument"), s); +} + +void +sh_neednumarg (s) + char *s; +{ + builtin_error (_("%s: numeric argument required"), s); +} + +void +sh_notfound (s) + char *s; +{ + builtin_error (_("%s: not found"), s); +} + +/* Function called when one of the builtin commands detects an invalid + option. */ +void +sh_invalidopt (s) + char *s; +{ + builtin_error (_("%s: invalid option"), s); +} + +void +sh_invalidoptname (s) + char *s; +{ + builtin_error (_("%s: invalid option name"), s); +} + +void +sh_invalidid (s) + char *s; +{ + builtin_error (_("`%s': not a valid identifier"), s); +} + +void +sh_invalidnum (s) + char *s; +{ + char *msg; + + if (*s == '0' && isdigit ((unsigned char)s[1])) + msg = _("invalid octal number"); + else if (*s == '0' && s[1] == 'x') + msg = _("invalid hex number"); + else + msg = _("invalid number"); + builtin_error ("%s: %s", s, msg); +} + +void +sh_invalidsig (s) + char *s; +{ + builtin_error (_("%s: invalid signal specification"), s); +} + +void +sh_badpid (s) + char *s; +{ + builtin_error (_("`%s': not a pid or valid job spec"), s); +} + +void +sh_readonly (s) + const char *s; +{ + builtin_error (_("%s: readonly variable"), s); +} + +void +sh_erange (s, desc) + char *s, *desc; +{ + if (s) + builtin_error (_("%s: %s out of range"), s, desc ? desc : _("argument")); + else + builtin_error (_("%s out of range"), desc ? desc : _("argument")); +} + +#if defined (JOB_CONTROL) +void +sh_badjob (s) + char *s; +{ + builtin_error (_("%s: no such job"), s); +} + +void +sh_nojobs (s) + char *s; +{ + if (s) + builtin_error (_("%s: no job control"), s); + else + builtin_error (_("no job control")); +} +#endif + +#if defined (RESTRICTED_SHELL) +void +sh_restricted (s) + char *s; +{ + if (s) + builtin_error (_("%s: restricted"), s); + else + builtin_error (_("restricted")); +} +#endif + +void +sh_notbuiltin (s) + char *s; +{ + builtin_error (_("%s: not a shell builtin"), s); +} + +void +sh_wrerror () +{ +#if defined (DONT_REPORT_BROKEN_PIPE_WRITE_ERRORS) && defined (EPIPE) + if (errno != EPIPE) +#endif /* DONT_REPORT_BROKEN_PIPE_WRITE_ERRORS && EPIPE */ + builtin_error (_("write error: %s"), strerror (errno)); +} + +void +sh_ttyerror (set) + int set; +{ + if (set) + builtin_error (_("error setting terminal attributes: %s"), strerror (errno)); + else + builtin_error (_("error getting terminal attributes: %s"), strerror (errno)); +} + +int +sh_chkwrite (s) + int s; +{ + QUIT; + fflush (stdout); + QUIT; + if (ferror (stdout)) + { + sh_wrerror (); + fpurge (stdout); + clearerr (stdout); + return (EXECUTION_FAILURE); + } + return (s); +} + +/* **************************************************************** */ +/* */ +/* Shell positional parameter manipulation */ +/* */ +/* **************************************************************** */ + +/* Convert a WORD_LIST into a C-style argv. Return the number of elements + in the list in *IP, if IP is non-null. A convenience function for + loadable builtins; also used by `test'. */ +char ** +make_builtin_argv (list, ip) + WORD_LIST *list; + int *ip; +{ + char **argv; + + argv = strvec_from_word_list (list, 0, 1, ip); + argv[0] = this_command_name; + return argv; +} + +/* Remember LIST in $1 ... $9, and REST_OF_ARGS. If DESTRUCTIVE is + non-zero, then discard whatever the existing arguments are, else + only discard the ones that are to be replaced. */ +void +remember_args (list, destructive) + WORD_LIST *list; + int destructive; +{ + register int i; + + for (i = 1; i < 10; i++) + { + if ((destructive || list) && dollar_vars[i]) + { + free (dollar_vars[i]); + dollar_vars[i] = (char *)NULL; + } + + if (list) + { + dollar_vars[i] = savestring (list->word->word); + list = list->next; + } + } + + /* If arguments remain, assign them to REST_OF_ARGS. + Note that copy_word_list (NULL) returns NULL, and + that dispose_words (NULL) does nothing. */ + if (destructive || list) + { + dispose_words (rest_of_args); + rest_of_args = copy_word_list (list); + } + + if (destructive) + set_dollar_vars_changed (); + + invalidate_cached_quoted_dollar_at (); +} + +static int changed_dollar_vars; + +/* Have the dollar variables been reset to new values since we last + checked? */ +int +dollar_vars_changed () +{ + return (changed_dollar_vars); +} + +void +set_dollar_vars_unchanged () +{ + changed_dollar_vars = 0; +} + +void +set_dollar_vars_changed () +{ + if (variable_context) + changed_dollar_vars |= ARGS_FUNC; + else if (this_shell_builtin == set_builtin) + changed_dollar_vars |= ARGS_SETBLTIN; + else + changed_dollar_vars |= ARGS_INVOC; +} + +/* **************************************************************** */ +/* */ +/* Validating numeric input and arguments */ +/* */ +/* **************************************************************** */ + +/* Read a numeric arg for this_command_name, the name of the shell builtin + that wants it. LIST is the word list that the arg is to come from. + Accept only the numeric argument; report an error if other arguments + follow. If FATAL is 1, call throw_to_top_level, which exits the + shell; if it's 2, call jump_to_top_level (DISCARD), which aborts the + current command; if FATAL is 0, return an indication of an invalid + number by setting *NUMOK == 0 and return -1. */ +int +get_numeric_arg (list, fatal, count) + WORD_LIST *list; + int fatal; + intmax_t *count; +{ + char *arg; + + if (count) + *count = 1; + + if (list && list->word && ISOPTION (list->word->word, '-')) + list = list->next; + + if (list) + { + arg = list->word->word; + if (arg == 0 || (legal_number (arg, count) == 0)) + { + sh_neednumarg (list->word->word ? list->word->word : "`'"); + if (fatal == 0) + return 0; + else if (fatal == 1) /* fatal == 1; abort */ + throw_to_top_level (); + else /* fatal == 2; discard current command */ + { + top_level_cleanup (); + jump_to_top_level (DISCARD); + } + } + no_args (list->next); + } + + return (1); +} + +/* Get an eight-bit status value from LIST */ +int +get_exitstat (list) + WORD_LIST *list; +{ + int status; + intmax_t sval; + char *arg; + + if (list && list->word && ISOPTION (list->word->word, '-')) + list = list->next; + + if (list == 0) + { + /* If we're not running the DEBUG trap, the return builtin, when not + given any arguments, uses the value of $? before the trap ran. If + given an argument, return uses it. This means that the trap can't + change $?. The DEBUG trap gets to change $?, though, since that is + part of its reason for existing, and because the extended debug mode + does things with the return value. */ + if (this_shell_builtin == return_builtin && running_trap > 0 && running_trap != DEBUG_TRAP+1) + return (trap_saved_exit_value); + return (last_command_exit_value); + } + + arg = list->word->word; + if (arg == 0 || legal_number (arg, &sval) == 0) + { + sh_neednumarg (list->word->word ? list->word->word : "`'"); + return EX_BADUSAGE; + } + no_args (list->next); + + status = sval & 255; + return status; +} + +/* Return the octal number parsed from STRING, or -1 to indicate + that the string contained a bad number. */ +int +read_octal (string) + char *string; +{ + int result, digits; + + result = digits = 0; + while (*string && ISOCTAL (*string)) + { + digits++; + result = (result * 8) + (*string++ - '0'); + if (result > 0777) + return -1; + } + + if (digits == 0 || *string) + result = -1; + + return (result); +} + +/* **************************************************************** */ +/* */ +/* Manipulating the current working directory */ +/* */ +/* **************************************************************** */ + +/* Return a consed string which is the current working directory. + FOR_WHOM is the name of the caller for error printing. */ +char *the_current_working_directory = (char *)NULL; + +char * +get_working_directory (for_whom) + char *for_whom; +{ + if (no_symbolic_links) + { + FREE (the_current_working_directory); + the_current_working_directory = (char *)NULL; + } + + if (the_current_working_directory == 0) + { +#if defined (GETCWD_BROKEN) + the_current_working_directory = getcwd (0, PATH_MAX); +#else + the_current_working_directory = getcwd (0, 0); +#endif + if (the_current_working_directory == 0) + { + fprintf (stderr, _("%s: error retrieving current directory: %s: %s\n"), + (for_whom && *for_whom) ? for_whom : get_name_for_error (), + _(bash_getcwd_errstr), strerror (errno)); + return (char *)NULL; + } + } + + return (savestring (the_current_working_directory)); +} + +/* Make NAME our internal idea of the current working directory. */ +void +set_working_directory (name) + char *name; +{ + FREE (the_current_working_directory); + the_current_working_directory = savestring (name); +} + +/* **************************************************************** */ +/* */ +/* Job control support functions */ +/* */ +/* **************************************************************** */ + +#if defined (JOB_CONTROL) +int +get_job_by_name (name, flags) + const char *name; + int flags; +{ + register int i, wl, cl, match, job; + register PROCESS *p; + register JOB *j; + + job = NO_JOB; + wl = strlen (name); + for (i = js.j_jobslots - 1; i >= 0; i--) + { + j = get_job_by_jid (i); + if (j == 0 || ((flags & JM_STOPPED) && J_JOBSTATE(j) != JSTOPPED)) + continue; + + p = j->pipe; + do + { + if (flags & JM_EXACT) + { + cl = strlen (p->command); + match = STREQN (p->command, name, cl); + } + else if (flags & JM_SUBSTRING) + match = strcasestr (p->command, name) != (char *)0; + else + match = STREQN (p->command, name, wl); + + if (match == 0) + { + p = p->next; + continue; + } + else if (flags & JM_FIRSTMATCH) + return i; /* return first match */ + else if (job != NO_JOB) + { + if (this_shell_builtin) + builtin_error (_("%s: ambiguous job spec"), name); + else + internal_error (_("%s: ambiguous job spec"), name); + return (DUP_JOB); + } + else + job = i; + } + while (p != j->pipe); + } + + return (job); +} + +/* Return the job spec found in LIST. */ +int +get_job_spec (list) + WORD_LIST *list; +{ + register char *word; + int job, jflags; + + if (list == 0) + return (js.j_current); + + word = list->word->word; + + if (*word == '\0') + return (NO_JOB); + + if (*word == '%') + word++; + + if (DIGIT (*word) && all_digits (word)) + { + job = atoi (word); + return (job > js.j_jobslots ? NO_JOB : job - 1); + } + + jflags = 0; + switch (*word) + { + case 0: + case '%': + case '+': + return (js.j_current); + + case '-': + return (js.j_previous); + + case '?': /* Substring search requested. */ + jflags |= JM_SUBSTRING; + word++; + /* FALLTHROUGH */ + + default: + return get_job_by_name (word, jflags); + } +} +#endif /* JOB_CONTROL */ + +/* + * NOTE: `kill' calls this function with forcecols == 0 + */ +int +display_signal_list (list, forcecols) + WORD_LIST *list; + int forcecols; +{ + register int i, column; + char *name; + int result, signum, dflags; + intmax_t lsignum; + + result = EXECUTION_SUCCESS; + if (!list) + { + for (i = 1, column = 0; i < NSIG; i++) + { + name = signal_name (i); + if (STREQN (name, "SIGJUNK", 7) || STREQN (name, "Unknown", 7)) + continue; + + if (posixly_correct && !forcecols) + { + /* This is for the kill builtin. POSIX.2 says the signal names + are displayed without the `SIG' prefix. */ + if (STREQN (name, "SIG", 3)) + name += 3; + printf ("%s%s", name, (i == NSIG - 1) ? "" : " "); + } + else + { + printf ("%2d) %s", i, name); + + if (++column < 5) + printf ("\t"); + else + { + printf ("\n"); + column = 0; + } + } + } + + if ((posixly_correct && !forcecols) || column != 0) + printf ("\n"); + return result; + } + + /* List individual signal names or numbers. */ + while (list) + { + if (legal_number (list->word->word, &lsignum)) + { + /* This is specified by Posix.2 so that exit statuses can be + mapped into signal numbers. */ + if (lsignum > 128) + lsignum -= 128; + if (lsignum < 0 || lsignum >= NSIG) + { + sh_invalidsig (list->word->word); + result = EXECUTION_FAILURE; + list = list->next; + continue; + } + + signum = lsignum; + name = signal_name (signum); + if (STREQN (name, "SIGJUNK", 7) || STREQN (name, "Unknown", 7)) + { + list = list->next; + continue; + } +#if defined (JOB_CONTROL) + /* POSIX.2 says that `kill -l signum' prints the signal name without + the `SIG' prefix. */ + printf ("%s\n", (this_shell_builtin == kill_builtin) ? name + 3 : name); +#else + printf ("%s\n", name); +#endif + } + else + { + dflags = DSIG_NOCASE; + if (posixly_correct == 0 || this_shell_builtin != kill_builtin) + dflags |= DSIG_SIGPREFIX; + signum = decode_signal (list->word->word, dflags); + if (signum == NO_SIG) + { + sh_invalidsig (list->word->word); + result = EXECUTION_FAILURE; + list = list->next; + continue; + } + printf ("%d\n", signum); + } + list = list->next; + } + return (result); +} + +/* **************************************************************** */ +/* */ +/* Finding builtin commands and their functions */ +/* */ +/* **************************************************************** */ + +/* Perform a binary search and return the address of the builtin function + whose name is NAME. If the function couldn't be found, or the builtin + is disabled or has no function associated with it, return NULL. + Return the address of the builtin. + DISABLED_OKAY means find it even if the builtin is disabled. */ +struct builtin * +builtin_address_internal (name, disabled_okay) + char *name; + int disabled_okay; +{ + int hi, lo, mid, j; + + hi = num_shell_builtins - 1; + lo = 0; + + while (lo <= hi) + { + mid = (lo + hi) / 2; + + j = shell_builtins[mid].name[0] - name[0]; + + if (j == 0) + j = strcmp (shell_builtins[mid].name, name); + + if (j == 0) + { + /* It must have a function pointer. It must be enabled, or we + must have explicitly allowed disabled functions to be found, + and it must not have been deleted. */ + if (shell_builtins[mid].function && + ((shell_builtins[mid].flags & BUILTIN_DELETED) == 0) && + ((shell_builtins[mid].flags & BUILTIN_ENABLED) || disabled_okay)) + return (&shell_builtins[mid]); + else + return ((struct builtin *)NULL); + } + if (j > 0) + hi = mid - 1; + else + lo = mid + 1; + } + return ((struct builtin *)NULL); +} + +/* Return the pointer to the function implementing builtin command NAME. */ +sh_builtin_func_t * +find_shell_builtin (name) + char *name; +{ + current_builtin = builtin_address_internal (name, 0); + return (current_builtin ? current_builtin->function : (sh_builtin_func_t *)NULL); +} + +/* Return the address of builtin with NAME, whether it is enabled or not. */ +sh_builtin_func_t * +builtin_address (name) + char *name; +{ + current_builtin = builtin_address_internal (name, 1); + return (current_builtin ? current_builtin->function : (sh_builtin_func_t *)NULL); +} + +/* Return the function implementing the builtin NAME, but only if it is a + POSIX.2 special builtin. */ +sh_builtin_func_t * +find_special_builtin (name) + char *name; +{ + current_builtin = builtin_address_internal (name, 0); + return ((current_builtin && (current_builtin->flags & SPECIAL_BUILTIN)) ? + current_builtin->function : + (sh_builtin_func_t *)NULL); +} + +static int +shell_builtin_compare (sbp1, sbp2) + struct builtin *sbp1, *sbp2; +{ + int result; + + if ((result = sbp1->name[0] - sbp2->name[0]) == 0) + result = strcmp (sbp1->name, sbp2->name); + + return (result); +} + +/* Sort the table of shell builtins so that the binary search will work + in find_shell_builtin. */ +void +initialize_shell_builtins () +{ + qsort (shell_builtins, num_shell_builtins, sizeof (struct builtin), + (QSFUNC *)shell_builtin_compare); +} + +#if !defined (HELP_BUILTIN) +void +builtin_help () +{ + printf ("%s: %s\n", this_command_name, _("help not available in this version")); +} +#endif diff --git a/builtins/common.h b/builtins/common.h new file mode 100644 index 0000000..ed85230 --- /dev/null +++ b/builtins/common.h @@ -0,0 +1,214 @@ +/* common.h -- extern declarations for functions defined in common.c. */ + +/* Copyright (C) 1993-2015 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 3 of the License, 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. If not, see . +*/ + +#if !defined (__COMMON_H) +# define __COMMON_H + +#include "stdc.h" + +#define ISOPTION(s, c) (s[0] == '-' && !s[2] && s[1] == c) +#define ISHELP(s) (STREQ ((s), "--help")) + +#define CHECK_HELPOPT(l) \ +do { \ + if ((l) && (l)->word && ISHELP((l)->word->word)) \ + { \ + builtin_help (); \ + return (EX_USAGE); \ + } \ +} while (0) + +#define CASE_HELPOPT \ + case GETOPT_HELP: \ + builtin_help (); \ + return (EX_USAGE) + +/* Flag values for parse_and_execute () */ +#define SEVAL_NONINT 0x001 +#define SEVAL_INTERACT 0x002 +#define SEVAL_NOHIST 0x004 +#define SEVAL_NOFREE 0x008 +#define SEVAL_RESETLINE 0x010 +#define SEVAL_PARSEONLY 0x020 +#define SEVAL_NOLONGJMP 0x040 +#define SEVAL_FUNCDEF 0x080 /* only allow function definitions */ +#define SEVAL_ONECMD 0x100 /* only allow a single command */ +#define SEVAL_NOHISTEXP 0x200 /* inhibit history expansion */ + +/* Flags for describe_command, shared between type.def and command.def */ +#define CDESC_ALL 0x001 /* type -a */ +#define CDESC_SHORTDESC 0x002 /* command -V */ +#define CDESC_REUSABLE 0x004 /* command -v */ +#define CDESC_TYPE 0x008 /* type -t */ +#define CDESC_PATH_ONLY 0x010 /* type -p */ +#define CDESC_FORCE_PATH 0x020 /* type -ap or type -P */ +#define CDESC_NOFUNCS 0x040 /* type -f */ +#define CDESC_ABSPATH 0x080 /* convert to absolute path, no ./ */ +#define CDESC_STDPATH 0x100 /* command -p */ + +/* Flags for get_job_by_name */ +#define JM_PREFIX 0x01 /* prefix of job name */ +#define JM_SUBSTRING 0x02 /* substring of job name */ +#define JM_EXACT 0x04 /* match job name exactly */ +#define JM_STOPPED 0x08 /* match stopped jobs only */ +#define JM_FIRSTMATCH 0x10 /* return first matching job */ + +/* Flags for remember_args and value of changed_dollar_vars */ +#define ARGS_NONE 0x0 +#define ARGS_INVOC 0x01 +#define ARGS_FUNC 0x02 +#define ARGS_SETBLTIN 0x04 + +/* Maximum number of attribute letters */ +#define MAX_ATTRIBUTES 16 + +/* Functions from common.c */ +extern void builtin_error __P((const char *, ...)) __attribute__((__format__ (printf, 1, 2))); +extern void builtin_warning __P((const char *, ...)) __attribute__((__format__ (printf, 1, 2))); +extern void builtin_usage __P((void)); +extern void no_args __P((WORD_LIST *)); +extern int no_options __P((WORD_LIST *)); + +/* common error message functions */ +extern void sh_needarg __P((char *)); +extern void sh_neednumarg __P((char *)); +extern void sh_notfound __P((char *)); +extern void sh_invalidopt __P((char *)); +extern void sh_invalidoptname __P((char *)); +extern void sh_invalidid __P((char *)); +extern void sh_invalidnum __P((char *)); +extern void sh_invalidsig __P((char *)); +extern void sh_erange __P((char *, char *)); +extern void sh_badpid __P((char *)); +extern void sh_badjob __P((char *)); +extern void sh_readonly __P((const char *)); +extern void sh_nojobs __P((char *)); +extern void sh_restricted __P((char *)); +extern void sh_notbuiltin __P((char *)); +extern void sh_wrerror __P((void)); +extern void sh_ttyerror __P((int)); +extern int sh_chkwrite __P((int)); + +extern char **make_builtin_argv __P((WORD_LIST *, int *)); +extern void remember_args __P((WORD_LIST *, int)); + +extern int dollar_vars_changed __P((void)); +extern void set_dollar_vars_unchanged __P((void)); +extern void set_dollar_vars_changed __P((void)); + +extern int get_numeric_arg __P((WORD_LIST *, int, intmax_t *)); +extern int get_exitstat __P((WORD_LIST *)); +extern int read_octal __P((char *)); + +/* Keeps track of the current working directory. */ +extern char *the_current_working_directory; +extern char *get_working_directory __P((char *)); +extern void set_working_directory __P((char *)); + +#if defined (JOB_CONTROL) +extern int get_job_by_name __P((const char *, int)); +extern int get_job_spec __P((WORD_LIST *)); +#endif +extern int display_signal_list __P((WORD_LIST *, int)); + +/* It's OK to declare a function as returning a Function * without + providing a definition of what a `Function' is. */ +extern struct builtin *builtin_address_internal __P((char *, int)); +extern sh_builtin_func_t *find_shell_builtin __P((char *)); +extern sh_builtin_func_t *builtin_address __P((char *)); +extern sh_builtin_func_t *find_special_builtin __P((char *)); +extern void initialize_shell_builtins __P((void)); + +/* Functions from exit.def */ +extern void bash_logout __P((void)); + +/* Functions from getopts.def */ +extern void getopts_reset __P((int)); + +/* Functions from help.def */ +extern void builtin_help __P((void)); + +/* Functions from read.def */ +extern void read_tty_cleanup __P((void)); +extern int read_tty_modified __P((void)); + +/* Functions from set.def */ +extern int minus_o_option_value __P((char *)); +extern void list_minus_o_opts __P((int, int)); +extern char **get_minus_o_opts __P((void)); +extern int set_minus_o_option __P((int, char *)); + +extern void set_shellopts __P((void)); +extern void parse_shellopts __P((char *)); +extern void initialize_shell_options __P((int)); + +extern void reset_shell_options __P((void)); + +extern char *get_current_options __P((void)); +extern void set_current_options __P((const char *)); + +/* Functions from shopt.def */ +extern void reset_shopt_options __P((void)); +extern char **get_shopt_options __P((void)); + +extern int shopt_setopt __P((char *, int)); +extern int shopt_listopt __P((char *, int)); + +extern int set_login_shell __P((char *, int)); + +extern void set_bashopts __P((void)); +extern void parse_bashopts __P((char *)); +extern void initialize_bashopts __P((int)); + +extern void set_compatibility_opts __P((void)); + +/* Functions from type.def */ +extern int describe_command __P((char *, int)); + +/* Functions from setattr.def */ +extern int set_or_show_attributes __P((WORD_LIST *, int, int)); +extern int show_all_var_attributes __P((int, int)); +extern int show_var_attributes __P((SHELL_VAR *, int, int)); +extern int show_name_attributes __P((char *, int)); +extern int show_func_attributes __P((char *, int)); +extern void set_var_attribute __P((char *, int, int)); +extern int var_attribute_string __P((SHELL_VAR *, int, char *)); + +/* Functions from pushd.def */ +extern char *get_dirstack_from_string __P((char *)); +extern char *get_dirstack_element __P((intmax_t, int)); +extern void set_dirstack_element __P((intmax_t, int, char *)); +extern WORD_LIST *get_directory_stack __P((int)); + +/* Functions from evalstring.c */ +extern int parse_and_execute __P((char *, const char *, int)); +extern int evalstring __P((char *, const char *, int)); +extern void parse_and_execute_cleanup __P((void)); +extern int parse_string __P((char *, const char *, int, char **)); +extern int should_suppress_fork __P((COMMAND *)); +extern void optimize_fork __P((COMMAND *)); + +/* Functions from evalfile.c */ +extern int maybe_execute_file __P((const char *, int)); +extern int force_execute_file __P((const char *, int)); +extern int source_file __P((const char *, int)); +extern int fc_execute_file __P((const char *)); + +#endif /* !__COMMON_H */ diff --git a/builtins/complete.def b/builtins/complete.def new file mode 100644 index 0000000..6bdf88b --- /dev/null +++ b/builtins/complete.def @@ -0,0 +1,877 @@ +This file is complete.def, from which is created complete.c. +It implements the builtins "complete", "compgen", and "compopt" in Bash. + +Copyright (C) 1999-2015 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 3 of the License, 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. If not, see . + +$PRODUCES complete.c + +$BUILTIN complete +$DEPENDS_ON PROGRAMMABLE_COMPLETION +$FUNCTION complete_builtin +$SHORT_DOC complete [-abcdefgjksuv] [-pr] [-DE] [-o option] [-A action] [-G globpat] [-W wordlist] [-F function] [-C command] [-X filterpat] [-P prefix] [-S suffix] [name ...] +Specify how arguments are to be completed by Readline. + +For each NAME, specify how arguments are to be completed. If no options +are supplied, existing completion specifications are printed in a way that +allows them to be reused as input. + +Options: + -p print existing completion specifications in a reusable format + -r remove a completion specification for each NAME, or, if no + NAMEs are supplied, all completion specifications + -D apply the completions and actions as the default for commands + without any specific completion defined + -E apply the completions and actions to "empty" commands -- + completion attempted on a blank line + +When completion is attempted, the actions are applied in the order the +uppercase-letter options are listed above. The -D option takes +precedence over -E. + +Exit Status: +Returns success unless an invalid option is supplied or an error occurs. +$END + +#include + +#include + +#include "../bashtypes.h" + +#if defined (HAVE_UNISTD_H) +# include +#endif + +#include "../bashansi.h" +#include "../bashintl.h" + +#include "../shell.h" +#include "../builtins.h" +#include "../pcomplete.h" +#include "../bashline.h" + +#include "common.h" +#include "bashgetopt.h" + +#include + +#define STRDUP(x) ((x) ? savestring (x) : (char *)NULL) + +/* Structure containing all the non-action (binary) options; filled in by + build_actions(). */ +struct _optflags { + int pflag; + int rflag; + int Dflag; + int Eflag; +}; + +static int find_compact __P((char *)); +static int find_compopt __P((char *)); + +static int build_actions __P((WORD_LIST *, struct _optflags *, unsigned long *, unsigned long *)); + +static int remove_cmd_completions __P((WORD_LIST *)); + +static int print_one_completion __P((char *, COMPSPEC *)); +static int print_compitem __P((BUCKET_CONTENTS *)); +static void print_compopts __P((const char *, COMPSPEC *, int)); +static void print_all_completions __P((void)); +static int print_cmd_completions __P((WORD_LIST *)); + +static char *Garg, *Warg, *Parg, *Sarg, *Xarg, *Farg, *Carg; + +static const struct _compacts { + const char * const actname; + int actflag; + int actopt; +} compacts[] = { + { "alias", CA_ALIAS, 'a' }, + { "arrayvar", CA_ARRAYVAR, 0 }, + { "binding", CA_BINDING, 0 }, + { "builtin", CA_BUILTIN, 'b' }, + { "command", CA_COMMAND, 'c' }, + { "directory", CA_DIRECTORY, 'd' }, + { "disabled", CA_DISABLED, 0 }, + { "enabled", CA_ENABLED, 0 }, + { "export", CA_EXPORT, 'e' }, + { "file", CA_FILE, 'f' }, + { "function", CA_FUNCTION, 0 }, + { "helptopic", CA_HELPTOPIC, 0 }, + { "hostname", CA_HOSTNAME, 0 }, + { "group", CA_GROUP, 'g' }, + { "job", CA_JOB, 'j' }, + { "keyword", CA_KEYWORD, 'k' }, + { "running", CA_RUNNING, 0 }, + { "service", CA_SERVICE, 's' }, + { "setopt", CA_SETOPT, 0 }, + { "shopt", CA_SHOPT, 0 }, + { "signal", CA_SIGNAL, 0 }, + { "stopped", CA_STOPPED, 0 }, + { "user", CA_USER, 'u' }, + { "variable", CA_VARIABLE, 'v' }, + { (char *)NULL, 0, 0 }, +}; + +/* This should be a STRING_INT_ALIST */ +static const struct _compopt { + const char * const optname; + int optflag; +} compopts[] = { + { "bashdefault", COPT_BASHDEFAULT }, + { "default", COPT_DEFAULT }, + { "dirnames", COPT_DIRNAMES }, + { "filenames",COPT_FILENAMES}, + { "noquote", COPT_NOQUOTE }, + { "nosort", COPT_NOSORT }, + { "nospace", COPT_NOSPACE }, + { "plusdirs", COPT_PLUSDIRS }, + { (char *)NULL, 0 }, +}; + +static int +find_compact (name) + char *name; +{ + register int i; + + for (i = 0; compacts[i].actname; i++) + if (STREQ (name, compacts[i].actname)) + return i; + return -1; +} + +static int +find_compopt (name) + char *name; +{ + register int i; + + for (i = 0; compopts[i].optname; i++) + if (STREQ (name, compopts[i].optname)) + return i; + return -1; +} + +/* Build the actions and compspec options from the options specified in LIST. + ACTP is a pointer to an unsigned long in which to place the bitmap of + actions. OPTP is a pointer to an unsigned long in which to place the + bitmap of compspec options (arguments to `-o'). PP, if non-null, gets 1 + if -p is supplied; RP, if non-null, gets 1 if -r is supplied. + If either is null, the corresponding option generates an error. + This also sets variables corresponding to options that take arguments as + a side effect; the caller should ensure that those variables are set to + NULL before calling build_actions. Return value: + EX_USAGE = bad option + EXECUTION_SUCCESS = some options supplied + EXECUTION_FAILURE = no options supplied +*/ + +static int +build_actions (list, flagp, actp, optp) + WORD_LIST *list; + struct _optflags *flagp; + unsigned long *actp, *optp; +{ + int opt, ind, opt_given; + unsigned long acts, copts; + + acts = copts = (unsigned long)0L; + opt_given = 0; + + reset_internal_getopt (); + while ((opt = internal_getopt (list, "abcdefgjko:prsuvA:G:W:P:S:X:F:C:DE")) != -1) + { + opt_given = 1; + switch (opt) + { + case 'r': + if (flagp) + { + flagp->rflag = 1; + break; + } + else + { + sh_invalidopt ("-r"); + builtin_usage (); + return (EX_USAGE); + } + + case 'p': + if (flagp) + { + flagp->pflag = 1; + break; + } + else + { + sh_invalidopt ("-p"); + builtin_usage (); + return (EX_USAGE); + } + + case 'a': + acts |= CA_ALIAS; + break; + case 'b': + acts |= CA_BUILTIN; + break; + case 'c': + acts |= CA_COMMAND; + break; + case 'd': + acts |= CA_DIRECTORY; + break; + case 'e': + acts |= CA_EXPORT; + break; + case 'f': + acts |= CA_FILE; + break; + case 'g': + acts |= CA_GROUP; + break; + case 'j': + acts |= CA_JOB; + break; + case 'k': + acts |= CA_KEYWORD; + break; + case 's': + acts |= CA_SERVICE; + break; + case 'u': + acts |= CA_USER; + break; + case 'v': + acts |= CA_VARIABLE; + break; + case 'o': + ind = find_compopt (list_optarg); + if (ind < 0) + { + sh_invalidoptname (list_optarg); + return (EX_USAGE); + } + copts |= compopts[ind].optflag; + break; + case 'A': + ind = find_compact (list_optarg); + if (ind < 0) + { + builtin_error (_("%s: invalid action name"), list_optarg); + return (EX_USAGE); + } + acts |= compacts[ind].actflag; + break; + case 'C': + Carg = list_optarg; + break; + case 'D': + if (flagp) + { + flagp->Dflag = 1; + break; + } + else + { + sh_invalidopt ("-D"); + builtin_usage (); + return (EX_USAGE); + } + case 'E': + if (flagp) + { + flagp->Eflag = 1; + break; + } + else + { + sh_invalidopt ("-E"); + builtin_usage (); + return (EX_USAGE); + } + case 'F': + Farg = list_optarg; + break; + case 'G': + Garg = list_optarg; + break; + case 'P': + Parg = list_optarg; + break; + case 'S': + Sarg = list_optarg; + break; + case 'W': + Warg = list_optarg; + break; + case 'X': + Xarg = list_optarg; + break; + CASE_HELPOPT; + default: + builtin_usage (); + return (EX_USAGE); + } + } + + *actp = acts; + *optp = copts; + + return (opt_given ? EXECUTION_SUCCESS : EXECUTION_FAILURE); +} + +/* Add, remove, and display completion specifiers. */ +int +complete_builtin (list) + WORD_LIST *list; +{ + int opt_given, rval; + unsigned long acts, copts; + COMPSPEC *cs; + struct _optflags oflags; + WORD_LIST *l, *wl; + + if (list == 0) + { + print_all_completions (); + return (EXECUTION_SUCCESS); + } + + opt_given = oflags.pflag = oflags.rflag = oflags.Dflag = oflags.Eflag = 0; + + acts = copts = (unsigned long)0L; + Garg = Warg = Parg = Sarg = Xarg = Farg = Carg = (char *)NULL; + cs = (COMPSPEC *)NULL; + + /* Build the actions from the arguments. Also sets the [A-Z]arg variables + as a side effect if they are supplied as options. */ + rval = build_actions (list, &oflags, &acts, &copts); + if (rval == EX_USAGE) + return (rval); + opt_given = rval != EXECUTION_FAILURE; + + list = loptend; + + wl = oflags.Dflag ? make_word_list (make_bare_word (DEFAULTCMD), (WORD_LIST *)NULL) + : (oflags.Eflag ? make_word_list (make_bare_word (EMPTYCMD), (WORD_LIST *)NULL) : 0); + + /* -p overrides everything else */ + if (oflags.pflag || (list == 0 && opt_given == 0)) + { + if (wl) + { + rval = print_cmd_completions (wl); + dispose_words (wl); + return rval; + } + else if (list == 0) + { + print_all_completions (); + return (EXECUTION_SUCCESS); + } + return (print_cmd_completions (list)); + } + + /* next, -r overrides everything else. */ + if (oflags.rflag) + { + if (wl) + { + rval = remove_cmd_completions (wl); + dispose_words (wl); + return rval; + } + else if (list == 0) + { + progcomp_flush (); + return (EXECUTION_SUCCESS); + } + return (remove_cmd_completions (list)); + } + + if (wl == 0 && list == 0 && opt_given) + { + builtin_usage (); + return (EX_USAGE); + } + + /* If we get here, we need to build a compspec and add it for each + remaining argument. */ + cs = compspec_create (); + cs->actions = acts; + cs->options = copts; + + cs->globpat = STRDUP (Garg); + cs->words = STRDUP (Warg); + cs->prefix = STRDUP (Parg); + cs->suffix = STRDUP (Sarg); + cs->funcname = STRDUP (Farg); + cs->command = STRDUP (Carg); + cs->filterpat = STRDUP (Xarg); + + for (rval = EXECUTION_SUCCESS, l = wl ? wl : list ; l; l = l->next) + { + /* Add CS as the compspec for the specified commands. */ + if (progcomp_insert (l->word->word, cs) == 0) + rval = EXECUTION_FAILURE; + } + + dispose_words (wl); + return (rval); +} + +static int +remove_cmd_completions (list) + WORD_LIST *list; +{ + WORD_LIST *l; + int ret; + + for (ret = EXECUTION_SUCCESS, l = list; l; l = l->next) + { + if (progcomp_remove (l->word->word) == 0) + { + builtin_error (_("%s: no completion specification"), l->word->word); + ret = EXECUTION_FAILURE; + } + } + return ret; +} + +#define SQPRINTARG(a, f) \ + do { \ + if (a) \ + { \ + x = sh_single_quote (a); \ + printf ("%s %s ", f, x); \ + free (x); \ + } \ + } while (0) + +#define PRINTARG(a, f) \ + do { \ + if (a) \ + printf ("%s %s ", f, a); \ + } while (0) + +#define PRINTOPT(a, f) \ + do { \ + if (acts & a) \ + printf ("%s ", f); \ + } while (0) + +#define PRINTACT(a, f) \ + do { \ + if (acts & a) \ + printf ("-A %s ", f); \ + } while (0) + +#define PRINTCOMPOPT(a, f) \ + do { \ + if (copts & a) \ + printf ("-o %s ", f); \ + } while (0) + +#define XPRINTCOMPOPT(a, f) \ + do { \ + if (copts & a) \ + printf ("-o %s ", f); \ + else \ + printf ("+o %s ", f); \ + } while (0) + +static int +print_one_completion (cmd, cs) + char *cmd; + COMPSPEC *cs; +{ + unsigned long acts, copts; + char *x; + + printf ("complete "); + + copts = cs->options; + + /* First, print the -o options. */ + PRINTCOMPOPT (COPT_BASHDEFAULT, "bashdefault"); + PRINTCOMPOPT (COPT_DEFAULT, "default"); + PRINTCOMPOPT (COPT_DIRNAMES, "dirnames"); + PRINTCOMPOPT (COPT_FILENAMES, "filenames"); + PRINTCOMPOPT (COPT_NOSPACE, "nospace"); + PRINTCOMPOPT (COPT_PLUSDIRS, "plusdirs"); + + acts = cs->actions; + + /* simple flags next */ + PRINTOPT (CA_ALIAS, "-a"); + PRINTOPT (CA_BUILTIN, "-b"); + PRINTOPT (CA_COMMAND, "-c"); + PRINTOPT (CA_DIRECTORY, "-d"); + PRINTOPT (CA_EXPORT, "-e"); + PRINTOPT (CA_FILE, "-f"); + PRINTOPT (CA_GROUP, "-g"); + PRINTOPT (CA_JOB, "-j"); + PRINTOPT (CA_KEYWORD, "-k"); + PRINTOPT (CA_SERVICE, "-s"); + PRINTOPT (CA_USER, "-u"); + PRINTOPT (CA_VARIABLE, "-v"); + + /* now the rest of the actions */ + PRINTACT (CA_ARRAYVAR, "arrayvar"); + PRINTACT (CA_BINDING, "binding"); + PRINTACT (CA_DISABLED, "disabled"); + PRINTACT (CA_ENABLED, "enabled"); + PRINTACT (CA_FUNCTION, "function"); + PRINTACT (CA_HELPTOPIC, "helptopic"); + PRINTACT (CA_HOSTNAME, "hostname"); + PRINTACT (CA_RUNNING, "running"); + PRINTACT (CA_SETOPT, "setopt"); + PRINTACT (CA_SHOPT, "shopt"); + PRINTACT (CA_SIGNAL, "signal"); + PRINTACT (CA_STOPPED, "stopped"); + + /* now the rest of the arguments */ + + /* arguments that require quoting */ + SQPRINTARG (cs->globpat, "-G"); + SQPRINTARG (cs->words, "-W"); + SQPRINTARG (cs->prefix, "-P"); + SQPRINTARG (cs->suffix, "-S"); + SQPRINTARG (cs->filterpat, "-X"); + + SQPRINTARG (cs->command, "-C"); + + /* simple arguments that don't require quoting */ + PRINTARG (cs->funcname, "-F"); + + if (STREQ (cmd, EMPTYCMD)) + printf ("-E\n"); + else if (STREQ (cmd, DEFAULTCMD)) + printf ("-D\n"); + else + printf ("%s\n", cmd); + + return (0); +} + +static void +print_compopts (cmd, cs, full) + const char *cmd; + COMPSPEC *cs; + int full; +{ + int copts; + + printf ("compopt "); + copts = cs->options; + + if (full) + { + XPRINTCOMPOPT (COPT_BASHDEFAULT, "bashdefault"); + XPRINTCOMPOPT (COPT_DEFAULT, "default"); + XPRINTCOMPOPT (COPT_DIRNAMES, "dirnames"); + XPRINTCOMPOPT (COPT_FILENAMES, "filenames"); + XPRINTCOMPOPT (COPT_NOSPACE, "nospace"); + XPRINTCOMPOPT (COPT_PLUSDIRS, "plusdirs"); + } + else + { + PRINTCOMPOPT (COPT_BASHDEFAULT, "bashdefault"); + PRINTCOMPOPT (COPT_DEFAULT, "default"); + PRINTCOMPOPT (COPT_DIRNAMES, "dirnames"); + PRINTCOMPOPT (COPT_FILENAMES, "filenames"); + PRINTCOMPOPT (COPT_NOSPACE, "nospace"); + PRINTCOMPOPT (COPT_PLUSDIRS, "plusdirs"); + } + + if (STREQ (cmd, EMPTYCMD)) + printf ("-E\n"); + else if (STREQ (cmd, DEFAULTCMD)) + printf ("-D\n"); + else + printf ("%s\n", cmd); +} + +static int +print_compitem (item) + BUCKET_CONTENTS *item; +{ + COMPSPEC *cs; + char *cmd; + + cmd = item->key; + cs = (COMPSPEC *)item->data; + + return (print_one_completion (cmd, cs)); +} + +static void +print_all_completions () +{ + progcomp_walk (print_compitem); +} + +static int +print_cmd_completions (list) + WORD_LIST *list; +{ + WORD_LIST *l; + COMPSPEC *cs; + int ret; + + for (ret = EXECUTION_SUCCESS, l = list; l; l = l->next) + { + cs = progcomp_search (l->word->word); + if (cs) + print_one_completion (l->word->word, cs); + else + { + builtin_error (_("%s: no completion specification"), l->word->word); + ret = EXECUTION_FAILURE; + } + } + + return (sh_chkwrite (ret)); +} + +$BUILTIN compgen +$DEPENDS_ON PROGRAMMABLE_COMPLETION +$FUNCTION compgen_builtin +$SHORT_DOC compgen [-abcdefgjksuv] [-o option] [-A action] [-G globpat] [-W wordlist] [-F function] [-C command] [-X filterpat] [-P prefix] [-S suffix] [word] +Display 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 generated. + +Exit Status: +Returns success unless an invalid option is supplied or an error occurs. +$END + +int +compgen_builtin (list) + WORD_LIST *list; +{ + int rval; + unsigned long acts, copts; + COMPSPEC *cs; + STRINGLIST *sl; + char *word, **matches; + + if (list == 0) + return (EXECUTION_SUCCESS); + + acts = copts = (unsigned long)0L; + Garg = Warg = Parg = Sarg = Xarg = Farg = Carg = (char *)NULL; + cs = (COMPSPEC *)NULL; + + /* Build the actions from the arguments. Also sets the [A-Z]arg variables + as a side effect if they are supplied as options. */ + rval = build_actions (list, (struct _optflags *)NULL, &acts, &copts); + if (rval == EX_USAGE) + return (rval); + if (rval == EXECUTION_FAILURE) + return (EXECUTION_SUCCESS); + + list = loptend; + + word = (list && list->word) ? list->word->word : ""; + + if (Farg) + builtin_error (_("warning: -F option may not work as you expect")); + if (Carg) + builtin_error (_("warning: -C option may not work as you expect")); + + /* If we get here, we need to build a compspec and evaluate it. */ + cs = compspec_create (); + cs->actions = acts; + cs->options = copts; + cs->refcount = 1; + + cs->globpat = STRDUP (Garg); + cs->words = STRDUP (Warg); + cs->prefix = STRDUP (Parg); + cs->suffix = STRDUP (Sarg); + cs->funcname = STRDUP (Farg); + cs->command = STRDUP (Carg); + cs->filterpat = STRDUP (Xarg); + + rval = EXECUTION_FAILURE; + sl = gen_compspec_completions (cs, "compgen", word, 0, 0, 0); + + /* If the compspec wants the bash default completions, temporarily + turn off programmable completion and call the bash completion code. */ + if ((sl == 0 || sl->list_len == 0) && (copts & COPT_BASHDEFAULT)) + { + matches = bash_default_completion (word, 0, 0, 0, 0); + sl = completions_to_stringlist (matches); + strvec_dispose (matches); + } + + /* This isn't perfect, but it's the best we can do, given what readline + exports from its set of completion utility functions. */ + if ((sl == 0 || sl->list_len == 0) && (copts & COPT_DEFAULT)) + { + matches = rl_completion_matches (word, rl_filename_completion_function); + strlist_dispose (sl); + sl = completions_to_stringlist (matches); + strvec_dispose (matches); + } + + if (sl) + { + if (sl->list && sl->list_len) + { + rval = EXECUTION_SUCCESS; + strlist_print (sl, (char *)NULL); + } + strlist_dispose (sl); + } + + compspec_dispose (cs); + return (rval); +} + +$BUILTIN compopt +$DEPENDS_ON PROGRAMMABLE_COMPLETION +$FUNCTION compopt_builtin +$SHORT_DOC compopt [-o|+o option] [-DE] [name ...] +Modify or display completion options. + +Modify the completion options for each NAME, or, if no NAMEs are supplied, +the completion currently being executed. If no OPTIONs are given, print +the completion options for each NAME or the current completion specification. + +Options: + -o option Set completion option OPTION for each NAME + -D Change options for the "default" command completion + -E Change options for the "empty" command completion + +Using `+o' instead of `-o' turns off the specified option. + +Arguments: + +Each NAME refers to a command for which a completion specification must +have previously been defined using the `complete' builtin. If no NAMEs +are supplied, compopt must be called by a function currently generating +completions, and the options for that currently-executing completion +generator are modified. + +Exit Status: +Returns success unless an invalid option is supplied or NAME does not +have a completion specification defined. +$END + +int +compopt_builtin (list) + WORD_LIST *list; +{ + int opts_on, opts_off, *opts, opt, oind, ret, Dflag, Eflag; + WORD_LIST *l, *wl; + COMPSPEC *cs; + + opts_on = opts_off = Eflag = Dflag = 0; + ret = EXECUTION_SUCCESS; + + reset_internal_getopt (); + while ((opt = internal_getopt (list, "+o:DE")) != -1) + { + opts = (list_opttype == '-') ? &opts_on : &opts_off; + + switch (opt) + { + case 'o': + oind = find_compopt (list_optarg); + if (oind < 0) + { + sh_invalidoptname (list_optarg); + return (EX_USAGE); + } + *opts |= compopts[oind].optflag; + break; + case 'D': + Dflag = 1; + break; + case 'E': + Eflag = 1; + break; + CASE_HELPOPT; + default: + builtin_usage (); + return (EX_USAGE); + } + } + list = loptend; + + wl = Dflag ? make_word_list (make_bare_word (DEFAULTCMD), (WORD_LIST *)NULL) + : (Eflag ? make_word_list (make_bare_word (EMPTYCMD), (WORD_LIST *)NULL) : 0); + + if (list == 0 && wl == 0) + { + if (RL_ISSTATE (RL_STATE_COMPLETING) == 0 || pcomp_curcs == 0) + { + builtin_error (_("not currently executing completion function")); + return (EXECUTION_FAILURE); + } + cs = pcomp_curcs; + + if (opts_on == 0 && opts_off == 0) + { + print_compopts (pcomp_curcmd, cs, 1); + return (sh_chkwrite (ret)); + } + + /* Set the compspec options */ + pcomp_set_compspec_options (cs, opts_on, 1); + pcomp_set_compspec_options (cs, opts_off, 0); + + /* And change the readline variables the options control */ + pcomp_set_readline_variables (opts_on, 1); + pcomp_set_readline_variables (opts_off, 0); + + return (ret); + } + + for (l = wl ? wl : list; l; l = l->next) + { + cs = progcomp_search (l->word->word); + if (cs == 0) + { + builtin_error (_("%s: no completion specification"), l->word->word); + ret = EXECUTION_FAILURE; + continue; + } + if (opts_on == 0 && opts_off == 0) + { + print_compopts (l->word->word, cs, 1); + continue; /* XXX -- fill in later */ + } + + /* Set the compspec options */ + pcomp_set_compspec_options (cs, opts_on, 1); + pcomp_set_compspec_options (cs, opts_off, 0); + } + + if (wl) + dispose_words (wl); + + return (ret); +} diff --git a/builtins/declare.def b/builtins/declare.def new file mode 100644 index 0000000..f4819b4 --- /dev/null +++ b/builtins/declare.def @@ -0,0 +1,923 @@ +This file is declare.def, from which is created declare.c. +It implements the builtins "declare" and "local" in Bash. + +Copyright (C) 1987-2016 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 3 of the License, 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. If not, see . + +$PRODUCES declare.c + +$BUILTIN declare +$FUNCTION declare_builtin +$SHORT_DOC declare [-aAfFgilnrtux] [-p] [name[=value] ...] +Set variable values and attributes. + +Declare variables and give them attributes. If no NAMEs are given, +display the attributes and values of all variables. + +Options: + -f restrict action or display to function names and definitions + -F restrict display to function names only (plus line number and + source file when debugging) + -g create global variables when used in a shell function; otherwise + ignored + -p display the attributes and value of each NAME + +Options which set attributes: + -a to make NAMEs indexed arrays (if supported) + -A to make NAMEs associative arrays (if supported) + -i to make NAMEs have the `integer' attribute + -l to convert NAMEs to lower case on assignment + -n make NAME a reference to the variable named by its value + -r to make NAMEs readonly + -t to make NAMEs have the `trace' attribute + -u to convert NAMEs to upper case on assignment + -x to make NAMEs export + +Using `+' instead of `-' turns off the given attribute. + +Variables with the integer attribute have arithmetic evaluation (see +the `let' command) performed when the variable is assigned a value. + +When used in a function, `declare' makes NAMEs local, as with the `local' +command. The `-g' option suppresses this behavior. + +Exit Status: +Returns success unless an invalid option is supplied or a variable +assignment error occurs. +$END + +$BUILTIN typeset +$FUNCTION declare_builtin +$SHORT_DOC typeset [-aAfFgilnrtux] [-p] name[=value] ... +Set variable values and attributes. + +A synonym for `declare'. See `help declare'. +$END + +#include + +#if defined (HAVE_UNISTD_H) +# ifdef _MINIX +# include +# endif +# include +#endif + +#include + +#include "../bashansi.h" +#include "../bashintl.h" + +#include "../shell.h" +#include "../flags.h" +#include "common.h" +#include "builtext.h" +#include "bashgetopt.h" + +extern int array_needs_making; +extern int posixly_correct; + +static int declare_internal __P((register WORD_LIST *, int)); + +/* Declare or change variable attributes. */ +int +declare_builtin (list) + register WORD_LIST *list; +{ + return (declare_internal (list, 0)); +} + +$BUILTIN local +$FUNCTION local_builtin +$SHORT_DOC local [option] name[=value] ... +Define local variables. + +Create a local variable called NAME, and give it VALUE. OPTION can +be any option accepted by `declare'. + +Local variables can only be used within a function; they are visible +only to the function where they are defined and its children. + +Exit Status: +Returns success unless an invalid option is supplied, a variable +assignment error occurs, or the shell is not executing a function. +$END +int +local_builtin (list) + register WORD_LIST *list; +{ + if (variable_context) + return (declare_internal (list, 1)); + else + { + builtin_error (_("can only be used in a function")); + return (EXECUTION_FAILURE); + } +} + +#if defined (ARRAY_VARS) +# define DECLARE_OPTS "+acfgilnprtuxAF" +#else +# define DECLARE_OPTS "+cfgilnprtuxF" +#endif + +/* The workhorse function. */ +static int +declare_internal (list, local_var) + register WORD_LIST *list; + int local_var; +{ + int flags_on, flags_off, *flags; + int any_failed, assign_error, pflag, nodefs, opt, mkglobal, onref, offref; + char *t, *subscript_start; + SHELL_VAR *var, *refvar, *v; + FUNCTION_DEF *shell_fn; + + flags_on = flags_off = any_failed = assign_error = pflag = nodefs = mkglobal = 0; + refvar = (SHELL_VAR *)NULL; + reset_internal_getopt (); + while ((opt = internal_getopt (list, DECLARE_OPTS)) != -1) + { + flags = list_opttype == '+' ? &flags_off : &flags_on; + + /* If you add options here, see whether or not they need to be added to + the loop in subst.c:shell_expand_word_list() */ + switch (opt) + { + case 'a': +#if defined (ARRAY_VARS) + *flags |= att_array; + break; +#else + builtin_usage (); + return (EX_USAGE); +#endif + case 'A': +#if defined (ARRAY_VARS) + *flags |= att_assoc; + break; +#else + builtin_usage (); + return (EX_USAGE); +#endif + case 'p': + if (local_var == 0) + pflag++; + break; + case 'F': + nodefs++; + *flags |= att_function; + break; + case 'f': + *flags |= att_function; + break; + case 'g': + if (flags == &flags_on) + mkglobal = 1; + break; + case 'i': + *flags |= att_integer; + break; + case 'n': + *flags |= att_nameref; + break; + case 'r': + *flags |= att_readonly; + break; + case 't': + *flags |= att_trace; + break; + case 'x': + *flags |= att_exported; + array_needs_making = 1; + break; +#if defined (CASEMOD_ATTRS) +# if defined (CASEMOD_CAPCASE) + case 'c': + *flags |= att_capcase; + if (flags == &flags_on) + flags_off |= att_uppercase|att_lowercase; + break; +# endif + case 'l': + *flags |= att_lowercase; + if (flags == &flags_on) + flags_off |= att_capcase|att_uppercase; + break; + case 'u': + *flags |= att_uppercase; + if (flags == &flags_on) + flags_off |= att_capcase|att_lowercase; + break; +#endif /* CASEMOD_ATTRS */ + CASE_HELPOPT; + default: + builtin_usage (); + return (EX_USAGE); + } + } + + list = loptend; + + /* If there are no more arguments left, then we just want to show + some variables. */ + if (list == 0) /* declare -[aAfFirtx] */ + { + /* Show local variables defined at this context level if this is + the `local' builtin. */ + if (local_var) + { + register SHELL_VAR **vlist; + register int i; + + vlist = all_local_variables (); + + if (vlist) + { + for (i = 0; vlist[i]; i++) + print_assignment (vlist[i]); + + free (vlist); + } + } + else if (pflag && (flags_on == 0 || flags_on == att_function)) + show_all_var_attributes (flags_on == 0, nodefs); + else if (flags_on == 0) + return (set_builtin ((WORD_LIST *)NULL)); + else + set_or_show_attributes ((WORD_LIST *)NULL, flags_on, nodefs); + + return (sh_chkwrite (EXECUTION_SUCCESS)); + } + + if (pflag) /* declare -p [-aAfFirtx] name [name...] */ + { + for (any_failed = 0; list; list = list->next) + { + if (flags_on & att_function) + pflag = show_func_attributes (list->word->word, nodefs); + else + pflag = show_name_attributes (list->word->word, nodefs); + if (pflag) + { + sh_notfound (list->word->word); + any_failed++; + } + } + return (sh_chkwrite (any_failed ? EXECUTION_FAILURE : EXECUTION_SUCCESS)); + } + +#define NEXT_VARIABLE() free (name); list = list->next; continue + + /* There are arguments left, so we are making variables. */ + while (list) /* declare [-aAfFirx] name [name ...] */ + { + char *value, *name, *oldname; + int offset, aflags, wflags, created_var, namelen; +#if defined (ARRAY_VARS) + int making_array_special, compound_array_assign, simple_array_assign; + int var_exists, array_exists, creating_array, array_subscript_assignment; +#endif + + name = savestring (list->word->word); + wflags = list->word->flags; + offset = assignment (name, 0); + aflags = 0; + created_var = 0; + + if (local_var && variable_context && STREQ (name, "-")) + { + var = make_local_variable ("-"); + FREE (value_cell (var)); /* just in case */ + value = get_current_options (); + var_setvalue (var, value); + VSETATTR (var, att_invisible); + NEXT_VARIABLE (); + } + + if (offset) /* declare [-aAfFirx] name=value */ + { + name[offset] = '\0'; + value = name + offset + 1; + if (name[offset - 1] == '+') + { + aflags |= ASS_APPEND; + name[offset - 1] = '\0'; + } + } + else + value = ""; + + /* Do some lexical error checking on the LHS and RHS of the assignment + that is specific to nameref variables. */ + if (flags_on & att_nameref) + { +#if defined (ARRAY_VARS) + if (valid_array_reference (name, 0)) + { + builtin_error (_("%s: reference variable cannot be an array"), name); + assign_error++; + NEXT_VARIABLE (); + } + else +#endif + /* disallow self references at global scope, warn at function scope */ + if (check_selfref (name, value, 0)) + { + if (variable_context == 0) + { + builtin_error (_("%s: nameref variable self references not allowed"), name); + assign_error++; + NEXT_VARIABLE (); + } + else + builtin_warning (_("%s: circular name reference"), name); + } +#if 1 + if (value && *value && (aflags & ASS_APPEND) == 0 && valid_nameref_value (value, 1) == 0) + { + builtin_error (_("`%s': invalid variable name for name reference"), value); + assign_error++; + NEXT_VARIABLE (); + } +#endif + } + +restart_new_var_name: +#if defined (ARRAY_VARS) + var_exists = array_exists = creating_array = 0; + compound_array_assign = simple_array_assign = 0; + array_subscript_assignment = 0; + subscript_start = (char *)NULL; + if (t = strchr (name, '[')) /* ] */ + { + /* If offset != 0 we have already validated any array reference + because assignment() calls skipsubscript() */ + if (offset == 0 && valid_array_reference (name, 0) == 0) + { + sh_invalidid (name); + assign_error++; + NEXT_VARIABLE (); + } + subscript_start = t; + *t = '\0'; + making_array_special = 1; /* XXX - should this check offset? */ + array_subscript_assignment = offset != 0; + } + else + making_array_special = 0; +#endif + + /* If we're in posix mode or not looking for a shell function (since + shell function names don't have to be valid identifiers when the + shell's not in posix mode), check whether or not the argument is a + valid, well-formed shell identifier. */ + if ((posixly_correct || (flags_on & att_function) == 0) && legal_identifier (name) == 0) + { + sh_invalidid (name); + assign_error++; + NEXT_VARIABLE (); + } + + /* If VARIABLE_CONTEXT has a non-zero value, then we are executing + inside of a function. This means we should make local variables, + not global ones. */ + + /* XXX - this has consequences when we're making a local copy of a + variable that was in the temporary environment. Watch out + for this. */ + refvar = (SHELL_VAR *)NULL; + if (variable_context && mkglobal == 0 && ((flags_on & att_function) == 0)) + { + /* check name for validity here? */ +#if defined (ARRAY_VARS) + if (flags_on & att_assoc) + var = make_local_assoc_variable (name); + else if ((flags_on & att_array) || making_array_special) + var = make_local_array_variable (name, making_array_special); + else +#endif + if (offset == 0 && (flags_on & att_nameref)) + { + /* First look for refvar at current scope */ + refvar = find_variable_last_nameref (name, 1); + var = find_variable (name); + /* VARIABLE_CONTEXT != 0, so we are attempting to create or modify + the attributes for a local variable at the same scope. If we've + used a reference from a previous context to resolve VAR, we + want to throw REFVAR and VAR away and create a new local var. */ + if (refvar && refvar->context != variable_context) + { + refvar = 0; + var = make_local_variable (name); + } + else if (refvar && refvar->context == variable_context) + var = refvar; + /* Maybe we just want to create a new local variable */ + else if (var == 0 || var->context != variable_context) + var = make_local_variable (name); + /* otherwise we have a var at the right context */ + } + else + /* XXX - check name for validity here with valid_nameref_value */ + var = make_local_variable (name); /* sets att_invisible for new vars */ + if (var == 0) + { + any_failed++; + NEXT_VARIABLE (); + } + if (var && nameref_p (var) && readonly_p (var) && nameref_cell (var) && (flags_off & att_nameref)) + { + sh_readonly (name); + any_failed++; + NEXT_VARIABLE (); + } + } + else + var = (SHELL_VAR *)NULL; + + /* If we are declaring a function, then complain about it in some way. + We don't let people make functions by saying `typeset -f foo=bar'. */ + + /* There should be a way, however, to let people look at a particular + function definition by saying `typeset -f foo'. */ + + if (flags_on & att_function) + { + if (offset) /* declare -f [-rix] foo=bar */ + { + builtin_error (_("cannot use `-f' to make functions")); + free (name); + return (EXECUTION_FAILURE); + } + else /* declare -f [-rx] name [name...] */ + { + var = find_function (name); + + if (var) + { + if (readonly_p (var) && (flags_off & att_readonly)) + { + builtin_error (_("%s: readonly function"), name); + any_failed++; + NEXT_VARIABLE (); + } + + /* declare -[Ff] name [name...] */ + if (flags_on == att_function && flags_off == 0) + { +#if defined (DEBUGGER) + if (nodefs && debugging_mode) + { + shell_fn = find_function_def (var->name); + if (shell_fn) + printf ("%s %d %s\n", var->name, shell_fn->line, shell_fn->source_file); + else + printf ("%s\n", var->name); + } + else +#endif /* DEBUGGER */ + { + t = nodefs ? var->name + : named_function_string (name, function_cell (var), FUNC_MULTILINE|FUNC_EXTERNAL); + printf ("%s\n", t); + any_failed = sh_chkwrite (any_failed); + } + } + else /* declare -[fF] -[rx] name [name...] */ + { + VSETATTR (var, flags_on); + VUNSETATTR (var, flags_off); + } + } + else + any_failed++; + NEXT_VARIABLE (); + } + } + else /* declare -[aAinrx] name [name...] */ + { + /* Non-null if we just created or fetched a local variable. */ +#if 0 + /* This is bash-4.3 code. */ + /* Here's what ksh93 seems to do. If we are modifying an existing + nameref variable, we don't follow the nameref chain past the last + nameref, and we set the nameref variable's value so future + references to that variable will return the value of the variable + we're assigning right now. */ +#else + /* Here's what ksh93 seems to do as of the 2012 version: if we are + using declare -n to modify the value of an existing nameref + variable, don't follow the nameref chain at all and just search + for a nameref at the current context. If we have a nameref, + modify its value (changing which variable it references). */ +#endif + if (var == 0 && (flags_on & att_nameref)) + { +#if 0 + /* See if we are trying to modify an existing nameref variable */ + var = mkglobal ? find_global_variable_last_nameref (name, 1) : find_variable_last_nameref (name, 1); +#else + /* See if we are trying to modify an existing nameref variable, + but don't follow the nameref chain. */ + var = mkglobal ? find_global_variable_noref (name) : find_variable_noref (name); +#endif + if (var && nameref_p (var) == 0) + var = 0; + } + /* However, if we're turning off the nameref attribute on an existing + nameref variable, we first follow the nameref chain to the end, + modify the value of the variable this nameref variable references, + *CHANGING ITS VALUE AS A SIDE EFFECT* then turn off the nameref + flag *LEAVING THE NAMEREF VARIABLE'S VALUE UNCHANGED* */ + else if (var == 0 && (flags_off & att_nameref)) + { + /* See if we are trying to modify an existing nameref variable */ + refvar = mkglobal ? find_global_variable_last_nameref (name, 0) : find_variable_last_nameref (name, 0); + if (refvar && nameref_p (refvar) == 0) + refvar = 0; + /* If the nameref is readonly but doesn't have a value, ksh93 + allows the nameref attribute to be removed. If it's readonly + and has a value, even if the value doesn't reference an + existing variable, we disallow the modification */ + if (refvar && nameref_cell (refvar) && readonly_p (refvar)) + { + sh_readonly (name); + any_failed++; + NEXT_VARIABLE (); + } + if (refvar) + var = mkglobal ? find_global_variable (nameref_cell (refvar)) : find_variable (nameref_cell (refvar)); + } +#if defined (ARRAY_VARS) + /* If we have an array assignment to a nameref, remove the nameref + attribute and go on. */ + else if (var == 0 && offset && array_subscript_assignment) + { + var = mkglobal ? find_global_variable_noref (name) : find_variable_noref (name); + if (var && nameref_p (var)) + { + internal_warning (_("%s: removing nameref attribute"), name); + FREE (value_cell (var)); /* XXX - bash-4.3 compat */ + var_setvalue (var, (char *)NULL); + VUNSETATTR (var, att_nameref); + } + } +#endif + + /* See if we are trying to set flags or value for an existing nameref + that points to a non-existent variable: e.g., + declare -n foo=bar + unset foo # unsets bar + declare -i foo + foo=4+4 + declare -p foo */ + if (var == 0 && (flags_on || flags_off || offset)) + { + refvar = mkglobal ? find_global_variable_last_nameref (name, 0) : find_variable_last_nameref (name, 0); + if (refvar && nameref_p (refvar) == 0) + refvar = 0; + if (refvar) + var = mkglobal ? find_global_variable (nameref_cell (refvar)) : find_variable (nameref_cell (refvar)); + if (refvar && var == 0) + { + oldname = name; /* need to free this */ + + namelen = strlen (nameref_cell (refvar)); +#if defined (ARRAY_VARS) + if (subscript_start) + { + *subscript_start = '['; /*]*/ + namelen += strlen (subscript_start); + } +#endif + name = xmalloc (namelen + 2 + strlen (value) + 1); + strcpy (name, nameref_cell (refvar)); +#if defined (ARRAY_VARS) + if (subscript_start) + strcpy (name + strlen (nameref_cell (refvar)), subscript_start); +#endif + /* We are committed to using the new name, so reset */ + if (offset) + { + /* Rebuild assignment and restore offset and value */ + if (aflags & ASS_APPEND) + name[namelen++] = '+'; + name[namelen++] = '='; + if (value && *value) + strcpy (name + namelen, value); + else + name[namelen] = '\0'; + offset = assignment (name, 0); + /* if offset was valid previously, but the substituting + of the nameref value results in an invalid assignment, + throw an invalid identifier error */ + if (offset == 0) + { + free (oldname); + sh_invalidid (name); + assign_error++; + NEXT_VARIABLE (); + } + name[offset] = '\0'; + value = name + namelen; + } + free (oldname); + goto restart_new_var_name; + /* NOTREACHED */ + } + } + if (var == 0) + var = mkglobal ? find_global_variable (name) : find_variable (name); + +#if defined (ARRAY_VARS) + var_exists = var != 0; + array_exists = var && (array_p (var) || assoc_p (var)); + creating_array = flags_on & (att_array|att_assoc); +#endif + + if (var == 0) + { +#if defined (ARRAY_VARS) + if (flags_on & att_assoc) + { + var = make_new_assoc_variable (name); + if (var && offset == 0 && no_invisible_vars == 0) + VSETATTR (var, att_invisible); + } + else if ((flags_on & att_array) || making_array_special) + { + var = make_new_array_variable (name); + if (var && offset == 0 && no_invisible_vars == 0) + VSETATTR (var, att_invisible); + } + else +#endif + { + var = mkglobal ? bind_global_variable (name, (char *)NULL, ASS_FORCE) : bind_variable (name, (char *)NULL, ASS_FORCE); + if (var && offset == 0 && no_invisible_vars == 0) + VSETATTR (var, att_invisible); + } + if (var == 0) + { + /* Has to appear in brackets */ + NEXT_VARIABLE (); + } + created_var = 1; + } + /* Can't take an existing array variable and make it a nameref */ + else if ((array_p (var) || assoc_p (var)) && (flags_on & att_nameref)) + { + builtin_error (_("%s: reference variable cannot be an array"), name); + assign_error++; + NEXT_VARIABLE (); + } + else if (nameref_p (var) && (flags_on & att_nameref) == 0 && (flags_off & att_nameref) == 0 && offset && valid_nameref_value (value, 1) == 0) + { + builtin_error (_("`%s': invalid variable name for name reference"), value); + any_failed++; + NEXT_VARIABLE (); + } + else if (flags_on & att_nameref) + { +#if 1 + /* Check of offset is to allow an assignment to a nameref var as + part of the declare word to override existing value */ + if (nameref_p (var) == 0 && var_isset (var) && offset == 0 && valid_nameref_value (value_cell (var), 0) == 0) + { + builtin_error (_("`%s': invalid variable name for name reference"), value_cell (var)); + any_failed++; + NEXT_VARIABLE (); + } +#endif + if (readonly_p (var)) + { + sh_readonly (name); + any_failed++; + NEXT_VARIABLE (); + } + /* ksh93 compat: turning on nameref attribute turns off -ilu */ + VUNSETATTR (var, att_integer|att_uppercase|att_lowercase|att_capcase); + } + + /* Cannot use declare +r to turn off readonly attribute. */ + if (readonly_p (var) && (flags_off & att_readonly)) + { + sh_readonly (name_cell (var)); + any_failed++; + NEXT_VARIABLE (); + } + + /* Cannot use declare to assign value to readonly or noassign + variable. */ + if ((readonly_p (var) || noassign_p (var)) && offset) + { + if (readonly_p (var)) + sh_readonly (name); + assign_error++; + NEXT_VARIABLE (); + } + +#if defined (ARRAY_VARS) + /* make declare a[2]=foo as similar to a[2]=foo as possible if + a is already an array or assoc variable. */ + if (array_subscript_assignment && array_exists && creating_array == 0) + simple_array_assign = 1; + else if ((making_array_special || creating_array || array_exists) && offset) + { + int vlen; + vlen = STRLEN (value); +/*itrace("declare_builtin: name = %s value = %s flags = %d", name, value, wflags);*/ + if (shell_compatibility_level > 43 && (wflags & W_COMPASSIGN) == 0 && + value[0] == '(' && value[vlen-1] == ')') + { + /* The warning is only printed when using compound assignment + to an array variable that doesn't already exist. We use + creating_array to allow things like + declare -a foo$bar='(abc)' to work. */ + if (array_exists == 0 && creating_array == 0) + internal_warning (_("%s: quoted compound array assignment deprecated"), list->word->word); + compound_array_assign = array_exists || creating_array; + simple_array_assign = making_array_special; + } + else if (value[0] == '(' && value[vlen-1] == ')' && (shell_compatibility_level < 44 || (wflags & W_COMPASSIGN))) + compound_array_assign = 1; + else + simple_array_assign = 1; + } + + /* Cannot use declare +a name or declare +A name to remove an + array variable. */ + if (((flags_off & att_array) && array_p (var)) || ((flags_off & att_assoc) && assoc_p (var))) + { + builtin_error (_("%s: cannot destroy array variables in this way"), name); + any_failed++; + NEXT_VARIABLE (); + } + + if ((flags_on & att_array) && assoc_p (var)) + { + builtin_error (_("%s: cannot convert associative to indexed array"), name); + any_failed++; + NEXT_VARIABLE (); + } + if ((flags_on & att_assoc) && array_p (var)) + { + builtin_error (_("%s: cannot convert indexed to associative array"), name); + any_failed++; + NEXT_VARIABLE (); + } + + /* declare -A name[[n]] makes name an associative array variable. */ + if (flags_on & att_assoc) + { + if (assoc_p (var) == 0) + var = convert_var_to_assoc (var); + } + /* declare -a name[[n]] or declare name[n] makes name an indexed + array variable. */ + else if ((making_array_special || (flags_on & att_array)) && array_p (var) == 0 && assoc_p (var) == 0) + var = convert_var_to_array (var); +#endif /* ARRAY_VARS */ + + /* XXX - we note that we are turning on nameref attribute and defer + setting it until the assignment has been made so we don't do an + inadvertent nameref lookup. Might have to do the same thing for + flags_off&att_nameref. */ + /* XXX - ksh93 makes it an error to set a readonly nameref variable + using a single typeset command. */ + onref = (flags_on & att_nameref); + flags_on &= ~att_nameref; +#if defined (ARRAY_VARS) + if (array_p (var) || assoc_p (var) + || (offset && compound_array_assign) + || simple_array_assign) + onref = 0; /* array variables may not be namerefs */ +#endif + + /* ksh93 seems to do this */ + offref = (flags_off & att_nameref); + flags_off &= ~att_nameref; + + VSETATTR (var, flags_on); + VUNSETATTR (var, flags_off); + +#if defined (ARRAY_VARS) + if (offset && compound_array_assign) + assign_array_var_from_string (var, value, aflags|ASS_FORCE); + else if (simple_array_assign && subscript_start) + { + /* declare [-aA] name[N]=value */ + *subscript_start = '['; /* ] */ + /* XXX - problem here with appending */ + var = assign_array_element (name, value, aflags&ASS_APPEND); /* XXX - not aflags */ + *subscript_start = '\0'; + if (var == 0) /* some kind of assignment error */ + { + assign_error++; + flags_on |= onref; + flags_off |= offref; + NEXT_VARIABLE (); + } + } + else if (simple_array_assign) + { + /* let bind_{array,assoc}_variable take care of this. */ + if (assoc_p (var)) + bind_assoc_variable (var, name, savestring ("0"), value, aflags|ASS_FORCE); + else + bind_array_variable (name, 0, value, aflags|ASS_FORCE); + } + else +#endif + /* XXX - no ASS_FORCE here */ + /* bind_variable_value duplicates the essential internals of + bind_variable() */ + if (offset) + { + if (onref || nameref_p (var)) + aflags |= ASS_NAMEREF; + v = bind_variable_value (var, value, aflags); + if (v == 0 && (onref || nameref_p (var))) + { + if (valid_nameref_value (value, 1) == 0) + sh_invalidid (value); + assign_error++; + /* XXX - unset this variable? or leave it as normal var? */ + if (created_var) + delete_var (var->name, mkglobal ? global_variables : shell_variables); + flags_on |= onref; /* undo change from above */ + flags_off |= offref; + NEXT_VARIABLE (); + } + } + + /* If we found this variable in the temporary environment, as with + `var=value declare -x var', make sure it is treated identically + to `var=value export var'. Do the same for `declare -r' and + `readonly'. Preserve the attributes, except for att_tempvar. */ + /* XXX -- should this create a variable in the global scope, or + modify the local variable flags? ksh93 has it modify the + global scope. + Need to handle case like in set_var_attribute where a temporary + variable is in the same table as the function local vars. */ + if ((flags_on & (att_exported|att_readonly)) && tempvar_p (var)) + { + SHELL_VAR *tv; + char *tvalue; + + tv = find_tempenv_variable (var->name); + if (tv) + { + tvalue = var_isset (var) ? savestring (value_cell (var)) : savestring (""); + tv = bind_variable (var->name, tvalue, 0); + tv->attributes |= var->attributes & ~att_tempvar; + if (tv->context > 0) + VSETATTR (tv, att_propagate); + free (tvalue); + } + VSETATTR (var, att_propagate); + } + } + + /* Turn on nameref attribute we deferred above. */ + /* XXX - should we turn on the noassign attribute for consistency with + ksh93 when we turn on the nameref attribute? */ + VSETATTR (var, onref); + flags_on |= onref; + VUNSETATTR (var, offref); + flags_off |= offref; + /* Yuck. ksh93 compatibility. XXX - need to investigate more but + definitely happens when turning off nameref attribute on nameref + (see comments above). Under no circumstances allow this to turn + off readonly attribute on readonly nameref variable. */ + if (refvar) + { + if (flags_off & att_readonly) + flags_off &= ~att_readonly; + VUNSETATTR (refvar, flags_off); + } + + stupidly_hack_special_variables (name); + + NEXT_VARIABLE (); + } + + return (assign_error ? EX_BADASSIGN + : ((any_failed == 0) ? EXECUTION_SUCCESS + : EXECUTION_FAILURE)); +} diff --git a/builtins/echo.def b/builtins/echo.def new file mode 100644 index 0000000..3f8b5a9 --- /dev/null +++ b/builtins/echo.def @@ -0,0 +1,200 @@ +This file is echo.def, from which is created echo.c. +It implements the builtin "echo" in Bash. + +Copyright (C) 1987-2016 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 3 of the License, 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. If not, see . + +$PRODUCES echo.c +#include + +#if defined (HAVE_UNISTD_H) +# include +#endif + +#include "../bashansi.h" + +#include +#include "../shell.h" + +#include "common.h" + +$BUILTIN echo +$FUNCTION echo_builtin +$DEPENDS_ON V9_ECHO +$SHORT_DOC echo [-neE] [arg ...] +Write arguments to the standard output. + +Display the ARGs, separated by a single space character and followed by a +newline, on the standard output. + +Options: + -n do not append a newline + -e enable interpretation of the following backslash escapes + -E explicitly suppress interpretation of backslash escapes + +`echo' interprets the following backslash-escaped characters: + \a alert (bell) + \b backspace + \c suppress further output + \e escape character + \E escape character + \f form feed + \n new line + \r carriage return + \t horizontal tab + \v vertical tab + \\ backslash + \0nnn the character whose ASCII code is NNN (octal). NNN can be + 0 to 3 octal digits + \xHH the eight-bit character whose value is HH (hexadecimal). HH + can be one or two hex digits + +Exit Status: +Returns success unless a write error occurs. +$END + +$BUILTIN echo +$FUNCTION echo_builtin +$DEPENDS_ON !V9_ECHO +$SHORT_DOC echo [-n] [arg ...] +Write arguments to the standard output. + +Display the ARGs on the standard output followed by a newline. + +Options: + -n do not append a newline + +Exit Status: +Returns success unless a write error occurs. +$END + +#if defined (V9_ECHO) +# define VALID_ECHO_OPTIONS "neE" +#else /* !V9_ECHO */ +# define VALID_ECHO_OPTIONS "n" +#endif /* !V9_ECHO */ + +/* System V machines already have a /bin/sh with a v9 behaviour. We + give Bash the identical behaviour for these machines so that the + existing system shells won't barf. Regrettably, the SUS v2 has + standardized the Sys V echo behavior. This variable is external + so that we can have a `shopt' variable to control it at runtime. */ +#if defined (DEFAULT_ECHO_TO_XPG) || defined (STRICT_POSIX) +int xpg_echo = 1; +#else +int xpg_echo = 0; +#endif /* DEFAULT_ECHO_TO_XPG */ + +extern int posixly_correct; + +/* Print the words in LIST to standard output. If the first word is + `-n', then don't print a trailing newline. We also support the + echo syntax from Version 9 Unix systems. */ +int +echo_builtin (list) + WORD_LIST *list; +{ + int display_return, do_v9, i, len; + char *temp, *s; + + do_v9 = xpg_echo; + display_return = 1; + + if (posixly_correct && xpg_echo) + goto just_echo; + + for (; list && (temp = list->word->word) && *temp == '-'; list = list->next) + { + /* If it appears that we are handling options, then make sure that + all of the options specified are actually valid. Otherwise, the + string should just be echoed. */ + temp++; + + for (i = 0; temp[i]; i++) + { + if (strchr (VALID_ECHO_OPTIONS, temp[i]) == 0) + break; + } + + /* echo - and echo - both mean to just echo the arguments. */ + if (*temp == 0 || temp[i]) + break; + + /* All of the options in TEMP are valid options to ECHO. + Handle them. */ + while (i = *temp++) + { + switch (i) + { + case 'n': + display_return = 0; + break; +#if defined (V9_ECHO) + case 'e': + do_v9 = 1; + break; + case 'E': + do_v9 = 0; + break; +#endif /* V9_ECHO */ + default: + goto just_echo; /* XXX */ + } + } + } + +just_echo: + + clearerr (stdout); /* clear error before writing and testing success */ + + while (list) + { + i = len = 0; + temp = do_v9 ? ansicstr (list->word->word, STRLEN (list->word->word), 1, &i, &len) + : list->word->word; + if (temp) + { + if (do_v9) + { + for (s = temp; len > 0; len--) + putchar (*s++); + } + else + printf ("%s", temp); +#if defined (SunOS5) + fflush (stdout); /* Fix for bug in SunOS 5.5 printf(3) */ +#endif + } + QUIT; + if (do_v9 && temp) + free (temp); + list = list->next; + if (i) + { + display_return = 0; + break; + } + if (list) + putchar(' '); + QUIT; + } + + if (display_return) + putchar ('\n'); + + return (sh_chkwrite (EXECUTION_SUCCESS)); +} diff --git a/builtins/enable.def b/builtins/enable.def new file mode 100644 index 0000000..39c3669 --- /dev/null +++ b/builtins/enable.def @@ -0,0 +1,547 @@ +This file is enable.def, from which is created enable.c. +It implements the builtin "enable" in Bash. + +Copyright (C) 1987-2016 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 3 of the License, 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. If not, see . + +$PRODUCES enable.c + +$BUILTIN enable +$FUNCTION enable_builtin +$SHORT_DOC enable [-a] [-dnps] [-f filename] [name ...] +Enable and disable shell builtins. + +Enables and disables builtin shell commands. Disabling allows you to +execute a disk command which has the same name as a shell builtin +without using a full pathname. + +Options: + -a print a list of builtins showing whether or not each is enabled + -n disable each NAME or display a list of disabled builtins + -p print the list of builtins in a reusable format + -s print only the names of Posix `special' builtins + +Options controlling dynamic loading: + -f Load builtin NAME from shared object FILENAME + -d Remove a builtin loaded with -f + +Without options, each NAME is enabled. + +To use the `test' found in $PATH instead of the shell builtin +version, type `enable -n test'. + +Exit Status: +Returns success unless NAME is not a shell builtin or an error occurs. +$END + +#include + +#if defined (HAVE_UNISTD_H) +# ifdef _MINIX +# include +# endif +# include +#endif + +#include +#include "../bashansi.h" +#include "../bashintl.h" + +#include "../shell.h" +#include "../builtins.h" +#include "../flags.h" +#include "common.h" +#include "bashgetopt.h" +#include "findcmd.h" + +#if defined (PROGRAMMABLE_COMPLETION) +# include "../pcomplete.h" +#endif + +#define ENABLED 1 +#define DISABLED 2 +#define SPECIAL 4 + +#define AFLAG 0x01 +#define DFLAG 0x02 +#define FFLAG 0x04 +#define NFLAG 0x08 +#define PFLAG 0x10 +#define SFLAG 0x20 + +#if defined (HAVE_DLOPEN) && defined (HAVE_DLSYM) +static int dyn_load_builtin __P((WORD_LIST *, int, char *)); +#endif + +#if defined (HAVE_DLCLOSE) +static int dyn_unload_builtin __P((char *)); +static void delete_builtin __P((struct builtin *)); +static int local_dlclose __P((void *)); +#endif + +#define STRUCT_SUFFIX "_struct" +/* for now */ +#define LOAD_SUFFIX "_builtin_load" +#define UNLOAD_SUFFIX "_builtin_unload" + +static void list_some_builtins __P((int)); +static int enable_shell_command __P((char *, int)); + +/* Enable/disable shell commands present in LIST. If list is not specified, + then print out a list of shell commands showing which are enabled and + which are disabled. */ +int +enable_builtin (list) + WORD_LIST *list; +{ + int result, flags; + int opt, filter; +#if defined (HAVE_DLOPEN) && defined (HAVE_DLSYM) + char *filename; +#endif + + result = EXECUTION_SUCCESS; + flags = 0; + + reset_internal_getopt (); + while ((opt = internal_getopt (list, "adnpsf:")) != -1) + { + switch (opt) + { + case 'a': + flags |= AFLAG; + break; + case 'n': + flags |= NFLAG; + break; + case 'p': + flags |= PFLAG; + break; + case 's': + flags |= SFLAG; + break; + case 'f': +#if defined (HAVE_DLOPEN) && defined (HAVE_DLSYM) + flags |= FFLAG; + filename = list_optarg; + break; +#else + builtin_error (_("dynamic loading not available")); + return (EX_USAGE); +#endif +#if defined (HAVE_DLCLOSE) + case 'd': + flags |= DFLAG; + break; +#else + builtin_error (_("dynamic loading not available")); + return (EX_USAGE); +#endif /* HAVE_DLCLOSE */ + CASE_HELPOPT; + default: + builtin_usage (); + return (EX_USAGE); + } + } + + list = loptend; + +#if defined (RESTRICTED_SHELL) + /* Restricted shells cannot load new builtins. */ + if (restricted && (flags & (FFLAG|DFLAG))) + { + sh_restricted ((char *)NULL); + return (EXECUTION_FAILURE); + } +#endif + + if (list == 0 || (flags & PFLAG)) + { + filter = (flags & AFLAG) ? (ENABLED | DISABLED) + : (flags & NFLAG) ? DISABLED : ENABLED; + + if (flags & SFLAG) + filter |= SPECIAL; + + list_some_builtins (filter); + } +#if defined (HAVE_DLOPEN) && defined (HAVE_DLSYM) + else if (flags & FFLAG) + { + filter = (flags & NFLAG) ? DISABLED : ENABLED; + if (flags & SFLAG) + filter |= SPECIAL; + + result = dyn_load_builtin (list, filter, filename); +#if defined (PROGRAMMABLE_COMPLETION) + set_itemlist_dirty (&it_builtins); +#endif + } +#endif +#if defined (HAVE_DLCLOSE) + else if (flags & DFLAG) + { + while (list) + { + opt = dyn_unload_builtin (list->word->word); + if (opt == EXECUTION_FAILURE) + result = EXECUTION_FAILURE; + list = list->next; + } +#if defined (PROGRAMMABLE_COMPLETION) + set_itemlist_dirty (&it_builtins); +#endif + } +#endif + else + { + while (list) + { + opt = enable_shell_command (list->word->word, flags & NFLAG); + + if (opt == EXECUTION_FAILURE) + { + sh_notbuiltin (list->word->word); + result = EXECUTION_FAILURE; + } + list = list->next; + } + } + return (result); +} + +/* List some builtins. + FILTER is a mask with two slots: ENABLED and DISABLED. */ +static void +list_some_builtins (filter) + int filter; +{ + register int i; + + for (i = 0; i < num_shell_builtins; i++) + { + if (shell_builtins[i].function == 0 || (shell_builtins[i].flags & BUILTIN_DELETED)) + continue; + + if ((filter & SPECIAL) && + (shell_builtins[i].flags & SPECIAL_BUILTIN) == 0) + continue; + + if ((filter & ENABLED) && (shell_builtins[i].flags & BUILTIN_ENABLED)) + printf ("enable %s\n", shell_builtins[i].name); + else if ((filter & DISABLED) && + ((shell_builtins[i].flags & BUILTIN_ENABLED) == 0)) + printf ("enable -n %s\n", shell_builtins[i].name); + } +} + +/* Enable the shell command NAME. If DISABLE_P is non-zero, then + disable NAME instead. */ +static int +enable_shell_command (name, disable_p) + char *name; + int disable_p; +{ + struct builtin *b; + + b = builtin_address_internal (name, 1); + if (b == 0) + return (EXECUTION_FAILURE); + + if (disable_p) + b->flags &= ~BUILTIN_ENABLED; +#if defined (RESTRICTED_SHELL) + else if (restricted && ((b->flags & BUILTIN_ENABLED) == 0)) + { + sh_restricted ((char *)NULL); + return (EXECUTION_FAILURE); + } +#endif + else + b->flags |= BUILTIN_ENABLED; + +#if defined (PROGRAMMABLE_COMPLETION) + set_itemlist_dirty (&it_enabled); + set_itemlist_dirty (&it_disabled); +#endif + + return (EXECUTION_SUCCESS); +} + +#if defined (HAVE_DLOPEN) && defined (HAVE_DLSYM) + +#if defined (HAVE_DLFCN_H) +# include +#endif + +static int +dyn_load_builtin (list, flags, filename) + WORD_LIST *list; + int flags; + char *filename; +{ + WORD_LIST *l; + void *handle; + + int total, size, new, replaced, r; + char *struct_name, *name, *funcname; + sh_load_func_t *loadfunc; + struct builtin **new_builtins, *b, *new_shell_builtins, *old_builtin; + char *loadables_path, *load_path; + + if (list == 0) + return (EXECUTION_FAILURE); + +#ifndef RTLD_LAZY +#define RTLD_LAZY 1 +#endif + + handle = 0; + if (absolute_program (filename) == 0) + { + loadables_path = get_string_value ("BASH_LOADABLES_PATH"); + if (loadables_path) + { + load_path = find_in_path (filename, loadables_path, FS_NODIRS|FS_EXEC_PREFERRED); + if (load_path) + { +#if defined (_AIX) + handle = dlopen (load_path, RTLD_NOW|RTLD_GLOBAL); +#else + handle = dlopen (load_path, RTLD_LAZY); +#endif /* !_AIX */ + free (load_path); + } + } + } + + /* Fall back to current directory for now */ + if (handle == 0) +#if defined (_AIX) + handle = dlopen (filename, RTLD_NOW|RTLD_GLOBAL); +#else + handle = dlopen (filename, RTLD_LAZY); +#endif /* !_AIX */ + + if (handle == 0) + { + name = printable_filename (filename, 0); + builtin_error (_("cannot open shared object %s: %s"), name, dlerror ()); + if (name != filename) + free (name); + return (EXECUTION_FAILURE); + } + + for (new = 0, l = list; l; l = l->next, new++) + ; + new_builtins = (struct builtin **)xmalloc (new * sizeof (struct builtin *)); + + /* For each new builtin in the shared object, find it and its describing + structure. If this is overwriting an existing builtin, do so, otherwise + save the loaded struct for creating the new list of builtins. */ + for (replaced = new = 0; list; list = list->next) + { + name = list->word->word; + + size = strlen (name); + struct_name = (char *)xmalloc (size + 8); + strcpy (struct_name, name); + strcpy (struct_name + size, STRUCT_SUFFIX); + + b = (struct builtin *)dlsym (handle, struct_name); + if (b == 0) + { + name = printable_filename (filename, 0); + builtin_error (_("cannot find %s in shared object %s: %s"), + struct_name, name, dlerror ()); + if (name != filename) + free (name); + free (struct_name); + continue; + } + + funcname = xrealloc (struct_name, size + sizeof (LOAD_SUFFIX) + 1); + strcpy (funcname, name); + strcpy (funcname + size, LOAD_SUFFIX); + + loadfunc = (sh_load_func_t *)dlsym (handle, funcname); + if (loadfunc) + { + r = (*loadfunc) (name); + if (r == 0) + { + builtin_error (_("load function for %s returns failure (%d): not loaded"), name, r); + free (funcname); + continue; + } + } + free (funcname); + + b->flags &= ~STATIC_BUILTIN; + if (flags & SPECIAL) + b->flags |= SPECIAL_BUILTIN; + b->handle = handle; + + if (old_builtin = builtin_address_internal (name, 1)) + { + replaced++; + FASTCOPY ((char *)b, (char *)old_builtin, sizeof (struct builtin)); + } + else + new_builtins[new++] = b; + } + + if (replaced == 0 && new == 0) + { + free (new_builtins); + dlclose (handle); + return (EXECUTION_FAILURE); + } + + if (new) + { + total = num_shell_builtins + new; + size = (total + 1) * sizeof (struct builtin); + + new_shell_builtins = (struct builtin *)xmalloc (size); + FASTCOPY ((char *)shell_builtins, (char *)new_shell_builtins, + num_shell_builtins * sizeof (struct builtin)); + for (replaced = 0; replaced < new; replaced++) + FASTCOPY ((char *)new_builtins[replaced], + (char *)&new_shell_builtins[num_shell_builtins + replaced], + sizeof (struct builtin)); + + new_shell_builtins[total].name = (char *)0; + new_shell_builtins[total].function = (sh_builtin_func_t *)0; + new_shell_builtins[total].flags = 0; + + if (shell_builtins != static_shell_builtins) + free (shell_builtins); + + shell_builtins = new_shell_builtins; + num_shell_builtins = total; + initialize_shell_builtins (); + } + + free (new_builtins); + return (EXECUTION_SUCCESS); +} +#endif + +#if defined (HAVE_DLCLOSE) +static void +delete_builtin (b) + struct builtin *b; +{ + int ind, size; + struct builtin *new_shell_builtins; + + /* XXX - funky pointer arithmetic - XXX */ +#ifdef __STDC__ + ind = b - shell_builtins; +#else + ind = ((int)b - (int)shell_builtins) / sizeof (struct builtin); +#endif + size = num_shell_builtins * sizeof (struct builtin); + new_shell_builtins = (struct builtin *)xmalloc (size); + + /* Copy shell_builtins[0]...shell_builtins[ind - 1] to new_shell_builtins */ + if (ind) + FASTCOPY ((char *)shell_builtins, (char *)new_shell_builtins, + ind * sizeof (struct builtin)); + /* Copy shell_builtins[ind+1]...shell_builtins[num_shell_builtins to + new_shell_builtins, starting at ind. */ + FASTCOPY ((char *)(&shell_builtins[ind+1]), + (char *)(&new_shell_builtins[ind]), + (num_shell_builtins - ind) * sizeof (struct builtin)); + + if (shell_builtins != static_shell_builtins) + free (shell_builtins); + + /* The result is still sorted. */ + num_shell_builtins--; + shell_builtins = new_shell_builtins; +} + +/* Tenon's MachTen has a dlclose that doesn't return a value, so we + finesse it with a local wrapper. */ +static int +local_dlclose (handle) + void *handle; +{ +#if !defined (__MACHTEN__) + return (dlclose (handle)); +#else /* __MACHTEN__ */ + dlclose (handle); + return ((dlerror () != NULL) ? -1 : 0); +#endif /* __MACHTEN__ */ +} + +static int +dyn_unload_builtin (name) + char *name; +{ + struct builtin *b; + void *handle; + char *funcname; + sh_unload_func_t *unloadfunc; + int ref, i, size; + + b = builtin_address_internal (name, 1); + if (b == 0) + { + sh_notbuiltin (name); + return (EXECUTION_FAILURE); + } + if (b->flags & STATIC_BUILTIN) + { + builtin_error (_("%s: not dynamically loaded"), name); + return (EXECUTION_FAILURE); + } + + handle = (void *)b->handle; + for (ref = i = 0; i < num_shell_builtins; i++) + { + if (shell_builtins[i].handle == b->handle) + ref++; + } + + /* Call any unload function */ + size = strlen (name); + funcname = xmalloc (size + sizeof (UNLOAD_SUFFIX) + 1); + strcpy (funcname, name); + strcpy (funcname + size, UNLOAD_SUFFIX); + + unloadfunc = (sh_unload_func_t *)dlsym (handle, funcname); + if (unloadfunc) + (*unloadfunc) (name); /* void function */ + free (funcname); + + /* Don't remove the shared object unless the reference count of builtins + using it drops to zero. */ + if (ref == 1 && local_dlclose (handle) != 0) + { + builtin_error (_("%s: cannot delete: %s"), name, dlerror ()); + return (EXECUTION_FAILURE); + } + + /* Now remove this entry from the builtin table and reinitialize. */ + delete_builtin (b); + + return (EXECUTION_SUCCESS); +} +#endif diff --git a/builtins/eval.def b/builtins/eval.def new file mode 100644 index 0000000..a92b538 --- /dev/null +++ b/builtins/eval.def @@ -0,0 +1,57 @@ +This file is eval.def, from which is created eval.c. +It implements the builtin "eval" in Bash. + +Copyright (C) 1987-2016 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 3 of the License, 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. If not, see . + +$PRODUCES eval.c + +$BUILTIN eval +$FUNCTION eval_builtin +$SHORT_DOC eval [arg ...] +Execute arguments as a shell command. + +Combine ARGs into a single string, use the result as input to the shell, +and execute the resulting commands. + +Exit Status: +Returns exit status of command or success if command is null. +$END + +#include +#if defined (HAVE_UNISTD_H) +# ifdef _MINIX +# include +# endif +# include +#endif + +#include "../shell.h" +#include "bashgetopt.h" +#include "common.h" + +/* Parse the string that these words make, and execute the command found. */ +int +eval_builtin (list) + WORD_LIST *list; +{ + if (no_options (list)) + return (EX_USAGE); + list = loptend; /* skip over possible `--' */ + + return (list ? evalstring (string_list (list), "eval", SEVAL_NOHIST) : EXECUTION_SUCCESS); +} diff --git a/builtins/evalfile.c b/builtins/evalfile.c new file mode 100644 index 0000000..316b794 --- /dev/null +++ b/builtins/evalfile.c @@ -0,0 +1,388 @@ +/* evalfile.c - read and evaluate commands from a file or file descriptor */ + +/* Copyright (C) 1996-2015 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 3 of the License, 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. If not, see . +*/ + +#include + +#if defined (HAVE_UNISTD_H) +# include +#endif + +#include "../bashtypes.h" +#include "posixstat.h" +#include "filecntl.h" + +#include +#include +#include + +#include "../bashansi.h" +#include "../bashintl.h" + +#include "../shell.h" +#include "../jobs.h" +#include "../builtins.h" +#include "../flags.h" +#include "../input.h" +#include "../execute_cmd.h" +#include "../trap.h" + +#include + +#if defined (HISTORY) +# include "../bashhist.h" +#endif + +#include + +#include "common.h" + +#if !defined (errno) +extern int errno; +#endif + +/* Flags for _evalfile() */ +#define FEVAL_ENOENTOK 0x001 +#define FEVAL_BUILTIN 0x002 +#define FEVAL_UNWINDPROT 0x004 +#define FEVAL_NONINT 0x008 +#define FEVAL_LONGJMP 0x010 +#define FEVAL_HISTORY 0x020 +#define FEVAL_CHECKBINARY 0x040 +#define FEVAL_REGFILE 0x080 +#define FEVAL_NOPUSHARGS 0x100 + +extern int posixly_correct; +extern int indirection_level, subshell_environment; +extern int return_catch_flag, return_catch_value; +extern int last_command_exit_value; +extern int executing_command_builtin; +extern int current_token; /* parse.y */ + +/* How many `levels' of sourced files we have. */ +int sourcelevel = 0; + +static int +_evalfile (filename, flags) + const char *filename; + int flags; +{ + volatile int old_interactive; + procenv_t old_return_catch; + int return_val, fd, result, pflags, i, nnull; + ssize_t nr; /* return value from read(2) */ + char *string; + struct stat finfo; + size_t file_size; + sh_vmsg_func_t *errfunc; +#if defined (ARRAY_VARS) + SHELL_VAR *funcname_v, *nfv, *bash_source_v, *bash_lineno_v; + ARRAY *funcname_a, *bash_source_a, *bash_lineno_a; + struct func_array_state *fa; +# if defined (DEBUGGER) + SHELL_VAR *bash_argv_v, *bash_argc_v; + ARRAY *bash_argv_a, *bash_argc_a; +# endif + char *t, tt[2]; +#endif + + USE_VAR(pflags); + +#if defined (ARRAY_VARS) + GET_ARRAY_FROM_VAR ("FUNCNAME", funcname_v, funcname_a); + GET_ARRAY_FROM_VAR ("BASH_SOURCE", bash_source_v, bash_source_a); + GET_ARRAY_FROM_VAR ("BASH_LINENO", bash_lineno_v, bash_lineno_a); +# if defined (DEBUGGER) + GET_ARRAY_FROM_VAR ("BASH_ARGV", bash_argv_v, bash_argv_a); + GET_ARRAY_FROM_VAR ("BASH_ARGC", bash_argc_v, bash_argc_a); +# endif +#endif + + fd = open (filename, O_RDONLY); + + if (fd < 0 || (fstat (fd, &finfo) == -1)) + { + i = errno; + if (fd >= 0) + close (fd); + errno = i; + +file_error_and_exit: + if (((flags & FEVAL_ENOENTOK) == 0) || errno != ENOENT) + file_error (filename); + + if (flags & FEVAL_LONGJMP) + { + last_command_exit_value = 1; + jump_to_top_level (EXITPROG); + } + + return ((flags & FEVAL_BUILTIN) ? EXECUTION_FAILURE + : ((errno == ENOENT && (flags & FEVAL_ENOENTOK) != 0) ? 0 : -1)); + } + + errfunc = ((flags & FEVAL_BUILTIN) ? builtin_error : internal_error); + + if (S_ISDIR (finfo.st_mode)) + { + (*errfunc) (_("%s: is a directory"), filename); + close (fd); + return ((flags & FEVAL_BUILTIN) ? EXECUTION_FAILURE : -1); + } + else if ((flags & FEVAL_REGFILE) && S_ISREG (finfo.st_mode) == 0) + { + (*errfunc) (_("%s: not a regular file"), filename); + close (fd); + return ((flags & FEVAL_BUILTIN) ? EXECUTION_FAILURE : -1); + } + + file_size = (size_t)finfo.st_size; + /* Check for overflow with large files. */ + if (file_size != finfo.st_size || file_size + 1 < file_size) + { + (*errfunc) (_("%s: file is too large"), filename); + close (fd); + return ((flags & FEVAL_BUILTIN) ? EXECUTION_FAILURE : -1); + } + + if (S_ISREG (finfo.st_mode) && file_size <= SSIZE_MAX) + { + string = (char *)xmalloc (1 + file_size); + nr = read (fd, string, file_size); + if (nr >= 0) + string[nr] = '\0'; + } + else + nr = zmapfd (fd, &string, 0); + + return_val = errno; + close (fd); + errno = return_val; + + if (nr < 0) /* XXX was != file_size, not < 0 */ + { + free (string); + goto file_error_and_exit; + } + + if (nr == 0) + { + free (string); + return ((flags & FEVAL_BUILTIN) ? EXECUTION_SUCCESS : 1); + } + + if ((flags & FEVAL_CHECKBINARY) && + check_binary_file (string, (nr > 80) ? 80 : nr)) + { + free (string); + (*errfunc) (_("%s: cannot execute binary file"), filename); + return ((flags & FEVAL_BUILTIN) ? EX_BINARY_FILE : -1); + } + + i = strlen (string); + if (i < nr) + { + for (nnull = i = 0; i < nr; i++) + if (string[i] == '\0') + { + memmove (string+i, string+i+1, nr - i); + nr--; + /* Even if the `check binary' flag is not set, we want to avoid + sourcing files with more than 256 null characters -- that + probably indicates a binary file. */ + if ((flags & FEVAL_BUILTIN) && ++nnull > 256) + { + free (string); + (*errfunc) (_("%s: cannot execute binary file"), filename); + return ((flags & FEVAL_BUILTIN) ? EX_BINARY_FILE : -1); + } + } + } + + if (flags & FEVAL_UNWINDPROT) + { + begin_unwind_frame ("_evalfile"); + + unwind_protect_int (return_catch_flag); + unwind_protect_jmp_buf (return_catch); + if (flags & FEVAL_NONINT) + unwind_protect_int (interactive); + unwind_protect_int (sourcelevel); + } + else + { + COPY_PROCENV (return_catch, old_return_catch); + if (flags & FEVAL_NONINT) + old_interactive = interactive; + } + + if (flags & FEVAL_NONINT) + interactive = 0; + + return_catch_flag++; + sourcelevel++; + +#if defined (ARRAY_VARS) + array_push (bash_source_a, (char *)filename); + t = itos (executing_line_number ()); + array_push (bash_lineno_a, t); + free (t); + array_push (funcname_a, "source"); /* not exactly right */ + + fa = (struct func_array_state *)xmalloc (sizeof (struct func_array_state)); + fa->source_a = bash_source_a; + fa->source_v = bash_source_v; + fa->lineno_a = bash_lineno_a; + fa->lineno_v = bash_lineno_v; + fa->funcname_a = funcname_a; + fa->funcname_v = funcname_v; + if (flags & FEVAL_UNWINDPROT) + add_unwind_protect (restore_funcarray_state, fa); + +# if defined (DEBUGGER) + /* Have to figure out a better way to do this when `source' is supplied + arguments */ + if ((flags & FEVAL_NOPUSHARGS) == 0) + { + array_push (bash_argv_a, (char *)filename); + tt[0] = '1'; tt[1] = '\0'; + array_push (bash_argc_a, tt); + if (flags & FEVAL_UNWINDPROT) + add_unwind_protect (pop_args, 0); + } +# endif +#endif + + /* set the flags to be passed to parse_and_execute */ + pflags = SEVAL_RESETLINE; + pflags |= (flags & FEVAL_HISTORY) ? 0 : SEVAL_NOHIST; + + if (flags & FEVAL_BUILTIN) + result = EXECUTION_SUCCESS; + + return_val = setjmp_nosigs (return_catch); + + /* If `return' was seen outside of a function, but in the script, then + force parse_and_execute () to clean up. */ + if (return_val) + { + parse_and_execute_cleanup (); + result = return_catch_value; + } + else + result = parse_and_execute (string, filename, pflags); + + if (flags & FEVAL_UNWINDPROT) + run_unwind_frame ("_evalfile"); + else + { + if (flags & FEVAL_NONINT) + interactive = old_interactive; +#if defined (ARRAY_VARS) + restore_funcarray_state (fa); +# if defined (DEBUGGER) + if ((flags & FEVAL_NOPUSHARGS) == 0) + { + /* Don't need to call pop_args here until we do something better + when source is passed arguments (see above). */ + array_pop (bash_argc_a); + array_pop (bash_argv_a); + } +# endif +#endif + return_catch_flag--; + sourcelevel--; + COPY_PROCENV (old_return_catch, return_catch); + } + + /* If we end up with EOF after sourcing a file, which can happen when the file + doesn't end with a newline, pretend that it did. */ + if (current_token == yacc_EOF) + push_token ('\n'); /* XXX */ + + return ((flags & FEVAL_BUILTIN) ? result : 1); +} + +int +maybe_execute_file (fname, force_noninteractive) + const char *fname; + int force_noninteractive; +{ + char *filename; + int result, flags; + + filename = bash_tilde_expand (fname, 0); + flags = FEVAL_ENOENTOK; + if (force_noninteractive) + flags |= FEVAL_NONINT; + result = _evalfile (filename, flags); + free (filename); + return result; +} + +int +force_execute_file (fname, force_noninteractive) + const char *fname; + int force_noninteractive; +{ + char *filename; + int result, flags; + + filename = bash_tilde_expand (fname, 0); + flags = 0; + if (force_noninteractive) + flags |= FEVAL_NONINT; + result = _evalfile (filename, flags); + free (filename); + return result; +} + +#if defined (HISTORY) +int +fc_execute_file (filename) + const char *filename; +{ + int flags; + + /* We want these commands to show up in the history list if + remember_on_history is set. We use FEVAL_BUILTIN to return + the result of parse_and_execute. */ + flags = FEVAL_ENOENTOK|FEVAL_HISTORY|FEVAL_REGFILE|FEVAL_BUILTIN; + return (_evalfile (filename, flags)); +} +#endif /* HISTORY */ + +int +source_file (filename, sflags) + const char *filename; + int sflags; +{ + int flags, rval; + + flags = FEVAL_BUILTIN|FEVAL_UNWINDPROT|FEVAL_NONINT; + if (sflags) + flags |= FEVAL_NOPUSHARGS; + /* POSIX shells exit if non-interactive and file error. */ + if (posixly_correct && interactive_shell == 0 && executing_command_builtin == 0) + flags |= FEVAL_LONGJMP; + rval = _evalfile (filename, flags); + + run_return_trap (); + return rval; +} diff --git a/builtins/evalstring.c b/builtins/evalstring.c new file mode 100644 index 0000000..e221591 --- /dev/null +++ b/builtins/evalstring.c @@ -0,0 +1,687 @@ +/* evalstring.c - evaluate a string as one or more shell commands. */ + +/* Copyright (C) 1996-2015 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 3 of the License, 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. If not, see . +*/ + +#include + +#if defined (HAVE_UNISTD_H) +# ifdef _MINIX +# include +# endif +# include +#endif + +#include +#include + +#include + +#include "filecntl.h" +#include "../bashansi.h" + +#include "../shell.h" +#include "../jobs.h" +#include "../builtins.h" +#include "../flags.h" +#include "../input.h" +#include "../execute_cmd.h" +#include "../redir.h" +#include "../trap.h" +#include "../bashintl.h" + +#include + +#if defined (HISTORY) +# include "../bashhist.h" +#endif + +#include "common.h" +#include "builtext.h" + +#if !defined (errno) +extern int errno; +#endif + +#define IS_BUILTIN(s) (builtin_address_internal(s, 0) != (struct builtin *)NULL) + +extern int indirection_level, subshell_environment; +extern int line_number, line_number_for_err_trap; +extern int current_token, shell_eof_token; +extern int last_command_exit_value; +extern int running_trap; +extern int loop_level; +extern int executing_list; +extern int comsub_ignore_return; +extern int posixly_correct; +extern int return_catch_flag, return_catch_value; +extern sh_builtin_func_t *this_shell_builtin; +extern char *the_printed_command_except_trap; + +int parse_and_execute_level = 0; + +static int cat_file __P((REDIRECT *)); + +#define PE_TAG "parse_and_execute top" +#define PS_TAG "parse_string top" + +#if defined (HISTORY) +static void +set_history_remembering () +{ + remember_on_history = enable_history_list; +} +#endif + +static void +restore_lastcom (x) + char *x; +{ + FREE (the_printed_command_except_trap); + the_printed_command_except_trap = x; +} + +int +should_suppress_fork (command) + COMMAND *command; +{ + return (startup_state == 2 && parse_and_execute_level == 1 && + running_trap == 0 && + *bash_input.location.string == '\0' && + command->type == cm_simple && +#if 0 + signal_is_trapped (EXIT_TRAP) == 0 && + signal_is_trapped (ERROR_TRAP) == 0 && +#else + any_signals_trapped () < 0 && +#endif + command->redirects == 0 && command->value.Simple->redirects == 0 && + ((command->flags & CMD_TIME_PIPELINE) == 0) && + ((command->flags & CMD_INVERT_RETURN) == 0)); +} + +void +optimize_fork (command) + COMMAND *command; +{ + if (command->type == cm_connection && + (command->value.Connection->connector == AND_AND || command->value.Connection->connector == OR_OR) && + should_suppress_fork (command->value.Connection->second)) + { + command->value.Connection->second->flags |= CMD_NO_FORK; + command->value.Connection->second->value.Simple->flags |= CMD_NO_FORK; + } +} + +/* How to force parse_and_execute () to clean up after itself. */ +void +parse_and_execute_cleanup () +{ + if (running_trap) + { + run_trap_cleanup (running_trap - 1); + unfreeze_jobs_list (); + } + + if (have_unwind_protects ()) + run_unwind_frame (PE_TAG); + else + parse_and_execute_level = 0; /* XXX */ +} + +static void +parse_prologue (string, flags, tag) + char *string; + int flags; + char *tag; +{ + char *orig_string, *lastcom; + int x; + + orig_string = string; + /* Unwind protect this invocation of parse_and_execute (). */ + begin_unwind_frame (tag); + unwind_protect_int (parse_and_execute_level); + unwind_protect_jmp_buf (top_level); + unwind_protect_int (indirection_level); + unwind_protect_int (line_number); + unwind_protect_int (line_number_for_err_trap); + unwind_protect_int (loop_level); + unwind_protect_int (executing_list); + unwind_protect_int (comsub_ignore_return); + if (flags & (SEVAL_NONINT|SEVAL_INTERACT)) + unwind_protect_int (interactive); + +#if defined (HISTORY) + if (parse_and_execute_level == 0) + add_unwind_protect (set_history_remembering, (char *)NULL); + else + unwind_protect_int (remember_on_history); /* can be used in scripts */ +# if defined (BANG_HISTORY) + unwind_protect_int (history_expansion_inhibited); +# endif /* BANG_HISTORY */ +#endif /* HISTORY */ + + if (interactive_shell) + { + x = get_current_prompt_level (); + add_unwind_protect (set_current_prompt_level, x); + } + + if (the_printed_command_except_trap) + { + lastcom = savestring (the_printed_command_except_trap); + add_unwind_protect (restore_lastcom, lastcom); + } + + add_unwind_protect (pop_stream, (char *)NULL); + if (parser_expanding_alias ()) + add_unwind_protect (parser_restore_alias, (char *)NULL); + + if (orig_string && ((flags & SEVAL_NOFREE) == 0)) + add_unwind_protect (xfree, orig_string); + end_unwind_frame (); + + if (flags & (SEVAL_NONINT|SEVAL_INTERACT)) + interactive = (flags & SEVAL_NONINT) ? 0 : 1; + +#if defined (HISTORY) + if (flags & SEVAL_NOHIST) + bash_history_disable (); +# if defined (BANG_HISTORY) + if (flags & SEVAL_NOHISTEXP) + history_expansion_inhibited = 1; +# endif /* BANG_HISTORY */ +#endif /* HISTORY */ +} + +/* Parse and execute the commands in STRING. Returns whatever + execute_command () returns. This frees STRING. FLAGS is a + flags word; look in common.h for the possible values. Actions + are: + (flags & SEVAL_NONINT) -> interactive = 0; + (flags & SEVAL_INTERACT) -> interactive = 1; + (flags & SEVAL_NOHIST) -> call bash_history_disable () + (flags & SEVAL_NOFREE) -> don't free STRING when finished + (flags & SEVAL_RESETLINE) -> reset line_number to 1 + (flags & SEVAL_NOHISTEXP) -> history_expansion_inhibited -> 1 +*/ + +int +parse_and_execute (string, from_file, flags) + char *string; + const char *from_file; + int flags; +{ + int code, lreset; + volatile int should_jump_to_top_level, last_result; + COMMAND *volatile command; + volatile sigset_t pe_sigmask; + + parse_prologue (string, flags, PE_TAG); + + parse_and_execute_level++; + + lreset = flags & SEVAL_RESETLINE; + +#if defined (HAVE_POSIX_SIGNALS) + /* If we longjmp and are going to go on, use this to restore signal mask */ + sigemptyset ((sigset_t *)&pe_sigmask); + sigprocmask (SIG_BLOCK, (sigset_t *)NULL, (sigset_t *)&pe_sigmask); +#endif + + /* Reset the line number if the caller wants us to. If we don't reset the + line number, we have to subtract one, because we will add one just + before executing the next command (resetting the line number sets it to + 0; the first line number is 1). */ + push_stream (lreset); + if (parser_expanding_alias ()) + /* push current shell_input_line */ + parser_save_alias (); + + if (lreset == 0) + line_number--; + + indirection_level++; + + code = should_jump_to_top_level = 0; + last_result = EXECUTION_SUCCESS; + + /* We need to reset enough of the token state so we can start fresh. */ + if (current_token == yacc_EOF) + current_token = '\n'; /* reset_parser() ? */ + + with_input_from_string (string, from_file); + clear_shell_input_line (); + while (*(bash_input.location.string)) + { + command = (COMMAND *)NULL; + + if (interrupt_state) + { + last_result = EXECUTION_FAILURE; + break; + } + + /* Provide a location for functions which `longjmp (top_level)' to + jump to. This prevents errors in substitution from restarting + the reader loop directly, for example. */ + code = setjmp_nosigs (top_level); + + if (code) + { + should_jump_to_top_level = 0; + switch (code) + { + case ERREXIT: + /* variable_context -> 0 is what eval.c:reader_loop() does in + these circumstances. Don't bother with cleanup here because + we don't want to run the function execution cleanup stuff + that will cause pop_context and other functions to run. + XXX - change that if we want the function context to be + unwound. */ + if (exit_immediately_on_error && variable_context) + { + discard_unwind_frame ("pe_dispose"); + variable_context = 0; /* not in a function */ + } + should_jump_to_top_level = 1; + goto out; + case FORCE_EOF: + case EXITPROG: + if (command) + run_unwind_frame ("pe_dispose"); + /* Remember to call longjmp (top_level) after the old + value for it is restored. */ + should_jump_to_top_level = 1; + goto out; + + case DISCARD: + if (command) + run_unwind_frame ("pe_dispose"); + last_result = last_command_exit_value = EXECUTION_FAILURE; /* XXX */ + if (subshell_environment) + { + should_jump_to_top_level = 1; + goto out; + } + else + { +#if 0 + dispose_command (command); /* pe_dispose does this */ +#endif +#if defined (HAVE_POSIX_SIGNALS) + sigprocmask (SIG_SETMASK, (sigset_t *)&pe_sigmask, (sigset_t *)NULL); +#endif + continue; + } + + default: + command_error ("parse_and_execute", CMDERR_BADJUMP, code, 0); + break; + } + } + + if (parse_command () == 0) + { + if ((flags & SEVAL_PARSEONLY) || (interactive_shell == 0 && read_but_dont_execute)) + { + last_result = EXECUTION_SUCCESS; + dispose_command (global_command); + global_command = (COMMAND *)NULL; + } + else if (command = global_command) + { + struct fd_bitmap *bitmap; + + if (flags & SEVAL_FUNCDEF) + { + char *x; + + /* If the command parses to something other than a straight + function definition, or if we have not consumed the entire + string, or if the parser has transformed the function + name (as parsing will if it begins or ends with shell + whitespace, for example), reject the attempt */ + if (command->type != cm_function_def || + ((x = parser_remaining_input ()) && *x) || + (STREQ (from_file, command->value.Function_def->name->word) == 0)) + { + internal_warning (_("%s: ignoring function definition attempt"), from_file); + should_jump_to_top_level = 0; + last_result = last_command_exit_value = EX_BADUSAGE; + reset_parser (); + break; + } + } + + bitmap = new_fd_bitmap (FD_BITMAP_SIZE); + begin_unwind_frame ("pe_dispose"); + add_unwind_protect (dispose_fd_bitmap, bitmap); + add_unwind_protect (dispose_command, command); /* XXX */ + + global_command = (COMMAND *)NULL; + + if ((subshell_environment & SUBSHELL_COMSUB) && comsub_ignore_return) + command->flags |= CMD_IGNORE_RETURN; + +#if defined (ONESHOT) + /* + * IF + * we were invoked as `bash -c' (startup_state == 2) AND + * parse_and_execute has not been called recursively AND + * we're not running a trap AND + * we have parsed the full command (string == '\0') AND + * we're not going to run the exit trap AND + * we have a simple command without redirections AND + * the command is not being timed AND + * the command's return status is not being inverted AND + * there aren't any traps in effect + * THEN + * tell the execution code that we don't need to fork + */ + if (should_suppress_fork (command)) + { + command->flags |= CMD_NO_FORK; + command->value.Simple->flags |= CMD_NO_FORK; + } + else if (command->type == cm_connection) + optimize_fork (command); +#endif /* ONESHOT */ + + /* See if this is a candidate for $( type == cm_simple && !command->redirects && + (command->flags & CMD_TIME_PIPELINE) == 0 && + command->value.Simple->words == 0 && + command->value.Simple->redirects && + command->value.Simple->redirects->next == 0 && + command->value.Simple->redirects->instruction == r_input_direction && + command->value.Simple->redirects->redirector.dest == 0) + { + int r; + r = cat_file (command->value.Simple->redirects); + last_result = (r < 0) ? EXECUTION_FAILURE : EXECUTION_SUCCESS; + } + else + last_result = execute_command_internal + (command, 0, NO_PIPE, NO_PIPE, bitmap); + dispose_command (command); + dispose_fd_bitmap (bitmap); + discard_unwind_frame ("pe_dispose"); + + if (flags & SEVAL_ONECMD) + { + reset_parser (); + break; + } + } + } + else + { + last_result = EXECUTION_FAILURE; + + if (interactive_shell == 0 && this_shell_builtin && + (this_shell_builtin == source_builtin || this_shell_builtin == eval_builtin) && + last_command_exit_value == EX_BADSYNTAX && posixly_correct) + { + should_jump_to_top_level = 1; + code = ERREXIT; + last_command_exit_value = EX_BADUSAGE; + } + + /* Since we are shell compatible, syntax errors in a script + abort the execution of the script. Right? */ + break; + } + } + + out: + + run_unwind_frame (PE_TAG); + + if (interrupt_state && parse_and_execute_level == 0) + { + /* An interrupt during non-interactive execution in an + interactive shell (e.g. via $PROMPT_COMMAND) should + not cause the shell to exit. */ + interactive = interactive_shell; + throw_to_top_level (); + } + + if (should_jump_to_top_level) + jump_to_top_level (code); + + return (last_result); +} + +/* Parse a command contained in STRING according to FLAGS and return the + number of characters consumed from the string. If non-NULL, set *ENDP + to the position in the string where the parse ended. Used to validate + command substitutions during parsing to obey Posix rules about finding + the end of the command and balancing parens. */ +int +parse_string (string, from_file, flags, endp) + char *string; + const char *from_file; + int flags; + char **endp; +{ + int code, nc; + volatile int should_jump_to_top_level; + COMMAND *volatile command, *oglobal; + char *ostring; + volatile sigset_t ps_sigmask; + + parse_prologue (string, flags, PS_TAG); + +#if defined (HAVE_POSIX_SIGNALS) + /* If we longjmp and are going to go on, use this to restore signal mask */ + sigemptyset ((sigset_t *)&ps_sigmask); + sigprocmask (SIG_BLOCK, (sigset_t *)NULL, (sigset_t *)&ps_sigmask); +#endif + +/*itrace("parse_string: `%s'", string);*/ + /* Reset the line number if the caller wants us to. If we don't reset the + line number, we have to subtract one, because we will add one just + before executing the next command (resetting the line number sets it to + 0; the first line number is 1). */ + push_stream (0); + if (parser_expanding_alias ()) + /* push current shell_input_line */ + parser_save_alias (); + + code = should_jump_to_top_level = 0; + oglobal = global_command; + ostring = string; + + with_input_from_string (string, from_file); + while (*(bash_input.location.string)) + { + command = (COMMAND *)NULL; + +#if 0 + if (interrupt_state) + break; +#endif + + /* Provide a location for functions which `longjmp (top_level)' to + jump to. */ + code = setjmp_nosigs (top_level); + + if (code) + { +#if defined (DEBUG) +itrace("parse_string: longjmp executed: code = %d", code); +#endif + should_jump_to_top_level = 0; + switch (code) + { + case FORCE_EOF: + case ERREXIT: + case EXITPROG: + case DISCARD: /* XXX */ + if (command) + dispose_command (command); + /* Remember to call longjmp (top_level) after the old + value for it is restored. */ + should_jump_to_top_level = 1; + goto out; + + default: +#if defined (HAVE_POSIX_SIGNALS) + sigprocmask (SIG_SETMASK, (sigset_t *)&ps_sigmask, (sigset_t *)NULL); +#endif + command_error ("parse_string", CMDERR_BADJUMP, code, 0); + break; + } + } + + if (parse_command () == 0) + { + dispose_command (global_command); + global_command = (COMMAND *)NULL; + } + else + { + if ((flags & SEVAL_NOLONGJMP) == 0) + { + should_jump_to_top_level = 1; + code = DISCARD; + } + else + reset_parser (); /* XXX - sets token_to_read */ + break; + } + + if (current_token == yacc_EOF || current_token == shell_eof_token) + break; + } + + out: + + global_command = oglobal; + nc = bash_input.location.string - ostring; + if (endp) + *endp = bash_input.location.string; + + run_unwind_frame (PS_TAG); + + /* If we return < 0, the caller (xparse_dolparen) will jump_to_top_level for + us, after doing cleanup */ + if (should_jump_to_top_level) + { + if (parse_and_execute_level == 0) + top_level_cleanup (); + if (code == DISCARD) + return -DISCARD; + jump_to_top_level (code); + } + + return (nc); +} + +/* Handle a $( < file ) command substitution. This expands the filename, + returning errors as appropriate, then just cats the file to the standard + output. */ +static int +cat_file (r) + REDIRECT *r; +{ + char *fn; + int fd, rval; + + if (r->instruction != r_input_direction) + return -1; + + /* Get the filename. */ + if (posixly_correct && !interactive_shell) + disallow_filename_globbing++; + fn = redirection_expand (r->redirectee.filename); + if (posixly_correct && !interactive_shell) + disallow_filename_globbing--; + + if (fn == 0) + { + redirection_error (r, AMBIGUOUS_REDIRECT); + return -1; + } + + fd = open(fn, O_RDONLY); + if (fd < 0) + { + file_error (fn); + free (fn); + return -1; + } + + rval = zcatfd (fd, 1, fn); + + free (fn); + close (fd); + + return (rval); +} + +int +evalstring (string, from_file, flags) + char *string; + const char *from_file; + int flags; +{ + volatile int r, rflag, rcatch; + + rcatch = 0; + rflag = return_catch_flag; + /* If we are in a place where `return' is valid, we have to catch + `eval "... return"' and make sure parse_and_execute cleans up. Then + we can trampoline to the previous saved return_catch location. */ + if (rflag) + { + begin_unwind_frame ("evalstring"); + + unwind_protect_int (return_catch_flag); + unwind_protect_jmp_buf (return_catch); + + return_catch_flag++; /* increment so we have a counter */ + rcatch = setjmp_nosigs (return_catch); + } + + if (rcatch) + { + parse_and_execute_cleanup (); + r = return_catch_value; + } + else + /* Note that parse_and_execute () frees the string it is passed. */ + r = parse_and_execute (string, from_file, flags); + + if (rflag) + { + run_unwind_frame ("evalstring"); + if (rcatch && return_catch_flag) + { + return_catch_value = r; + sh_longjmp (return_catch, 1); + } + } + + return (r); +} diff --git a/builtins/exec.def b/builtins/exec.def new file mode 100644 index 0000000..7d7edce --- /dev/null +++ b/builtins/exec.def @@ -0,0 +1,262 @@ +This file is exec.def, from which is created exec.c. +It implements the builtin "exec" in Bash. + +Copyright (C) 1987-2015 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 3 of the License, 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. If not, see . + +$PRODUCES exec.c + +$BUILTIN exec +$FUNCTION exec_builtin +$SHORT_DOC exec [-cl] [-a name] [command [arguments ...]] [redirection ...] +Replace the shell with the given command. + +Execute COMMAND, replacing this shell with the specified program. +ARGUMENTS become the arguments to COMMAND. If COMMAND is not specified, +any redirections take effect in the current shell. + +Options: + -a name pass NAME as the zeroth argument to COMMAND + -c execute COMMAND with an empty environment + -l place a dash in the zeroth argument to COMMAND + +If the command cannot be executed, a non-interactive shell exits, unless +the shell option `execfail' is set. + +Exit Status: +Returns success unless COMMAND is not found or a redirection error occurs. +$END + +#include + +#include "../bashtypes.h" +#include "posixstat.h" +#include +#include + +#if defined (HAVE_UNISTD_H) +# include +#endif + +#include "../bashansi.h" +#include "../bashintl.h" + +#include "../shell.h" +#include "../execute_cmd.h" +#include "../findcmd.h" +#if defined (JOB_CONTROL) +# include "../jobs.h" +#endif +#include "../flags.h" +#include "../trap.h" +#if defined (HISTORY) +# include "../bashhist.h" +#endif +#include "common.h" +#include "bashgetopt.h" + +/* Not all systems declare ERRNO in errno.h... and some systems #define it! */ +#if !defined (errno) +extern int errno; +#endif /* !errno */ + +extern int subshell_environment; +extern REDIRECT *redirection_undo_list; +extern char *exec_argv0; + +int no_exit_on_failed_exec; + +/* If the user wants this to look like a login shell, then + prepend a `-' onto NAME and return the new name. */ +static char * +mkdashname (name) + char *name; +{ + char *ret; + + ret = (char *)xmalloc (2 + strlen (name)); + ret[0] = '-'; + strcpy (ret + 1, name); + return ret; +} + +int +exec_builtin (list) + WORD_LIST *list; +{ + int exit_value = EXECUTION_FAILURE; + int cleanenv, login, opt; + char *argv0, *command, **args, **env, *newname, *com2; + + cleanenv = login = 0; + exec_argv0 = argv0 = (char *)NULL; + + reset_internal_getopt (); + while ((opt = internal_getopt (list, "cla:")) != -1) + { + switch (opt) + { + case 'c': + cleanenv = 1; + break; + case 'l': + login = 1; + break; + case 'a': + argv0 = list_optarg; + break; + CASE_HELPOPT; + default: + builtin_usage (); + return (EX_USAGE); + } + } + list = loptend; + + /* First, let the redirections remain. */ + dispose_redirects (redirection_undo_list); + redirection_undo_list = (REDIRECT *)NULL; + + if (list == 0) + return (EXECUTION_SUCCESS); + +#if defined (RESTRICTED_SHELL) + if (restricted) + { + sh_restricted ((char *)NULL); + return (EXECUTION_FAILURE); + } +#endif /* RESTRICTED_SHELL */ + + args = strvec_from_word_list (list, 1, 0, (int *)NULL); + env = (char **)0; + + /* A command with a slash anywhere in its name is not looked up in $PATH. */ + command = absolute_program (args[0]) ? args[0] : search_for_command (args[0], 1); + + if (command == 0) + { + if (file_isdir (args[0])) + { +#if defined (EISDIR) + builtin_error (_("%s: cannot execute: %s"), args[0], strerror (EISDIR)); +#else + builtin_error (_("%s: cannot execute: %s"), args[0], strerror (errno)); +#endif + exit_value = EX_NOEXEC; + } + else + { + sh_notfound (args[0]); + exit_value = EX_NOTFOUND; /* As per Posix.2, 3.14.6 */ + } + goto failed_exec; + } + + com2 = full_pathname (command); + if (com2) + { + if (command != args[0]) + free (command); + command = com2; + } + + if (argv0) + { + free (args[0]); + args[0] = login ? mkdashname (argv0) : savestring (argv0); + exec_argv0 = savestring (args[0]); + } + else if (login) + { + newname = mkdashname (args[0]); + free (args[0]); + args[0] = newname; + } + + /* Decrement SHLVL by 1 so a new shell started here has the same value, + preserving the appearance. After we do that, we need to change the + exported environment to include the new value. */ + if (cleanenv == 0) + adjust_shell_level (-1); + + if (cleanenv) + { + env = strvec_create (1); + env[0] = (char *)0; + } + else + { + maybe_make_export_env (); + env = export_env; + } + +#if defined (HISTORY) + if (interactive_shell && subshell_environment == 0) + maybe_save_shell_history (); +#endif /* HISTORY */ + + restore_original_signals (); + +#if defined (JOB_CONTROL) + if (subshell_environment == 0) + end_job_control (); + if (interactive || job_control) + default_tty_job_signals (); /* undo initialize_job_signals */ +#endif /* JOB_CONTROL */ + + exit_value = shell_execve (command, args, env); + + /* We have to set this to NULL because shell_execve has called realloc() + to stuff more items at the front of the array, which may have caused + the memory to be freed by realloc(). We don't want to free it twice. */ + args = (char **)NULL; + if (cleanenv == 0) + adjust_shell_level (1); + + if (exit_value == EX_NOTFOUND) /* no duplicate error message */ + goto failed_exec; + else if (executable_file (command) == 0) + { + builtin_error (_("%s: cannot execute: %s"), command, strerror (errno)); + exit_value = EX_NOEXEC; /* As per Posix.2, 3.14.6 */ + } + else + file_error (command); + +failed_exec: + FREE (command); + + if (subshell_environment || (interactive == 0 && no_exit_on_failed_exec == 0)) + exit_shell (exit_value); + + if (args) + strvec_dispose (args); + + if (env && env != export_env) + strvec_dispose (env); + + initialize_traps (); + initialize_signals (1); + +#if defined (JOB_CONTROL) + if (interactive_shell || job_control) + restart_job_control (); +#endif /* JOB_CONTROL */ + + return (exit_value); +} diff --git a/builtins/exit.def b/builtins/exit.def new file mode 100644 index 0000000..f28c234 --- /dev/null +++ b/builtins/exit.def @@ -0,0 +1,172 @@ +This file is exit.def, from which is created exit.c. +It implements the builtins "exit", and "logout" in Bash. + +Copyright (C) 1987-2009 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 3 of the License, 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. If not, see . + +$PRODUCES exit.c + +$BUILTIN exit +$FUNCTION exit_builtin +$SHORT_DOC exit [n] +Exit the shell. + +Exits the shell with a status of N. If N is omitted, the exit status +is that of the last command executed. +$END + +#include + +#include "../bashtypes.h" +#include + +#if defined (HAVE_UNISTD_H) +# include +#endif + +#include "../bashintl.h" + +#include "../shell.h" +#include "../jobs.h" + +#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; +extern sh_builtin_func_t *this_shell_builtin; +extern sh_builtin_func_t *last_shell_builtin; + +static int exit_or_logout __P((WORD_LIST *)); +static int sourced_logout; + +int +exit_builtin (list) + WORD_LIST *list; +{ + CHECK_HELPOPT (list); + + if (interactive) + { + fprintf (stderr, login_shell ? _("logout\n") : "exit\n"); + fflush (stderr); + } + + return (exit_or_logout (list)); +} + +$BUILTIN logout +$FUNCTION logout_builtin +$SHORT_DOC logout [n] +Exit a login shell. + +Exits a login shell with exit status N. Returns an error if not executed +in a login shell. +$END + +/* How to logout. */ +int +logout_builtin (list) + WORD_LIST *list; +{ + CHECK_HELPOPT (list); + + if (login_shell == 0 /* && interactive */) + { + builtin_error (_("not login shell: use `exit'")); + return (EXECUTION_FAILURE); + } + else + return (exit_or_logout (list)); +} + +static int +exit_or_logout (list) + WORD_LIST *list; +{ + int exit_value; + +#if defined (JOB_CONTROL) + int exit_immediate_okay, stopmsg; + + exit_immediate_okay = (interactive == 0 || + last_shell_builtin == exit_builtin || + last_shell_builtin == logout_builtin || + last_shell_builtin == jobs_builtin); + + /* Check for stopped jobs if the user wants to. */ + if (exit_immediate_okay == 0) + { + register int i; + for (i = stopmsg = 0; i < js.j_jobslots; i++) + if (jobs[i] && STOPPED (i)) + stopmsg = JSTOPPED; + else if (check_jobs_at_exit && stopmsg == 0 && jobs[i] && 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 */ + + /* Get return value if present. This means that you can type + `logout 5' to a shell, and it returns 5. */ + + /* If we're running the exit trap (running_trap == 1, since running_trap + gets set to SIG+1), and we don't have a argument given to `exit' + (list == 0), use the exit status we saved before running the trap + commands (trap_saved_exit_value). */ + exit_value = (running_trap == 1 && list == 0) ? trap_saved_exit_value : get_exitstat (list); + + bash_logout (); + + last_command_exit_value = exit_value; + + /* Exit the program. */ + jump_to_top_level (EXITPROG); + /*NOTREACHED*/ +} + +void +bash_logout () +{ + /* Run our `~/.bash_logout' file if it exists, and this is a login shell. */ + if (login_shell && sourced_logout++ == 0 && subshell_environment == 0) + { + maybe_execute_file ("~/.bash_logout", 1); +#ifdef SYS_BASH_LOGOUT + maybe_execute_file (SYS_BASH_LOGOUT, 1); +#endif + } +} diff --git a/builtins/fc.def b/builtins/fc.def new file mode 100644 index 0000000..fe16471 --- /dev/null +++ b/builtins/fc.def @@ -0,0 +1,711 @@ +This file is fc.def, from which is created fc.c. +It implements the builtin "fc" in Bash. + +Copyright (C) 1987-2015 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 3 of the License, 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. If not, see . + +$PRODUCES fc.c + +$BUILTIN fc +$FUNCTION fc_builtin +$DEPENDS_ON HISTORY +$SHORT_DOC fc [-e ename] [-lnr] [first] [last] or fc -s [pat=rep] [command] +Display or execute commands from the history list. + +fc is used to list or edit and re-execute commands from the history list. +FIRST and LAST can be numbers specifying the range, or FIRST can be a +string, which means the most recent command beginning with that +string. + +Options: + -e ENAME select which editor to use. Default is FCEDIT, then EDITOR, + then vi + -l list lines instead of editing + -n omit line numbers when listing + -r reverse the order of the lines (newest listed first) + +With the `fc -s [pat=rep ...] [command]' format, COMMAND is +re-executed after the substitution OLD=NEW is performed. + +A useful alias to use with this is r='fc -s', so that typing `r cc' +runs the last command beginning with `cc' and typing `r' re-executes +the last command. + +Exit Status: +Returns success or status of executed command; non-zero if an error occurs. +$END + +#include + +#if defined (HISTORY) +#if defined (HAVE_SYS_PARAM_H) +# include +#endif +#include "../bashtypes.h" +#include "posixstat.h" +#if ! defined(_MINIX) && defined (HAVE_SYS_FILE_H) +# include +#endif + +#if defined (HAVE_UNISTD_H) +# include +#endif + +#include +#include + +#include "../bashansi.h" +#include "../bashintl.h" +#include + +#include "../shell.h" +#include "../builtins.h" +#include "../flags.h" +#include "../bashhist.h" +#include "maxpath.h" +#include +#include "bashgetopt.h" +#include "common.h" + +#if !defined (errno) +extern int errno; +#endif /* !errno */ + +extern int current_command_line_count; +extern int literal_history; +extern int posixly_correct; +extern int subshell_environment, interactive_shell; + +extern int unlink __P((const char *)); + +extern FILE *sh_mktmpfp __P((char *, int, char **)); + +/* **************************************************************** */ +/* */ +/* The K*rn shell style fc command (Fix Command) */ +/* */ +/* **************************************************************** */ + +/* fc builtin command (fix command) for Bash for those who + like K*rn-style history better than csh-style. + + fc [-e ename] [-nlr] [first] [last] + + FIRST and LAST can be numbers specifying the range, or FIRST can be + a string, which means the most recent command beginning with that + string. + + -e ENAME selects which editor to use. Default is FCEDIT, then EDITOR, + then the editor which corresponds to the current readline editing + mode, then vi. + + -l means list lines instead of editing. + -n means no line numbers listed. + -r means reverse the order of the lines (making it newest listed first). + + fc -e - [pat=rep ...] [command] + fc -s [pat=rep ...] [command] + + Equivalent to !command:sg/pat/rep execpt there can be multiple PAT=REP's. +*/ + +/* Data structure describing a list of global replacements to perform. */ +typedef struct repl { + struct repl *next; + char *pat; + char *rep; +} REPL; + +/* Accessors for HIST_ENTRY lists that are called HLIST. */ +#define histline(i) (hlist[(i)]->line) +#define histdata(i) (hlist[(i)]->data) + +#define FREE_RLIST() \ + do { \ + for (rl = rlist; rl; ) { \ + REPL *r; \ + r = rl->next; \ + if (rl->pat) \ + free (rl->pat); \ + if (rl->rep) \ + free (rl->rep); \ + free (rl); \ + rl = r; \ + } \ + } while (0) + +static char *fc_dosubs __P((char *, REPL *)); +static char *fc_gethist __P((char *, HIST_ENTRY **)); +static int fc_gethnum __P((char *, HIST_ENTRY **)); +static int fc_number __P((WORD_LIST *)); +static void fc_replhist __P((char *)); +#ifdef INCLUDE_UNUSED +static char *fc_readline __P((FILE *)); +static void fc_addhist __P((char *)); +#endif + +static void +set_verbose_flag () +{ + echo_input_at_read = verbose_flag; +} + +/* String to execute on a file that we want to edit. */ +#define FC_EDIT_COMMAND "${FCEDIT:-${EDITOR:-vi}}" +#if defined (STRICT_POSIX) +# define POSIX_FC_EDIT_COMMAND "${FCEDIT:-ed}" +#else +# define POSIX_FC_EDIT_COMMAND "${FCEDIT:-${EDITOR:-ed}}" +#endif + +int +fc_builtin (list) + WORD_LIST *list; +{ + register int i; + register char *sep; + int numbering, reverse, listing, execute; + int histbeg, histend, last_hist, retval, opt, rh, real_last; + FILE *stream; + REPL *rlist, *rl; + char *ename, *command, *newcom, *fcedit; + HIST_ENTRY **hlist; + char *fn; + + numbering = 1; + reverse = listing = execute = 0; + ename = (char *)NULL; + + /* Parse out the options and set which of the two forms we're in. */ + reset_internal_getopt (); + lcurrent = list; /* XXX */ + while (fc_number (loptend = lcurrent) == 0 && + (opt = internal_getopt (list, ":e:lnrs")) != -1) + { + switch (opt) + { + case 'n': + numbering = 0; + break; + + case 'l': + listing = 1; + break; + + case 'r': + reverse = 1; + break; + + case 's': + execute = 1; + break; + + case 'e': + ename = list_optarg; + break; + + CASE_HELPOPT; + default: + builtin_usage (); + return (EX_USAGE); + } + } + + list = loptend; + + if (ename && (*ename == '-') && (ename[1] == '\0')) + execute = 1; + + /* The "execute" form of the command (re-run, with possible string + substitutions). */ + if (execute) + { + rlist = (REPL *)NULL; + while (list && ((sep = (char *)strchr (list->word->word, '=')) != NULL)) + { + *sep++ = '\0'; + rl = (REPL *)xmalloc (sizeof (REPL)); + rl->next = (REPL *)NULL; + rl->pat = savestring (list->word->word); + rl->rep = savestring (sep); + + if (rlist == NULL) + rlist = rl; + else + { + rl->next = rlist; + rlist = rl; + } + list = list->next; + } + + /* If we have a list of substitutions to do, then reverse it + to get the replacements in the proper order. */ + + rlist = REVERSE_LIST (rlist, REPL *); + + hlist = history_list (); + + /* If we still have something in list, it is a command spec. + Otherwise, we use the most recent command in time. */ + command = fc_gethist (list ? list->word->word : (char *)NULL, hlist); + + if (command == NULL) + { + builtin_error (_("no command found")); + if (rlist) + FREE_RLIST (); + + return (EXECUTION_FAILURE); + } + + if (rlist) + { + newcom = fc_dosubs (command, rlist); + free (command); + FREE_RLIST (); + command = newcom; + } + + fprintf (stderr, "%s\n", command); + fc_replhist (command); /* replace `fc -s' with command */ + /* Posix says that the re-executed commands should be entered into the + history. */ + return (parse_and_execute (command, "fc", SEVAL_NOHIST)); + } + + /* This is the second form of the command (the list-or-edit-and-rerun + form). */ + hlist = history_list (); + if (hlist == 0) + return (EXECUTION_SUCCESS); + for (i = 0; hlist[i]; i++); + + /* With the Bash implementation of history, the current command line + ("fc blah..." and so on) is already part of the history list by + the time we get to this point. This just skips over that command + and makes the last command that this deals with be the last command + the user entered before the fc. We need to check whether the + line was actually added (HISTIGNORE may have caused it to not be), + so we check hist_last_line_added. */ + + /* Even though command substitution through parse_and_execute turns off + remember_on_history, command substitution in a shell when set -o history + has been enabled (interactive or not) should use it in the last_hist + calculation as if it were on. */ + rh = remember_on_history || ((subshell_environment & SUBSHELL_COMSUB) && enable_history_list); + last_hist = i - rh - hist_last_line_added; + + /* Make sure that real_last is calculated the same way here and in + fc_gethnum. The return value from fc_gethnum is treated specially if + it is == real_last and we are listing commands. */ + real_last = i; + /* back up from the end to the last non-null history entry */ + while (hlist[real_last] == 0 && real_last > 0) + real_last--; + + /* XXX */ + if (i == last_hist && hlist[last_hist] == 0) + while (last_hist >= 0 && hlist[last_hist] == 0) + last_hist--; + if (last_hist < 0) + { + sh_erange ((char *)NULL, _("history specification")); + return (EXECUTION_FAILURE); + } + + if (list) + { + histbeg = fc_gethnum (list->word->word, hlist); + list = list->next; + + if (list) + histend = fc_gethnum (list->word->word, hlist); + else if (histbeg == real_last) + histend = listing ? real_last : histbeg; + else + histend = listing ? last_hist : histbeg; + } + else + { + /* The default for listing is the last 16 history items. */ + if (listing) + { + histend = last_hist; + histbeg = histend - 16 + 1; /* +1 because loop below uses >= */ + if (histbeg < 0) + histbeg = 0; + } + else + /* For editing, it is the last history command. */ + histbeg = histend = last_hist; + } + + /* "When not listing, the fc command that caused the editing shall not be + entered into the history list." */ + if (listing == 0 && hist_last_line_added) + { + bash_delete_last_history (); + /* If we're editing a single command -- the last command in the + history -- and we just removed the dummy command added by + edit_and_execute_command (), we need to check whether or not we + just removed the last command in the history and need to back + the pointer up. remember_on_history is off because we're running + in parse_and_execute(). */ + if (histbeg == histend && histend == last_hist && hlist[last_hist] == 0) + last_hist = histbeg = --histend; + } + + /* We print error messages for line specifications out of range. */ + if ((histbeg < 0) || (histend < 0)) + { + sh_erange ((char *)NULL, _("history specification")); + return (EXECUTION_FAILURE); + } + + if (histend < histbeg) + { + i = histend; + histend = histbeg; + histbeg = i; + + reverse = 1; + } + + if (listing) + stream = stdout; + else + { + numbering = 0; + stream = sh_mktmpfp ("bash-fc", MT_USERANDOM|MT_USETMPDIR, &fn); + if (stream == 0) + { + builtin_error (_("%s: cannot open temp file: %s"), fn ? fn : "", strerror (errno)); + FREE (fn); + return (EXECUTION_FAILURE); + } + } + + for (i = reverse ? histend : histbeg; reverse ? i >= histbeg : i <= histend; reverse ? i-- : i++) + { + QUIT; + if (numbering) + fprintf (stream, "%d", i + history_base); + if (listing) + { + if (posixly_correct) + fputs ("\t", stream); + else + fprintf (stream, "\t%c", histdata (i) ? '*' : ' '); + } + fprintf (stream, "%s\n", histline (i)); + } + + if (listing) + return (sh_chkwrite (EXECUTION_SUCCESS)); + + fflush (stream); + if (ferror (stream)) + { + sh_wrerror (); + fclose (stream); + return (EXECUTION_FAILURE); + } + fclose (stream); + + /* Now edit the file of commands. */ + if (ename) + { + command = (char *)xmalloc (strlen (ename) + strlen (fn) + 2); + sprintf (command, "%s %s", ename, fn); + } + else + { + fcedit = posixly_correct ? POSIX_FC_EDIT_COMMAND : FC_EDIT_COMMAND; + command = (char *)xmalloc (3 + strlen (fcedit) + strlen (fn)); + sprintf (command, "%s %s", fcedit, fn); + } + retval = parse_and_execute (command, "fc", SEVAL_NOHIST); + if (retval != EXECUTION_SUCCESS) + { + unlink (fn); + free (fn); + return (EXECUTION_FAILURE); + } + +#if defined (READLINE) + /* If we're executing as part of a dispatched readline commnand like + {emacs,vi}_edit_and_execute_command, the readline state will indicate it. + We could remove the partial command from the history, but ksh93 doesn't + so we stay compatible. */ +#endif + + /* Make sure parse_and_execute doesn't turn this off, even though a + call to parse_and_execute farther up the function call stack (e.g., + if this is called by vi_edit_and_execute_command) may have already + called bash_history_disable. */ + remember_on_history = 1; + + /* Turn on the `v' flag while fc_execute_file runs so the commands + will be echoed as they are read by the parser. */ + begin_unwind_frame ("fc builtin"); + add_unwind_protect ((Function *)xfree, fn); + add_unwind_protect (unlink, fn); + add_unwind_protect (set_verbose_flag, (char *)NULL); + echo_input_at_read = 1; + + retval = fc_execute_file (fn); + run_unwind_frame ("fc builtin"); + + return (retval); +} + +/* Return 1 if LIST->word->word is a legal number for fc's use. */ +static int +fc_number (list) + WORD_LIST *list; +{ + char *s; + + if (list == 0) + return 0; + s = list->word->word; + if (*s == '-') + s++; + return (legal_number (s, (intmax_t *)NULL)); +} + +/* Return an absolute index into HLIST which corresponds to COMMAND. If + COMMAND is a number, then it was specified in relative terms. If it + is a string, then it is the start of a command line present in HLIST. */ +static int +fc_gethnum (command, hlist) + char *command; + HIST_ENTRY **hlist; +{ + int sign, n, clen, rh; + register int i, j, last_hist, real_last; + register char *s; + + sign = 1; + /* Count history elements. */ + for (i = 0; hlist[i]; i++); + + /* With the Bash implementation of history, the current command line + ("fc blah..." and so on) is already part of the history list by + the time we get to this point. This just skips over that command + and makes the last command that this deals with be the last command + the user entered before the fc. We need to check whether the + line was actually added (HISTIGNORE may have caused it to not be), + so we check hist_last_line_added. This needs to agree with the + calculation of last_hist in fc_builtin above. */ + /* Even though command substitution through parse_and_execute turns off + remember_on_history, command substitution in a shell when set -o history + has been enabled (interactive or not) should use it in the last_hist + calculation as if it were on. */ + rh = remember_on_history || ((subshell_environment & SUBSHELL_COMSUB) && enable_history_list); + last_hist = i - rh - hist_last_line_added; + + if (i == last_hist && hlist[last_hist] == 0) + while (last_hist >= 0 && hlist[last_hist] == 0) + last_hist--; + if (last_hist < 0) + return (-1); + + real_last = i; + i = last_hist; + + /* No specification defaults to most recent command. */ + if (command == NULL) + return (i); + + /* back up from the end to the last non-null history entry */ + while (hlist[real_last] == 0 && real_last > 0) + real_last--; + + /* Otherwise, there is a specification. It can be a number relative to + the current position, or an absolute history number. */ + s = command; + + /* Handle possible leading minus sign. */ + if (s && (*s == '-')) + { + sign = -1; + s++; + } + + if (s && DIGIT(*s)) + { + n = atoi (s); + n *= sign; + + /* If the value is negative or zero, then it is an offset from + the current history item. */ + if (n < 0) + { + n += i + 1; + return (n < 0 ? 0 : n); + } + else if (n == 0) + return ((sign == -1) ? real_last : i); + else + { + n -= history_base; + return (i < n ? i : n); + } + } + + clen = strlen (command); + for (j = i; j >= 0; j--) + { + if (STREQN (command, histline (j), clen)) + return (j); + } + return (-1); +} + +/* Locate the most recent history line which begins with + COMMAND in HLIST, and return a malloc()'ed copy of it. */ +static char * +fc_gethist (command, hlist) + char *command; + HIST_ENTRY **hlist; +{ + int i; + + if (hlist == 0) + return ((char *)NULL); + + i = fc_gethnum (command, hlist); + + if (i >= 0) + return (savestring (histline (i))); + else + return ((char *)NULL); +} + +#ifdef INCLUDE_UNUSED +/* Read the edited history lines from STREAM and return them + one at a time. This can read unlimited length lines. The + caller should free the storage. */ +static char * +fc_readline (stream) + FILE *stream; +{ + register int c; + int line_len = 0, lindex = 0; + char *line = (char *)NULL; + + while ((c = getc (stream)) != EOF) + { + if ((lindex + 2) >= line_len) + line = (char *)xrealloc (line, (line_len += 128)); + + if (c == '\n') + { + line[lindex++] = '\n'; + line[lindex++] = '\0'; + return (line); + } + else + line[lindex++] = c; + } + + if (!lindex) + { + if (line) + free (line); + + return ((char *)NULL); + } + + if (lindex + 2 >= line_len) + line = (char *)xrealloc (line, lindex + 3); + + line[lindex++] = '\n'; /* Finish with newline if none in file */ + line[lindex++] = '\0'; + return (line); +} +#endif + +/* Perform the SUBS on COMMAND. + SUBS is a list of substitutions, and COMMAND is a simple string. + Return a pointer to a malloc'ed string which contains the substituted + command. */ +static char * +fc_dosubs (command, subs) + char *command; + REPL *subs; +{ + register char *new, *t; + register REPL *r; + + for (new = savestring (command), r = subs; r; r = r->next) + { + t = strsub (new, r->pat, r->rep, 1); + free (new); + new = t; + } + return (new); +} + +/* Use `command' to replace the last entry in the history list, which, + by this time, is `fc blah...'. The intent is that the new command + become the history entry, and that `fc' should never appear in the + history list. This way you can do `r' to your heart's content. */ +static void +fc_replhist (command) + char *command; +{ + int n; + + if (command == 0 || *command == '\0') + return; + + n = strlen (command); + if (command[n - 1] == '\n') + command[n - 1] = '\0'; + + if (command && *command) + { + bash_delete_last_history (); + maybe_add_history (command); /* Obeys HISTCONTROL setting. */ + } +} + +#ifdef INCLUDE_UNUSED +/* Add LINE to the history, after removing a single trailing newline. */ +static void +fc_addhist (line) + char *line; +{ + register int n; + + if (line == 0 || *line == 0) + return; + + n = strlen (line); + + if (line[n - 1] == '\n') + line[n - 1] = '\0'; + + if (line && *line) + maybe_add_history (line); /* Obeys HISTCONTROL setting. */ +} +#endif + +#endif /* HISTORY */ diff --git a/builtins/fg_bg.def b/builtins/fg_bg.def new file mode 100644 index 0000000..1565e0a --- /dev/null +++ b/builtins/fg_bg.def @@ -0,0 +1,190 @@ +This file is fg_bg.def, from which is created fg_bg.c. +It implements the builtins "bg" and "fg" in Bash. + +Copyright (C) 1987-2009 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 3 of the License, 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. If not, see . + +$PRODUCES fg_bg.c + +$BUILTIN fg +$FUNCTION fg_builtin +$DEPENDS_ON JOB_CONTROL +$SHORT_DOC fg [job_spec] +Move job to the foreground. + +Place the job identified by JOB_SPEC in the foreground, making it the +current job. If JOB_SPEC is not present, the shell's notion of the +current job is used. + +Exit Status: +Status of command placed in foreground, or failure if an error occurs. +$END + +#include + +#include "../bashtypes.h" +#include + +#if defined (HAVE_UNISTD_H) +# include +#endif + +#include "../bashintl.h" + +#include "../shell.h" +#include "../jobs.h" +#include "common.h" +#include "bashgetopt.h" + +#if defined (JOB_CONTROL) +extern char *this_command_name; + +static int fg_bg __P((WORD_LIST *, int)); + +/* How to bring a job into the foreground. */ +int +fg_builtin (list) + WORD_LIST *list; +{ + int fg_bit; + register WORD_LIST *t; + + CHECK_HELPOPT (list); + + if (job_control == 0) + { + sh_nojobs ((char *)NULL); + return (EXECUTION_FAILURE); + } + + if (no_options (list)) + return (EX_USAGE); + list = loptend; + + /* If the last arg on the line is '&', then start this job in the + background. Else, fg the job. */ + for (t = list; t && t->next; t = t->next) + ; + fg_bit = (t && t->word->word[0] == '&' && t->word->word[1] == '\0') == 0; + + return (fg_bg (list, fg_bit)); +} +#endif /* JOB_CONTROL */ + +$BUILTIN bg +$FUNCTION bg_builtin +$DEPENDS_ON JOB_CONTROL +$SHORT_DOC bg [job_spec ...] +Move jobs to the background. + +Place the jobs identified by each JOB_SPEC in the background, as if they +had been started with `&'. If JOB_SPEC is not present, the shell's notion +of the current job is used. + +Exit Status: +Returns success unless job control is not enabled or an error occurs. +$END + +#if defined (JOB_CONTROL) +/* How to put a job into the background. */ +int +bg_builtin (list) + WORD_LIST *list; +{ + int r; + + CHECK_HELPOPT (list); + + if (job_control == 0) + { + sh_nojobs ((char *)NULL); + return (EXECUTION_FAILURE); + } + + if (no_options (list)) + return (EX_USAGE); + list = loptend; + + /* This relies on the fact that fg_bg() takes a WORD_LIST *, but only acts + on the first member (if any) of that list. */ + r = EXECUTION_SUCCESS; + do + { + if (fg_bg (list, 0) == EXECUTION_FAILURE) + r = EXECUTION_FAILURE; + if (list) + list = list->next; + } + while (list); + + return r; +} + +/* How to put a job into the foreground/background. */ +static int +fg_bg (list, foreground) + WORD_LIST *list; + int foreground; +{ + sigset_t set, oset; + int job, status, old_async_pid; + JOB *j; + + BLOCK_CHILD (set, oset); + job = get_job_spec (list); + + if (INVALID_JOB (job)) + { + if (job != DUP_JOB) + sh_badjob (list ? list->word->word : _("current")); + + goto failure; + } + + j = get_job_by_jid (job); + /* Or if j->pgrp == shell_pgrp. */ + if (IS_JOBCONTROL (job) == 0) + { + builtin_error (_("job %d started without job control"), job + 1); + goto failure; + } + + if (foreground == 0) + { + old_async_pid = last_asynchronous_pid; + last_asynchronous_pid = j->pgrp; /* As per Posix.2 5.4.2 */ + } + + status = start_job (job, foreground); + + if (status >= 0) + { + /* win: */ + UNBLOCK_CHILD (oset); + return (foreground ? status : EXECUTION_SUCCESS); + } + else + { + if (foreground == 0) + last_asynchronous_pid = old_async_pid; + + failure: + UNBLOCK_CHILD (oset); + return (EXECUTION_FAILURE); + } +} +#endif /* JOB_CONTROL */ diff --git a/builtins/gen-helpfiles.c b/builtins/gen-helpfiles.c new file mode 100644 index 0000000..fac34ed --- /dev/null +++ b/builtins/gen-helpfiles.c @@ -0,0 +1,197 @@ +/* gen-helpfiles - create files containing builtin help text */ + +/* Copyright (C) 2012 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 3 of the License, 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. If not, see . +*/ + +/* This links with a specially-generated version of builtins.c and takes + the long_doc members of each struct builtin element and writes those to + the file named by the `handle' member of the struct builtin element. */ + +#if !defined (CROSS_COMPILING) +# include +#else /* CROSS_COMPILING */ +/* A conservative set of defines based on POSIX/SUS3/XPG6 */ +# define HAVE_UNISTD_H +# define HAVE_STRING_H +# define HAVE_STDLIB_H + +# define HAVE_RENAME +#endif /* CROSS_COMPILING */ + +#if defined (HAVE_UNISTD_H) +# ifdef _MINIX +# include +# endif +# include +#endif + +#ifndef _MINIX +# include "../bashtypes.h" +# if defined (HAVE_SYS_FILE_H) +# include +# endif +#endif + +#include "posixstat.h" +#include "filecntl.h" + +#include "../bashansi.h" +#include +#include + +#include "stdc.h" + +#include "../builtins.h" +#include "tmpbuiltins.h" + +#if defined (USING_BASH_MALLOC) +#undef xmalloc +#undef xrealloc +#undef xfree + +#undef free /* defined in xmalloc.h */ +#endif + +#ifndef errno +extern int errno; +#endif + +#if !defined (__STDC__) && !defined (strcpy) +extern char *strcpy (); +#endif /* !__STDC__ && !strcpy */ + +#define whitespace(c) (((c) == ' ') || ((c) == '\t')) + +/* Flag values that builtins can have. */ +#define BUILTIN_FLAG_SPECIAL 0x01 +#define BUILTIN_FLAG_ASSIGNMENT 0x02 +#define BUILTIN_FLAG_POSIX_BUILTIN 0x04 + +#define BASE_INDENT 4 + +/* Non-zero means to produce separate help files for each builtin, named by + the builtin name, in `./helpfiles'. */ +int separate_helpfiles = 0; + +/* Non-zero means to create single C strings for each `longdoc', with + embedded newlines, for ease of translation. */ +int single_longdoc_strings = 1; + +/* The name of a directory into which the separate external help files will + eventually be installed. */ +char *helpfile_directory; + +/* Forward declarations. */ + +int write_helpfiles __P((struct builtin *)); + +/* For each file mentioned on the command line, process it and + write the information to STRUCTFILE and EXTERNFILE, while + creating the production file if neccessary. */ +int +main (argc, argv) + int argc; + char **argv; +{ + int arg_index = 1; + + while (arg_index < argc && argv[arg_index][0] == '-') + { + char *arg = argv[arg_index++]; + + if (strcmp (arg, "-noproduction") == 0) + ; + else if (strcmp (arg, "-H") == 0) + helpfile_directory = argv[arg_index++]; + else if (strcmp (arg, "-S") == 0) + single_longdoc_strings = 0; + else + { + fprintf (stderr, "%s: Unknown flag %s.\n", argv[0], arg); + exit (2); + } + } + + write_helpfiles(shell_builtins); + + exit (0); +} + +/* Write DOCUMENTATION to STREAM, perhaps surrounding it with double-quotes + and quoting special characters in the string. Handle special things for + internationalization (gettext) and the single-string vs. multiple-strings + issues. */ +void +write_documentation (stream, documentation, indentation) + FILE *stream; + char *documentation; + int indentation; +{ + if (stream == 0) + return; + + if (documentation) + fprintf (stream, "%*s%s\n", indentation, " ", documentation); +} + +int +write_helpfiles (builtins) + struct builtin *builtins; +{ + char *helpfile, *bname, *fname; + FILE *helpfp; + int i, hdlen; + struct builtin b; + + i = mkdir ("helpfiles", 0777); + if (i < 0 && errno != EEXIST) + { + fprintf (stderr, "write_helpfiles: helpfiles: cannot create directory\n"); + return -1; + } + + hdlen = strlen ("helpfiles/"); + for (i = 0; i < num_shell_builtins; i++) + { + b = builtins[i]; + + fname = (char *)b.handle; + helpfile = (char *)malloc (hdlen + strlen (fname) + 1); + if (helpfile == 0) + { + fprintf (stderr, "gen-helpfiles: cannot allocate memory\n"); + exit (1); + } + sprintf (helpfile, "helpfiles/%s", fname); + + helpfp = fopen (helpfile, "w"); + if (helpfp == 0) + { + fprintf (stderr, "write_helpfiles: cannot open %s\n", helpfile); + free (helpfile); + continue; + } + + write_documentation (helpfp, b.long_doc[0], 4); + + fflush (helpfp); + fclose (helpfp); + free (helpfile); + } + return 0; +} diff --git a/builtins/getopt.c b/builtins/getopt.c new file mode 100644 index 0000000..9529bc3 --- /dev/null +++ b/builtins/getopt.c @@ -0,0 +1,355 @@ +/* getopt.c - getopt for Bash. Used by the getopt builtin. */ + +/* Copyright (C) 1993-2009 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 3 of the License, 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. If not, see . +*/ + +#include + +#if defined (HAVE_UNISTD_H) +# ifdef _MINIX +# include +# endif +# include +#endif + +#include +#include "memalloc.h" +#include "../bashintl.h" +#include "../shell.h" +#include "getopt.h" + +/* For communication from `sh_getopt' to the caller. + When `sh_getopt' finds an option that takes an argument, + the argument value is returned here. */ +char *sh_optarg = 0; + +/* Index in ARGV of the next element to be scanned. + This is used for communication to and from the caller + and for communication between successive calls to `sh_getopt'. + + On entry to `sh_getopt', zero means this is the first call; initialize. + + When `sh_getopt' returns EOF, this is the index of the first of the + non-option elements that the caller should itself scan. + + Otherwise, `sh_optind' communicates from one call to the next + how much of ARGV has been scanned so far. */ + +/* XXX 1003.2 says this must be 1 before any call. */ +int sh_optind = 0; + +/* Index of the current argument. */ +static int sh_curopt; + +/* The next char to be scanned in the option-element + in which the last option character we returned was found. + This allows us to pick up the scan where we left off. + + If this is zero, or a null string, it means resume the scan + by advancing to the next ARGV-element. */ + +static char *nextchar; +static int sh_charindex; + +/* Callers store zero here to inhibit the error message + for unrecognized options. */ + +int sh_opterr = 1; + +/* Set to an option character which was unrecognized. + This must be initialized on some systems to avoid linking in the + system's own getopt implementation. */ + +int sh_optopt = '?'; + +/* Set to 1 when we see an invalid option; public so getopts can reset it. */ +int sh_badopt = 0; + +/* Scan elements of ARGV (whose length is ARGC) for option characters + given in OPTSTRING. + + If an element of ARGV starts with '-', and is not exactly "-" or "--", + then it is an option element. The characters of this element + (aside from the initial '-') are option characters. If `sh_getopt' + is called repeatedly, it returns successively each of the option characters + from each of the option elements. + + If `sh_getopt' finds another option character, it returns that character, + updating `sh_optind' and `nextchar' so that the next call to `sh_getopt' can + resume the scan with the following option character or ARGV-element. + + If there are no more option characters, `sh_getopt' returns `EOF'. + Then `sh_optind' is the index in ARGV of the first ARGV-element + that is not an option. + + OPTSTRING is a string containing the legitimate option characters. + If an option character is seen that is not listed in OPTSTRING, + return '?' after printing an error message. If you set `sh_opterr' to + zero, the error message is suppressed but we still return '?'. + + If a char in OPTSTRING is followed by a colon, that means it wants an arg, + so the following text in the same ARGV-element, or the text of the following + ARGV-element, is returned in `sh_optarg'. */ + +/* 1003.2 specifies the format of this message. */ +#define BADOPT(x) fprintf (stderr, _("%s: illegal option -- %c\n"), argv[0], x) +#define NEEDARG(x) fprintf (stderr, _("%s: option requires an argument -- %c\n"), argv[0], x) + +int +sh_getopt (argc, argv, optstring) + int argc; + char *const *argv; + const char *optstring; +{ + char c, *temp; + + sh_optarg = 0; + + if (sh_optind >= argc || sh_optind < 0) /* XXX was sh_optind > argc */ + { + sh_optind = argc; + return (EOF); + } + + /* Initialize the internal data when the first call is made. + Start processing options with ARGV-element 1 (since ARGV-element 0 + is the program name); the sequence of previously skipped + non-option ARGV-elements is empty. */ + + if (sh_optind == 0) + { + sh_optind = 1; + nextchar = (char *)NULL; + } + + if (nextchar == 0 || *nextchar == '\0') + { + /* If we have done all the ARGV-elements, stop the scan. */ + if (sh_optind >= argc) + return EOF; + + temp = argv[sh_optind]; + + /* Special ARGV-element `--' means premature end of options. + Skip it like a null option, and return EOF. */ + if (temp[0] == '-' && temp[1] == '-' && temp[2] == '\0') + { + sh_optind++; + return EOF; + } + + /* If we have come to a non-option, either stop the scan or describe + it to the caller and pass it by. This makes the pseudo-option + `-' mean the end of options, but does not skip over it. */ + if (temp[0] != '-' || temp[1] == '\0') + return EOF; + + /* We have found another option-ARGV-element. + Start decoding its characters. */ + nextchar = argv[sh_curopt = sh_optind] + 1; + sh_charindex = 1; + } + + /* Look at and handle the next option-character. */ + + c = *nextchar++; sh_charindex++; + temp = strchr (optstring, c); + + sh_optopt = c; + + /* Increment `sh_optind' when we start to process its last character. */ + if (nextchar == 0 || *nextchar == '\0') + { + sh_optind++; + nextchar = (char *)NULL; + } + + if (sh_badopt = (temp == NULL || c == ':')) + { + if (sh_opterr) + BADOPT (c); + + return '?'; + } + + if (temp[1] == ':') + { + if (nextchar && *nextchar) + { + /* This is an option that requires an argument. */ + sh_optarg = nextchar; + /* If we end this ARGV-element by taking the rest as an arg, + we must advance to the next element now. */ + sh_optind++; + } + else if (sh_optind == argc) + { + if (sh_opterr) + NEEDARG (c); + + sh_optopt = c; + sh_optarg = ""; /* Needed by getopts. */ + c = (optstring[0] == ':') ? ':' : '?'; + } + else + /* We already incremented `sh_optind' once; + increment it again when taking next ARGV-elt as argument. */ + sh_optarg = argv[sh_optind++]; + nextchar = (char *)NULL; + } + return c; +} + +void +sh_getopt_restore_state (argv) + char **argv; +{ + if (nextchar) + nextchar = argv[sh_curopt] + sh_charindex; +} + +sh_getopt_state_t * +sh_getopt_alloc_istate () +{ + sh_getopt_state_t *ret; + + ret = (sh_getopt_state_t *)xmalloc (sizeof (sh_getopt_state_t)); + return ret; +} + +void +sh_getopt_dispose_istate (gs) + sh_getopt_state_t *gs; +{ + free (gs); +} + +sh_getopt_state_t * +sh_getopt_save_istate () +{ + sh_getopt_state_t *ret; + + ret = sh_getopt_alloc_istate (); + + ret->gs_optarg = sh_optarg; + ret->gs_optind = sh_optind; + ret->gs_curopt = sh_curopt; + ret->gs_nextchar = nextchar; /* XXX */ + ret->gs_charindex = sh_charindex; + ret->gs_flags = 0; /* XXX for later use */ + + return ret; +} + +void +sh_getopt_restore_istate (state) + sh_getopt_state_t *state; +{ + sh_optarg = state->gs_optarg; + sh_optind = state->gs_optind; + sh_curopt = state->gs_curopt; + nextchar = state->gs_nextchar; /* XXX - probably not usable */ + sh_charindex = state->gs_charindex; + + sh_getopt_dispose_istate (state); +} + +#if 0 +void +sh_getopt_debug_restore_state (argv) + char **argv; +{ + if (nextchar && nextchar != argv[sh_curopt] + sh_charindex) + { + itrace("sh_getopt_debug_restore_state: resetting nextchar"); + nextchar = argv[sh_curopt] + sh_charindex; + } +} +#endif + +#ifdef TEST + +/* Compile with -DTEST to make an executable for use in testing + the above definition of `sh_getopt'. */ + +int +main (argc, argv) + int argc; + char **argv; +{ + int c; + int digit_sh_optind = 0; + + while (1) + { + int this_option_sh_optind = sh_optind ? sh_optind : 1; + + c = sh_getopt (argc, argv, "abc:d:0123456789"); + if (c == EOF) + break; + + switch (c) + { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + if (digit_sh_optind != 0 && digit_sh_optind != this_option_sh_optind) + printf ("digits occur in two different argv-elements.\n"); + digit_sh_optind = this_option_sh_optind; + printf ("option %c\n", c); + break; + + case 'a': + printf ("option a\n"); + break; + + case 'b': + printf ("option b\n"); + break; + + case 'c': + printf ("option c with value `%s'\n", sh_optarg); + break; + + case '?': + break; + + default: + printf ("?? sh_getopt returned character code 0%o ??\n", c); + } + } + + if (sh_optind < argc) + { + printf ("non-option ARGV-elements: "); + while (sh_optind < argc) + printf ("%s ", argv[sh_optind++]); + printf ("\n"); + } + + exit (0); +} + +#endif /* TEST */ diff --git a/builtins/getopt.h b/builtins/getopt.h new file mode 100644 index 0000000..9909618 --- /dev/null +++ b/builtins/getopt.h @@ -0,0 +1,82 @@ +/* getopt.h - declarations for getopt. */ + +/* Copyright (C) 1989, 1990, 1991, 1992, 1993, 2008,2009 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 3 of the License, 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. If not, see . +*/ + +/* XXX THIS HAS BEEN MODIFIED FOR INCORPORATION INTO BASH XXX */ + +#ifndef _SH_GETOPT_H +#define _SH_GETOPT_H 1 + +#include "stdc.h" + +/* For communication from `getopt' to the caller. + When `getopt' finds an option that takes an argument, + the argument value is returned here. + Also, when `ordering' is RETURN_IN_ORDER, + each non-option ARGV-element is returned here. */ + +extern char *sh_optarg; + +/* Index in ARGV of the next element to be scanned. + This is used for communication to and from the caller + and for communication between successive calls to `getopt'. + + On entry to `getopt', zero means this is the first call; initialize. + + When `getopt' returns EOF, this is the index of the first of the + non-option elements that the caller should itself scan. + + Otherwise, `sh_optind' communicates from one call to the next + how much of ARGV has been scanned so far. */ + +extern int sh_optind; + +/* Callers store zero here to inhibit the error message `getopt' prints + for unrecognized options. */ + +extern int sh_opterr; + +/* Set to an option character which was unrecognized. */ + +extern int sh_optopt; + +/* Set to 1 when an unrecognized option is encountered. */ +extern int sh_badopt; + +extern int sh_getopt __P((int, char *const *, const char *)); + +typedef struct sh_getopt_state +{ + char *gs_optarg; + int gs_optind; + int gs_curopt; + char *gs_nextchar; + int gs_charindex; + int gs_flags; +} sh_getopt_state_t; + +extern void sh_getopt_restore_state __P((char **)); + +extern sh_getopt_state_t *sh_getopt_alloc_istate __P((void)); +extern void sh_getopt_dispose_istate __P((sh_getopt_state_t *)); + +extern sh_getopt_state_t *sh_getopt_save_istate __P((void)); +extern void sh_getopt_restore_istate __P((sh_getopt_state_t *)); + +#endif /* _SH_GETOPT_H */ diff --git a/builtins/getopts.def b/builtins/getopts.def new file mode 100644 index 0000000..590b110 --- /dev/null +++ b/builtins/getopts.def @@ -0,0 +1,347 @@ +This file is getopts.def, from which is created getopts.c. +It implements the builtin "getopts" in Bash. + +Copyright (C) 1987-2015 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 3 of the License, 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. If not, see . + +$PRODUCES getopts.c + +$BUILTIN getopts +$FUNCTION getopts_builtin +$SHORT_DOC getopts optstring name [arg] +Parse option arguments. + +Getopts is used by shell procedures to parse positional parameters +as options. + +OPTSTRING contains the option letters to be recognized; if a letter +is followed by a colon, the option is expected to have an argument, +which should be separated from it by white space. + +Each time it is invoked, getopts will place the next option in the +shell variable $name, initializing name if it does not exist, and +the index of the next argument to be processed into the shell +variable OPTIND. OPTIND is initialized to 1 each time the shell or +a shell script is invoked. When an option requires an argument, +getopts places that argument into the shell variable OPTARG. + +getopts reports errors in one of two ways. If the first character +of OPTSTRING is a colon, getopts uses silent error reporting. In +this mode, no error messages are printed. If an invalid option is +seen, getopts places the option character found into OPTARG. If a +required argument is not found, getopts places a ':' into NAME and +sets OPTARG to the option character found. If getopts is not in +silent mode, and an invalid option is seen, getopts places '?' into +NAME and unsets OPTARG. If a required argument is not found, a '?' +is placed in NAME, OPTARG is unset, and a diagnostic message is +printed. + +If the shell variable OPTERR has the value 0, getopts disables the +printing of error messages, even if the first character of +OPTSTRING is not a colon. OPTERR has the value 1 by default. + +Getopts normally parses the positional parameters ($0 - $9), but if +more arguments are given, they are parsed instead. + +Exit Status: +Returns success if an option is found; fails if the end of options is +encountered or an error occurs. +$END + +#include + +#include + +#if defined (HAVE_UNISTD_H) +# ifdef _MINIX +# include +# endif +# include +#endif + +#include "../bashansi.h" +#include "../bashintl.h" + +#include "../shell.h" +#include "common.h" +#include "bashgetopt.h" +#include "getopt.h" + +#define G_EOF -1 +#define G_INVALID_OPT -2 +#define G_ARG_MISSING -3 + +extern char *this_command_name; + +static int getopts_unbind_variable __P((char *)); +static int getopts_bind_variable __P((char *, char *)); +static int dogetopts __P((int, char **)); + +/* getopts_reset is magic code for when OPTIND is reset. N is the + value that has just been assigned to OPTIND. */ +void +getopts_reset (newind) + int newind; +{ + sh_optind = newind; + sh_badopt = 0; +} + +static int +getopts_unbind_variable (name) + char *name; +{ +#if 0 + return (unbind_variable (name)); +#else + return (unbind_variable_noref (name)); +#endif +} + +static int +getopts_bind_variable (name, value) + char *name, *value; +{ + SHELL_VAR *v; + + if (legal_identifier (name)) + { + v = bind_variable (name, value, 0); + if (v && (readonly_p (v) || noassign_p (v))) + return (EX_MISCERROR); + return (v ? EXECUTION_SUCCESS : EXECUTION_FAILURE); + } + else + { + sh_invalidid (name); + return (EXECUTION_FAILURE); + } +} + +/* Error handling is now performed as specified by Posix.2, draft 11 + (identical to that of ksh-88). The special handling is enabled if + the first character of the option string is a colon; this handling + disables diagnostic messages concerning missing option arguments + and invalid option characters. The handling is as follows. + + INVALID OPTIONS: + name -> "?" + if (special_error) then + OPTARG = option character found + no error output + else + OPTARG unset + diagnostic message + fi + + MISSING OPTION ARGUMENT; + if (special_error) then + name -> ":" + OPTARG = option character found + else + name -> "?" + OPTARG unset + diagnostic message + fi + */ + +static int +dogetopts (argc, argv) + int argc; + char **argv; +{ + int ret, special_error, old_opterr, i, n; + char strval[2], numval[16]; + char *optstr; /* list of options */ + char *name; /* variable to get flag val */ + char *t; + + if (argc < 3) + { + builtin_usage (); + return (EX_USAGE); + } + + /* argv[0] is "getopts". */ + + optstr = argv[1]; + name = argv[2]; + argc -= 2; + argv += 2; + + special_error = optstr[0] == ':'; + + if (special_error) + { + old_opterr = sh_opterr; + optstr++; + sh_opterr = 0; /* suppress diagnostic messages */ + } + + if (argc > 1) + { + sh_getopt_restore_state (argv); + t = argv[0]; + argv[0] = dollar_vars[0]; + ret = sh_getopt (argc, argv, optstr); + argv[0] = t; + } + else if (rest_of_args == (WORD_LIST *)NULL) + { + for (i = 0; i < 10 && dollar_vars[i]; i++) + ; + + sh_getopt_restore_state (dollar_vars); + ret = sh_getopt (i, dollar_vars, optstr); + } + else + { + register WORD_LIST *words; + char **v; + + for (i = 0; i < 10 && dollar_vars[i]; i++) + ; + for (words = rest_of_args; words; words = words->next, i++) + ; + v = strvec_create (i + 1); + for (i = 0; i < 10 && dollar_vars[i]; i++) + v[i] = dollar_vars[i]; + for (words = rest_of_args; words; words = words->next, i++) + v[i] = words->word->word; + v[i] = (char *)NULL; + sh_getopt_restore_state (v); + ret = sh_getopt (i, v, optstr); + free (v); + } + + if (special_error) + sh_opterr = old_opterr; + + /* Set the OPTIND variable in any case, to handle "--" skipping. It's + highly unlikely that 14 digits will be too few. */ + if (sh_optind < 10) + { + numval[14] = sh_optind + '0'; + numval[15] = '\0'; + i = 14; + } + else + { + numval[i = 15] = '\0'; + n = sh_optind; + do + { + numval[--i] = (n % 10) + '0'; + } + while (n /= 10); + } + bind_variable ("OPTIND", numval + i, 0); + + /* If an error occurred, decide which one it is and set the return + code appropriately. In all cases, the option character in error + is in OPTOPT. If an invalid option was encountered, OPTARG is + NULL. If a required option argument was missing, OPTARG points + to a NULL string (that is, sh_optarg[0] == 0). */ + if (ret == '?') + { + if (sh_optarg == NULL) + ret = G_INVALID_OPT; + else if (sh_optarg[0] == '\0') + ret = G_ARG_MISSING; + } + + if (ret == G_EOF) + { + getopts_unbind_variable ("OPTARG"); + getopts_bind_variable (name, "?"); + return (EXECUTION_FAILURE); + } + + if (ret == G_INVALID_OPT) + { + /* Invalid option encountered. */ + ret = getopts_bind_variable (name, "?"); + + if (special_error) + { + strval[0] = (char)sh_optopt; + strval[1] = '\0'; + bind_variable ("OPTARG", strval, 0); + } + else + getopts_unbind_variable ("OPTARG"); + + return (ret); + } + + if (ret == G_ARG_MISSING) + { + /* Required argument missing. */ + if (special_error) + { + ret = getopts_bind_variable (name, ":"); + + strval[0] = (char)sh_optopt; + strval[1] = '\0'; + bind_variable ("OPTARG", strval, 0); + } + else + { + ret = getopts_bind_variable (name, "?"); + getopts_unbind_variable ("OPTARG"); + } + return (ret); + } + + bind_variable ("OPTARG", sh_optarg, 0); + + strval[0] = (char) ret; + strval[1] = '\0'; + return (getopts_bind_variable (name, strval)); +} + +/* The getopts builtin. Build an argv, and call dogetopts with it. */ +int +getopts_builtin (list) + WORD_LIST *list; +{ + char **av; + int ac, ret; + + if (list == 0) + { + builtin_usage (); + return EX_USAGE; + } + + reset_internal_getopt (); + if ((ret = internal_getopt (list, "")) != -1) + { + if (ret == GETOPT_HELP) + builtin_help (); + else + builtin_usage (); + return (EX_USAGE); + } + list = loptend; + + av = make_builtin_argv (list, &ac); + ret = dogetopts (ac, av); + free ((char *)av); + + return (ret); +} diff --git a/builtins/hash.def b/builtins/hash.def new file mode 100644 index 0000000..bec4b07 --- /dev/null +++ b/builtins/hash.def @@ -0,0 +1,292 @@ +This file is hash.def, from which is created hash.c. +It implements the builtin "hash" in Bash. + +Copyright (C) 1987-2015 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 3 of the License, 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. If not, see . + +$PRODUCES hash.c + +$BUILTIN hash +$FUNCTION hash_builtin +$SHORT_DOC hash [-lr] [-p pathname] [-dt] [name ...] +Remember or display program locations. + +Determine and remember the full pathname of each command NAME. If +no arguments are given, information about remembered commands is displayed. + +Options: + -d forget the remembered location of each NAME + -l display in a format that may be reused as input + -p pathname use PATHNAME as the full pathname of NAME + -r forget all remembered locations + -t print the remembered location of each NAME, preceding + each location with the corresponding NAME if multiple + NAMEs are given +Arguments: + NAME Each NAME is searched for in $PATH and added to the list + of remembered commands. + +Exit Status: +Returns success unless NAME is not found or an invalid option is given. +$END + +#include + +#include + +#include "../bashtypes.h" + +#if defined (HAVE_UNISTD_H) +# include +#endif + +#include + +#include "../bashansi.h" +#include "../bashintl.h" + +#include "../shell.h" +#include "../builtins.h" +#include "../flags.h" +#include "../findcmd.h" +#include "../hashcmd.h" +#include "common.h" +#include "bashgetopt.h" + +extern int posixly_correct; +extern int dot_found_in_search; +extern char *this_command_name; + +static int add_hashed_command __P((char *, int)); +static int print_hash_info __P((BUCKET_CONTENTS *)); +static int print_portable_hash_info __P((BUCKET_CONTENTS *)); +static int print_hashed_commands __P((int)); +static int list_hashed_filename_targets __P((WORD_LIST *, int)); + +/* Print statistics on the current state of hashed commands. If LIST is + not empty, then rehash (or hash in the first place) the specified + commands. */ +int +hash_builtin (list) + WORD_LIST *list; +{ + int expunge_hash_table, list_targets, list_portably, delete, opt; + char *w, *pathname; + + if (hashing_enabled == 0) + { + builtin_error (_("hashing disabled")); + return (EXECUTION_FAILURE); + } + + expunge_hash_table = list_targets = list_portably = delete = 0; + pathname = (char *)NULL; + reset_internal_getopt (); + while ((opt = internal_getopt (list, "dlp:rt")) != -1) + { + switch (opt) + { + case 'd': + delete = 1; + break; + case 'l': + list_portably = 1; + break; + case 'p': + pathname = list_optarg; + break; + case 'r': + expunge_hash_table = 1; + break; + case 't': + list_targets = 1; + break; + CASE_HELPOPT; + default: + builtin_usage (); + return (EX_USAGE); + } + } + list = loptend; + + /* hash -t requires at least one argument. */ + if (list == 0 && list_targets) + { + sh_needarg ("-t"); + return (EXECUTION_FAILURE); + } + + /* We want hash -r to be silent, but hash -- to print hashing info, so + we test expunge_hash_table. */ + if (list == 0 && expunge_hash_table == 0) + { + opt = print_hashed_commands (list_portably); + if (opt == 0 && posixly_correct == 0) + printf (_("%s: hash table empty\n"), this_command_name); + + return (EXECUTION_SUCCESS); + } + + if (expunge_hash_table) + phash_flush (); + + /* If someone runs `hash -r -t xyz' he will be disappointed. */ + if (list_targets) + return (list_hashed_filename_targets (list, list_portably)); + +#if defined (RESTRICTED_SHELL) + if (restricted && pathname && strchr (pathname, '/')) + { + sh_restricted (pathname); + return (EXECUTION_FAILURE); + } +#endif + + for (opt = EXECUTION_SUCCESS; list; list = list->next) + { + /* Add, remove or rehash the specified commands. */ + w = list->word->word; + if (absolute_program (w)) + continue; + else if (pathname) + { + if (is_directory (pathname)) + { +#ifdef EISDIR + builtin_error ("%s: %s", pathname, strerror (EISDIR)); +#else + builtin_error (_("%s: is a directory"), pathname); +#endif + opt = EXECUTION_FAILURE; + } + else + phash_insert (w, pathname, 0, 0); + } + else if (delete) + { + if (phash_remove (w)) + { + sh_notfound (w); + opt = EXECUTION_FAILURE; + } + } + else if (add_hashed_command (w, 0)) + opt = EXECUTION_FAILURE; + } + + fflush (stdout); + return (opt); +} + +static int +add_hashed_command (w, quiet) + char *w; + int quiet; +{ + int rv; + char *full_path; + + rv = 0; + if (find_function (w) == 0 && find_shell_builtin (w) == 0) + { + phash_remove (w); + full_path = find_user_command (w); + if (full_path && executable_file (full_path)) + phash_insert (w, full_path, dot_found_in_search, 0); + else + { + if (quiet == 0) + sh_notfound (w); + rv++; + } + FREE (full_path); + } + return (rv); +} + +/* Print information about current hashed info. */ +static int +print_hash_info (item) + BUCKET_CONTENTS *item; +{ + printf ("%4d\t%s\n", item->times_found, pathdata(item)->path); + return 0; +} + +static int +print_portable_hash_info (item) + BUCKET_CONTENTS *item; +{ + char *fp, *fn; + + fp = printable_filename (pathdata(item)->path, 1); + fn = printable_filename (item->key, 1); + printf ("builtin hash -p %s %s\n", fp, fn); + if (fp != pathdata(item)->path) + free (fp); + if (fn != item->key) + free (fn); + return 0; +} + +static int +print_hashed_commands (fmt) + int fmt; +{ + if (hashed_filenames == 0 || HASH_ENTRIES (hashed_filenames) == 0) + return (0); + + if (fmt == 0) + printf (_("hits\tcommand\n")); + hash_walk (hashed_filenames, fmt ? print_portable_hash_info : print_hash_info); + return (1); +} + +static int +list_hashed_filename_targets (list, fmt) + WORD_LIST *list; + int fmt; +{ + int all_found, multiple; + char *target; + WORD_LIST *l; + + all_found = 1; + multiple = list->next != 0; + + for (l = list; l; l = l->next) + { + target = phash_search (l->word->word); + if (target == 0) + { + all_found = 0; + sh_notfound (l->word->word); + continue; + } + if (fmt) + printf ("builtin hash -p %s %s\n", target, l->word->word); + else + { + if (multiple) + printf ("%s\t", l->word->word); + printf ("%s\n", target); + } + free (target); + } + + return (all_found ? EXECUTION_SUCCESS : EXECUTION_FAILURE); +} diff --git a/builtins/help.def b/builtins/help.def new file mode 100644 index 0000000..95a1a36 --- /dev/null +++ b/builtins/help.def @@ -0,0 +1,558 @@ +This file is help.def, from which is created help.c. +It implements the builtin "help" in Bash. + +Copyright (C) 1987-2015 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 3 of the License, 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. If not, see . + +$PRODUCES help.c + +$BUILTIN help +$FUNCTION help_builtin +$DEPENDS_ON HELP_BUILTIN +$SHORT_DOC help [-dms] [pattern ...] +Display information about builtin commands. + +Displays brief summaries of builtin commands. If PATTERN is +specified, gives detailed help on all commands matching PATTERN, +otherwise the list of help topics is printed. + +Options: + -d output short description for each topic + -m display usage in pseudo-manpage format + -s output only a short usage synopsis for each topic matching + PATTERN + +Arguments: + PATTERN Pattern specifiying a help topic + +Exit Status: +Returns success unless PATTERN is not found or an invalid option is given. +$END + +#include + +#if defined (HELP_BUILTIN) +#include + +#if defined (HAVE_UNISTD_H) +# ifdef _MINIX +# include +# endif +# include +#endif + +#include + +#include +#include + +#include "../bashintl.h" + +#include "../shell.h" +#include "../builtins.h" +#include "../pathexp.h" +#include "common.h" +#include "bashgetopt.h" + +#include +#include + +#ifndef errno +extern int errno; +#endif + +extern const char * const bash_copyright; +extern const char * const bash_license; + +extern char *this_command_name; +extern struct builtin *current_builtin; + +static void show_builtin_command_help __P((void)); +static int open_helpfile __P((char *)); +static void show_desc __P((char *, int)); +static void show_manpage __P((char *, int)); +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, dflag, mflag, m, pass, this_found; + + dflag = sflag = mflag = 0; + reset_internal_getopt (); + while ((i = internal_getopt (list, "dms")) != -1) + { + switch (i) + { + case 'd': + dflag = 1; + break; + case 'm': + mflag = 1; + break; + case 's': + sflag = 1; + break; + CASE_HELPOPT; + 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)) + { + printf (ngettext ("Shell commands matching keyword `", "Shell commands matching keywords `", (list->next ? 2 : 1))); + print_word_list (list, ", "); + printf ("'\n\n"); + } + + for (match_found = 0, pattern = ""; list; list = list->next) + { + pattern = list->word->word; + plen = strlen (pattern); + + for (pass = 1, this_found = 0; pass < 3; pass++) + { + for (i = 0; name = shell_builtins[i].name; i++) + { + QUIT; + + /* First pass: look for exact string or pattern matches. + Second pass: look for prefix matches like bash-4.2 */ + if (pass == 1) + m = (strcmp (pattern, name) == 0) || + (strmatch (pattern, name, FNMATCH_EXTFLAG) != FNM_NOMATCH); + else + m = strncmp (pattern, name, plen) == 0; + + if (m) + { + this_found = 1; + match_found++; + if (dflag) + { + show_desc (name, i); + continue; + } + else if (mflag) + { + show_manpage (name, i); + continue; + } + + printf ("%s: %s\n", name, _(shell_builtins[i].short_doc)); + + if (sflag == 0) + show_longdoc (i); + } + } + if (pass == 1 && this_found == 1) + break; + } + } + + 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); +} + +void +builtin_help () +{ + int ind; + ptrdiff_t d; + + current_builtin = builtin_address_internal (this_command_name, 0); + if (current_builtin == 0) + return; + + d = current_builtin - shell_builtins; + +#if defined (__STDC__) + ind = (int)d; +#else + ind = (int)d / sizeof (struct builtin); +#endif + + printf ("%s: %s\n", this_command_name, _(shell_builtins[ind].short_doc)); + show_longdoc (ind); +} + +static int +open_helpfile (name) + char *name; +{ + int fd; + + fd = open (name, O_RDONLY); + if (fd == -1) + { + builtin_error (_("%s: cannot open: %s"), name, strerror (errno)); + return -1; + } + return fd; +} + +/* 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_helpfile (doc[0]); + if (fd < 0) + return; + zcatfd (fd, 1, doc[0]); + close (fd); + } + else if (doc) + for (j = 0; doc[j]; j++) + printf ("%*s%s\n", BASE_INDENT, " ", _(doc[j])); +} + +static void +show_desc (name, i) + char *name; + int i; +{ + register int j; + char **doc, *line; + int fd, usefile; + + doc = (char **)shell_builtins[i].long_doc; + + usefile = (doc && doc[0] && *doc[0] == '/' && doc[1] == (char *)NULL); + if (usefile) + { + fd = open_helpfile (doc[0]); + if (fd < 0) + return; + zmapfd (fd, &line, doc[0]); + close (fd); + } + else + line = doc ? doc[0] : (char *)NULL; + + printf ("%s - ", name); + for (j = 0; line && line[j]; j++) + { + putchar (line[j]); + if (line[j] == '\n') + break; + } + + fflush (stdout); + + if (usefile) + free (line); +} + +/* Print builtin help in pseudo-manpage format. */ +static void +show_manpage (name, i) + char *name; + int i; +{ + register int j; + char **doc, *line; + int fd, usefile; + + doc = (char **)shell_builtins[i].long_doc; + + usefile = (doc && doc[0] && *doc[0] == '/' && doc[1] == (char *)NULL); + if (usefile) + { + fd = open_helpfile (doc[0]); + if (fd < 0) + return; + zmapfd (fd, &line, doc[0]); + close (fd); + } + else + line = doc ? _(doc[0]) : (char *)NULL; + + /* NAME */ + printf ("NAME\n"); + printf ("%*s%s - ", BASE_INDENT, " ", name); + for (j = 0; line && line[j]; j++) + { + putchar (line[j]); + if (line[j] == '\n') + break; + } + printf ("\n"); + + /* SYNOPSIS */ + printf ("SYNOPSIS\n"); + printf ("%*s%s\n\n", BASE_INDENT, " ", _(shell_builtins[i].short_doc)); + + /* DESCRIPTION */ + printf ("DESCRIPTION\n"); + if (usefile == 0) + { + for (j = 0; doc[j]; j++) + printf ("%*s%s\n", BASE_INDENT, " ", _(doc[j])); + } + else + { + for (j = 0; line && line[j]; j++) + { + putchar (line[j]); + if (line[j] == '\n') + printf ("%*s", BASE_INDENT, " "); + } + } + putchar ('\n'); + + /* SEE ALSO */ + printf ("SEE ALSO\n"); + printf ("%*sbash(1)\n\n", BASE_INDENT, " "); + + /* IMPLEMENTATION */ + printf ("IMPLEMENTATION\n"); + printf ("%*s", BASE_INDENT, " "); + show_shell_version (0); + printf ("%*s", BASE_INDENT, " "); + printf ("%s\n", _(bash_copyright)); + printf ("%*s", BASE_INDENT, " "); + printf ("%s\n", _(bash_license)); + + fflush (stdout); + if (usefile) + free (line); +} + +static void +dispcolumn (i, buf, bufsize, width, height) + int i; + char *buf; + size_t bufsize; + int width, height; +{ + int j; + int dispcols; + char *helpdoc; + + /* first column */ + helpdoc = _(shell_builtins[i].short_doc); + + buf[0] = (shell_builtins[i].flags & BUILTIN_ENABLED) ? ' ' : '*'; + strncpy (buf + 1, helpdoc, width - 2); + buf[width - 2] = '>'; /* indicate truncation */ + buf[width - 1] = '\0'; + printf ("%s", buf); + if (((i << 1) >= num_shell_builtins) || (i+height >= num_shell_builtins)) + { + printf ("\n"); + return; + } + + dispcols = strlen (buf); + /* two spaces */ + for (j = dispcols; j < width; j++) + putc (' ', stdout); + + /* second column */ + helpdoc = _(shell_builtins[i+height].short_doc); + + buf[0] = (shell_builtins[i+height].flags & BUILTIN_ENABLED) ? ' ' : '*'; + strncpy (buf + 1, helpdoc, width - 3); + buf[width - 3] = '>'; /* indicate truncation */ + buf[width - 2] = '\0'; + + printf ("%s\n", buf); +} + +#if defined (HANDLE_MULTIBYTE) +static void +wdispcolumn (i, buf, bufsize, width, height) + int i; + char *buf; + size_t bufsize; + int width, height; +{ + int j; + int dispcols, dispchars; + char *helpdoc; + wchar_t *wcstr; + size_t slen, n; + int wclen; + + /* first column */ + helpdoc = _(shell_builtins[i].short_doc); + + wcstr = 0; + slen = mbstowcs ((wchar_t *)0, helpdoc, 0); + if (slen == -1) + { + dispcolumn (i, buf, bufsize, width, height); + return; + } + + /* No bigger than the passed max width */ + if (slen >= width) + slen = width - 2; + wcstr = (wchar_t *)xmalloc (sizeof (wchar_t) * (width + 2)); + n = mbstowcs (wcstr+1, helpdoc, slen + 1); + wcstr[n+1] = L'\0'; + + /* Turn tabs and newlines into spaces for column display, since wcwidth + returns -1 for them */ + for (j = 1; j < n; j++) + if (wcstr[j] == L'\n' || wcstr[j] == L'\t') + wcstr[j] = L' '; + + /* dispchars == number of characters that will be displayed */ + dispchars = wcsnwidth (wcstr+1, slen, width - 2); + /* dispcols == number of columns required to display DISPCHARS */ + dispcols = wcswidth (wcstr+1, dispchars) + 1; /* +1 for ' ' or '*' */ + + wcstr[0] = (shell_builtins[i].flags & BUILTIN_ENABLED) ? L' ' : L'*'; + + if (dispcols >= width-2) + { + wcstr[dispchars] = L'>'; /* indicate truncation */ + wcstr[dispchars+1] = L'\0'; + } + + printf ("%ls", wcstr); + if (((i << 1) >= num_shell_builtins) || (i+height >= num_shell_builtins)) + { + printf ("\n"); + free (wcstr); + return; + } + + /* at least one space */ + for (j = dispcols; j < width; j++) + putc (' ', stdout); + + /* second column */ + helpdoc = _(shell_builtins[i+height].short_doc); + slen = mbstowcs ((wchar_t *)0, helpdoc, 0); + if (slen == -1) + { + /* for now */ + printf ("%c%s\n", (shell_builtins[i+height].flags & BUILTIN_ENABLED) ? ' ' : '*', helpdoc); + free (wcstr); + return; + } + + /* Reuse wcstr since it is already width wide chars long */ + if (slen >= width) + slen = width - 2; + n = mbstowcs (wcstr+1, helpdoc, slen + 1); + wcstr[n+1] = L'\0'; /* make sure null-terminated */ + + /* Turn tabs and newlines into spaces for column display */ + for (j = 1; j < n; j++) + if (wcstr[j] == L'\n' || wcstr[j] == L'\t') + wcstr[j] = L' '; + + /* dispchars == number of characters that will be displayed */ + dispchars = wcsnwidth (wcstr+1, slen, width - 2); + dispcols = wcswidth (wcstr+1, dispchars) + 1; /* +1 for ' ' or '*' */ + + wcstr[0] = (shell_builtins[i+height].flags & BUILTIN_ENABLED) ? L' ' : L'*'; + + /* The dispchars-1 is there for terminals that behave strangely when you + have \n in the nth column for terminal width n; this is what bash-4.3 + did. */ + if (dispcols >= width - 2) + { + wcstr[dispchars-1] = L'>'; /* indicate truncation */ + wcstr[dispchars] = L'\0'; + } + + printf ("%ls\n", wcstr); + + free (wcstr); +} +#endif /* HANDLE_MULTIBYTE */ + +static void +show_builtin_command_help () +{ + int i, j; + int height, 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); + if (width <= 3) + width = 40; + height = (num_shell_builtins + 1) / 2; /* number of rows */ + + for (i = 0; i < height; i++) + { + QUIT; + +#if defined (HANDLE_MULTIBYTE) + if (MB_CUR_MAX > 1) + wdispcolumn (i, blurb, sizeof (blurb), width, height); + else +#endif + dispcolumn (i, blurb, sizeof (blurb), width, height); + } +} +#endif /* HELP_BUILTIN */ diff --git a/builtins/history.def b/builtins/history.def new file mode 100644 index 0000000..48b59ae --- /dev/null +++ b/builtins/history.def @@ -0,0 +1,390 @@ +This file is history.def, from which is created history.c. +It implements the builtin "history" in Bash. + +Copyright (C) 1987-2016 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 3 of the License, 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. If not, see . + +$PRODUCES history.c + +$BUILTIN history +$FUNCTION history_builtin +$DEPENDS_ON HISTORY +$SHORT_DOC history [-c] [-d offset] [n] or history -anrw [filename] or history -ps arg [arg...] +Display or manipulate the history list. + +Display the history list with line numbers, prefixing each modified +entry with a `*'. An argument of N lists only the last N entries. + +Options: + -c clear the history list by deleting all of the entries + -d offset delete the history entry at position OFFSET. + + -a append history lines from this session to the history file + -n read all history lines not already read from the history file + and append them to the history list + -r read the history file and append the contents to the history + list + -w write the current history to the history file + + -p perform history expansion on each ARG and display the result + without storing it in the history list + -s append the ARGs to the history list as a single entry + +If FILENAME is given, it is used as the history file. Otherwise, +if HISTFILE has a value, that is used, else ~/.bash_history. + +If the HISTTIMEFORMAT variable is set and not null, its value is used +as a format string for strftime(3) to print the time stamp associated +with each displayed history entry. No time stamps are printed otherwise. + +Exit Status: +Returns success unless an invalid option is given or an error occurs. +$END + +#include + +#if defined (HISTORY) +#include "../bashtypes.h" +#if ! defined(_MINIX) && defined (HAVE_SYS_FILE_H) +# include +#endif +#include "posixstat.h" +#include "filecntl.h" +#include +#include +#if defined (HAVE_UNISTD_H) +# include +#endif + +#include "../bashansi.h" +#include "../bashintl.h" + +#include "../shell.h" +#include "../bashhist.h" +#include +#include "bashgetopt.h" +#include "common.h" + +#if !defined (errno) +extern int errno; +#endif + +extern int current_command_line_count; +extern int force_append_history; /* shopt -s histappend */ + +static char *histtime __P((HIST_ENTRY *, const char *)); +static int display_history __P((WORD_LIST *)); +static void push_history __P((WORD_LIST *)); +static int expand_and_print_history __P((WORD_LIST *)); + +#define AFLAG 0x01 +#define RFLAG 0x02 +#define WFLAG 0x04 +#define NFLAG 0x08 +#define SFLAG 0x10 +#define PFLAG 0x20 +#define CFLAG 0x40 +#define DFLAG 0x80 + +int +history_builtin (list) + WORD_LIST *list; +{ + int flags, opt, result, old_history_lines, obase; + char *filename, *delete_arg; + intmax_t delete_offset; + + flags = 0; + reset_internal_getopt (); + while ((opt = internal_getopt (list, "acd:npsrw")) != -1) + { + switch (opt) + { + case 'a': + flags |= AFLAG; + break; + case 'c': + flags |= CFLAG; + break; + case 'n': + flags |= NFLAG; + break; + case 'r': + flags |= RFLAG; + break; + case 'w': + flags |= WFLAG; + break; + case 's': + flags |= SFLAG; + break; + case 'd': + flags |= DFLAG; + delete_arg = list_optarg; + break; + case 'p': +#if defined (BANG_HISTORY) + flags |= PFLAG; +#endif + break; + CASE_HELPOPT; + default: + builtin_usage (); + return (EX_USAGE); + } + } + list = loptend; + + opt = flags & (AFLAG|RFLAG|WFLAG|NFLAG); + if (opt && opt != AFLAG && opt != RFLAG && opt != WFLAG && opt != NFLAG) + { + builtin_error (_("cannot use more than one of -anrw")); + return (EXECUTION_FAILURE); + } + + /* clear the history, but allow other arguments to add to it again. */ + if (flags & CFLAG) + { + bash_clear_history (); + if (list == 0) + return (EXECUTION_SUCCESS); + } + + if (flags & SFLAG) + { + if (list) + push_history (list); + return (EXECUTION_SUCCESS); + } +#if defined (BANG_HISTORY) + else if (flags & PFLAG) + { + if (list) + return (expand_and_print_history (list)); + return (sh_chkwrite (EXECUTION_SUCCESS)); + } +#endif + else if (flags & DFLAG) + { + if ((legal_number (delete_arg, &delete_offset) == 0) + || (delete_offset < history_base) + || (delete_offset > (history_base + history_length))) + { + sh_erange (delete_arg, _("history position")); + return (EXECUTION_FAILURE); + } + opt = delete_offset; + result = bash_delete_histent (opt - history_base); + /* Since remove_history changes history_length, this can happen if + we delete the last history entry. */ + if (where_history () > history_length) + history_set_pos (history_length); + return (result ? EXECUTION_SUCCESS : EXECUTION_FAILURE); + } + else if ((flags & (AFLAG|RFLAG|NFLAG|WFLAG|CFLAG)) == 0) + { + result = display_history (list); + return (sh_chkwrite (result)); + } + + filename = list ? list->word->word : get_string_value ("HISTFILE"); + result = EXECUTION_SUCCESS; + + if (flags & AFLAG) /* Append session's history to file. */ + result = maybe_append_history (filename); + else if (flags & WFLAG) /* Write entire history. */ + result = write_history (filename); + else if (flags & RFLAG) /* Read entire file. */ + { + result = read_history (filename); + history_lines_in_file = history_lines_read_from_file; + /* history_lines_in_file = where_history () + history_base - 1; */ + } + else if (flags & NFLAG) /* Read `new' history from file. */ + { + /* Read all of the lines in the file that we haven't already read. */ + old_history_lines = history_lines_in_file; + obase = history_base; + + using_history (); + result = read_history_range (filename, history_lines_in_file, -1); + using_history (); + + history_lines_in_file = history_lines_read_from_file; + /* history_lines_in_file = where_history () + history_base - 1; */ + + /* If we're rewriting the history file at shell exit rather than just + appending the lines from this session to it, the question is whether + we reset history_lines_this_session to 0, losing any history entries + we had before we read the new entries from the history file, or + whether we count the new entries we just read from the file as + history lines added during this session. + Right now, we do the latter. This will cause these history entries + to be written to the history file along with any intermediate entries + we add when we do a `history -a', but the alternative is losing + them altogether. */ + if (force_append_history == 0) + history_lines_this_session += history_lines_in_file - old_history_lines + + history_base - obase; + } + + return (result ? EXECUTION_FAILURE : EXECUTION_SUCCESS); +} + +/* Accessors for HIST_ENTRY lists that are called HLIST. */ +#define histline(i) (hlist[(i)]->line) +#define histdata(i) (hlist[(i)]->data) + +static char * +histtime (hlist, histtimefmt) + HIST_ENTRY *hlist; + const char *histtimefmt; +{ + static char timestr[128]; + time_t t; + + t = history_get_time (hlist); + if (t) + strftime (timestr, sizeof (timestr), histtimefmt, localtime (&t)); + else if (hlist->timestamp && hlist->timestamp[0]) + snprintf (timestr, sizeof (timestr), _("%s: invalid timestamp"), + (hlist->timestamp[0] == '#') ? hlist->timestamp + 1: hlist->timestamp); + else + strcpy (timestr, "??"); + return timestr; +} + +static int +display_history (list) + WORD_LIST *list; +{ + register int i; + intmax_t limit; + HIST_ENTRY **hlist; + char *histtimefmt, *timestr; + + if (list) + { + if (get_numeric_arg (list, 0, &limit) == 0) + return (EXECUTION_FAILURE); + + if (limit < 0) + limit = -limit; + } + else + limit = -1; + + hlist = history_list (); + + if (hlist) + { + for (i = 0; hlist[i]; i++) + ; + + if (0 <= limit && limit < i) + i -= limit; + else + i = 0; + + histtimefmt = get_string_value ("HISTTIMEFORMAT"); + + while (hlist[i]) + { + QUIT; + + timestr = (histtimefmt && *histtimefmt) ? histtime (hlist[i], histtimefmt) : (char *)NULL; + printf ("%5d%c %s%s\n", i + history_base, + histdata(i) ? '*' : ' ', + ((timestr && *timestr) ? timestr : ""), + histline(i)); + i++; + } + } + + return (EXECUTION_SUCCESS); +} + +/* Remove the last entry in the history list and add each argument in + LIST to the history. */ +static void +push_history (list) + WORD_LIST *list; +{ + char *s; + + /* Delete the last history entry if it was a single entry added to the + history list (generally the `history -s' itself), or if `history -s' + is being used in a compound command and the compound command was + added to the history as a single element (command-oriented history). + If you don't want history -s to remove the compound command from the + history, change #if 0 to #if 1 below. */ +#if 0 + if (remember_on_history && hist_last_line_pushed == 0 && + hist_last_line_added && bash_delete_last_history () == 0) +#else + if (remember_on_history && hist_last_line_pushed == 0 && + (hist_last_line_added || + (current_command_line_count > 0 && current_command_first_line_saved && command_oriented_history)) + && bash_delete_last_history () == 0) +#endif + return; + + s = string_list (list); + /* Call check_add_history with FORCE set to 1 to skip the check against + current_command_line_count. If history -s is used in a compound + command, the above code will delete the compound command's history + entry and this call will add the line to the history as a separate + entry. Without FORCE=1, if current_command_line_count were > 1, the + line would be appended to the entry before the just-deleted entry. */ + check_add_history (s, 1); /* obeys HISTCONTROL, HISTIGNORE */ + + hist_last_line_pushed = 1; /* XXX */ + free (s); +} + +#if defined (BANG_HISTORY) +static int +expand_and_print_history (list) + WORD_LIST *list; +{ + char *s; + int r, result; + + if (hist_last_line_pushed == 0 && hist_last_line_added && bash_delete_last_history () == 0) + return EXECUTION_FAILURE; + result = EXECUTION_SUCCESS; + while (list) + { + r = history_expand (list->word->word, &s); + if (r < 0) + { + builtin_error (_("%s: history expansion failed"), list->word->word); + result = EXECUTION_FAILURE; + } + else + { + fputs (s, stdout); + putchar ('\n'); + } + FREE (s); + list = list->next; + } + fflush (stdout); + return result; +} +#endif /* BANG_HISTORY */ +#endif /* HISTORY */ diff --git a/builtins/inlib.def b/builtins/inlib.def new file mode 100644 index 0000000..c4faf0d --- /dev/null +++ b/builtins/inlib.def @@ -0,0 +1,80 @@ +This file is inlib.def, from which is created inlib.c. +It implements the Apollo-specific builtin "inlib" in Bash. + +Copyright (C) 1987-2002 Free Software Foundation, Inc. + +This file is part of GNU Bash, the Bourne Again SHell. + +Bash is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, 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. If not, see . + +$PRODUCES inlib.c +#include + +#include +#include "../shell.h" + +$BUILTIN inlib +$FUNCTION inlib_builtin +$DEPENDS_ON apollo +$SHORT_DOC inlib pathname [pathname...] +Install user-supplied library. + +Install a user-supplied library specified by pathname in the current +shell process. The library is used to resolve external references +in programs and libraries loaded after its installation. Note +that the library is not loaded into the address space unless it is +needed to resolve an external reference. The list of inlibed +libraries is passed to all children of the current shell. + +Exit Status: +Returns success unless PATHNAME is not found or an error occurs. +$END + +#if defined (apollo) + +#include +#include + +inlib_builtin (list) + WORD_LIST *list; +{ + status_$t status; + int return_value; + short len; + + if (!list) + { + builtin_usage (); + return (EX_USAGE); + } + + return_value = EXECUTION_SUCCESS; + + while (list) + { + len = (short)strlen (list->word->word); + loader_$inlib (list->word->word, len, &status); + + if (status.all != status_$ok) + { + builtin_error (_("%s: inlib failed"), list->word->word); + return_value = EXECUTION_FAILURE; + } + + list = list->next; + } + + return (return_value); +} +#endif /* apollo */ diff --git a/builtins/jobs.def b/builtins/jobs.def new file mode 100644 index 0000000..be1a7d8 --- /dev/null +++ b/builtins/jobs.def @@ -0,0 +1,300 @@ +This file is jobs.def, from which is created jobs.c. +It implements the builtins "jobs" and "disown" in Bash. + +Copyright (C) 1987-2015 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 3 of the License, 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. If not, see . + +$PRODUCES jobs.c + +$BUILTIN jobs +$FUNCTION jobs_builtin +$DEPENDS_ON JOB_CONTROL +$SHORT_DOC jobs [-lnprs] [jobspec ...] or jobs -x command [args] +Display status of jobs. + +Lists the active jobs. JOBSPEC restricts output to that job. +Without options, the status of all active jobs is displayed. + +Options: + -l lists process IDs in addition to the normal information + -n lists only processes that have changed status since the last + notification + -p lists process IDs only + -r restrict output to running jobs + -s restrict output to stopped jobs + +If -x is supplied, COMMAND is run after all job specifications that +appear in ARGS have been replaced with the process ID of that job's +process group leader. + +Exit Status: +Returns success unless an invalid option is given or an error occurs. +If -x is used, returns the exit status of COMMAND. +$END + +#include + +#if defined (JOB_CONTROL) +#include "../bashtypes.h" +#include +#if defined (HAVE_UNISTD_H) +# include +#endif + +#include "../bashansi.h" +#include "../bashintl.h" + +#include "../shell.h" +#include "../jobs.h" +#include "../execute_cmd.h" +#include "bashgetopt.h" +#include "common.h" + +#define JSTATE_ANY 0x0 +#define JSTATE_RUNNING 0x1 +#define JSTATE_STOPPED 0x2 + +static int execute_list_with_replacements __P((WORD_LIST *)); + +/* The `jobs' command. Prints outs a list of active jobs. If the + argument `-l' is given, then the process id's are printed also. + If the argument `-p' is given, print the process group leader's + pid only. If `-n' is given, only processes that have changed + status since the last notification are printed. If -x is given, + replace all job specs with the pid of the appropriate process + group leader and execute the command. The -r and -s options mean + to print info about running and stopped jobs only, respectively. */ +int +jobs_builtin (list) + WORD_LIST *list; +{ + int form, execute, state, opt, any_failed, job; + sigset_t set, oset; + + execute = any_failed = 0; + form = JLIST_STANDARD; + state = JSTATE_ANY; + + reset_internal_getopt (); + while ((opt = internal_getopt (list, "lpnxrs")) != -1) + { + switch (opt) + { + case 'l': + form = JLIST_LONG; + break; + case 'p': + form = JLIST_PID_ONLY; + break; + case 'n': + form = JLIST_CHANGED_ONLY; + break; + case 'x': + if (form != JLIST_STANDARD) + { + builtin_error (_("no other options allowed with `-x'")); + return (EXECUTION_FAILURE); + } + execute++; + break; + case 'r': + state = JSTATE_RUNNING; + break; + case 's': + state = JSTATE_STOPPED; + break; + + CASE_HELPOPT; + default: + builtin_usage (); + return (EX_USAGE); + } + } + + list = loptend; + + if (execute) + return (execute_list_with_replacements (list)); + + if (!list) + { + switch (state) + { + case JSTATE_ANY: + list_all_jobs (form); + break; + case JSTATE_RUNNING: + list_running_jobs (form); + break; + case JSTATE_STOPPED: + list_stopped_jobs (form); + break; + } + return (EXECUTION_SUCCESS); + } + + while (list) + { + BLOCK_CHILD (set, oset); + job = get_job_spec (list); + + if ((job == NO_JOB) || jobs == 0 || get_job_by_jid (job) == 0) + { + sh_badjob (list->word->word); + any_failed++; + } + else if (job != DUP_JOB) + list_one_job ((JOB *)NULL, form, 0, job); + + UNBLOCK_CHILD (oset); + list = list->next; + } + return (any_failed ? EXECUTION_FAILURE : EXECUTION_SUCCESS); +} + +static int +execute_list_with_replacements (list) + WORD_LIST *list; +{ + register WORD_LIST *l; + int job, result; + COMMAND *command; + JOB *j; + + /* First do the replacement of job specifications with pids. */ + for (l = list; l; l = l->next) + { + if (l->word->word[0] == '%') /* we have a winner */ + { + job = get_job_spec (l); + + /* A bad job spec is not really a job spec! Pass it through. */ + if (INVALID_JOB (job)) + continue; + + j = get_job_by_jid (job); + free (l->word->word); + l->word->word = itos (j->pgrp); + } + } + + /* Next make a new simple command and execute it. */ + begin_unwind_frame ("jobs_builtin"); + + command = make_bare_simple_command (); + command->value.Simple->words = copy_word_list (list); + command->value.Simple->redirects = (REDIRECT *)NULL; + command->flags |= CMD_INHIBIT_EXPANSION; + command->value.Simple->flags |= CMD_INHIBIT_EXPANSION; + + add_unwind_protect (dispose_command, command); + result = execute_command (command); + dispose_command (command); + + discard_unwind_frame ("jobs_builtin"); + return (result); +} +#endif /* JOB_CONTROL */ + +$BUILTIN disown +$FUNCTION disown_builtin +$DEPENDS_ON JOB_CONTROL +$SHORT_DOC disown [-h] [-ar] [jobspec ... | pid ...] +Remove jobs from current shell. + +Removes each JOBSPEC argument from the table of active jobs. Without +any JOBSPECs, the shell uses its notion of the current job. + +Options: + -a remove all jobs if JOBSPEC is not supplied + -h mark each JOBSPEC so that SIGHUP is not sent to the job if the + shell receives a SIGHUP + -r remove only running jobs + +Exit Status: +Returns success unless an invalid option or JOBSPEC is given. +$END + +#if defined (JOB_CONTROL) +int +disown_builtin (list) + WORD_LIST *list; +{ + int opt, job, retval, nohup_only, running_jobs, all_jobs; + sigset_t set, oset; + intmax_t pid_value; + + nohup_only = running_jobs = all_jobs = 0; + reset_internal_getopt (); + while ((opt = internal_getopt (list, "ahr")) != -1) + { + switch (opt) + { + case 'a': + all_jobs = 1; + break; + case 'h': + nohup_only = 1; + break; + case 'r': + running_jobs = 1; + break; + CASE_HELPOPT; + default: + builtin_usage (); + return (EX_USAGE); + } + } + list = loptend; + retval = EXECUTION_SUCCESS; + + /* `disown -a' or `disown -r' */ + if (list == 0 && (all_jobs || running_jobs)) + { + if (nohup_only) + nohup_all_jobs (running_jobs); + else + delete_all_jobs (running_jobs); + return (EXECUTION_SUCCESS); + } + + do + { + BLOCK_CHILD (set, oset); + job = (list && legal_number (list->word->word, &pid_value) && pid_value == (pid_t) pid_value) + ? get_job_by_pid ((pid_t) pid_value, 0) + : get_job_spec (list); + + if (job == NO_JOB || jobs == 0 || INVALID_JOB (job)) + { + sh_badjob (list ? list->word->word : _("current")); + retval = EXECUTION_FAILURE; + } + else if (nohup_only) + nohup_job (job); + else + delete_job (job, 1); + UNBLOCK_CHILD (oset); + + if (list) + list = list->next; + } + while (list); + + return (retval); +} +#endif /* JOB_CONTROL */ diff --git a/builtins/kill.def b/builtins/kill.def new file mode 100644 index 0000000..f05189d --- /dev/null +++ b/builtins/kill.def @@ -0,0 +1,267 @@ +This file is kill.def, from which is created kill.c. +It implements the builtin "kill" in Bash. + +Copyright (C) 1987-2015 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 3 of the License, 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. If not, see . + +$PRODUCES kill.c + +$BUILTIN kill +$FUNCTION kill_builtin +$SHORT_DOC kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec] +Send a signal to a job. + +Send the processes identified by PID or JOBSPEC the signal named by +SIGSPEC or SIGNUM. If neither SIGSPEC nor SIGNUM is present, then +SIGTERM is assumed. + +Options: + -s sig SIG is a signal name + -n sig SIG is a signal number + -l list the signal names; if arguments follow `-l' they are + assumed to be signal numbers for which names should be listed + -L synonym for -l + +Kill is a shell builtin for two reasons: it allows job IDs to be used +instead of process IDs, and allows processes to be killed if the limit +on processes that you can create is reached. + +Exit Status: +Returns success unless an invalid option is given or an error occurs. +$END + +#include + +#include +#include +#if defined (HAVE_UNISTD_H) +# ifdef _MINIX +# include +# endif +# include +#endif + +#include "../bashansi.h" +#include "../bashintl.h" + +#include + +#include "../shell.h" +#include "../trap.h" +#include "../jobs.h" +#include "common.h" + +/* Not all systems declare ERRNO in errno.h... and some systems #define it! */ +#if !defined (errno) +extern int errno; +#endif /* !errno */ + +extern int posixly_correct; + +static void kill_error __P((pid_t, int)); + +#if !defined (CONTINUE_AFTER_KILL_ERROR) +# define CONTINUE_OR_FAIL return (EXECUTION_FAILURE) +#else +# define CONTINUE_OR_FAIL goto continue_killing +#endif /* CONTINUE_AFTER_KILL_ERROR */ + +/* Here is the kill builtin. We only have it so that people can type + kill -KILL %1? No, if you fill up the process table this way you + can still kill some. */ +int +kill_builtin (list) + WORD_LIST *list; +{ + int sig, any_succeeded, listing, saw_signal, dflags; + char *sigspec, *word; + pid_t pid; + intmax_t pid_value; + + if (list == 0) + { + builtin_usage (); + return (EX_USAGE); + } + CHECK_HELPOPT (list); + + any_succeeded = listing = saw_signal = 0; + sig = SIGTERM; + sigspec = "TERM"; + + dflags = DSIG_NOCASE | ((posixly_correct == 0) ? DSIG_SIGPREFIX : 0); + /* Process options. */ + while (list) + { + word = list->word->word; + + if (ISOPTION (word, 'l') || ISOPTION (word, 'L')) + { + listing++; + list = list->next; + } + else if (ISOPTION (word, 's') || ISOPTION (word, 'n')) + { + list = list->next; + if (list) + { + sigspec = list->word->word; + if (sigspec[0] == '0' && sigspec[1] == '\0') + sig = 0; + else + sig = decode_signal (sigspec, dflags); + list = list->next; + saw_signal++; + } + else + { + sh_needarg (word); + return (EXECUTION_FAILURE); + } + } + else if (ISOPTION (word, '-')) + { + list = list->next; + break; + } + else if (ISOPTION (word, '?')) + { + builtin_usage (); + return (EX_USAGE); + } + /* If this is a signal specification then process it. We only process + the first one seen; other arguments may signify process groups (e.g, + -num == process group num). */ + else if (*word == '-' && saw_signal == 0) + { + sigspec = word + 1; + sig = decode_signal (sigspec, dflags); + saw_signal++; + list = list->next; + } + else + break; + } + + if (listing) + return (display_signal_list (list, 0)); + + /* OK, we are killing processes. */ + if (sig == NO_SIG) + { + sh_invalidsig (sigspec); + return (EXECUTION_FAILURE); + } + + if (list == 0) + { + builtin_usage (); + return (EX_USAGE); + } + + while (list) + { + word = list->word->word; + + if (*word == '-') + word++; + + /* Use the entire argument in case of minus sign presence. */ + if (*word && legal_number (list->word->word, &pid_value) && (pid_value == (pid_t)pid_value)) + { + pid = (pid_t) pid_value; + + if (kill_pid (pid, sig, pid < -1) < 0) + { + if (errno == EINVAL) + sh_invalidsig (sigspec); + else + kill_error (pid, errno); + CONTINUE_OR_FAIL; + } + else + any_succeeded++; + } +#if defined (JOB_CONTROL) + else if (*list->word->word && *list->word->word != '%') + { + builtin_error (_("%s: arguments must be process or job IDs"), list->word->word); + CONTINUE_OR_FAIL; + } + else if (*word) + /* Posix.2 says you can kill without job control active (4.32.4) */ + { /* Must be a job spec. Check it out. */ + int job; + sigset_t set, oset; + JOB *j; + + BLOCK_CHILD (set, oset); + job = get_job_spec (list); + + if (INVALID_JOB (job)) + { + if (job != DUP_JOB) + sh_badjob (list->word->word); + UNBLOCK_CHILD (oset); + CONTINUE_OR_FAIL; + } + + j = get_job_by_jid (job); + /* Job spec used. Kill the process group. If the job was started + without job control, then its pgrp == shell_pgrp, so we have + to be careful. We take the pid of the first job in the pipeline + in that case. */ + pid = IS_JOBCONTROL (job) ? j->pgrp : j->pipe->pid; + + UNBLOCK_CHILD (oset); + + if (kill_pid (pid, sig, 1) < 0) + { + if (errno == EINVAL) + sh_invalidsig (sigspec); + else + kill_error (pid, errno); + CONTINUE_OR_FAIL; + } + else + any_succeeded++; + } +#endif /* !JOB_CONTROL */ + else + { + sh_badpid (list->word->word); + CONTINUE_OR_FAIL; + } + continue_killing: + list = list->next; + } + + return (any_succeeded ? EXECUTION_SUCCESS : EXECUTION_FAILURE); +} + +static void +kill_error (pid, e) + pid_t pid; + int e; +{ + char *x; + + x = strerror (e); + if (x == 0) + x = _("Unknown error"); + builtin_error ("(%ld) - %s", (long)pid, x); +} diff --git a/builtins/let.def b/builtins/let.def new file mode 100644 index 0000000..23e684f --- /dev/null +++ b/builtins/let.def @@ -0,0 +1,131 @@ +This file is let.def, from which is created let.c. +It implements the builtin "let" in Bash. + +Copyright (C) 1987-2009 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 3 of the License, 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. If not, see . + +$BUILTIN let +$FUNCTION let_builtin +$PRODUCES let.c +$SHORT_DOC let arg [arg ...] +Evaluate arithmetic expressions. + +Evaluate each ARG as an arithmetic expression. Evaluation is done in +fixed-width integers with no check for overflow, though division by 0 +is trapped and flagged as an error. The following list of operators is +grouped into levels of equal-precedence operators. The levels are listed +in order of decreasing precedence. + + id++, id-- variable post-increment, post-decrement + ++id, --id variable pre-increment, pre-decrement + -, + unary minus, plus + !, ~ logical and bitwise negation + ** exponentiation + *, /, % multiplication, division, remainder + +, - addition, subtraction + <<, >> left and right bitwise shifts + <=, >=, <, > comparison + ==, != equality, inequality + & bitwise AND + ^ bitwise XOR + | bitwise OR + && logical AND + || logical OR + expr ? expr : expr + conditional operator + =, *=, /=, %=, + +=, -=, <<=, >>=, + &=, ^=, |= assignment + +Shell variables are allowed as operands. The name of the variable +is replaced by its value (coerced to a fixed-width integer) within +an expression. The variable need not have its integer attribute +turned on to be used in an expression. + +Operators are evaluated in order of precedence. Sub-expressions in +parentheses are evaluated first and may override the precedence +rules above. + +Exit Status: +If the last ARG evaluates to 0, let returns 1; let returns 0 otherwise. +$END + +#include + +#if defined (HAVE_UNISTD_H) +# ifdef _MINIX +# include +# endif +# include +#endif + +#include "../bashintl.h" + +#include "../shell.h" +#include "common.h" + +/* Arithmetic LET function. */ +int +let_builtin (list) + WORD_LIST *list; +{ + intmax_t ret; + int expok; + + CHECK_HELPOPT (list); + + /* Skip over leading `--' argument. */ + if (list && list->word && ISOPTION (list->word->word, '-')) + list = list->next; + + if (list == 0) + { + builtin_error (_("expression expected")); + return (EXECUTION_FAILURE); + } + + for (; list; list = list->next) + { + ret = evalexp (list->word->word, &expok); + if (expok == 0) + return (EXECUTION_FAILURE); + } + + return ((ret == 0) ? EXECUTION_FAILURE : EXECUTION_SUCCESS); +} + +#ifdef INCLUDE_UNUSED +int +exp_builtin (list) + WORD_LIST *list; +{ + char *exp; + intmax_t ret; + int expok; + + if (list == 0) + { + builtin_error (_("expression expected")); + return (EXECUTION_FAILURE); + } + + exp = string_list (list); + ret = evalexp (exp, &expok); + (void)free (exp); + return (((ret == 0) || (expok == 0)) ? EXECUTION_FAILURE : EXECUTION_SUCCESS); +} +#endif diff --git a/builtins/mapfile.def b/builtins/mapfile.def new file mode 100644 index 0000000..0d64f61 --- /dev/null +++ b/builtins/mapfile.def @@ -0,0 +1,375 @@ +This file is mapfile.def, from which is created mapfile.c. +It implements the builtin "mapfile" in Bash. + +Copyright (C) 2005-2006 Rocky Bernstein for Free Software Foundation, Inc. +Copyright (C) 2008-2016 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 3 of the License, 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. If not, see . + +$PRODUCES mapfile.c + +$BUILTIN mapfile +$FUNCTION mapfile_builtin +$SHORT_DOC mapfile [-d delim] [-n count] [-O origin] [-s count] [-t] [-u fd] [-C callback] [-c quantum] [array] +Read lines from the standard input into an indexed array variable. + +Read lines from the standard input into the indexed array variable ARRAY, or +from file descriptor FD if the -u option is supplied. The variable MAPFILE +is the default ARRAY. + +Options: + -d delim Use DELIM to terminate lines, instead of newline + -n count Copy at most COUNT lines. If COUNT is 0, all lines are copied + -O origin Begin assigning to ARRAY at index ORIGIN. The default index is 0 + -s count Discard the first COUNT lines read + -t Remove a trailing DELIM from each line read (default newline) + -u fd Read lines from file descriptor FD instead of the standard input + -C callback Evaluate CALLBACK each time QUANTUM lines are read + -c quantum Specify the number of lines read between each call to + CALLBACK + +Arguments: + ARRAY Array variable name to use for file data + +If -C is supplied without -c, the default quantum is 5000. When +CALLBACK is evaluated, it is supplied the index of the next array +element to be assigned and the line to be assigned to that element +as additional arguments. + +If not supplied with an explicit origin, mapfile will clear ARRAY before +assigning to it. + +Exit Status: +Returns success unless an invalid option is given or ARRAY is readonly or +not an indexed array. +$END + +$BUILTIN readarray +$FUNCTION mapfile_builtin +$SHORT_DOC readarray [-n count] [-O origin] [-s count] [-t] [-u fd] [-C callback] [-c quantum] [array] +Read lines from a file into an array variable. + +A synonym for `mapfile'. +$END + +#include + +#include "builtins.h" +#include "posixstat.h" + +#if defined (HAVE_UNISTD_H) +# include +#endif + +#include "bashansi.h" +#include "bashintl.h" + +#include +#include + +#include "../bashintl.h" +#include "../shell.h" +#include "common.h" +#include "bashgetopt.h" + +#if !defined (errno) +extern int errno; +#endif + +#if defined (ARRAY_VARS) + +static int run_callback __P((const char *, unsigned int, const char *)); + +#define DEFAULT_ARRAY_NAME "MAPFILE" +#define DEFAULT_VARIABLE_NAME "MAPLINE" /* not used right now */ + +/* The value specifying how frequently `mapfile' calls the callback. */ +#define DEFAULT_QUANTUM 5000 + +/* Values for FLAGS */ +#define MAPF_CLEARARRAY 0x01 +#define MAPF_CHOP 0x02 + +static int delim; + +static int +run_callback (callback, curindex, curline) + const char *callback; + unsigned int curindex; + const char *curline; +{ + unsigned int execlen; + char *execstr, *qline; + int flags; + + qline = sh_single_quote (curline); + execlen = strlen (callback) + strlen (qline) + 10; + /* 1 for each space between %s and %d, + another 1 for the last nul char for C string. */ + execlen += 3; + execstr = xmalloc (execlen); + + flags = SEVAL_NOHIST; +#if 0 + if (interactive) + flags |= SEVAL_INTERACT; +#endif + snprintf (execstr, execlen, "%s %d %s", callback, curindex, qline); + free (qline); + return evalstring (execstr, NULL, flags); +} + +static void +do_chop(line, delim) + char *line; + unsigned char delim; +{ + int length; + + length = strlen (line); + if (length && line[length-1] == delim) + line[length-1] = '\0'; +} + +static int +mapfile (fd, line_count_goal, origin, nskip, callback_quantum, callback, array_name, delim, flags) + int fd; + long line_count_goal, origin, nskip, callback_quantum; + char *callback, *array_name; + int delim; + int flags; +{ + char *line; + size_t line_length; + unsigned int array_index, line_count; + SHELL_VAR *entry; + int unbuffered_read; + + line = NULL; + line_length = 0; + unbuffered_read = 0; + + /* The following check should be done before reading any lines. Doing it + here allows us to call bind_array_element instead of bind_array_variable + and skip the variable lookup on every call. */ + entry = find_or_make_array_variable (array_name, 1); + if (entry == 0 || readonly_p (entry) || noassign_p (entry)) + { + if (entry && readonly_p (entry)) + err_readonly (array_name); + + return (EXECUTION_FAILURE); + } + else if (array_p (entry) == 0) + { + builtin_error (_("%s: not an indexed array"), array_name); + return (EXECUTION_FAILURE); + } + else if (invisible_p (entry)) + VUNSETATTR (entry, att_invisible); /* no longer invisible */ + + if (flags & MAPF_CLEARARRAY) + array_flush (array_cell (entry)); + +#ifndef __CYGWIN__ + unbuffered_read = (lseek (fd, 0L, SEEK_CUR) < 0) && (errno == ESPIPE); +#else + unbuffered_read = 1; +#endif + + if (delim != '\n') + unbuffered_read = 1; + + zreset (); + + /* Skip any lines at beginning of file? */ + for (line_count = 0; line_count < nskip; line_count++) + if (zgetline (fd, &line, &line_length, delim, unbuffered_read) < 0) + break; + + line = 0; + line_length = 0; + + /* Reset the buffer for bash own stream */ + for (array_index = origin, line_count = 1; + zgetline (fd, &line, &line_length, delim, unbuffered_read) != -1; + array_index++) + { + /* Remove trailing newlines? */ + if (flags & MAPF_CHOP) + do_chop (line, delim); + + /* Has a callback been registered and if so is it time to call it? */ + if (callback && line_count && (line_count % callback_quantum) == 0) + { + run_callback (callback, array_index, line); + + /* Reset the buffer for bash own stream. */ + if (unbuffered_read == 0) + zsyncfd (fd); + } + + /* XXX - bad things can happen if the callback modifies ENTRY, e.g., + unsetting it or changing it to a non-indexed-array type. */ + bind_array_element (entry, array_index, line, 0); + + /* Have we exceeded # of lines to store? */ + line_count++; + if (line_count_goal != 0 && line_count > line_count_goal) + break; + } + + xfree (line); + + if (unbuffered_read == 0) + zsyncfd (fd); + + return EXECUTION_SUCCESS; +} + +int +mapfile_builtin (list) + WORD_LIST *list; +{ + int opt, code, fd, clear_array, flags; + intmax_t intval; + long lines, origin, nskip, callback_quantum; + char *array_name, *callback; + + clear_array = 1; + fd = 0; + lines = origin = nskip = 0; + flags = MAPF_CLEARARRAY; + callback_quantum = DEFAULT_QUANTUM; + callback = 0; + delim = '\n'; + + reset_internal_getopt (); + while ((opt = internal_getopt (list, "d:u:n:O:tC:c:s:")) != -1) + { + switch (opt) + { + case 'd': + delim = *list_optarg; + break; + case 'u': + code = legal_number (list_optarg, &intval); + if (code == 0 || intval < 0 || intval != (int)intval) + { + builtin_error (_("%s: invalid file descriptor specification"), list_optarg); + return (EXECUTION_FAILURE); + } + else + fd = intval; + + if (sh_validfd (fd) == 0) + { + builtin_error (_("%d: invalid file descriptor: %s"), fd, strerror (errno)); + return (EXECUTION_FAILURE); + } + break; + + case 'n': + code = legal_number (list_optarg, &intval); + if (code == 0 || intval < 0 || intval != (unsigned)intval) + { + builtin_error (_("%s: invalid line count"), list_optarg); + return (EXECUTION_FAILURE); + } + else + lines = intval; + break; + + case 'O': + code = legal_number (list_optarg, &intval); + if (code == 0 || intval < 0 || intval != (unsigned)intval) + { + builtin_error (_("%s: invalid array origin"), list_optarg); + return (EXECUTION_FAILURE); + } + else + origin = intval; + flags &= ~MAPF_CLEARARRAY; + break; + case 't': + flags |= MAPF_CHOP; + break; + case 'C': + callback = list_optarg; + break; + case 'c': + code = legal_number (list_optarg, &intval); + if (code == 0 || intval <= 0 || intval != (unsigned)intval) + { + builtin_error (_("%s: invalid callback quantum"), list_optarg); + return (EXECUTION_FAILURE); + } + else + callback_quantum = intval; + break; + case 's': + code = legal_number (list_optarg, &intval); + if (code == 0 || intval < 0 || intval != (unsigned)intval) + { + builtin_error (_("%s: invalid line count"), list_optarg); + return (EXECUTION_FAILURE); + } + else + nskip = intval; + break; + CASE_HELPOPT; + default: + builtin_usage (); + return (EX_USAGE); + } + } + list = loptend; + + if (list == 0) + array_name = DEFAULT_ARRAY_NAME; + else if (list->word == 0 || list->word->word == 0) + { + builtin_error ("internal error: getting variable name"); + return (EXECUTION_FAILURE); + } + else if (list->word->word[0] == '\0') + { + builtin_error (_("empty array variable name")); + return (EX_USAGE); + } + else + array_name = list->word->word; + + if (legal_identifier (array_name) == 0) + { + sh_invalidid (array_name); + return (EXECUTION_FAILURE); + } + + return mapfile (fd, lines, origin, nskip, callback_quantum, callback, array_name, delim, flags); +} + +#else + +int +mapfile_builtin (list) + WORD_LIST *list; +{ + builtin_error (_("array variable support required")); + return (EXECUTION_FAILURE); +} + +#endif /* ARRAY_VARS */ diff --git a/builtins/mkbuiltins.c b/builtins/mkbuiltins.c new file mode 100644 index 0000000..4f51201 --- /dev/null +++ b/builtins/mkbuiltins.c @@ -0,0 +1,1659 @@ +/* mkbuiltins.c - Create builtins.c, builtext.h, and builtdoc.c from + a single source file called builtins.def. */ + +/* Copyright (C) 1987-2016 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 3 of the License, 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. If not, see . +*/ + +#if !defined (CROSS_COMPILING) +# include +#else /* CROSS_COMPILING */ +/* A conservative set of defines based on POSIX/SUS3/XPG6 */ +# define HAVE_UNISTD_H +# define HAVE_STRING_H +# define HAVE_STDLIB_H + +# define HAVE_RENAME +#endif /* CROSS_COMPILING */ + +#if defined (HAVE_UNISTD_H) +# ifdef _MINIX +# include +# endif +# include +#endif + +#ifndef _MINIX +# include "../bashtypes.h" +# if defined (HAVE_SYS_FILE_H) +# include +# endif +#endif + +#include "posixstat.h" +#include "filecntl.h" + +#include "../bashansi.h" +#include +#include + +#include "stdc.h" + +#define DOCFILE "builtins.texi" + +#ifndef errno +extern int errno; +#endif + +static char *xmalloc (), *xrealloc (); + +#if !defined (__STDC__) && !defined (strcpy) +extern char *strcpy (); +#endif /* !__STDC__ && !strcpy */ + +#define savestring(x) strcpy (xmalloc (1 + strlen (x)), (x)) +#define whitespace(c) (((c) == ' ') || ((c) == '\t')) + +/* Flag values that builtins can have. */ +#define BUILTIN_FLAG_SPECIAL 0x01 +#define BUILTIN_FLAG_ASSIGNMENT 0x02 +#define BUILTIN_FLAG_LOCALVAR 0x04 +#define BUILTIN_FLAG_POSIX_BUILTIN 0x08 + +#define BASE_INDENT 4 + +/* If this stream descriptor is non-zero, then write + texinfo documentation to it. */ +FILE *documentation_file = (FILE *)NULL; + +/* Non-zero means to only produce documentation. */ +int only_documentation = 0; + +/* Non-zero means to not do any productions. */ +int inhibit_production = 0; + +/* Non-zero means to not add functions (xxx_builtin) to the members of the + produced `struct builtin []' */ +int inhibit_functions = 0; + +/* Non-zero means to produce separate help files for each builtin, named by + the builtin name, in `./helpfiles'. */ +int separate_helpfiles = 0; + +/* Non-zero means to create single C strings for each `longdoc', with + embedded newlines, for ease of translation. */ +int single_longdoc_strings = 1; + +/* The name of a directory into which the separate external help files will + eventually be installed. */ +char *helpfile_directory; + +/* The name of a directory to precede the filename when reporting + errors. */ +char *error_directory = (char *)NULL; + +/* The name of the structure file. */ +char *struct_filename = (char *)NULL; + +/* The name of the external declaration file. */ +char *extern_filename = (char *)NULL; + +/* Here is a structure for manipulating arrays of data. */ +typedef struct { + int size; /* Number of slots allocated to array. */ + int sindex; /* Current location in array. */ + int width; /* Size of each element. */ + int growth_rate; /* How fast to grow. */ + char **array; /* The array itself. */ +} ARRAY; + +/* Here is a structure defining a single BUILTIN. */ +typedef struct { + char *name; /* The name of this builtin. */ + char *function; /* The name of the function to call. */ + char *shortdoc; /* The short documentation for this builtin. */ + char *docname; /* Possible name for documentation string. */ + ARRAY *longdoc; /* The long documentation for this builtin. */ + ARRAY *dependencies; /* Null terminated array of #define names. */ + int flags; /* Flags for this builtin. */ +} BUILTIN_DESC; + +/* Here is a structure which defines a DEF file. */ +typedef struct { + char *filename; /* The name of the input def file. */ + ARRAY *lines; /* The contents of the file. */ + int line_number; /* The current line number. */ + char *production; /* The name of the production file. */ + FILE *output; /* Open file stream for PRODUCTION. */ + ARRAY *builtins; /* Null terminated array of BUILTIN_DESC *. */ +} DEF_FILE; + +/* The array of all builtins encountered during execution of this code. */ +ARRAY *saved_builtins = (ARRAY *)NULL; + +/* The Posix.2 so-called `special' builtins. */ +char *special_builtins[] = +{ + ":", ".", "source", "break", "continue", "eval", "exec", "exit", + "export", "readonly", "return", "set", "shift", "times", "trap", "unset", + (char *)NULL +}; + +/* The builtin commands that take assignment statements as arguments. */ +char *assignment_builtins[] = +{ + "alias", "declare", "export", "local", "readonly", "typeset", + (char *)NULL +}; + +char *localvar_builtins[] = +{ + "declare", "local", "typeset", (char *)NULL +}; + +/* The builtin commands that are special to the POSIX search order. */ +char *posix_builtins[] = +{ + "alias", "bg", "cd", "command", "false", "fc", "fg", "getopts", "jobs", + "kill", "newgrp", "pwd", "read", "true", "umask", "unalias", "wait", + (char *)NULL +}; + +/* Forward declarations. */ +static int is_special_builtin (); +static int is_assignment_builtin (); +static int is_localvar_builtin (); +static int is_posix_builtin (); + +#if !defined (HAVE_RENAME) +static int rename (); +#endif + +void extract_info (); + +void file_error (); +void line_error (); + +void write_file_headers (); +void write_file_footers (); +void write_ifdefs (); +void write_endifs (); +void write_documentation (); +void write_longdocs (); +void write_builtins (); + +int write_helpfiles (); + +void free_defs (); +void add_documentation (); + +void must_be_building (); +void remove_trailing_whitespace (); + +#define document_name(b) ((b)->docname ? (b)->docname : (b)->name) + + +/* For each file mentioned on the command line, process it and + write the information to STRUCTFILE and EXTERNFILE, while + creating the production file if necessary. */ +int +main (argc, argv) + int argc; + char **argv; +{ + int arg_index = 1; + FILE *structfile, *externfile; + char *documentation_filename, *temp_struct_filename; + + structfile = externfile = (FILE *)NULL; + documentation_filename = DOCFILE; + temp_struct_filename = (char *)NULL; + + while (arg_index < argc && argv[arg_index][0] == '-') + { + char *arg = argv[arg_index++]; + + if (strcmp (arg, "-externfile") == 0) + extern_filename = argv[arg_index++]; + else if (strcmp (arg, "-structfile") == 0) + struct_filename = argv[arg_index++]; + else if (strcmp (arg, "-noproduction") == 0) + inhibit_production = 1; + else if (strcmp (arg, "-nofunctions") == 0) + inhibit_functions = 1; + else if (strcmp (arg, "-document") == 0) + documentation_file = fopen (documentation_filename, "w"); + else if (strcmp (arg, "-D") == 0) + { + int len; + + if (error_directory) + free (error_directory); + + error_directory = xmalloc (2 + strlen (argv[arg_index])); + strcpy (error_directory, argv[arg_index]); + len = strlen (error_directory); + + if (len && error_directory[len - 1] != '/') + strcat (error_directory, "/"); + + arg_index++; + } + else if (strcmp (arg, "-documentonly") == 0) + { + only_documentation = 1; + documentation_file = fopen (documentation_filename, "w"); + } + else if (strcmp (arg, "-H") == 0) + { + separate_helpfiles = 1; + helpfile_directory = argv[arg_index++]; + } + else if (strcmp (arg, "-S") == 0) + single_longdoc_strings = 0; + else + { + fprintf (stderr, "%s: Unknown flag %s.\n", argv[0], arg); + exit (2); + } + } + + /* If there are no files to process, just quit now. */ + if (arg_index == argc) + exit (0); + + if (!only_documentation) + { + /* Open the files. */ + if (struct_filename) + { + temp_struct_filename = xmalloc (15); + sprintf (temp_struct_filename, "mk-%ld", (long) getpid ()); + structfile = fopen (temp_struct_filename, "w"); + + if (!structfile) + file_error (temp_struct_filename); + } + + if (extern_filename) + { + externfile = fopen (extern_filename, "w"); + + if (!externfile) + file_error (extern_filename); + } + + /* Write out the headers. */ + write_file_headers (structfile, externfile); + } + + if (documentation_file) + { + fprintf (documentation_file, "@c Table of builtins created with %s.\n", + argv[0]); + fprintf (documentation_file, "@ftable @asis\n"); + } + + /* Process the .def files. */ + while (arg_index < argc) + { + register char *arg; + + arg = argv[arg_index++]; + + extract_info (arg, structfile, externfile); + } + + /* Close the files. */ + if (!only_documentation) + { + /* Write the footers. */ + write_file_footers (structfile, externfile); + + if (structfile) + { + write_longdocs (structfile, saved_builtins); + fclose (structfile); + rename (temp_struct_filename, struct_filename); + } + + if (externfile) + fclose (externfile); + } + +#if 0 + /* This is now done by a different program */ + if (separate_helpfiles) + { + write_helpfiles (saved_builtins); + } +#endif + + if (documentation_file) + { + fprintf (documentation_file, "@end ftable\n"); + fclose (documentation_file); + } + + exit (0); +} + +/* **************************************************************** */ +/* */ +/* Array Functions and Manipulators */ +/* */ +/* **************************************************************** */ + +/* Make a new array, and return a pointer to it. The array will + contain elements of size WIDTH, and is initialized to no elements. */ +ARRAY * +array_create (width) + int width; +{ + ARRAY *array; + + array = (ARRAY *)xmalloc (sizeof (ARRAY)); + array->size = 0; + array->sindex = 0; + array->width = width; + + /* Default to increasing size in units of 20. */ + array->growth_rate = 20; + + array->array = (char **)NULL; + + return (array); +} + +/* Copy the array of strings in ARRAY. */ +ARRAY * +copy_string_array (array) + ARRAY *array; +{ + register int i; + ARRAY *copy; + + if (!array) + return (ARRAY *)NULL; + + copy = array_create (sizeof (char *)); + + copy->size = array->size; + copy->sindex = array->sindex; + copy->width = array->width; + + copy->array = (char **)xmalloc ((1 + array->sindex) * sizeof (char *)); + + for (i = 0; i < array->sindex; i++) + copy->array[i] = savestring (array->array[i]); + + copy->array[i] = (char *)NULL; + + return (copy); +} + +/* Add ELEMENT to ARRAY, growing the array if necessary. */ +void +array_add (element, array) + char *element; + ARRAY *array; +{ + if (array->sindex + 2 > array->size) + array->array = (char **)xrealloc + (array->array, (array->size += array->growth_rate) * array->width); + + array->array[array->sindex++] = element; + array->array[array->sindex] = (char *)NULL; +} + +/* Free an allocated array and data pointer. */ +void +array_free (array) + ARRAY *array; +{ + if (array->array) + free (array->array); + + free (array); +} + +/* **************************************************************** */ +/* */ +/* Processing a DEF File */ +/* */ +/* **************************************************************** */ + +/* The definition of a function. */ +typedef int Function (); +typedef int mk_handler_func_t __P((char *, DEF_FILE *, char *)); + +/* Structure handles processor directives. */ +typedef struct { + char *directive; + mk_handler_func_t *function; +} HANDLER_ENTRY; + +extern int builtin_handler __P((char *, DEF_FILE *, char *)); +extern int function_handler __P((char *, DEF_FILE *, char *)); +extern int short_doc_handler __P((char *, DEF_FILE *, char *)); +extern int comment_handler __P((char *, DEF_FILE *, char *)); +extern int depends_on_handler __P((char *, DEF_FILE *, char *)); +extern int produces_handler __P((char *, DEF_FILE *, char *)); +extern int end_handler __P((char *, DEF_FILE *, char *)); +extern int docname_handler __P((char *, DEF_FILE *, char *)); + +HANDLER_ENTRY handlers[] = { + { "BUILTIN", builtin_handler }, + { "DOCNAME", docname_handler }, + { "FUNCTION", function_handler }, + { "SHORT_DOC", short_doc_handler }, + { "$", comment_handler }, + { "COMMENT", comment_handler }, + { "DEPENDS_ON", depends_on_handler }, + { "PRODUCES", produces_handler }, + { "END", end_handler }, + { (char *)NULL, (mk_handler_func_t *)NULL } +}; + +/* Return the entry in the table of handlers for NAME. */ +HANDLER_ENTRY * +find_directive (directive) + char *directive; +{ + register int i; + + for (i = 0; handlers[i].directive; i++) + if (strcmp (handlers[i].directive, directive) == 0) + return (&handlers[i]); + + return ((HANDLER_ENTRY *)NULL); +} + +/* Non-zero indicates that a $BUILTIN has been seen, but not + the corresponding $END. */ +static int building_builtin = 0; + +/* Non-zero means to output cpp line and file information before + printing the current line to the production file. */ +int output_cpp_line_info = 0; + +/* The main function of this program. Read FILENAME and act on what is + found. Lines not starting with a dollar sign are copied to the + $PRODUCES target, if one is present. Lines starting with a dollar sign + are directives to this program, specifying the name of the builtin, the + function to call, the short documentation and the long documentation + strings. FILENAME can contain multiple $BUILTINs, but only one $PRODUCES + target. After the file has been processed, write out the names of + builtins found in each $BUILTIN. Plain text found before the $PRODUCES + is ignored, as is "$$ comment text". */ +void +extract_info (filename, structfile, externfile) + char *filename; + FILE *structfile, *externfile; +{ + register int i; + DEF_FILE *defs; + struct stat finfo; + size_t file_size; + char *buffer, *line; + int fd, nr; + + if (stat (filename, &finfo) == -1) + file_error (filename); + + fd = open (filename, O_RDONLY, 0666); + + if (fd == -1) + file_error (filename); + + file_size = (size_t)finfo.st_size; + buffer = xmalloc (1 + file_size); + + if ((nr = read (fd, buffer, file_size)) < 0) + file_error (filename); + + /* This is needed on WIN32, and does not hurt on Unix. */ + if (nr < file_size) + file_size = nr; + + close (fd); + + if (nr == 0) + { + fprintf (stderr, "mkbuiltins: %s: skipping zero-length file\n", filename); + free (buffer); + return; + } + + /* Create and fill in the initial structure describing this file. */ + defs = (DEF_FILE *)xmalloc (sizeof (DEF_FILE)); + defs->filename = filename; + defs->lines = array_create (sizeof (char *)); + defs->line_number = 0; + defs->production = (char *)NULL; + defs->output = (FILE *)NULL; + defs->builtins = (ARRAY *)NULL; + + /* Build the array of lines. */ + i = 0; + while (i < file_size) + { + array_add (&buffer[i], defs->lines); + + while (i < file_size && buffer[i] != '\n') + i++; + buffer[i++] = '\0'; + } + + /* Begin processing the input file. We don't write any output + until we have a file to write output to. */ + output_cpp_line_info = 1; + + /* Process each line in the array. */ + for (i = 0; line = defs->lines->array[i]; i++) + { + defs->line_number = i; + + if (*line == '$') + { + register int j; + char *directive; + HANDLER_ENTRY *handler; + + /* Isolate the directive. */ + for (j = 0; line[j] && !whitespace (line[j]); j++); + + directive = xmalloc (j); + strncpy (directive, line + 1, j - 1); + directive[j -1] = '\0'; + + /* Get the function handler and call it. */ + handler = find_directive (directive); + + if (!handler) + { + line_error (defs, "Unknown directive `%s'", directive); + free (directive); + continue; + } + else + { + /* Advance to the first non-whitespace character. */ + while (whitespace (line[j])) + j++; + + /* Call the directive handler with the FILE, and ARGS. */ + (*(handler->function)) (directive, defs, line + j); + } + free (directive); + } + else + { + if (building_builtin) + add_documentation (defs, line); + else if (defs->output) + { + if (output_cpp_line_info) + { + /* If we're handed an absolute pathname, don't prepend + the directory name. */ + if (defs->filename[0] == '/') + fprintf (defs->output, "#line %d \"%s\"\n", + defs->line_number + 1, defs->filename); + else + fprintf (defs->output, "#line %d \"%s%s\"\n", + defs->line_number + 1, + error_directory ? error_directory : "./", + defs->filename); + output_cpp_line_info = 0; + } + + fprintf (defs->output, "%s\n", line); + } + } + } + + /* Close the production file. */ + if (defs->output) + fclose (defs->output); + + /* The file has been processed. Write the accumulated builtins to + the builtins.c file, and write the extern definitions to the + builtext.h file. */ + write_builtins (defs, structfile, externfile); + + free (buffer); + free_defs (defs); +} + +#define free_safely(x) if (x) free (x) + +static void +free_builtin (builtin) + BUILTIN_DESC *builtin; +{ + register int i; + + free_safely (builtin->name); + free_safely (builtin->function); + free_safely (builtin->shortdoc); + free_safely (builtin->docname); + + if (builtin->longdoc) + array_free (builtin->longdoc); + + if (builtin->dependencies) + { + for (i = 0; builtin->dependencies->array[i]; i++) + free (builtin->dependencies->array[i]); + array_free (builtin->dependencies); + } +} + +/* Free all of the memory allocated to a DEF_FILE. */ +void +free_defs (defs) + DEF_FILE *defs; +{ + register int i; + register BUILTIN_DESC *builtin; + + if (defs->production) + free (defs->production); + + if (defs->lines) + array_free (defs->lines); + + if (defs->builtins) + { + for (i = 0; builtin = (BUILTIN_DESC *)defs->builtins->array[i]; i++) + { + free_builtin (builtin); + free (builtin); + } + array_free (defs->builtins); + } + free (defs); +} + +/* **************************************************************** */ +/* */ +/* The Handler Functions Themselves */ +/* */ +/* **************************************************************** */ + +/* Strip surrounding whitespace from STRING, and + return a pointer to the start of it. */ +char * +strip_whitespace (string) + char *string; +{ + while (whitespace (*string)) + string++; + + remove_trailing_whitespace (string); + return (string); +} + +/* Remove only the trailing whitespace from STRING. */ +void +remove_trailing_whitespace (string) + char *string; +{ + register int i; + + i = strlen (string) - 1; + + while (i > 0 && whitespace (string[i])) + i--; + + string[++i] = '\0'; +} + +/* Ensure that there is a argument in STRING and return it. + FOR_WHOM is the name of the directive which needs the argument. + DEFS is the DEF_FILE in which the directive is found. + If there is no argument, produce an error. */ +char * +get_arg (for_whom, defs, string) + char *for_whom, *string; + DEF_FILE *defs; +{ + char *new; + + new = strip_whitespace (string); + + if (!*new) + line_error (defs, "%s requires an argument", for_whom); + + return (savestring (new)); +} + +/* Error if not building a builtin. */ +void +must_be_building (directive, defs) + char *directive; + DEF_FILE *defs; +{ + if (!building_builtin) + line_error (defs, "%s must be inside of a $BUILTIN block", directive); +} + +/* Return the current builtin. */ +BUILTIN_DESC * +current_builtin (directive, defs) + char *directive; + DEF_FILE *defs; +{ + must_be_building (directive, defs); + if (defs->builtins) + return ((BUILTIN_DESC *)defs->builtins->array[defs->builtins->sindex - 1]); + else + return ((BUILTIN_DESC *)NULL); +} + +/* Add LINE to the long documentation for the current builtin. + Ignore blank lines until the first non-blank line has been seen. */ +void +add_documentation (defs, line) + DEF_FILE *defs; + char *line; +{ + register BUILTIN_DESC *builtin; + + builtin = current_builtin ("(implied LONGDOC)", defs); + + remove_trailing_whitespace (line); + + if (!*line && !builtin->longdoc) + return; + + if (!builtin->longdoc) + builtin->longdoc = array_create (sizeof (char *)); + + array_add (line, builtin->longdoc); +} + +/* How to handle the $BUILTIN directive. */ +int +builtin_handler (self, defs, arg) + char *self; + DEF_FILE *defs; + char *arg; +{ + BUILTIN_DESC *new; + char *name; + + /* If we are already building a builtin, we cannot start a new one. */ + if (building_builtin) + { + line_error (defs, "%s found before $END", self); + return (-1); + } + + output_cpp_line_info++; + + /* Get the name of this builtin, and stick it in the array. */ + name = get_arg (self, defs, arg); + + /* If this is the first builtin, create the array to hold them. */ + if (!defs->builtins) + defs->builtins = array_create (sizeof (BUILTIN_DESC *)); + + new = (BUILTIN_DESC *)xmalloc (sizeof (BUILTIN_DESC)); + new->name = name; + new->function = (char *)NULL; + new->shortdoc = (char *)NULL; + new->docname = (char *)NULL; + new->longdoc = (ARRAY *)NULL; + new->dependencies = (ARRAY *)NULL; + new->flags = 0; + + if (is_special_builtin (name)) + new->flags |= BUILTIN_FLAG_SPECIAL; + if (is_assignment_builtin (name)) + new->flags |= BUILTIN_FLAG_ASSIGNMENT; + if (is_localvar_builtin (name)) + new->flags |= BUILTIN_FLAG_LOCALVAR; + if (is_posix_builtin (name)) + new->flags |= BUILTIN_FLAG_POSIX_BUILTIN; + + array_add ((char *)new, defs->builtins); + building_builtin = 1; + + return (0); +} + +/* How to handle the $FUNCTION directive. */ +int +function_handler (self, defs, arg) + char *self; + DEF_FILE *defs; + char *arg; +{ + register BUILTIN_DESC *builtin; + + builtin = current_builtin (self, defs); + + if (builtin == 0) + { + line_error (defs, "syntax error: no current builtin for $FUNCTION directive"); + exit (1); + } + if (builtin->function) + line_error (defs, "%s already has a function (%s)", + builtin->name, builtin->function); + else + builtin->function = get_arg (self, defs, arg); + + return (0); +} + +/* How to handle the $DOCNAME directive. */ +int +docname_handler (self, defs, arg) + char *self; + DEF_FILE *defs; + char *arg; +{ + register BUILTIN_DESC *builtin; + + builtin = current_builtin (self, defs); + + if (builtin->docname) + line_error (defs, "%s already had a docname (%s)", + builtin->name, builtin->docname); + else + builtin->docname = get_arg (self, defs, arg); + + return (0); +} + +/* How to handle the $SHORT_DOC directive. */ +int +short_doc_handler (self, defs, arg) + char *self; + DEF_FILE *defs; + char *arg; +{ + register BUILTIN_DESC *builtin; + + builtin = current_builtin (self, defs); + + if (builtin->shortdoc) + line_error (defs, "%s already has short documentation (%s)", + builtin->name, builtin->shortdoc); + else + builtin->shortdoc = get_arg (self, defs, arg); + + return (0); +} + +/* How to handle the $COMMENT directive. */ +int +comment_handler (self, defs, arg) + char *self; + DEF_FILE *defs; + char *arg; +{ + return (0); +} + +/* How to handle the $DEPENDS_ON directive. */ +int +depends_on_handler (self, defs, arg) + char *self; + DEF_FILE *defs; + char *arg; +{ + register BUILTIN_DESC *builtin; + char *dependent; + + builtin = current_builtin (self, defs); + dependent = get_arg (self, defs, arg); + + if (!builtin->dependencies) + builtin->dependencies = array_create (sizeof (char *)); + + array_add (dependent, builtin->dependencies); + + return (0); +} + +/* How to handle the $PRODUCES directive. */ +int +produces_handler (self, defs, arg) + char *self; + DEF_FILE *defs; + char *arg; +{ + /* If just hacking documentation, don't change any of the production + files. */ + if (only_documentation) + return (0); + + output_cpp_line_info++; + + if (defs->production) + line_error (defs, "%s already has a %s definition", defs->filename, self); + else + { + defs->production = get_arg (self, defs, arg); + + if (inhibit_production) + return (0); + + defs->output = fopen (defs->production, "w"); + + if (!defs->output) + file_error (defs->production); + + fprintf (defs->output, "/* %s, created from %s. */\n", + defs->production, defs->filename); + } + return (0); +} + +/* How to handle the $END directive. */ +int +end_handler (self, defs, arg) + char *self; + DEF_FILE *defs; + char *arg; +{ + must_be_building (self, defs); + building_builtin = 0; + return (0); +} + +/* **************************************************************** */ +/* */ +/* Error Handling Functions */ +/* */ +/* **************************************************************** */ + +/* Produce an error for DEFS with FORMAT and ARGS. */ +void +line_error (defs, format, arg1, arg2) + DEF_FILE *defs; + char *format, *arg1, *arg2; +{ + if (defs->filename[0] != '/') + fprintf (stderr, "%s", error_directory ? error_directory : "./"); + fprintf (stderr, "%s:%d:", defs->filename, defs->line_number + 1); + fprintf (stderr, format, arg1, arg2); + fprintf (stderr, "\n"); + fflush (stderr); +} + +/* Print error message for FILENAME. */ +void +file_error (filename) + char *filename; +{ + perror (filename); + exit (2); +} + +/* **************************************************************** */ +/* */ +/* xmalloc and xrealloc () */ +/* */ +/* **************************************************************** */ + +static void memory_error_and_abort (); + +static char * +xmalloc (bytes) + int bytes; +{ + char *temp = (char *)malloc (bytes); + + if (!temp) + memory_error_and_abort (); + return (temp); +} + +static char * +xrealloc (pointer, bytes) + char *pointer; + int bytes; +{ + char *temp; + + if (!pointer) + temp = (char *)malloc (bytes); + else + temp = (char *)realloc (pointer, bytes); + + if (!temp) + memory_error_and_abort (); + + return (temp); +} + +static void +memory_error_and_abort () +{ + fprintf (stderr, "mkbuiltins: out of virtual memory\n"); + abort (); +} + +/* **************************************************************** */ +/* */ +/* Creating the Struct and Extern Files */ +/* */ +/* **************************************************************** */ + +/* Return a pointer to a newly allocated builtin which is + an exact copy of BUILTIN. */ +BUILTIN_DESC * +copy_builtin (builtin) + BUILTIN_DESC *builtin; +{ + BUILTIN_DESC *new; + + new = (BUILTIN_DESC *)xmalloc (sizeof (BUILTIN_DESC)); + + new->name = savestring (builtin->name); + new->shortdoc = savestring (builtin->shortdoc); + new->longdoc = copy_string_array (builtin->longdoc); + new->dependencies = copy_string_array (builtin->dependencies); + + new->function = + builtin->function ? savestring (builtin->function) : (char *)NULL; + new->docname = + builtin->docname ? savestring (builtin->docname) : (char *)NULL; + + return (new); +} + +/* How to save away a builtin. */ +void +save_builtin (builtin) + BUILTIN_DESC *builtin; +{ + BUILTIN_DESC *newbuiltin; + + newbuiltin = copy_builtin (builtin); + + /* If this is the first builtin to be saved, create the array + to hold it. */ + if (!saved_builtins) + saved_builtins = array_create (sizeof (BUILTIN_DESC *)); + + array_add ((char *)newbuiltin, saved_builtins); +} + +/* Flags that mean something to write_documentation (). */ +#define STRING_ARRAY 0x01 +#define TEXINFO 0x02 +#define PLAINTEXT 0x04 +#define HELPFILE 0x08 + +char *structfile_header[] = { + "/* builtins.c -- the built in shell commands. */", + "", + "/* This file is manufactured by ./mkbuiltins, and should not be", + " edited by hand. See the source to mkbuiltins for details. */", + "", + "/* Copyright (C) 1987-2015 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 3 of the License, 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. If not, see .", + "*/", + "", + "/* The list of shell builtins. Each element is name, function, flags,", + " long-doc, short-doc. The long-doc field contains a pointer to an array", + " of help lines. The function takes a WORD_LIST *; the first word in the", + " list is the first arg to the command. The list has already had word", + " expansion performed.", + "", + " Functions which need to look at only the simple commands (e.g.", + " the enable_builtin ()), should ignore entries where", + " (array[i].function == (sh_builtin_func_t *)NULL). Such entries are for", + " the list of shell reserved control structures, like `if' and `while'.", + " The end of the list is denoted with a NULL name field. */", + "", + "/* TRANSLATORS: Please do not translate command names in descriptions */", + "", + "#include \"../builtins.h\"", + (char *)NULL + }; + +char *structfile_footer[] = { + " { (char *)0x0, (sh_builtin_func_t *)0x0, 0, (char **)0x0, (char *)0x0, (char *)0x0 }", + "};", + "", + "struct builtin *shell_builtins = static_shell_builtins;", + "struct builtin *current_builtin;", + "", + "int num_shell_builtins =", + "\tsizeof (static_shell_builtins) / sizeof (struct builtin) - 1;", + (char *)NULL +}; + +/* Write out any necessary opening information for + STRUCTFILE and EXTERNFILE. */ +void +write_file_headers (structfile, externfile) + FILE *structfile, *externfile; +{ + register int i; + + if (structfile) + { + for (i = 0; structfile_header[i]; i++) + fprintf (structfile, "%s\n", structfile_header[i]); + + fprintf (structfile, "#include \"%s\"\n", + extern_filename ? extern_filename : "builtext.h"); + + fprintf (structfile, "#include \"bashintl.h\"\n"); + + fprintf (structfile, "\nstruct builtin static_shell_builtins[] = {\n"); + } + + if (externfile) + fprintf (externfile, + "/* %s - The list of builtins found in libbuiltins.a. */\n", + extern_filename ? extern_filename : "builtext.h"); +} + +/* Write out any necessary closing information for + STRUCTFILE and EXTERNFILE. */ +void +write_file_footers (structfile, externfile) + FILE *structfile, *externfile; +{ + register int i; + + /* Write out the footers. */ + if (structfile) + { + for (i = 0; structfile_footer[i]; i++) + fprintf (structfile, "%s\n", structfile_footer[i]); + } +} + +/* Write out the information accumulated in DEFS to + STRUCTFILE and EXTERNFILE. */ +void +write_builtins (defs, structfile, externfile) + DEF_FILE *defs; + FILE *structfile, *externfile; +{ + register int i; + + /* Write out the information. */ + if (defs->builtins) + { + register BUILTIN_DESC *builtin; + + for (i = 0; i < defs->builtins->sindex; i++) + { + builtin = (BUILTIN_DESC *)defs->builtins->array[i]; + + /* Write out any #ifdefs that may be there. */ + if (!only_documentation) + { + if (builtin->dependencies) + { + write_ifdefs (externfile, builtin->dependencies->array); + write_ifdefs (structfile, builtin->dependencies->array); + } + + /* Write the extern definition. */ + if (externfile) + { + if (builtin->function) + fprintf (externfile, "extern int %s __P((WORD_LIST *));\n", + builtin->function); + + fprintf (externfile, "extern char * const %s_doc[];\n", + document_name (builtin)); + } + + /* Write the structure definition. */ + if (structfile) + { + fprintf (structfile, " { \"%s\", ", builtin->name); + + if (builtin->function && inhibit_functions == 0) + fprintf (structfile, "%s, ", builtin->function); + else + fprintf (structfile, "(sh_builtin_func_t *)0x0, "); + + fprintf (structfile, "%s%s%s%s%s, %s_doc,\n", + "BUILTIN_ENABLED | STATIC_BUILTIN", + (builtin->flags & BUILTIN_FLAG_SPECIAL) ? " | SPECIAL_BUILTIN" : "", + (builtin->flags & BUILTIN_FLAG_ASSIGNMENT) ? " | ASSIGNMENT_BUILTIN" : "", + (builtin->flags & BUILTIN_FLAG_LOCALVAR) ? " | LOCALVAR_BUILTIN" : "", + (builtin->flags & BUILTIN_FLAG_POSIX_BUILTIN) ? " | POSIX_BUILTIN" : "", + document_name (builtin)); + + /* Don't translate short document summaries that are identical + to command names */ + if (builtin->shortdoc && strcmp (builtin->name, builtin->shortdoc) == 0) + { + if (inhibit_functions) + fprintf (structfile, " \"%s\", \"%s\" },\n", + builtin->shortdoc ? builtin->shortdoc : builtin->name, + document_name (builtin)); + else + fprintf (structfile, " \"%s\", (char *)NULL },\n", + builtin->shortdoc ? builtin->shortdoc : builtin->name); + } + else + { + if (inhibit_functions) + fprintf (structfile, " N_(\"%s\"), \"%s\" },\n", + builtin->shortdoc ? builtin->shortdoc : builtin->name, + document_name (builtin)); + else + fprintf (structfile, " N_(\"%s\"), (char *)NULL },\n", + builtin->shortdoc ? builtin->shortdoc : builtin->name); + } + } + + if (structfile || separate_helpfiles) + /* Save away this builtin for later writing of the + long documentation strings. */ + save_builtin (builtin); + + /* Write out the matching #endif, if necessary. */ + if (builtin->dependencies) + { + if (externfile) + write_endifs (externfile, builtin->dependencies->array); + + if (structfile) + write_endifs (structfile, builtin->dependencies->array); + } + } + + if (documentation_file) + { + fprintf (documentation_file, "@item %s\n", builtin->name); + write_documentation + (documentation_file, builtin->longdoc->array, 0, TEXINFO); + } + } + } +} + +/* Write out the long documentation strings in BUILTINS to STREAM. */ +void +write_longdocs (stream, builtins) + FILE *stream; + ARRAY *builtins; +{ + register int i; + register BUILTIN_DESC *builtin; + char *dname; + char *sarray[2]; + + for (i = 0; i < builtins->sindex; i++) + { + builtin = (BUILTIN_DESC *)builtins->array[i]; + + if (builtin->dependencies) + write_ifdefs (stream, builtin->dependencies->array); + + /* Write the long documentation strings. */ + dname = document_name (builtin); + fprintf (stream, "char * const %s_doc[] =", dname); + + if (separate_helpfiles) + { + int l = strlen (helpfile_directory) + strlen (dname) + 1; + sarray[0] = (char *)xmalloc (l + 1); + sprintf (sarray[0], "%s/%s", helpfile_directory, dname); + sarray[1] = (char *)NULL; + write_documentation (stream, sarray, 0, STRING_ARRAY|HELPFILE); + free (sarray[0]); + } + else + write_documentation (stream, builtin->longdoc->array, 0, STRING_ARRAY); + + if (builtin->dependencies) + write_endifs (stream, builtin->dependencies->array); + + } +} + +void +write_dummy_declarations (stream, builtins) + FILE *stream; + ARRAY *builtins; +{ + register int i; + BUILTIN_DESC *builtin; + + for (i = 0; structfile_header[i]; i++) + fprintf (stream, "%s\n", structfile_header[i]); + + for (i = 0; i < builtins->sindex; i++) + { + builtin = (BUILTIN_DESC *)builtins->array[i]; + + /* How to guarantee that no builtin is written more than once? */ + fprintf (stream, "int %s () { return (0); }\n", builtin->function); + } +} + +/* Write an #ifdef string saying what needs to be defined (or not defined) + in order to allow compilation of the code that will follow. + STREAM is the stream to write the information to, + DEFINES is a null terminated array of define names. + If a define is preceded by an `!', then the sense of the test is + reversed. */ +void +write_ifdefs (stream, defines) + FILE *stream; + char **defines; +{ + register int i; + + if (!stream) + return; + + fprintf (stream, "#if "); + + for (i = 0; defines[i]; i++) + { + char *def = defines[i]; + + if (*def == '!') + fprintf (stream, "!defined (%s)", def + 1); + else + fprintf (stream, "defined (%s)", def); + + if (defines[i + 1]) + fprintf (stream, " && "); + } + fprintf (stream, "\n"); +} + +/* Write an #endif string saying what defines controlled the compilation + of the immediately preceding code. + STREAM is the stream to write the information to. + DEFINES is a null terminated array of define names. */ +void +write_endifs (stream, defines) + FILE *stream; + char **defines; +{ + register int i; + + if (!stream) + return; + + fprintf (stream, "#endif /* "); + + for (i = 0; defines[i]; i++) + { + fprintf (stream, "%s", defines[i]); + + if (defines[i + 1]) + fprintf (stream, " && "); + } + + fprintf (stream, " */\n"); +} + +/* Write DOCUMENTATION to STREAM, perhaps surrounding it with double-quotes + and quoting special characters in the string. Handle special things for + internationalization (gettext) and the single-string vs. multiple-strings + issues. */ +void +write_documentation (stream, documentation, indentation, flags) + FILE *stream; + char **documentation; + int indentation, flags; +{ + register int i, j; + register char *line; + int string_array, texinfo, base_indent, filename_p; + + if (stream == 0) + return; + + string_array = flags & STRING_ARRAY; + filename_p = flags & HELPFILE; + + if (string_array) + { + fprintf (stream, " {\n#if defined (HELP_BUILTIN)\n"); /* } */ + if (single_longdoc_strings) + { + if (filename_p == 0) + { + if (documentation && documentation[0] && documentation[0][0]) + fprintf (stream, "N_(\""); + else + fprintf (stream, "N_(\" "); /* the empty string translates specially. */ + } + else + fprintf (stream, "\""); + } + } + + base_indent = (string_array && single_longdoc_strings && filename_p == 0) ? BASE_INDENT : 0; + + for (i = 0, texinfo = (flags & TEXINFO); documentation && (line = documentation[i]); i++) + { + /* Allow #ifdef's to be written out verbatim, but don't put them into + separate help files. */ + if (*line == '#') + { + if (string_array && filename_p == 0 && single_longdoc_strings == 0) + fprintf (stream, "%s\n", line); + continue; + } + + /* prefix with N_( for gettext */ + if (string_array && single_longdoc_strings == 0) + { + if (filename_p == 0) + { + if (line[0]) + fprintf (stream, " N_(\""); + else + fprintf (stream, " N_(\" "); /* the empty string translates specially. */ + } + else + fprintf (stream, " \""); + } + + if (indentation) + for (j = 0; j < indentation; j++) + fprintf (stream, " "); + + /* Don't indent the first line, because of how the help builtin works. */ + if (i == 0) + indentation += base_indent; + + if (string_array) + { + for (j = 0; line[j]; j++) + { + switch (line[j]) + { + case '\\': + case '"': + fprintf (stream, "\\%c", line[j]); + break; + + default: + fprintf (stream, "%c", line[j]); + } + } + + /* closing right paren for gettext */ + if (single_longdoc_strings == 0) + { + if (filename_p == 0) + fprintf (stream, "\"),\n"); + else + fprintf (stream, "\",\n"); + } + else if (documentation[i+1]) + /* don't add extra newline after last line */ + fprintf (stream, "\\n\\\n"); + } + else if (texinfo) + { + for (j = 0; line[j]; j++) + { + switch (line[j]) + { + case '@': + case '{': + case '}': + fprintf (stream, "@%c", line[j]); + break; + + default: + fprintf (stream, "%c", line[j]); + } + } + fprintf (stream, "\n"); + } + else + fprintf (stream, "%s\n", line); + } + + /* closing right paren for gettext */ + if (string_array && single_longdoc_strings) + { + if (filename_p == 0) + fprintf (stream, "\"),\n"); + else + fprintf (stream, "\",\n"); + } + + if (string_array) + fprintf (stream, "#endif /* HELP_BUILTIN */\n (char *)NULL\n};\n"); +} + +int +write_helpfiles (builtins) + ARRAY *builtins; +{ + char *helpfile, *bname; + FILE *helpfp; + int i, hdlen; + BUILTIN_DESC *builtin; + + i = mkdir ("helpfiles", 0777); + if (i < 0 && errno != EEXIST) + { + fprintf (stderr, "write_helpfiles: helpfiles: cannot create directory\n"); + return -1; + } + + hdlen = strlen ("helpfiles/"); + for (i = 0; i < builtins->sindex; i++) + { + builtin = (BUILTIN_DESC *)builtins->array[i]; + + bname = document_name (builtin); + helpfile = (char *)xmalloc (hdlen + strlen (bname) + 1); + sprintf (helpfile, "helpfiles/%s", bname); + + helpfp = fopen (helpfile, "w"); + if (helpfp == 0) + { + fprintf (stderr, "write_helpfiles: cannot open %s\n", helpfile); + free (helpfile); + continue; + } + + write_documentation (helpfp, builtin->longdoc->array, 4, PLAINTEXT); + + fflush (helpfp); + fclose (helpfp); + free (helpfile); + } + return 0; +} + +static int +_find_in_table (name, name_table) + char *name, *name_table[]; +{ + register int i; + + for (i = 0; name_table[i]; i++) + if (strcmp (name, name_table[i]) == 0) + return 1; + return 0; +} + +static int +is_special_builtin (name) + char *name; +{ + return (_find_in_table (name, special_builtins)); +} + +static int +is_assignment_builtin (name) + char *name; +{ + return (_find_in_table (name, assignment_builtins)); +} + +static int +is_localvar_builtin (name) + char *name; +{ + return (_find_in_table (name, localvar_builtins)); +} + +static int +is_posix_builtin (name) + char *name; +{ + return (_find_in_table (name, posix_builtins)); +} + +#if !defined (HAVE_RENAME) +static int +rename (from, to) + char *from, *to; +{ + unlink (to); + if (link (from, to) < 0) + return (-1); + unlink (from); + return (0); +} +#endif /* !HAVE_RENAME */ diff --git a/builtins/printf.def b/builtins/printf.def new file mode 100644 index 0000000..d39a6d3 --- /dev/null +++ b/builtins/printf.def @@ -0,0 +1,1283 @@ +This file is printf.def, from which is created printf.c. +It implements the builtin "printf" in Bash. + +Copyright (C) 1997-2016 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 3 of the License, 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. If not, see . + +$PRODUCES printf.c + +$BUILTIN printf +$FUNCTION printf_builtin +$SHORT_DOC printf [-v var] format [arguments] +Formats and prints ARGUMENTS under control of the FORMAT. + +Options: + -v var assign the output to shell variable VAR rather than + display it on the standard output + +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 +argument. + +In addition to the standard format specifications described in printf(1), +printf interprets: + + %b expand backslash escape sequences in the corresponding argument + %q quote the argument in a way that can be reused as shell input + %(fmt)T output the date-time string resulting from using FMT as a format + string for strftime(3) + +The format is re-used as necessary to consume all of the arguments. If +there are fewer arguments than the format requires, extra format +specifications behave as if a zero value or null string, as appropriate, +had been supplied. + +Exit Status: +Returns success unless an invalid option is given or a write or assignment +error occurs. +$END + +#include + +#include "../bashtypes.h" + +#include +#if defined (HAVE_LIMITS_H) +# include +#else + /* Assume 32-bit ints. */ +# define INT_MAX 2147483647 +# define INT_MIN (-2147483647-1) +#endif + +#if defined (PREFER_STDARG) +# include +#else +# include +#endif + +#include +#include + +#ifdef HAVE_INTTYPES_H +# include +#endif + +#include "posixtime.h" +#include "../bashansi.h" +#include "../bashintl.h" + +#define NEED_STRFTIME_DECL + +#include "../shell.h" +#include "shmbutil.h" +#include "stdc.h" +#include "bashgetopt.h" +#include "common.h" + +#if defined (PRI_MACROS_BROKEN) +# undef PRIdMAX +#endif + +#if !defined (PRIdMAX) +# if HAVE_LONG_LONG +# define PRIdMAX "lld" +# else +# define PRIdMAX "ld" +# endif +#endif + +#if !defined (errno) +extern int errno; +#endif + +#define PC(c) \ + do { \ + char b[2]; \ + tw++; \ + b[0] = c; b[1] = '\0'; \ + if (vflag) \ + vbadd (b, 1); \ + else \ + putchar (c); \ + QUIT; \ + } while (0) + +#define PF(f, func) \ + do { \ + int nw; \ + clearerr (stdout); \ + if (have_fieldwidth && have_precision) \ + nw = vflag ? vbprintf (f, fieldwidth, precision, func) : printf (f, fieldwidth, precision, func); \ + else if (have_fieldwidth) \ + nw = vflag ? vbprintf (f, fieldwidth, func) : printf (f, fieldwidth, func); \ + else if (have_precision) \ + nw = vflag ? vbprintf (f, precision, func) : printf (f, precision, func); \ + else \ + nw = vflag ? vbprintf (f, func) : printf (f, func); \ + tw += nw; \ + QUIT; \ + if (ferror (stdout)) \ + { \ + sh_wrerror (); \ + clearerr (stdout); \ + return (EXECUTION_FAILURE); \ + } \ + } while (0) + +/* We free the buffer used by mklong() if it's `too big'. */ +#define PRETURN(value) \ + do \ + { \ + QUIT; \ + if (vflag) \ + { \ + bind_printf_variable (vname, vbuf, 0); \ + stupidly_hack_special_variables (vname); \ + } \ + if (conv_bufsize > 4096 ) \ + { \ + free (conv_buf); \ + conv_bufsize = 0; \ + conv_buf = 0; \ + } \ + if (vbsize > 4096) \ + { \ + free (vbuf); \ + vbsize = 0; \ + vbuf = 0; \ + } \ + else if (vbuf) \ + vbuf[0] = 0; \ + if (ferror (stdout) == 0) \ + fflush (stdout); \ + QUIT; \ + if (ferror (stdout)) \ + { \ + sh_wrerror (); \ + clearerr (stdout); \ + return (EXECUTION_FAILURE); \ + } \ + return (value); \ + } \ + while (0) + +#define SKIP1 "#'-+ 0" +#define LENMODS "hjlLtz" + +extern time_t shell_start_time; + +#if !HAVE_ASPRINTF +extern int asprintf __P((char **, const char *, ...)) __attribute__((__format__ (printf, 2, 3))); +#endif + +#if !HAVE_VSNPRINTF +extern int vsnprintf __P((char *, size_t, const char *, va_list)) __attribute__((__format__ (printf, 3, 0))); +#endif + +static void printf_erange __P((char *)); +static int printstr __P((char *, char *, int, int, int)); +static int tescape __P((char *, char *, int *, int *)); +static char *bexpand __P((char *, int, int *, int *)); +static char *vbadd __P((char *, int)); +static int vbprintf __P((const char *, ...)) __attribute__((__format__ (printf, 1, 2))); +static char *mklong __P((char *, char *, size_t)); +static int getchr __P((void)); +static char *getstr __P((void)); +static int getint __P((void)); +static intmax_t getintmax __P((void)); +static uintmax_t getuintmax __P((void)); +static SHELL_VAR *bind_printf_variable __P((char *, char *, int)); + +#if defined (HAVE_LONG_DOUBLE) && HAVE_DECL_STRTOLD && !defined(STRTOLD_BROKEN) +typedef long double floatmax_t; +# define FLOATMAX_CONV "L" +# define strtofltmax strtold +#else +typedef double floatmax_t; +# define FLOATMAX_CONV "" +# define strtofltmax strtod +#endif +static floatmax_t getfloatmax __P((void)); + +static intmax_t asciicode __P((void)); + +static WORD_LIST *garglist; +static int retval; +static int conversion_error; + +/* printf -v var support */ +static int vflag = 0; +static char *vbuf, *vname; +static size_t vbsize; +static int vblen; + +static intmax_t tw; + +static char *conv_buf; +static size_t conv_bufsize; + +int +printf_builtin (list) + WORD_LIST *list; +{ + int ch, fieldwidth, precision; + int have_fieldwidth, have_precision; + char convch, thisch, nextch, *format, *modstart, *fmt, *start; +#if defined (HANDLE_MULTIBYTE) + char mbch[25]; /* 25 > MB_LEN_MAX, plus can handle 4-byte UTF-8 and large Unicode characters*/ + int mbind, mblen; +#endif + + conversion_error = 0; + retval = EXECUTION_SUCCESS; + + vflag = 0; + + reset_internal_getopt (); + while ((ch = internal_getopt (list, "v:")) != -1) + { + switch (ch) + { + case 'v': + vname = list_optarg; +#if defined (ARRAY_VARS) + if (legal_identifier (vname) || valid_array_reference (vname, 0)) +#else + if (legal_identifier (vname)) +#endif + { + vflag = 1; + if (vbsize == 0) + vbuf = xmalloc (vbsize = 16); + vblen = 0; + if (vbuf) + vbuf[0] = 0; + } + else + { + sh_invalidid (vname); + return (EX_USAGE); + } + break; + CASE_HELPOPT; + default: + builtin_usage (); + return (EX_USAGE); + } + } + list = loptend; /* skip over possible `--' */ + + if (list == 0) + { + builtin_usage (); + return (EX_USAGE); + } + + /* Allow printf -v var "" to act like var="" */ + if (vflag && list->word->word && list->word->word[0] == '\0') + { + bind_printf_variable (vname, "", 0); + stupidly_hack_special_variables (vname); + return (EXECUTION_SUCCESS); + } + + if (list->word->word == 0 || list->word->word[0] == '\0') + return (EXECUTION_SUCCESS); + + format = list->word->word; + tw = 0; + + garglist = list->next; + + /* If the format string is empty after preprocessing, return immediately. */ + if (format == 0 || *format == 0) + return (EXECUTION_SUCCESS); + + /* Basic algorithm is to scan the format string for conversion + specifications -- once one is found, find out if the field + width or precision is a '*'; if it is, gather up value. Note, + format strings are reused as necessary to use up the provided + arguments, arguments of zero/null string are provided to use + up the format string. */ + do + { + tw = 0; + /* find next format specification */ + for (fmt = format; *fmt; fmt++) + { + precision = fieldwidth = 0; + have_fieldwidth = have_precision = 0; + + if (*fmt == '\\') + { + fmt++; + /* A NULL third argument to tescape means to bypass the + special processing for arguments to %b. */ +#if defined (HANDLE_MULTIBYTE) + /* Accommodate possible use of \u or \U, which can result in + multibyte characters */ + memset (mbch, '\0', sizeof (mbch)); + fmt += tescape (fmt, mbch, &mblen, (int *)NULL); + for (mbind = 0; mbind < mblen; mbind++) + PC (mbch[mbind]); +#else + fmt += tescape (fmt, &nextch, (int *)NULL, (int *)NULL); + PC (nextch); +#endif + fmt--; /* for loop will increment it for us again */ + continue; + } + + if (*fmt != '%') + { + PC (*fmt); + continue; + } + + /* ASSERT(*fmt == '%') */ + start = fmt++; + + if (*fmt == '%') /* %% prints a % */ + { + PC ('%'); + continue; + } + + /* found format specification, skip to field width */ + for (; *fmt && strchr(SKIP1, *fmt); ++fmt) + ; + + /* Skip optional field width. */ + if (*fmt == '*') + { + fmt++; + have_fieldwidth = 1; + fieldwidth = getint (); + } + else + while (DIGIT (*fmt)) + fmt++; + + /* Skip optional '.' and precision */ + if (*fmt == '.') + { + ++fmt; + if (*fmt == '*') + { + fmt++; + have_precision = 1; + precision = getint (); + } + else + { + /* Negative precisions are allowed but treated as if the + precision were missing; I would like to allow a leading + `+' in the precision number as an extension, but lots + of asprintf/fprintf implementations get this wrong. */ +#if 0 + if (*fmt == '-' || *fmt == '+') +#else + if (*fmt == '-') +#endif + fmt++; + while (DIGIT (*fmt)) + fmt++; + } + } + + /* skip possible format modifiers */ + modstart = fmt; + while (*fmt && strchr (LENMODS, *fmt)) + fmt++; + + if (*fmt == 0) + { + builtin_error (_("`%s': missing format character"), start); + PRETURN (EXECUTION_FAILURE); + } + + convch = *fmt; + thisch = modstart[0]; + nextch = modstart[1]; + modstart[0] = convch; + modstart[1] = '\0'; + + QUIT; + switch(convch) + { + case 'c': + { + char p; + + p = getchr (); + PF(start, p); + break; + } + + case 's': + { + char *p; + + p = getstr (); + PF(start, p); + break; + } + + case '(': + { + char *timefmt, timebuf[128], *t; + int n; + intmax_t arg; + time_t secs; + struct tm *tm; + + modstart[1] = nextch; /* restore char after left paren */ + timefmt = xmalloc (strlen (fmt) + 3); + fmt++; /* skip over left paren */ + for (t = timefmt, n = 1; *fmt; ) + { + if (*fmt == '(') + n++; + else if (*fmt == ')') + n--; + if (n == 0) + break; + *t++ = *fmt++; + } + *t = '\0'; + if (*++fmt != 'T') + { + builtin_warning (_("`%c': invalid time format specification"), *fmt); + fmt = start; + free (timefmt); + PC (*fmt); + continue; + } + if (timefmt[0] == '\0') + { + timefmt[0] = '%'; + timefmt[1] = 'X'; /* locale-specific current time - should we use `+'? */ + timefmt[2] = '\0'; + } + /* argument is seconds since the epoch with special -1 and -2 */ + /* default argument is equivalent to -1; special case */ + arg = garglist ? getintmax () : -1; + if (arg == -1) + secs = NOW; /* roughly date +%s */ + else if (arg == -2) + secs = shell_start_time; /* roughly $SECONDS */ + else + secs = arg; +#if defined (HAVE_TZSET) + sv_tz ("TZ"); /* XXX -- just make sure */ +#endif + tm = localtime (&secs); + if (tm == 0) + { + secs = 0; + tm = localtime (&secs); + } + n = tm ? strftime (timebuf, sizeof (timebuf), timefmt, tm) : 0; + free (timefmt); + if (n == 0) + timebuf[0] = '\0'; + else + timebuf[sizeof(timebuf) - 1] = '\0'; + /* convert to %s format that preserves fieldwidth and precision */ + modstart[0] = 's'; + modstart[1] = '\0'; + n = printstr (start, timebuf, strlen (timebuf), fieldwidth, precision); /* XXX - %s for now */ + if (n < 0) + { + if (ferror (stdout) == 0) + { + sh_wrerror (); + clearerr (stdout); + } + PRETURN (EXECUTION_FAILURE); + } + break; + } + + case 'n': + { + char *var; + + var = getstr (); + if (var && *var) + { + if (legal_identifier (var)) + bind_var_to_int (var, tw); + else + { + sh_invalidid (var); + PRETURN (EXECUTION_FAILURE); + } + } + break; + } + + case 'b': /* expand escapes in argument */ + { + char *p, *xp; + int rlen, r; + + p = getstr (); + ch = rlen = r = 0; + xp = bexpand (p, strlen (p), &ch, &rlen); + + if (xp) + { + /* Have to use printstr because of possible NUL bytes + in XP -- printf does not handle that well. */ + r = printstr (start, xp, rlen, fieldwidth, precision); + if (r < 0) + { + if (ferror (stdout) == 0) + { + sh_wrerror (); + clearerr (stdout); + } + retval = EXECUTION_FAILURE; + } + free (xp); + } + + if (ch || r < 0) + PRETURN (retval); + break; + } + + case 'q': /* print with shell quoting */ + { + char *p, *xp; + int r; + + r = 0; + p = getstr (); + if (p && *p == 0) /* XXX - getstr never returns null */ + xp = savestring ("''"); + else if (ansic_shouldquote (p)) + xp = ansic_quote (p, 0, (int *)0); + else + xp = sh_backslash_quote (p, 0, 1); + if (xp) + { + /* Use printstr to get fieldwidth and precision right. */ + r = printstr (start, xp, strlen (xp), fieldwidth, precision); + if (r < 0) + { + sh_wrerror (); + clearerr (stdout); + } + free (xp); + } + + if (r < 0) + PRETURN (EXECUTION_FAILURE); + break; + } + + case 'd': + case 'i': + { + char *f; + long p; + intmax_t pp; + + p = pp = getintmax (); + if (p != pp) + { + f = mklong (start, PRIdMAX, sizeof (PRIdMAX) - 2); + PF (f, pp); + } + else + { + /* Optimize the common case where the integer fits + in "long". This also works around some long + long and/or intmax_t library bugs in the common + case, e.g. glibc 2.2 x86. */ + f = mklong (start, "l", 1); + PF (f, p); + } + break; + } + + case 'o': + case 'u': + case 'x': + case 'X': + { + char *f; + unsigned long p; + uintmax_t pp; + + p = pp = getuintmax (); + if (p != pp) + { + f = mklong (start, PRIdMAX, sizeof (PRIdMAX) - 2); + PF (f, pp); + } + else + { + f = mklong (start, "l", 1); + PF (f, p); + } + break; + } + + case 'e': + case 'E': + case 'f': + case 'F': + case 'g': + case 'G': +#if defined (HAVE_PRINTF_A_FORMAT) + case 'a': + case 'A': +#endif + { + char *f; + floatmax_t p; + + p = getfloatmax (); + f = mklong (start, FLOATMAX_CONV, sizeof(FLOATMAX_CONV) - 1); + PF (f, p); + break; + } + + /* We don't output unrecognized format characters; we print an + error message and return a failure exit status. */ + default: + builtin_error (_("`%c': invalid format character"), convch); + PRETURN (EXECUTION_FAILURE); + } + + modstart[0] = thisch; + modstart[1] = nextch; + } + + if (ferror (stdout)) + { + /* PRETURN will print error message. */ + PRETURN (EXECUTION_FAILURE); + } + } + while (garglist && garglist != list->next); + + if (conversion_error) + retval = EXECUTION_FAILURE; + + PRETURN (retval); +} + +static void +printf_erange (s) + char *s; +{ + builtin_error (_("warning: %s: %s"), s, strerror(ERANGE)); +} + +/* We duplicate a lot of what printf(3) does here. */ +static int +printstr (fmt, string, len, fieldwidth, precision) + char *fmt; /* format */ + char *string; /* expanded string argument */ + int len; /* length of expanded string */ + int fieldwidth; /* argument for width of `*' */ + int precision; /* argument for precision of `*' */ +{ +#if 0 + char *s; +#endif + int padlen, nc, ljust, i; + int fw, pr; /* fieldwidth and precision */ + intmax_t mfw, mpr; + + if (string == 0 || len == 0) + return 0; + +#if 0 + s = fmt; +#endif + if (*fmt == '%') + fmt++; + + ljust = fw = 0; + pr = -1; + mfw = 0; + mpr = -1; + + /* skip flags */ + while (strchr (SKIP1, *fmt)) + { + if (*fmt == '-') + ljust = 1; + fmt++; + } + + /* get fieldwidth, if present. rely on caller to clamp fieldwidth at INT_MAX */ + if (*fmt == '*') + { + fmt++; + fw = fieldwidth; + if (fw < 0) + { + fw = -fw; + ljust = 1; + } + } + else if (DIGIT (*fmt)) + { + mfw = *fmt++ - '0'; + while (DIGIT (*fmt)) + mfw = (mfw * 10) + (*fmt++ - '0'); + /* Error if fieldwidth > INT_MAX here? */ + fw = (mfw < 0 || mfw > INT_MAX) ? INT_MAX : mfw; + } + + /* get precision, if present */ + if (*fmt == '.') + { + fmt++; + if (*fmt == '*') + { + fmt++; + pr = precision; + } + else if (DIGIT (*fmt)) + { + mpr = *fmt++ - '0'; + while (DIGIT (*fmt)) + mpr = (mpr * 10) + (*fmt++ - '0'); + /* Error if precision > INT_MAX here? */ + pr = (mpr < 0 || mpr > INT_MAX) ? INT_MAX : mpr; + } + else + pr = 0; /* "a null digit string is treated as zero" */ + } + +#if 0 + /* If we remove this, get rid of `s'. */ + if (*fmt != 'b' && *fmt != 'q') + { + internal_error (_("format parsing problem: %s"), s); + fw = pr = 0; + } +#endif + + /* chars from string to print */ + nc = (pr >= 0 && pr <= len) ? pr : len; + + padlen = fw - nc; + if (padlen < 0) + padlen = 0; + if (ljust) + padlen = -padlen; + + /* leading pad characters */ + for (; padlen > 0; padlen--) + PC (' '); + + /* output NC characters from STRING */ + for (i = 0; i < nc; i++) + PC (string[i]); + + /* output any necessary trailing padding */ + for (; padlen < 0; padlen++) + PC (' '); + + return (ferror (stdout) ? -1 : 0); +} + +/* Convert STRING by expanding the escape sequences specified by the + POSIX standard for printf's `%b' format string. If SAWC is non-null, + perform the processing appropriate for %b arguments. In particular, + recognize `\c' and use that as a string terminator. If we see \c, set + *SAWC to 1 before returning. LEN is the length of STRING. */ + +/* Translate a single backslash-escape sequence starting at ESTART (the + character after the backslash) and return the number of characters + consumed by the sequence. CP is the place to return the translated + value. *SAWC is set to 1 if the escape sequence was \c, since that means + to short-circuit the rest of the processing. If SAWC is null, we don't + do the \c short-circuiting, and \c is treated as an unrecognized escape + sequence; we also bypass the other processing specific to %b arguments. */ +static int +tescape (estart, cp, lenp, sawc) + char *estart; + char *cp; + int *lenp, *sawc; +{ + register char *p; + int temp, c, evalue; + unsigned long uvalue; + + p = estart; + if (lenp) + *lenp = 1; + + switch (c = *p++) + { +#if defined (__STDC__) + case 'a': *cp = '\a'; break; +#else + case 'a': *cp = '\007'; break; +#endif + + case 'b': *cp = '\b'; break; + + case 'e': + case 'E': *cp = '\033'; break; /* ESC -- non-ANSI */ + + case 'f': *cp = '\f'; break; + + case 'n': *cp = '\n'; break; + + case 'r': *cp = '\r'; break; + + case 't': *cp = '\t'; break; + + case 'v': *cp = '\v'; break; + + /* The octal escape sequences are `\0' followed by up to three octal + digits (if SAWC), or `\' followed by up to three octal digits (if + !SAWC). As an extension, we allow the latter form even if SAWC. */ + case '0': case '1': case '2': case '3': + case '4': case '5': case '6': case '7': + evalue = OCTVALUE (c); + for (temp = 2 + (!evalue && !!sawc); ISOCTAL (*p) && temp--; p++) + evalue = (evalue * 8) + OCTVALUE (*p); + *cp = evalue & 0xFF; + break; + + /* And, as another extension, we allow \xNN, where each N is a + hex digit. */ + case 'x': + for (temp = 2, evalue = 0; ISXDIGIT ((unsigned char)*p) && temp--; p++) + evalue = (evalue * 16) + HEXVALUE (*p); + if (p == estart + 1) + { + builtin_error (_("missing hex digit for \\x")); + *cp = '\\'; + return 0; + } + *cp = evalue & 0xFF; + break; + +#if defined (HANDLE_MULTIBYTE) + case 'u': + case 'U': + temp = (c == 'u') ? 4 : 8; /* \uNNNN \UNNNNNNNN */ + for (uvalue = 0; ISXDIGIT ((unsigned char)*p) && temp--; p++) + uvalue = (uvalue * 16) + HEXVALUE (*p); + if (p == estart + 1) + { + builtin_error (_("missing unicode digit for \\%c"), c); + *cp = '\\'; + return 0; + } + if (uvalue <= 0x7f) /* <= 0x7f translates directly */ + *cp = uvalue; + else + { + temp = u32cconv (uvalue, cp); + cp[temp] = '\0'; + if (lenp) + *lenp = temp; + } + break; +#endif + + case '\\': /* \\ -> \ */ + *cp = c; + break; + + /* SAWC == 0 means that \', \", and \? are recognized as escape + sequences, though the only processing performed is backslash + removal. */ + case '\'': case '"': case '?': + if (!sawc) + *cp = c; + else + { + *cp = '\\'; + return 0; + } + break; + + case 'c': + if (sawc) + { + *sawc = 1; + break; + } + /* other backslash escapes are passed through unaltered */ + default: + *cp = '\\'; + return 0; + } + return (p - estart); +} + +static char * +bexpand (string, len, sawc, lenp) + char *string; + int len, *sawc, *lenp; +{ + int temp; + char *ret, *r, *s, c; +#if defined (HANDLE_MULTIBYTE) + char mbch[25]; + int mbind, mblen; +#endif + + if (string == 0 || len == 0) + { + if (sawc) + *sawc = 0; + if (lenp) + *lenp = 0; + return ((char *)NULL); + } + + ret = (char *)xmalloc (len + 1); + for (r = ret, s = string; s && *s; ) + { + c = *s++; + if (c != '\\' || *s == '\0') + { + *r++ = c; + continue; + } + temp = 0; +#if defined (HANDLE_MULTIBYTE) + memset (mbch, '\0', sizeof (mbch)); + s += tescape (s, mbch, &mblen, &temp); +#else + s += tescape (s, &c, (int *)NULL, &temp); +#endif + if (temp) + { + if (sawc) + *sawc = 1; + break; + } + +#if defined (HANDLE_MULTIBYTE) + for (mbind = 0; mbind < mblen; mbind++) + *r++ = mbch[mbind]; +#else + *r++ = c; +#endif + } + + *r = '\0'; + if (lenp) + *lenp = r - ret; + return ret; +} + +static char * +vbadd (buf, blen) + char *buf; + int blen; +{ + size_t nlen; + + nlen = vblen + blen + 1; + if (nlen >= vbsize) + { + vbsize = ((nlen + 63) >> 6) << 6; + vbuf = (char *)xrealloc (vbuf, vbsize); + } + + if (blen == 1) + vbuf[vblen++] = buf[0]; + else if (blen > 1) + { + FASTCOPY (buf, vbuf + vblen, blen); + vblen += blen; + } + vbuf[vblen] = '\0'; + +#ifdef DEBUG + if (strlen (vbuf) != vblen) + internal_error ("printf:vbadd: vblen (%d) != strlen (vbuf) (%d)", vblen, (int)strlen (vbuf)); +#endif + + return vbuf; +} + +static int +#if defined (PREFER_STDARG) +vbprintf (const char *format, ...) +#else +vbprintf (format, va_alist) + const char *format; + va_dcl +#endif +{ + va_list args; + size_t nlen; + int blen; + + SH_VA_START (args, format); + blen = vsnprintf (vbuf + vblen, vbsize - vblen, format, args); + va_end (args); + + nlen = vblen + blen + 1; + if (nlen >= vbsize) + { + vbsize = ((nlen + 63) >> 6) << 6; + vbuf = (char *)xrealloc (vbuf, vbsize); + SH_VA_START (args, format); + blen = vsnprintf (vbuf + vblen, vbsize - vblen, format, args); + va_end (args); + } + + vblen += blen; + vbuf[vblen] = '\0'; + +#ifdef DEBUG + if (strlen (vbuf) != vblen) + internal_error ("printf:vbprintf: vblen (%d) != strlen (vbuf) (%d)", vblen, (int)strlen (vbuf)); +#endif + + return (blen); +} + +static char * +mklong (str, modifiers, mlen) + char *str; + char *modifiers; + size_t mlen; +{ + size_t len, slen; + + slen = strlen (str); + len = slen + mlen + 1; + + if (len > conv_bufsize) + { + conv_bufsize = (((len + 1023) >> 10) << 10); + conv_buf = (char *)xrealloc (conv_buf, conv_bufsize); + } + + FASTCOPY (str, conv_buf, slen - 1); + FASTCOPY (modifiers, conv_buf + slen - 1, mlen); + + conv_buf[len - 2] = str[slen - 1]; + conv_buf[len - 1] = '\0'; + return (conv_buf); +} + +static int +getchr () +{ + int ret; + + if (garglist == 0) + return ('\0'); + + ret = (int)garglist->word->word[0]; + garglist = garglist->next; + return ret; +} + +static char * +getstr () +{ + char *ret; + + if (garglist == 0) + return (""); + + ret = garglist->word->word; + garglist = garglist->next; + return ret; +} + +static int +getint () +{ + intmax_t ret; + + ret = getintmax (); + + if (garglist == 0) + return ret; + + if (ret > INT_MAX) + { + printf_erange (garglist->word->word); + ret = INT_MAX; + } + else if (ret < INT_MIN) + { + printf_erange (garglist->word->word); + ret = INT_MIN; + } + + return ((int)ret); +} + +static intmax_t +getintmax () +{ + intmax_t ret; + char *ep; + + if (garglist == 0) + return (0); + + if (garglist->word->word[0] == '\'' || garglist->word->word[0] == '"') + return asciicode (); + + errno = 0; + ret = strtoimax (garglist->word->word, &ep, 0); + + if (*ep) + { + sh_invalidnum (garglist->word->word); + /* POSIX.2 says ``...a diagnostic message shall be written to standard + error, and the utility shall not exit with a zero exit status, but + shall continue processing any remaining operands and shall write the + value accumulated at the time the error was detected to standard + output.'' Yecch. */ +#if 0 + ret = 0; /* return partially-converted value from strtoimax */ +#endif + conversion_error = 1; + } + else if (errno == ERANGE) + printf_erange (garglist->word->word); + + garglist = garglist->next; + return (ret); +} + +static uintmax_t +getuintmax () +{ + uintmax_t ret; + char *ep; + + if (garglist == 0) + return (0); + + if (garglist->word->word[0] == '\'' || garglist->word->word[0] == '"') + return asciicode (); + + errno = 0; + ret = strtoumax (garglist->word->word, &ep, 0); + + if (*ep) + { + sh_invalidnum (garglist->word->word); + /* Same POSIX.2 conversion error requirements as getintmax(). */ + ret = 0; + conversion_error = 1; + } + else if (errno == ERANGE) + printf_erange (garglist->word->word); + + garglist = garglist->next; + return (ret); +} + +static floatmax_t +getfloatmax () +{ + floatmax_t ret; + char *ep; + + if (garglist == 0) + return (0); + + if (garglist->word->word[0] == '\'' || garglist->word->word[0] == '"') + return asciicode (); + + errno = 0; + ret = strtofltmax (garglist->word->word, &ep); + + if (*ep) + { + sh_invalidnum (garglist->word->word); + /* Same thing about POSIX.2 conversion error requirements. */ + ret = 0; + conversion_error = 1; + } + else if (errno == ERANGE) + printf_erange (garglist->word->word); + + garglist = garglist->next; + return (ret); +} + +/* NO check is needed for garglist here. */ +static intmax_t +asciicode () +{ + register intmax_t ch; +#if defined (HANDLE_MULTIBYTE) + wchar_t wc; + size_t mblength, slen; +#endif + DECLARE_MBSTATE; + +#if defined (HANDLE_MULTIBYTE) + slen = strlen (garglist->word->word+1); + mblength = MBLEN (garglist->word->word+1, slen); + if (mblength > 1) + { + mblength = mbtowc (&wc, garglist->word->word+1, slen); + ch = wc; /* XXX */ + } + else +#endif + ch = (unsigned char)garglist->word->word[1]; + + garglist = garglist->next; + return (ch); +} + +static SHELL_VAR * +bind_printf_variable (name, value, flags) + char *name; + char *value; + int flags; +{ + SHELL_VAR *v; + +#if defined (ARRAY_VARS) + if (valid_array_reference (name, 0) == 0) + v = bind_variable (name, value, flags); + else + v = assign_array_element (name, value, flags); +#else /* !ARRAY_VARS */ + v = bind_variable (name, value, flags); +#endif /* !ARRAY_VARS */ + + if (v && readonly_p (v) == 0 && noassign_p (v) == 0) + VUNSETATTR (v, att_invisible); + + return v; +} diff --git a/builtins/psize.c b/builtins/psize.c new file mode 100644 index 0000000..30881fb --- /dev/null +++ b/builtins/psize.c @@ -0,0 +1,79 @@ +/* psize.c - Find pipe size. */ + +/* Copyright (C) 1987, 1991 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 3 of the License, 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. If not, see . +*/ + +/* Write output in 128-byte chunks until we get a sigpipe or write gets an + EPIPE. Then report how many bytes we wrote. We assume that this is the + pipe size. */ +#include + +#if defined (HAVE_UNISTD_H) +# ifdef _MINIX +# include +# endif +# include +#endif + +#include +#ifndef _MINIX +#include "../bashtypes.h" +#endif +#include +#include + +#include "../command.h" +#include "../general.h" +#include "../sig.h" + +#ifndef errno +extern int errno; +#endif + +int nw; + +sighandler +sigpipe (sig) + int sig; +{ + fprintf (stderr, "%d\n", nw); + exit (0); +} + +int +main (argc, argv) + int argc; + char **argv; +{ + char buf[128]; + register int i; + + for (i = 0; i < 128; i++) + buf[i] = ' '; + + signal (SIGPIPE, sigpipe); + + nw = 0; + for (;;) + { + int n; + n = write (1, buf, 128); + nw += n; + } + return (0); +} diff --git a/builtins/psize.sh b/builtins/psize.sh new file mode 100644 index 0000000..29bc115 --- /dev/null +++ b/builtins/psize.sh @@ -0,0 +1,45 @@ +#! /bin/sh +# +# psize.sh -- determine this system's pipe size, and write a define to +# pipesize.h so ulimit.c can use it. + +: ${TMPDIR:=/tmp} +# try to use mktemp(1) if the system supports it +{ TMPFILE="`mktemp $TMPDIR/pipsize.XXXXXX 2>/dev/null`"; } 2>/dev/null +used_mktemp=true + +if [ -z "$TMPFILE" ]; then + TMPNAME=pipsize.$$ + TMPFILE=$TMPDIR/$TMPNAME + used_mktemp=false +fi + +trap 'rm -f "$TMPFILE" ; exit 1' 1 2 3 6 15 +trap 'rm -f "$TMPFILE"' 0 + +echo "/*" +echo " * pipesize.h" +echo " *" +echo " * This file is automatically generated by psize.sh" +echo " * Do not edit!" +echo " */" +echo "" + +# +# Try to avoid tempfile races. We can't really check for the file's +# existence before we run psize.aux, because `test -e' is not portable, +# `test -h' (test for symlinks) is not portable, and `test -f' only +# checks for regular files. If we used mktemp(1), we're ahead of the +# game. +# +$used_mktemp || rm -f "$TMPFILE" + +./psize.aux 2>"$TMPFILE" | sleep 3 + +if [ -s "$TMPFILE" ]; then + echo "#define PIPESIZE `cat "$TMPFILE"`" +else + echo "#define PIPESIZE 512" +fi + +exit 0 diff --git a/builtins/pushd.def b/builtins/pushd.def new file mode 100644 index 0000000..82653c4 --- /dev/null +++ b/builtins/pushd.def @@ -0,0 +1,791 @@ +This file is pushd.def, from which is created pushd.c. It implements the +builtins "pushd", "popd", and "dirs" in Bash. + +Copyright (C) 1987-2015 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 3 of the License, 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. If not, see . + +$PRODUCES pushd.c + +$BUILTIN pushd +$FUNCTION pushd_builtin +$DEPENDS_ON PUSHD_AND_POPD +$SHORT_DOC pushd [-n] [+N | -N | dir] +Add directories to stack. + +Adds a directory to the top of the directory stack, or rotates +the stack, making the new top of the stack the current working +directory. With no arguments, exchanges the top two directories. + +Options: + -n Suppresses the normal change of directory when adding + directories to the stack, so only the stack is manipulated. + +Arguments: + +N Rotates the stack so that the Nth directory (counting + from the left of the list shown by `dirs', starting with + zero) is at the top. + + -N Rotates the stack so that the Nth directory (counting + from the right of the list shown by `dirs', starting with + zero) is at the top. + + dir Adds DIR to the directory stack at the top, making it the + new current working directory. + +The `dirs' builtin displays the directory stack. + +Exit Status: +Returns success unless an invalid argument is supplied or the directory +change fails. +$END + +$BUILTIN popd +$FUNCTION popd_builtin +$DEPENDS_ON PUSHD_AND_POPD +$SHORT_DOC popd [-n] [+N | -N] +Remove directories from stack. + +Removes entries from the directory stack. With no arguments, removes +the top directory from the stack, and changes to the new top directory. + +Options: + -n Suppresses the normal change of directory when removing + directories from the stack, so only the stack is manipulated. + +Arguments: + +N Removes the Nth entry counting from the left of the list + shown by `dirs', starting with zero. For example: `popd +0' + removes the first directory, `popd +1' the second. + + -N Removes the Nth entry counting from the right of the list + shown by `dirs', starting with zero. For example: `popd -0' + removes the last directory, `popd -1' the next to last. + +The `dirs' builtin displays the directory stack. + +Exit Status: +Returns success unless an invalid argument is supplied or the directory +change fails. +$END + +$BUILTIN dirs +$FUNCTION dirs_builtin +$DEPENDS_ON PUSHD_AND_POPD +$SHORT_DOC dirs [-clpv] [+N] [-N] +Display directory stack. + +Display the list of currently remembered directories. Directories +find their way onto the list with the `pushd' command; you can get +back up through the list with the `popd' command. + +Options: + -c clear the directory stack by deleting all of the elements + -l do not print tilde-prefixed versions of directories relative + to your home directory + -p print the directory stack with one entry per line + -v print the directory stack with one entry per line prefixed + with its position in the stack + +Arguments: + +N Displays the Nth entry counting from the left of the list + shown by dirs when invoked without options, starting with + zero. + + -N Displays the Nth entry counting from the right of the list + shown by dirs when invoked without options, starting with + zero. + +Exit Status: +Returns success unless an invalid option is supplied or an error occurs. +$END + +#include + +#if defined (PUSHD_AND_POPD) +#include +#if defined (HAVE_SYS_PARAM_H) +# include +#endif + +#if defined (HAVE_UNISTD_H) +# ifdef _MINIX +# include +# endif +# include +#endif + +#include "../bashansi.h" +#include "../bashintl.h" + +#include + +#include + +#include "../shell.h" +#include "maxpath.h" +#include "common.h" +#include "builtext.h" + +#ifdef LOADABLE_BUILTIN +# include "builtins.h" +#endif + +#if !defined (errno) +extern int errno; +#endif /* !errno */ + +/* The list of remembered directories. */ +static char **pushd_directory_list = (char **)NULL; + +/* Number of existing slots in this list. */ +static int directory_list_size; + +/* Offset to the end of the list. */ +static int directory_list_offset; + +static void pushd_error __P((int, char *)); +static void clear_directory_stack __P((void)); +static int cd_to_string __P((char *)); +static int change_to_temp __P((char *)); +static void add_dirstack_element __P((char *)); +static int get_dirstack_index __P((intmax_t, int, int *)); + +#define NOCD 0x01 +#define ROTATE 0x02 +#define LONGFORM 0x04 +#define CLEARSTAK 0x08 + +int +pushd_builtin (list) + WORD_LIST *list; +{ + WORD_LIST *orig_list; + char *temp, *current_directory, *top; + int j, flags, skipopt; + intmax_t num; + char direction; + + orig_list = list; + + CHECK_HELPOPT (list); + if (list && list->word && ISOPTION (list->word->word, '-')) + { + list = list->next; + skipopt = 1; + } + else + skipopt = 0; + + /* If there is no argument list then switch current and + top of list. */ + if (list == 0) + { + if (directory_list_offset == 0) + { + builtin_error (_("no other directory")); + return (EXECUTION_FAILURE); + } + + current_directory = get_working_directory ("pushd"); + if (current_directory == 0) + return (EXECUTION_FAILURE); + + j = directory_list_offset - 1; + temp = pushd_directory_list[j]; + pushd_directory_list[j] = current_directory; + j = change_to_temp (temp); + free (temp); + return j; + } + + for (flags = 0; skipopt == 0 && list; list = list->next) + { + if (ISOPTION (list->word->word, 'n')) + { + flags |= NOCD; + } + else if (ISOPTION (list->word->word, '-')) + { + list = list->next; + break; + } + else if (list->word->word[0] == '-' && list->word->word[1] == '\0') + /* Let `pushd -' work like it used to. */ + break; + else if (((direction = list->word->word[0]) == '+') || direction == '-') + { + if (legal_number (list->word->word + 1, &num) == 0) + { + sh_invalidnum (list->word->word); + builtin_usage (); + return (EX_USAGE); + } + + if (direction == '-') + num = directory_list_offset - num; + + if (num > directory_list_offset || num < 0) + { + pushd_error (directory_list_offset, list->word->word); + return (EXECUTION_FAILURE); + } + flags |= ROTATE; + } + else if (*list->word->word == '-') + { + sh_invalidopt (list->word->word); + builtin_usage (); + return (EX_USAGE); + } + else + break; + } + + if (flags & ROTATE) + { + /* Rotate the stack num times. Remember, the current + directory acts like it is part of the stack. */ + temp = get_working_directory ("pushd"); + + if (num == 0) + { + j = ((flags & NOCD) == 0) ? change_to_temp (temp) : EXECUTION_SUCCESS; + free (temp); + return j; + } + + do + { + top = pushd_directory_list[directory_list_offset - 1]; + + for (j = directory_list_offset - 2; j > -1; j--) + pushd_directory_list[j + 1] = pushd_directory_list[j]; + + pushd_directory_list[j + 1] = temp; + + temp = top; + num--; + } + while (num); + + j = ((flags & NOCD) == 0) ? change_to_temp (temp) : EXECUTION_SUCCESS; + free (temp); + return j; + } + + if (list == 0) + return (EXECUTION_SUCCESS); + + /* Change to the directory in list->word->word. Save the current + directory on the top of the stack. */ + current_directory = get_working_directory ("pushd"); + if (current_directory == 0) + return (EXECUTION_FAILURE); + + j = ((flags & NOCD) == 0) ? cd_builtin (skipopt ? orig_list : list) : EXECUTION_SUCCESS; + if (j == EXECUTION_SUCCESS) + { + add_dirstack_element ((flags & NOCD) ? savestring (list->word->word) : current_directory); + dirs_builtin ((WORD_LIST *)NULL); + if (flags & NOCD) + free (current_directory); + return (EXECUTION_SUCCESS); + } + else + { + free (current_directory); + return (EXECUTION_FAILURE); + } +} + +/* Pop the directory stack, and then change to the new top of the stack. + If LIST is non-null it should consist of a word +N or -N, which says + what element to delete from the stack. The default is the top one. */ +int +popd_builtin (list) + WORD_LIST *list; +{ + register int i; + intmax_t which; + int flags; + char direction; + char *which_word; + + CHECK_HELPOPT (list); + + which_word = (char *)NULL; + for (flags = 0, which = 0, direction = '+'; list; list = list->next) + { + if (ISOPTION (list->word->word, 'n')) + { + flags |= NOCD; + } + else if (ISOPTION (list->word->word, '-')) + { + list = list->next; + break; + } + else if (((direction = list->word->word[0]) == '+') || direction == '-') + { + if (legal_number (list->word->word + 1, &which) == 0) + { + sh_invalidnum (list->word->word); + builtin_usage (); + return (EX_USAGE); + } + which_word = list->word->word; + } + else if (*list->word->word == '-') + { + sh_invalidopt (list->word->word); + builtin_usage (); + return (EX_USAGE); + } + else if (*list->word->word) + { + builtin_error (_("%s: invalid argument"), list->word->word); + builtin_usage (); + return (EX_USAGE); + } + else + break; + } + + if (which > directory_list_offset || (directory_list_offset == 0 && which == 0)) + { + pushd_error (directory_list_offset, which_word ? which_word : ""); + return (EXECUTION_FAILURE); + } + + /* Handle case of no specification, or top of stack specification. */ + if ((direction == '+' && which == 0) || + (direction == '-' && which == directory_list_offset)) + { + i = ((flags & NOCD) == 0) ? cd_to_string (pushd_directory_list[directory_list_offset - 1]) + : EXECUTION_SUCCESS; + if (i != EXECUTION_SUCCESS) + return (i); + free (pushd_directory_list[--directory_list_offset]); + } + else + { + /* Since an offset other than the top directory was specified, + remove that directory from the list and shift the remainder + of the list into place. */ + i = (direction == '+') ? directory_list_offset - which : which; + free (pushd_directory_list[i]); + directory_list_offset--; + + /* Shift the remainder of the list into place. */ + for (; i < directory_list_offset; i++) + pushd_directory_list[i] = pushd_directory_list[i + 1]; + } + + dirs_builtin ((WORD_LIST *)NULL); + return (EXECUTION_SUCCESS); +} + +/* Print the current list of directories on the directory stack. */ +int +dirs_builtin (list) + WORD_LIST *list; +{ + int flags, desired_index, index_flag, vflag; + intmax_t i; + char *temp, *w; + + CHECK_HELPOPT (list); + for (flags = vflag = index_flag = 0, desired_index = -1, w = ""; list; list = list->next) + { + if (ISOPTION (list->word->word, 'l')) + { + flags |= LONGFORM; + } + else if (ISOPTION (list->word->word, 'c')) + { + flags |= CLEARSTAK; + } + else if (ISOPTION (list->word->word, 'v')) + { + vflag |= 2; + } + else if (ISOPTION (list->word->word, 'p')) + { + vflag |= 1; + } + else if (ISOPTION (list->word->word, '-')) + { + list = list->next; + break; + } + else if (*list->word->word == '+' || *list->word->word == '-') + { + int sign; + if (legal_number (w = list->word->word + 1, &i) == 0) + { + sh_invalidnum (list->word->word); + builtin_usage (); + return (EX_USAGE); + } + sign = (*list->word->word == '+') ? 1 : -1; + desired_index = get_dirstack_index (i, sign, &index_flag); + } + else + { + sh_invalidopt (list->word->word); + builtin_usage (); + return (EX_USAGE); + } + } + + if (flags & CLEARSTAK) + { + clear_directory_stack (); + return (EXECUTION_SUCCESS); + } + + if (index_flag && (desired_index < 0 || desired_index > directory_list_offset)) + { + pushd_error (directory_list_offset, w); + return (EXECUTION_FAILURE); + } + +#define DIRSTACK_FORMAT(temp) \ + (flags & LONGFORM) ? temp : polite_directory_format (temp) + + /* The first directory printed is always the current working directory. */ + if (index_flag == 0 || (index_flag == 1 && desired_index == 0)) + { + temp = get_working_directory ("dirs"); + if (temp == 0) + temp = savestring (_("")); + if (vflag & 2) + printf ("%2d %s", 0, DIRSTACK_FORMAT (temp)); + else + printf ("%s", DIRSTACK_FORMAT (temp)); + free (temp); + if (index_flag) + { + putchar ('\n'); + return (sh_chkwrite (EXECUTION_SUCCESS)); + } + } + +#define DIRSTACK_ENTRY(i) \ + (flags & LONGFORM) ? pushd_directory_list[i] \ + : polite_directory_format (pushd_directory_list[i]) + + /* Now print the requested directory stack entries. */ + if (index_flag) + { + if (vflag & 2) + printf ("%2d %s", directory_list_offset - desired_index, + DIRSTACK_ENTRY (desired_index)); + else + printf ("%s", DIRSTACK_ENTRY (desired_index)); + } + else + for (i = directory_list_offset - 1; i >= 0; i--) + if (vflag >= 2) + printf ("\n%2d %s", directory_list_offset - (int)i, DIRSTACK_ENTRY (i)); + else + printf ("%s%s", (vflag & 1) ? "\n" : " ", DIRSTACK_ENTRY (i)); + + putchar ('\n'); + + return (sh_chkwrite (EXECUTION_SUCCESS)); +} + +static void +pushd_error (offset, arg) + int offset; + char *arg; +{ + if (offset == 0) + builtin_error (_("directory stack empty")); + else + sh_erange (arg, _("directory stack index")); +} + +static void +clear_directory_stack () +{ + register int i; + + for (i = 0; i < directory_list_offset; i++) + free (pushd_directory_list[i]); + directory_list_offset = 0; +} + +/* Switch to the directory in NAME. This uses the cd_builtin to do the work, + so if the result is EXECUTION_FAILURE then an error message has already + been printed. */ +static int +cd_to_string (name) + char *name; +{ + WORD_LIST *tlist; + WORD_LIST *dir; + int result; + + dir = make_word_list (make_word (name), NULL); + tlist = make_word_list (make_word ("--"), dir); + result = cd_builtin (tlist); + dispose_words (tlist); + return (result); +} + +static int +change_to_temp (temp) + char *temp; +{ + int tt; + + tt = temp ? cd_to_string (temp) : EXECUTION_FAILURE; + + if (tt == EXECUTION_SUCCESS) + dirs_builtin ((WORD_LIST *)NULL); + + return (tt); +} + +static void +add_dirstack_element (dir) + char *dir; +{ + if (directory_list_offset == directory_list_size) + pushd_directory_list = strvec_resize (pushd_directory_list, directory_list_size += 10); + pushd_directory_list[directory_list_offset++] = dir; +} + +static int +get_dirstack_index (ind, sign, indexp) + intmax_t ind; + int sign, *indexp; +{ + if (indexp) + *indexp = sign > 0 ? 1 : 2; + + /* dirs +0 prints the current working directory. */ + /* dirs -0 prints last element in directory stack */ + if (ind == 0 && sign > 0) + return 0; + else if (ind == directory_list_offset) + { + if (indexp) + *indexp = sign > 0 ? 2 : 1; + return 0; + } + else if (ind >= 0 && ind <= directory_list_offset) + return (sign > 0 ? directory_list_offset - ind : ind); + else + return -1; +} + +/* Used by the tilde expansion code. */ +char * +get_dirstack_from_string (string) + char *string; +{ + int ind, sign, index_flag; + intmax_t i; + + sign = 1; + if (*string == '-' || *string == '+') + { + sign = (*string == '-') ? -1 : 1; + string++; + } + if (legal_number (string, &i) == 0) + return ((char *)NULL); + + index_flag = 0; + ind = get_dirstack_index (i, sign, &index_flag); + if (index_flag && (ind < 0 || ind > directory_list_offset)) + return ((char *)NULL); + if (index_flag == 0 || (index_flag == 1 && ind == 0)) + return (get_string_value ("PWD")); + else + return (pushd_directory_list[ind]); +} + +#ifdef INCLUDE_UNUSED +char * +get_dirstack_element (ind, sign) + intmax_t ind; + int sign; +{ + int i; + + i = get_dirstack_index (ind, sign, (int *)NULL); + return (i < 0 || i > directory_list_offset) ? (char *)NULL + : pushd_directory_list[i]; +} +#endif + +void +set_dirstack_element (ind, sign, value) + intmax_t ind; + int sign; + char *value; +{ + int i; + + i = get_dirstack_index (ind, sign, (int *)NULL); + if (ind == 0 || i < 0 || i > directory_list_offset) + return; + free (pushd_directory_list[i]); + pushd_directory_list[i] = savestring (value); +} + +WORD_LIST * +get_directory_stack (flags) + int flags; +{ + register int i; + WORD_LIST *ret; + char *d, *t; + + for (ret = (WORD_LIST *)NULL, i = 0; i < directory_list_offset; i++) + { + d = (flags&1) ? polite_directory_format (pushd_directory_list[i]) + : pushd_directory_list[i]; + ret = make_word_list (make_word (d), ret); + } + /* Now the current directory. */ + d = get_working_directory ("dirstack"); + i = 0; /* sentinel to decide whether or not to free d */ + if (d == 0) + d = "."; + else + { + t = polite_directory_format (d); + /* polite_directory_format sometimes returns its argument unchanged. + If it does not, we can free d right away. If it does, we need to + mark d to be deleted later. */ + if (t != d) + { + free (d); + d = t; + } + else /* t == d, so d is what we want */ + i = 1; + } + ret = make_word_list (make_word (d), ret); + if (i) + free (d); + return ret; /* was (REVERSE_LIST (ret, (WORD_LIST *)); */ +} + +#ifdef LOADABLE_BUILTIN +char * const dirs_doc[] = { +N_("Display the list of currently remembered directories. Directories\n\ + find their way onto the list with the `pushd' command; you can get\n\ + back up through the list with the `popd' command.\n\ + \n\ + Options:\n\ + -c clear the directory stack by deleting all of the elements\n\ + -l do not print tilde-prefixed versions of directories relative\n\ + to your home directory\n\ + -p print the directory stack with one entry per line\n\ + -v print the directory stack with one entry per line prefixed\n\ + with its position in the stack\n\ + \n\ + Arguments:\n\ + +N Displays the Nth entry counting from the left of the list shown by\n\ + dirs when invoked without options, starting with zero.\n\ + \n\ + -N Displays the Nth entry counting from the right of the list shown by\n\ + dirs when invoked without options, starting with zero."), + (char *)NULL +}; + +char * const pushd_doc[] = { +N_("Adds a directory to the top of the directory stack, or rotates\n\ + the stack, making the new top of the stack the current working\n\ + directory. With no arguments, exchanges the top two directories.\n\ + \n\ + Options:\n\ + -n Suppresses the normal change of directory when adding\n\ + directories to the stack, so only the stack is manipulated.\n\ + \n\ + Arguments:\n\ + +N Rotates the stack so that the Nth directory (counting\n\ + from the left of the list shown by `dirs', starting with\n\ + zero) is at the top.\n\ + \n\ + -N Rotates the stack so that the Nth directory (counting\n\ + from the right of the list shown by `dirs', starting with\n\ + zero) is at the top.\n\ + \n\ + dir Adds DIR to the directory stack at the top, making it the\n\ + new current working directory.\n\ + \n\ + The `dirs' builtin displays the directory stack."), + (char *)NULL +}; + +char * const popd_doc[] = { +N_("Removes entries from the directory stack. With no arguments, removes\n\ + the top directory from the stack, and changes to the new top directory.\n\ + \n\ + Options:\n\ + -n Suppresses the normal change of directory when removing\n\ + directories from the stack, so only the stack is manipulated.\n\ + \n\ + Arguments:\n\ + +N Removes the Nth entry counting from the left of the list\n\ + shown by `dirs', starting with zero. For example: `popd +0'\n\ + removes the first directory, `popd +1' the second.\n\ + \n\ + -N Removes the Nth entry counting from the right of the list\n\ + shown by `dirs', starting with zero. For example: `popd -0'\n\ + removes the last directory, `popd -1' the next to last.\n\ + \n\ + The `dirs' builtin displays the directory stack."), + (char *)NULL +}; + +struct builtin pushd_struct = { + "pushd", + pushd_builtin, + BUILTIN_ENABLED, + pushd_doc, + "pushd [+N | -N] [-n] [dir]", + 0 +}; + +struct builtin popd_struct = { + "popd", + popd_builtin, + BUILTIN_ENABLED, + popd_doc, + "popd [+N | -N] [-n]", + 0 +}; + +struct builtin dirs_struct = { + "dirs", + dirs_builtin, + BUILTIN_ENABLED, + dirs_doc, + "dirs [-clpv] [+N] [-N]", + 0 +}; +#endif /* LOADABLE_BUILTIN */ + +#endif /* PUSHD_AND_POPD */ diff --git a/builtins/read.def b/builtins/read.def new file mode 100644 index 0000000..48fda33 --- /dev/null +++ b/builtins/read.def @@ -0,0 +1,1128 @@ +This file is read.def, from which is created read.c. +It implements the builtin "read" in Bash. + +Copyright (C) 1987-2015 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 3 of the License, 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. If not, see . + +$PRODUCES read.c + +$BUILTIN read +$FUNCTION read_builtin +$SHORT_DOC read [-ers] [-a array] [-d delim] [-i text] [-n nchars] [-N nchars] [-p prompt] [-t timeout] [-u fd] [name ...] +Read a line from the standard input and split it into fields. + +Reads a single line from the standard input, or from file descriptor FD +if the -u option is supplied. The line is split into fields as with word +splitting, and the first word is assigned to the first NAME, the second +word to the second NAME, and so on, with any leftover words assigned to +the last NAME. Only the characters found in $IFS are recognized as word +delimiters. + +If no NAMEs are supplied, the line read is stored in the REPLY variable. + +Options: + -a array assign the words read to sequential indices of the array + variable ARRAY, starting at zero + -d delim continue until the first character of DELIM is read, rather + than newline + -e use Readline to obtain the line in an interactive shell + -i text use TEXT as the initial text for Readline + -n nchars return after reading NCHARS characters rather than waiting + for a newline, but honor a delimiter if fewer than + NCHARS characters are read before the delimiter + -N nchars return only after reading exactly NCHARS characters, unless + EOF is encountered or read times out, ignoring any + delimiter + -p prompt output the string PROMPT without a trailing newline before + attempting to read + -r do not allow backslashes to escape any characters + -s do not echo input coming from a terminal + -t timeout time out and return failure if a complete line of + input is not read within TIMEOUT seconds. The value of the + TMOUT variable is the default timeout. TIMEOUT may be a + fractional number. If TIMEOUT is 0, read returns + immediately, without trying to read any data, returning + success only if input is available on the specified + file descriptor. The exit status is greater than 128 + if the timeout is exceeded + -u fd read from file descriptor FD instead of the standard input + +Exit Status: +The return code is zero, unless end-of-file is encountered, read times out +(in which case it's greater than 128), a variable assignment error occurs, +or an invalid file descriptor is supplied as the argument to -u. +$END + +#include + +#include "bashtypes.h" +#include "posixstat.h" + +#include + +#include "bashansi.h" + +#if defined (HAVE_UNISTD_H) +# include +#endif + +#include +#include + +#ifdef __CYGWIN__ +# include +# include +#endif + +#include "../bashintl.h" + +#include "../shell.h" +#include "common.h" +#include "bashgetopt.h" + +#include + +#if defined (READLINE) +#include "../bashline.h" +#include +#endif + +#if defined (BUFFERED_INPUT) +# include "input.h" +#endif + +#include "shmbutil.h" + +#if !defined(errno) +extern int errno; +#endif + +extern void run_pending_traps __P((void)); + +extern int posixly_correct; +extern int trapped_signal_received; + +struct ttsave +{ + int fd; + TTYSTRUCT *attrs; +}; + +#if defined (READLINE) +static void reset_attempted_completion_function __P((char *)); +static int set_itext __P((void)); +static char *edit_line __P((char *, char *)); +static void set_eol_delim __P((int)); +static void reset_eol_delim __P((char *)); +#endif +static SHELL_VAR *bind_read_variable __P((char *, char *)); +#if defined (HANDLE_MULTIBYTE) +static int read_mbchar __P((int, char *, int, int, int)); +#endif +static void ttyrestore __P((struct ttsave *)); + +static sighandler sigalrm __P((int)); +static void reset_alarm __P((void)); + +/* Try this to see what the rest of the shell can do with the information. */ +procenv_t alrmbuf; +int sigalrm_seen; + +static int reading, tty_modified; +static SigHandler *old_alrm; +static unsigned char delim; + +static struct ttsave termsave; + +/* In all cases, SIGALRM just sets a flag that we check periodically. This + avoids problems with the semi-tricky stuff we do with the xfree of + input_string at the top of the unwind-protect list (see below). */ + +/* Set a flag that CHECK_ALRM can check. This relies on zread calling + trap.c:check_signals_and_traps(), which knows about sigalrm_seen and + alrmbuf. */ +static sighandler +sigalrm (s) + int s; +{ + sigalrm_seen = 1; +} + +static void +reset_alarm () +{ + /* Cancel alarm before restoring signal handler. */ + falarm (0, 0); + set_signal_handler (SIGALRM, old_alrm); +} + +/* Read the value of the shell variables whose names follow. + The reading is done from the current input stream, whatever + that may be. Successive words of the input line are assigned + to the variables mentioned in LIST. The last variable in LIST + gets the remainder of the words on the line. If no variables + are mentioned in LIST, then the default variable is $REPLY. */ +int +read_builtin (list) + WORD_LIST *list; +{ + register char *varname; + int size, i, nr, pass_next, saw_escape, eof, opt, retval, code, print_ps2; + int input_is_tty, input_is_pipe, unbuffered_read, skip_ctlesc, skip_ctlnul; + int raw, edit, nchars, silent, have_timeout, ignore_delim, fd, lastsig, t_errno; + unsigned int tmsec, tmusec; + long ival, uval; + intmax_t intval; + char c; + char *input_string, *orig_input_string, *ifs_chars, *prompt, *arrayname; + char *e, *t, *t1, *ps2, *tofree; + struct stat tsb; + SHELL_VAR *var; + TTYSTRUCT ttattrs, ttset; +#if defined (ARRAY_VARS) + WORD_LIST *alist; +#endif +#if defined (READLINE) + char *rlbuf, *itext; + int rlind; +#endif + + USE_VAR(size); + USE_VAR(i); + USE_VAR(pass_next); + USE_VAR(print_ps2); + USE_VAR(saw_escape); + USE_VAR(input_is_pipe); +/* USE_VAR(raw); */ + USE_VAR(edit); + USE_VAR(tmsec); + USE_VAR(tmusec); + USE_VAR(nchars); + USE_VAR(silent); + USE_VAR(ifs_chars); + USE_VAR(prompt); + USE_VAR(arrayname); +#if defined (READLINE) + USE_VAR(rlbuf); + USE_VAR(rlind); + USE_VAR(itext); +#endif + USE_VAR(list); + USE_VAR(ps2); + USE_VAR(lastsig); + + sigalrm_seen = reading = tty_modified = 0; + + i = 0; /* Index into the string that we are reading. */ + raw = edit = 0; /* Not reading raw input by default. */ + silent = 0; + arrayname = prompt = (char *)NULL; + fd = 0; /* file descriptor to read from */ + +#if defined (READLINE) + rlbuf = itext = (char *)0; + rlind = 0; +#endif + + tmsec = tmusec = 0; /* no timeout */ + nr = nchars = input_is_tty = input_is_pipe = unbuffered_read = have_timeout = 0; + delim = '\n'; /* read until newline */ + ignore_delim = 0; + + reset_internal_getopt (); + while ((opt = internal_getopt (list, "ersa:d:i:n:p:t:u:N:")) != -1) + { + switch (opt) + { + case 'r': + raw = 1; + break; + case 'p': + prompt = list_optarg; + break; + case 's': + silent = 1; + break; + case 'e': +#if defined (READLINE) + edit = 1; +#endif + break; + case 'i': +#if defined (READLINE) + itext = list_optarg; +#endif + break; +#if defined (ARRAY_VARS) + case 'a': + arrayname = list_optarg; + break; +#endif + case 't': + code = uconvert (list_optarg, &ival, &uval); + if (code == 0 || ival < 0 || uval < 0) + { + builtin_error (_("%s: invalid timeout specification"), list_optarg); + return (EXECUTION_FAILURE); + } + else + { + have_timeout = 1; + tmsec = ival; + tmusec = uval; + } + break; + case 'N': + ignore_delim = 1; + delim = -1; + case 'n': + code = legal_number (list_optarg, &intval); + if (code == 0 || intval < 0 || intval != (int)intval) + { + sh_invalidnum (list_optarg); + return (EXECUTION_FAILURE); + } + else + nchars = intval; + break; + case 'u': + code = legal_number (list_optarg, &intval); + if (code == 0 || intval < 0 || intval != (int)intval) + { + builtin_error (_("%s: invalid file descriptor specification"), list_optarg); + return (EXECUTION_FAILURE); + } + else + fd = intval; + if (sh_validfd (fd) == 0) + { + builtin_error (_("%d: invalid file descriptor: %s"), fd, strerror (errno)); + return (EXECUTION_FAILURE); + } + break; + case 'd': + delim = *list_optarg; + break; + CASE_HELPOPT; + default: + builtin_usage (); + return (EX_USAGE); + } + } + list = loptend; + + /* `read -t 0 var' tests whether input is available with select/FIONREAD, + and fails if those are unavailable */ + if (have_timeout && tmsec == 0 && tmusec == 0) +#if 0 + return (EXECUTION_FAILURE); +#else + return (input_avail (fd) ? EXECUTION_SUCCESS : EXECUTION_FAILURE); +#endif + + /* Convenience: check early whether or not the first of possibly several + variable names is a valid identifier, and bail early if so. */ +#if defined (ARRAY_VARS) + if (list && legal_identifier (list->word->word) == 0 && valid_array_reference (list->word->word, 0) == 0) +#else + if (list && legal_identifier (list->word->word) == 0) +#endif + { + sh_invalidid (list->word->word); + return (EXECUTION_FAILURE); + } + + /* If we're asked to ignore the delimiter, make sure we do. */ + if (ignore_delim) + delim = -1; + + /* IF IFS is unset, we use the default of " \t\n". */ + ifs_chars = getifs (); + if (ifs_chars == 0) /* XXX - shouldn't happen */ + ifs_chars = ""; + /* If we want to read exactly NCHARS chars, don't split on IFS */ + if (ignore_delim) + ifs_chars = ""; + for (skip_ctlesc = skip_ctlnul = 0, e = ifs_chars; *e; e++) + skip_ctlesc |= *e == CTLESC, skip_ctlnul |= *e == CTLNUL; + + input_string = (char *)xmalloc (size = 112); /* XXX was 128 */ + input_string[0] = '\0'; + + /* $TMOUT, if set, is the default timeout for read. */ + if (have_timeout == 0 && (e = get_string_value ("TMOUT"))) + { + code = uconvert (e, &ival, &uval); + if (code == 0 || ival < 0 || uval < 0) + tmsec = tmusec = 0; + else + { + tmsec = ival; + tmusec = uval; + } + } + + begin_unwind_frame ("read_builtin"); + +#if defined (BUFFERED_INPUT) + if (interactive == 0 && default_buffered_input >= 0 && fd_is_bash_input (fd)) + sync_buffered_stream (default_buffered_input); +#endif + + input_is_tty = isatty (fd); + if (input_is_tty == 0) +#ifndef __CYGWIN__ + input_is_pipe = (lseek (fd, 0L, SEEK_CUR) < 0) && (errno == ESPIPE); +#else + input_is_pipe = 1; +#endif + + /* If the -p, -e or -s flags were given, but input is not coming from the + terminal, turn them off. */ + if ((prompt || edit || silent) && input_is_tty == 0) + { + prompt = (char *)NULL; +#if defined (READLINE) + itext = (char *)NULL; +#endif + edit = silent = 0; + } + +#if defined (READLINE) + if (edit) + add_unwind_protect (xfree, rlbuf); +#endif + + pass_next = 0; /* Non-zero signifies last char was backslash. */ + saw_escape = 0; /* Non-zero signifies that we saw an escape char */ + + if (tmsec > 0 || tmusec > 0) + { + /* Turn off the timeout if stdin is a regular file (e.g. from + input redirection). */ + if ((fstat (fd, &tsb) < 0) || S_ISREG (tsb.st_mode)) + tmsec = tmusec = 0; + } + + if (tmsec > 0 || tmusec > 0) + { + code = setjmp_nosigs (alrmbuf); + if (code) + { + sigalrm_seen = 0; + /* Tricky. The top of the unwind-protect stack is the free of + input_string. We want to run all the rest and use input_string, + so we have to save input_string temporarily, run the unwind- + protects, then restore input_string so we can use it later */ + orig_input_string = 0; + input_string[i] = '\0'; /* make sure it's terminated */ + if (i == 0) + { + t = (char *)xmalloc (1); + t[0] = 0; + } + else + t = savestring (input_string); + + run_unwind_frame ("read_builtin"); + input_string = t; + retval = 128+SIGALRM; + goto assign_vars; + } + if (interactive_shell == 0) + initialize_terminating_signals (); + old_alrm = set_signal_handler (SIGALRM, sigalrm); + add_unwind_protect (reset_alarm, (char *)NULL); +#if defined (READLINE) + if (edit) + { + add_unwind_protect (reset_attempted_completion_function, (char *)NULL); + add_unwind_protect (bashline_reset_event_hook, (char *)NULL); + } +#endif + falarm (tmsec, tmusec); + } + + /* If we've been asked to read only NCHARS chars, or we're using some + character other than newline to terminate the line, do the right + thing to readline or the tty. */ + if (nchars > 0 || delim != '\n') + { +#if defined (READLINE) + if (edit) + { + if (nchars > 0) + { + unwind_protect_int (rl_num_chars_to_read); + rl_num_chars_to_read = nchars; + } + if (delim != '\n') + { + set_eol_delim (delim); + add_unwind_protect (reset_eol_delim, (char *)NULL); + } + } + else +#endif + if (input_is_tty) + { + /* ttsave() */ + termsave.fd = fd; + ttgetattr (fd, &ttattrs); + termsave.attrs = &ttattrs; + + ttset = ttattrs; + i = silent ? ttfd_cbreak (fd, &ttset) : ttfd_onechar (fd, &ttset); + if (i < 0) + sh_ttyerror (1); + tty_modified = 1; + add_unwind_protect ((Function *)ttyrestore, (char *)&termsave); + if (interactive_shell == 0) + initialize_terminating_signals (); + } + } + else if (silent) /* turn off echo but leave term in canonical mode */ + { + /* ttsave (); */ + termsave.fd = fd; + ttgetattr (fd, &ttattrs); + termsave.attrs = &ttattrs; + + ttset = ttattrs; + i = ttfd_noecho (fd, &ttset); /* ttnoecho (); */ + if (i < 0) + sh_ttyerror (1); + + tty_modified = 1; + add_unwind_protect ((Function *)ttyrestore, (char *)&termsave); + if (interactive_shell == 0) + initialize_terminating_signals (); + } + + /* This *must* be the top unwind-protect on the stack, so the manipulation + of the unwind-protect stack after the realloc() works right. */ + add_unwind_protect (xfree, input_string); + + CHECK_ALRM; + if ((nchars > 0) && (input_is_tty == 0) && ignore_delim) /* read -N */ + unbuffered_read = 2; + else if ((nchars > 0) || (delim != '\n') || input_is_pipe) + unbuffered_read = 1; + + if (prompt && edit == 0) + { + fprintf (stderr, "%s", prompt); + fflush (stderr); + } + +#if defined (__CYGWIN__) && defined (O_TEXT) + setmode (0, O_TEXT); +#endif + + ps2 = 0; + for (print_ps2 = eof = retval = 0;;) + { + CHECK_ALRM; + +#if defined (READLINE) + if (edit) + { + if (rlbuf && rlbuf[rlind] == '\0') + { + xfree (rlbuf); + rlbuf = (char *)0; + } + if (rlbuf == 0) + { + reading = 1; + rlbuf = edit_line (prompt ? prompt : "", itext); + reading = 0; + rlind = 0; + } + if (rlbuf == 0) + { + eof = 1; + break; + } + c = rlbuf[rlind++]; + } + else + { +#endif + + if (print_ps2) + { + if (ps2 == 0) + ps2 = get_string_value ("PS2"); + fprintf (stderr, "%s", ps2 ? ps2 : ""); + fflush (stderr); + print_ps2 = 0; + } + +#if 0 + if (posixly_correct == 0) + interrupt_immediately++; +#endif + reading = 1; + if (unbuffered_read == 2) + retval = posixly_correct ? zreadintr (fd, &c, 1) : zreadn (fd, &c, nchars - nr); + else if (unbuffered_read) + retval = posixly_correct ? zreadintr (fd, &c, 1) : zread (fd, &c, 1); + else + retval = posixly_correct ? zreadcintr (fd, &c) : zreadc (fd, &c); + reading = 0; +#if 0 + if (posixly_correct == 0) + interrupt_immediately--; +#endif + + if (retval <= 0) + { + if (retval < 0 && errno == EINTR) + { + lastsig = LASTSIG(); + if (lastsig == 0) + lastsig = trapped_signal_received; + run_pending_traps (); /* because interrupt_immediately is not set */ + } + else + lastsig = 0; + if (terminating_signal && tty_modified) + ttyrestore (&termsave); /* fix terminal before exiting */ + CHECK_TERMSIG; + eof = 1; + break; + } + + CHECK_ALRM; + +#if defined (READLINE) + } +#endif + + CHECK_ALRM; + if (i + 4 >= size) /* XXX was i + 2; use i + 4 for multibyte/read_mbchar */ + { + char *t; + t = (char *)xrealloc (input_string, size += 128); + + /* Only need to change unwind-protect if input_string changes */ + if (t != input_string) + { + input_string = t; + remove_unwind_protect (); + add_unwind_protect (xfree, input_string); + } + } + + /* If the next character is to be accepted verbatim, a backslash + newline pair still disappears from the input. */ + if (pass_next) + { + pass_next = 0; + if (c == '\n') + { + i--; /* back up over the CTLESC */ + if (interactive && input_is_tty && raw == 0) + print_ps2 = 1; + } + else + goto add_char; + continue; + } + + /* This may cause problems if IFS contains CTLESC */ + if (c == '\\' && raw == 0) + { + pass_next++; + if (skip_ctlesc == 0) + { + saw_escape++; + input_string[i++] = CTLESC; + } + continue; + } + + if (ignore_delim == 0 && (unsigned char)c == delim) + break; + + if (c == '\0' && delim != '\0') + continue; /* skip NUL bytes in input */ + + if ((skip_ctlesc == 0 && c == CTLESC) || (skip_ctlnul == 0 && c == CTLNUL)) + { + saw_escape++; + input_string[i++] = CTLESC; + } + +add_char: + input_string[i++] = c; + CHECK_ALRM; + +#if defined (HANDLE_MULTIBYTE) + if (nchars > 0 && MB_CUR_MAX > 1 && is_basic (c) == 0) + { + input_string[i] = '\0'; /* for simplicity and debugging */ + i += read_mbchar (fd, input_string, i, c, unbuffered_read); + } +#endif + + nr++; + + if (nchars > 0 && nr >= nchars) + break; + } + input_string[i] = '\0'; + CHECK_ALRM; + + if (retval < 0) + { + t_errno = errno; + if (errno != EINTR) + builtin_error (_("read error: %d: %s"), fd, strerror (errno)); + run_unwind_frame ("read_builtin"); + return ((t_errno != EINTR) ? EXECUTION_FAILURE : 128+lastsig); + } + + if (tmsec > 0 || tmusec > 0) + reset_alarm (); + + if (nchars > 0 || delim != '\n') + { +#if defined (READLINE) + if (edit) + { + if (nchars > 0) + rl_num_chars_to_read = 0; + if (delim != '\n') + reset_eol_delim ((char *)NULL); + } + else +#endif + if (input_is_tty) + ttyrestore (&termsave); + } + else if (silent) + ttyrestore (&termsave); + + if (unbuffered_read == 0) + zsyncfd (fd); + + discard_unwind_frame ("read_builtin"); + + retval = eof ? EXECUTION_FAILURE : EXECUTION_SUCCESS; + +assign_vars: + +#if defined (ARRAY_VARS) + /* If -a was given, take the string read, break it into a list of words, + an assign them to `arrayname' in turn. */ + if (arrayname) + { + if (legal_identifier (arrayname) == 0) + { + sh_invalidid (arrayname); + xfree (input_string); + return (EXECUTION_FAILURE); + } + + var = find_or_make_array_variable (arrayname, 1); + if (var == 0) + { + xfree (input_string); + return EXECUTION_FAILURE; /* readonly or noassign */ + } + if (assoc_p (var)) + { + builtin_error (_("%s: cannot convert associative to indexed array"), arrayname); + xfree (input_string); + return EXECUTION_FAILURE; /* existing associative array */ + } + else if (invisible_p (var)) + VUNSETATTR (var, att_invisible); + array_flush (array_cell (var)); + + alist = list_string (input_string, ifs_chars, 0); + if (alist) + { + if (saw_escape) + dequote_list (alist); + else + word_list_remove_quoted_nulls (alist); + assign_array_var_from_word_list (var, alist, 0); + dispose_words (alist); + } + xfree (input_string); + return (retval); + } +#endif /* ARRAY_VARS */ + + /* If there are no variables, save the text of the line read to the + variable $REPLY. ksh93 strips leading and trailing IFS whitespace, + so that `read x ; echo "$x"' and `read ; echo "$REPLY"' behave the + same way, but I believe that the difference in behaviors is useful + enough to not do it. Without the bash behavior, there is no way + to read a line completely without interpretation or modification + unless you mess with $IFS (e.g., setting it to the empty string). + If you disagree, change the occurrences of `#if 0' to `#if 1' below. */ + if (list == 0) + { +#if 0 + orig_input_string = input_string; + for (t = input_string; ifs_chars && *ifs_chars && spctabnl(*t) && isifs(*t); t++) + ; + input_string = t; + input_string = strip_trailing_ifs_whitespace (input_string, ifs_chars, saw_escape); +#endif + + if (saw_escape) + { + t = dequote_string (input_string); + var = bind_variable ("REPLY", t, 0); + free (t); + } + else + var = bind_variable ("REPLY", input_string, 0); + if (var == 0 || readonly_p (var) || noassign_p (var)) + retval = EXECUTION_FAILURE; + else + VUNSETATTR (var, att_invisible); + + xfree (input_string); + return (retval); + } + + /* This code implements the Posix.2 spec for splitting the words + read and assigning them to variables. */ + orig_input_string = input_string; + + /* Remove IFS white space at the beginning of the input string. If + $IFS is null, no field splitting is performed. */ + for (t = input_string; ifs_chars && *ifs_chars && spctabnl(*t) && isifs(*t); t++) + ; + input_string = t; + for (; list->next; list = list->next) + { + varname = list->word->word; +#if defined (ARRAY_VARS) + if (legal_identifier (varname) == 0 && valid_array_reference (varname, 0) == 0) +#else + if (legal_identifier (varname) == 0) +#endif + { + sh_invalidid (varname); + xfree (orig_input_string); + return (EXECUTION_FAILURE); + } + + /* If there are more variables than words read from the input, + the remaining variables are set to the empty string. */ + if (*input_string) + { + /* This call updates INPUT_STRING. */ + t = get_word_from_string (&input_string, ifs_chars, &e); + if (t) + *e = '\0'; + /* Don't bother to remove the CTLESC unless we added one + somewhere while reading the string. */ + if (t && saw_escape) + { + t1 = dequote_string (t); + var = bind_read_variable (varname, t1); + xfree (t1); + } + else + var = bind_read_variable (varname, t ? t : ""); + } + else + { + t = (char *)0; + var = bind_read_variable (varname, ""); + } + + FREE (t); + if (var == 0) + { + xfree (orig_input_string); + return (EXECUTION_FAILURE); + } + + stupidly_hack_special_variables (varname); + VUNSETATTR (var, att_invisible); + } + + /* Now assign the rest of the line to the last variable argument. */ +#if defined (ARRAY_VARS) + if (legal_identifier (list->word->word) == 0 && valid_array_reference (list->word->word, 0) == 0) +#else + if (legal_identifier (list->word->word) == 0) +#endif + { + sh_invalidid (list->word->word); + xfree (orig_input_string); + return (EXECUTION_FAILURE); + } + +#if 0 + /* This has to be done this way rather than using string_list + and list_string because Posix.2 says that the last variable gets the + remaining words and their intervening separators. */ + input_string = strip_trailing_ifs_whitespace (input_string, ifs_chars, saw_escape); +#else + /* Check whether or not the number of fields is exactly the same as the + number of variables. */ + tofree = NULL; + if (*input_string) + { + t1 = input_string; + t = get_word_from_string (&input_string, ifs_chars, &e); + if (*input_string == 0) + tofree = input_string = t; + else + { + input_string = strip_trailing_ifs_whitespace (t1, ifs_chars, saw_escape); + tofree = t; + } + } +#endif + + if (saw_escape && input_string && *input_string) + { + t = dequote_string (input_string); + var = bind_read_variable (list->word->word, t); + xfree (t); + } + else + var = bind_read_variable (list->word->word, input_string ? input_string : ""); + + if (var) + { + stupidly_hack_special_variables (list->word->word); + VUNSETATTR (var, att_invisible); + } + else + retval = EXECUTION_FAILURE; + + FREE (tofree); + xfree (orig_input_string); + + return (retval); +} + +static SHELL_VAR * +bind_read_variable (name, value) + char *name, *value; +{ + SHELL_VAR *v; + +#if defined (ARRAY_VARS) + if (valid_array_reference (name, 0) == 0) + v = bind_variable (name, value, 0); + else + v = assign_array_element (name, value, 0); +#else /* !ARRAY_VARS */ + v = bind_variable (name, value, 0); +#endif /* !ARRAY_VARS */ + return (v == 0 ? v + : ((readonly_p (v) || noassign_p (v)) ? (SHELL_VAR *)NULL : v)); +} + +#if defined (HANDLE_MULTIBYTE) +static int +read_mbchar (fd, string, ind, ch, unbuffered) + int fd; + char *string; + int ind, ch, unbuffered; +{ + char mbchar[MB_LEN_MAX + 1]; + int i, n, r; + char c; + size_t ret; + mbstate_t ps, ps_back; + wchar_t wc; + + memset (&ps, '\0', sizeof (mbstate_t)); + memset (&ps_back, '\0', sizeof (mbstate_t)); + + mbchar[0] = ch; + i = 1; + for (n = 0; n <= MB_LEN_MAX; n++) + { + ps_back = ps; + ret = mbrtowc (&wc, mbchar, i, &ps); + if (ret == (size_t)-2) + { + ps = ps_back; + /* We don't want to be interrupted during a multibyte char read */ + if (unbuffered) + r = zread (fd, &c, 1); + else + r = zreadc (fd, &c); + if (r < 0) + goto mbchar_return; + mbchar[i++] = c; + continue; + } + else if (ret == (size_t)-1 || ret == (size_t)0 || ret > (size_t)0) + break; + } + +mbchar_return: + if (i > 1) /* read a multibyte char */ + /* mbchar[0] is already string[ind-1] */ + for (r = 1; r < i; r++) + string[ind+r-1] = mbchar[r]; + return i - 1; +} +#endif + + +static void +ttyrestore (ttp) + struct ttsave *ttp; +{ + ttsetattr (ttp->fd, ttp->attrs); + tty_modified = 0; +} + +void +read_tty_cleanup () +{ + if (tty_modified) + ttyrestore (&termsave); +} + +int +read_tty_modified () +{ + return (tty_modified); +} + +#if defined (READLINE) +static rl_completion_func_t *old_attempted_completion_function = 0; +static rl_hook_func_t *old_startup_hook; +static char *deftext; + +static void +reset_attempted_completion_function (cp) + char *cp; +{ + if (rl_attempted_completion_function == 0 && old_attempted_completion_function) + rl_attempted_completion_function = old_attempted_completion_function; +} + +static int +set_itext () +{ + int r1, r2; + + r1 = r2 = 0; + if (old_startup_hook) + r1 = (*old_startup_hook) (); + if (deftext) + { + r2 = rl_insert_text (deftext); + deftext = (char *)NULL; + rl_startup_hook = old_startup_hook; + old_startup_hook = (rl_hook_func_t *)NULL; + } + return (r1 || r2); +} + +static char * +edit_line (p, itext) + char *p; + char *itext; +{ + char *ret; + int len; + + if (bash_readline_initialized == 0) + initialize_readline (); + + old_attempted_completion_function = rl_attempted_completion_function; + rl_attempted_completion_function = (rl_completion_func_t *)NULL; + bashline_set_event_hook (); + if (itext) + { + old_startup_hook = rl_startup_hook; + rl_startup_hook = set_itext; + deftext = itext; + } + + ret = readline (p); + + rl_attempted_completion_function = old_attempted_completion_function; + old_attempted_completion_function = (rl_completion_func_t *)NULL; + bashline_reset_event_hook (); + + if (ret == 0) + return ret; + len = strlen (ret); + ret = (char *)xrealloc (ret, len + 2); + ret[len++] = delim; + ret[len] = '\0'; + return ret; +} + +static int old_delim_ctype; +static rl_command_func_t *old_delim_func; +static int old_newline_ctype; +static rl_command_func_t *old_newline_func; + +static unsigned char delim_char; + +static void +set_eol_delim (c) + int c; +{ + Keymap cmap; + + if (bash_readline_initialized == 0) + initialize_readline (); + cmap = rl_get_keymap (); + + /* Change newline to self-insert */ + old_newline_ctype = cmap[RETURN].type; + old_newline_func = cmap[RETURN].function; + cmap[RETURN].type = ISFUNC; + cmap[RETURN].function = rl_insert; + + /* Bind the delimiter character to accept-line. */ + old_delim_ctype = cmap[c].type; + old_delim_func = cmap[c].function; + cmap[c].type = ISFUNC; + cmap[c].function = rl_newline; + + delim_char = c; +} + +static void +reset_eol_delim (cp) + char *cp; +{ + Keymap cmap; + + cmap = rl_get_keymap (); + + cmap[RETURN].type = old_newline_ctype; + cmap[RETURN].function = old_newline_func; + + cmap[delim_char].type = old_delim_ctype; + cmap[delim_char].function = old_delim_func; +} +#endif diff --git a/builtins/reserved.def b/builtins/reserved.def new file mode 100644 index 0000000..7f3c236 --- /dev/null +++ b/builtins/reserved.def @@ -0,0 +1,288 @@ +This file is reserved.def, in which the shell reserved words are defined. +It has no direct C file production, but defines builtins for the Bash +builtin help command. + +Copyright (C) 1987-2009 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 3 of the License, 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. If not, see . + +$BUILTIN for +$SHORT_DOC for NAME [in WORDS ... ] ; do COMMANDS; done +Execute commands for each member in a list. + +The `for' loop executes a sequence of commands for each member in a +list of items. If `in WORDS ...;' is not present, then `in "$@"' is +assumed. For each element in WORDS, NAME is set to that element, and +the COMMANDS are executed. + +Exit Status: +Returns the status of the last command executed. +$END + +$BUILTIN for (( +$DOCNAME arith_for +$SHORT_DOC for (( exp1; exp2; exp3 )); do COMMANDS; done +Arithmetic for loop. + +Equivalent to + (( EXP1 )) + while (( EXP2 )); do + COMMANDS + (( EXP3 )) + done +EXP1, EXP2, and EXP3 are arithmetic expressions. If any expression is +omitted, it behaves as if it evaluates to 1. + +Exit Status: +Returns the status of the last command executed. +$END + +$BUILTIN select +$SHORT_DOC select NAME [in WORDS ... ;] do COMMANDS; done +Select words from a list and execute commands. + +The WORDS are expanded, generating a list of words. The +set of expanded words is printed on the standard error, each +preceded by a number. If `in WORDS' is not present, `in "$@"' +is assumed. The PS3 prompt is then displayed and a line read +from the standard input. If the line consists of the number +corresponding to one of the displayed words, then NAME is set +to that word. If the line is empty, WORDS and the prompt are +redisplayed. If EOF is read, the command completes. Any other +value read causes NAME to be set to null. The line read is saved +in the variable REPLY. COMMANDS are executed after each selection +until a break command is executed. + +Exit Status: +Returns the status of the last command executed. +$END + +$BUILTIN time +$SHORT_DOC time [-p] pipeline +Report time consumed by pipeline's execution. + +Execute PIPELINE and print a summary of the real time, user CPU time, +and system CPU time spent executing PIPELINE when it terminates. + +Options: + -p print the timing summary in the portable Posix format + +The value of the TIMEFORMAT variable is used as the output format. + +Exit Status: +The return status is the return status of PIPELINE. +$END + +$BUILTIN case +$SHORT_DOC case WORD in [PATTERN [| PATTERN]...) COMMANDS ;;]... esac +Execute commands based on pattern matching. + +Selectively execute COMMANDS based upon WORD matching PATTERN. The +`|' is used to separate multiple patterns. + +Exit Status: +Returns the status of the last command executed. +$END + +$BUILTIN if +$SHORT_DOC if COMMANDS; then COMMANDS; [ elif COMMANDS; then COMMANDS; ]... [ else COMMANDS; ] fi +Execute commands based on conditional. + +The `if COMMANDS' list is executed. If its exit status is zero, then the +`then COMMANDS' list is executed. Otherwise, each `elif COMMANDS' list is +executed in turn, and if its exit status is zero, the corresponding +`then COMMANDS' list is executed and the if command completes. Otherwise, +the `else COMMANDS' list is executed, if present. The exit status of the +entire construct is the exit status of the last command executed, or zero +if no condition tested true. + +Exit Status: +Returns the status of the last command executed. +$END + +$BUILTIN while +$SHORT_DOC while COMMANDS; do COMMANDS; done +Execute commands as long as a test succeeds. + +Expand and execute COMMANDS as long as the final command in the +`while' COMMANDS has an exit status of zero. + +Exit Status: +Returns the status of the last command executed. +$END + +$BUILTIN until +$SHORT_DOC until COMMANDS; do COMMANDS; done +Execute commands as long as a test does not succeed. + +Expand and execute COMMANDS as long as the final command in the +`until' COMMANDS has an exit status which is not zero. + +Exit Status: +Returns the status of the last command executed. +$END + +$BUILTIN coproc +$SHORT_DOC coproc [NAME] command [redirections] +Create a coprocess named NAME. + +Execute COMMAND asynchronously, with the standard output and standard +input of the command connected via a pipe to file descriptors assigned +to indices 0 and 1 of an array variable NAME in the executing shell. +The default NAME is "COPROC". + +Exit Status: +The coproc command returns an exit status of 0. +$END + +$BUILTIN function +$SHORT_DOC function name { COMMANDS ; } or name () { COMMANDS ; } +Define shell function. + +Create a shell function named NAME. When invoked as a simple command, +NAME runs COMMANDs in the calling shell's context. When NAME is invoked, +the arguments are passed to the function as $1...$n, and the function's +name is in $FUNCNAME. + +Exit Status: +Returns success unless NAME is readonly. +$END + +$BUILTIN { ... } +$DOCNAME grouping_braces +$SHORT_DOC { COMMANDS ; } +Group commands as a unit. + +Run a set of commands in a group. This is one way to redirect an +entire set of commands. + +Exit Status: +Returns the status of the last command executed. +$END + +$BUILTIN % +$DOCNAME fg_percent +$SHORT_DOC job_spec [&] +Resume job in foreground. + +Equivalent to the JOB_SPEC argument to the `fg' command. Resume a +stopped or background job. JOB_SPEC can specify either a job name +or a job number. Following JOB_SPEC with a `&' places the job in +the background, as if the job specification had been supplied as an +argument to `bg'. + +Exit Status: +Returns the status of the resumed job. +$END + +$BUILTIN (( ... )) +$DOCNAME arith +$SHORT_DOC (( expression )) +Evaluate arithmetic expression. + +The EXPRESSION is evaluated according to the rules for arithmetic +evaluation. Equivalent to "let EXPRESSION". + +Exit Status: +Returns 1 if EXPRESSION evaluates to 0; returns 0 otherwise. +$END + +$BUILTIN [[ ... ]] +$DOCNAME conditional +$SHORT_DOC [[ expression ]] +Execute conditional command. + +Returns a status of 0 or 1 depending on the evaluation of the conditional +expression EXPRESSION. Expressions are composed of the same primaries used +by the `test' builtin, and may be combined using the following operators: + + ( EXPRESSION ) Returns the value of EXPRESSION + ! EXPRESSION True if EXPRESSION is false; else false + EXPR1 && EXPR2 True if both EXPR1 and EXPR2 are true; else false + EXPR1 || EXPR2 True if either EXPR1 or EXPR2 is true; else false + +When the `==' and `!=' operators are used, the string to the right of +the operator is used as a pattern and pattern matching is performed. +When the `=~' operator is used, the string to the right of the operator +is matched as a regular expression. + +The && and || operators do not evaluate EXPR2 if EXPR1 is sufficient to +determine the expression's value. + +Exit Status: +0 or 1 depending on value of EXPRESSION. +$END + +$BUILTIN variables +$DOCNAME variable_help +$SHORT_DOC variables - Names and meanings of some shell variables +Common shell variable names and usage. + +BASH_VERSION Version information for this Bash. +CDPATH A colon-separated list of directories to search + for directories given as arguments to `cd'. +GLOBIGNORE A colon-separated list of patterns describing filenames to + be ignored by pathname expansion. +#if defined (HISTORY) +HISTFILE The name of the file where your command history is stored. +HISTFILESIZE The maximum number of lines this file can contain. +HISTSIZE The maximum number of history lines that a running + shell can access. +#endif /* HISTORY */ +HOME The complete pathname to your login directory. +HOSTNAME The name of the current host. +HOSTTYPE The type of CPU this version of Bash is running under. +IGNOREEOF Controls the action of the shell on receipt of an EOF + character as the sole input. If set, then the value + of it is the number of EOF characters that can be seen + in a row on an empty line before the shell will exit + (default 10). When unset, EOF signifies the end of input. +MACHTYPE A string describing the current system Bash is running on. +MAILCHECK How often, in seconds, Bash checks for new mail. +MAILPATH A colon-separated list of filenames which Bash checks + for new mail. +OSTYPE The version of Unix this version of Bash is running on. +PATH A colon-separated list of directories to search when + looking for commands. +PROMPT_COMMAND A command to be executed before the printing of each + primary prompt. +PS1 The primary prompt string. +PS2 The secondary prompt string. +PWD The full pathname of the current directory. +SHELLOPTS A colon-separated list of enabled shell options. +TERM The name of the current terminal type. +TIMEFORMAT The output format for timing statistics displayed by the + `time' reserved word. +auto_resume Non-null means a command word appearing on a line by + itself is first looked for in the list of currently + stopped jobs. If found there, that job is foregrounded. + A value of `exact' means that the command word must + exactly match a command in the list of stopped jobs. A + value of `substring' means that the command word must + match a substring of the job. Any other value means that + the command must be a prefix of a stopped job. +#if defined (HISTORY) +# if defined (BANG_HISTORY) +histchars Characters controlling history expansion and quick + substitution. The first character is the history + substitution character, usually `!'. The second is + the `quick substitution' character, usually `^'. The + third is the `history comment' character, usually `#'. +# endif /* BANG_HISTORY */ +HISTIGNORE A colon-separated list of patterns used to decide which + commands should be saved on the history list. +#endif /* HISTORY */ +$END diff --git a/builtins/return.def b/builtins/return.def new file mode 100644 index 0000000..4d9fef1 --- /dev/null +++ b/builtins/return.def @@ -0,0 +1,74 @@ +This file is return.def, from which is created return.c. +It implements the builtin "return" in Bash. + +Copyright (C) 1987-2015 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 3 of the License, 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. If not, see . + +$PRODUCES return.c + +$BUILTIN return + +$FUNCTION return_builtin +$SHORT_DOC return [n] +Return from a shell function. + +Causes a function or sourced script to exit with the return value +specified by N. If N is omitted, the return status is that of the +last command executed within the function or script. + +Exit Status: +Returns N, or failure if the shell is not executing a function or script. +$END + +#include + +#if defined (HAVE_UNISTD_H) +# ifdef _MINIX +# include +# endif +# include +#endif + +#include "../bashintl.h" + +#include "../shell.h" +#include "common.h" +#include "bashgetopt.h" + +extern int last_command_exit_value; +extern int subshell_environment; +extern int return_catch_flag, return_catch_value; + +/* If we are executing a user-defined function then exit with the value + specified as an argument. if no argument is given, then the last + exit status is used. */ +int +return_builtin (list) + WORD_LIST *list; +{ + CHECK_HELPOPT (list); + + return_catch_value = get_exitstat (list); + + if (return_catch_flag) + sh_longjmp (return_catch, 1); + else + { + builtin_error (_("can only `return' from a function or sourced script")); + return (EXECUTION_FAILURE); + } +} diff --git a/builtins/set.def b/builtins/set.def new file mode 100644 index 0000000..8122361 --- /dev/null +++ b/builtins/set.def @@ -0,0 +1,974 @@ +This file is set.def, from which is created set.c. +It implements the "set" and "unset" builtins in Bash. + +Copyright (C) 1987-2015 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 3 of the License, 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. If not, see . + +$PRODUCES set.c + +#include + +#if defined (HAVE_UNISTD_H) +# ifdef _MINIX +# include +# endif +# include +#endif + +#include + +#include "../bashansi.h" +#include "../bashintl.h" + +#include "../shell.h" +#include "../flags.h" +#include "common.h" +#include "bashgetopt.h" + +#if defined (READLINE) +# include "../input.h" +# include "../bashline.h" +# include +#endif + +#if defined (HISTORY) +# include "../bashhist.h" +#endif + +extern int posixly_correct, ignoreeof, eof_encountered_limit; +#if defined (HISTORY) +extern int dont_save_function_defs; +#endif +#if defined (READLINE) +extern int no_line_editing; +#endif /* READLINE */ + +$BUILTIN set +$FUNCTION set_builtin +$SHORT_DOC set [-abefhkmnptuvxBCHP] [-o option-name] [--] [arg ...] +Set or unset values of shell options and positional parameters. + +Change the value of shell attributes and positional parameters, or +display the names and values of shell variables. + +Options: + -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. + -f Disable file name generation (globbing). + -h Remember the location of commands as they are looked up. + -k All assignment arguments are placed in the environment for a + command, not just those that precede the command name. + -m Job control is enabled. + -n Read commands but do not execute them. + -o option-name + Set the variable corresponding to option-name: + allexport same as -a + braceexpand same as -B +#if defined (READLINE) + emacs use an emacs-style line editing interface +#endif /* READLINE */ + errexit same as -e + errtrace same as -E + functrace same as -T + hashall same as -h +#if defined (BANG_HISTORY) + histexpand same as -H +#endif /* BANG_HISTORY */ +#if defined (HISTORY) + history enable command history +#endif + ignoreeof the shell will not exit upon reading EOF + interactive-comments + allow comments to appear in interactive commands + keyword same as -k +#if defined (JOB_CONTROL) + monitor same as -m +#endif + noclobber same as -C + noexec same as -n + noglob same as -f + nolog currently accepted but ignored +#if defined (JOB_CONTROL) + notify same as -b +#endif + nounset same as -u + onecmd same as -t + physical same as -P + pipefail the return value of a pipeline is the status of + the last command to exit with a non-zero status, + or zero if no command exited with a non-zero status + posix change the behavior of bash where the default + operation differs from the Posix standard to + match the standard + privileged same as -p + verbose same as -v +#if defined (READLINE) + vi use a vi-style line editing interface +#endif /* READLINE */ + xtrace same as -x + -p Turned on whenever the real and effective user ids do not match. + Disables processing of the $ENV file and importing of shell + functions. Turning this option off causes the effective uid and + gid to be set to the real uid and gid. + -t Exit after reading and executing one command. + -u Treat unset variables as an error when substituting. + -v Print shell input lines as they are read. + -x Print commands and their arguments as they are executed. +#if defined (BRACE_EXPANSION) + -B the shell will perform brace expansion +#endif /* BRACE_EXPANSION */ + -C If set, disallow existing regular files to be overwritten + by redirection of output. + -E If set, the ERR trap is inherited by shell functions. +#if defined (BANG_HISTORY) + -H Enable ! style history substitution. This flag is on + by default when the shell is interactive. +#endif /* BANG_HISTORY */ + -P If set, do not resolve symbolic links when executing commands + such as cd which change the current directory. + -T If set, the DEBUG and RETURN traps are inherited by shell functions. + -- Assign any remaining arguments to the positional parameters. + If there are no remaining arguments, the positional parameters + are unset. + - Assign any remaining arguments to the positional parameters. + The -x and -v options are turned off. + +Using + rather than - causes these flags to be turned off. The +flags can also be used upon invocation of the shell. The current +set of flags may be found in $-. The remaining n ARGs are positional +parameters and are assigned, in order, to $1, $2, .. $n. If no +ARGs are given, all shell variables are printed. + +Exit Status: +Returns success unless an invalid option is given. +$END + +typedef int setopt_set_func_t __P((int, char *)); +typedef int setopt_get_func_t __P((char *)); + +static void print_minus_o_option __P((char *, int, int)); +static void print_all_shell_variables __P((void)); + +static int set_ignoreeof __P((int, char *)); +static int set_posix_mode __P((int, char *)); + +#if defined (READLINE) +static int set_edit_mode __P((int, char *)); +static int get_edit_mode __P((char *)); +#endif + +#if defined (HISTORY) +static int bash_set_history __P((int, char *)); +#endif + +static const char * const on = "on"; +static const char * const off = "off"; + +static int previous_option_value; + +/* 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. If you add a new variable name here + that doesn't have a corresponding single-character option letter, make + sure to set the value appropriately in reset_shell_options. */ +const struct { + char *name; + int letter; + int *variable; + setopt_set_func_t *set_func; + setopt_get_func_t *get_func; +} o_options[] = { + { "allexport", 'a', (int *)NULL, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL }, +#if defined (BRACE_EXPANSION) + { "braceexpand",'B', (int *)NULL, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL }, +#endif +#if defined (READLINE) + { "emacs", '\0', (int *)NULL, set_edit_mode, get_edit_mode }, +#endif + { "errexit", 'e', (int *)NULL, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL }, + { "errtrace", 'E', (int *)NULL, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL }, + { "functrace", 'T', (int *)NULL, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL }, + { "hashall", 'h', (int *)NULL, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL }, +#if defined (BANG_HISTORY) + { "histexpand", 'H', (int *)NULL, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL }, +#endif /* BANG_HISTORY */ +#if defined (HISTORY) + { "history", '\0', &enable_history_list, bash_set_history, (setopt_get_func_t *)NULL }, +#endif + { "ignoreeof", '\0', &ignoreeof, set_ignoreeof, (setopt_get_func_t *)NULL }, + { "interactive-comments", '\0', &interactive_comments, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL }, + { "keyword", 'k', (int *)NULL, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL }, +#if defined (JOB_CONTROL) + { "monitor", 'm', (int *)NULL, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL }, +#endif + { "noclobber", 'C', (int *)NULL, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL }, + { "noexec", 'n', (int *)NULL, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL }, + { "noglob", 'f', (int *)NULL, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL }, +#if defined (HISTORY) + { "nolog", '\0', &dont_save_function_defs, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL }, +#endif +#if defined (JOB_CONTROL) + { "notify", 'b', (int *)NULL, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL }, +#endif /* JOB_CONTROL */ + { "nounset", 'u', (int *)NULL, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL }, + { "onecmd", 't', (int *)NULL, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL }, + { "physical", 'P', (int *)NULL, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL }, + { "pipefail", '\0', &pipefail_opt, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL }, + { "posix", '\0', &posixly_correct, set_posix_mode, (setopt_get_func_t *)NULL }, + { "privileged", 'p', (int *)NULL, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL }, + { "verbose", 'v', (int *)NULL, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL }, +#if defined (READLINE) + { "vi", '\0', (int *)NULL, set_edit_mode, get_edit_mode }, +#endif + { "xtrace", 'x', (int *)NULL, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL }, + {(char *)NULL, 0 , (int *)NULL, (setopt_set_func_t *)NULL, (setopt_get_func_t *)NULL }, +}; + +#define N_O_OPTIONS (sizeof (o_options) / sizeof (o_options[0])) + +#define GET_BINARY_O_OPTION_VALUE(i, name) \ + ((o_options[i].get_func) ? (*o_options[i].get_func) (name) \ + : (*o_options[i].variable)) + +#define SET_BINARY_O_OPTION_VALUE(i, onoff, name) \ + ((o_options[i].set_func) ? (*o_options[i].set_func) (onoff, name) \ + : (*o_options[i].variable = (onoff == FLAG_ON))) + +int +minus_o_option_value (name) + char *name; +{ + register int i; + int *on_or_off; + + for (i = 0; o_options[i].name; i++) + { + if (STREQ (name, o_options[i].name)) + { + if (o_options[i].letter) + { + on_or_off = find_flag (o_options[i].letter); + return ((on_or_off == FLAG_UNKNOWN) ? -1 : *on_or_off); + } + else + return (GET_BINARY_O_OPTION_VALUE (i, name)); + } + } + + return (-1); +} + +#define MINUS_O_FORMAT "%-15s\t%s\n" + +static void +print_minus_o_option (name, value, pflag) + char *name; + int value, pflag; +{ + if (pflag == 0) + printf (MINUS_O_FORMAT, name, value ? on : off); + else + printf ("set %co %s\n", value ? '-' : '+', name); +} + +void +list_minus_o_opts (mode, reusable) + int mode, reusable; +{ + register int i; + int *on_or_off, value; + + for (i = 0; o_options[i].name; i++) + { + if (o_options[i].letter) + { + value = 0; + on_or_off = find_flag (o_options[i].letter); + if (on_or_off == FLAG_UNKNOWN) + on_or_off = &value; + if (mode == -1 || mode == *on_or_off) + print_minus_o_option (o_options[i].name, *on_or_off, reusable); + } + else + { + value = GET_BINARY_O_OPTION_VALUE (i, o_options[i].name); + if (mode == -1 || mode == value) + print_minus_o_option (o_options[i].name, value, reusable); + } + } +} + +char ** +get_minus_o_opts () +{ + char **ret; + int i; + + ret = strvec_create (N_O_OPTIONS + 1); + for (i = 0; o_options[i].name; i++) + ret[i] = o_options[i].name; + ret[i] = (char *)NULL; + return ret; +} + +char * +get_current_options () +{ + char *temp; + int i; + + temp = (char *)xmalloc (1 + N_O_OPTIONS); + for (i = 0; o_options[i].name; i++) + { + if (o_options[i].letter) + temp[i] = *(find_flag (o_options[i].letter)); + else + temp[i] = GET_BINARY_O_OPTION_VALUE (i, o_options[i].name); + } + temp[i] = '\0'; + return (temp); +} + +void +set_current_options (bitmap) + const char *bitmap; +{ + int i; + + if (bitmap == 0) + return; + for (i = 0; o_options[i].name; i++) + { + if (o_options[i].letter) + change_flag (o_options[i].letter, bitmap[i] ? FLAG_ON : FLAG_OFF); + else + SET_BINARY_O_OPTION_VALUE (i, bitmap[i] ? FLAG_ON : FLAG_OFF, o_options[i].name); + } +} + +static int +set_ignoreeof (on_or_off, option_name) + int on_or_off; + char *option_name; +{ + ignoreeof = on_or_off == FLAG_ON; + unbind_variable_noref ("ignoreeof"); + if (ignoreeof) + bind_variable ("IGNOREEOF", "10", 0); + else + unbind_variable_noref ("IGNOREEOF"); + sv_ignoreeof ("IGNOREEOF"); + return 0; +} + +static int +set_posix_mode (on_or_off, option_name) + int on_or_off; + char *option_name; +{ + posixly_correct = on_or_off == FLAG_ON; + if (posixly_correct == 0) + unbind_variable_noref ("POSIXLY_CORRECT"); + else + bind_variable ("POSIXLY_CORRECT", "y", 0); + sv_strict_posix ("POSIXLY_CORRECT"); + return (0); +} + +#if defined (READLINE) +/* Magic. This code `knows' how readline handles rl_editing_mode. */ +static int +set_edit_mode (on_or_off, option_name) + int on_or_off; + char *option_name; +{ + int isemacs; + + if (on_or_off == FLAG_ON) + { + rl_variable_bind ("editing-mode", option_name); + + if (interactive) + with_input_from_stdin (); + no_line_editing = 0; + } + else + { + isemacs = rl_editing_mode == 1; + if ((isemacs && *option_name == 'e') || (!isemacs && *option_name == 'v')) + { + if (interactive) + with_input_from_stream (stdin, "stdin"); + no_line_editing = 1; + } + } + return 1-no_line_editing; +} + +static int +get_edit_mode (name) + char *name; +{ + return (*name == 'e' ? no_line_editing == 0 && rl_editing_mode == 1 + : no_line_editing == 0 && rl_editing_mode == 0); +} +#endif /* READLINE */ + +#if defined (HISTORY) +static int +bash_set_history (on_or_off, option_name) + int on_or_off; + char *option_name; +{ + if (on_or_off == FLAG_ON) + { + enable_history_list = 1; + bash_history_enable (); + if (history_lines_this_session == 0) + load_history (); + } + else + { + enable_history_list = 0; + bash_history_disable (); + } + return (1 - enable_history_list); +} +#endif + +int +set_minus_o_option (on_or_off, option_name) + int on_or_off; + char *option_name; +{ + register int i; + + for (i = 0; o_options[i].name; i++) + { + if (STREQ (option_name, o_options[i].name)) + { + if (o_options[i].letter == 0) + { + previous_option_value = GET_BINARY_O_OPTION_VALUE (i, o_options[i].name); + SET_BINARY_O_OPTION_VALUE (i, on_or_off, option_name); + return (EXECUTION_SUCCESS); + } + else + { + if ((previous_option_value = change_flag (o_options[i].letter, on_or_off)) == FLAG_ERROR) + { + sh_invalidoptname (option_name); + return (EXECUTION_FAILURE); + } + else + return (EXECUTION_SUCCESS); + } + + } + } + + sh_invalidoptname (option_name); + return (EX_USAGE); +} + +static void +print_all_shell_variables () +{ + SHELL_VAR **vars; + + vars = all_shell_variables (); + if (vars) + { + print_var_list (vars); + free (vars); + } + + /* POSIX.2 does not allow function names and definitions to be output when + `set' is invoked without options (PASC Interp #202). */ + if (posixly_correct == 0) + { + vars = all_shell_functions (); + if (vars) + { + print_func_list (vars); + free (vars); + } + } +} + +void +set_shellopts () +{ + char *value; + char tflag[N_O_OPTIONS]; + int vsize, i, vptr, *ip, exported; + SHELL_VAR *v; + + for (vsize = i = 0; o_options[i].name; i++) + { + tflag[i] = 0; + if (o_options[i].letter) + { + ip = find_flag (o_options[i].letter); + if (ip && *ip) + { + vsize += strlen (o_options[i].name) + 1; + tflag[i] = 1; + } + } + else if (GET_BINARY_O_OPTION_VALUE (i, o_options[i].name)) + { + vsize += strlen (o_options[i].name) + 1; + tflag[i] = 1; + } + } + + value = (char *)xmalloc (vsize + 1); + + for (i = vptr = 0; o_options[i].name; i++) + { + if (tflag[i]) + { + strcpy (value + vptr, o_options[i].name); + vptr += strlen (o_options[i].name); + value[vptr++] = ':'; + } + } + + if (vptr) + vptr--; /* cut off trailing colon */ + value[vptr] = '\0'; + + v = find_variable ("SHELLOPTS"); + + /* Turn off the read-only attribute so we can bind the new value, and + note whether or not the variable was exported. */ + if (v) + { + VUNSETATTR (v, att_readonly); + exported = exported_p (v); + } + else + exported = 0; + + v = bind_variable ("SHELLOPTS", value, 0); + + /* Turn the read-only attribute back on, and turn off the export attribute + if it was set implicitly by mark_modified_vars and SHELLOPTS was not + exported before we bound the new value. */ + VSETATTR (v, att_readonly); + if (mark_modified_vars && exported == 0 && exported_p (v)) + VUNSETATTR (v, att_exported); + + free (value); +} + +void +parse_shellopts (value) + char *value; +{ + char *vname; + int vptr; + + vptr = 0; + while (vname = extract_colon_unit (value, &vptr)) + { + set_minus_o_option (FLAG_ON, vname); + free (vname); + } +} + +void +initialize_shell_options (no_shellopts) + int no_shellopts; +{ + char *temp; + SHELL_VAR *var; + + if (no_shellopts == 0) + { + var = find_variable ("SHELLOPTS"); + /* set up any shell options we may have inherited. */ + if (var && imported_p (var)) + { + temp = (array_p (var) || assoc_p (var)) ? (char *)NULL : savestring (value_cell (var)); + if (temp) + { + parse_shellopts (temp); + free (temp); + } + } + } + + /* Set up the $SHELLOPTS variable. */ + set_shellopts (); +} + +/* Reset the values of the -o options that are not also shell flags. This is + called from execute_cmd.c:initialize_subshell() when setting up a subshell + to run an executable shell script without a leading `#!'. */ +void +reset_shell_options () +{ + pipefail_opt = 0; + ignoreeof = 0; + +#if defined (STRICT_POSIX) + posixly_correct = 1; +#else + posixly_correct = 0; +#endif +#if defined (HISTORY) + dont_save_function_defs = 0; + remember_on_history = enable_history_list = 1; +#endif +} + +/* Set some flags from the word values in the input list. If LIST is empty, + then print out the values of the variables instead. If LIST contains + non-flags, then set $1 - $9 to the successive words of LIST. */ +int +set_builtin (list) + WORD_LIST *list; +{ + int on_or_off, flag_name, force_assignment, opts_changed, rv, r; + register char *arg; + char s[3]; + + if (list == 0) + { + print_all_shell_variables (); + return (sh_chkwrite (EXECUTION_SUCCESS)); + } + + /* Check validity of flag arguments. */ + rv = EXECUTION_SUCCESS; + reset_internal_getopt (); + while ((flag_name = internal_getopt (list, optflags)) != -1) + { + switch (flag_name) + { + case 'i': /* don't allow set -i */ + s[0] = list_opttype; + s[1] = 'i'; + s[2] = '\0'; + sh_invalidopt (s); + builtin_usage (); + return (EX_USAGE); + CASE_HELPOPT; + case '?': + builtin_usage (); + return (list_optopt == '?' ? EXECUTION_SUCCESS : EX_USAGE); + default: + break; + } + } + + /* Do the set command. While the list consists of words starting with + '-' or '+' treat them as flags, otherwise, start assigning them to + $1 ... $n. */ + for (force_assignment = opts_changed = 0; list; ) + { + arg = list->word->word; + + /* If the argument is `--' or `-' then signal the end of the list + and remember the remaining arguments. */ + if (arg[0] == '-' && (!arg[1] || (arg[1] == '-' && !arg[2]))) + { + list = list->next; + + /* `set --' unsets the positional parameters. */ + if (arg[1] == '-') + force_assignment = 1; + + /* Until told differently, the old shell behaviour of + `set - [arg ...]' being equivalent to `set +xv [arg ...]' + stands. Posix.2 says the behaviour is marked as obsolescent. */ + else + { + change_flag ('x', '+'); + change_flag ('v', '+'); + opts_changed = 1; + } + + break; + } + + if ((on_or_off = *arg) && (on_or_off == '-' || on_or_off == '+')) + { + while (flag_name = *++arg) + { + if (flag_name == '?') + { + builtin_usage (); + return (EXECUTION_SUCCESS); + } + else if (flag_name == 'o') /* -+o option-name */ + { + char *option_name; + WORD_LIST *opt; + + opt = list->next; + + if (opt == 0) + { + list_minus_o_opts (-1, (on_or_off == '+')); + rv = sh_chkwrite (rv); + continue; + } + + option_name = opt->word->word; + + if (option_name == 0 || *option_name == '\0' || + *option_name == '-' || *option_name == '+') + { + list_minus_o_opts (-1, (on_or_off == '+')); + continue; + } + list = list->next; /* Skip over option name. */ + + opts_changed = 1; + if ((r = set_minus_o_option (on_or_off, option_name)) != EXECUTION_SUCCESS) + { + set_shellopts (); + return (r); + } + } + else if (change_flag (flag_name, on_or_off) == FLAG_ERROR) + { + s[0] = on_or_off; + s[1] = flag_name; + s[2] = '\0'; + sh_invalidopt (s); + builtin_usage (); + set_shellopts (); + return (EXECUTION_FAILURE); + } + opts_changed = 1; + } + } + else + { + break; + } + list = list->next; + } + + /* Assigning $1 ... $n */ + if (list || force_assignment) + remember_args (list, 1); + /* Set up new value of $SHELLOPTS */ + if (opts_changed) + set_shellopts (); + return (rv); +} + +$BUILTIN unset +$FUNCTION unset_builtin +$SHORT_DOC unset [-f] [-v] [-n] [name ...] +Unset values and attributes of shell variables and functions. + +For each NAME, remove the corresponding variable or function. + +Options: + -f treat each NAME as a shell function + -v treat each NAME as a shell variable + -n treat each NAME as a name reference and unset the variable itself + rather than the variable it references + +Without options, unset first tries to unset a variable, and if that fails, +tries to unset a function. + +Some variables cannot be unset; also see `readonly'. + +Exit Status: +Returns success unless an invalid option is given or a NAME is read-only. +$END + +#define NEXT_VARIABLE() any_failed++; list = list->next; continue; + +int +unset_builtin (list) + WORD_LIST *list; +{ + int unset_function, unset_variable, unset_array, opt, nameref, any_failed; + int global_unset_func, global_unset_var; + char *name, *tname; + + unset_function = unset_variable = unset_array = nameref = any_failed = 0; + global_unset_func = global_unset_var = 0; + + reset_internal_getopt (); + while ((opt = internal_getopt (list, "fnv")) != -1) + { + switch (opt) + { + case 'f': + global_unset_func = 1; + break; + case 'v': + global_unset_var = 1; + break; + case 'n': + nameref = 1; + break; + CASE_HELPOPT; + default: + builtin_usage (); + return (EX_USAGE); + } + } + + list = loptend; + + if (global_unset_func && global_unset_var) + { + builtin_error (_("cannot simultaneously unset a function and a variable")); + return (EXECUTION_FAILURE); + } + else if (unset_function && nameref) + nameref = 0; + + while (list) + { + SHELL_VAR *var; + int tem; +#if defined (ARRAY_VARS) + char *t; +#endif + + name = list->word->word; + + unset_function = global_unset_func; + unset_variable = global_unset_var; + +#if defined (ARRAY_VARS) + unset_array = 0; + if (!unset_function && nameref == 0 && valid_array_reference (name, 0)) + { + t = strchr (name, '['); + *t++ = '\0'; + unset_array++; + } +#endif + /* Get error checking out of the way first. The low-level functions + just perform the unset, relying on the caller to verify. */ + + /* Bash allows functions with names which are not valid identifiers + to be created when not in posix mode, so check only when in posix + mode when unsetting a function. */ + if (((unset_function && posixly_correct) || !unset_function) && legal_identifier (name) == 0) + { + sh_invalidid (name); + NEXT_VARIABLE (); + } + + /* Only search for functions here if -f supplied. */ + var = unset_function ? find_function (name) + : (nameref ? find_variable_last_nameref (name, 0) : find_variable (name)); + + /* Some variables (but not functions yet) cannot be unset, period. */ + if (var && unset_function == 0 && non_unsettable_p (var)) + { + builtin_error (_("%s: cannot unset"), name); + NEXT_VARIABLE (); + } + + /* if we have a nameref we want to use it */ + if (var && unset_function == 0 && nameref == 0 && STREQ (name, name_cell(var)) == 0) + name = name_cell (var); + + /* Posix.2 says try variables first, then functions. If we would + find a function after unsuccessfully searching for a variable, + note that we're acting on a function now as if -f were + supplied. The readonly check below takes care of it. */ + if (var == 0 && nameref == 0 && unset_variable == 0 && unset_function == 0) + { + if (var = find_function (name)) + unset_function = 1; + } + + /* Posix.2 says that unsetting readonly variables is an error. */ + if (var && readonly_p (var)) + { + builtin_error (_("%s: cannot unset: readonly %s"), + var->name, unset_function ? "function" : "variable"); + NEXT_VARIABLE (); + } + + /* Unless the -f option is supplied, the name refers to a variable. */ +#if defined (ARRAY_VARS) + if (var && unset_array) + { + /* Let unbind_array_element decide what to do with non-array vars */ + tem = unbind_array_element (var, t); + if (tem == -2 && array_p (var) == 0 && assoc_p (var) == 0) + { + builtin_error (_("%s: not an array variable"), var->name); + NEXT_VARIABLE (); + } + else if (tem < 0) + any_failed++; + } + else +#endif /* ARRAY_VARS */ + /* If we're trying to unset a nameref variable whose value isn't a set + variable, make sure we still try to unset the nameref's value */ + if (var == 0 && nameref == 0 && unset_function == 0) + { + var = find_variable_last_nameref (name, 0); + if (var && nameref_p (var)) + { +#if defined (ARRAY_VARS) + if (valid_array_reference (nameref_cell (var), 0)) + { + tname = savestring (nameref_cell (var)); + if (var = array_variable_part (tname, &t, 0)) + tem = unbind_array_element (var, t); + free (tname); + } + else +#endif + tem = unbind_variable (nameref_cell (var)); + } + else + tem = unbind_variable (name); + } + else + tem = unset_function ? unbind_func (name) : (nameref ? unbind_nameref (name) : unbind_variable (name)); + + /* This is what Posix.2 says: ``If neither -f nor -v + is specified, the name refers to a variable; if a variable by + that name does not exist, a function by that name, if any, + shall be unset.'' */ + if (tem == -1 && nameref == 0 && unset_function == 0 && unset_variable == 0) + tem = unbind_func (name); + + name = list->word->word; /* reset above for namerefs */ + + /* SUSv3, POSIX.1-2001 say: ``Unsetting a variable or function that + was not previously set shall not be considered an error.'' */ + + if (unset_function == 0) + stupidly_hack_special_variables (name); + + list = list->next; + } + + return (any_failed ? EXECUTION_FAILURE : EXECUTION_SUCCESS); +} diff --git a/builtins/setattr.def b/builtins/setattr.def new file mode 100644 index 0000000..8f29e11 --- /dev/null +++ b/builtins/setattr.def @@ -0,0 +1,614 @@ +This file is setattr.def, from which is created setattr.c. +It implements the builtins "export" and "readonly", in Bash. + +Copyright (C) 1987-2015 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 3 of the License, 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. If not, see . + +$PRODUCES setattr.c + +#include + +#if defined (HAVE_UNISTD_H) +# ifdef _MINIX +# include +# endif +# include +#endif + +#include +#include "../bashansi.h" +#include "../bashintl.h" + +#include "../shell.h" +#include "../flags.h" +#include "common.h" +#include "bashgetopt.h" + +extern int posixly_correct; +extern int array_needs_making; +extern char *this_command_name; +extern sh_builtin_func_t *this_shell_builtin; + +#ifdef ARRAY_VARS +extern int declare_builtin __P((WORD_LIST *)); +#endif + +#define READONLY_OR_EXPORT \ + (this_shell_builtin == readonly_builtin || this_shell_builtin == export_builtin) + +$BUILTIN export +$FUNCTION export_builtin +$SHORT_DOC export [-fn] [name[=value] ...] or export -p +Set export attribute for shell variables. + +Marks each NAME for automatic export to the environment of subsequently +executed commands. If VALUE is supplied, assign VALUE before exporting. + +Options: + -f refer to shell functions + -n remove the export property from each NAME + -p display a list of all exported variables and functions + +An argument of `--' disables further option processing. + +Exit Status: +Returns success unless an invalid option is given or NAME is invalid. +$END + +/* For each variable name in LIST, make that variable appear in the + environment passed to simple commands. If there is no LIST, then + print all such variables. An argument of `-n' says to remove the + exported attribute from variables named in LIST. An argument of + -f indicates that the names present in LIST refer to functions. */ +int +export_builtin (list) + register WORD_LIST *list; +{ + return (set_or_show_attributes (list, att_exported, 0)); +} + +$BUILTIN readonly +$FUNCTION readonly_builtin +$SHORT_DOC readonly [-aAf] [name[=value] ...] or readonly -p +Mark shell variables as unchangeable. + +Mark each NAME as read-only; the values of these NAMEs may not be +changed by subsequent assignment. If VALUE is supplied, assign VALUE +before marking as read-only. + +Options: + -a refer to indexed array variables + -A refer to associative array variables + -f refer to shell functions + -p display a list of all readonly variables or functions, + depending on whether or not the -f option is given + +An argument of `--' disables further option processing. + +Exit Status: +Returns success unless an invalid option is given or NAME is invalid. +$END + +/* For each variable name in LIST, make that variable readonly. Given an + empty LIST, print out all existing readonly variables. */ +int +readonly_builtin (list) + register WORD_LIST *list; +{ + return (set_or_show_attributes (list, att_readonly, 0)); +} + +#if defined (ARRAY_VARS) +# define ATTROPTS "aAfnp" +#else +# define ATTROPTS "fnp" +#endif + +/* For each variable name in LIST, make that variable have the specified + ATTRIBUTE. An arg of `-n' says to remove the attribute from the the + remaining names in LIST (doesn't work for readonly). */ +int +set_or_show_attributes (list, attribute, nodefs) + register WORD_LIST *list; + int attribute, nodefs; +{ + register SHELL_VAR *var; + int assign, undo, any_failed, assign_error, opt; + int functions_only, arrays_only, assoc_only; + int aflags; + char *name; +#if defined (ARRAY_VARS) + WORD_LIST *nlist, *tlist; + WORD_DESC *w; + char optw[8]; + int opti; +#endif + + functions_only = arrays_only = assoc_only = 0; + undo = any_failed = assign_error = 0; + /* Read arguments from the front of the list. */ + reset_internal_getopt (); + while ((opt = internal_getopt (list, ATTROPTS)) != -1) + { + switch (opt) + { + case 'n': + undo = 1; + break; + case 'f': + functions_only = 1; + break; +#if defined (ARRAY_VARS) + case 'a': + arrays_only = 1; + break; + case 'A': + assoc_only = 1; + break; +#endif + case 'p': + break; + CASE_HELPOPT; + default: + builtin_usage (); + return (EX_USAGE); + } + } + list = loptend; + + if (list) + { + if (attribute & att_exported) + array_needs_making = 1; + + /* Cannot undo readonly status, silently disallowed. */ + if (undo && (attribute & att_readonly)) + attribute &= ~att_readonly; + + while (list) + { + name = list->word->word; + + if (functions_only) /* xxx -f name */ + { + var = find_function (name); + if (var == 0) + { + builtin_error (_("%s: not a function"), name); + any_failed++; + } + else if ((attribute & att_exported) && undo == 0 && exportable_function_name (name) == 0) + { + builtin_error (_("%s: cannot export"), name); + any_failed++; + } + else + SETVARATTR (var, attribute, undo); + + list = list->next; + continue; + } + + /* xxx [-np] name[=value] */ + assign = assignment (name, 0); + + aflags = 0; + if (assign) + { + name[assign] = '\0'; + if (name[assign - 1] == '+') + { + aflags |= ASS_APPEND; + name[assign - 1] = '\0'; + } + } + + if (legal_identifier (name) == 0) + { + sh_invalidid (name); + if (assign) + assign_error++; + else + any_failed++; + list = list->next; + continue; + } + + if (assign) /* xxx [-np] name=value */ + { + name[assign] = '='; + if (aflags & ASS_APPEND) + name[assign - 1] = '+'; +#if defined (ARRAY_VARS) + /* Let's try something here. Turn readonly -a xxx=yyy into + declare -ra xxx=yyy and see what that gets us. */ + if (arrays_only || assoc_only) + { + tlist = list->next; + list->next = (WORD_LIST *)NULL; + /* Add -g to avoid readonly/export creating local variables: + only local/declare/typeset create local variables */ + opti = 0; + optw[opti++] = '-'; + optw[opti++] = 'g'; + if (attribute & att_readonly) + optw[opti++] = 'r'; + if (attribute & att_exported) + optw[opti++] = 'x'; + if (arrays_only) + optw[opti++] = 'a'; + else + optw[opti++] = 'A'; + optw[opti] = '\0'; + + w = make_word (optw); + nlist = make_word_list (w, list); + + opt = declare_builtin (nlist); + if (opt != EXECUTION_SUCCESS) + assign_error++; + list->next = tlist; + dispose_word (w); + free (nlist); + } + else +#endif + /* This word has already been expanded once with command + and parameter expansion. Call do_assignment_no_expand (), + which does not do command or parameter substitution. If + the assignment is not performed correctly, flag an error. */ + if (do_assignment_no_expand (name) == 0) + assign_error++; + name[assign] = '\0'; + if (aflags & ASS_APPEND) + name[assign - 1] = '\0'; + } + + set_var_attribute (name, attribute, undo); + list = list->next; + } + } + else + { + SHELL_VAR **variable_list; + register int i; + + if ((attribute & att_function) || functions_only) + { + variable_list = all_shell_functions (); + if (attribute != att_function) + attribute &= ~att_function; /* so declare -xf works, for example */ + } + else + variable_list = all_shell_variables (); + +#if defined (ARRAY_VARS) + if (attribute & att_array) + { + arrays_only++; + if (attribute != att_array) + attribute &= ~att_array; + } + else if (attribute & att_assoc) + { + assoc_only++; + if (attribute != att_assoc) + attribute &= ~att_assoc; + } +#endif + + if (variable_list) + { + for (i = 0; var = variable_list[i]; i++) + { +#if defined (ARRAY_VARS) + if (arrays_only && array_p (var) == 0) + continue; + else if (assoc_only && assoc_p (var) == 0) + continue; +#endif + + /* If we imported a variable that's not a valid identifier, don't + show it in any lists. */ + if ((var->attributes & (att_invisible|att_imported)) == (att_invisible|att_imported)) + continue; + + if ((var->attributes & attribute)) + { + show_var_attributes (var, READONLY_OR_EXPORT, nodefs); + if (any_failed = sh_chkwrite (any_failed)) + break; + } + } + free (variable_list); + } + } + + return (assign_error ? EX_BADASSIGN + : ((any_failed == 0) ? EXECUTION_SUCCESS + : EXECUTION_FAILURE)); +} + +/* Show all variable variables (v == 1) or functions (v == 0) with + attributes. */ +int +show_all_var_attributes (v, nodefs) + int v, nodefs; +{ + SHELL_VAR **variable_list, *var; + int any_failed; + register int i; + + variable_list = v ? all_shell_variables () : all_shell_functions (); + if (variable_list == 0) + return (EXECUTION_SUCCESS); + + for (i = any_failed = 0; var = variable_list[i]; i++) + { + show_var_attributes (var, READONLY_OR_EXPORT, nodefs); + if (any_failed = sh_chkwrite (any_failed)) + break; + } + free (variable_list); + return (any_failed == 0 ? EXECUTION_SUCCESS : EXECUTION_FAILURE); +} + +int +var_attribute_string (var, pattr, flags) + SHELL_VAR *var; + int pattr; + char *flags; /* filled in with attributes */ +{ + int i; + + i = 0; + + /* pattr == 0 means we are called from `declare'. */ + if (pattr == 0 || posixly_correct == 0) + { +#if defined (ARRAY_VARS) + if (array_p (var)) + flags[i++] = 'a'; + + if (assoc_p (var)) + flags[i++] = 'A'; +#endif + + if (function_p (var)) + flags[i++] = 'f'; + + if (integer_p (var)) + flags[i++] = 'i'; + + if (nameref_p (var)) + flags[i++] = 'n'; + + if (readonly_p (var)) + flags[i++] = 'r'; + + if (trace_p (var)) + flags[i++] = 't'; + + if (exported_p (var)) + flags[i++] = 'x'; + + if (capcase_p (var)) + flags[i++] = 'c'; + + if (lowercase_p (var)) + flags[i++] = 'l'; + + if (uppercase_p (var)) + flags[i++] = 'u'; + } + else + { +#if defined (ARRAY_VARS) + if (array_p (var)) + flags[i++] = 'a'; + + if (assoc_p (var)) + flags[i++] = 'A'; +#endif + + if (function_p (var)) + flags[i++] = 'f'; + } + + flags[i] = '\0'; + return i; +} + +/* Show the attributes for shell variable VAR. If NODEFS is non-zero, + don't show function definitions along with the name. If PATTR is + non-zero, it indicates we're being called from `export' or `readonly'. + In POSIX mode, this prints the name of the calling builtin (`export' + or `readonly') instead of `declare', and doesn't print function defs + when called by `export' or `readonly'. */ +int +show_var_attributes (var, pattr, nodefs) + SHELL_VAR *var; + int pattr, nodefs; +{ + char flags[MAX_ATTRIBUTES], *x; + int i; + + i = var_attribute_string (var, pattr, flags); + + /* If we're printing functions with definitions, print the function def + first, then the attributes, instead of printing output that can't be + reused as input to recreate the current state. */ + if (function_p (var) && nodefs == 0 && (pattr == 0 || posixly_correct == 0)) + { + printf ("%s\n", named_function_string (var->name, function_cell (var), FUNC_MULTILINE|FUNC_EXTERNAL)); + nodefs++; + if (pattr == 0 && i == 1 && flags[0] == 'f') + return 0; /* don't print `declare -f name' */ + } + + if (pattr == 0 || posixly_correct == 0) + printf ("declare -%s ", i ? flags : "-"); + else if (i) + printf ("%s -%s ", this_command_name, flags); + else + printf ("%s ", this_command_name); + +#if defined (ARRAY_VARS) + if (invisible_p (var) && (array_p (var) || assoc_p (var))) + printf ("%s\n", var->name); + else if (array_p (var)) + print_array_assignment (var, 0); + else if (assoc_p (var)) + print_assoc_assignment (var, 0); + else +#endif + /* force `readonly' and `export' to not print out function definitions + when in POSIX mode. */ + if (nodefs || (function_p (var) && pattr != 0 && posixly_correct)) + printf ("%s\n", var->name); + else if (function_p (var)) + printf ("%s\n", named_function_string (var->name, function_cell (var), FUNC_MULTILINE|FUNC_EXTERNAL)); + else if (invisible_p (var) || var_isset (var) == 0) + printf ("%s\n", var->name); + else + { + x = sh_double_quote (value_cell (var)); + printf ("%s=%s\n", var->name, x); + free (x); + } + return (0); +} + +int +show_name_attributes (name, nodefs) + char *name; + int nodefs; +{ + SHELL_VAR *var; + +#if 0 + var = find_variable_tempenv (name); +#else + var = find_variable_noref (name); +#endif + + if (var /* && invisible_p (var) == 0 */) /* XXX bash-4.4/bash-5.0 */ + { + show_var_attributes (var, READONLY_OR_EXPORT, nodefs); + return (0); + } + else + return (1); +} + +int +show_func_attributes (name, nodefs) + char *name; + int nodefs; +{ + SHELL_VAR *var; + + var = find_function (name); + + if (var) + { + show_var_attributes (var, READONLY_OR_EXPORT, nodefs); + return (0); + } + else + return (1); +} + +void +set_var_attribute (name, attribute, undo) + char *name; + int attribute, undo; +{ + SHELL_VAR *var, *tv, *v, *refvar; + char *tvalue, *refname; + + if (undo) + var = find_variable (name); + else + { + tv = find_tempenv_variable (name); + /* XXX -- need to handle case where tv is a temp variable in a + function-scope context, since function_env has been merged into + the local variables table. */ + if (tv && tempvar_p (tv)) + { + tvalue = var_isset (tv) ? savestring (value_cell (tv)) : savestring (""); + + var = bind_variable (tv->name, tvalue, 0); + if (var == 0) + { + free (tvalue); + return; /* XXX - no error message here */ + } + var->attributes |= tv->attributes & ~att_tempvar; + /* This avoids an error message when propagating a read-only var + later on. */ + if (var->context == 0 && (attribute & att_readonly)) + { + /* Don't bother to set the `propagate to the global variables + table' flag if we've just bound the variable in that table */ + v = find_global_variable (tv->name); + if (v != var) + VSETATTR (tv, att_propagate); + } + else + VSETATTR (tv, att_propagate); + if (var->context != 0) + VSETATTR (var, att_propagate); + SETVARATTR (tv, attribute, undo); /* XXX */ + + stupidly_hack_special_variables (tv->name); + + free (tvalue); + } + else + { + var = find_variable_notempenv (name); + if (var == 0) + { + /* We might have a nameref pointing to something that we can't + resolve to a shell variable. If we do, skip it. We do a little + checking just so we can print an error message. */ + refvar = find_variable_nameref_for_create (name, 0); + if (refvar == INVALID_NAMEREF_VALUE) + return; + /* Otherwise we probably have a nameref pointing to a variable + that hasn't been created yet. bind_variable will take care + of that. */ + } + if (var == 0) + { + var = bind_variable (name, (char *)NULL, 0); + if (var && no_invisible_vars == 0) + VSETATTR (var, att_invisible); + } + else if (var->context != 0) + VSETATTR (var, att_propagate); + } + } + + if (var) + SETVARATTR (var, attribute, undo); + + if (var && (exported_p (var) || (attribute & att_exported))) + array_needs_making++; /* XXX */ +} diff --git a/builtins/shift.def b/builtins/shift.def new file mode 100644 index 0000000..589e329 --- /dev/null +++ b/builtins/shift.def @@ -0,0 +1,106 @@ +This file is shift.def, from which is created shift.c. +It implements the builtin "shift" in Bash. + +Copyright (C) 1987-2009 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 3 of the License, 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. If not, see . + +$PRODUCES shift.c + +#include + +#if defined (HAVE_UNISTD_H) +# ifdef _MINIX +# include +# endif +# include +#endif + +#include "../bashansi.h" +#include "../bashintl.h" + +#include "../shell.h" +#include "common.h" + +$BUILTIN shift +$FUNCTION shift_builtin +$SHORT_DOC shift [n] +Shift positional parameters. + +Rename the positional parameters $N+1,$N+2 ... to $1,$2 ... If N is +not given, it is assumed to be 1. + +Exit Status: +Returns success unless N is negative or greater than $#. +$END + +int print_shift_error; + +/* Shift the arguments ``left''. Shift DOLLAR_VARS down then take one + off of REST_OF_ARGS and place it into DOLLAR_VARS[9]. If LIST has + anything in it, it is a number which says where to start the + shifting. Return > 0 if `times' > $#, otherwise 0. */ +int +shift_builtin (list) + WORD_LIST *list; +{ + intmax_t times; + register int count; + WORD_LIST *temp; + + CHECK_HELPOPT (list); + + if (get_numeric_arg (list, 0, ×) == 0) + return (EXECUTION_FAILURE); + + if (times == 0) + return (EXECUTION_SUCCESS); + else if (times < 0) + { + sh_erange (list ? list->word->word : NULL, _("shift count")); + return (EXECUTION_FAILURE); + } + else if (times > number_of_args ()) + { + if (print_shift_error) + sh_erange (list ? list->word->word : NULL, _("shift count")); + return (EXECUTION_FAILURE); + } + + while (times-- > 0) + { + if (dollar_vars[1]) + free (dollar_vars[1]); + + for (count = 1; count < 9; count++) + dollar_vars[count] = dollar_vars[count + 1]; + + if (rest_of_args) + { + temp = rest_of_args; + dollar_vars[9] = savestring (temp->word->word); + rest_of_args = rest_of_args->next; + temp->next = (WORD_LIST *)NULL; + dispose_words (temp); + } + else + dollar_vars[9] = (char *)NULL; + } + + invalidate_cached_quoted_dollar_at (); + + return (EXECUTION_SUCCESS); +} diff --git a/builtins/shopt.def b/builtins/shopt.def new file mode 100644 index 0000000..2febb7e --- /dev/null +++ b/builtins/shopt.def @@ -0,0 +1,846 @@ +This file is shopt.def, from which is created shopt.c. +It implements the Bash `shopt' builtin. + +Copyright (C) 1994-2016 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 3 of the License, 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. If not, see . + +$PRODUCES shopt.c + +$BUILTIN shopt +$FUNCTION shopt_builtin +$SHORT_DOC shopt [-pqsu] [-o] [optname ...] +Set and unset shell options. + +Change the setting of each shell option OPTNAME. Without any option +arguments, list all shell options with an indication of whether or not each +is set. + +Options: + -o restrict OPTNAMEs to those defined for use with `set -o' + -p print each shell option with an indication of its status + -q suppress output + -s enable (set) each OPTNAME + -u disable (unset) each OPTNAME + +Exit Status: +Returns success if OPTNAME is enabled; fails if an invalid option is +given or OPTNAME is disabled. +$END + +#include + +#if defined (HAVE_UNISTD_H) +# ifdef _MINIX +# include +# endif +# include +#endif + +#include + +#include "version.h" + +#include "../bashintl.h" + +#include "../shell.h" +#include "../flags.h" +#include "common.h" +#include "bashgetopt.h" + +#if defined (READLINE) +# include "../bashline.h" +#endif + +#if defined (HISTORY) +# include "../bashhist.h" +#endif + +#define UNSETOPT 0 +#define SETOPT 1 + +#define OPTFMT "%-15s\t%s\n" + +extern int allow_null_glob_expansion, fail_glob_expansion, glob_dot_filenames; +extern int cdable_vars, mail_warning, source_uses_path; +extern int no_exit_on_failed_exec, print_shift_error; +extern int check_hashed_filenames, promptvars; +extern int cdspelling, expand_aliases; +extern int extended_quote; +extern int check_window_size; +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; +extern int glob_star; +extern int glob_asciirange; +extern int lastpipe_opt; +extern int inherit_errexit; + +#if defined (EXTENDED_GLOB) +extern int extended_glob; +#endif + +#if defined (READLINE) +extern int hist_verify, history_reediting, perform_hostname_completion; +extern int no_empty_command_completion; +extern int force_fignore; +extern int dircomplete_spelling, dircomplete_expand; +extern int complete_fullquote; + +extern int enable_hostname_completion __P((int)); +#endif + +#if defined (PROGRAMMABLE_COMPLETION) +extern int prog_completion_enabled; +#endif + +#if defined (RESTRICTED_SHELL) +extern char *shell_name; +#endif + +#if defined (DEBUGGER) +extern int debugging_mode; +#endif + +static void shopt_error __P((char *)); + +static int set_shellopts_after_change __P((char *, int)); +static int shopt_enable_hostname_completion __P((char *, int)); +static int set_compatibility_level __P((char *, int)); + +#if defined (RESTRICTED_SHELL) +static int set_restricted_shell __P((char *, int)); +#endif + +#if defined (READLINE) +static int shopt_set_complete_direxpand __P((char *, int)); +#endif + +static int shopt_set_debug_mode __P((char *, int)); + +static int shopt_login_shell; +static int shopt_compat31; +static int shopt_compat32; +static int shopt_compat40; +static int shopt_compat41; +static int shopt_compat42; +static int shopt_compat43; + +typedef int shopt_set_func_t __P((char *, int)); + +/* If you add a new variable name here, make sure to set the default value + appropriately in reset_shopt_options. */ + +static struct { + char *name; + 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 }, +#if defined (JOB_CONTROL) + { "checkjobs", &check_jobs_at_exit, (shopt_set_func_t *)NULL }, +#endif + { "checkwinsize", &check_window_size, (shopt_set_func_t *)NULL }, +#if defined (HISTORY) + { "cmdhist", &command_oriented_history, (shopt_set_func_t *)NULL }, +#endif + { "compat31", &shopt_compat31, set_compatibility_level }, + { "compat32", &shopt_compat32, set_compatibility_level }, + { "compat40", &shopt_compat40, set_compatibility_level }, + { "compat41", &shopt_compat41, set_compatibility_level }, + { "compat42", &shopt_compat42, set_compatibility_level }, + { "compat43", &shopt_compat43, set_compatibility_level }, +#if defined (READLINE) + { "complete_fullquote", &complete_fullquote, (shopt_set_func_t *)NULL}, + { "direxpand", &dircomplete_expand, shopt_set_complete_direxpand }, + { "dirspell", &dircomplete_spelling, (shopt_set_func_t *)NULL }, +#endif + { "dotglob", &glob_dot_filenames, (shopt_set_func_t *)NULL }, + { "execfail", &no_exit_on_failed_exec, (shopt_set_func_t *)NULL }, + { "expand_aliases", &expand_aliases, (shopt_set_func_t *)NULL }, +#if defined (DEBUGGER) + { "extdebug", &debugging_mode, shopt_set_debug_mode }, +#endif +#if defined (EXTENDED_GLOB) + { "extglob", &extended_glob, (shopt_set_func_t *)NULL }, +#endif + { "extquote", &extended_quote, (shopt_set_func_t *)NULL }, + { "failglob", &fail_glob_expansion, (shopt_set_func_t *)NULL }, +#if defined (READLINE) + { "force_fignore", &force_fignore, (shopt_set_func_t *)NULL }, +#endif + { "globasciiranges", &glob_asciirange, (shopt_set_func_t *)NULL }, + { "globstar", &glob_star, (shopt_set_func_t *)NULL }, + { "gnu_errfmt", &gnu_error_format, (shopt_set_func_t *)NULL }, +#if defined (HISTORY) + { "histappend", &force_append_history, (shopt_set_func_t *)NULL }, +#endif +#if defined (READLINE) + { "histreedit", &history_reediting, (shopt_set_func_t *)NULL }, + { "histverify", &hist_verify, (shopt_set_func_t *)NULL }, + { "hostcomplete", &perform_hostname_completion, shopt_enable_hostname_completion }, +#endif + { "huponexit", &hup_on_exit, (shopt_set_func_t *)NULL }, + { "inherit_errexit", &inherit_errexit, (shopt_set_func_t *)NULL }, + { "interactive_comments", &interactive_comments, set_shellopts_after_change }, + { "lastpipe", &lastpipe_opt, (shopt_set_func_t *)NULL }, +#if defined (HISTORY) + { "lithist", &literal_history, (shopt_set_func_t *)NULL }, +#endif + { "login_shell", &shopt_login_shell, set_login_shell }, + { "mailwarn", &mail_warning, (shopt_set_func_t *)NULL }, +#if defined (READLINE) + { "no_empty_cmd_completion", &no_empty_command_completion, (shopt_set_func_t *)NULL }, +#endif + { "nocaseglob", &glob_ignore_case, (shopt_set_func_t *)NULL }, + { "nocasematch", &match_ignore_case, (shopt_set_func_t *)NULL }, + { "nullglob", &allow_null_glob_expansion, (shopt_set_func_t *)NULL }, +#if defined (PROGRAMMABLE_COMPLETION) + { "progcomp", &prog_completion_enabled, (shopt_set_func_t *)NULL }, +#endif + { "promptvars", &promptvars, (shopt_set_func_t *)NULL }, +#if defined (RESTRICTED_SHELL) + { "restricted_shell", &restricted_shell, set_restricted_shell }, +#endif + { "shift_verbose", &print_shift_error, (shopt_set_func_t *)NULL }, + { "sourcepath", &source_uses_path, (shopt_set_func_t *)NULL }, + { "xpg_echo", &xpg_echo, (shopt_set_func_t *)NULL }, + { (char *)0, (int *)0, (shopt_set_func_t *)NULL } +}; + +#define N_SHOPT_OPTIONS (sizeof (shopt_vars) / sizeof (shopt_vars[0])) + +#define GET_SHOPT_OPTION_VALUE(i) (*shopt_vars[i].value) + +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)); +static void print_shopt __P((char *, int, int)); +static int list_shopts __P((WORD_LIST *, int)); +static int list_some_shopts __P((int, int)); +static int list_shopt_o_options __P((WORD_LIST *, int)); +static int list_some_o_options __P((int, int)); +static int set_shopt_o_options __P((int, WORD_LIST *, int)); + +#define SFLAG 0x01 +#define UFLAG 0x02 +#define QFLAG 0x04 +#define OFLAG 0x08 +#define PFLAG 0x10 + +int +shopt_builtin (list) + WORD_LIST *list; +{ + int opt, flags, rval; + + flags = 0; + reset_internal_getopt (); + while ((opt = internal_getopt (list, "psuoq")) != -1) + { + switch (opt) + { + case 's': + flags |= SFLAG; + break; + case 'u': + flags |= UFLAG; + break; + case 'q': + flags |= QFLAG; + break; + case 'o': + flags |= OFLAG; + break; + case 'p': + flags |= PFLAG; + break; + CASE_HELPOPT; + default: + builtin_usage (); + return (EX_USAGE); + } + } + list = loptend; + + if ((flags & (SFLAG|UFLAG)) == (SFLAG|UFLAG)) + { + builtin_error (_("cannot set and unset shell options simultaneously")); + return (EXECUTION_FAILURE); + } + + rval = EXECUTION_SUCCESS; + if ((flags & OFLAG) && ((flags & (SFLAG|UFLAG)) == 0)) /* shopt -o */ + rval = list_shopt_o_options (list, flags); + else if (list && (flags & OFLAG)) /* shopt -so args */ + rval = set_shopt_o_options ((flags & SFLAG) ? FLAG_ON : FLAG_OFF, list, flags & QFLAG); + else if (flags & OFLAG) /* shopt -so */ + rval = list_some_o_options ((flags & SFLAG) ? 1 : 0, flags); + else if (list && (flags & (SFLAG|UFLAG))) /* shopt -su args */ + rval = toggle_shopts ((flags & SFLAG) ? SETOPT : UNSETOPT, list, flags & QFLAG); + else if ((flags & (SFLAG|UFLAG)) == 0) /* shopt [args] */ + rval = list_shopts (list, flags); + else /* shopt -su */ + rval = list_some_shopts ((flags & SFLAG) ? SETOPT : UNSETOPT, flags); + return (rval); +} + +/* Reset the options managed by `shopt' to the values they would have at + shell startup. Variables from shopt_vars. */ +void +reset_shopt_options () +{ + autocd = cdable_vars = cdspelling = 0; + check_hashed_filenames = CHECKHASH_DEFAULT; + check_window_size = CHECKWINSIZE_DEFAULT; + allow_null_glob_expansion = glob_dot_filenames = 0; + no_exit_on_failed_exec = 0; + expand_aliases = 0; + extended_quote = 1; + fail_glob_expansion = 0; + glob_asciirange = GLOBASCII_DEFAULT; + glob_star = 0; + gnu_error_format = 0; + hup_on_exit = 0; + inherit_errexit = 0; + interactive_comments = 1; + lastpipe_opt = 0; + mail_warning = 0; + glob_ignore_case = match_ignore_case = 0; + print_shift_error = 0; + source_uses_path = promptvars = 1; + +#if defined (JOB_CONTROL) + check_jobs_at_exit = 0; +#endif + +#if defined (EXTENDED_GLOB) + extended_glob = EXTGLOB_DEFAULT; +#endif + +#if defined (HISTORY) + literal_history = 0; + force_append_history = 0; + command_oriented_history = 1; +#endif + +#if defined (READLINE) + complete_fullquote = 1; + force_fignore = 1; + hist_verify = history_reediting = 0; + perform_hostname_completion = 1; +# if DIRCOMPLETE_EXPAND_DEFAULT + dircomplete_expand = 1; +# else + dircomplete_expand = 0; +#endif + dircomplete_spelling = 0; + no_empty_command_completion = 0; +#endif + +#if defined (PROGRAMMABLE_COMPLETION) + prog_completion_enabled = 1; +#endif + +#if defined (DEFAULT_ECHO_TO_XPG) || defined (STRICT_POSIX) + xpg_echo = 1; +#else + xpg_echo = 0; +#endif /* DEFAULT_ECHO_TO_XPG */ + + shopt_login_shell = login_shell; +} + +static int +find_shopt (name) + char *name; +{ + int i; + + for (i = 0; shopt_vars[i].name; i++) + if (STREQ (name, shopt_vars[i].name)) + return i; + return -1; +} + +static void +shopt_error (s) + char *s; +{ + builtin_error (_("%s: invalid shell option name"), s); +} + +static int +toggle_shopts (mode, list, quiet) + int mode; + WORD_LIST *list; + int quiet; +{ + WORD_LIST *l; + int ind, rval; + SHELL_VAR *v; + + for (l = list, rval = EXECUTION_SUCCESS; l; l = l->next) + { + ind = find_shopt (l->word->word); + if (ind < 0) + { + shopt_error (l->word->word); + rval = EXECUTION_FAILURE; + } + else + { + *shopt_vars[ind].value = mode; /* 1 for set, 0 for unset */ + if (shopt_vars[ind].set_func) + (*shopt_vars[ind].set_func) (shopt_vars[ind].name, mode); + } + } + + /* Don't set $BASHOPTS here if it hasn't already been initialized */ + if (v = find_variable ("BASHOPTS")) + set_bashopts (); + return (rval); +} + +static void +print_shopt (name, val, flags) + char *name; + int val, flags; +{ + if (flags & PFLAG) + printf ("shopt %s %s\n", val ? "-s" : "-u", name); + else + printf (OPTFMT, name, val ? on : off); +} + +/* List the values of all or any of the `shopt' options. Returns 0 if + all were listed or all variables queried were on; 1 otherwise. */ +static int +list_shopts (list, flags) + WORD_LIST *list; + int flags; +{ + WORD_LIST *l; + int i, val, rval; + + if (list == 0) + { + for (i = 0; shopt_vars[i].name; i++) + { + val = *shopt_vars[i].value; + if ((flags & QFLAG) == 0) + print_shopt (shopt_vars[i].name, val, flags); + } + return (sh_chkwrite (EXECUTION_SUCCESS)); + } + + for (l = list, rval = EXECUTION_SUCCESS; l; l = l->next) + { + i = find_shopt (l->word->word); + if (i < 0) + { + shopt_error (l->word->word); + rval = EXECUTION_FAILURE; + continue; + } + val = *shopt_vars[i].value; + if (val == 0) + rval = EXECUTION_FAILURE; + if ((flags & QFLAG) == 0) + print_shopt (l->word->word, val, flags); + } + + return (sh_chkwrite (rval)); +} + +static int +list_some_shopts (mode, flags) + int mode, flags; +{ + int val, i; + + for (i = 0; shopt_vars[i].name; i++) + { + val = *shopt_vars[i].value; + if (((flags & QFLAG) == 0) && mode == val) + print_shopt (shopt_vars[i].name, val, flags); + } + return (sh_chkwrite (EXECUTION_SUCCESS)); +} + +static int +list_shopt_o_options (list, flags) + WORD_LIST *list; + int flags; +{ + WORD_LIST *l; + int val, rval; + + if (list == 0) + { + if ((flags & QFLAG) == 0) + list_minus_o_opts (-1, (flags & PFLAG)); + return (sh_chkwrite (EXECUTION_SUCCESS)); + } + + for (l = list, rval = EXECUTION_SUCCESS; l; l = l->next) + { + val = minus_o_option_value (l->word->word); + if (val == -1) + { + sh_invalidoptname (l->word->word); + rval = EXECUTION_FAILURE; + continue; + } + if (val == 0) + rval = EXECUTION_FAILURE; + if ((flags & QFLAG) == 0) + { + if (flags & PFLAG) + printf ("set %co %s\n", val ? '-' : '+', l->word->word); + else + printf (OPTFMT, l->word->word, val ? on : off); + } + } + return (sh_chkwrite (rval)); +} + +static int +list_some_o_options (mode, flags) + int mode, flags; +{ + if ((flags & QFLAG) == 0) + list_minus_o_opts (mode, (flags & PFLAG)); + return (sh_chkwrite (EXECUTION_SUCCESS)); +} + +static int +set_shopt_o_options (mode, list, quiet) + int mode; + WORD_LIST *list; + int quiet; +{ + WORD_LIST *l; + int rval; + + for (l = list, rval = EXECUTION_SUCCESS; l; l = l->next) + { + if (set_minus_o_option (mode, l->word->word) == EXECUTION_FAILURE) + rval = EXECUTION_FAILURE; + } + set_shellopts (); + return rval; +} + +/* If we set or unset interactive_comments with shopt, make sure the + change is reflected in $SHELLOPTS. */ +static int +set_shellopts_after_change (option_name, mode) + char *option_name; + int mode; +{ + set_shellopts (); + return (0); +} + +static int +shopt_set_debug_mode (option_name, mode) + char *option_name; + int mode; +{ +#if defined (DEBUGGER) + error_trace_mode = function_trace_mode = debugging_mode; + set_shellopts (); +#endif + return (0); +} + +static int +shopt_enable_hostname_completion (option_name, mode) + char *option_name; + int mode; +{ + return (enable_hostname_completion (mode)); +} + +static int +set_compatibility_level (option_name, mode) + char *option_name; + int mode; +{ + int ind; + + /* If we're setting something, redo some of the work we did above in + toggle_shopt(). Unset everything and reset the appropriate option + based on OPTION_NAME. */ + if (mode) + { + shopt_compat31 = shopt_compat32 = 0; + shopt_compat40 = shopt_compat41 = shopt_compat42 = shopt_compat43 = 0; + ind = find_shopt (option_name); + *shopt_vars[ind].value = mode; + } + + /* Then set shell_compatibility_level based on what remains */ + if (shopt_compat31) + shell_compatibility_level = 31; + else if (shopt_compat32) + shell_compatibility_level = 32; + else if (shopt_compat40) + shell_compatibility_level = 40; + else if (shopt_compat41) + shell_compatibility_level = 41; + else if (shopt_compat42) + shell_compatibility_level = 42; + else if (shopt_compat43) + shell_compatibility_level = 43; + else + shell_compatibility_level = DEFAULT_COMPAT_LEVEL; + + return 0; +} + +/* Set and unset the various compatibility options from the value of + shell_compatibility_level; used by sv_shcompat */ +void +set_compatibility_opts () +{ + shopt_compat31 = shopt_compat32 = 0; + shopt_compat40 = shopt_compat41 = shopt_compat42 = shopt_compat43 = 0; + switch (shell_compatibility_level) + { + case DEFAULT_COMPAT_LEVEL: + break; + case 43: + shopt_compat43 = 1; break; + case 42: + shopt_compat42 = 1; break; + case 41: + shopt_compat41 = 1; break; + case 40: + shopt_compat40 = 1; break; + case 32: + shopt_compat32 = 1; break; + case 31: + shopt_compat31 = 1; break; + } +} + +#if defined (READLINE) +static int +shopt_set_complete_direxpand (option_name, mode) + char *option_name; + int mode; +{ + set_directory_hook (); + return 0; +} +#endif + +#if defined (RESTRICTED_SHELL) +/* Don't allow the value of restricted_shell to be modified. */ + +static int +set_restricted_shell (option_name, mode) + char *option_name; + int mode; +{ + static int save_restricted = -1; + + if (save_restricted == -1) + save_restricted = shell_is_restricted (shell_name); + + restricted_shell = save_restricted; + return (0); +} +#endif /* RESTRICTED_SHELL */ + +/* Not static so shell.c can call it to initialize shopt_login_shell */ +int +set_login_shell (option_name, mode) + char *option_name; + int mode; +{ + shopt_login_shell = login_shell != 0; + return (0); +} + +char ** +get_shopt_options () +{ + char **ret; + int n, i; + + n = sizeof (shopt_vars) / sizeof (shopt_vars[0]); + ret = strvec_create (n + 1); + for (i = 0; shopt_vars[i].name; i++) + ret[i] = savestring (shopt_vars[i].name); + ret[i] = (char *)NULL; + return ret; +} + +/* + * External interface for other parts of the shell. NAME is a string option; + * MODE is 0 if we want to unset an option; 1 if we want to set an option. + * REUSABLE is 1 if we want to print output in a form that may be reused. + */ +int +shopt_setopt (name, mode) + char *name; + int mode; +{ + WORD_LIST *wl; + int r; + + wl = add_string_to_list (name, (WORD_LIST *)NULL); + r = toggle_shopts (mode, wl, 0); + dispose_words (wl); + return r; +} + +int +shopt_listopt (name, reusable) + char *name; + int reusable; +{ + int i; + + if (name == 0) + return (list_shopts ((WORD_LIST *)NULL, reusable ? PFLAG : 0)); + + i = find_shopt (name); + if (i < 0) + { + shopt_error (name); + return (EXECUTION_FAILURE); + } + + print_shopt (name, *shopt_vars[i].value, reusable ? PFLAG : 0); + return (sh_chkwrite (EXECUTION_SUCCESS)); +} + +void +set_bashopts () +{ + char *value; + char tflag[N_SHOPT_OPTIONS]; + int vsize, i, vptr, *ip, exported; + SHELL_VAR *v; + + for (vsize = i = 0; shopt_vars[i].name; i++) + { + tflag[i] = 0; + if (GET_SHOPT_OPTION_VALUE (i)) + { + vsize += strlen (shopt_vars[i].name) + 1; + tflag[i] = 1; + } + } + + value = (char *)xmalloc (vsize + 1); + + for (i = vptr = 0; shopt_vars[i].name; i++) + { + if (tflag[i]) + { + strcpy (value + vptr, shopt_vars[i].name); + vptr += strlen (shopt_vars[i].name); + value[vptr++] = ':'; + } + } + + if (vptr) + vptr--; /* cut off trailing colon */ + value[vptr] = '\0'; + + v = find_variable ("BASHOPTS"); + + /* Turn off the read-only attribute so we can bind the new value, and + note whether or not the variable was exported. */ + if (v) + { + VUNSETATTR (v, att_readonly); + exported = exported_p (v); + } + else + exported = 0; + + v = bind_variable ("BASHOPTS", value, 0); + + /* Turn the read-only attribute back on, and turn off the export attribute + if it was set implicitly by mark_modified_vars and SHELLOPTS was not + exported before we bound the new value. */ + VSETATTR (v, att_readonly); + if (mark_modified_vars && exported == 0 && exported_p (v)) + VUNSETATTR (v, att_exported); + + free (value); +} + +void +parse_bashopts (value) + char *value; +{ + char *vname; + int vptr, ind; + + vptr = 0; + while (vname = extract_colon_unit (value, &vptr)) + { + ind = find_shopt (vname); + if (ind >= 0) + { + *shopt_vars[ind].value = 1; + if (shopt_vars[ind].set_func) + (*shopt_vars[ind].set_func) (shopt_vars[ind].name, 1); + } + free (vname); + } +} + +void +initialize_bashopts (no_bashopts) + int no_bashopts; +{ + char *temp; + SHELL_VAR *var; + + if (no_bashopts == 0) + { + var = find_variable ("BASHOPTS"); + /* set up any shell options we may have inherited. */ + if (var && imported_p (var)) + { + temp = (array_p (var) || assoc_p (var)) ? (char *)NULL : savestring (value_cell (var)); + if (temp) + { + parse_bashopts (temp); + free (temp); + } + } + } + + /* Set up the $BASHOPTS variable. */ + set_bashopts (); +} diff --git a/builtins/source.def b/builtins/source.def new file mode 100644 index 0000000..b3df1f9 --- /dev/null +++ b/builtins/source.def @@ -0,0 +1,201 @@ +This file is source.def, from which is created source.c. +It implements the builtins "." and "source" in Bash. + +Copyright (C) 1987-2015 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 3 of the License, 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. If not, see . + +$PRODUCES source.c + +$BUILTIN source +$FUNCTION source_builtin +$SHORT_DOC source filename [arguments] +Execute commands from a file in the current shell. + +Read and execute commands from FILENAME in the current shell. The +entries in $PATH are used to find the directory containing FILENAME. +If any ARGUMENTS are supplied, they become the positional parameters +when FILENAME is executed. + +Exit Status: +Returns the status of the last command executed in FILENAME; fails if +FILENAME cannot be read. +$END + +$BUILTIN . +$DOCNAME dot +$FUNCTION source_builtin +$SHORT_DOC . filename [arguments] +Execute commands from a file in the current shell. + +Read and execute commands from FILENAME in the current shell. The +entries in $PATH are used to find the directory containing FILENAME. +If any ARGUMENTS are supplied, they become the positional parameters +when FILENAME is executed. + +Exit Status: +Returns the status of the last command executed in FILENAME; fails if +FILENAME cannot be read. +$END + +#include + +#include "../bashtypes.h" +#include "posixstat.h" +#include "filecntl.h" +#if ! defined(_MINIX) && defined (HAVE_SYS_FILE_H) +# include +#endif +#include + +#if defined (HAVE_UNISTD_H) +# include +#endif + +#include "../bashansi.h" +#include "../bashintl.h" + +#include "../shell.h" +#include "../flags.h" +#include "../findcmd.h" +#include "common.h" +#include "bashgetopt.h" +#include "../trap.h" + +#if !defined (errno) +extern int errno; +#endif /* !errno */ + +extern int posixly_correct; +extern int last_command_exit_value; +extern int executing_command_builtin; + +static void maybe_pop_dollar_vars __P((void)); + +/* If non-zero, `.' uses $PATH to look up the script to be sourced. */ +int source_uses_path = 1; + +/* If non-zero, `.' looks in the current directory if the filename argument + is not found in the $PATH. */ +int source_searches_cwd = 1; + +/* If this . script is supplied arguments, we save the dollar vars and + replace them with the script arguments for the duration of the script's + execution. If the script does not change the dollar vars, we restore + what we saved. If the dollar vars are changed in the script, and we are + not executing a shell function, we leave the new values alone and free + the saved values. */ +static void +maybe_pop_dollar_vars () +{ + if (variable_context == 0 && (dollar_vars_changed () & ARGS_SETBLTIN)) + dispose_saved_dollar_vars (); + else + pop_dollar_vars (); + if (debugging_mode) + pop_args (); /* restore BASH_ARGC and BASH_ARGV */ + set_dollar_vars_unchanged (); + invalidate_cached_quoted_dollar_at (); /* just invalidate to be safe */ +} + +/* Read and execute commands from the file passed as argument. Guess what. + This cannot be done in a subshell, since things like variable assignments + take place in there. So, I open the file, place it into a large string, + close the file, and then execute the string. */ +int +source_builtin (list) + WORD_LIST *list; +{ + int result; + char *filename, *debug_trap, *x; + + if (no_options (list)) + return (EX_USAGE); + list = loptend; + + if (list == 0) + { + builtin_error (_("filename argument required")); + builtin_usage (); + return (EX_USAGE); + } + +#if defined (RESTRICTED_SHELL) + if (restricted && strchr (list->word->word, '/')) + { + sh_restricted (list->word->word); + return (EXECUTION_FAILURE); + } +#endif + + filename = (char *)NULL; + /* XXX -- should this be absolute_pathname? */ + if (posixly_correct && strchr (list->word->word, '/')) + filename = savestring (list->word->word); + else if (absolute_pathname (list->word->word)) + filename = savestring (list->word->word); + else if (source_uses_path) + filename = find_path_file (list->word->word); + if (filename == 0) + { + if (source_searches_cwd == 0) + { + x = printable_filename (list->word->word, 0); + builtin_error (_("%s: file not found"), x); + if (x != list->word->word) + free (x); + if (posixly_correct && interactive_shell == 0 && executing_command_builtin == 0) + { + last_command_exit_value = 1; + jump_to_top_level (EXITPROG); + } + return (EXECUTION_FAILURE); + } + else + filename = savestring (list->word->word); + } + + begin_unwind_frame ("source"); + add_unwind_protect ((Function *)xfree, filename); + + if (list->next) + { + push_dollar_vars (); + add_unwind_protect ((Function *)maybe_pop_dollar_vars, (char *)NULL); + remember_args (list->next, 1); + if (debugging_mode) + push_args (list->next); /* Update BASH_ARGV and BASH_ARGC */ + } + set_dollar_vars_unchanged (); + + /* Don't inherit the DEBUG trap unless function_trace_mode (overloaded) + is set. XXX - should sourced files inherit the RETURN trap? Functions + don't. */ + debug_trap = TRAP_STRING (DEBUG_TRAP); + if (debug_trap && function_trace_mode == 0) + { + debug_trap = savestring (debug_trap); + add_unwind_protect (xfree, debug_trap); + add_unwind_protect (maybe_set_debug_trap, debug_trap); + restore_default_signal (DEBUG_TRAP); + } + + result = source_file (filename, (list && list->next)); + + run_unwind_frame ("source"); + + return (result); +} diff --git a/builtins/suspend.def b/builtins/suspend.def new file mode 100644 index 0000000..db28fee --- /dev/null +++ b/builtins/suspend.def @@ -0,0 +1,128 @@ +This file is suspend.def, from which is created suspend.c. +It implements the builtin "suspend" in Bash. + +Copyright (C) 1987-2015 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 3 of the License, 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. If not, see . + +$PRODUCES suspend.c + +$BUILTIN suspend +$DEPENDS_ON JOB_CONTROL +$FUNCTION suspend_builtin +$SHORT_DOC suspend [-f] +Suspend shell execution. + +Suspend the execution of this shell until it receives a SIGCONT signal. +Unless forced, login shells cannot be suspended. + +Options: + -f force the suspend, even if the shell is a login shell + +Exit Status: +Returns success unless job control is not enabled or an error occurs. +$END + +#include + +#if defined (JOB_CONTROL) +#if defined (HAVE_UNISTD_H) +# ifdef _MINIX +# include +# endif +# include +#endif + +#include "../bashtypes.h" +#include +#include "../bashintl.h" +#include "../shell.h" +#include "../jobs.h" +#include "common.h" +#include "bashgetopt.h" + +static sighandler suspend_continue __P((int)); + +static SigHandler *old_cont; +#if 0 +static SigHandler *old_stop; +#endif + +/* Continue handler. */ +static sighandler +suspend_continue (sig) + int sig; +{ + set_signal_handler (SIGCONT, old_cont); +#if 0 + set_signal_handler (SIGSTOP, old_stop); +#endif + SIGRETURN (0); +} + +/* Suspending the shell. If -f is the arg, then do the suspend + no matter what. Otherwise, complain if a login shell. */ +int +suspend_builtin (list) + WORD_LIST *list; +{ + int opt, force; + + reset_internal_getopt (); + force = 0; + while ((opt = internal_getopt (list, "f")) != -1) + switch (opt) + { + case 'f': + force++; + break; + CASE_HELPOPT; + default: + builtin_usage (); + return (EX_USAGE); + } + + list = loptend; + + if (job_control == 0) + { + sh_nojobs (_("cannot suspend")); + return (EXECUTION_FAILURE); + } + + if (force == 0) + { + no_args (list); + + if (login_shell) + { + builtin_error (_("cannot suspend a login shell")); + return (EXECUTION_FAILURE); + } + } + + /* XXX - should we put ourselves back into the original pgrp now? If so, + call end_job_control() here and do the right thing in suspend_continue + (that is, call restart_job_control()). */ + old_cont = (SigHandler *)set_signal_handler (SIGCONT, suspend_continue); +#if 0 + old_stop = (SigHandler *)set_signal_handler (SIGSTOP, SIG_DFL); +#endif + killpg (shell_pgrp, SIGSTOP); + return (EXECUTION_SUCCESS); +} + +#endif /* JOB_CONTROL */ diff --git a/builtins/test.def b/builtins/test.def new file mode 100644 index 0000000..d6c89bf --- /dev/null +++ b/builtins/test.def @@ -0,0 +1,160 @@ +This file is test.def, from which is created test.c. +It implements the builtin "test" in Bash. + +Copyright (C) 1987-2015 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 3 of the License, 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. If not, see . + +$PRODUCES test.c + +$BUILTIN test +$FUNCTION test_builtin +$SHORT_DOC test [expr] +Evaluate conditional expression. + +Exits with a status of 0 (true) or 1 (false) depending on +the evaluation of EXPR. Expressions may be unary or binary. Unary +expressions are often used to examine the status of a file. There +are string operators and numeric comparison operators as well. + +The behavior of test depends on the number of arguments. Read the +bash manual page for the complete specification. + +File operators: + + -a FILE True if file exists. + -b FILE True if file is block special. + -c FILE True if file is character special. + -d FILE True if file is a directory. + -e FILE True if file exists. + -f FILE True if file exists and is a regular file. + -g FILE True if file is set-group-id. + -h FILE True if file is a symbolic link. + -L FILE True if file is a symbolic link. + -k FILE True if file has its `sticky' bit set. + -p FILE True if file is a named pipe. + -r FILE True if file is readable by you. + -s FILE True if file exists and is not empty. + -S FILE True if file is a socket. + -t FD True if FD is opened on a terminal. + -u FILE True if the file is set-user-id. + -w FILE True if the file is writable by you. + -x FILE True if the file is executable by you. + -O FILE True if the file is effectively owned by you. + -G FILE True if the file is effectively owned by your group. + -N FILE True if the file has been modified since it was last read. + + FILE1 -nt FILE2 True if file1 is newer than file2 (according to + modification date). + + FILE1 -ot FILE2 True if file1 is older than file2. + + FILE1 -ef FILE2 True if file1 is a hard link to file2. + +String operators: + + -z STRING True if string is empty. + + -n STRING + STRING True if string is not empty. + + STRING1 = STRING2 + True if the strings are equal. + STRING1 != STRING2 + True if the strings are not equal. + STRING1 < STRING2 + True if STRING1 sorts before STRING2 lexicographically. + STRING1 > STRING2 + True if STRING1 sorts after STRING2 lexicographically. + +Other operators: + + -o OPTION True if the shell option OPTION is enabled. + -v VAR True if the shell variable VAR is set. + -R VAR True if the shell variable VAR is set and is a name + reference. + ! EXPR True if expr is false. + EXPR1 -a EXPR2 True if both expr1 AND expr2 are true. + EXPR1 -o EXPR2 True if either expr1 OR expr2 is true. + + arg1 OP arg2 Arithmetic tests. OP is one of -eq, -ne, + -lt, -le, -gt, or -ge. + +Arithmetic binary operators return true if ARG1 is equal, not-equal, +less-than, less-than-or-equal, greater-than, or greater-than-or-equal +than ARG2. + +Exit Status: +Returns success if EXPR evaluates to true; fails if EXPR evaluates to +false or an invalid argument is given. +$END + +$BUILTIN [ +$DOCNAME test_bracket +$FUNCTION test_builtin +$SHORT_DOC [ arg... ] +Evaluate conditional expression. + +This is a synonym for the "test" builtin, but the last argument must +be a literal `]', to match the opening `['. +$END + +#include + +#if defined (HAVE_UNISTD_H) +# ifdef _MINIX +# include +# endif +# include +#endif + +#include "../bashansi.h" +#include "../bashintl.h" + +#include "../shell.h" +#include "../test.h" +#include "common.h" + +extern char *this_command_name; + +/* TEST/[ builtin. */ +int +test_builtin (list) + WORD_LIST *list; +{ + char **argv; + int argc, result; + + /* We let Matthew Bradburn and Kevin Braunsdorf's code do the + actual test command. So turn the list of args into an array + of strings, since that is what their code wants. */ + if (list == 0) + { + if (this_command_name[0] == '[' && !this_command_name[1]) + { + builtin_error (_("missing `]'")); + return (EX_BADUSAGE); + } + + return (EXECUTION_FAILURE); + } + + argv = make_builtin_argv (list, &argc); + result = test_command (argc, argv); + free ((char *)argv); + + return (result); +} diff --git a/builtins/times.def b/builtins/times.def new file mode 100644 index 0000000..f31f433 --- /dev/null +++ b/builtins/times.def @@ -0,0 +1,119 @@ +This file is times.def, from which is created times.c. +It implements the builtin "times" in Bash. + +Copyright (C) 1987-2009 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 3 of the License, 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. If not, see . + +$PRODUCES times.c + +$BUILTIN times +$FUNCTION times_builtin +$SHORT_DOC times +Display process times. + +Prints the accumulated user and system times for the shell and all of its +child processes. + +Exit Status: +Always succeeds. +$END + +#include + +#if defined (HAVE_UNISTD_H) +# ifdef _MINIX +# include +# endif +# include +#endif + +#include +#include "../bashtypes.h" +#include "../shell.h" + +#include + +#if defined (HAVE_SYS_TIMES_H) +# include +#endif /* HAVE_SYS_TIMES_H */ + +#if defined (HAVE_SYS_RESOURCE_H) && !defined (RLIMTYPE) +# include +#endif + +#include "common.h" + +/* Print the totals for system and user time used. */ +int +times_builtin (list) + WORD_LIST *list; +{ +#if defined (HAVE_GETRUSAGE) && defined (HAVE_TIMEVAL) && defined (RUSAGE_SELF) + struct rusage self, kids; + + USE_VAR(list); + + if (no_options (list)) + return (EX_USAGE); + + getrusage (RUSAGE_SELF, &self); + getrusage (RUSAGE_CHILDREN, &kids); /* terminated child processes */ + + print_timeval (stdout, &self.ru_utime); + putchar (' '); + print_timeval (stdout, &self.ru_stime); + putchar ('\n'); + print_timeval (stdout, &kids.ru_utime); + putchar (' '); + print_timeval (stdout, &kids.ru_stime); + putchar ('\n'); + +#else +# if defined (HAVE_TIMES) + /* This uses the POSIX.1/XPG5 times(2) interface, which fills in a + `struct tms' with values of type clock_t. */ + struct tms t; + + USE_VAR(list); + + if (no_options (list)) + return (EX_USAGE); + + times (&t); + + print_clock_t (stdout, t.tms_utime); + putchar (' '); + print_clock_t (stdout, t.tms_stime); + putchar ('\n'); + print_clock_t (stdout, t.tms_cutime); + putchar (' '); + print_clock_t (stdout, t.tms_cstime); + putchar ('\n'); + +# else /* !HAVE_TIMES */ + + USE_VAR(list); + + if (no_options (list)) + return (EX_USAGE); + printf ("0.00 0.00\n0.00 0.00\n"); + +# endif /* HAVE_TIMES */ +#endif /* !HAVE_TIMES */ + + return (sh_chkwrite (EXECUTION_SUCCESS)); +} diff --git a/builtins/trap.def b/builtins/trap.def new file mode 100644 index 0000000..57d9b52 --- /dev/null +++ b/builtins/trap.def @@ -0,0 +1,305 @@ +This file is trap.def, from which is created trap.c. +It implements the builtin "trap" in Bash. + +Copyright (C) 1987-2015 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 3 of the License, 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. If not, see . + +$PRODUCES trap.c + +$BUILTIN trap +$FUNCTION trap_builtin +$SHORT_DOC trap [-lp] [[arg] signal_spec ...] +Trap signals and other events. + +Defines and activates handlers to be run when the shell receives signals +or other conditions. + +ARG is a command to be read and executed when the shell receives the +signal(s) SIGNAL_SPEC. If ARG is absent (and a single SIGNAL_SPEC +is supplied) or `-', each specified signal is reset to its original +value. If ARG is the null string each SIGNAL_SPEC is ignored by the +shell and by the commands it invokes. + +If a SIGNAL_SPEC is EXIT (0) ARG is executed on exit from the shell. If +a SIGNAL_SPEC is DEBUG, ARG is executed before every simple command. If +a SIGNAL_SPEC is RETURN, ARG is executed each time a shell function or a +script run by the . or source builtins finishes executing. A SIGNAL_SPEC +of ERR means to execute ARG each time a command's failure would cause the +shell to exit when the -e option is enabled. + +If no arguments are supplied, trap prints the list of commands associated +with each signal. + +Options: + -l print a list of signal names and their corresponding numbers + -p display the trap commands associated with each SIGNAL_SPEC + +Each SIGNAL_SPEC is either a signal name in or a signal number. +Signal names are case insensitive and the SIG prefix is optional. A +signal may be sent to the shell with "kill -signal $$". + +Exit Status: +Returns success unless a SIGSPEC is invalid or an invalid option is given. +$END + +#include + +#if defined (HAVE_UNISTD_H) +# ifdef _MINIX +# include +# endif +# include +#endif + +#include "../bashtypes.h" +#include +#include +#include "../bashansi.h" + +#include "../shell.h" +#include "../trap.h" +#include "common.h" +#include "bashgetopt.h" + +static void showtrap __P((int)); +static int display_traps __P((WORD_LIST *)); + +/* The trap command: + + trap + trap + trap -l + trap -p [sigspec ...] + trap [--] + + Set things up so that ARG is executed when SIGNAL(s) N is received. + If ARG is the empty string, then ignore the SIGNAL(s). If there is + no ARG, then set the trap for SIGNAL(s) to its original value. Just + plain "trap" means to print out the list of commands associated with + each signal number. Single arg of "-l" means list the signal names. */ + +/* Possible operations to perform on the list of signals.*/ +#define SET 0 /* Set this signal to first_arg. */ +#define REVERT 1 /* Revert to this signals original value. */ +#define IGNORE 2 /* Ignore this signal. */ + +extern int posixly_correct, subshell_environment; + +int +trap_builtin (list) + WORD_LIST *list; +{ + int list_signal_names, display, result, opt; + + list_signal_names = display = 0; + result = EXECUTION_SUCCESS; + + reset_internal_getopt (); + while ((opt = internal_getopt (list, "lp")) != -1) + { + switch (opt) + { + case 'l': + list_signal_names++; + break; + case 'p': + display++; + break; + CASE_HELPOPT; + default: + builtin_usage (); + return (EX_USAGE); + } + } + list = loptend; + + opt = DSIG_NOCASE|DSIG_SIGPREFIX; /* flags for decode_signal */ + + if (list_signal_names) + return (sh_chkwrite (display_signal_list ((WORD_LIST *)NULL, 1))); + else if (display || list == 0) + { + initialize_terminating_signals (); + get_all_original_signals (); + return (sh_chkwrite (display_traps (list))); + } + else + { + char *first_arg; + int operation, sig, first_signal; + + operation = SET; + first_arg = list->word->word; + first_signal = first_arg && *first_arg && all_digits (first_arg) && signal_object_p (first_arg, opt); + + /* Backwards compatibility. XXX - question about whether or not we + should throw an error if an all-digit argument doesn't correspond + to a valid signal number (e.g., if it's `50' on a system with only + 32 signals). */ + if (first_signal) + operation = REVERT; + /* When in posix mode, the historical behavior of looking for a + missing first argument is disabled. To revert to the original + signal handling disposition, use `-' as the first argument. */ + else if (posixly_correct == 0 && first_arg && *first_arg && + (*first_arg != '-' || first_arg[1]) && + signal_object_p (first_arg, opt) && list->next == 0) + operation = REVERT; + else + { + list = list->next; + if (list == 0) + { + builtin_usage (); + return (EX_USAGE); + } + else if (*first_arg == '\0') + operation = IGNORE; + else if (first_arg[0] == '-' && !first_arg[1]) + operation = REVERT; + } + + /* If we're in a command substitution, we haven't freed the trap strings + (though we reset the signal handlers). If we're setting a trap to + handle a signal here, free the rest of the trap strings since they + don't apply any more. */ + if (subshell_environment & SUBSHELL_RESETTRAP) + { + free_trap_strings (); + subshell_environment &= ~SUBSHELL_RESETTRAP; + } + + while (list) + { + sig = decode_signal (list->word->word, opt); + + if (sig == NO_SIG) + { + sh_invalidsig (list->word->word); + result = EXECUTION_FAILURE; + } + else + { + switch (operation) + { + case SET: + set_signal (sig, first_arg); + break; + + case REVERT: + restore_default_signal (sig); + + /* Signals that the shell treats specially need special + handling. */ + switch (sig) + { + case SIGINT: + /* XXX - should we do this if original disposition + was SIG_IGN? */ + if (interactive) + set_signal_handler (SIGINT, sigint_sighandler); + else + set_signal_handler (SIGINT, termsig_sighandler); + break; + + case SIGQUIT: + /* Always ignore SIGQUIT. */ + set_signal_handler (SIGQUIT, SIG_IGN); + break; + case SIGTERM: +#if defined (JOB_CONTROL) + case SIGTTIN: + case SIGTTOU: + case SIGTSTP: +#endif /* JOB_CONTROL */ + if (interactive) + set_signal_handler (sig, SIG_IGN); + break; + } + break; + + case IGNORE: + ignore_signal (sig); + break; + } + } + list = list->next; + } + } + + return (result); +} + +static void +showtrap (i) + int i; +{ + char *t, *p, *sn; + + p = trap_list[i]; + if (p == (char *)DEFAULT_SIG && signal_is_hard_ignored (i) == 0) + return; + else if (signal_is_hard_ignored (i)) + t = (char *)NULL; + else + t = (p == (char *)IGNORE_SIG) ? (char *)NULL : sh_single_quote (p); + + sn = signal_name (i); + /* Make sure that signals whose names are unknown (for whatever reason) + are printed as signal numbers. */ + if (STREQN (sn, "SIGJUNK", 7) || STREQN (sn, "unknown", 7)) + printf ("trap -- %s %d\n", t ? t : "''", i); + else if (posixly_correct) + { + if (STREQN (sn, "SIG", 3)) + printf ("trap -- %s %s\n", t ? t : "''", sn+3); + else + printf ("trap -- %s %s\n", t ? t : "''", sn); + } + else + printf ("trap -- %s %s\n", t ? t : "''", sn); + + FREE (t); +} + +static int +display_traps (list) + WORD_LIST *list; +{ + int result, i; + + if (list == 0) + { + for (i = 0; i < BASH_NSIG; i++) + showtrap (i); + return (EXECUTION_SUCCESS); + } + + for (result = EXECUTION_SUCCESS; list; list = list->next) + { + i = decode_signal (list->word->word, DSIG_NOCASE|DSIG_SIGPREFIX); + if (i == NO_SIG) + { + sh_invalidsig (list->word->word); + result = EXECUTION_FAILURE; + } + else + showtrap (i); + } + + return (result); +} diff --git a/builtins/type.def b/builtins/type.def new file mode 100644 index 0000000..3187add --- /dev/null +++ b/builtins/type.def @@ -0,0 +1,421 @@ +This file is type.def, from which is created type.c. +It implements the builtin "type" in Bash. + +Copyright (C) 1987-2015 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 3 of the License, 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. If not, see . + +$PRODUCES type.c + +$BUILTIN type +$FUNCTION type_builtin +$SHORT_DOC type [-afptP] name [name ...] +Display information about command type. + +For each NAME, indicate how it would be interpreted if used as a +command name. + +Options: + -a display all locations containing an executable named NAME; + includes aliases, builtins, and functions, if and only if + the `-p' option is not also used + -f suppress shell function lookup + -P force a PATH search for each NAME, even if it is an alias, + builtin, or function, and returns the name of the disk file + that would be executed + -p returns either the name of the disk file that would be executed, + or nothing if `type -t NAME' would not return `file' + -t output a single word which is one of `alias', `keyword', + `function', `builtin', `file' or `', if NAME is an alias, + shell reserved word, shell function, shell builtin, disk file, + or not found, respectively + +Arguments: + NAME Command name to be interpreted. + +Exit Status: +Returns success if all of the NAMEs are found; fails if any are not found. +$END + +#include + +#include "../bashtypes.h" +#include "posixstat.h" + +#if defined (HAVE_UNISTD_H) +# include +#endif + +#include +#include "../bashansi.h" +#include "../bashintl.h" + +#include "../shell.h" +#include "../findcmd.h" +#include "../hashcmd.h" + +#if defined (ALIAS) +#include "../alias.h" +#endif /* ALIAS */ + +#include "common.h" +#include "bashgetopt.h" + +extern int find_reserved_word __P((char *)); + +extern char *this_command_name; +extern int expand_aliases, posixly_correct; + +/* For each word in LIST, find out what the shell is going to do with + it as a simple command. i.e., which file would this shell use to + execve, or if it is a builtin command, or an alias. Possible flag + arguments: + -t Returns the "type" of the object, one of + `alias', `keyword', `function', `builtin', + or `file'. + + -p Returns the pathname of the file if -type is + a file. + + -a Returns all occurrences of words, whether they + be a filename in the path, alias, function, + or builtin. + + -f Suppress shell function lookup, like `command'. + + -P Force a path search even in the presence of other + definitions. + + Order of evaluation: + alias + keyword + function + builtin + file + */ + +int +type_builtin (list) + WORD_LIST *list; +{ + int dflags, any_failed, opt; + WORD_LIST *this; + + if (list == 0) + return (EXECUTION_SUCCESS); + + dflags = CDESC_SHORTDESC; /* default */ + any_failed = 0; + + /* Handle the obsolescent `-type', `-path', and `-all' by prescanning + the arguments and converting those options to the form that + internal_getopt recognizes. Converts `--type', `--path', and `--all' + also. THIS SHOULD REALLY GO AWAY. */ + for (this = list; this && this->word->word[0] == '-'; this = this->next) + { + char *flag = &(this->word->word[1]); + + if (STREQ (flag, "type") || STREQ (flag, "-type")) + { + this->word->word[1] = 't'; + this->word->word[2] = '\0'; + } + else if (STREQ (flag, "path") || STREQ (flag, "-path")) + { + this->word->word[1] = 'p'; + this->word->word[2] = '\0'; + } + else if (STREQ (flag, "all") || STREQ (flag, "-all")) + { + this->word->word[1] = 'a'; + this->word->word[2] = '\0'; + } + } + + reset_internal_getopt (); + while ((opt = internal_getopt (list, "afptP")) != -1) + { + switch (opt) + { + case 'a': + dflags |= CDESC_ALL; + break; + case 'f': + dflags |= CDESC_NOFUNCS; + break; + case 'p': + dflags |= CDESC_PATH_ONLY; + dflags &= ~(CDESC_TYPE|CDESC_SHORTDESC); + break; + case 't': + dflags |= CDESC_TYPE; + dflags &= ~(CDESC_PATH_ONLY|CDESC_SHORTDESC); + break; + case 'P': /* shorthand for type -ap */ + dflags |= (CDESC_PATH_ONLY|CDESC_FORCE_PATH); + dflags &= ~(CDESC_TYPE|CDESC_SHORTDESC); + break; + CASE_HELPOPT; + default: + builtin_usage (); + return (EX_USAGE); + } + } + list = loptend; + + while (list) + { + int found; + + found = describe_command (list->word->word, dflags); + + if (!found && (dflags & (CDESC_PATH_ONLY|CDESC_TYPE)) == 0) + sh_notfound (list->word->word); + + any_failed += found == 0; + list = list->next; + } + + opt = (any_failed == 0) ? EXECUTION_SUCCESS : EXECUTION_FAILURE; + return (sh_chkwrite (opt)); +} + +/* + * Describe COMMAND as required by the type and command builtins. + * + * Behavior is controlled by DFLAGS. Flag values are + * CDESC_ALL print all descriptions of a command + * CDESC_SHORTDESC print the description for type and command -V + * CDESC_REUSABLE print in a format that may be reused as input + * CDESC_TYPE print the type for type -t + * CDESC_PATH_ONLY print the path for type -p + * CDESC_FORCE_PATH force a path search for type -P + * CDESC_NOFUNCS skip function lookup for type -f + * CDESC_ABSPATH convert to absolute path, no ./ prefix + * CDESC_STDPATH command -p standard path list + * + * CDESC_ALL says whether or not to look for all occurrences of COMMAND, or + * return after finding it once. + */ +int +describe_command (command, dflags) + char *command; + int dflags; +{ + int found, i, found_file, f, all; + char *full_path, *x, *pathlist; + SHELL_VAR *func; +#if defined (ALIAS) + alias_t *alias; +#endif + + all = (dflags & CDESC_ALL) != 0; + found = found_file = 0; + full_path = (char *)NULL; + +#if defined (ALIAS) + /* Command is an alias? */ + if (((dflags & CDESC_FORCE_PATH) == 0) && expand_aliases && (alias = find_alias (command))) + { + if (dflags & CDESC_TYPE) + puts ("alias"); + else if (dflags & CDESC_SHORTDESC) + printf (_("%s is aliased to `%s'\n"), command, alias->value); + else if (dflags & CDESC_REUSABLE) + { + x = sh_single_quote (alias->value); + printf ("alias %s=%s\n", command, x); + free (x); + } + + found = 1; + + if (all == 0) + return (1); + } +#endif /* ALIAS */ + + /* Command is a shell reserved word? */ + if (((dflags & CDESC_FORCE_PATH) == 0) && (i = find_reserved_word (command)) >= 0) + { + if (dflags & CDESC_TYPE) + puts ("keyword"); + else if (dflags & CDESC_SHORTDESC) + printf (_("%s is a shell keyword\n"), command); + else if (dflags & CDESC_REUSABLE) + printf ("%s\n", command); + + found = 1; + + if (all == 0) + return (1); + } + + /* Command is a function? */ + if (((dflags & (CDESC_FORCE_PATH|CDESC_NOFUNCS)) == 0) && (func = find_function (command))) + { + if (dflags & CDESC_TYPE) + puts ("function"); + else if (dflags & CDESC_SHORTDESC) + { + char *result; + + printf (_("%s is a function\n"), command); + + /* We're blowing away THE_PRINTED_COMMAND here... */ + + result = named_function_string (command, function_cell (func), FUNC_MULTILINE|FUNC_EXTERNAL); + printf ("%s\n", result); + } + else if (dflags & CDESC_REUSABLE) + printf ("%s\n", command); + + found = 1; + + if (all == 0) + return (1); + } + + /* Command is a builtin? */ + if (((dflags & CDESC_FORCE_PATH) == 0) && find_shell_builtin (command)) + { + if (dflags & CDESC_TYPE) + puts ("builtin"); + else if (dflags & CDESC_SHORTDESC) + { + if (posixly_correct && find_special_builtin (command) != 0) + printf (_("%s is a special shell builtin\n"), command); + else + printf (_("%s is a shell builtin\n"), command); + } + else if (dflags & CDESC_REUSABLE) + printf ("%s\n", command); + + found = 1; + + if (all == 0) + return (1); + } + + /* Command is a disk file? */ + /* If the command name given is already an absolute command, just + check to see if it is executable. */ + if (absolute_program (command)) + { + f = file_status (command); + if (f & FS_EXECABLE) + { + if (dflags & CDESC_TYPE) + puts ("file"); + else if (dflags & CDESC_SHORTDESC) + printf (_("%s is %s\n"), command, command); + else if (dflags & (CDESC_REUSABLE|CDESC_PATH_ONLY)) + printf ("%s\n", command); + + /* There's no use looking in the hash table or in $PATH, + because they're not consulted when an absolute program + name is supplied. */ + return (1); + } + } + + /* If the user isn't doing "-a", then we might care about + whether the file is present in our hash table. */ + if (all == 0 || (dflags & CDESC_FORCE_PATH)) + { + if (full_path = phash_search (command)) + { + if (dflags & CDESC_TYPE) + puts ("file"); + else if (dflags & CDESC_SHORTDESC) + printf (_("%s is hashed (%s)\n"), command, full_path); + else if (dflags & (CDESC_REUSABLE|CDESC_PATH_ONLY)) + printf ("%s\n", full_path); + + free (full_path); + return (1); + } + } + + /* Now search through $PATH. */ + while (1) + { + if (dflags & CDESC_STDPATH) /* command -p, all cannot be non-zero */ + { + pathlist = conf_standard_path (); + full_path = find_in_path (command, pathlist, FS_EXEC_PREFERRED|FS_NODIRS); + free (pathlist); + /* Will only go through this once, since all == 0 if STDPATH set */ + } + else if (all == 0) + full_path = find_user_command (command); + else + full_path = user_command_matches (command, FS_EXEC_ONLY, found_file); /* XXX - should that be FS_EXEC_PREFERRED? */ + + if (full_path == 0) + break; + + /* If we found the command as itself by looking through $PATH, it + probably doesn't exist. Check whether or not the command is an + executable file. If it's not, don't report a match. This is + the default posix mode behavior */ + if (STREQ (full_path, command) || posixly_correct) + { + f = file_status (full_path); + if ((f & FS_EXECABLE) == 0) + { + free (full_path); + full_path = (char *)NULL; + if (all == 0) + break; + } + else if (ABSPATH (full_path)) + ; /* placeholder; don't need to do anything yet */ + else if (dflags & (CDESC_REUSABLE|CDESC_PATH_ONLY|CDESC_SHORTDESC)) + { + f = MP_DOCWD | ((dflags & CDESC_ABSPATH) ? MP_RMDOT : 0); + x = sh_makepath ((char *)NULL, full_path, f); + free (full_path); + full_path = x; + } + } + /* If we require a full path and don't have one, make one */ + else if ((dflags & CDESC_ABSPATH) && ABSPATH (full_path) == 0) + { + x = sh_makepath ((char *)NULL, full_path, MP_DOCWD|MP_RMDOT); + free (full_path); + full_path = x; + } + + found_file++; + found = 1; + + if (dflags & CDESC_TYPE) + puts ("file"); + else if (dflags & CDESC_SHORTDESC) + printf (_("%s is %s\n"), command, full_path); + else if (dflags & (CDESC_REUSABLE|CDESC_PATH_ONLY)) + printf ("%s\n", full_path); + + free (full_path); + full_path = (char *)NULL; + + if (all == 0) + break; + } + + return (found); +} diff --git a/builtins/ulimit.def b/builtins/ulimit.def new file mode 100644 index 0000000..62def4f --- /dev/null +++ b/builtins/ulimit.def @@ -0,0 +1,798 @@ +This file is ulimit.def, from which is created ulimit.c. +It implements the builtin "ulimit" in Bash. + +Copyright (C) 1987-2015 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 3 of the License, 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. If not, see . + +$PRODUCES ulimit.c + +$BUILTIN ulimit +$FUNCTION ulimit_builtin +$DEPENDS_ON !_MINIX +$SHORT_DOC ulimit [-SHabcdefiklmnpqrstuvxPT] [limit] +Modify shell resource limits. + +Provides control over the resources available to the shell and processes +it creates, on systems that allow such control. + +Options: + -S use the `soft' resource limit + -H use the `hard' resource limit + -a all current limits are reported + -b the socket buffer size + -c the maximum size of core files created + -d the maximum size of a process's data segment + -e the maximum scheduling priority (`nice') + -f the maximum size of files written by the shell and its children + -i the maximum number of pending signals + -k the maximum number of kqueues allocated for this process + -l the maximum size a process may lock into memory + -m the maximum resident set size + -n the maximum number of open file descriptors + -p the pipe buffer size + -q the maximum number of bytes in POSIX message queues + -r the maximum real-time scheduling priority + -s the maximum stack size + -t the maximum amount of cpu time in seconds + -u the maximum number of user processes + -v the size of virtual memory + -x the maximum number of file locks + -P the maximum number of pseudoterminals + -T the maximum number of threads + +Not all options are available on all platforms. + +If LIMIT is given, it is the new value of the specified resource; the +special LIMIT values `soft', `hard', and `unlimited' stand for the +current soft limit, the current hard limit, and no limit, respectively. +Otherwise, the current value of the specified resource is printed. If +no option is given, then -f is assumed. + +Values are in 1024-byte increments, except for -t, which is in seconds, +-p, which is in increments of 512 bytes, and -u, which is an unscaled +number of processes. + +Exit Status: +Returns success unless an invalid option is supplied or an error occurs. +$END + +#if !defined (_MINIX) + +#include + +#include "../bashtypes.h" +#if defined (HAVE_SYS_PARAM_H) +# include +#endif + +#if defined (HAVE_UNISTD_H) +# include +#endif + +#include +#include + +#include "../bashintl.h" + +#include "../shell.h" +#include "common.h" +#include "bashgetopt.h" +#include "pipesize.h" + +#if !defined (errno) +extern int errno; +#endif + +/* For some reason, HPUX chose to make these definitions visible only if + _KERNEL is defined, so we define _KERNEL before including + and #undef it afterward. */ +#if defined (HAVE_RESOURCE) +# include +# if defined (HPUX) && defined (RLIMIT_NEEDS_KERNEL) +# define _KERNEL +# endif +# include +# if defined (HPUX) && defined (RLIMIT_NEEDS_KERNEL) +# undef _KERNEL +# endif +#elif defined (HAVE_SYS_TIMES_H) +# include +#endif + +#if defined (HAVE_LIMITS_H) +# include +#endif + +/* Check for the most basic symbols. If they aren't present, this + system's isn't very useful to us. */ +#if !defined (RLIMIT_FSIZE) || !defined (HAVE_GETRLIMIT) +# undef HAVE_RESOURCE +#endif + +#if !defined (HAVE_RESOURCE) && defined (HAVE_ULIMIT_H) +# include +#endif + +#if !defined (RLIMTYPE) +# define RLIMTYPE long +# define string_to_rlimtype(s) strtol(s, (char **)NULL, 10) +# define print_rlimtype(num, nl) printf ("%ld%s", num, nl ? "\n" : "") +#endif + +/* Alternate names */ + +/* Some systems use RLIMIT_NOFILE, others use RLIMIT_OFILE */ +#if defined (HAVE_RESOURCE) && defined (RLIMIT_OFILE) && !defined (RLIMIT_NOFILE) +# define RLIMIT_NOFILE RLIMIT_OFILE +#endif /* HAVE_RESOURCE && RLIMIT_OFILE && !RLIMIT_NOFILE */ + +#if defined (HAVE_RESOURCE) && defined (RLIMIT_POSIXLOCKS) && !defined (RLIMIT_LOCKS) +# define RLIMIT_LOCKS RLIMIT_POSIXLOCKS +#endif /* HAVE_RESOURCE && RLIMIT_POSIXLOCKS && !RLIMIT_LOCKS */ + +/* Some systems have these, some do not. */ +#ifdef RLIMIT_FSIZE +# define RLIMIT_FILESIZE RLIMIT_FSIZE +#else +# define RLIMIT_FILESIZE 256 +#endif + +#define RLIMIT_PIPESIZE 257 + +#ifdef RLIMIT_NOFILE +# define RLIMIT_OPENFILES RLIMIT_NOFILE +#else +# define RLIMIT_OPENFILES 258 +#endif + +#ifdef RLIMIT_VMEM +# define RLIMIT_VIRTMEM RLIMIT_VMEM +# define RLIMIT_VMBLKSZ 1024 +#else +# ifdef RLIMIT_AS +# define RLIMIT_VIRTMEM RLIMIT_AS +# define RLIMIT_VMBLKSZ 1024 +# else +# define RLIMIT_VIRTMEM 259 +# define RLIMIT_VMBLKSZ 1 +# endif +#endif + +#ifdef RLIMIT_NPROC +# define RLIMIT_MAXUPROC RLIMIT_NPROC +#else +# define RLIMIT_MAXUPROC 260 +#endif + +#if !defined (RLIMIT_PTHREAD) && defined (RLIMIT_NTHR) +# define RLIMIT_PTHREAD RLIMIT_NTHR +#endif + +#if !defined (RLIM_INFINITY) +# define RLIM_INFINITY 0x7fffffff +#endif + +#if !defined (RLIM_SAVED_CUR) +# define RLIM_SAVED_CUR RLIM_INFINITY +#endif + +#if !defined (RLIM_SAVED_MAX) +# define RLIM_SAVED_MAX RLIM_INFINITY +#endif + +#define LIMIT_HARD 0x01 +#define LIMIT_SOFT 0x02 + +/* "Blocks" are defined as 512 bytes when in Posix mode and 1024 bytes + otherwise. */ +#define POSIXBLK -2 + +#define BLOCKSIZE(x) (((x) == POSIXBLK) ? (posixly_correct ? 512 : 1024) : (x)) + +extern int posixly_correct; + +static int _findlim __P((int)); + +static int ulimit_internal __P((int, char *, int, int)); + +static int get_limit __P((int, RLIMTYPE *, RLIMTYPE *)); +static int set_limit __P((int, RLIMTYPE, int)); + +static void printone __P((int, RLIMTYPE, int)); +static void print_all_limits __P((int)); + +static int set_all_limits __P((int, RLIMTYPE)); + +static int filesize __P((RLIMTYPE *)); +static int pipesize __P((RLIMTYPE *)); +static int getmaxuprc __P((RLIMTYPE *)); +static int getmaxvm __P((RLIMTYPE *, RLIMTYPE *)); + +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. */ + const char * const description; /* Descriptive string to output. */ + const char * const units; /* scale */ +} RESOURCE_LIMITS; + +static RESOURCE_LIMITS limits[] = { +#ifdef RLIMIT_NPTS + { 'P', RLIMIT_NPTS, 1, "number of pseudoterminals", (char *)NULL }, +#endif +#ifdef RLIMIT_PTHREAD + { 'T', RLIMIT_PTHREAD, 1, "number of threads", (char *)NULL }, +#endif +#ifdef RLIMIT_SBSIZE + { 'b', RLIMIT_SBSIZE, 1, "socket buffer size", "bytes" }, +#endif +#ifdef RLIMIT_CORE + { 'c', RLIMIT_CORE, POSIXBLK, "core file size", "blocks" }, +#endif +#ifdef RLIMIT_DATA + { 'd', RLIMIT_DATA, 1024, "data seg size", "kbytes" }, +#endif +#ifdef RLIMIT_NICE + { 'e', RLIMIT_NICE, 1, "scheduling priority", (char *)NULL }, +#endif + { 'f', RLIMIT_FILESIZE, POSIXBLK, "file size", "blocks" }, +#ifdef RLIMIT_SIGPENDING + { 'i', RLIMIT_SIGPENDING, 1, "pending signals", (char *)NULL }, +#endif +#ifdef RLIMIT_KQUEUES + { 'k', RLIMIT_KQUEUES, 1, "max kqueues", (char *)NULL }, +#endif +#ifdef RLIMIT_MEMLOCK + { 'l', RLIMIT_MEMLOCK, 1024, "max locked memory", "kbytes" }, +#endif +#ifdef RLIMIT_RSS + { 'm', RLIMIT_RSS, 1024, "max memory size", "kbytes" }, +#endif /* RLIMIT_RSS */ + { 'n', RLIMIT_OPENFILES, 1, "open files", (char *)NULL}, + { 'p', RLIMIT_PIPESIZE, 512, "pipe size", "512 bytes" }, +#ifdef RLIMIT_MSGQUEUE + { 'q', RLIMIT_MSGQUEUE, 1, "POSIX message queues", "bytes" }, +#endif +#ifdef RLIMIT_RTPRIO + { 'r', RLIMIT_RTPRIO, 1, "real-time priority", (char *)NULL }, +#endif +#ifdef RLIMIT_STACK + { 's', RLIMIT_STACK, 1024, "stack size", "kbytes" }, +#endif +#ifdef RLIMIT_CPU + { 't', RLIMIT_CPU, 1, "cpu time", "seconds" }, +#endif /* RLIMIT_CPU */ + { 'u', RLIMIT_MAXUPROC, 1, "max user processes", (char *)NULL }, +#if defined (HAVE_RESOURCE) + { 'v', RLIMIT_VIRTMEM, RLIMIT_VMBLKSZ, "virtual memory", "kbytes" }, +#endif +#ifdef RLIMIT_SWAP + { 'w', RLIMIT_SWAP, 1024, "swap size", "kbytes" }, +#endif +#ifdef RLIMIT_LOCKS + { 'x', RLIMIT_LOCKS, 1, "file locks", (char *)NULL }, +#endif + { -1, -1, -1, (char *)NULL, (char *)NULL } +}; +#define NCMDS (sizeof(limits) / sizeof(limits[0])) + +typedef struct _cmd { + int cmd; + char *arg; +} ULCMD; + +static ULCMD *cmdlist; +static int ncmd; +static int cmdlistsz; + +#if !defined (HAVE_RESOURCE) && !defined (HAVE_ULIMIT) +long +ulimit (cmd, newlim) + int cmd; + long newlim; +{ + errno = EINVAL; + return -1; +} +#endif /* !HAVE_RESOURCE && !HAVE_ULIMIT */ + +static int +_findlim (opt) + int opt; +{ + register int i; + + for (i = 0; limits[i].option > 0; i++) + if (limits[i].option == opt) + return i; + return -1; +} + +static char optstring[4 + 2 * NCMDS]; + +/* Report or set limits associated with certain per-process resources. + See the help documentation in builtins.c for a full description. */ +int +ulimit_builtin (list) + register WORD_LIST *list; +{ + register char *s; + int c, limind, mode, opt, all_limits; + + mode = 0; + + all_limits = 0; + + /* Idea stolen from pdksh -- build option string the first time called. */ + if (optstring[0] == 0) + { + s = optstring; + *s++ = 'a'; *s++ = 'S'; *s++ = 'H'; + for (c = 0; limits[c].option > 0; c++) + { + *s++ = limits[c].option; + *s++ = ';'; + } + *s = '\0'; + } + + /* Initialize the command list. */ + if (cmdlistsz == 0) + cmdlist = (ULCMD *)xmalloc ((cmdlistsz = 16) * sizeof (ULCMD)); + ncmd = 0; + + reset_internal_getopt (); + while ((opt = internal_getopt (list, optstring)) != -1) + { + switch (opt) + { + case 'a': + all_limits++; + break; + + /* -S and -H are modifiers, not real options. */ + case 'S': + mode |= LIMIT_SOFT; + break; + + case 'H': + mode |= LIMIT_HARD; + break; + + CASE_HELPOPT; + case '?': + builtin_usage (); + return (EX_USAGE); + + default: + if (ncmd >= cmdlistsz) + cmdlist = (ULCMD *)xrealloc (cmdlist, (cmdlistsz *= 2) * sizeof (ULCMD)); + cmdlist[ncmd].cmd = opt; + cmdlist[ncmd++].arg = list_optarg; + break; + } + } + list = loptend; + + if (all_limits) + { +#ifdef NOTYET + if (list) /* setting */ + { + if (STREQ (list->word->word, "unlimited") == 0) + { + builtin_error (_("%s: invalid limit argument"), list->word->word); + return (EXECUTION_FAILURE); + } + return (set_all_limits (mode == 0 ? LIMIT_SOFT|LIMIT_HARD : mode, RLIM_INFINITY)); + } +#endif + print_all_limits (mode == 0 ? LIMIT_SOFT : mode); + return (sh_chkwrite (EXECUTION_SUCCESS)); + } + + /* default is `ulimit -f' */ + if (ncmd == 0) + { + cmdlist[ncmd].cmd = 'f'; + /* `ulimit something' is same as `ulimit -f something' */ + cmdlist[ncmd++].arg = list ? list->word->word : (char *)NULL; + if (list) + list = list->next; + } + + /* verify each command in the list. */ + for (c = 0; c < ncmd; c++) + { + limind = _findlim (cmdlist[c].cmd); + if (limind == -1) + { + builtin_error (_("`%c': bad command"), cmdlist[c].cmd); + return (EX_USAGE); + } + } + + for (c = 0; c < ncmd; c++) + if (ulimit_internal (cmdlist[c].cmd, cmdlist[c].arg, mode, ncmd > 1) == EXECUTION_FAILURE) + return (EXECUTION_FAILURE); + + return (EXECUTION_SUCCESS); +} + +static int +ulimit_internal (cmd, cmdarg, mode, multiple) + int cmd; + char *cmdarg; + int mode, multiple; +{ + int opt, limind, setting; + int block_factor; + RLIMTYPE soft_limit, hard_limit, real_limit, limit; + + setting = cmdarg != 0; + limind = _findlim (cmd); + if (mode == 0) + mode = setting ? (LIMIT_HARD|LIMIT_SOFT) : LIMIT_SOFT; + opt = get_limit (limind, &soft_limit, &hard_limit); + if (opt < 0) + { + builtin_error (_("%s: cannot get limit: %s"), limits[limind].description, + strerror (errno)); + return (EXECUTION_FAILURE); + } + + if (setting == 0) /* print the value of the specified limit */ + { + printone (limind, (mode & LIMIT_SOFT) ? soft_limit : hard_limit, multiple); + return (EXECUTION_SUCCESS); + } + + /* Setting the limit. */ + if (STREQ (cmdarg, "hard")) + real_limit = hard_limit; + else if (STREQ (cmdarg, "soft")) + real_limit = soft_limit; + else if (STREQ (cmdarg, "unlimited")) + real_limit = RLIM_INFINITY; + else if (all_digits (cmdarg)) + { + limit = string_to_rlimtype (cmdarg); + block_factor = BLOCKSIZE(limits[limind].block_factor); + real_limit = limit * block_factor; + + if ((real_limit / block_factor) != limit) + { + sh_erange (cmdarg, _("limit")); + return (EXECUTION_FAILURE); + } + } + else + { + sh_invalidnum (cmdarg); + return (EXECUTION_FAILURE); + } + + if (set_limit (limind, real_limit, mode) < 0) + { + builtin_error (_("%s: cannot modify limit: %s"), limits[limind].description, + strerror (errno)); + return (EXECUTION_FAILURE); + } + + return (EXECUTION_SUCCESS); +} + +static int +get_limit (ind, softlim, hardlim) + int ind; + RLIMTYPE *softlim, *hardlim; +{ + RLIMTYPE value; +#if defined (HAVE_RESOURCE) + struct rlimit limit; +#endif + + if (limits[ind].parameter >= 256) + { + switch (limits[ind].parameter) + { + case RLIMIT_FILESIZE: + if (filesize (&value) < 0) + return -1; + break; + case RLIMIT_PIPESIZE: + if (pipesize (&value) < 0) + return -1; + break; + case RLIMIT_OPENFILES: + value = (RLIMTYPE)getdtablesize (); + break; + case RLIMIT_VIRTMEM: + return (getmaxvm (softlim, hardlim)); + case RLIMIT_MAXUPROC: + if (getmaxuprc (&value) < 0) + return -1; + break; + default: + errno = EINVAL; + return -1; + } + *softlim = *hardlim = value; + return (0); + } + else + { +#if defined (HAVE_RESOURCE) + if (getrlimit (limits[ind].parameter, &limit) < 0) + return -1; + *softlim = limit.rlim_cur; + *hardlim = limit.rlim_max; +# if defined (HPUX9) + if (limits[ind].parameter == RLIMIT_FILESIZE) + { + *softlim *= 512; + *hardlim *= 512; /* Ugh. */ + } + else +# endif /* HPUX9 */ + return 0; +#else + errno = EINVAL; + return -1; +#endif + } +} + +static int +set_limit (ind, newlim, mode) + int ind; + RLIMTYPE newlim; + int mode; +{ +#if defined (HAVE_RESOURCE) + struct rlimit limit; + RLIMTYPE val; +#endif + + if (limits[ind].parameter >= 256) + switch (limits[ind].parameter) + { + case RLIMIT_FILESIZE: +#if !defined (HAVE_RESOURCE) + return (ulimit (2, newlim / 512L)); +#else + errno = EINVAL; + return -1; +#endif + + case RLIMIT_OPENFILES: +#if defined (HAVE_SETDTABLESIZE) +# if defined (__CYGWIN__) + /* Grrr... Cygwin declares setdtablesize as void. */ + setdtablesize (newlim); + return 0; +# else + return (setdtablesize (newlim)); +# endif +#endif + case RLIMIT_PIPESIZE: + case RLIMIT_VIRTMEM: + case RLIMIT_MAXUPROC: + default: + errno = EINVAL; + return -1; + } + else + { +#if defined (HAVE_RESOURCE) + if (getrlimit (limits[ind].parameter, &limit) < 0) + return -1; +# if defined (HPUX9) + if (limits[ind].parameter == RLIMIT_FILESIZE) + newlim /= 512; /* Ugh. */ +# endif /* HPUX9 */ + val = (current_user.euid != 0 && newlim == RLIM_INFINITY && + (mode & LIMIT_HARD) == 0 && /* XXX -- test */ + (limit.rlim_cur <= limit.rlim_max)) + ? limit.rlim_max : newlim; + if (mode & LIMIT_SOFT) + limit.rlim_cur = val; + if (mode & LIMIT_HARD) + limit.rlim_max = val; + + return (setrlimit (limits[ind].parameter, &limit)); +#else + errno = EINVAL; + return -1; +#endif + } +} + +static int +getmaxvm (softlim, hardlim) + RLIMTYPE *softlim, *hardlim; +{ +#if defined (HAVE_RESOURCE) + struct rlimit datalim, stacklim; + + if (getrlimit (RLIMIT_DATA, &datalim) < 0) + return -1; + + if (getrlimit (RLIMIT_STACK, &stacklim) < 0) + return -1; + + /* Protect against overflow. */ + *softlim = (datalim.rlim_cur / 1024L) + (stacklim.rlim_cur / 1024L); + *hardlim = (datalim.rlim_max / 1024L) + (stacklim.rlim_max / 1024L); + return 0; +#else + errno = EINVAL; + return -1; +#endif /* HAVE_RESOURCE */ +} + +static int +filesize(valuep) + RLIMTYPE *valuep; +{ +#if !defined (HAVE_RESOURCE) + long result; + if ((result = ulimit (1, 0L)) < 0) + return -1; + else + *valuep = (RLIMTYPE) result * 512; + return 0; +#else + errno = EINVAL; + return -1; +#endif +} + +static int +pipesize (valuep) + RLIMTYPE *valuep; +{ +#if defined (PIPE_BUF) + /* This is defined on Posix systems. */ + *valuep = (RLIMTYPE) PIPE_BUF; + return 0; +#else +# if defined (_POSIX_PIPE_BUF) + *valuep = (RLIMTYPE) _POSIX_PIPE_BUF; + return 0; +# else +# if defined (PIPESIZE) + /* This is defined by running a program from the Makefile. */ + *valuep = (RLIMTYPE) PIPESIZE; + return 0; +# else + errno = EINVAL; + return -1; +# endif /* PIPESIZE */ +# endif /* _POSIX_PIPE_BUF */ +#endif /* PIPE_BUF */ +} + +static int +getmaxuprc (valuep) + RLIMTYPE *valuep; +{ + long maxchild; + + maxchild = getmaxchild (); + if (maxchild < 0) + { + errno = EINVAL; + return -1; + } + else + { + *valuep = (RLIMTYPE) maxchild; + return 0; + } +} + +static void +print_all_limits (mode) + int mode; +{ + register int i; + RLIMTYPE softlim, hardlim; + + if (mode == 0) + mode |= LIMIT_SOFT; + + for (i = 0; limits[i].option > 0; i++) + { + if (get_limit (i, &softlim, &hardlim) == 0) + printone (i, (mode & LIMIT_SOFT) ? softlim : hardlim, 1); + else if (errno != EINVAL) + builtin_error ("%s: cannot get limit: %s", limits[i].description, + strerror (errno)); + } +} + +static void +printone (limind, curlim, pdesc) + int limind; + RLIMTYPE curlim; + int pdesc; +{ + char unitstr[64]; + int factor; + + factor = BLOCKSIZE(limits[limind].block_factor); + if (pdesc) + { + if (limits[limind].units) + sprintf (unitstr, "(%s, -%c) ", limits[limind].units, limits[limind].option); + else + sprintf (unitstr, "(-%c) ", limits[limind].option); + + printf ("%-20s %16s", limits[limind].description, unitstr); + } + if (curlim == RLIM_INFINITY) + puts ("unlimited"); + else if (curlim == RLIM_SAVED_MAX) + puts ("hard"); + else if (curlim == RLIM_SAVED_CUR) + puts ("soft"); + else + print_rlimtype ((curlim / factor), 1); +} + +/* Set all limits to NEWLIM. NEWLIM currently must be RLIM_INFINITY, which + causes all limits to be set as high as possible depending on mode (like + csh `unlimit'). Returns -1 if NEWLIM is invalid, 0 if all limits + were set successfully, and 1 if at least one limit could not be set. + + To raise all soft limits to their corresponding hard limits, use + ulimit -S -a unlimited + To attempt to raise all hard limits to infinity (superuser-only), use + ulimit -H -a unlimited + To attempt to raise all soft and hard limits to infinity, use + ulimit -a unlimited +*/ + +static int +set_all_limits (mode, newlim) + int mode; + RLIMTYPE newlim; +{ + register int i; + int retval = 0; + + if (newlim != RLIM_INFINITY) + { + errno = EINVAL; + return -1; + } + + if (mode == 0) + mode = LIMIT_SOFT|LIMIT_HARD; + + for (retval = i = 0; limits[i].option > 0; i++) + if (set_limit (i, newlim, mode) < 0) + { + builtin_error (_("%s: cannot modify limit: %s"), limits[i].description, + strerror (errno)); + retval = 1; + } + return retval; +} + +#endif /* !_MINIX */ diff --git a/builtins/umask.def b/builtins/umask.def new file mode 100644 index 0000000..d3138d4 --- /dev/null +++ b/builtins/umask.def @@ -0,0 +1,317 @@ +This file is umask.def, from which is created umask.c. +It implements the builtin "umask" in Bash. + +Copyright (C) 1987-2015 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 3 of the License, 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. If not, see . + +$PRODUCES umask.c + +$BUILTIN umask +$FUNCTION umask_builtin +$SHORT_DOC umask [-p] [-S] [mode] +Display or set file mode mask. + +Sets the user file-creation mask to MODE. If MODE is omitted, prints +the current value of the mask. + +If MODE begins with a digit, it is interpreted as an octal number; +otherwise it is a symbolic mode string like that accepted by chmod(1). + +Options: + -p if MODE is omitted, output in a form that may be reused as input + -S makes the output symbolic; otherwise an octal number is output + +Exit Status: +Returns success unless MODE is invalid or an invalid option is given. +$END + +#include + +#include "../bashtypes.h" +#include "filecntl.h" +#if ! defined(_MINIX) && defined (HAVE_SYS_FILE_H) +# include +#endif + +#if defined (HAVE_UNISTD_H) +#include +#endif + +#include +#include + +#include "../bashintl.h" + +#include "../shell.h" +#include "posixstat.h" +#include "common.h" +#include "bashgetopt.h" + +/* **************************************************************** */ +/* */ +/* UMASK Builtin and Helpers */ +/* */ +/* **************************************************************** */ + +static void print_symbolic_umask __P((mode_t)); +static int symbolic_umask __P((WORD_LIST *)); + +/* Set or display the mask used by the system when creating files. Flag + of -S means display the umask in a symbolic mode. */ +int +umask_builtin (list) + WORD_LIST *list; +{ + int print_symbolically, opt, umask_value, pflag; + mode_t umask_arg; + + print_symbolically = pflag = 0; + reset_internal_getopt (); + while ((opt = internal_getopt (list, "Sp")) != -1) + { + switch (opt) + { + case 'S': + print_symbolically++; + break; + case 'p': + pflag++; + break; + CASE_HELPOPT; + default: + builtin_usage (); + return (EX_USAGE); + } + } + + list = loptend; + + if (list) + { + if (DIGIT (*list->word->word)) + { + umask_value = read_octal (list->word->word); + + /* Note that other shells just let you set the umask to zero + by specifying a number out of range. This is a problem + with those shells. We don't change the umask if the input + is lousy. */ + if (umask_value == -1) + { + sh_erange (list->word->word, _("octal number")); + return (EXECUTION_FAILURE); + } + } + else + { + umask_value = symbolic_umask (list); + if (umask_value == -1) + return (EXECUTION_FAILURE); + } + umask_arg = (mode_t)umask_value; + umask (umask_arg); + if (print_symbolically) + print_symbolic_umask (umask_arg); + } + else /* Display the UMASK for this user. */ + { + umask_arg = umask (022); + umask (umask_arg); + + if (pflag) + printf ("umask%s ", (print_symbolically ? " -S" : "")); + if (print_symbolically) + print_symbolic_umask (umask_arg); + else + printf ("%04lo\n", (unsigned long)umask_arg); + } + + return (sh_chkwrite (EXECUTION_SUCCESS)); +} + +/* Print the umask in a symbolic form. In the output, a letter is + printed if the corresponding bit is clear in the umask. */ +static void +#if defined (__STDC__) +print_symbolic_umask (mode_t um) +#else +print_symbolic_umask (um) + mode_t um; +#endif +{ + char ubits[4], gbits[4], obits[4]; /* u=rwx,g=rwx,o=rwx */ + int i; + + i = 0; + if ((um & S_IRUSR) == 0) + ubits[i++] = 'r'; + if ((um & S_IWUSR) == 0) + ubits[i++] = 'w'; + if ((um & S_IXUSR) == 0) + ubits[i++] = 'x'; + ubits[i] = '\0'; + + i = 0; + if ((um & S_IRGRP) == 0) + gbits[i++] = 'r'; + if ((um & S_IWGRP) == 0) + gbits[i++] = 'w'; + if ((um & S_IXGRP) == 0) + gbits[i++] = 'x'; + gbits[i] = '\0'; + + i = 0; + if ((um & S_IROTH) == 0) + obits[i++] = 'r'; + if ((um & S_IWOTH) == 0) + obits[i++] = 'w'; + if ((um & S_IXOTH) == 0) + obits[i++] = 'x'; + obits[i] = '\0'; + + printf ("u=%s,g=%s,o=%s\n", ubits, gbits, obits); +} + +int +parse_symbolic_mode (mode, initial_bits) + char *mode; + int initial_bits; +{ + int who, op, perm, bits, c; + char *s; + + for (s = mode, bits = initial_bits;;) + { + who = op = perm = 0; + + /* Parse the `who' portion of the symbolic mode clause. */ + while (member (*s, "agou")) + { + switch (c = *s++) + { + case 'u': + who |= S_IRWXU; + continue; + case 'g': + who |= S_IRWXG; + continue; + case 'o': + who |= S_IRWXO; + continue; + case 'a': + who |= S_IRWXU | S_IRWXG | S_IRWXO; + continue; + default: + break; + } + } + + /* The operation is now sitting in *s. */ + op = *s++; + switch (op) + { + case '+': + case '-': + case '=': + break; + default: + builtin_error (_("`%c': invalid symbolic mode operator"), op); + return (-1); + } + + /* Parse out the `perm' section of the symbolic mode clause. */ + while (member (*s, "rwx")) + { + c = *s++; + + switch (c) + { + case 'r': + perm |= S_IRUGO; + break; + case 'w': + perm |= S_IWUGO; + break; + case 'x': + perm |= S_IXUGO; + break; + } + } + + /* Now perform the operation or return an error for a + bad permission string. */ + if (!*s || *s == ',') + { + if (who) + perm &= who; + + switch (op) + { + case '+': + bits |= perm; + break; + case '-': + bits &= ~perm; + break; + case '=': + if (who == 0) + who = S_IRWXU | S_IRWXG | S_IRWXO; + bits &= ~who; + bits |= perm; + break; + + /* No other values are possible. */ + } + + if (*s == '\0') + break; + else + s++; /* skip past ',' */ + } + else + { + builtin_error (_("`%c': invalid symbolic mode character"), *s); + return (-1); + } + } + + return (bits); +} + +/* Set the umask from a symbolic mode string similar to that accepted + by chmod. If the -S argument is given, then print the umask in a + symbolic form. */ +static int +symbolic_umask (list) + WORD_LIST *list; +{ + int um, bits; + + /* Get the initial umask. Don't change it yet. */ + um = umask (022); + umask (um); + + /* All work is done with the complement of the umask -- it's + more intuitive and easier to deal with. It is complemented + again before being returned. */ + bits = parse_symbolic_mode (list->word->word, ~um & 0777); + if (bits == -1) + return (-1); + + um = ~bits & 0777; + return (um); +} diff --git a/builtins/wait.def b/builtins/wait.def new file mode 100644 index 0000000..974f959 --- /dev/null +++ b/builtins/wait.def @@ -0,0 +1,224 @@ +This file is wait.def, from which is created wait.c. +It implements the builtin "wait" in Bash. + +Copyright (C) 1987-2015 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 3 of the License, 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. If not, see . + +$BUILTIN wait +$FUNCTION wait_builtin +$DEPENDS_ON JOB_CONTROL +$PRODUCES wait.c +$SHORT_DOC wait [-n] [id ...] +Wait for job completion and return exit status. + +Waits for each process identified by an ID, which may be a process ID or a +job specification, and reports its termination status. If ID is not +given, waits for all currently active child processes, and the return +status is zero. If ID is a a job specification, waits for all processes +in that job's pipeline. + +If the -n option is supplied, waits for the next job to terminate and +returns its exit status. + +Exit Status: +Returns the status of the last ID; fails if ID is invalid or an invalid +option is given. +$END + +$BUILTIN wait +$FUNCTION wait_builtin +$DEPENDS_ON !JOB_CONTROL +$SHORT_DOC wait [pid ...] +Wait for process completion and return exit status. + +Waits for each process specified by a PID and reports its termination status. +If PID is not given, waits for all currently active child processes, +and the return status is zero. PID must be a process ID. + +Exit Status: +Returns the status of the last PID; fails if PID is invalid or an invalid +option is given. +$END + +#include + +#include "../bashtypes.h" +#include + +#if defined (HAVE_UNISTD_H) +# include +#endif + +#include + +#include "../bashansi.h" + +#include "../shell.h" +#include "../jobs.h" +#include "common.h" +#include "bashgetopt.h" + +extern int wait_signal_received; +extern int last_command_exit_signal; + +procenv_t wait_intr_buf; +int wait_intr_flag; + +/* Wait for the pid in LIST to stop or die. If no arguments are given, then + wait for all of the active background processes of the shell and return + 0. If a list of pids or job specs are given, return the exit status of + the last one waited for. */ + +#define WAIT_RETURN(s) \ + do \ + { \ + interrupt_immediately = old_interrupt_immediately;\ + wait_signal_received = 0; \ + wait_intr_flag = 0; \ + return (s);\ + } \ + while (0) + +int +wait_builtin (list) + WORD_LIST *list; +{ + int status, code, opt, nflag; + volatile int old_interrupt_immediately; + + USE_VAR(list); + + nflag = 0; + reset_internal_getopt (); + while ((opt = internal_getopt (list, "n")) != -1) + { + switch (opt) + { +#if defined (JOB_CONTROL) + case 'n': + nflag = 1; + break; +#endif + CASE_HELPOPT; + default: + builtin_usage (); + return (EX_USAGE); + } + } + list = loptend; + + old_interrupt_immediately = interrupt_immediately; +#if 0 + interrupt_immediately++; +#endif + + /* POSIX.2 says: When the shell is waiting (by means of the wait utility) + for asynchronous commands to complete, the reception of a signal for + which a trap has been set shall cause the wait utility to return + immediately with an exit status greater than 128, after which the trap + associated with the signal shall be taken. + + We handle SIGINT here; it's the only one that needs to be treated + specially (I think), since it's handled specially in {no,}jobs.c. */ + wait_intr_flag = 1; + code = setjmp_sigs (wait_intr_buf); + + if (code) + { + last_command_exit_signal = wait_signal_received; + status = 128 + wait_signal_received; + wait_sigint_cleanup (); + WAIT_RETURN (status); + } + + /* We support jobs or pids. + wait [pid-or-job ...] */ + +#if defined (JOB_CONTROL) + if (nflag) + { + status = wait_for_any_job (); + if (status < 0) + status = 127; + WAIT_RETURN (status); + } +#endif + + /* But wait without any arguments means to wait for all of the shell's + currently active background processes. */ + if (list == 0) + { + wait_for_background_pids (); + WAIT_RETURN (EXECUTION_SUCCESS); + } + + status = EXECUTION_SUCCESS; + while (list) + { + pid_t pid; + char *w; + intmax_t pid_value; + + w = list->word->word; + if (DIGIT (*w)) + { + if (legal_number (w, &pid_value) && pid_value == (pid_t)pid_value) + { + pid = (pid_t)pid_value; + status = wait_for_single_pid (pid, 1); + } + else + { + sh_badpid (w); + WAIT_RETURN (EXECUTION_FAILURE); + } + } +#if defined (JOB_CONTROL) + else if (*w && *w == '%') + /* Must be a job spec. Check it out. */ + { + int job; + sigset_t set, oset; + + BLOCK_CHILD (set, oset); + job = get_job_spec (list); + + if (INVALID_JOB (job)) + { + if (job != DUP_JOB) + sh_badjob (list->word->word); + UNBLOCK_CHILD (oset); + status = 127; /* As per Posix.2, section 4.70.2 */ + list = list->next; + continue; + } + + /* Job spec used. Wait for the last pid in the pipeline. */ + UNBLOCK_CHILD (oset); + status = wait_for_job (job); + } +#endif /* JOB_CONTROL */ + else + { + sh_badpid (w); + status = EXECUTION_FAILURE; + } + list = list->next; + } + + WAIT_RETURN (status); +} diff --git a/command.h b/command.h new file mode 100644 index 0000000..3da5b77 --- /dev/null +++ b/command.h @@ -0,0 +1,401 @@ +/* command.h -- The structures used internally to represent commands, and + the extern declarations of the functions used to create them. */ + +/* Copyright (C) 1993-2016 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 3 of the License, 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. If not, see . +*/ + +#if !defined (_COMMAND_H_) +#define _COMMAND_H_ + +#include "stdc.h" + +/* Instructions describing what kind of thing to do for a redirection. */ +enum r_instruction { + r_output_direction, r_input_direction, r_inputa_direction, + r_appending_to, r_reading_until, r_reading_string, + r_duplicating_input, r_duplicating_output, r_deblank_reading_until, + r_close_this, r_err_and_out, r_input_output, r_output_force, + r_duplicating_input_word, r_duplicating_output_word, + r_move_input, r_move_output, r_move_input_word, r_move_output_word, + r_append_err_and_out +}; + +/* Redirection flags; values for rflags */ +#define REDIR_VARASSIGN 0x01 + +/* Redirection errors. */ +#define AMBIGUOUS_REDIRECT -1 +#define NOCLOBBER_REDIRECT -2 +#define RESTRICTED_REDIRECT -3 /* can only happen in restricted shells. */ +#define HEREDOC_REDIRECT -4 /* here-doc temp file can't be created */ +#define BADVAR_REDIRECT -5 /* something wrong with {varname}redir */ + +#define CLOBBERING_REDIRECT(ri) \ + (ri == r_output_direction || ri == r_err_and_out) + +#define OUTPUT_REDIRECT(ri) \ + (ri == r_output_direction || ri == r_input_output || ri == r_err_and_out || ri == r_append_err_and_out) + +#define INPUT_REDIRECT(ri) \ + (ri == r_input_direction || ri == r_inputa_direction || ri == r_input_output) + +#define WRITE_REDIRECT(ri) \ + (ri == r_output_direction || \ + ri == r_input_output || \ + ri == r_err_and_out || \ + ri == r_appending_to || \ + ri == r_append_err_and_out || \ + ri == r_output_force) + +/* redirection needs translation */ +#define TRANSLATE_REDIRECT(ri) \ + (ri == r_duplicating_input_word || ri == r_duplicating_output_word || \ + ri == r_move_input_word || ri == r_move_output_word) + +/* Command Types: */ +enum command_type { cm_for, cm_case, cm_while, cm_if, cm_simple, cm_select, + cm_connection, cm_function_def, cm_until, cm_group, + cm_arith, cm_cond, cm_arith_for, cm_subshell, cm_coproc }; + +/* Possible values for the `flags' field of a WORD_DESC. */ +#define W_HASDOLLAR 0x000001 /* Dollar sign present. */ +#define W_QUOTED 0x000002 /* Some form of quote character is present. */ +#define W_ASSIGNMENT 0x000004 /* This word is a variable assignment. */ +#define W_SPLITSPACE 0x000008 /* Split this word on " " regardless of IFS */ +#define W_NOSPLIT 0x000010 /* Do not perform word splitting on this word because ifs is empty string. */ +#define W_NOGLOB 0x000020 /* Do not perform globbing on this word. */ +#define W_NOSPLIT2 0x000040 /* Don't split word except for $@ expansion (using spaces) because context does not allow it. */ +#define W_TILDEEXP 0x000080 /* Tilde expand this assignment word */ +#define W_DOLLARAT 0x000100 /* $@ and its special handling */ +#define W_DOLLARSTAR 0x000200 /* $* and its special handling */ +#define W_NOCOMSUB 0x000400 /* Don't perform command substitution on this word */ +#define W_ASSIGNRHS 0x000800 /* Word is rhs of an assignment statement */ +#define W_NOTILDE 0x001000 /* Don't perform tilde expansion on this word */ +#define W_ITILDE 0x002000 /* Internal flag for word expansion */ +#define W_NOEXPAND 0x004000 /* Don't expand at all -- do quote removal */ +#define W_COMPASSIGN 0x008000 /* Compound assignment */ +#define W_ASSNBLTIN 0x010000 /* word is a builtin command that takes assignments */ +#define W_ASSIGNARG 0x020000 /* word is assignment argument to command */ +#define W_HASQUOTEDNULL 0x040000 /* word contains a quoted null character */ +#define W_DQUOTE 0x080000 /* word should be treated as if double-quoted */ +#define W_NOPROCSUB 0x100000 /* don't perform process substitution */ +#define W_HASCTLESC 0x200000 /* word contains literal CTLESC characters */ +#define W_ASSIGNASSOC 0x400000 /* word looks like associative array assignment */ +#define W_ASSIGNARRAY 0x800000 /* word looks like a compound indexed array assignment */ +#define W_ARRAYIND 0x1000000 /* word is an array index being expanded */ +#define W_ASSNGLOBAL 0x2000000 /* word is a global assignment to declare (declare/typeset -g) */ +#define W_NOBRACE 0x4000000 /* Don't perform brace expansion */ +#define W_COMPLETE 0x8000000 /* word is being expanded for completion */ + +/* Flags for the `pflags' argument to param_expand() and various + parameter_brace_expand_xxx functions; also used for string_list_dollar_at */ +#define PF_NOCOMSUB 0x01 /* Do not perform command substitution */ +#define PF_IGNUNBOUND 0x02 /* ignore unbound vars even if -u set */ +#define PF_NOSPLIT2 0x04 /* same as W_NOSPLIT2 */ +#define PF_ASSIGNRHS 0x08 /* same as W_ASSIGNRHS */ +#define PF_COMPLETE 0x10 /* same as W_COMPLETE, sets SX_COMPLETE */ + +/* Possible values for subshell_environment */ +#define SUBSHELL_ASYNC 0x01 /* subshell caused by `command &' */ +#define SUBSHELL_PAREN 0x02 /* subshell caused by ( ... ) */ +#define SUBSHELL_COMSUB 0x04 /* subshell caused by `command` or $(command) */ +#define SUBSHELL_FORK 0x08 /* subshell caused by executing a disk command */ +#define SUBSHELL_PIPE 0x10 /* subshell from a pipeline element */ +#define SUBSHELL_PROCSUB 0x20 /* subshell caused by <(command) or >(command) */ +#define SUBSHELL_COPROC 0x40 /* subshell from a coproc pipeline */ +#define SUBSHELL_RESETTRAP 0x80 /* subshell needs to reset trap strings on first call to trap */ + +/* A structure which represents a word. */ +typedef struct word_desc { + char *word; /* Zero terminated string. */ + int flags; /* Flags associated with this word. */ +} WORD_DESC; + +/* A linked list of words. */ +typedef struct word_list { + struct word_list *next; + WORD_DESC *word; +} WORD_LIST; + + +/* **************************************************************** */ +/* */ +/* Shell Command Structs */ +/* */ +/* **************************************************************** */ + +/* What a redirection descriptor looks like. If the redirection instruction + is ri_duplicating_input or ri_duplicating_output, use DEST, otherwise + use the file in FILENAME. Out-of-range descriptors are identified by a + negative DEST. */ + +typedef union { + int dest; /* Place to redirect REDIRECTOR to, or ... */ + WORD_DESC *filename; /* filename to redirect to. */ +} REDIRECTEE; + +/* Structure describing a redirection. If REDIRECTOR is negative, the parser + (or translator in redir.c) encountered an out-of-range file descriptor. */ +typedef struct redirect { + struct redirect *next; /* Next element, or NULL. */ + REDIRECTEE redirector; /* Descriptor or varname to be redirected. */ + int rflags; /* Private flags for this redirection */ + int flags; /* Flag value for `open'. */ + enum r_instruction instruction; /* What to do with the information. */ + REDIRECTEE redirectee; /* File descriptor or filename */ + char *here_doc_eof; /* The word that appeared in <flags. */ +#define CMD_WANT_SUBSHELL 0x01 /* User wants a subshell: ( command ) */ +#define CMD_FORCE_SUBSHELL 0x02 /* Shell needs to force a subshell. */ +#define CMD_INVERT_RETURN 0x04 /* Invert the exit value. */ +#define CMD_IGNORE_RETURN 0x08 /* Ignore the exit value. For set -e. */ +#define CMD_NO_FUNCTIONS 0x10 /* Ignore functions during command lookup. */ +#define CMD_INHIBIT_EXPANSION 0x20 /* Do not expand the command words. */ +#define CMD_NO_FORK 0x40 /* Don't fork; just call execve */ +#define CMD_TIME_PIPELINE 0x80 /* Time a pipeline */ +#define CMD_TIME_POSIX 0x100 /* time -p; use POSIX.2 time output spec. */ +#define CMD_AMPERSAND 0x200 /* command & */ +#define CMD_STDIN_REDIR 0x400 /* async command needs implicit . +*/ + +/*********************************************************/ +/* Modify or set defines based on the configure results. */ +/*********************************************************/ + +#if !defined (HAVE_VPRINTF) && defined (HAVE_DOPRNT) +# define USE_VFPRINTF_EMULATION +# define HAVE_VPRINTF +#endif + +#if defined (HAVE_SYS_RESOURCE_H) && defined (HAVE_GETRLIMIT) +# define HAVE_RESOURCE +#endif + +#if !defined (GETPGRP_VOID) +# define HAVE_BSD_PGRP +#endif + +/* Try this without testing __STDC__ for the time being. */ +#if defined (HAVE_STDARG_H) +# define PREFER_STDARG +# define USE_VARARGS +#else +# if defined (HAVE_VARARGS_H) +# define PREFER_VARARGS +# define USE_VARARGS +# endif +#endif + +#if defined (HAVE_SYS_SOCKET_H) && defined (HAVE_GETPEERNAME) && defined (HAVE_NETINET_IN_H) +# define HAVE_NETWORK +#endif + +#if defined (HAVE_REGEX_H) && defined (HAVE_REGCOMP) && defined (HAVE_REGEXEC) +# define HAVE_POSIX_REGEXP +#endif + +/* backwards compatibility between different autoconf versions */ +#if HAVE_DECL_SYS_SIGLIST && !defined (SYS_SIGLIST_DECLARED) +# define SYS_SIGLIST_DECLARED +#endif + +/***********************************************************************/ +/* Unset defines based on what configure reports as missing or broken. */ +/***********************************************************************/ + +/* Ultrix botches type-ahead when switching from canonical to + non-canonical mode, at least through version 4.3 */ +#if !defined (HAVE_TERMIOS_H) || !defined (HAVE_TCGETATTR) || defined (ultrix) +# define TERMIOS_MISSING +#endif + +/* If we have a getcwd(3), but one that does not dynamically allocate memory, + #undef HAVE_GETCWD so the replacement in getcwd.c will be built. We do + not do this on Solaris, because their implementation of loopback mounts + breaks the traditional file system assumptions that getcwd uses. */ +#if defined (HAVE_GETCWD) && defined (GETCWD_BROKEN) && !defined (SOLARIS) +# undef HAVE_GETCWD +#endif + +#if !defined (HAVE_DEV_FD) && defined (NAMED_PIPES_MISSING) +# undef PROCESS_SUBSTITUTION +#endif + +#if defined (JOB_CONTROL_MISSING) +# undef JOB_CONTROL +#endif + +#if defined (STRCOLL_BROKEN) +# undef HAVE_STRCOLL +#endif + +#if !defined (HAVE_POSIX_REGEXP) +# undef COND_REGEXP +#endif + +#if !HAVE_MKSTEMP +# undef USE_MKSTEMP +#endif + +/* If the shell is called by this name, it will become restricted. */ +#if defined (RESTRICTED_SHELL) +# define RESTRICTED_SHELL_NAME "rbash" +#endif + +/***********************************************************/ +/* Make sure feature defines have necessary prerequisites. */ +/***********************************************************/ + +/* BANG_HISTORY requires HISTORY. */ +#if defined (BANG_HISTORY) && !defined (HISTORY) +# define HISTORY +#endif /* BANG_HISTORY && !HISTORY */ + +#if defined (READLINE) && !defined (HISTORY) +# define HISTORY +#endif + +#if defined (PROGRAMMABLE_COMPLETION) && !defined (READLINE) +# undef PROGRAMMABLE_COMPLETION +#endif + +#if !defined (V9_ECHO) +# undef DEFAULT_ECHO_TO_XPG +#endif + +#if !defined (PROMPT_STRING_DECODE) +# undef PPROMPT +# define PPROMPT "$ " +#endif + +#if !defined (HAVE_SYSLOG) || !defined (HAVE_SYSLOG_H) +# undef SYSLOG_HISTORY +#endif + +/************************************************/ +/* check multibyte capability for I18N code */ +/************************************************/ + +/* For platforms which support the ISO C amendement 1 functionality we + support user defined character classes. */ +/* Solaris 2.5 has a bug: must be included before . */ +#if defined (HAVE_WCTYPE_H) && defined (HAVE_WCHAR_H) && defined (HAVE_LOCALE_H) +# include +# include +# if defined (HAVE_ISWCTYPE) && \ + defined (HAVE_ISWLOWER) && \ + defined (HAVE_ISWUPPER) && \ + defined (HAVE_MBSRTOWCS) && \ + defined (HAVE_MBRTOWC) && \ + defined (HAVE_MBRLEN) && \ + defined (HAVE_TOWLOWER) && \ + defined (HAVE_TOWUPPER) && \ + defined (HAVE_WCHAR_T) && \ + defined (HAVE_WCTYPE_T) && \ + defined (HAVE_WINT_T) && \ + defined (HAVE_WCWIDTH) && \ + defined (HAVE_WCTYPE) + /* system is supposed to support XPG5 */ +# define HANDLE_MULTIBYTE 1 +# endif +#endif + +/* If we don't want multibyte chars even on a system that supports them, let + the configuring user turn multibyte support off. */ +#if defined (NO_MULTIBYTE_SUPPORT) +# undef HANDLE_MULTIBYTE +#endif + +/* Some systems, like BeOS, have multibyte encodings but lack mbstate_t. */ +#if HANDLE_MULTIBYTE && !defined (HAVE_MBSTATE_T) +# define wcsrtombs(dest, src, len, ps) (wcsrtombs) (dest, src, len, 0) +# define mbsrtowcs(dest, src, len, ps) (mbsrtowcs) (dest, src, len, 0) +# define wcrtomb(s, wc, ps) (wcrtomb) (s, wc, 0) +# define mbrtowc(pwc, s, n, ps) (mbrtowc) (pwc, s, n, 0) +# define mbrlen(s, n, ps) (mbrlen) (s, n, 0) +# define mbstate_t int +#endif + +/* Make sure MB_LEN_MAX is at least 16 (some systems define + MB_LEN_MAX as 1) */ +#ifdef HANDLE_MULTIBYTE +# include +# if defined(MB_LEN_MAX) && (MB_LEN_MAX < 16) +# undef MB_LEN_MAX +# endif +# if !defined (MB_LEN_MAX) +# define MB_LEN_MAX 16 +# endif +#endif + +/************************************************/ +/* end of multibyte capability checks for I18N */ +/************************************************/ + +/******************************************************************/ +/* Placeholder for builders to #undef any unwanted features from */ +/* config-top.h or created by configure (such as the default mail */ +/* file for mail checking). */ +/******************************************************************/ + +/* If you don't want bash to provide a default mail file to check. */ +/* #undef DEFAULT_MAIL_DIRECTORY */ diff --git a/config-top.h b/config-top.h new file mode 100644 index 0000000..d89682e --- /dev/null +++ b/config-top.h @@ -0,0 +1,162 @@ +/* config-top.h - various user-settable options not under the control of autoconf. */ + +/* Copyright (C) 2002-2009 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 3 of the License, 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. If not, see . +*/ + +/* Define CONTINUE_AFTER_KILL_ERROR if you want the kill command to + continue processing arguments after one of them fails. This is + what POSIX.2 specifies. */ +#define CONTINUE_AFTER_KILL_ERROR + +/* Define BREAK_COMPLAINS if you want the non-standard, but useful + error messages about `break' and `continue' out of context. */ +#define BREAK_COMPLAINS + +/* Define CD_COMPLAINS if you want the non-standard, but sometimes-desired + error messages about multiple directory arguments to `cd'. */ +#define CD_COMPLAINS + +/* Define BUFFERED_INPUT if you want the shell to do its own input + buffering, rather than using stdio. Do not undefine this; it's + required to preserve semantics required by POSIX. */ +#define BUFFERED_INPUT + +/* Define ONESHOT if you want sh -c 'command' to avoid forking to execute + `command' whenever possible. This is a big efficiency improvement. */ +#define ONESHOT + +/* Define V9_ECHO if you want to give the echo builtin backslash-escape + interpretation using the -e option, in the style of the Bell Labs 9th + Edition version of echo. You cannot emulate the System V echo behavior + without this option. */ +#define V9_ECHO + +/* Define DONT_REPORT_SIGPIPE if you don't want to see `Broken pipe' messages + when a job like `cat jobs.c | exit 1' terminates due to a SIGPIPE. */ +#define DONT_REPORT_SIGPIPE + +/* Define DONT_REPORT_SIGTERM if you don't want to see `Terminates' message + when a job exits due to SIGTERM, since that's the default signal sent + by the kill builtin. */ +/* #define DONT_REPORT_SIGTERM */ + +/* Define DONT_REPORT_BROKEN_PIPE_WRITE_ERRORS if you don't want builtins + like `echo' and `printf' to report errors when output does not succeed + due to EPIPE. */ +/* #define DONT_REPORT_BROKEN_PIPE_WRITE_ERRORS */ + +/* The default value of the PATH variable. */ +#ifndef DEFAULT_PATH_VALUE +#define DEFAULT_PATH_VALUE \ + "/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:." +#endif + +/* The value for PATH when invoking `command -p'. This is only used when + the Posix.2 confstr () function, or CS_PATH define are not present. */ +#ifndef STANDARD_UTILS_PATH +#define STANDARD_UTILS_PATH \ + "/bin:/usr/bin:/sbin:/usr/sbin:/etc:/usr/etc" +#endif + +/* Default primary and secondary prompt strings. */ +#define PPROMPT "\\s-\\v\\$ " +#define SPROMPT "> " + +/* Undefine this if you don't want the ksh-compatible behavior of reprinting + the select menu after a valid choice is made only if REPLY is set to NULL + in the body of the select command. The menu is always reprinted if the + reply to the select query is an empty line. */ +#define KSH_COMPATIBLE_SELECT + +/* Default interactive shell startup file. */ +#define DEFAULT_BASHRC "~/.bashrc" + +/* System-wide .bashrc file for interactive shells. */ +/* #define SYS_BASHRC "/etc/bash.bashrc" */ + +/* System-wide .bash_logout for login shells. */ +/* #define SYS_BASH_LOGOUT "/etc/bash.bash_logout" */ + +/* Define this to make non-interactive shells begun with argv[0][0] == '-' + run the startup files when not in posix mode. */ +/* #define NON_INTERACTIVE_LOGIN_SHELLS */ + +/* Define this if you want bash to try to check whether it's being run by + sshd and source the .bashrc if so (like the rshd behavior). This checks + for the presence of SSH_CLIENT or SSH2_CLIENT in the initial environment, + which can be fooled under certain not-uncommon circumstances. */ +/* #define SSH_SOURCE_BASHRC */ + +/* Define if you want the case-capitalizing operators (~[~]) and the + `capcase' variable attribute (declare -c). */ +#define CASEMOD_CAPCASE + +/* This is used as the name of a shell function to call when a command + name is not found. If you want to name it something other than the + default ("command_not_found_handle"), change it here. */ +/* #define NOTFOUND_HOOK "command_not_found_handle" */ + +/* Define if you want each line saved to the history list in bashhist.c: + bash_add_history() to be sent to syslog(). */ +/* #define SYSLOG_HISTORY */ +#if defined (SYSLOG_HISTORY) +# define SYSLOG_FACILITY LOG_USER +# define SYSLOG_LEVEL LOG_INFO +# define OPENLOG_OPTS LOG_PID +#endif + +/* Define if you want to include code in shell.c to support wordexp(3) */ +/* #define WORDEXP_OPTION */ + +/* Define as 1 if you want to enable code that implements multiple coprocs */ +#ifndef MULTIPLE_COPROCS +# define MULTIPLE_COPROCS 0 +#endif + +/* Define to 0 if you want the checkwinsize option off by default, 1 if you + want it on. */ +#define CHECKWINSIZE_DEFAULT 0 + +/* Define to 1 if you want to optimize for sequential array assignment when + using indexed arrays, 0 if you want bash-4.2 behavior, which favors + random access but is O(N) for each array assignment. */ +#define OPTIMIZE_SEQUENTIAL_ARRAY_ASSIGNMENT 1 + +/* Define to 1 if you want to be able to export indexed arrays to processes + using the foo=([0]=one [1]=two) and so on */ +/* #define ARRAY_EXPORT 1 */ + +/* Define to 1 if you want the shell to exit if it is running setuid and its + attempt to drop privilege using setuid(getuid()) fails with errno == EAGAIN */ +/* #define EXIT_ON_SETUID_FAILURE 1 */ + +/* Define to 1 if you want the shell to re-check $PATH if a hashed filename + no longer exists. This behavior is the default in Posix mode. */ +#define CHECKHASH_DEFAULT 0 + +/* Define to the maximum level of recursion you want for the eval builtin. + 0 means the limit is not active. */ +#define EVALNEST_MAX 0 + +/* Define to the maximum level of recursion you want for the source/. builtin. + 0 means the limit is not active. */ +#define SOURCENEST_MAX 0 + +/* Define to use libc mktemp/mkstemp instead of replacements in lib/sh/tmpfile.c */ +#define USE_MKTEMP +#define USE_MKSTEMP diff --git a/config.h.in b/config.h.in new file mode 100644 index 0000000..a5ad9e7 --- /dev/null +++ b/config.h.in @@ -0,0 +1,1189 @@ +/* config.h -- Configuration file for bash. */ + +/* Copyright (C) 1987-2009,2011-2012 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 3 of the License, 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. If not, see . +*/ + +#ifndef _CONFIG_H_ +#define _CONFIG_H_ + +/* Template settings for autoconf */ + +#undef __EXTENSIONS__ +#undef _ALL_SOURCE +#undef _GNU_SOURCE +#undef _POSIX_SOURCE +#undef _POSIX_1_SOURCE +#undef _POSIX_PTHREAD_SEMANTICS +#undef _TANDEM_SOURCE +#undef _MINIX + +/* Configuration feature settings controllable by autoconf. */ + +/* Define JOB_CONTROL if your operating system supports + BSD-like job control. */ +#undef JOB_CONTROL + +/* Define ALIAS if you want the alias features. */ +#undef ALIAS + +/* Define PUSHD_AND_POPD if you want those commands to be compiled in. + (Also the `dirs' commands.) */ +#undef PUSHD_AND_POPD + +/* Define BRACE_EXPANSION if you want curly brace expansion a la Csh: + foo{a,b} -> fooa foob. Even if this is compiled in (the default) you + can turn it off at shell startup with `-nobraceexpansion', or during + shell execution with `set +o braceexpand'. */ +#undef BRACE_EXPANSION + +/* Define READLINE to get the nifty/glitzy editing features. + This is on by default. You can turn it off interactively + with the -nolineediting flag. */ +#undef READLINE + +/* Define BANG_HISTORY if you want to have Csh style "!" history expansion. + This is unrelated to READLINE. */ +#undef BANG_HISTORY + +/* Define HISTORY if you want to have access to previously typed commands. + + If both HISTORY and READLINE are defined, you can get at the commands + with line editing commands, and you can directly manipulate the history + from the command line. + + If only HISTORY is defined, the `fc' and `history' builtins are + available. */ +#undef HISTORY + +/* Define this if you want completion that puts all alternatives into + a brace expansion shell expression. */ +#if defined (BRACE_EXPANSION) && defined (READLINE) +# define BRACE_COMPLETION +#endif /* BRACE_EXPANSION */ + +/* Define DEFAULT_ECHO_TO_XPG if you want the echo builtin to interpret + the backslash-escape characters by default, like the XPG Single Unix + Specification V2 for echo. + This requires that V9_ECHO be defined. */ +#undef DEFAULT_ECHO_TO_XPG + +/* Define HELP_BUILTIN if you want the `help' shell builtin and the long + documentation strings compiled into the shell. */ +#undef HELP_BUILTIN + +/* Define RESTRICTED_SHELL if you want the generated shell to have the + ability to be a restricted one. The shell thus generated can become + restricted by being run with the name "rbash", or by setting the -r + flag. */ +#undef RESTRICTED_SHELL + +/* Define DISABLED_BUILTINS if you want "builtin foo" to always run the + shell builtin "foo", even if it has been disabled with "enable -n foo". */ +#undef DISABLED_BUILTINS + +/* Define PROCESS_SUBSTITUTION if you want the K*rn shell-like process + substitution features "<(file)". */ +/* Right now, you cannot do this on machines without fully operational + FIFO support. This currently include NeXT and Alliant. */ +#undef PROCESS_SUBSTITUTION + +/* Define PROMPT_STRING_DECODE if you want the backslash-escaped special + characters in PS1 and PS2 expanded. Variable expansion will still be + performed. */ +#undef PROMPT_STRING_DECODE + +/* Define SELECT_COMMAND if you want the Korn-shell style `select' command: + select word in word_list; do command_list; done */ +#undef SELECT_COMMAND + +/* Define COMMAND_TIMING of you want the ksh-style `time' reserved word and + the ability to time pipelines, functions, and builtins. */ +#undef COMMAND_TIMING + +/* Define ARRAY_VARS if you want ksh-style one-dimensional array variables. */ +#undef ARRAY_VARS + +/* Define DPAREN_ARITHMETIC if you want the ksh-style ((...)) arithmetic + evaluation command. */ +#undef DPAREN_ARITHMETIC + +/* Define EXTENDED_GLOB if you want the ksh-style [*+@?!](patlist) extended + pattern matching. */ +#undef EXTENDED_GLOB + +/* Define EXTGLOB_DEFAULT to the value you'd like the extglob shell option + to have by default */ +#undef EXTGLOB_DEFAULT + +/* Define COND_COMMAND if you want the ksh-style [[...]] conditional + command. */ +#undef COND_COMMAND + +/* Define COND_REGEXP if you want extended regular expression matching and the + =~ binary operator in the [[...]] conditional command. */ +#define COND_REGEXP + +/* Define COPROCESS_SUPPORT if you want support for ksh-like coprocesses and + the `coproc' reserved word */ +#define COPROCESS_SUPPORT + +/* Define ARITH_FOR_COMMAND if you want the ksh93-style + for (( init; test; step )) do list; done + arithmetic for command. */ +#undef ARITH_FOR_COMMAND + +/* Define NETWORK_REDIRECTIONS if you want /dev/(tcp|udp)/host/port to open + socket connections when used in redirections */ +#undef NETWORK_REDIRECTIONS + +/* Define PROGRAMMABLE_COMPLETION for the programmable completion features + and the complete builtin. */ +#undef PROGRAMMABLE_COMPLETION + +/* Define NO_MULTIBYTE_SUPPORT to not compile in support for multibyte + characters, even if the OS supports them. */ +#undef NO_MULTIBYTE_SUPPORT + +/* Define DEBUGGER if you want to compile in some features used only by the + bash debugger. */ +#undef DEBUGGER + +/* Define STRICT_POSIX if you want bash to be strictly posix.2 conformant by + default (except for echo; that is controlled separately). */ +#undef STRICT_POSIX + +/* Define MEMSCRAMBLE if you want the bash malloc and free to scramble + memory contents on malloc() and free(). */ +#undef MEMSCRAMBLE + +/* Define for case-modifying variable attributes; variables modified on + assignment */ +#undef CASEMOD_ATTRS + +/* Define for case-modifying word expansions */ +#undef CASEMOD_EXPANSIONS + +/* Define to make the `direxpand' shopt option enabled by default. */ +#undef DIRCOMPLETE_EXPAND_DEFAULT + +/* Define to make the `globasciiranges' shopt option enabled by default. */ +#undef GLOBASCII_DEFAULT + +/* Define to allow functions to be imported from the environment. */ +#undef FUNCTION_IMPORT + +/* Define AFS if you are using Transarc's AFS. */ +#undef AFS + +#undef ENABLE_NLS + +/* End of configuration settings controllable by autoconf. */ +/* Other settable options appear in config-top.h. */ + +#include "config-top.h" + +/* Beginning of autoconf additions. */ + +/* Characteristics of the C compiler */ +#undef const + +#undef inline + +#undef restrict + +#undef volatile + +/* Define if cpp supports the ANSI-C stringizing `#' operator */ +#undef HAVE_STRINGIZE + +/* Define if the compiler supports `long double' variables. */ +#undef HAVE_LONG_DOUBLE + +#undef PROTOTYPES +#undef __PROTOTYPES + +#undef __CHAR_UNSIGNED__ + +/* Define if the compiler supports `long long' variables. */ +#undef HAVE_LONG_LONG + +#undef HAVE_UNSIGNED_LONG_LONG + +/* The number of bytes in a int. */ +#undef SIZEOF_INT + +/* The number of bytes in a long. */ +#undef SIZEOF_LONG + +/* The number of bytes in a pointer to char. */ +#undef SIZEOF_CHAR_P + +/* The number of bytes in a double (hopefully 8). */ +#undef SIZEOF_DOUBLE + +/* The number of bytes in an `intmax_t'. */ +#undef SIZEOF_INTMAX_T + +/* The number of bytes in a `long long', if we have one. */ +#undef SIZEOF_LONG_LONG + +/* System paths */ + +#define DEFAULT_MAIL_DIRECTORY "/usr/spool/mail" + +/* Characteristics of the system's header files and libraries that affect + the compilation environment. */ + +/* Define if the system does not provide POSIX.1 features except + with this defined. */ +#undef _POSIX_1_SOURCE + +/* Define if you need to in order for stat and other things to work. */ +#undef _POSIX_SOURCE + +/* Define to use GNU libc extensions */ +#undef _GNU_SOURCE + +/* Define if you have the ANSI C header files. */ +#undef STDC_HEADERS + +/* Memory management functions. */ + +/* Define if using the bash version of malloc in lib/malloc/malloc.c */ +#undef USING_BASH_MALLOC + +#undef DISABLE_MALLOC_WRAPPERS + +/* Define if using alloca.c. */ +#undef C_ALLOCA + +/* Define to one of _getb67, GETB67, getb67 for Cray-2 and Cray-YMP systems. + This function is required for alloca.c support on those systems. */ +#undef CRAY_STACKSEG_END + +/* Define if you have alloca, as a function or macro. */ +#undef HAVE_ALLOCA + +/* Define if you have and it should be used (not on Ultrix). */ +#undef HAVE_ALLOCA_H + + +/* SYSTEM TYPES */ + +/* Define to `long' if doesn't define. */ +#undef off_t + +/* Define to `int' if doesn't define. */ +#undef mode_t + +/* Define to `int' if doesn't define. */ +#undef sigset_t + +/* Define to `int' if doesn't define. */ +#undef pid_t + +/* Define to `short' if doesn't define. */ +#undef bits16_t + +/* Define to `unsigned short' if doesn't define. */ +#undef u_bits16_t + +/* Define to `int' if doesn't define. */ +#undef bits32_t + +/* Define to `unsigned int' if doesn't define. */ +#undef u_bits32_t + +/* Define to `double' if doesn't define. */ +#undef bits64_t + +/* Define to `unsigned int' if doesn't define. */ +#undef u_int + +/* Define to `unsigned long' if doesn't define. */ +#undef u_long + +/* Define to `int' if doesn't define. */ +#undef ptrdiff_t + +/* Define to `unsigned' if doesn't define. */ +#undef size_t + +/* Define to `int' if doesn't define. */ +#undef ssize_t + +/* Define to `long' if doesn't define. */ +#undef intmax_t + +/* Define to `unsigned long' if doesn't define. */ +#undef uintmax_t + +/* Define to integer type wide enough to hold a pointer if doesn't define. */ +#undef uintptr_t + +/* Define to `int' if doesn't define. */ +#undef uid_t + +/* Define to `long' if doesn't define. */ +#undef clock_t + +/* Define to `long' if doesn't define. */ +#undef time_t + +/* Define to `int' if doesn't define. */ +#undef gid_t + +/* Define to `unsigned int' if doesn't define. */ +#undef socklen_t + +/* Define to `int' if doesn't define. */ +#undef sig_atomic_t + +#undef HAVE_MBSTATE_T + +/* Define if you have quad_t in . */ +#undef HAVE_QUAD_T + +/* Define if you have wchar_t in . */ +#undef HAVE_WCHAR_T + +/* Define if you have wctype_t in . */ +#undef HAVE_WCTYPE_T + +/* Define if you have wint_t in . */ +#undef HAVE_WINT_T + +#undef RLIMTYPE + +/* Define to the type of elements in the array set by `getgroups'. + Usually this is either `int' or `gid_t'. */ +#undef GETGROUPS_T + +/* Characteristics of the machine archictecture. */ + +/* If using the C implementation of alloca, define if you know the + direction of stack growth for your system; otherwise it will be + automatically deduced at run-time. + STACK_DIRECTION > 0 => grows toward higher addresses + STACK_DIRECTION < 0 => grows toward lower addresses + STACK_DIRECTION = 0 => direction of growth unknown + */ +#undef STACK_DIRECTION + +/* Define if the machine architecture is big-endian. */ +#undef WORDS_BIGENDIAN + +/* Check for the presence of certain non-function symbols in the system + libraries. */ + +/* Define if `sys_siglist' is declared by or . */ +#undef HAVE_DECL_SYS_SIGLIST +#undef SYS_SIGLIST_DECLARED + +/* Define if `_sys_siglist' is declared by or . */ +#undef UNDER_SYS_SIGLIST_DECLARED + +#undef HAVE_SYS_SIGLIST + +#undef HAVE_UNDER_SYS_SIGLIST + +#undef HAVE_SYS_ERRLIST + +#undef HAVE_TZNAME +#undef HAVE_DECL_TZNAME + +/* Characteristics of some of the system structures. */ + +#undef HAVE_STRUCT_DIRENT_D_INO + +#undef HAVE_STRUCT_DIRENT_D_FILENO + +#undef HAVE_STRUCT_DIRENT_D_NAMLEN + +#undef TIOCSTAT_IN_SYS_IOCTL + +#undef FIONREAD_IN_SYS_IOCTL + +#undef GWINSZ_IN_SYS_IOCTL + +#undef STRUCT_WINSIZE_IN_SYS_IOCTL + +#undef TM_IN_SYS_TIME + +#undef STRUCT_WINSIZE_IN_TERMIOS + +#undef SPEED_T_IN_SYS_TYPES + +#undef TERMIOS_LDISC + +#undef TERMIO_LDISC + +#undef HAVE_STRUCT_STAT_ST_BLOCKS + +#undef HAVE_STRUCT_TM_TM_ZONE +#undef HAVE_TM_ZONE + +#undef HAVE_TIMEVAL + +#undef HAVE_STRUCT_TIMEZONE + +#undef WEXITSTATUS_OFFSET + +#undef HAVE_STRUCT_TIMESPEC +#undef TIME_H_DEFINES_STRUCT_TIMESPEC +#undef SYS_TIME_H_DEFINES_STRUCT_TIMESPEC +#undef PTHREAD_H_DEFINES_STRUCT_TIMESPEC + +#undef TYPEOF_STRUCT_STAT_ST_ATIM_IS_STRUCT_TIMESPEC +#undef HAVE_STRUCT_STAT_ST_ATIMESPEC_TV_NSEC +#undef HAVE_STRUCT_STAT_ST_ATIMENSEC +#undef HAVE_STRUCT_STAT_ST_ATIM_ST__TIM_TV_NSEC + +/* Characteristics of definitions in the system header files. */ + +#undef HAVE_GETPW_DECLS + +#undef HAVE_RESOURCE + +#undef HAVE_LIBC_FNM_EXTMATCH + +/* Define if you have and it defines AUDIT_USER_TTY */ +#undef HAVE_DECL_AUDIT_USER_TTY + +#undef HAVE_DECL_CONFSTR + +#undef HAVE_DECL_PRINTF + +#undef HAVE_DECL_SBRK + +#undef HAVE_DECL_STRCPY + +#undef HAVE_DECL_STRSIGNAL + +#undef HAVE_DECL_STRTOLD + +#undef PRI_MACROS_BROKEN + +#undef STRTOLD_BROKEN + +/* Define if WCONTINUED is defined in system headers, but rejected by waitpid */ +#undef WCONTINUED_BROKEN + +/* These are checked with BASH_CHECK_DECL */ + +#undef HAVE_DECL_STRTOIMAX +#undef HAVE_DECL_STRTOL +#undef HAVE_DECL_STRTOLL +#undef HAVE_DECL_STRTOUL +#undef HAVE_DECL_STRTOULL +#undef HAVE_DECL_STRTOUMAX + +/* Characteristics of system calls and C library functions. */ + +/* Define if the `getpgrp' function takes no argument. */ +#undef GETPGRP_VOID + +#undef NAMED_PIPES_MISSING + +#undef OPENDIR_NOT_ROBUST + +#undef PGRP_PIPE + +/* Define if the setvbuf function takes the buffering type as its second + argument and the buffer pointer as the third, as on System V + before release 3. */ +#undef SETVBUF_REVERSED + +#undef STAT_MACROS_BROKEN + +#undef ULIMIT_MAXFDS + +#undef CAN_REDEFINE_GETENV + +#undef HAVE_STD_PUTENV + +#undef HAVE_STD_UNSETENV + +#undef HAVE_PRINTF_A_FORMAT + +#undef CTYPE_NON_ASCII + +/* Define if you have and nl_langinfo(CODESET). */ +#undef HAVE_LANGINFO_CODESET + +/* Characteristics of properties exported by the kernel. */ + +/* Define if the kernel can exec files beginning with #! */ +#undef HAVE_HASH_BANG_EXEC + +/* Define if you have the /dev/fd devices to map open files into the file system. */ +#undef HAVE_DEV_FD + +/* Defined to /dev/fd or /proc/self/fd (linux). */ +#undef DEV_FD_PREFIX + +/* Define if you have the /dev/stdin device. */ +#undef HAVE_DEV_STDIN + +/* The type of iconv's `inbuf' argument */ +#undef ICONV_CONST + +/* Type and behavior of signal handling functions. */ + +/* Define as the return type of signal handlers (int or void). */ +#undef RETSIGTYPE + +/* Define if return type of signal handlers is void */ +#undef VOID_SIGHANDLER + +#undef MUST_REINSTALL_SIGHANDLERS + +#undef HAVE_BSD_SIGNALS + +#undef HAVE_POSIX_SIGNALS + +#undef HAVE_USG_SIGHOLD + +#undef UNUSABLE_RT_SIGNALS + +/* Presence of system and C library functions. */ + +/* Define if you have the asprintf function. */ +#undef HAVE_ASPRINTF + +/* Define if you have the bcopy function. */ +#undef HAVE_BCOPY + +/* Define if you have the bzero function. */ +#undef HAVE_BZERO + +/* Define if you have the chown function. */ +#undef HAVE_CHOWN + +/* Define if you have the confstr function. */ +#undef HAVE_CONFSTR + +/* Define if you have the dlclose function. */ +#undef HAVE_DLCLOSE + +/* Define if you have the dlopen function. */ +#undef HAVE_DLOPEN + +/* Define if you have the dlsym function. */ +#undef HAVE_DLSYM + +/* Define if you don't have vprintf but do have _doprnt. */ +#undef HAVE_DOPRNT + +/* Define if you have the dprintf function. */ +#undef HAVE_DPRINTF + +/* Define if you have the dup2 function. */ +#undef HAVE_DUP2 + +/* Define if you have the eaccess function. */ +#undef HAVE_EACCESS + +/* Define if you have the faccessat function. */ +#undef HAVE_FACCESSAT + +/* Define if you have the fcntl function. */ +#undef HAVE_FCNTL + +/* Define if you have the fpurge/__fpurge function. */ +#undef HAVE_FPURGE +#undef HAVE___FPURGE +#undef HAVE_DECL_FPURGE + +/* Define if you have the getaddrinfo function. */ +#undef HAVE_GETADDRINFO + +/* Define if you have the getcwd function. */ +#undef HAVE_GETCWD + +/* Define if you have the getdtablesize function. */ +#undef HAVE_GETDTABLESIZE + +/* Define if you have the getgroups function. */ +#undef HAVE_GETGROUPS + +/* Define if you have the gethostbyname function. */ +#undef HAVE_GETHOSTBYNAME + +/* Define if you have the gethostname function. */ +#undef HAVE_GETHOSTNAME + +/* Define if you have the getpagesize function. */ +#undef HAVE_GETPAGESIZE + +/* Define if you have the getpeername function. */ +#undef HAVE_GETPEERNAME + +/* Define if you have the getpwent function. */ +#undef HAVE_GETPWENT + +/* Define if you have the getpwnam function. */ +#undef HAVE_GETPWNAM + +/* Define if you have the getpwuid function. */ +#undef HAVE_GETPWUID + +/* Define if you have the getrlimit function. */ +#undef HAVE_GETRLIMIT + +/* Define if you have the getrusage function. */ +#undef HAVE_GETRUSAGE + +/* Define if you have the getservbyname function. */ +#undef HAVE_GETSERVBYNAME + +/* Define if you have the getservent function. */ +#undef HAVE_GETSERVENT + +/* Define if you have the gettimeofday function. */ +#undef HAVE_GETTIMEOFDAY + +/* Define if you have the getwd function. */ +#undef HAVE_GETWD + +/* Define if you have the iconv function. */ +#undef HAVE_ICONV + +/* Define if you have the imaxdiv function. */ +#undef HAVE_IMAXDIV + +/* Define if you have the inet_aton function. */ +#undef HAVE_INET_ATON + +/* Define if you have the isascii function. */ +#undef HAVE_ISASCII + +/* Define if you have the isblank function. */ +#undef HAVE_ISBLANK + +/* Define if you have the isgraph function. */ +#undef HAVE_ISGRAPH + +/* Define if you have the isprint function. */ +#undef HAVE_ISPRINT + +/* Define if you have the isspace function. */ +#undef HAVE_ISSPACE + +/* Define if you have the iswctype function. */ +#undef HAVE_ISWCTYPE + +/* Define if you have the iswlower function. */ +#undef HAVE_ISWLOWER + +/* Define if you have the iswupper function. */ +#undef HAVE_ISWUPPER + +/* Define if you have the isxdigit function. */ +#undef HAVE_ISXDIGIT + +/* Define if you have the kill function. */ +#undef HAVE_KILL + +/* Define if you have the killpg function. */ +#undef HAVE_KILLPG + +/* Define if you have the lstat function. */ +#undef HAVE_LSTAT + +/* Define if you have the locale_charset function. */ +#undef HAVE_LOCALE_CHARSET + +/* Define if you have the mbrlen function. */ +#undef HAVE_MBRLEN + +/* Define if you have the mbrtowc function. */ +#undef HAVE_MBRTOWC + +/* Define if you have the mbscasecmp function. */ +#undef HAVE_MBSCASECMP + +/* Define if you have the mbschr function. */ +#undef HAVE_MBSCHR + +/* Define if you have the mbscmp function. */ +#undef HAVE_MBSCMP + +/* Define if you have the mbsnrtowcs function. */ +#undef HAVE_MBSNRTOWCS + +/* Define if you have the mbsrtowcs function. */ +#undef HAVE_MBSRTOWCS + +/* Define if you have the memmove function. */ +#undef HAVE_MEMMOVE + +/* Define if you have the memset function. */ +#undef HAVE_MEMSET + +/* Define if you have the mkfifo function. */ +#undef HAVE_MKFIFO + +/* Define if you have the mkstemp function. */ +#undef HAVE_MKSTEMP + +/* Define if you have the pathconf function. */ +#undef HAVE_PATHCONF + +/* Define if you have the pselect function. */ +#undef HAVE_PSELECT + +/* Define if you have the putenv function. */ +#undef HAVE_PUTENV + +/* Define if you have the raise function. */ +#undef HAVE_RAISE + +/* Define if you have the random function. */ +#undef HAVE_RANDOM + +/* Define if you have the readlink function. */ +#undef HAVE_READLINK + +/* Define if you have the regcomp function. */ +#undef HAVE_REGCOMP + +/* Define if you have the regexec function. */ +#undef HAVE_REGEXEC + +/* Define if you have the rename function. */ +#undef HAVE_RENAME + +/* Define if you have the sbrk function. */ +#undef HAVE_SBRK + +/* Define if you have the select function. */ +#undef HAVE_SELECT + +/* Define if you have the setdtablesize function. */ +#undef HAVE_SETDTABLESIZE + +/* Define if you have the setenv function. */ +#undef HAVE_SETENV + +/* Define if you have the setitimer function. */ +#undef HAVE_SETITIMER + +/* Define if you have the setlinebuf function. */ +#undef HAVE_SETLINEBUF + +/* Define if you have the setlocale function. */ +#undef HAVE_SETLOCALE + +/* Define if you have the setostype function. */ +#undef HAVE_SETOSTYPE + +/* Define if you have the setregid function. */ +#undef HAVE_SETREGID +#undef HAVE_DECL_SETREGID + +/* Define if you have the setvbuf function. */ +#undef HAVE_SETVBUF + +/* Define if you have the siginterrupt function. */ +#undef HAVE_SIGINTERRUPT + +/* Define if you have the POSIX.1-style sigsetjmp function. */ +#undef HAVE_POSIX_SIGSETJMP + +/* Define if you have the snprintf function. */ +#undef HAVE_SNPRINTF + +/* Define if you have the strcasecmp function. */ +#undef HAVE_STRCASECMP + +/* Define if you have the strcasestr function. */ +#undef HAVE_STRCASESTR + +/* Define if you have the strchr function. */ +#undef HAVE_STRCHR + +/* Define if you have the strchrnul function. */ +#undef HAVE_STRCHRNUL + +/* Define if you have the strcoll function. */ +#undef HAVE_STRCOLL + +/* Define if you have the strerror function. */ +#undef HAVE_STRERROR + +/* Define if you have the strftime function. */ +#undef HAVE_STRFTIME + +/* Define if you have the strnlen function. */ +#undef HAVE_STRNLEN + +/* Define if you have the strpbrk function. */ +#undef HAVE_STRPBRK + +/* Define if you have the strstr function. */ +#undef HAVE_STRSTR + +/* Define if you have the strtod function. */ +#undef HAVE_STRTOD + +/* Define if you have the strtoimax function. */ +#undef HAVE_STRTOIMAX + +/* Define if you have the strtol function. */ +#undef HAVE_STRTOL + +/* Define if you have the strtoll function. */ +#undef HAVE_STRTOLL + +/* Define if you have the strtoul function. */ +#undef HAVE_STRTOUL + +/* Define if you have the strtoull function. */ +#undef HAVE_STRTOULL + +/* Define if you have the strtoumax function. */ +#undef HAVE_STRTOUMAX + +/* Define if you have the strsignal function or macro. */ +#undef HAVE_STRSIGNAL + +/* Define if you have the sysconf function. */ +#undef HAVE_SYSCONF + +/* Define if you have the syslog function. */ +#undef HAVE_SYSLOG + +/* Define if you have the tcgetattr function. */ +#undef HAVE_TCGETATTR + +/* Define if you have the tcgetpgrp function. */ +#undef HAVE_TCGETPGRP + +/* Define if you have the times function. */ +#undef HAVE_TIMES + +/* Define if you have the towlower function. */ +#undef HAVE_TOWLOWER + +/* Define if you have the towupper function. */ +#undef HAVE_TOWUPPER + +/* Define if you have the ttyname function. */ +#undef HAVE_TTYNAME + +/* Define if you have the tzset function. */ +#undef HAVE_TZSET + +/* Define if you have the ulimit function. */ +#undef HAVE_ULIMIT + +/* Define if you have the uname function. */ +#undef HAVE_UNAME + +/* Define if you have the unsetenv function. */ +#undef HAVE_UNSETENV + +/* Define if you have the vasprintf function. */ +#undef HAVE_VASPRINTF + +/* Define if you have the vprintf function. */ +#undef HAVE_VPRINTF + +/* Define if you have the vsnprintf function. */ +#undef HAVE_VSNPRINTF + +/* Define if you have the waitpid function. */ +#undef HAVE_WAITPID + +/* Define if you have the wait3 function. */ +#undef HAVE_WAIT3 + +/* Define if you have the wcrtomb function. */ +#undef HAVE_WCRTOMB + +/* Define if you have the wcscoll function. */ +#undef HAVE_WCSCOLL + +/* Define if you have the wcsdup function. */ +#undef HAVE_WCSDUP + +/* Define if you have the wctype function. */ +#undef HAVE_WCTYPE + +/* Define if you have the wcswidth function. */ +#undef HAVE_WCSWIDTH + +/* Define if you have the wcwidth function. */ +#undef HAVE_WCWIDTH + +/* and if it works */ +#undef WCWIDTH_BROKEN + +/* Presence of certain system include files. */ + +/* Define if you have the header file. */ +#undef HAVE_ARPA_INET_H + +/* Define if you have the header file. */ +#undef HAVE_DIRENT_H + +/* Define if you have the header file. */ +#undef HAVE_DLFCN_H + +/* Define if you have the header file. */ +#undef HAVE_GRP_H + +/* Define if you have the header file. */ +#undef HAVE_INTTYPES_H + +/* Define if you have the header file. */ +#undef HAVE_LANGINFO_H + +/* Define if you have the header file. */ +#undef HAVE_LIBAUDIT_H + +/* Define if you have the header file. */ +#undef HAVE_LIBINTL_H + +/* Define if you have the header file. */ +#undef HAVE_LIMITS_H + +/* Define if you have the header file. */ +#undef HAVE_LOCALE_H + +/* Define if you have the header file. */ +#undef HAVE_MBSTR_H + +/* Define if you have the header file. */ +#undef HAVE_NDIR_H + +/* Define if you have the header file. */ +#undef HAVE_NETDB_H + +/* Define if you have the header file. */ +#undef HAVE_NETINET_IN_H + +/* Define if you have the header file. */ +#undef HAVE_PWD_H + +/* Define if you have the header file. */ +#undef HAVE_REGEX_H + +/* Define if you have the header file. */ +#undef HAVE_STDLIB_H + +/* Define if you have the header file. */ +#undef HAVE_STDARG_H + +/* Define if you have the header file. */ +#undef HAVE_STRING_H + +/* Define if you have the header file. */ +#undef HAVE_STRINGS_H + +/* Define if you have the header file. */ +#undef HAVE_MEMORY_H + +/* Define if you have the header file. */ +#undef HAVE_STDBOOL_H + +/* Define if you have the header file. */ +#undef HAVE_STDDEF_H + +/* Define if you have the header file. */ +#undef HAVE_STDINT_H + +/* Define if you have the header file. */ +#undef HAVE_SYSLOG_H + +/* Define if you have the header file. */ +#undef HAVE_SYS_DIR_H + +/* Define if you have the header file. */ +#undef HAVE_SYS_FILE_H + +/* Define if you have the header file. */ +#undef HAVE_SYS_IOCTL_H + +/* Define if you have the header file. */ +#undef HAVE_SYS_NDIR_H + +/* Define if you have the header file. */ +#undef HAVE_SYS_PARAM_H + +/* Define if you have the header file. */ +#undef HAVE_SYS_PTE_H + +/* Define if you have the header file. */ +#undef HAVE_SYS_PTEM_H + +/* Define if you have the header file. */ +#undef HAVE_SYS_RESOURCE_H + +/* Define if you have the header file. */ +#undef HAVE_SYS_SELECT_H + +/* Define if you have the header file. */ +#undef HAVE_SYS_SOCKET_H + +/* Define if you have the header file. */ +#undef HAVE_SYS_STAT_H + +/* Define if you have the header file. */ +#undef HAVE_SYS_STREAM_H + +/* Define if you have */ +#undef HAVE_SYS_TIME_H + +#undef TIME_WITH_SYS_TIME + +/* Define if you have */ +#undef HAVE_SYS_TIMES_H + +/* Define if you have the header file. */ +#undef HAVE_SYS_TYPES_H + +/* Define if you have that is POSIX.1 compatible. */ +#undef HAVE_SYS_WAIT_H + +/* Define if you have the header file. */ +#undef HAVE_TERMCAP_H + +/* Define if you have the header file. */ +#undef HAVE_TERMIO_H + +/* Define if you have the header file. */ +#undef HAVE_TERMIOS_H + +/* Define if you have the header file. */ +#undef HAVE_ULIMIT_H + +/* Define if you have the header file. */ +#undef HAVE_UNISTD_H + +/* Define if you have the header file. */ +#undef HAVE_VARARGS_H + +/* Define if you have the header file. */ +#undef HAVE_WCHAR_H + +/* Define if you have the header file. */ +#undef HAVE_WCTYPE_H + +/* Presence of certain system libraries. */ + +#undef HAVE_LIBDL + +#undef HAVE_LIBSUN + +#undef HAVE_LIBSOCKET + +/* Are we running the GNU C library, version 2.1 or later? */ +#undef GLIBC21 + +/* Are we running SVR5 (UnixWare 7)? */ +#undef SVR5 + +/* Are we running SVR4.2? */ +#undef SVR4_2 + +/* Are we running some version of SVR4? */ +#undef SVR4 + +/* Define if job control is unusable or unsupported. */ +#undef JOB_CONTROL_MISSING + +/* Do we need to define _KERNEL to get the RLIMIT_* defines from + ? */ +#undef RLIMIT_NEEDS_KERNEL + +/* Number of bits in a file offset, on hosts where this is settable. */ +#undef _FILE_OFFSET_BITS + +/* Define for large files on AIX-style hosts. */ +#undef _LARGE_FILES + +/* Do strcoll(3) and strcmp(3) give different results in the default locale? */ +#undef STRCOLL_BROKEN + +#undef DUP2_BROKEN + +#undef GETCWD_BROKEN + +/* Additional defines for configuring lib/intl, maintained by autoscan/autoheader */ + +/* Define if you have the header file. */ +#undef HAVE_ARGZ_H + +/* Define if you have the header file. */ +#undef HAVE_ERRNO_H + +/* Define if you have the header file. */ +#undef HAVE_FCNTL_H + +/* Define if you have the header file. */ +#undef HAVE_MALLOC_H + +/* Define if you have the header file. */ +#undef HAVE_STDIO_EXT_H + +/* Define if you have the `dcgettext' function. */ +#undef HAVE_DCGETTEXT + +/* Define if you have the `localeconv' function. */ +#undef HAVE_LOCALECONV + +/* Define if your system has a working `malloc' function. */ +/* #undef HAVE_MALLOC */ + +/* Define if you have the `mempcpy' function. */ +#undef HAVE_MEMPCPY + +/* Define if you have a working `mmap' system call. */ +#undef HAVE_MMAP + +/* Define if you have the `munmap' function. */ +#undef HAVE_MUNMAP + +/* Define if you have the `nl_langinfo' function. */ +#undef HAVE_NL_LANGINFO + +/* Define if you have the `stpcpy' function. */ +#undef HAVE_STPCPY + +/* Define if you have the `strcspn' function. */ +#undef HAVE_STRCSPN + +/* Define if you have the `strdup' function. */ +#undef HAVE_STRDUP + +/* Define if you have the `__argz_count' function. */ +#undef HAVE___ARGZ_COUNT + +/* Define if you have the `__argz_next' function. */ +#undef HAVE___ARGZ_NEXT + +/* Define if you have the `__argz_stringify' function. */ +#undef HAVE___ARGZ_STRINGIFY + +/* End additions for lib/intl */ + +#include "config-bot.h" + +#endif /* _CONFIG_H_ */ diff --git a/configure b/configure new file mode 100755 index 0000000..60f86d6 --- /dev/null +++ b/configure @@ -0,0 +1,17623 @@ +#! /bin/sh +# From configure.ac for Bash 4.4, version 4.082. +# Guess values for system-dependent variables and create Makefiles. +# Generated by GNU Autoconf 2.69 for bash 4.4-release. +# +# Report bugs to . +# +# +# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. +# +# +# This configure script is free software; the Free Software Foundation +# gives unlimited permission to copy, distribute and modify it. +## -------------------- ## +## M4sh Initialization. ## +## -------------------- ## + +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi + + +as_nl=' +' +export as_nl +# Printing a long string crashes Solaris 7 /usr/bin/printf. +as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo +# Prefer a ksh shell builtin over an external printf program on Solaris, +# but without wasting forks for bash or zsh. +if test -z "$BASH_VERSION$ZSH_VERSION" \ + && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='print -r --' + as_echo_n='print -rn --' +elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='printf %s\n' + as_echo_n='printf %s' +else + if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then + as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' + as_echo_n='/usr/ucb/echo -n' + else + as_echo_body='eval expr "X$1" : "X\\(.*\\)"' + as_echo_n_body='eval + arg=$1; + case $arg in #( + *"$as_nl"*) + expr "X$arg" : "X\\(.*\\)$as_nl"; + arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; + esac; + expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" + ' + export as_echo_n_body + as_echo_n='sh -c $as_echo_n_body as_echo' + fi + export as_echo_body + as_echo='sh -c $as_echo_body as_echo' +fi + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { + (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || + PATH_SEPARATOR=';' + } +fi + + +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +as_myself= +case $0 in #(( + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break + done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + exit 1 +fi + +# Unset variables that we do not need and which cause bugs (e.g. in +# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" +# suppresses any "Segmentation fault" message there. '((' could +# trigger a bug in pdksh 5.2.14. +for as_var in BASH_ENV ENV MAIL MAILPATH +do eval test x\${$as_var+set} = xset \ + && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : +done +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +LC_ALL=C +export LC_ALL +LANGUAGE=C +export LANGUAGE + +# CDPATH. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +# Use a proper internal environment variable to ensure we don't fall + # into an infinite loop, continuously re-executing ourselves. + if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then + _as_can_reexec=no; export _as_can_reexec; + # We cannot yet assume a decent shell, so we have to provide a +# neutralization value for shells without unset; and this also +# works around shells that cannot unset nonexistent variables. +# Preserve -v and -x to the replacement shell. +BASH_ENV=/dev/null +ENV=/dev/null +(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV +case $- in # (((( + *v*x* | *x*v* ) as_opts=-vx ;; + *v* ) as_opts=-v ;; + *x* ) as_opts=-x ;; + * ) as_opts= ;; +esac +exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} +# Admittedly, this is quite paranoid, since all the known shells bail +# out after a failed `exec'. +$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 +as_fn_exit 255 + fi + # We don't want this to propagate to other subprocesses. + { _as_can_reexec=; unset _as_can_reexec;} +if test "x$CONFIG_SHELL" = x; then + as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which + # is contrary to our usage. Disable this feature. + alias -g '\${1+\"\$@\"}'='\"\$@\"' + setopt NO_GLOB_SUBST +else + case \`(set -o) 2>/dev/null\` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi +" + as_required="as_fn_return () { (exit \$1); } +as_fn_success () { as_fn_return 0; } +as_fn_failure () { as_fn_return 1; } +as_fn_ret_success () { return 0; } +as_fn_ret_failure () { return 1; } + +exitcode=0 +as_fn_success || { exitcode=1; echo as_fn_success failed.; } +as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } +as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } +as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } +if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : + +else + exitcode=1; echo positional parameters were not saved. +fi +test x\$exitcode = x0 || exit 1 +test -x / || exit 1" + as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO + as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO + eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && + test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 +test \$(( 1 + 1 )) = 2 || exit 1" + if (eval "$as_required") 2>/dev/null; then : + as_have_required=yes +else + as_have_required=no +fi + if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : + +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +as_found=false +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + as_found=: + case $as_dir in #( + /*) + for as_base in sh bash ksh sh5; do + # Try only shells that exist, to save several forks. + as_shell=$as_dir/$as_base + if { test -f "$as_shell" || test -f "$as_shell.exe"; } && + { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : + CONFIG_SHELL=$as_shell as_have_required=yes + if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : + break 2 +fi +fi + done;; + esac + as_found=false +done +$as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && + { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : + CONFIG_SHELL=$SHELL as_have_required=yes +fi; } +IFS=$as_save_IFS + + + if test "x$CONFIG_SHELL" != x; then : + export CONFIG_SHELL + # We cannot yet assume a decent shell, so we have to provide a +# neutralization value for shells without unset; and this also +# works around shells that cannot unset nonexistent variables. +# Preserve -v and -x to the replacement shell. +BASH_ENV=/dev/null +ENV=/dev/null +(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV +case $- in # (((( + *v*x* | *x*v* ) as_opts=-vx ;; + *v* ) as_opts=-v ;; + *x* ) as_opts=-x ;; + * ) as_opts= ;; +esac +exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} +# Admittedly, this is quite paranoid, since all the known shells bail +# out after a failed `exec'. +$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 +exit 255 +fi + + if test x$as_have_required = xno; then : + $as_echo "$0: This script requires a shell more modern than all" + $as_echo "$0: the shells that I found on your system." + if test x${ZSH_VERSION+set} = xset ; then + $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" + $as_echo "$0: be upgraded to zsh 4.3.4 or later." + else + $as_echo "$0: Please tell bug-autoconf@gnu.org and bug-bash@gnu.org +$0: about your system, including any error possibly output +$0: before this message. Then install a modern shell, or +$0: manually run the script under such a shell if you do +$0: have one." + fi + exit 1 +fi +fi +fi +SHELL=${CONFIG_SHELL-/bin/sh} +export SHELL +# Unset more variables known to interfere with behavior of common tools. +CLICOLOR_FORCE= GREP_OPTIONS= +unset CLICOLOR_FORCE GREP_OPTIONS + +## --------------------- ## +## M4sh Shell Functions. ## +## --------------------- ## +# as_fn_unset VAR +# --------------- +# Portably unset VAR. +as_fn_unset () +{ + { eval $1=; unset $1;} +} +as_unset=as_fn_unset + +# as_fn_set_status STATUS +# ----------------------- +# Set $? to STATUS, without forking. +as_fn_set_status () +{ + return $1 +} # as_fn_set_status + +# as_fn_exit STATUS +# ----------------- +# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. +as_fn_exit () +{ + set +e + as_fn_set_status $1 + exit $1 +} # as_fn_exit + +# as_fn_mkdir_p +# ------------- +# Create "$as_dir" as a directory, including parents if necessary. +as_fn_mkdir_p () +{ + + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || eval $as_mkdir_p || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" + + +} # as_fn_mkdir_p + +# as_fn_executable_p FILE +# ----------------------- +# Test if FILE is an executable regular file. +as_fn_executable_p () +{ + test -f "$1" && test -x "$1" +} # as_fn_executable_p +# as_fn_append VAR VALUE +# ---------------------- +# Append the text in VALUE to the end of the definition contained in VAR. Take +# advantage of any shell optimizations that allow amortized linear growth over +# repeated appends, instead of the typical quadratic growth present in naive +# implementations. +if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : + eval 'as_fn_append () + { + eval $1+=\$2 + }' +else + as_fn_append () + { + eval $1=\$$1\$2 + } +fi # as_fn_append + +# as_fn_arith ARG... +# ------------------ +# Perform arithmetic evaluation on the ARGs, and store the result in the +# global $as_val. Take advantage of shells that can avoid forks. The arguments +# must be portable across $(()) and expr. +if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : + eval 'as_fn_arith () + { + as_val=$(( $* )) + }' +else + as_fn_arith () + { + as_val=`expr "$@" || test $? -eq 1` + } +fi # as_fn_arith + + +# as_fn_error STATUS ERROR [LINENO LOG_FD] +# ---------------------------------------- +# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are +# provided, also output the error to LOG_FD, referencing LINENO. Then exit the +# script with STATUS, using 1 if that was 0. +as_fn_error () +{ + as_status=$1; test $as_status -eq 0 && as_status=1 + if test "$4"; then + as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 + fi + $as_echo "$as_me: error: $2" >&2 + as_fn_exit $as_status +} # as_fn_error + +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + + + as_lineno_1=$LINENO as_lineno_1a=$LINENO + as_lineno_2=$LINENO as_lineno_2a=$LINENO + eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && + test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { + # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) + sed -n ' + p + /[$]LINENO/= + ' <$as_myself | + sed ' + s/[$]LINENO.*/&-/ + t lineno + b + :lineno + N + :loop + s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ + t loop + s/-\n.*// + ' >$as_me.lineno && + chmod +x "$as_me.lineno" || + { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } + + # If we had to re-execute with $CONFIG_SHELL, we're ensured to have + # already done that, so ensure we don't try to do so again and fall + # in an infinite loop. This has already happened in practice. + _as_can_reexec=no; export _as_can_reexec + # Don't try to exec as it changes $[0], causing all sort of problems + # (the dirname of $[0] is not the place where we might find the + # original and so on. Autoconf is especially sensitive to this). + . "./$as_me.lineno" + # Exit status is that of the last command. + exit +} + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in #((((( +-n*) + case `echo 'xy\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + xy) ECHO_C='\c';; + *) echo `echo ksh88 bug on AIX 6.1` > /dev/null + ECHO_T=' ';; + esac;; +*) + ECHO_N='-n';; +esac + +rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir 2>/dev/null +fi +if (echo >conf$$.file) 2>/dev/null; then + if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -pR'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -pR' + elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln + else + as_ln_s='cp -pR' + fi +else + as_ln_s='cp -pR' +fi +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null + +if mkdir -p . 2>/dev/null; then + as_mkdir_p='mkdir -p "$as_dir"' +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + +as_test_x='test -x' +as_executable_p=as_fn_executable_p + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + +test -n "$DJDIR" || exec 7<&0 &1 + +# Name of the host. +# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, +# so uname gets run too. +ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` + +# +# Initializations. +# +ac_default_prefix=/usr/local +ac_clean_files= +ac_config_libobj_dir=. +LIBOBJS= +cross_compiling=no +subdirs= +MFLAGS= +MAKEFLAGS= + +# Identity of this package. +PACKAGE_NAME='bash' +PACKAGE_TARNAME='bash' +PACKAGE_VERSION='4.4-release' +PACKAGE_STRING='bash 4.4-release' +PACKAGE_BUGREPORT='bug-bash@gnu.org' +PACKAGE_URL='' + +ac_unique_file="shell.h" +# Factoring default headers for most tests. +ac_includes_default="\ +#include +#ifdef HAVE_SYS_TYPES_H +# include +#endif +#ifdef HAVE_SYS_STAT_H +# include +#endif +#ifdef STDC_HEADERS +# include +# include +#else +# ifdef HAVE_STDLIB_H +# include +# endif +#endif +#ifdef HAVE_STRING_H +# if !defined STDC_HEADERS && defined HAVE_MEMORY_H +# include +# endif +# include +#endif +#ifdef HAVE_STRINGS_H +# include +#endif +#ifdef HAVE_INTTYPES_H +# include +#endif +#ifdef HAVE_STDINT_H +# include +#endif +#ifdef HAVE_UNISTD_H +# include +#endif" + +ac_header_list= +ac_func_list= +ac_subst_vars='LTLIBOBJS +LOCAL_DEFS +LOCAL_LDFLAGS +LOCAL_CFLAGS +LOCAL_LIBS +MALLOC_DEBUG +DEBUG +RELSTATUS +BASHVERS +ARFLAGS +headersdir +loadablesdir +BUILD_DIR +incdir +PROFILE_FLAGS +SHOBJ_STATUS +SHOBJ_LIBS +SHOBJ_XLDFLAGS +SHOBJ_LDFLAGS +SHOBJ_LD +SHOBJ_CFLAGS +SHOBJ_CC +JOBS_O +TERMCAP_DEP +TERMCAP_LIB +SIGLIST_O +PTHREAD_H_DEFINES_STRUCT_TIMESPEC +SYS_TIME_H_DEFINES_STRUCT_TIMESPEC +TIME_H_DEFINES_STRUCT_TIMESPEC +LIBINTL_H +INTL_INC +INTL_DEP +LIBOBJS +POSUB +LTLIBINTL +LIBINTL +INTLLIBS +INTL_LIBTOOL_SUFFIX_PREFIX +INTLOBJS +GENCAT +INSTOBJEXT +DATADIRNAME +CATOBJEXT +USE_INCLUDED_LIBINTL +BUILD_INCLUDED_LIBINTL +INTLBISON +LTLIBICONV +LIBICONV +GLIBC21 +ALLOCA +MSGMERGE +XGETTEXT +GMSGFMT +MSGFMT +USE_NLS +MKINSTALLDIRS +SIZE +MAKE_SHELL +SET_MAKE +YFLAGS +YACC +RANLIB +AR +INSTALL_DATA +INSTALL_SCRIPT +INSTALL_PROGRAM +TILDE_LIB +HIST_LIBDIR +HISTORY_DEP +HISTORY_LIB +RL_INCLUDE +RL_INCLUDEDIR +RL_LIBDIR +READLINE_DEP +READLINE_LIB +RL_MINOR +RL_MAJOR +RL_VERSION +LIBS_FOR_BUILD +STATIC_LD +SIGNAMES_O +SIGNAMES_H +CROSS_COMPILE +EGREP +GREP +CPP +OBJEXT +EXEEXT +ac_ct_CC +CPPFLAGS +LDFLAGS +CFLAGS +CC +HELPSTRINGS +HELPFILES_TARGET +HELPINSTALL +HELPDIRDEFINE +HELPDIR +MALLOC_DEP +MALLOC_LDFLAGS +MALLOC_LIBRARY +MALLOC_LIB +MALLOC_SRC +MALLOC_TARGET +TESTSCRIPT +CPPFLAGS_FOR_BUILD +LDFLAGS_FOR_BUILD +CFLAGS_FOR_BUILD +CC_FOR_BUILD +DEBUGGER_START_FILE +host_os +host_vendor +host_cpu +host +build_os +build_vendor +build_cpu +build +target_alias +host_alias +build_alias +LIBS +ECHO_T +ECHO_N +ECHO_C +DEFS +mandir +localedir +libdir +psdir +pdfdir +dvidir +htmldir +infodir +docdir +oldincludedir +includedir +localstatedir +sharedstatedir +sysconfdir +datadir +datarootdir +libexecdir +sbindir +bindir +program_transform_name +prefix +exec_prefix +PACKAGE_URL +PACKAGE_BUGREPORT +PACKAGE_STRING +PACKAGE_VERSION +PACKAGE_TARNAME +PACKAGE_NAME +PATH_SEPARATOR +SHELL' +ac_subst_files='' +ac_user_opts=' +enable_option_checking +with_afs +with_bash_malloc +with_curses +with_gnu_malloc +with_installed_readline +enable_minimal_config +enable_alias +enable_arith_for_command +enable_array_variables +enable_bang_history +enable_brace_expansion +enable_casemod_attributes +enable_casemod_expansions +enable_command_timing +enable_cond_command +enable_cond_regexp +enable_coprocesses +enable_debugger +enable_direxpand_default +enable_directory_stack +enable_disabled_builtins +enable_dparen_arithmetic +enable_extended_glob +enable_extended_glob_default +enable_function_import +enable_glob_asciiranges_default +enable_help_builtin +enable_history +enable_job_control +enable_multibyte +enable_net_redirections +enable_process_substitution +enable_progcomp +enable_prompt_string_decoding +enable_readline +enable_restricted +enable_select +enable_separate_helpfiles +enable_single_help_strings +enable_strict_posix_default +enable_usg_echo_default +enable_xpg_echo_default +enable_mem_scramble +enable_profiling +enable_static_link +enable_largefile +enable_nls +with_gnu_ld +enable_rpath +with_libiconv_prefix +with_included_gettext +with_libintl_prefix +' + ac_precious_vars='build_alias +host_alias +target_alias +DEBUGGER_START_FILE +CC_FOR_BUILD +CFLAGS_FOR_BUILD +LDFLAGS_FOR_BUILD +CPPFLAGS_FOR_BUILD +CC +CFLAGS +LDFLAGS +LIBS +CPPFLAGS +CPP +YACC +YFLAGS' + + +# Initialize some variables set by options. +ac_init_help= +ac_init_version=false +ac_unrecognized_opts= +ac_unrecognized_sep= +# The variables have the same names as the options, with +# dashes changed to underlines. +cache_file=/dev/null +exec_prefix=NONE +no_create= +no_recursion= +prefix=NONE +program_prefix=NONE +program_suffix=NONE +program_transform_name=s,x,x, +silent= +site= +srcdir= +verbose= +x_includes=NONE +x_libraries=NONE + +# Installation directory options. +# These are left unexpanded so users can "make install exec_prefix=/foo" +# and all the variables that are supposed to be based on exec_prefix +# by default will actually change. +# Use braces instead of parens because sh, perl, etc. also accept them. +# (The list follows the same order as the GNU Coding Standards.) +bindir='${exec_prefix}/bin' +sbindir='${exec_prefix}/sbin' +libexecdir='${exec_prefix}/libexec' +datarootdir='${prefix}/share' +datadir='${datarootdir}' +sysconfdir='${prefix}/etc' +sharedstatedir='${prefix}/com' +localstatedir='${prefix}/var' +includedir='${prefix}/include' +oldincludedir='/usr/include' +docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' +infodir='${datarootdir}/info' +htmldir='${docdir}' +dvidir='${docdir}' +pdfdir='${docdir}' +psdir='${docdir}' +libdir='${exec_prefix}/lib' +localedir='${datarootdir}/locale' +mandir='${datarootdir}/man' + +ac_prev= +ac_dashdash= +for ac_option +do + # If the previous option needs an argument, assign it. + if test -n "$ac_prev"; then + eval $ac_prev=\$ac_option + ac_prev= + continue + fi + + case $ac_option in + *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; + *=) ac_optarg= ;; + *) ac_optarg=yes ;; + esac + + # Accept the important Cygnus configure options, so we can diagnose typos. + + case $ac_dashdash$ac_option in + --) + ac_dashdash=yes ;; + + -bindir | --bindir | --bindi | --bind | --bin | --bi) + ac_prev=bindir ;; + -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) + bindir=$ac_optarg ;; + + -build | --build | --buil | --bui | --bu) + ac_prev=build_alias ;; + -build=* | --build=* | --buil=* | --bui=* | --bu=*) + build_alias=$ac_optarg ;; + + -cache-file | --cache-file | --cache-fil | --cache-fi \ + | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) + ac_prev=cache_file ;; + -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ + | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) + cache_file=$ac_optarg ;; + + --config-cache | -C) + cache_file=config.cache ;; + + -datadir | --datadir | --datadi | --datad) + ac_prev=datadir ;; + -datadir=* | --datadir=* | --datadi=* | --datad=*) + datadir=$ac_optarg ;; + + -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ + | --dataroo | --dataro | --datar) + ac_prev=datarootdir ;; + -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ + | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) + datarootdir=$ac_optarg ;; + + -disable-* | --disable-*) + ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid feature name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"enable_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval enable_$ac_useropt=no ;; + + -docdir | --docdir | --docdi | --doc | --do) + ac_prev=docdir ;; + -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) + docdir=$ac_optarg ;; + + -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) + ac_prev=dvidir ;; + -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) + dvidir=$ac_optarg ;; + + -enable-* | --enable-*) + ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid feature name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"enable_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval enable_$ac_useropt=\$ac_optarg ;; + + -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ + | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ + | --exec | --exe | --ex) + ac_prev=exec_prefix ;; + -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ + | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ + | --exec=* | --exe=* | --ex=*) + exec_prefix=$ac_optarg ;; + + -gas | --gas | --ga | --g) + # Obsolete; use --with-gas. + with_gas=yes ;; + + -help | --help | --hel | --he | -h) + ac_init_help=long ;; + -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) + ac_init_help=recursive ;; + -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) + ac_init_help=short ;; + + -host | --host | --hos | --ho) + ac_prev=host_alias ;; + -host=* | --host=* | --hos=* | --ho=*) + host_alias=$ac_optarg ;; + + -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) + ac_prev=htmldir ;; + -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ + | --ht=*) + htmldir=$ac_optarg ;; + + -includedir | --includedir | --includedi | --included | --include \ + | --includ | --inclu | --incl | --inc) + ac_prev=includedir ;; + -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ + | --includ=* | --inclu=* | --incl=* | --inc=*) + includedir=$ac_optarg ;; + + -infodir | --infodir | --infodi | --infod | --info | --inf) + ac_prev=infodir ;; + -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) + infodir=$ac_optarg ;; + + -libdir | --libdir | --libdi | --libd) + ac_prev=libdir ;; + -libdir=* | --libdir=* | --libdi=* | --libd=*) + libdir=$ac_optarg ;; + + -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ + | --libexe | --libex | --libe) + ac_prev=libexecdir ;; + -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ + | --libexe=* | --libex=* | --libe=*) + libexecdir=$ac_optarg ;; + + -localedir | --localedir | --localedi | --localed | --locale) + ac_prev=localedir ;; + -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) + localedir=$ac_optarg ;; + + -localstatedir | --localstatedir | --localstatedi | --localstated \ + | --localstate | --localstat | --localsta | --localst | --locals) + ac_prev=localstatedir ;; + -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ + | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) + localstatedir=$ac_optarg ;; + + -mandir | --mandir | --mandi | --mand | --man | --ma | --m) + ac_prev=mandir ;; + -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) + mandir=$ac_optarg ;; + + -nfp | --nfp | --nf) + # Obsolete; use --without-fp. + with_fp=no ;; + + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c | -n) + no_create=yes ;; + + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) + no_recursion=yes ;; + + -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ + | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ + | --oldin | --oldi | --old | --ol | --o) + ac_prev=oldincludedir ;; + -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ + | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ + | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) + oldincludedir=$ac_optarg ;; + + -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) + ac_prev=prefix ;; + -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) + prefix=$ac_optarg ;; + + -program-prefix | --program-prefix | --program-prefi | --program-pref \ + | --program-pre | --program-pr | --program-p) + ac_prev=program_prefix ;; + -program-prefix=* | --program-prefix=* | --program-prefi=* \ + | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) + program_prefix=$ac_optarg ;; + + -program-suffix | --program-suffix | --program-suffi | --program-suff \ + | --program-suf | --program-su | --program-s) + ac_prev=program_suffix ;; + -program-suffix=* | --program-suffix=* | --program-suffi=* \ + | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) + program_suffix=$ac_optarg ;; + + -program-transform-name | --program-transform-name \ + | --program-transform-nam | --program-transform-na \ + | --program-transform-n | --program-transform- \ + | --program-transform | --program-transfor \ + | --program-transfo | --program-transf \ + | --program-trans | --program-tran \ + | --progr-tra | --program-tr | --program-t) + ac_prev=program_transform_name ;; + -program-transform-name=* | --program-transform-name=* \ + | --program-transform-nam=* | --program-transform-na=* \ + | --program-transform-n=* | --program-transform-=* \ + | --program-transform=* | --program-transfor=* \ + | --program-transfo=* | --program-transf=* \ + | --program-trans=* | --program-tran=* \ + | --progr-tra=* | --program-tr=* | --program-t=*) + program_transform_name=$ac_optarg ;; + + -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) + ac_prev=pdfdir ;; + -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) + pdfdir=$ac_optarg ;; + + -psdir | --psdir | --psdi | --psd | --ps) + ac_prev=psdir ;; + -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) + psdir=$ac_optarg ;; + + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + silent=yes ;; + + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) + ac_prev=sbindir ;; + -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ + | --sbi=* | --sb=*) + sbindir=$ac_optarg ;; + + -sharedstatedir | --sharedstatedir | --sharedstatedi \ + | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ + | --sharedst | --shareds | --shared | --share | --shar \ + | --sha | --sh) + ac_prev=sharedstatedir ;; + -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ + | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ + | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ + | --sha=* | --sh=*) + sharedstatedir=$ac_optarg ;; + + -site | --site | --sit) + ac_prev=site ;; + -site=* | --site=* | --sit=*) + site=$ac_optarg ;; + + -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) + ac_prev=srcdir ;; + -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) + srcdir=$ac_optarg ;; + + -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ + | --syscon | --sysco | --sysc | --sys | --sy) + ac_prev=sysconfdir ;; + -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ + | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) + sysconfdir=$ac_optarg ;; + + -target | --target | --targe | --targ | --tar | --ta | --t) + ac_prev=target_alias ;; + -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) + target_alias=$ac_optarg ;; + + -v | -verbose | --verbose | --verbos | --verbo | --verb) + verbose=yes ;; + + -version | --version | --versio | --versi | --vers | -V) + ac_init_version=: ;; + + -with-* | --with-*) + ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid package name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"with_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval with_$ac_useropt=\$ac_optarg ;; + + -without-* | --without-*) + ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid package name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"with_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval with_$ac_useropt=no ;; + + --x) + # Obsolete; use --with-x. + with_x=yes ;; + + -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ + | --x-incl | --x-inc | --x-in | --x-i) + ac_prev=x_includes ;; + -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ + | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) + x_includes=$ac_optarg ;; + + -x-libraries | --x-libraries | --x-librarie | --x-librari \ + | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) + ac_prev=x_libraries ;; + -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ + | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) + x_libraries=$ac_optarg ;; + + -*) as_fn_error $? "unrecognized option: \`$ac_option' +Try \`$0 --help' for more information" + ;; + + *=*) + ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` + # Reject names that are not valid shell variable names. + case $ac_envvar in #( + '' | [0-9]* | *[!_$as_cr_alnum]* ) + as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; + esac + eval $ac_envvar=\$ac_optarg + export $ac_envvar ;; + + *) + # FIXME: should be removed in autoconf 3.0. + $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 + expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && + $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 + : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" + ;; + + esac +done + +if test -n "$ac_prev"; then + ac_option=--`echo $ac_prev | sed 's/_/-/g'` + as_fn_error $? "missing argument to $ac_option" +fi + +if test -n "$ac_unrecognized_opts"; then + case $enable_option_checking in + no) ;; + fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; + *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; + esac +fi + +# Check all directory arguments for consistency. +for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ + datadir sysconfdir sharedstatedir localstatedir includedir \ + oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ + libdir localedir mandir +do + eval ac_val=\$$ac_var + # Remove trailing slashes. + case $ac_val in + */ ) + ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` + eval $ac_var=\$ac_val;; + esac + # Be sure to have absolute directory names. + case $ac_val in + [\\/$]* | ?:[\\/]* ) continue;; + NONE | '' ) case $ac_var in *prefix ) continue;; esac;; + esac + as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" +done + +# There might be people who depend on the old broken behavior: `$host' +# used to hold the argument of --host etc. +# FIXME: To remove some day. +build=$build_alias +host=$host_alias +target=$target_alias + +# FIXME: To remove some day. +if test "x$host_alias" != x; then + if test "x$build_alias" = x; then + cross_compiling=maybe + elif test "x$build_alias" != "x$host_alias"; then + cross_compiling=yes + fi +fi + +ac_tool_prefix= +test -n "$host_alias" && ac_tool_prefix=$host_alias- + +test "$silent" = yes && exec 6>/dev/null + + +ac_pwd=`pwd` && test -n "$ac_pwd" && +ac_ls_di=`ls -di .` && +ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || + as_fn_error $? "working directory cannot be determined" +test "X$ac_ls_di" = "X$ac_pwd_ls_di" || + as_fn_error $? "pwd does not report name of working directory" + + +# Find the source files, if location was not specified. +if test -z "$srcdir"; then + ac_srcdir_defaulted=yes + # Try the directory containing this script, then the parent directory. + ac_confdir=`$as_dirname -- "$as_myself" || +$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_myself" : 'X\(//\)[^/]' \| \ + X"$as_myself" : 'X\(//\)$' \| \ + X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_myself" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + srcdir=$ac_confdir + if test ! -r "$srcdir/$ac_unique_file"; then + srcdir=.. + fi +else + ac_srcdir_defaulted=no +fi +if test ! -r "$srcdir/$ac_unique_file"; then + test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." + as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" +fi +ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" +ac_abs_confdir=`( + cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" + pwd)` +# When building in place, set srcdir=. +if test "$ac_abs_confdir" = "$ac_pwd"; then + srcdir=. +fi +# Remove unnecessary trailing slashes from srcdir. +# Double slashes in file names in object file debugging info +# mess up M-x gdb in Emacs. +case $srcdir in +*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; +esac +for ac_var in $ac_precious_vars; do + eval ac_env_${ac_var}_set=\${${ac_var}+set} + eval ac_env_${ac_var}_value=\$${ac_var} + eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} + eval ac_cv_env_${ac_var}_value=\$${ac_var} +done + +# +# Report the --help message. +# +if test "$ac_init_help" = "long"; then + # Omit some internal or obsolete options to make the list less imposing. + # This message is too long to be a string in the A/UX 3.1 sh. + cat <<_ACEOF +\`configure' configures bash 4.4-release to adapt to many kinds of systems. + +Usage: $0 [OPTION]... [VAR=VALUE]... + +To assign environment variables (e.g., CC, CFLAGS...), specify them as +VAR=VALUE. See below for descriptions of some of the useful variables. + +Defaults for the options are specified in brackets. + +Configuration: + -h, --help display this help and exit + --help=short display options specific to this package + --help=recursive display the short help of all the included packages + -V, --version display version information and exit + -q, --quiet, --silent do not print \`checking ...' messages + --cache-file=FILE cache test results in FILE [disabled] + -C, --config-cache alias for \`--cache-file=config.cache' + -n, --no-create do not create output files + --srcdir=DIR find the sources in DIR [configure dir or \`..'] + +Installation directories: + --prefix=PREFIX install architecture-independent files in PREFIX + [$ac_default_prefix] + --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX + [PREFIX] + +By default, \`make install' will install all the files in +\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify +an installation prefix other than \`$ac_default_prefix' using \`--prefix', +for instance \`--prefix=\$HOME'. + +For better control, use the options below. + +Fine tuning of the installation directories: + --bindir=DIR user executables [EPREFIX/bin] + --sbindir=DIR system admin executables [EPREFIX/sbin] + --libexecdir=DIR program executables [EPREFIX/libexec] + --sysconfdir=DIR read-only single-machine data [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] + --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --libdir=DIR object code libraries [EPREFIX/lib] + --includedir=DIR C header files [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc [/usr/include] + --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] + --datadir=DIR read-only architecture-independent data [DATAROOTDIR] + --infodir=DIR info documentation [DATAROOTDIR/info] + --localedir=DIR locale-dependent data [DATAROOTDIR/locale] + --mandir=DIR man documentation [DATAROOTDIR/man] + --docdir=DIR documentation root [DATAROOTDIR/doc/bash] + --htmldir=DIR html documentation [DOCDIR] + --dvidir=DIR dvi documentation [DOCDIR] + --pdfdir=DIR pdf documentation [DOCDIR] + --psdir=DIR ps documentation [DOCDIR] +_ACEOF + + cat <<\_ACEOF + +System types: + --build=BUILD configure for building on BUILD [guessed] + --host=HOST cross-compile to build programs to run on HOST [BUILD] +_ACEOF +fi + +if test -n "$ac_init_help"; then + case $ac_init_help in + short | recursive ) echo "Configuration of bash 4.4-release:";; + esac + cat <<\_ACEOF + +Optional Features: + --disable-option-checking ignore unrecognized --enable/--with options + --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) + --enable-FEATURE[=ARG] include FEATURE [ARG=yes] + --enable-minimal-config a minimal sh-like configuration + --enable-alias enable shell aliases + --enable-arith-for-command + enable arithmetic for command + --enable-array-variables + include shell array variables + --enable-bang-history turn on csh-style history substitution + --enable-brace-expansion + include brace expansion + --enable-casemod-attributes + include case-modifying variable attributes + --enable-casemod-expansions + include case-modifying word expansions + --enable-command-timing enable the time reserved word and command timing + --enable-cond-command enable the conditional command + --enable-cond-regexp enable extended regular expression matching in + conditional commands + --enable-coprocesses enable coprocess support and the coproc reserved + word + --enable-debugger enable support for bash debugger + --enable-direxpand-default + enable the direxpand shell option by default + --enable-directory-stack + enable builtins pushd/popd/dirs + --enable-disabled-builtins + allow disabled builtins to still be invoked + --enable-dparen-arithmetic + include ((...)) command + --enable-extended-glob include ksh-style extended pattern matching + --enable-extended-glob-default + force extended pattern matching to be enabled by + default + --enable-function-import + allow bash to import exported function definitions + by default + --enable-glob-asciiranges-default + force bracket range expressions in pattern matching + to use the C locale by default + --enable-help-builtin include the help builtin + --enable-history turn on command history + --enable-job-control enable job control features + --enable-multibyte enable multibyte characters if OS supports them + --enable-net-redirections + enable /dev/tcp/host/port redirection + --enable-process-substitution + enable process substitution + --enable-progcomp enable programmable completion and the complete + builtin + --enable-prompt-string-decoding + turn on escape character decoding in prompts + --enable-readline turn on command line editing + --enable-restricted enable a restricted shell + --enable-select include select command + --enable-separate-helpfiles + use external files for help builtin documentation + --enable-single-help-strings + store help documentation as a single string to ease + translation + --enable-strict-posix-default + configure bash to be posix-conformant by default + --enable-usg-echo-default + a synonym for --enable-xpg-echo-default + --enable-xpg-echo-default + make the echo builtin expand escape sequences by + default + --enable-mem-scramble scramble memory on calls to malloc and free + --enable-profiling allow profiling with gprof + --enable-static-link link bash statically, for use as a root shell + --disable-largefile omit support for large files + --disable-nls do not use Native Language Support + --disable-rpath do not hardcode runtime library paths + +Optional Packages: + --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] + --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) + --with-afs if you are running AFS + --with-bash-malloc use the Bash version of malloc + --with-curses use the curses library instead of the termcap + library + --with-gnu-malloc synonym for --with-bash-malloc + --with-installed-readline + use a version of the readline library that is + already installed + --with-gnu-ld assume the C compiler uses GNU ld default=no + --with-libiconv-prefix[=DIR] search for libiconv in DIR/include and DIR/lib + --without-libiconv-prefix don't search for libiconv in includedir and libdir + --with-included-gettext use the GNU gettext library included here + --with-libintl-prefix[=DIR] search for libintl in DIR/include and DIR/lib + --without-libintl-prefix don't search for libintl in includedir and libdir + +Some influential environment variables: + DEBUGGER_START_FILE + location of bash debugger initialization file + CC_FOR_BUILD + C compiler used when compiling binaries used only at build time + CFLAGS_FOR_BUILD + Compliation options (CFLAGS) used when compiling binaries used + only at build time + LDFLAGS_FOR_BUILD + Linker options (LDFLAGS) used when compiling binaries used only + at build time + CPPFLAGS_FOR_BUILD + C preprocessor options (CPPFLAGS) used when compiling binaries + used only at build time + CC C compiler command + CFLAGS C compiler flags + LDFLAGS linker flags, e.g. -L if you have libraries in a + nonstandard directory + LIBS libraries to pass to the linker, e.g. -l + CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if + you have headers in a nonstandard directory + CPP C preprocessor + YACC The `Yet Another Compiler Compiler' implementation to use. + Defaults to the first program found out of: `bison -y', `byacc', + `yacc'. + YFLAGS The list of arguments that will be passed by default to $YACC. + This script will default YFLAGS to the empty string to avoid a + default value of `-d' given by some make applications. + +Use these variables to override the choices made by `configure' or to help +it to find libraries and programs with nonstandard names/locations. + +Report bugs to . +_ACEOF +ac_status=$? +fi + +if test "$ac_init_help" = "recursive"; then + # If there are subdirs, report their specific --help. + for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue + test -d "$ac_dir" || + { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || + continue + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix + +case $srcdir in + .) # We are building in place. + ac_srcdir=. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; +esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix + + cd "$ac_dir" || { ac_status=$?; continue; } + # Check for guested configure. + if test -f "$ac_srcdir/configure.gnu"; then + echo && + $SHELL "$ac_srcdir/configure.gnu" --help=recursive + elif test -f "$ac_srcdir/configure"; then + echo && + $SHELL "$ac_srcdir/configure" --help=recursive + else + $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 + fi || ac_status=$? + cd "$ac_pwd" || { ac_status=$?; break; } + done +fi + +test -n "$ac_init_help" && exit $ac_status +if $ac_init_version; then + cat <<\_ACEOF +bash configure 4.4-release +generated by GNU Autoconf 2.69 + +Copyright (C) 2012 Free Software Foundation, Inc. +This configure script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it. +_ACEOF + exit +fi + +## ------------------------ ## +## Autoconf initialization. ## +## ------------------------ ## + +# ac_fn_c_try_compile LINENO +# -------------------------- +# Try to compile conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_compile () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext + if { { ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compile") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_compile + +# ac_fn_c_try_link LINENO +# ----------------------- +# Try to link conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_link () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext conftest$ac_exeext + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + test -x conftest$ac_exeext + }; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information + # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would + # interfere with the next link command; also delete a directory that is + # left behind by Apple's compiler. We do this before executing the actions. + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_link + +# ac_fn_c_try_cpp LINENO +# ---------------------- +# Try to preprocess conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_cpp () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { { ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } > conftest.i && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_cpp + +# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES +# ------------------------------------------------------- +# Tests whether HEADER exists, giving a warning if it cannot be compiled using +# the include files in INCLUDES and setting the cache variable VAR +# accordingly. +ac_fn_c_check_header_mongrel () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if eval \${$3+:} false; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +else + # Is the header compilable? +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 +$as_echo_n "checking $2 usability... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +#include <$2> +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_header_compiler=yes +else + ac_header_compiler=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 +$as_echo "$ac_header_compiler" >&6; } + +# Is the header present? +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 +$as_echo_n "checking $2 presence... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <$2> +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + ac_header_preproc=yes +else + ac_header_preproc=no +fi +rm -f conftest.err conftest.i conftest.$ac_ext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 +$as_echo "$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #(( + yes:no: ) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 +$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} + ;; + no:yes:* ) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 +$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 +$as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 +$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 +$as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} +( $as_echo "## ------------------------------- ## +## Report this to bug-bash@gnu.org ## +## ------------------------------- ##" + ) | sed "s/^/$as_me: WARNING: /" >&2 + ;; +esac + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + eval "$3=\$ac_header_compiler" +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +fi + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_check_header_mongrel + +# ac_fn_c_try_run LINENO +# ---------------------- +# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes +# that executables *can* be run. +ac_fn_c_try_run () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; then : + ac_retval=0 +else + $as_echo "$as_me: program exited with status $ac_status" >&5 + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=$ac_status +fi + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_run + +# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES +# ------------------------------------------------------- +# Tests whether HEADER exists and can be compiled using the include files in +# INCLUDES, setting the cache variable VAR accordingly. +ac_fn_c_check_header_compile () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +#include <$2> +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + eval "$3=yes" +else + eval "$3=no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_check_header_compile + +# ac_fn_c_check_func LINENO FUNC VAR +# ---------------------------------- +# Tests whether FUNC exists, setting the cache variable VAR accordingly +ac_fn_c_check_func () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +/* Define $2 to an innocuous variant, in case declares $2. + For example, HP-UX 11i declares gettimeofday. */ +#define $2 innocuous_$2 + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $2 (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $2 + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char $2 (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub_$2 || defined __stub___$2 +choke me +#endif + +int +main () +{ +return $2 (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + eval "$3=yes" +else + eval "$3=no" +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_check_func + +# ac_fn_c_check_type LINENO TYPE VAR INCLUDES +# ------------------------------------------- +# Tests whether TYPE exists after having included INCLUDES, setting cache +# variable VAR accordingly. +ac_fn_c_check_type () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + eval "$3=no" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +if (sizeof ($2)) + return 0; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +if (sizeof (($2))) + return 0; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + +else + eval "$3=yes" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_check_type + +# ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES +# --------------------------------------------- +# Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR +# accordingly. +ac_fn_c_check_decl () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + as_decl_name=`echo $2|sed 's/ *(.*//'` + as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'` + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5 +$as_echo_n "checking whether $as_decl_name is declared... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +#ifndef $as_decl_name +#ifdef __cplusplus + (void) $as_decl_use; +#else + (void) $as_decl_name; +#endif +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + eval "$3=yes" +else + eval "$3=no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_check_decl + +# ac_fn_c_compute_int LINENO EXPR VAR INCLUDES +# -------------------------------------------- +# Tries to find the compile-time value of EXPR in a program that includes +# INCLUDES, setting VAR accordingly. Returns whether the value could be +# computed +ac_fn_c_compute_int () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if test "$cross_compiling" = yes; then + # Depending upon the size, compute the lo and hi bounds. +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +static int test_array [1 - 2 * !(($2) >= 0)]; +test_array [0] = 0; +return test_array [0]; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_lo=0 ac_mid=0 + while :; do + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +static int test_array [1 - 2 * !(($2) <= $ac_mid)]; +test_array [0] = 0; +return test_array [0]; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_hi=$ac_mid; break +else + as_fn_arith $ac_mid + 1 && ac_lo=$as_val + if test $ac_lo -le $ac_mid; then + ac_lo= ac_hi= + break + fi + as_fn_arith 2 '*' $ac_mid + 1 && ac_mid=$as_val +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +static int test_array [1 - 2 * !(($2) < 0)]; +test_array [0] = 0; +return test_array [0]; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_hi=-1 ac_mid=-1 + while :; do + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +static int test_array [1 - 2 * !(($2) >= $ac_mid)]; +test_array [0] = 0; +return test_array [0]; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_lo=$ac_mid; break +else + as_fn_arith '(' $ac_mid ')' - 1 && ac_hi=$as_val + if test $ac_mid -le $ac_hi; then + ac_lo= ac_hi= + break + fi + as_fn_arith 2 '*' $ac_mid && ac_mid=$as_val +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + ac_lo= ac_hi= +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +# Binary search between lo and hi bounds. +while test "x$ac_lo" != "x$ac_hi"; do + as_fn_arith '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo && ac_mid=$as_val + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +static int test_array [1 - 2 * !(($2) <= $ac_mid)]; +test_array [0] = 0; +return test_array [0]; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_hi=$ac_mid +else + as_fn_arith '(' $ac_mid ')' + 1 && ac_lo=$as_val +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +done +case $ac_lo in #(( +?*) eval "$3=\$ac_lo"; ac_retval=0 ;; +'') ac_retval=1 ;; +esac + else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +static long int longval () { return $2; } +static unsigned long int ulongval () { return $2; } +#include +#include +int +main () +{ + + FILE *f = fopen ("conftest.val", "w"); + if (! f) + return 1; + if (($2) < 0) + { + long int i = longval (); + if (i != ($2)) + return 1; + fprintf (f, "%ld", i); + } + else + { + unsigned long int i = ulongval (); + if (i != ($2)) + return 1; + fprintf (f, "%lu", i); + } + /* Do not output a trailing newline, as this causes \r\n confusion + on some platforms. */ + return ferror (f) || fclose (f) != 0; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + echo >>conftest.val; read $3 &5 +$as_echo_n "checking for $2.$3... " >&6; } +if eval \${$4+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$5 +int +main () +{ +static $2 ac_aggr; +if (ac_aggr.$3) +return 0; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + eval "$4=yes" +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$5 +int +main () +{ +static $2 ac_aggr; +if (sizeof ac_aggr.$3) +return 0; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + eval "$4=yes" +else + eval "$4=no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +eval ac_res=\$$4 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_check_member +cat >config.log <<_ACEOF +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. + +It was created by bash $as_me 4.4-release, which was +generated by GNU Autoconf 2.69. Invocation command line was + + $ $0 $@ + +_ACEOF +exec 5>>config.log +{ +cat <<_ASUNAME +## --------- ## +## Platform. ## +## --------- ## + +hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` + +/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` +/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` +/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` +/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` + +_ASUNAME + +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + $as_echo "PATH: $as_dir" + done +IFS=$as_save_IFS + +} >&5 + +cat >&5 <<_ACEOF + + +## ----------- ## +## Core tests. ## +## ----------- ## + +_ACEOF + + +# Keep a trace of the command line. +# Strip out --no-create and --no-recursion so they do not pile up. +# Strip out --silent because we don't want to record it for future runs. +# Also quote any args containing shell meta-characters. +# Make two passes to allow for proper duplicate-argument suppression. +ac_configure_args= +ac_configure_args0= +ac_configure_args1= +ac_must_keep_next=false +for ac_pass in 1 2 +do + for ac_arg + do + case $ac_arg in + -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + continue ;; + *\'*) + ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + case $ac_pass in + 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; + 2) + as_fn_append ac_configure_args1 " '$ac_arg'" + if test $ac_must_keep_next = true; then + ac_must_keep_next=false # Got value, back to normal. + else + case $ac_arg in + *=* | --config-cache | -C | -disable-* | --disable-* \ + | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ + | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ + | -with-* | --with-* | -without-* | --without-* | --x) + case "$ac_configure_args0 " in + "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; + esac + ;; + -* ) ac_must_keep_next=true ;; + esac + fi + as_fn_append ac_configure_args " '$ac_arg'" + ;; + esac + done +done +{ ac_configure_args0=; unset ac_configure_args0;} +{ ac_configure_args1=; unset ac_configure_args1;} + +# When interrupted or exit'd, cleanup temporary files, and complete +# config.log. We remove comments because anyway the quotes in there +# would cause problems or look ugly. +# WARNING: Use '\'' to represent an apostrophe within the trap. +# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. +trap 'exit_status=$? + # Save into config.log some information that might help in debugging. + { + echo + + $as_echo "## ---------------- ## +## Cache variables. ## +## ---------------- ##" + echo + # The following way of writing the cache mishandles newlines in values, +( + for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 +$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( + *) { eval $ac_var=; unset $ac_var;} ;; + esac ;; + esac + done + (set) 2>&1 | + case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( + *${as_nl}ac_space=\ *) + sed -n \ + "s/'\''/'\''\\\\'\'''\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" + ;; #( + *) + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" + ;; + esac | + sort +) + echo + + $as_echo "## ----------------- ## +## Output variables. ## +## ----------------- ##" + echo + for ac_var in $ac_subst_vars + do + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + $as_echo "$ac_var='\''$ac_val'\''" + done | sort + echo + + if test -n "$ac_subst_files"; then + $as_echo "## ------------------- ## +## File substitutions. ## +## ------------------- ##" + echo + for ac_var in $ac_subst_files + do + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + $as_echo "$ac_var='\''$ac_val'\''" + done | sort + echo + fi + + if test -s confdefs.h; then + $as_echo "## ----------- ## +## confdefs.h. ## +## ----------- ##" + echo + cat confdefs.h + echo + fi + test "$ac_signal" != 0 && + $as_echo "$as_me: caught signal $ac_signal" + $as_echo "$as_me: exit $exit_status" + } >&5 + rm -f core *.core core.conftest.* && + rm -f -r conftest* confdefs* conf$$* $ac_clean_files && + exit $exit_status +' 0 +for ac_signal in 1 2 13 15; do + trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal +done +ac_signal=0 + +# confdefs.h avoids OS command line length limits that DEFS can exceed. +rm -f -r conftest* confdefs.h + +$as_echo "/* confdefs.h */" > confdefs.h + +# Predefined preprocessor variables. + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_NAME "$PACKAGE_NAME" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_TARNAME "$PACKAGE_TARNAME" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_VERSION "$PACKAGE_VERSION" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_STRING "$PACKAGE_STRING" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_URL "$PACKAGE_URL" +_ACEOF + + +# Let the site file select an alternate cache file if it wants to. +# Prefer an explicitly selected file to automatically selected ones. +ac_site_file1=NONE +ac_site_file2=NONE +if test -n "$CONFIG_SITE"; then + # We do not want a PATH search for config.site. + case $CONFIG_SITE in #(( + -*) ac_site_file1=./$CONFIG_SITE;; + */*) ac_site_file1=$CONFIG_SITE;; + *) ac_site_file1=./$CONFIG_SITE;; + esac +elif test "x$prefix" != xNONE; then + ac_site_file1=$prefix/share/config.site + ac_site_file2=$prefix/etc/config.site +else + ac_site_file1=$ac_default_prefix/share/config.site + ac_site_file2=$ac_default_prefix/etc/config.site +fi +for ac_site_file in "$ac_site_file1" "$ac_site_file2" +do + test "x$ac_site_file" = xNONE && continue + if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 +$as_echo "$as_me: loading site script $ac_site_file" >&6;} + sed 's/^/| /' "$ac_site_file" >&5 + . "$ac_site_file" \ + || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "failed to load site script $ac_site_file +See \`config.log' for more details" "$LINENO" 5; } + fi +done + +if test -r "$cache_file"; then + # Some versions of bash will fail to source /dev/null (special files + # actually), so we avoid doing that. DJGPP emulates it as a regular file. + if test /dev/null != "$cache_file" && test -f "$cache_file"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 +$as_echo "$as_me: loading cache $cache_file" >&6;} + case $cache_file in + [\\/]* | ?:[\\/]* ) . "$cache_file";; + *) . "./$cache_file";; + esac + fi +else + { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 +$as_echo "$as_me: creating cache $cache_file" >&6;} + >$cache_file +fi + +as_fn_append ac_header_list " stdlib.h" +as_fn_append ac_header_list " unistd.h" +as_fn_append ac_header_list " sys/param.h" +as_fn_append ac_header_list " sys/time.h" +as_fn_append ac_func_list " alarm" +as_fn_append ac_func_list " fpurge" +as_fn_append ac_func_list " __fpurge" +as_fn_append ac_func_list " snprintf" +as_fn_append ac_func_list " vsnprintf" +# Check that the precious variables saved in the cache have kept the same +# value. +ac_cache_corrupted=false +for ac_var in $ac_precious_vars; do + eval ac_old_set=\$ac_cv_env_${ac_var}_set + eval ac_new_set=\$ac_env_${ac_var}_set + eval ac_old_val=\$ac_cv_env_${ac_var}_value + eval ac_new_val=\$ac_env_${ac_var}_value + case $ac_old_set,$ac_new_set in + set,) + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 +$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,set) + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 +$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,);; + *) + if test "x$ac_old_val" != "x$ac_new_val"; then + # differences in whitespace do not lead to failure. + ac_old_val_w=`echo x $ac_old_val` + ac_new_val_w=`echo x $ac_new_val` + if test "$ac_old_val_w" != "$ac_new_val_w"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 +$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} + ac_cache_corrupted=: + else + { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 +$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} + eval $ac_var=\$ac_old_val + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 +$as_echo "$as_me: former value: \`$ac_old_val'" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 +$as_echo "$as_me: current value: \`$ac_new_val'" >&2;} + fi;; + esac + # Pass precious variables to config.status. + if test "$ac_new_set" = set; then + case $ac_new_val in + *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; + *) ac_arg=$ac_var=$ac_new_val ;; + esac + case " $ac_configure_args " in + *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. + *) as_fn_append ac_configure_args " '$ac_arg'" ;; + esac + fi +done +if $ac_cache_corrupted; then + { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 +$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} + as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 +fi +## -------------------- ## +## Main body of script. ## +## -------------------- ## + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + + + + +ac_aux_dir= +for ac_dir in ./support "$srcdir"/./support; do + if test -f "$ac_dir/install-sh"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install-sh -c" + break + elif test -f "$ac_dir/install.sh"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install.sh -c" + break + elif test -f "$ac_dir/shtool"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/shtool install -c" + break + fi +done +if test -z "$ac_aux_dir"; then + as_fn_error $? "cannot find install-sh, install.sh, or shtool in ./support \"$srcdir\"/./support" "$LINENO" 5 +fi + +# These three variables are undocumented and unsupported, +# and are intended to be withdrawn in a future Autoconf release. +# They can cause serious problems if a builder's source tree is in a directory +# whose full name contains unusual characters. +ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. +ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. +ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. + + +ac_config_headers="$ac_config_headers config.h" + + +BASHVERS=4.4 +RELSTATUS=release + +case "$RELSTATUS" in +alp*|bet*|dev*|rc*|releng*|maint*) DEBUG='-DDEBUG' MALLOC_DEBUG='-DMALLOC_DEBUG' ;; +*) DEBUG= MALLOC_DEBUG= ;; +esac + +# Make sure we can run config.sub. +$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || + as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5 + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 +$as_echo_n "checking build system type... " >&6; } +if ${ac_cv_build+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_build_alias=$build_alias +test "x$ac_build_alias" = x && + ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` +test "x$ac_build_alias" = x && + as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5 +ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || + as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5 + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 +$as_echo "$ac_cv_build" >&6; } +case $ac_cv_build in +*-*-*) ;; +*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;; +esac +build=$ac_cv_build +ac_save_IFS=$IFS; IFS='-' +set x $ac_cv_build +shift +build_cpu=$1 +build_vendor=$2 +shift; shift +# Remember, the first character of IFS is used to create $*, +# except with old shells: +build_os=$* +IFS=$ac_save_IFS +case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 +$as_echo_n "checking host system type... " >&6; } +if ${ac_cv_host+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test "x$host_alias" = x; then + ac_cv_host=$ac_cv_build +else + ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || + as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5 +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5 +$as_echo "$ac_cv_host" >&6; } +case $ac_cv_host in +*-*-*) ;; +*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;; +esac +host=$ac_cv_host +ac_save_IFS=$IFS; IFS='-' +set x $ac_cv_host +shift +host_cpu=$1 +host_vendor=$2 +shift; shift +# Remember, the first character of IFS is used to create $*, +# except with old shells: +host_os=$* +IFS=$ac_save_IFS +case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac + + + + +opt_bash_malloc=yes +opt_afs=no +opt_curses=no +opt_with_installed_readline=no + +#htmldir= + +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 +*-mirbsd*) 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 +*-openstep*) opt_bash_malloc=no ;; # i386/Sparc/HP machines running Openstep +*-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 +*-nsk*) opt_bash_malloc=no ;; # HP NonStop +*-haiku*) opt_bash_malloc=no ;; # Haiku OS +esac + +# memory scrambling on free() +case "${host_os}" in +sco3.2v5*|sco3.2v4*) opt_memscramble=no ;; +*) opt_memscramble=yes ;; +esac + + + + +# Check whether --with-afs was given. +if test "${with_afs+set}" = set; then : + withval=$with_afs; opt_afs=$withval +fi + + +# Check whether --with-bash-malloc was given. +if test "${with_bash_malloc+set}" = set; then : + withval=$with_bash_malloc; opt_bash_malloc=$withval +fi + + +# Check whether --with-curses was given. +if test "${with_curses+set}" = set; then : + withval=$with_curses; opt_curses=$withval +fi + + +# Check whether --with-gnu-malloc was given. +if test "${with_gnu_malloc+set}" = set; then : + withval=$with_gnu_malloc; opt_bash_malloc=$withval +fi + + +# Check whether --with-installed-readline was given. +if test "${with_installed_readline+set}" = set; then : + withval=$with_installed_readline; opt_with_installed_readline=$withval +fi + + +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)' + + $as_echo "#define USING_BASH_MALLOC 1" >>confdefs.h + +else + MALLOC_LIB= + MALLOC_LIBRARY= + MALLOC_LDFLAGS= + MALLOC_DEP= +fi + +if test "$opt_afs" = yes; then + $as_echo "#define AFS 1" >>confdefs.h + +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 + +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_coproc=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 +opt_casemod_attrs=yes +opt_casemod_expansions=yes +opt_extglob_default=no +opt_dircomplete_expand_default=no +opt_globascii_default=no +opt_function_import=yes + +opt_static_link=no +opt_profiling=no + +# Check whether --enable-minimal-config was given. +if test "${enable_minimal_config+set}" = set; then : + enableval=$enable_minimal_config; opt_minimal_config=$enableval +fi + + +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 opt_coproc=no + opt_casemod_attrs=no opt_casemod_expansions=no opt_extglob_default=no + opt_globascii_default=no +fi + +# Check whether --enable-alias was given. +if test "${enable_alias+set}" = set; then : + enableval=$enable_alias; opt_alias=$enableval +fi + +# Check whether --enable-arith-for-command was given. +if test "${enable_arith_for_command+set}" = set; then : + enableval=$enable_arith_for_command; opt_arith_for_command=$enableval +fi + +# Check whether --enable-array-variables was given. +if test "${enable_array_variables+set}" = set; then : + enableval=$enable_array_variables; opt_array_variables=$enableval +fi + +# Check whether --enable-bang-history was given. +if test "${enable_bang_history+set}" = set; then : + enableval=$enable_bang_history; opt_bang_history=$enableval +fi + +# Check whether --enable-brace-expansion was given. +if test "${enable_brace_expansion+set}" = set; then : + enableval=$enable_brace_expansion; opt_brace_expansion=$enableval +fi + +# Check whether --enable-casemod-attributes was given. +if test "${enable_casemod_attributes+set}" = set; then : + enableval=$enable_casemod_attributes; opt_casemod_attrs=$enableval +fi + +# Check whether --enable-casemod-expansions was given. +if test "${enable_casemod_expansions+set}" = set; then : + enableval=$enable_casemod_expansions; opt_casemod_expansions=$enableval +fi + +# Check whether --enable-command-timing was given. +if test "${enable_command_timing+set}" = set; then : + enableval=$enable_command_timing; opt_command_timing=$enableval +fi + +# Check whether --enable-cond-command was given. +if test "${enable_cond_command+set}" = set; then : + enableval=$enable_cond_command; opt_cond_command=$enableval +fi + +# Check whether --enable-cond-regexp was given. +if test "${enable_cond_regexp+set}" = set; then : + enableval=$enable_cond_regexp; opt_cond_regexp=$enableval +fi + +# Check whether --enable-coprocesses was given. +if test "${enable_coprocesses+set}" = set; then : + enableval=$enable_coprocesses; opt_coproc=$enableval +fi + +# Check whether --enable-debugger was given. +if test "${enable_debugger+set}" = set; then : + enableval=$enable_debugger; opt_debugger=$enableval +fi + +# Check whether --enable-direxpand-default was given. +if test "${enable_direxpand_default+set}" = set; then : + enableval=$enable_direxpand_default; opt_dircomplete_expand_default=$enableval +fi + +# Check whether --enable-directory-stack was given. +if test "${enable_directory_stack+set}" = set; then : + enableval=$enable_directory_stack; opt_dirstack=$enableval +fi + +# Check whether --enable-disabled-builtins was given. +if test "${enable_disabled_builtins+set}" = set; then : + enableval=$enable_disabled_builtins; opt_disabled_builtins=$enableval +fi + +# Check whether --enable-dparen-arithmetic was given. +if test "${enable_dparen_arithmetic+set}" = set; then : + enableval=$enable_dparen_arithmetic; opt_dparen_arith=$enableval +fi + +# Check whether --enable-extended-glob was given. +if test "${enable_extended_glob+set}" = set; then : + enableval=$enable_extended_glob; opt_extended_glob=$enableval +fi + +# Check whether --enable-extended-glob-default was given. +if test "${enable_extended_glob_default+set}" = set; then : + enableval=$enable_extended_glob_default; opt_extglob_default=$enableval +fi + +# Check whether --enable-function-import was given. +if test "${enable_function_import+set}" = set; then : + enableval=$enable_function_import; opt_function_import=$enableval +fi + +# Check whether --enable-glob-asciiranges-default was given. +if test "${enable_glob_asciiranges_default+set}" = set; then : + enableval=$enable_glob_asciiranges_default; opt_globascii_default=$enableval +fi + +# Check whether --enable-help-builtin was given. +if test "${enable_help_builtin+set}" = set; then : + enableval=$enable_help_builtin; opt_help=$enableval +fi + +# Check whether --enable-history was given. +if test "${enable_history+set}" = set; then : + enableval=$enable_history; opt_history=$enableval +fi + +# Check whether --enable-job-control was given. +if test "${enable_job_control+set}" = set; then : + enableval=$enable_job_control; opt_job_control=$enableval +fi + +# Check whether --enable-multibyte was given. +if test "${enable_multibyte+set}" = set; then : + enableval=$enable_multibyte; opt_multibyte=$enableval +fi + +# Check whether --enable-net-redirections was given. +if test "${enable_net_redirections+set}" = set; then : + enableval=$enable_net_redirections; opt_net_redirs=$enableval +fi + +# Check whether --enable-process-substitution was given. +if test "${enable_process_substitution+set}" = set; then : + enableval=$enable_process_substitution; opt_process_subst=$enableval +fi + +# Check whether --enable-progcomp was given. +if test "${enable_progcomp+set}" = set; then : + enableval=$enable_progcomp; opt_progcomp=$enableval +fi + +# Check whether --enable-prompt-string-decoding was given. +if test "${enable_prompt_string_decoding+set}" = set; then : + enableval=$enable_prompt_string_decoding; opt_prompt_decoding=$enableval +fi + +# Check whether --enable-readline was given. +if test "${enable_readline+set}" = set; then : + enableval=$enable_readline; opt_readline=$enableval +fi + +# Check whether --enable-restricted was given. +if test "${enable_restricted+set}" = set; then : + enableval=$enable_restricted; opt_restricted=$enableval +fi + +# Check whether --enable-select was given. +if test "${enable_select+set}" = set; then : + enableval=$enable_select; opt_select=$enableval +fi + +# Check whether --enable-separate-helpfiles was given. +if test "${enable_separate_helpfiles+set}" = set; then : + enableval=$enable_separate_helpfiles; opt_separate_help=$enableval +fi + +# Check whether --enable-single-help-strings was given. +if test "${enable_single_help_strings+set}" = set; then : + enableval=$enable_single_help_strings; opt_single_longdoc_strings=$enableval +fi + +# Check whether --enable-strict-posix-default was given. +if test "${enable_strict_posix_default+set}" = set; then : + enableval=$enable_strict_posix_default; opt_strict_posix=$enableval +fi + +# Check whether --enable-usg-echo-default was given. +if test "${enable_usg_echo_default+set}" = set; then : + enableval=$enable_usg_echo_default; opt_xpg_echo=$enableval +fi + +# Check whether --enable-xpg-echo-default was given. +if test "${enable_xpg_echo_default+set}" = set; then : + enableval=$enable_xpg_echo_default; opt_xpg_echo=$enableval +fi + + +# Check whether --enable-mem-scramble was given. +if test "${enable_mem_scramble+set}" = set; then : + enableval=$enable_mem_scramble; opt_memscramble=$enableval +fi + +# Check whether --enable-profiling was given. +if test "${enable_profiling+set}" = set; then : + enableval=$enable_profiling; opt_profiling=$enableval +fi + +# Check whether --enable-static-link was given. +if test "${enable_static_link+set}" = set; then : + enableval=$enable_static_link; opt_static_link=$enableval +fi + + + + + + + + + +if test $opt_alias = yes; then +$as_echo "#define ALIAS 1" >>confdefs.h + +fi +if test $opt_dirstack = yes; then +$as_echo "#define PUSHD_AND_POPD 1" >>confdefs.h + +fi +if test $opt_restricted = yes; then +$as_echo "#define RESTRICTED_SHELL 1" >>confdefs.h + +fi +if test $opt_process_subst = yes; then +$as_echo "#define PROCESS_SUBSTITUTION 1" >>confdefs.h + +fi +if test $opt_prompt_decoding = yes; then +$as_echo "#define PROMPT_STRING_DECODE 1" >>confdefs.h + +fi +if test $opt_select = yes; then +$as_echo "#define SELECT_COMMAND 1" >>confdefs.h + +fi +if test $opt_help = yes; then +$as_echo "#define HELP_BUILTIN 1" >>confdefs.h + +fi +if test $opt_array_variables = yes; then +$as_echo "#define ARRAY_VARS 1" >>confdefs.h + +fi +if test $opt_dparen_arith = yes; then +$as_echo "#define DPAREN_ARITHMETIC 1" >>confdefs.h + +fi +if test $opt_brace_expansion = yes; then +$as_echo "#define BRACE_EXPANSION 1" >>confdefs.h + +fi +if test $opt_disabled_builtins = yes; then +$as_echo "#define DISABLED_BUILTINS 1" >>confdefs.h + +fi +if test $opt_command_timing = yes; then +$as_echo "#define COMMAND_TIMING 1" >>confdefs.h + +fi +if test $opt_xpg_echo = yes ; then +$as_echo "#define DEFAULT_ECHO_TO_XPG 1" >>confdefs.h + +fi +if test $opt_strict_posix = yes; then +$as_echo "#define STRICT_POSIX 1" >>confdefs.h + +fi +if test $opt_extended_glob = yes ; then +$as_echo "#define EXTENDED_GLOB 1" >>confdefs.h + +fi +if test $opt_extglob_default = yes; then +$as_echo "#define EXTGLOB_DEFAULT 1" >>confdefs.h + +else +$as_echo "#define EXTGLOB_DEFAULT 0" >>confdefs.h + +fi +if test $opt_cond_command = yes ; then +$as_echo "#define COND_COMMAND 1" >>confdefs.h + +fi +if test $opt_cond_regexp = yes ; then +$as_echo "#define COND_REGEXP 1" >>confdefs.h + +fi +if test $opt_coproc = yes; then +$as_echo "#define COPROCESS_SUPPORT 1" >>confdefs.h + +fi +if test $opt_arith_for_command = yes; then +$as_echo "#define ARITH_FOR_COMMAND 1" >>confdefs.h + +fi +if test $opt_net_redirs = yes; then +$as_echo "#define NETWORK_REDIRECTIONS 1" >>confdefs.h + +fi +if test $opt_progcomp = yes; then +$as_echo "#define PROGRAMMABLE_COMPLETION 1" >>confdefs.h + +fi +if test $opt_multibyte = no; then +$as_echo "#define NO_MULTIBYTE_SUPPORT 1" >>confdefs.h + +fi +if test $opt_debugger = yes; then +$as_echo "#define DEBUGGER 1" >>confdefs.h + +fi +if test $opt_casemod_attrs = yes; then +$as_echo "#define CASEMOD_ATTRS 1" >>confdefs.h + +fi +if test $opt_casemod_expansions = yes; then +$as_echo "#define CASEMOD_EXPANSIONS 1" >>confdefs.h + +fi +if test $opt_dircomplete_expand_default = yes; then +$as_echo "#define DIRCOMPLETE_EXPAND_DEFAULT 1" >>confdefs.h + +fi +if test $opt_globascii_default = yes; then +$as_echo "#define GLOBASCII_DEFAULT 1" >>confdefs.h + +else +$as_echo "#define GLOBASCII_DEFAULT 0" >>confdefs.h + +fi +if test $opt_function_import = yes; then +$as_echo "#define FUNCTION_IMPORT 1" >>confdefs.h + +fi + +if test $opt_memscramble = yes; then +$as_echo "#define MEMSCRAMBLE 1" >>confdefs.h + +fi + +if test "$opt_minimal_config" = yes; then + TESTSCRIPT=run-minimal +else + TESTSCRIPT=run-all +fi + +HELPDIR= HELPDIRDEFINE= HELPINSTALL= HELPFILES_TARGET= +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' + HELPFILES_TARGET='helpdoc' +fi +HELPSTRINGS= +if test "$opt_single_longdoc_strings" != "yes"; then + HELPSTRINGS='-S' +fi + + + + + + + + + + + + + + + + + + +if test -z "$CFLAGS"; then + AUTO_CFLAGS="-g ${GCC+-O2} ${GCC+-Wno-parentheses}" + AUTO_LDFLAGS="-g ${GCC+-O2}" +else + AUTO_CFLAGS= AUTO_LDFLAGS= +fi + +echo "" +echo "Beginning configuration for bash-$BASHVERS-$RELSTATUS for ${host_cpu}-${host_vendor}-${host_os}" +echo "" + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. +set dummy ${ac_tool_prefix}gcc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="${ac_tool_prefix}gcc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "gcc", so it can be a program name with args. +set dummy gcc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="gcc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 +$as_echo "$ac_ct_CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +else + CC="$ac_cv_prog_CC" +fi + +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. +set dummy ${ac_tool_prefix}cc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="${ac_tool_prefix}cc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + fi +fi +if test -z "$CC"; then + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + ac_prog_rejected=no +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue + fi + ac_cv_prog_CC="cc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +if test $ac_prog_rejected = yes; then + # We found a bogon in the path, so make sure we never use it. + set dummy $ac_cv_prog_CC + shift + if test $# != 0; then + # We chose a different compiler from the bogus one. + # However, it has the same basename, so the bogon will be chosen + # first if we set CC to just the basename; use the full file name. + shift + ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" + fi +fi +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + for ac_prog in cl.exe + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="$ac_tool_prefix$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$CC" && break + done +fi +if test -z "$CC"; then + ac_ct_CC=$CC + for ac_prog in cl.exe +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 +$as_echo "$ac_ct_CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$ac_ct_CC" && break +done + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +fi + +fi + + +test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "no acceptable C compiler found in \$PATH +See \`config.log' for more details" "$LINENO" 5; } + +# Provide some information about the compiler. +$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 +set X $ac_compile +ac_compiler=$2 +for ac_option in --version -v -V -qversion; do + { { ac_try="$ac_compiler $ac_option >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compiler $ac_option >&5") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + sed '10a\ +... rest of stderr output deleted ... + 10q' conftest.err >conftest.er1 + cat conftest.er1 >&5 + fi + rm -f conftest.er1 conftest.err + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } +done + +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" +# Try to create an executable without -o first, disregard a.out. +# It will help us diagnose broken compilers, and finding out an intuition +# of exeext. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 +$as_echo_n "checking whether the C compiler works... " >&6; } +ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` + +# The possible output files: +ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" + +ac_rmfiles= +for ac_file in $ac_files +do + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; + * ) ac_rmfiles="$ac_rmfiles $ac_file";; + esac +done +rm -f $ac_rmfiles + +if { { ac_try="$ac_link_default" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link_default") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : + # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. +# So ignore a value of `no', otherwise this would lead to `EXEEXT = no' +# in a Makefile. We should not override ac_cv_exeext if it was cached, +# so that the user can short-circuit this test for compilers unknown to +# Autoconf. +for ac_file in $ac_files '' +do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) + ;; + [ab].out ) + # We found the default executable, but exeext='' is most + # certainly right. + break;; + *.* ) + if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; + then :; else + ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + fi + # We set ac_cv_exeext here because the later test for it is not + # safe: cross compilers may not add the suffix if given an `-o' + # argument, so we may need to know it at that point already. + # Even if this section looks crufty: it has the advantage of + # actually working. + break;; + * ) + break;; + esac +done +test "$ac_cv_exeext" = no && ac_cv_exeext= + +else + ac_file='' +fi +if test -z "$ac_file"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +$as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error 77 "C compiler cannot create executables +See \`config.log' for more details" "$LINENO" 5; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 +$as_echo_n "checking for C compiler default output file name... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 +$as_echo "$ac_file" >&6; } +ac_exeext=$ac_cv_exeext + +rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out +ac_clean_files=$ac_clean_files_save +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 +$as_echo_n "checking for suffix of executables... " >&6; } +if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : + # If both `conftest.exe' and `conftest' are `present' (well, observable) +# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will +# work properly (i.e., refer to `conftest.exe'), while it won't with +# `rm'. +for ac_file in conftest.exe conftest conftest.*; do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; + *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + break;; + * ) break;; + esac +done +else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details" "$LINENO" 5; } +fi +rm -f conftest conftest$ac_cv_exeext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 +$as_echo "$ac_cv_exeext" >&6; } + +rm -f conftest.$ac_ext +EXEEXT=$ac_cv_exeext +ac_exeext=$EXEEXT +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ +FILE *f = fopen ("conftest.out", "w"); + return ferror (f) || fclose (f) != 0; + + ; + return 0; +} +_ACEOF +ac_clean_files="$ac_clean_files conftest.out" +# Check that the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 +$as_echo_n "checking whether we are cross compiling... " >&6; } +if test "$cross_compiling" != yes; then + { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } + if { ac_try='./conftest$ac_cv_exeext' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; then + cross_compiling=no + else + if test "$cross_compiling" = maybe; then + cross_compiling=yes + else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot run C compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details" "$LINENO" 5; } + fi + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 +$as_echo "$cross_compiling" >&6; } + +rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out +ac_clean_files=$ac_clean_files_save +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 +$as_echo_n "checking for suffix of object files... " >&6; } +if ${ac_cv_objext+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.o conftest.obj +if { { ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compile") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : + for ac_file in conftest.o conftest.obj conftest.*; do + test -f "$ac_file" || continue; + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; + *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` + break;; + esac +done +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot compute suffix of object files: cannot compile +See \`config.log' for more details" "$LINENO" 5; } +fi +rm -f conftest.$ac_cv_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 +$as_echo "$ac_cv_objext" >&6; } +OBJEXT=$ac_cv_objext +ac_objext=$OBJEXT +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 +$as_echo_n "checking whether we are using the GNU C compiler... " >&6; } +if ${ac_cv_c_compiler_gnu+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_compiler_gnu=yes +else + ac_compiler_gnu=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_cv_c_compiler_gnu=$ac_compiler_gnu + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 +$as_echo "$ac_cv_c_compiler_gnu" >&6; } +if test $ac_compiler_gnu = yes; then + GCC=yes +else + GCC= +fi +ac_test_CFLAGS=${CFLAGS+set} +ac_save_CFLAGS=$CFLAGS +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 +$as_echo_n "checking whether $CC accepts -g... " >&6; } +if ${ac_cv_prog_cc_g+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_save_c_werror_flag=$ac_c_werror_flag + ac_c_werror_flag=yes + ac_cv_prog_cc_g=no + CFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_g=yes +else + CFLAGS="" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + +else + ac_c_werror_flag=$ac_save_c_werror_flag + CFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_g=yes +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag=$ac_save_c_werror_flag +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 +$as_echo "$ac_cv_prog_cc_g" >&6; } +if test "$ac_test_CFLAGS" = set; then + CFLAGS=$ac_save_CFLAGS +elif test $ac_cv_prog_cc_g = yes; then + if test "$GCC" = yes; then + CFLAGS="-g -O2" + else + CFLAGS="-g" + fi +else + if test "$GCC" = yes; then + CFLAGS="-O2" + else + CFLAGS= + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 +$as_echo_n "checking for $CC option to accept ISO C89... " >&6; } +if ${ac_cv_prog_cc_c89+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_cv_prog_cc_c89=no +ac_save_CC=$CC +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +struct stat; +/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ +struct buf { int x; }; +FILE * (*rcsopen) (struct buf *, struct stat *, int); +static char *e (p, i) + char **p; + int i; +{ + return p[i]; +} +static char *f (char * (*g) (char **, int), char **p, ...) +{ + char *s; + va_list v; + va_start (v,p); + s = g (p, va_arg (v,int)); + va_end (v); + return s; +} + +/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has + function prototypes and stuff, but not '\xHH' hex character constants. + These don't provoke an error unfortunately, instead are silently treated + as 'x'. The following induces an error, until -std is added to get + proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an + array size at least. It's necessary to write '\x00'==0 to get something + that's true only with -std. */ +int osf4_cc_array ['\x00' == 0 ? 1 : -1]; + +/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters + inside strings and character constants. */ +#define FOO(x) 'x' +int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; + +int test (int i, double x); +struct s1 {int (*f) (int a);}; +struct s2 {int (*f) (double a);}; +int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); +int argc; +char **argv; +int +main () +{ +return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; + ; + return 0; +} +_ACEOF +for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ + -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +do + CC="$ac_save_CC $ac_arg" + if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_c89=$ac_arg +fi +rm -f core conftest.err conftest.$ac_objext + test "x$ac_cv_prog_cc_c89" != "xno" && break +done +rm -f conftest.$ac_ext +CC=$ac_save_CC + +fi +# AC_CACHE_VAL +case "x$ac_cv_prog_cc_c89" in + x) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 +$as_echo "none needed" >&6; } ;; + xno) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 +$as_echo "unsupported" >&6; } ;; + *) + CC="$CC $ac_cv_prog_cc_c89" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 +$as_echo "$ac_cv_prog_cc_c89" >&6; } ;; +esac +if test "x$ac_cv_prog_cc_c89" != xno; then : + +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for strerror in -lcposix" >&5 +$as_echo_n "checking for strerror in -lcposix... " >&6; } +if ${ac_cv_lib_cposix_strerror+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lcposix $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char strerror (); +int +main () +{ +return strerror (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_cposix_strerror=yes +else + ac_cv_lib_cposix_strerror=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_cposix_strerror" >&5 +$as_echo "$ac_cv_lib_cposix_strerror" >&6; } +if test "x$ac_cv_lib_cposix_strerror" = xyes; then : + LIBS="$LIBS -lcposix" +fi + + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 +$as_echo_n "checking how to run the C preprocessor... " >&6; } +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then + if ${ac_cv_prog_CPP+:} false; then : + $as_echo_n "(cached) " >&6 +else + # Double quotes because CPP needs to be expanded + for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" + do + ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + +else + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.i conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + # Broken: success on invalid input. +continue +else + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.i conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + break +fi + + done + ac_cv_prog_CPP=$CPP + +fi + CPP=$ac_cv_prog_CPP +else + ac_cv_prog_CPP=$CPP +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 +$as_echo "$CPP" >&6; } +ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + +else + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.i conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + # Broken: success on invalid input. +continue +else + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.i conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + +else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details" "$LINENO" 5; } +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 +$as_echo_n "checking for grep that handles long lines and -e... " >&6; } +if ${ac_cv_path_GREP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -z "$GREP"; then + ac_path_GREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in grep ggrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" + as_fn_executable_p "$ac_path_GREP" || continue +# Check for GNU ac_path_GREP and select it if it is found. + # Check for GNU $ac_path_GREP +case `"$ac_path_GREP" --version 2>&1` in +*GNU*) + ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo 'GREP' >> "conftest.nl" + "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_GREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_GREP="$ac_path_GREP" + ac_path_GREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_GREP_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_GREP"; then + as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + fi +else + ac_cv_path_GREP=$GREP +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 +$as_echo "$ac_cv_path_GREP" >&6; } + GREP="$ac_cv_path_GREP" + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 +$as_echo_n "checking for egrep... " >&6; } +if ${ac_cv_path_EGREP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 + then ac_cv_path_EGREP="$GREP -E" + else + if test -z "$EGREP"; then + ac_path_EGREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in egrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" + as_fn_executable_p "$ac_path_EGREP" || continue +# Check for GNU ac_path_EGREP and select it if it is found. + # Check for GNU $ac_path_EGREP +case `"$ac_path_EGREP" --version 2>&1` in +*GNU*) + ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo 'EGREP' >> "conftest.nl" + "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_EGREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_EGREP="$ac_path_EGREP" + ac_path_EGREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_EGREP_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_EGREP"; then + as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + fi +else + ac_cv_path_EGREP=$EGREP +fi + + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 +$as_echo "$ac_cv_path_EGREP" >&6; } + EGREP="$ac_cv_path_EGREP" + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 +$as_echo_n "checking for ANSI C header files... " >&6; } +if ${ac_cv_header_stdc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#include +#include + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_header_stdc=yes +else + ac_cv_header_stdc=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "memchr" >/dev/null 2>&1; then : + +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "free" >/dev/null 2>&1; then : + +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. + if test "$cross_compiling" = yes; then : + : +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#if ((' ' & 0x0FF) == 0x020) +# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#else +# define ISLOWER(c) \ + (('a' <= (c) && (c) <= 'i') \ + || ('j' <= (c) && (c) <= 'r') \ + || ('s' <= (c) && (c) <= 'z')) +# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) +#endif + +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int +main () +{ + int i; + for (i = 0; i < 256; i++) + if (XOR (islower (i), ISLOWER (i)) + || toupper (i) != TOUPPER (i)) + return 2; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + +else + ac_cv_header_stdc=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 +$as_echo "$ac_cv_header_stdc" >&6; } +if test $ac_cv_header_stdc = yes; then + +$as_echo "#define STDC_HEADERS 1" >>confdefs.h + +fi + +# On IRIX 5.3, sys/types and inttypes.h are conflicting. +for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ + inttypes.h stdint.h unistd.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default +" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + + + ac_fn_c_check_header_mongrel "$LINENO" "minix/config.h" "ac_cv_header_minix_config_h" "$ac_includes_default" +if test "x$ac_cv_header_minix_config_h" = xyes; then : + MINIX=yes +else + MINIX= +fi + + + if test "$MINIX" = yes; then + +$as_echo "#define _POSIX_SOURCE 1" >>confdefs.h + + +$as_echo "#define _POSIX_1_SOURCE 2" >>confdefs.h + + +$as_echo "#define _MINIX 1" >>confdefs.h + + fi + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether it is safe to define __EXTENSIONS__" >&5 +$as_echo_n "checking whether it is safe to define __EXTENSIONS__... " >&6; } +if ${ac_cv_safe_to_define___extensions__+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +# define __EXTENSIONS__ 1 + $ac_includes_default +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_safe_to_define___extensions__=yes +else + ac_cv_safe_to_define___extensions__=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_safe_to_define___extensions__" >&5 +$as_echo "$ac_cv_safe_to_define___extensions__" >&6; } + test $ac_cv_safe_to_define___extensions__ = yes && + $as_echo "#define __EXTENSIONS__ 1" >>confdefs.h + + $as_echo "#define _ALL_SOURCE 1" >>confdefs.h + + $as_echo "#define _GNU_SOURCE 1" >>confdefs.h + + $as_echo "#define _POSIX_PTHREAD_SEMANTICS 1" >>confdefs.h + + $as_echo "#define _TANDEM_SOURCE 1" >>confdefs.h + + + + +# Check whether --enable-largefile was given. +if test "${enable_largefile+set}" = set; then : + enableval=$enable_largefile; +fi + +if test "$enable_largefile" != no; then + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for special C compiler options needed for large files" >&5 +$as_echo_n "checking for special C compiler options needed for large files... " >&6; } +if ${ac_cv_sys_largefile_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_cv_sys_largefile_CC=no + if test "$GCC" != yes; then + ac_save_CC=$CC + while :; do + # IRIX 6.2 and later do not support large files by default, + # so use the C compiler's -n32 option if that helps. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + /* Check that off_t can represent 2**63 - 1 correctly. + We can't simply define LARGE_OFF_T to be 9223372036854775807, + since some C++ compilers masquerading as C compilers + incorrectly reject 9223372036854775807. */ +#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) + int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 + && LARGE_OFF_T % 2147483647 == 1) + ? 1 : -1]; +int +main () +{ + + ; + return 0; +} +_ACEOF + if ac_fn_c_try_compile "$LINENO"; then : + break +fi +rm -f core conftest.err conftest.$ac_objext + CC="$CC -n32" + if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_sys_largefile_CC=' -n32'; break +fi +rm -f core conftest.err conftest.$ac_objext + break + done + CC=$ac_save_CC + rm -f conftest.$ac_ext + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_largefile_CC" >&5 +$as_echo "$ac_cv_sys_largefile_CC" >&6; } + if test "$ac_cv_sys_largefile_CC" != no; then + CC=$CC$ac_cv_sys_largefile_CC + fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for _FILE_OFFSET_BITS value needed for large files" >&5 +$as_echo_n "checking for _FILE_OFFSET_BITS value needed for large files... " >&6; } +if ${ac_cv_sys_file_offset_bits+:} false; then : + $as_echo_n "(cached) " >&6 +else + while :; do + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + /* Check that off_t can represent 2**63 - 1 correctly. + We can't simply define LARGE_OFF_T to be 9223372036854775807, + since some C++ compilers masquerading as C compilers + incorrectly reject 9223372036854775807. */ +#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) + int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 + && LARGE_OFF_T % 2147483647 == 1) + ? 1 : -1]; +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_sys_file_offset_bits=no; break +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#define _FILE_OFFSET_BITS 64 +#include + /* Check that off_t can represent 2**63 - 1 correctly. + We can't simply define LARGE_OFF_T to be 9223372036854775807, + since some C++ compilers masquerading as C compilers + incorrectly reject 9223372036854775807. */ +#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) + int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 + && LARGE_OFF_T % 2147483647 == 1) + ? 1 : -1]; +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_sys_file_offset_bits=64; break +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_cv_sys_file_offset_bits=unknown + break +done +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_file_offset_bits" >&5 +$as_echo "$ac_cv_sys_file_offset_bits" >&6; } +case $ac_cv_sys_file_offset_bits in #( + no | unknown) ;; + *) +cat >>confdefs.h <<_ACEOF +#define _FILE_OFFSET_BITS $ac_cv_sys_file_offset_bits +_ACEOF +;; +esac +rm -rf conftest* + if test $ac_cv_sys_file_offset_bits = unknown; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for _LARGE_FILES value needed for large files" >&5 +$as_echo_n "checking for _LARGE_FILES value needed for large files... " >&6; } +if ${ac_cv_sys_large_files+:} false; then : + $as_echo_n "(cached) " >&6 +else + while :; do + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + /* Check that off_t can represent 2**63 - 1 correctly. + We can't simply define LARGE_OFF_T to be 9223372036854775807, + since some C++ compilers masquerading as C compilers + incorrectly reject 9223372036854775807. */ +#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) + int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 + && LARGE_OFF_T % 2147483647 == 1) + ? 1 : -1]; +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_sys_large_files=no; break +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#define _LARGE_FILES 1 +#include + /* Check that off_t can represent 2**63 - 1 correctly. + We can't simply define LARGE_OFF_T to be 9223372036854775807, + since some C++ compilers masquerading as C compilers + incorrectly reject 9223372036854775807. */ +#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) + int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 + && LARGE_OFF_T % 2147483647 == 1) + ? 1 : -1]; +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_sys_large_files=1; break +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_cv_sys_large_files=unknown + break +done +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_large_files" >&5 +$as_echo "$ac_cv_sys_large_files" >&6; } +case $ac_cv_sys_large_files in #( + no | unknown) ;; + *) +cat >>confdefs.h <<_ACEOF +#define _LARGE_FILES $ac_cv_sys_large_files +_ACEOF +;; +esac +rm -rf conftest* + fi + + +fi + + + +SIGNAMES_O= +SIGNAMES_H=lsignames.h + + + +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' + +fi + + + + +CFLAGS=${CFLAGS-"$AUTO_CFLAGS"} +# LDFLAGS=${LDFLAGS="$AUTO_LDFLAGS"} # XXX + +# turn off paren warnings in gcc +if test "$GCC" = yes # && test -n "$DEBUG" +then + CFLAGS="$CFLAGS -Wno-parentheses -Wno-format-security" +fi + +if test "$opt_profiling" = "yes"; then + PROFILE_FLAGS=-pg + case "$host_os" in + solaris2*) ;; + *) opt_static_link=yes ;; + esac + DEBUG= MALLOC_DEBUG= +fi + +prefer_shared=yes +prefer_static=no + +if test "$opt_static_link" = yes; then + prefer_static=yes + prefer_shared=no + # if we're using gcc, add `-static' to LDFLAGS, except on Solaris >= 2 + if test -n "$GCC" || test "$ac_cv_c_compiler_gnu" = "yes"; then + STATIC_LD="-static" + case "$host_os" in + solaris2*) ;; + *) LDFLAGS="$LDFLAGS -static" ;; # XXX experimental + esac + fi +fi + +# set the appropriate make variables for building the "build tools" +# modify defaults based on whether or not we are cross compiling, since the +# options for the target host may not be appropriate for the build host +if test "X$cross_compiling" = "Xno"; then + CC_FOR_BUILD=${CC_FOR_BUILD-'$(CC)'} + CPPFLAGS_FOR_BUILD=${CPPFLAGS_FOR_BUILD-"$CPPFLAGS"} # XXX - should it be '$(CPPFLAGS)' + LDFLAGS_FOR_BUILD=${LDFLAGS_FOR_BUILD-'$(LDFLAGS)'} + # CFLAGS set above to default value if not passed in environment + CFLAGS_FOR_BUILD=${CFLAGS-'$(CFLAGS)'} + LIBS_FOR_BUILD=${LIBS_FOR_BUILD-'$(LIBS)'} +else + CC_FOR_BUILD=${CC_FOR_BUILD-"gcc"} + CPPFLAGS_FOR_BUILD=${CPPFLAGS_FOR_BUILD-""} + LDFLAGS_FOR_BUILD=${LDFLAGS_FOR_BUILD-""} + CFLAGS_FOR_BUILD=${CFLAGS_FOR_BUILD="-g"} + LIBS_FOR_BUILD=${LIBS_FOR_BUILD-""} +fi + + + + + + + + + + + + +if test $ac_cv_c_compiler_gnu = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC needs -traditional" >&5 +$as_echo_n "checking whether $CC needs -traditional... " >&6; } +if ${ac_cv_prog_gcc_traditional+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_pattern="Autoconf.*'x'" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +Autoconf TIOCGETP +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "$ac_pattern" >/dev/null 2>&1; then : + ac_cv_prog_gcc_traditional=yes +else + ac_cv_prog_gcc_traditional=no +fi +rm -f conftest* + + + if test $ac_cv_prog_gcc_traditional = no; then + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +Autoconf TCGETA +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "$ac_pattern" >/dev/null 2>&1; then : + ac_cv_prog_gcc_traditional=yes +fi +rm -f conftest* + + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_gcc_traditional" >&5 +$as_echo "$ac_cv_prog_gcc_traditional" >&6; } + if test $ac_cv_prog_gcc_traditional = yes; then + CC="$CC -traditional" + fi +fi + + + +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 + + +if test "X$bash_cv_termcap_lib" = "X"; then +_bash_needmsg=yes +else +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking which library has the termcap functions" >&5 +$as_echo_n "checking which library has the termcap functions... " >&6; } +_bash_needmsg= +fi +if ${bash_cv_termcap_lib+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_fn_c_check_func "$LINENO" "tgetent" "ac_cv_func_tgetent" +if test "x$ac_cv_func_tgetent" = xyes; then : + bash_cv_termcap_lib=libc +else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for tgetent in -ltermcap" >&5 +$as_echo_n "checking for tgetent in -ltermcap... " >&6; } +if ${ac_cv_lib_termcap_tgetent+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ltermcap $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char tgetent (); +int +main () +{ +return tgetent (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_termcap_tgetent=yes +else + ac_cv_lib_termcap_tgetent=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_termcap_tgetent" >&5 +$as_echo "$ac_cv_lib_termcap_tgetent" >&6; } +if test "x$ac_cv_lib_termcap_tgetent" = xyes; then : + bash_cv_termcap_lib=libtermcap +else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for tgetent in -ltinfo" >&5 +$as_echo_n "checking for tgetent in -ltinfo... " >&6; } +if ${ac_cv_lib_tinfo_tgetent+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ltinfo $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char tgetent (); +int +main () +{ +return tgetent (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_tinfo_tgetent=yes +else + ac_cv_lib_tinfo_tgetent=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_tinfo_tgetent" >&5 +$as_echo "$ac_cv_lib_tinfo_tgetent" >&6; } +if test "x$ac_cv_lib_tinfo_tgetent" = xyes; then : + bash_cv_termcap_lib=libtinfo +else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for tgetent in -lcurses" >&5 +$as_echo_n "checking for tgetent in -lcurses... " >&6; } +if ${ac_cv_lib_curses_tgetent+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lcurses $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char tgetent (); +int +main () +{ +return tgetent (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_curses_tgetent=yes +else + ac_cv_lib_curses_tgetent=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_curses_tgetent" >&5 +$as_echo "$ac_cv_lib_curses_tgetent" >&6; } +if test "x$ac_cv_lib_curses_tgetent" = xyes; then : + bash_cv_termcap_lib=libcurses +else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for tgetent in -lncurses" >&5 +$as_echo_n "checking for tgetent in -lncurses... " >&6; } +if ${ac_cv_lib_ncurses_tgetent+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lncurses $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char tgetent (); +int +main () +{ +return tgetent (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_ncurses_tgetent=yes +else + ac_cv_lib_ncurses_tgetent=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ncurses_tgetent" >&5 +$as_echo "$ac_cv_lib_ncurses_tgetent" >&6; } +if test "x$ac_cv_lib_ncurses_tgetent" = xyes; then : + bash_cv_termcap_lib=libncurses +else + bash_cv_termcap_lib=gnutermcap +fi + +fi + +fi + +fi + +fi + +fi + +if test "X$_bash_needmsg" = "Xyes"; then +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking which library has the termcap functions" >&5 +$as_echo_n "checking which library has the termcap functions... " >&6; } +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: using $bash_cv_termcap_lib" >&5 +$as_echo "using $bash_cv_termcap_lib" >&6; } +if test $bash_cv_termcap_lib = gnutermcap && test -z "$prefer_curses"; then +LDFLAGS="$LDFLAGS -L./lib/termcap" +TERMCAP_LIB="./lib/termcap/libtermcap.a" +TERMCAP_DEP="./lib/termcap/libtermcap.a" +elif test $bash_cv_termcap_lib = libtermcap && test -z "$prefer_curses"; then +TERMCAP_LIB=-ltermcap +TERMCAP_DEP= +elif test $bash_cv_termcap_lib = libtinfo; then +TERMCAP_LIB=-ltinfo +TERMCAP_DEP= +elif test $bash_cv_termcap_lib = libncurses; then +TERMCAP_LIB=-lncurses +TERMCAP_DEP= +elif test $bash_cv_termcap_lib = libc; then +TERMCAP_LIB= +TERMCAP_DEP= +else +TERMCAP_LIB=-lcurses +TERMCAP_DEP= +fi + + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking version of installed readline library" >&5 +$as_echo_n "checking version of installed readline library... " >&6; } + +# What a pain in the ass this is. + +# save cpp and ld options +_save_CFLAGS="$CFLAGS" +_save_LDFLAGS="$LDFLAGS" +_save_LIBS="$LIBS" + +# Don't set ac_cv_rl_prefix if the caller has already assigned a value. This +# allows the caller to do something like $_rl_prefix=$withval if the user +# specifies --with-installed-readline=PREFIX as an argument to configure + +if test -z "$ac_cv_rl_prefix"; then +test "x$prefix" = xNONE && ac_cv_rl_prefix=$ac_default_prefix || ac_cv_rl_prefix=${prefix} +fi + +eval ac_cv_rl_includedir=${ac_cv_rl_prefix}/include +eval ac_cv_rl_libdir=${ac_cv_rl_prefix}/lib + +LIBS="$LIBS -lreadline ${TERMCAP_LIB}" +CFLAGS="$CFLAGS -I${ac_cv_rl_includedir}" +LDFLAGS="$LDFLAGS -L${ac_cv_rl_libdir}" + +if ${ac_cv_rl_version+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + ac_cv_rl_version='6.3' +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include + +extern int rl_gnu_readline_p; + +main() +{ + FILE *fp; + fp = fopen("conftest.rlv", "w"); + if (fp == 0) + exit(1); + if (rl_gnu_readline_p != 1) + fprintf(fp, "0.0\n"); + else + fprintf(fp, "%s\n", rl_library_version ? rl_library_version : "0.0"); + fclose(fp); + exit(0); +} + +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + ac_cv_rl_version=`cat conftest.rlv` +else + ac_cv_rl_version='0.0' +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi + + +CFLAGS="$_save_CFLAGS" +LDFLAGS="$_save_LDFLAGS" +LIBS="$_save_LIBS" + +RL_MAJOR=0 +RL_MINOR=0 + +# ( +case "$ac_cv_rl_version" in +2*|3*|4*|5*|6*|7*|8*|9*) + RL_MAJOR=`echo $ac_cv_rl_version | sed 's:\..*$::'` + RL_MINOR=`echo $ac_cv_rl_version | sed -e 's:^.*\.::' -e 's:[a-zA-Z]*$::'` + ;; +esac + +# ((( +case $RL_MAJOR in +[0-9][0-9]) _RL_MAJOR=$RL_MAJOR ;; +[0-9]) _RL_MAJOR=0$RL_MAJOR ;; +*) _RL_MAJOR=00 ;; +esac + +# ((( +case $RL_MINOR in +[0-9][0-9]) _RL_MINOR=$RL_MINOR ;; +[0-9]) _RL_MINOR=0$RL_MINOR ;; +*) _RL_MINOR=00 ;; +esac + +RL_VERSION="0x${_RL_MAJOR}${_RL_MINOR}" + +# Readline versions greater than 4.2 have these defines in readline.h + +if test $ac_cv_rl_version = '0.0' ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Could not test version of installed readline library." >&5 +$as_echo "$as_me: WARNING: Could not test version of installed readline library." >&2;} +elif test $RL_MAJOR -gt 4 || { test $RL_MAJOR = 4 && test $RL_MINOR -gt 2 ; } ; then + # set these for use by the caller + RL_PREFIX=$ac_cv_rl_prefix + RL_LIBDIR=$ac_cv_rl_libdir + RL_INCLUDEDIR=$ac_cv_rl_includedir + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_rl_version" >&5 +$as_echo "$ac_cv_rl_version" >&6; } +else + + +cat >>confdefs.h <<_ACEOF +#define RL_READLINE_VERSION $RL_VERSION +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define RL_VERSION_MAJOR $RL_MAJOR +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define RL_VERSION_MINOR $RL_MINOR +_ACEOF + + + + + + +# set these for use by the caller +RL_PREFIX=$ac_cv_rl_prefix +RL_LIBDIR=$ac_cv_rl_libdir +RL_INCLUDEDIR=$ac_cv_rl_includedir + +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_rl_version" >&5 +$as_echo "$ac_cv_rl_version" >&6; } + +fi + + + case "$ac_cv_rl_version" in + 5*|6*|7*|8*|9*) ;; + *) opt_with_installed_readline=no + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: installed readline library is too old to be linked with bash" >&5 +$as_echo "$as_me: WARNING: installed readline library is too old to be linked with bash" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using private bash version" >&5 +$as_echo "$as_me: WARNING: using private bash version" >&2;} + ;; + esac +fi + +TILDE_LIB=-ltilde +if test $opt_readline = yes; then + $as_echo "#define READLINE 1" >>confdefs.h + + 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 + darwin[89]*|darwin10*) 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 + $as_echo "#define HISTORY 1" >>confdefs.h + + fi + if test $opt_bang_history = yes; then + $as_echo "#define BANG_HISTORY 1" >>confdefs.h + + 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 + darwin[89]*|darwin10*) HISTORY_LIB='${HISTORY_LIBRARY}' ;; + *) HISTORY_LIB=-lhistory ;; + esac + fi +else + HIST_LIBDIR='$(dot)/$(LIBSUBDIR)/readline' + HISTORY_LIB= HISTORY_DEP= +fi + + + + + + + + + + + +# Find a good install program. We prefer a C program (faster), +# so one script is as good as another. But avoid the broken or +# incompatible versions: +# SysV /etc/install, /usr/sbin/install +# SunOS /usr/etc/install +# IRIX /sbin/install +# AIX /bin/install +# AmigaOS /C/install, which installs bootblocks on floppy discs +# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag +# AFS /usr/afsws/bin/install, which mishandles nonexistent args +# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" +# OS/2's system install, which has a completely different semantic +# ./install, which can be erroneously created by make from ./install.sh. +# Reject install programs that cannot install multiple files. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 +$as_echo_n "checking for a BSD-compatible install... " >&6; } +if test -z "$INSTALL"; then +if ${ac_cv_path_install+:} false; then : + $as_echo_n "(cached) " >&6 +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + # Account for people who put trailing slashes in PATH elements. +case $as_dir/ in #(( + ./ | .// | /[cC]/* | \ + /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ + ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \ + /usr/ucb/* ) ;; + *) + # OSF1 and SCO ODT 3.0 have their own names for install. + # Don't use installbsd from OSF since it installs stuff as root + # by default. + for ac_prog in ginstall scoinst install; do + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then + if test $ac_prog = install && + grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # AIX install. It has an incompatible calling convention. + : + elif test $ac_prog = install && + grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # program-specific install script used by HP pwplus--don't use. + : + else + rm -rf conftest.one conftest.two conftest.dir + echo one > conftest.one + echo two > conftest.two + mkdir conftest.dir + if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" && + test -s conftest.one && test -s conftest.two && + test -s conftest.dir/conftest.one && + test -s conftest.dir/conftest.two + then + ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" + break 3 + fi + fi + fi + done + done + ;; +esac + + done +IFS=$as_save_IFS + +rm -rf conftest.one conftest.two conftest.dir + +fi + if test "${ac_cv_path_install+set}" = set; then + INSTALL=$ac_cv_path_install + else + # As a last resort, use the slow shell script. Don't cache a + # value for INSTALL within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the value is a relative name. + INSTALL=$ac_install_sh + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5 +$as_echo "$INSTALL" >&6; } + +# Use test -z because SunOS4 sh mishandles braces in ${var-val}. +# It thinks the first close brace ends the variable substitution. +test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' + +test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' + +test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' + +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args. +set dummy ${ac_tool_prefix}ar; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_AR+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$AR"; then + ac_cv_prog_AR="$AR" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_AR="${ac_tool_prefix}ar" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +AR=$ac_cv_prog_AR +if test -n "$AR"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5 +$as_echo "$AR" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_AR"; then + ac_ct_AR=$AR + # Extract the first word of "ar", so it can be a program name with args. +set dummy ar; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_AR+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_AR"; then + ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_AR="ar" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_AR=$ac_cv_prog_ac_ct_AR +if test -n "$ac_ct_AR"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5 +$as_echo "$ac_ct_AR" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_AR" = x; then + AR="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + AR=$ac_ct_AR + fi +else + AR="$ac_cv_prog_AR" +fi + +test -n "$ARFLAGS" || ARFLAGS="cr" +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. +set dummy ${ac_tool_prefix}ranlib; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_RANLIB+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$RANLIB"; then + ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +RANLIB=$ac_cv_prog_RANLIB +if test -n "$RANLIB"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5 +$as_echo "$RANLIB" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_RANLIB"; then + ac_ct_RANLIB=$RANLIB + # Extract the first word of "ranlib", so it can be a program name with args. +set dummy ranlib; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_RANLIB+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_RANLIB"; then + ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_RANLIB="ranlib" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB +if test -n "$ac_ct_RANLIB"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5 +$as_echo "$ac_ct_RANLIB" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_RANLIB" = x; then + RANLIB=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + RANLIB=$ac_ct_RANLIB + fi +else + RANLIB="$ac_cv_prog_RANLIB" +fi + +for ac_prog in 'bison -y' byacc +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_YACC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$YACC"; then + ac_cv_prog_YACC="$YACC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_YACC="$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +YACC=$ac_cv_prog_YACC +if test -n "$YACC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $YACC" >&5 +$as_echo "$YACC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$YACC" && break +done +test -n "$YACC" || YACC="yacc" + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 +$as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } +set x ${MAKE-make} +ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` +if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat >conftest.make <<\_ACEOF +SHELL = /bin/sh +all: + @echo '@@@%%%=$(MAKE)=@@@%%%' +_ACEOF +# GNU make sometimes prints "make[1]: Entering ...", which would confuse us. +case `${MAKE-make} -f conftest.make 2>/dev/null` in + *@@@%%%=?*=@@@%%%*) + eval ac_cv_prog_make_${ac_make}_set=yes;; + *) + eval ac_cv_prog_make_${ac_make}_set=no;; +esac +rm -f conftest.make +fi +if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + SET_MAKE= +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + SET_MAKE="MAKE=${MAKE-make}" +fi + + +case "$ac_cv_prog_YACC" in +*bison*) ;; +*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: bison not available; needed to process parse.y" >&5 +$as_echo "$as_me: WARNING: bison not available; needed to process parse.y" >&2;} ;; +esac + +case "$host_os" in +opennt*|interix*) MAKE_SHELL="$INTERIX_ROOT/bin/sh" ;; +*) MAKE_SHELL=/bin/sh ;; +esac + + +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 + + +# Checks for stat-related time functions. + +# Copyright (C) 1998-1999, 2001, 2003, 2005-2007, 2009-2012 Free Software +# Foundation, Inc. + +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + + +# st_atim.tv_nsec - Linux, Solaris, Cygwin +# st_atimespec.tv_nsec - FreeBSD, NetBSD, if ! defined _POSIX_SOURCE +# st_atimensec - FreeBSD, NetBSD, if defined _POSIX_SOURCE +# st_atim.st__tim.tv_nsec - UnixWare (at least 2.1.2 through 7.1) + +# st_birthtimespec - FreeBSD, NetBSD (hidden on OpenBSD 3.9, anyway) +# st_birthtim - Cygwin 1.7.0+ + + + +# Configure checks for struct timespec + +# Copyright (C) 2000-2001, 2003-2007, 2009-2011, 2012 Free Software Foundation, Inc. + +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# Original written by Paul Eggert and Jim Meyering. +# Modified by Chet Ramey for bash + + + + + +$as_echo "#define _GNU_SOURCE 1" >>confdefs.h + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for an ANSI C-conforming const" >&5 +$as_echo_n "checking for an ANSI C-conforming const... " >&6; } +if ${ac_cv_c_const+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + +#ifndef __cplusplus + /* Ultrix mips cc rejects this sort of thing. */ + typedef int charset[2]; + const charset cs = { 0, 0 }; + /* SunOS 4.1.1 cc rejects this. */ + char const *const *pcpcc; + char **ppc; + /* NEC SVR4.0.2 mips cc rejects this. */ + struct point {int x, y;}; + static struct point const zero = {0,0}; + /* AIX XL C 1.02.0.0 rejects this. + It does not let you subtract one const X* pointer from another in + an arm of an if-expression whose if-part is not a constant + expression */ + const char *g = "string"; + pcpcc = &g + (g ? g-g : 0); + /* HPUX 7.0 cc rejects these. */ + ++pcpcc; + ppc = (char**) pcpcc; + pcpcc = (char const *const *) ppc; + { /* SCO 3.2v4 cc rejects this sort of thing. */ + char tx; + char *t = &tx; + char const *s = 0 ? (char *) 0 : (char const *) 0; + + *t++ = 0; + if (s) return 0; + } + { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */ + int x[] = {25, 17}; + const int *foo = &x[0]; + ++foo; + } + { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */ + typedef const int *iptr; + iptr p = 0; + ++p; + } + { /* AIX XL C 1.02.0.0 rejects this sort of thing, saying + "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ + struct s { int j; const int *ap[3]; } bx; + struct s *b = &bx; b->j = 5; + } + { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ + const int foo = 10; + if (!foo) return 0; + } + return !cs[0] && !zero.x; +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_c_const=yes +else + ac_cv_c_const=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_const" >&5 +$as_echo "$ac_cv_c_const" >&6; } +if test $ac_cv_c_const = no; then + +$as_echo "#define const /**/" >>confdefs.h + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for inline" >&5 +$as_echo_n "checking for inline... " >&6; } +if ${ac_cv_c_inline+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_cv_c_inline=no +for ac_kw in inline __inline__ __inline; do + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifndef __cplusplus +typedef int foo_t; +static $ac_kw foo_t static_foo () {return 0; } +$ac_kw foo_t foo () {return 0; } +#endif + +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_c_inline=$ac_kw +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + test "$ac_cv_c_inline" != no && break +done + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_inline" >&5 +$as_echo "$ac_cv_c_inline" >&6; } + +case $ac_cv_c_inline in + inline | yes) ;; + *) + case $ac_cv_c_inline in + no) ac_val=;; + *) ac_val=$ac_cv_c_inline;; + esac + cat >>confdefs.h <<_ACEOF +#ifndef __cplusplus +#define inline $ac_val +#endif +_ACEOF + ;; +esac + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether byte ordering is bigendian" >&5 +$as_echo_n "checking whether byte ordering is bigendian... " >&6; } +if ${ac_cv_c_bigendian+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_cv_c_bigendian=unknown + # See if we're dealing with a universal compiler. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifndef __APPLE_CC__ + not a universal capable compiler + #endif + typedef int dummy; + +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + + # Check for potential -arch flags. It is not universal unless + # there are at least two -arch flags with different values. + ac_arch= + ac_prev= + for ac_word in $CC $CFLAGS $CPPFLAGS $LDFLAGS; do + if test -n "$ac_prev"; then + case $ac_word in + i?86 | x86_64 | ppc | ppc64) + if test -z "$ac_arch" || test "$ac_arch" = "$ac_word"; then + ac_arch=$ac_word + else + ac_cv_c_bigendian=universal + break + fi + ;; + esac + ac_prev= + elif test "x$ac_word" = "x-arch"; then + ac_prev=arch + fi + done +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + if test $ac_cv_c_bigendian = unknown; then + # See if sys/param.h defines the BYTE_ORDER macro. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + #include + +int +main () +{ +#if ! (defined BYTE_ORDER && defined BIG_ENDIAN \ + && defined LITTLE_ENDIAN && BYTE_ORDER && BIG_ENDIAN \ + && LITTLE_ENDIAN) + bogus endian macros + #endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + # It does; now see whether it defined to BIG_ENDIAN or not. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + #include + +int +main () +{ +#if BYTE_ORDER != BIG_ENDIAN + not big endian + #endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_c_bigendian=yes +else + ac_cv_c_bigendian=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + fi + if test $ac_cv_c_bigendian = unknown; then + # See if defines _LITTLE_ENDIAN or _BIG_ENDIAN (e.g., Solaris). + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +int +main () +{ +#if ! (defined _LITTLE_ENDIAN || defined _BIG_ENDIAN) + bogus endian macros + #endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + # It does; now see whether it defined to _BIG_ENDIAN or not. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +int +main () +{ +#ifndef _BIG_ENDIAN + not big endian + #endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_c_bigendian=yes +else + ac_cv_c_bigendian=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + fi + if test $ac_cv_c_bigendian = unknown; then + # Compile a test program. + if test "$cross_compiling" = yes; then : + # Try to guess by grepping values from an object file. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +short int ascii_mm[] = + { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 }; + short int ascii_ii[] = + { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 }; + int use_ascii (int i) { + return ascii_mm[i] + ascii_ii[i]; + } + short int ebcdic_ii[] = + { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 }; + short int ebcdic_mm[] = + { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 }; + int use_ebcdic (int i) { + return ebcdic_mm[i] + ebcdic_ii[i]; + } + extern int foo; + +int +main () +{ +return use_ascii (foo) == use_ebcdic (foo); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + if grep BIGenDianSyS conftest.$ac_objext >/dev/null; then + ac_cv_c_bigendian=yes + fi + if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then + if test "$ac_cv_c_bigendian" = unknown; then + ac_cv_c_bigendian=no + else + # finding both strings is unlikely to happen, but who knows? + ac_cv_c_bigendian=unknown + fi + fi +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ + + /* Are we little or big endian? From Harbison&Steele. */ + union + { + long int l; + char c[sizeof (long int)]; + } u; + u.l = 1; + return u.c[sizeof (long int) - 1] == 1; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + ac_cv_c_bigendian=no +else + ac_cv_c_bigendian=yes +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_bigendian" >&5 +$as_echo "$ac_cv_c_bigendian" >&6; } + case $ac_cv_c_bigendian in #( + yes) + $as_echo "#define WORDS_BIGENDIAN 1" >>confdefs.h +;; #( + no) + ;; #( + universal) + +$as_echo "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h + + ;; #( + *) + as_fn_error $? "unknown endianness + presetting ac_cv_c_bigendian=no (or yes) will help" "$LINENO" 5 ;; + esac + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for preprocessor stringizing operator" >&5 +$as_echo_n "checking for preprocessor stringizing operator... " >&6; } +if ${ac_cv_c_stringize+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#define x(y) #y + +char *s = x(teststring); +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "#teststring" >/dev/null 2>&1; then : + ac_cv_c_stringize=no +else + ac_cv_c_stringize=yes +fi +rm -f conftest* + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_stringize" >&5 +$as_echo "$ac_cv_c_stringize" >&6; } +if test $ac_cv_c_stringize = yes; then + +$as_echo "#define HAVE_STRINGIZE 1" >>confdefs.h + +fi + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for long double with more range or precision than double" >&5 +$as_echo_n "checking for long double with more range or precision than double... " >&6; } +if ${ac_cv_type_long_double_wider+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + long double const a[] = + { + 0.0L, DBL_MIN, DBL_MAX, DBL_EPSILON, + LDBL_MIN, LDBL_MAX, LDBL_EPSILON + }; + long double + f (long double x) + { + return ((x + (unsigned long int) 10) * (-1 / x) + a[0] + + (x ? f (x) : 'c')); + } + +int +main () +{ +static int test_array [1 - 2 * !((0 < ((DBL_MAX_EXP < LDBL_MAX_EXP) + + (DBL_MANT_DIG < LDBL_MANT_DIG) + - (LDBL_MAX_EXP < DBL_MAX_EXP) + - (LDBL_MANT_DIG < DBL_MANT_DIG))) + && (int) LDBL_EPSILON == 0 + )]; +test_array [0] = 0; +return test_array [0]; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_type_long_double_wider=yes +else + ac_cv_type_long_double_wider=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_long_double_wider" >&5 +$as_echo "$ac_cv_type_long_double_wider" >&6; } + if test $ac_cv_type_long_double_wider = yes; then + +$as_echo "#define HAVE_LONG_DOUBLE_WIDER 1" >>confdefs.h + + fi + + ac_cv_c_long_double=$ac_cv_type_long_double_wider + if test $ac_cv_c_long_double = yes; then + +$as_echo "#define HAVE_LONG_DOUBLE 1" >>confdefs.h + + fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for function prototypes" >&5 +$as_echo_n "checking for function prototypes... " >&6; } +if test "$ac_cv_prog_cc_c89" != no; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + +$as_echo "#define PROTOTYPES 1" >>confdefs.h + + +$as_echo "#define __PROTOTYPES 1" >>confdefs.h + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether char is unsigned" >&5 +$as_echo_n "checking whether char is unsigned... " >&6; } +if ${ac_cv_c_char_unsigned+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((char) -1) < 0)]; +test_array [0] = 0; +return test_array [0]; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_c_char_unsigned=no +else + ac_cv_c_char_unsigned=yes +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_char_unsigned" >&5 +$as_echo "$ac_cv_c_char_unsigned" >&6; } +if test $ac_cv_c_char_unsigned = yes && test "$GCC" != yes; then + $as_echo "#define __CHAR_UNSIGNED__ 1" >>confdefs.h + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for working volatile" >&5 +$as_echo_n "checking for working volatile... " >&6; } +if ${ac_cv_c_volatile+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + +volatile int x; +int * volatile y = (int *) 0; +return !x && !y; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_c_volatile=yes +else + ac_cv_c_volatile=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_volatile" >&5 +$as_echo "$ac_cv_c_volatile" >&6; } +if test $ac_cv_c_volatile = no; then + +$as_echo "#define volatile /**/" >>confdefs.h + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C/C++ restrict keyword" >&5 +$as_echo_n "checking for C/C++ restrict keyword... " >&6; } +if ${ac_cv_c_restrict+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_cv_c_restrict=no + # The order here caters to the fact that C++ does not require restrict. + for ac_kw in __restrict __restrict__ _Restrict restrict; do + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +typedef int * int_ptr; + int foo (int_ptr $ac_kw ip) { + return ip[0]; + } +int +main () +{ +int s[1]; + int * $ac_kw t = s; + t[0] = 0; + return foo(t) + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_c_restrict=$ac_kw +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + test "$ac_cv_c_restrict" != no && break + done + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_restrict" >&5 +$as_echo "$ac_cv_c_restrict" >&6; } + + case $ac_cv_c_restrict in + restrict) ;; + no) $as_echo "#define restrict /**/" >>confdefs.h + ;; + *) cat >>confdefs.h <<_ACEOF +#define restrict $ac_cv_c_restrict +_ACEOF + ;; + esac + + + + MKINSTALLDIRS= + if test -n "$ac_aux_dir"; then + case "$ac_aux_dir" in + /*) MKINSTALLDIRS="$ac_aux_dir/mkinstalldirs" ;; + *) MKINSTALLDIRS="\$(top_builddir)/$ac_aux_dir/mkinstalldirs" ;; + esac + fi + if test -z "$MKINSTALLDIRS"; then + MKINSTALLDIRS="\$(top_srcdir)/mkinstalldirs" + fi + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether NLS is requested" >&5 +$as_echo_n "checking whether NLS is requested... " >&6; } + # Check whether --enable-nls was given. +if test "${enable_nls+set}" = set; then : + enableval=$enable_nls; USE_NLS=$enableval +else + USE_NLS=yes +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $USE_NLS" >&5 +$as_echo "$USE_NLS" >&6; } + + + + + + +# Prepare PATH_SEPARATOR. +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh +fi + +# Find out how to test for executable files. Don't use a zero-byte file, +# as systems may use methods other than mode bits to determine executability. +cat >conf$$.file <<_ASEOF +#! /bin/sh +exit 0 +_ASEOF +chmod +x conf$$.file +if test -x conf$$.file >/dev/null 2>&1; then + ac_executable_p="test -x" +else + ac_executable_p="test -f" +fi +rm -f conf$$.file + +# Extract the first word of "msgfmt", so it can be a program name with args. +set dummy msgfmt; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_MSGFMT+:} false; then : + $as_echo_n "(cached) " >&6 +else + case "$MSGFMT" in + [\\/]* | ?:[\\/]*) + ac_cv_path_MSGFMT="$MSGFMT" # Let the user override the test with a path. + ;; + *) + ac_save_IFS="$IFS"; IFS=$PATH_SEPARATOR + for ac_dir in $PATH; do + IFS="$ac_save_IFS" + test -z "$ac_dir" && ac_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $ac_executable_p "$ac_dir/$ac_word$ac_exec_ext"; then + if $ac_dir/$ac_word --statistics /dev/null >/dev/null 2>&1 && + (if $ac_dir/$ac_word --statistics /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi); then + ac_cv_path_MSGFMT="$ac_dir/$ac_word$ac_exec_ext" + break 2 + fi + fi + done + done + IFS="$ac_save_IFS" + test -z "$ac_cv_path_MSGFMT" && ac_cv_path_MSGFMT=":" + ;; +esac +fi +MSGFMT="$ac_cv_path_MSGFMT" +if test "$MSGFMT" != ":"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MSGFMT" >&5 +$as_echo "$MSGFMT" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + # Extract the first word of "gmsgfmt", so it can be a program name with args. +set dummy gmsgfmt; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_GMSGFMT+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $GMSGFMT in + [\\/]* | ?:[\\/]*) + ac_cv_path_GMSGFMT="$GMSGFMT" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_GMSGFMT="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + test -z "$ac_cv_path_GMSGFMT" && ac_cv_path_GMSGFMT="$MSGFMT" + ;; +esac +fi +GMSGFMT=$ac_cv_path_GMSGFMT +if test -n "$GMSGFMT"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GMSGFMT" >&5 +$as_echo "$GMSGFMT" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + + +# Prepare PATH_SEPARATOR. +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh +fi + +# Find out how to test for executable files. Don't use a zero-byte file, +# as systems may use methods other than mode bits to determine executability. +cat >conf$$.file <<_ASEOF +#! /bin/sh +exit 0 +_ASEOF +chmod +x conf$$.file +if test -x conf$$.file >/dev/null 2>&1; then + ac_executable_p="test -x" +else + ac_executable_p="test -f" +fi +rm -f conf$$.file + +# Extract the first word of "xgettext", so it can be a program name with args. +set dummy xgettext; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_XGETTEXT+:} false; then : + $as_echo_n "(cached) " >&6 +else + case "$XGETTEXT" in + [\\/]* | ?:[\\/]*) + ac_cv_path_XGETTEXT="$XGETTEXT" # Let the user override the test with a path. + ;; + *) + ac_save_IFS="$IFS"; IFS=$PATH_SEPARATOR + for ac_dir in $PATH; do + IFS="$ac_save_IFS" + test -z "$ac_dir" && ac_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $ac_executable_p "$ac_dir/$ac_word$ac_exec_ext"; then + if $ac_dir/$ac_word --omit-header --copyright-holder= --msgid-bugs-address= /dev/null >/dev/null 2>&1 && + (if $ac_dir/$ac_word --omit-header --copyright-holder= --msgid-bugs-address= /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi); then + ac_cv_path_XGETTEXT="$ac_dir/$ac_word$ac_exec_ext" + break 2 + fi + fi + done + done + IFS="$ac_save_IFS" + test -z "$ac_cv_path_XGETTEXT" && ac_cv_path_XGETTEXT=":" + ;; +esac +fi +XGETTEXT="$ac_cv_path_XGETTEXT" +if test "$XGETTEXT" != ":"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $XGETTEXT" >&5 +$as_echo "$XGETTEXT" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + rm -f messages.po + + +# Prepare PATH_SEPARATOR. +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh +fi + +# Find out how to test for executable files. Don't use a zero-byte file, +# as systems may use methods other than mode bits to determine executability. +cat >conf$$.file <<_ASEOF +#! /bin/sh +exit 0 +_ASEOF +chmod +x conf$$.file +if test -x conf$$.file >/dev/null 2>&1; then + ac_executable_p="test -x" +else + ac_executable_p="test -f" +fi +rm -f conf$$.file + +# Extract the first word of "msgmerge", so it can be a program name with args. +set dummy msgmerge; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_MSGMERGE+:} false; then : + $as_echo_n "(cached) " >&6 +else + case "$MSGMERGE" in + [\\/]* | ?:[\\/]*) + ac_cv_path_MSGMERGE="$MSGMERGE" # Let the user override the test with a path. + ;; + *) + ac_save_IFS="$IFS"; IFS=$PATH_SEPARATOR + for ac_dir in $PATH; do + IFS="$ac_save_IFS" + test -z "$ac_dir" && ac_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $ac_executable_p "$ac_dir/$ac_word$ac_exec_ext"; then + if $ac_dir/$ac_word --update -q /dev/null /dev/null >/dev/null 2>&1; then + ac_cv_path_MSGMERGE="$ac_dir/$ac_word$ac_exec_ext" + break 2 + fi + fi + done + done + IFS="$ac_save_IFS" + test -z "$ac_cv_path_MSGMERGE" && ac_cv_path_MSGMERGE=":" + ;; +esac +fi +MSGMERGE="$ac_cv_path_MSGMERGE" +if test "$MSGMERGE" != ":"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MSGMERGE" >&5 +$as_echo "$MSGMERGE" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + if test "$GMSGFMT" != ":"; then + if $GMSGFMT --statistics /dev/null >/dev/null 2>&1 && + (if $GMSGFMT --statistics /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi); then + : ; + else + GMSGFMT=`echo "$GMSGFMT" | sed -e 's,^.*/,,'` + { $as_echo "$as_me:${as_lineno-$LINENO}: result: found $GMSGFMT program is not GNU msgfmt; ignore it" >&5 +$as_echo "found $GMSGFMT program is not GNU msgfmt; ignore it" >&6; } + GMSGFMT=":" + fi + fi + + if test "$XGETTEXT" != ":"; then + if $XGETTEXT --omit-header --copyright-holder= --msgid-bugs-address= /dev/null >/dev/null 2>&1 && + (if $XGETTEXT --omit-header --copyright-holder= --msgid-bugs-address= /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi); then + : ; + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: found xgettext program is not GNU xgettext; ignore it" >&5 +$as_echo "found xgettext program is not GNU xgettext; ignore it" >&6; } + XGETTEXT=":" + fi + rm -f messages.po + fi + + ac_config_commands="$ac_config_commands default-1" + + +ac_fn_c_check_type "$LINENO" "off_t" "ac_cv_type_off_t" "$ac_includes_default" +if test "x$ac_cv_type_off_t" = xyes; then : + +else + +cat >>confdefs.h <<_ACEOF +#define off_t long int +_ACEOF + +fi + +ac_fn_c_check_type "$LINENO" "size_t" "ac_cv_type_size_t" "$ac_includes_default" +if test "x$ac_cv_type_size_t" = xyes; then : + +else + +cat >>confdefs.h <<_ACEOF +#define size_t unsigned int +_ACEOF + +fi + +# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works +# for constant arguments. Useless! +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for working alloca.h" >&5 +$as_echo_n "checking for working alloca.h... " >&6; } +if ${ac_cv_working_alloca_h+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ +char *p = (char *) alloca (2 * sizeof (int)); + if (p) return 0; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_working_alloca_h=yes +else + ac_cv_working_alloca_h=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_working_alloca_h" >&5 +$as_echo "$ac_cv_working_alloca_h" >&6; } +if test $ac_cv_working_alloca_h = yes; then + +$as_echo "#define HAVE_ALLOCA_H 1" >>confdefs.h + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for alloca" >&5 +$as_echo_n "checking for alloca... " >&6; } +if ${ac_cv_func_alloca_works+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __GNUC__ +# define alloca __builtin_alloca +#else +# ifdef _MSC_VER +# include +# define alloca _alloca +# else +# ifdef HAVE_ALLOCA_H +# include +# else +# ifdef _AIX + #pragma alloca +# else +# ifndef alloca /* predefined by HP cc +Olibcalls */ +void *alloca (size_t); +# endif +# endif +# endif +# endif +#endif + +int +main () +{ +char *p = (char *) alloca (1); + if (p) return 0; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_func_alloca_works=yes +else + ac_cv_func_alloca_works=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_alloca_works" >&5 +$as_echo "$ac_cv_func_alloca_works" >&6; } + +if test $ac_cv_func_alloca_works = yes; then + +$as_echo "#define HAVE_ALLOCA 1" >>confdefs.h + +else + # The SVR3 libPW and SVR4 libucb both contain incompatible functions +# that cause trouble. Some versions do not even contain alloca or +# contain a buggy version. If you still want to use their alloca, +# use ar to extract alloca.o from them instead of compiling alloca.c. + +ALLOCA=\${LIBOBJDIR}alloca.$ac_objext + +$as_echo "#define C_ALLOCA 1" >>confdefs.h + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether \`alloca.c' needs Cray hooks" >&5 +$as_echo_n "checking whether \`alloca.c' needs Cray hooks... " >&6; } +if ${ac_cv_os_cray+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#if defined CRAY && ! defined CRAY2 +webecray +#else +wenotbecray +#endif + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "webecray" >/dev/null 2>&1; then : + ac_cv_os_cray=yes +else + ac_cv_os_cray=no +fi +rm -f conftest* + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_os_cray" >&5 +$as_echo "$ac_cv_os_cray" >&6; } +if test $ac_cv_os_cray = yes; then + for ac_func in _getb67 GETB67 getb67; do + as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" +if eval test \"x\$"$as_ac_var"\" = x"yes"; then : + +cat >>confdefs.h <<_ACEOF +#define CRAY_STACKSEG_END $ac_func +_ACEOF + + break +fi + + done +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking stack direction for C alloca" >&5 +$as_echo_n "checking stack direction for C alloca... " >&6; } +if ${ac_cv_c_stack_direction+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + ac_cv_c_stack_direction=0 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$ac_includes_default +int +find_stack_direction (int *addr, int depth) +{ + int dir, dummy = 0; + if (! addr) + addr = &dummy; + *addr = addr < &dummy ? 1 : addr == &dummy ? 0 : -1; + dir = depth ? find_stack_direction (addr, depth - 1) : 0; + return dir + dummy; +} + +int +main (int argc, char **argv) +{ + return find_stack_direction (0, argc + !argv + 20) < 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + ac_cv_c_stack_direction=1 +else + ac_cv_c_stack_direction=-1 +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_stack_direction" >&5 +$as_echo "$ac_cv_c_stack_direction" >&6; } +cat >>confdefs.h <<_ACEOF +#define STACK_DIRECTION $ac_cv_c_stack_direction +_ACEOF + + +fi + + + + + for ac_header in $ac_header_list +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default +" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + + + + + + + +for ac_func in getpagesize +do : + ac_fn_c_check_func "$LINENO" "getpagesize" "ac_cv_func_getpagesize" +if test "x$ac_cv_func_getpagesize" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_GETPAGESIZE 1 +_ACEOF + +fi +done + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for working mmap" >&5 +$as_echo_n "checking for working mmap... " >&6; } +if ${ac_cv_func_mmap_fixed_mapped+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + ac_cv_func_mmap_fixed_mapped=no +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$ac_includes_default +/* malloc might have been renamed as rpl_malloc. */ +#undef malloc + +/* Thanks to Mike Haertel and Jim Avera for this test. + Here is a matrix of mmap possibilities: + mmap private not fixed + mmap private fixed at somewhere currently unmapped + mmap private fixed at somewhere already mapped + mmap shared not fixed + mmap shared fixed at somewhere currently unmapped + mmap shared fixed at somewhere already mapped + For private mappings, we should verify that changes cannot be read() + back from the file, nor mmap's back from the file at a different + address. (There have been systems where private was not correctly + implemented like the infamous i386 svr4.0, and systems where the + VM page cache was not coherent with the file system buffer cache + like early versions of FreeBSD and possibly contemporary NetBSD.) + For shared mappings, we should conversely verify that changes get + propagated back to all the places they're supposed to be. + + Grep wants private fixed already mapped. + The main things grep needs to know about mmap are: + * does it exist and is it safe to write into the mmap'd area + * how to use it (BSD variants) */ + +#include +#include + +#if !defined STDC_HEADERS && !defined HAVE_STDLIB_H +char *malloc (); +#endif + +/* This mess was copied from the GNU getpagesize.h. */ +#ifndef HAVE_GETPAGESIZE +# ifdef _SC_PAGESIZE +# define getpagesize() sysconf(_SC_PAGESIZE) +# else /* no _SC_PAGESIZE */ +# ifdef HAVE_SYS_PARAM_H +# include +# ifdef EXEC_PAGESIZE +# define getpagesize() EXEC_PAGESIZE +# else /* no EXEC_PAGESIZE */ +# ifdef NBPG +# define getpagesize() NBPG * CLSIZE +# ifndef CLSIZE +# define CLSIZE 1 +# endif /* no CLSIZE */ +# else /* no NBPG */ +# ifdef NBPC +# define getpagesize() NBPC +# else /* no NBPC */ +# ifdef PAGESIZE +# define getpagesize() PAGESIZE +# endif /* PAGESIZE */ +# endif /* no NBPC */ +# endif /* no NBPG */ +# endif /* no EXEC_PAGESIZE */ +# else /* no HAVE_SYS_PARAM_H */ +# define getpagesize() 8192 /* punt totally */ +# endif /* no HAVE_SYS_PARAM_H */ +# endif /* no _SC_PAGESIZE */ + +#endif /* no HAVE_GETPAGESIZE */ + +int +main () +{ + char *data, *data2, *data3; + const char *cdata2; + int i, pagesize; + int fd, fd2; + + pagesize = getpagesize (); + + /* First, make a file with some known garbage in it. */ + data = (char *) malloc (pagesize); + if (!data) + return 1; + for (i = 0; i < pagesize; ++i) + *(data + i) = rand (); + umask (0); + fd = creat ("conftest.mmap", 0600); + if (fd < 0) + return 2; + if (write (fd, data, pagesize) != pagesize) + return 3; + close (fd); + + /* Next, check that the tail of a page is zero-filled. File must have + non-zero length, otherwise we risk SIGBUS for entire page. */ + fd2 = open ("conftest.txt", O_RDWR | O_CREAT | O_TRUNC, 0600); + if (fd2 < 0) + return 4; + cdata2 = ""; + if (write (fd2, cdata2, 1) != 1) + return 5; + data2 = (char *) mmap (0, pagesize, PROT_READ | PROT_WRITE, MAP_SHARED, fd2, 0L); + if (data2 == MAP_FAILED) + return 6; + for (i = 0; i < pagesize; ++i) + if (*(data2 + i)) + return 7; + close (fd2); + if (munmap (data2, pagesize)) + return 8; + + /* Next, try to mmap the file at a fixed address which already has + something else allocated at it. If we can, also make sure that + we see the same garbage. */ + fd = open ("conftest.mmap", O_RDWR); + if (fd < 0) + return 9; + if (data2 != mmap (data2, pagesize, PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_FIXED, fd, 0L)) + return 10; + for (i = 0; i < pagesize; ++i) + if (*(data + i) != *(data2 + i)) + return 11; + + /* Finally, make sure that changes to the mapped area do not + percolate back to the file as seen by read(). (This is a bug on + some variants of i386 svr4.0.) */ + for (i = 0; i < pagesize; ++i) + *(data2 + i) = *(data2 + i) + 1; + data3 = (char *) malloc (pagesize); + if (!data3) + return 12; + if (read (fd, data3, pagesize) != pagesize) + return 13; + for (i = 0; i < pagesize; ++i) + if (*(data + i) != *(data3 + i)) + return 14; + close (fd); + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + ac_cv_func_mmap_fixed_mapped=yes +else + ac_cv_func_mmap_fixed_mapped=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_mmap_fixed_mapped" >&5 +$as_echo "$ac_cv_func_mmap_fixed_mapped" >&6; } +if test $ac_cv_func_mmap_fixed_mapped = yes; then + +$as_echo "#define HAVE_MMAP 1" >>confdefs.h + +fi +rm -f conftest.mmap conftest.txt + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C Library 2.1 or newer" >&5 +$as_echo_n "checking whether we are using the GNU C Library 2.1 or newer... " >&6; } +if ${ac_cv_gnu_library_2_1+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#ifdef __GNU_LIBRARY__ + #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2) + Lucky GNU user + #endif +#endif + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "Lucky GNU user" >/dev/null 2>&1; then : + ac_cv_gnu_library_2_1=yes +else + ac_cv_gnu_library_2_1=no +fi +rm -f conftest* + + + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_gnu_library_2_1" >&5 +$as_echo "$ac_cv_gnu_library_2_1" >&6; } + + GLIBC21="$ac_cv_gnu_library_2_1" + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether integer division by zero raises SIGFPE" >&5 +$as_echo_n "checking whether integer division by zero raises SIGFPE... " >&6; } +if ${gt_cv_int_divbyzero_sigfpe+:} false; then : + $as_echo_n "(cached) " >&6 +else + + if test "$cross_compiling" = yes; then : + + # Guess based on the CPU. + case "$host_cpu" in + alpha* | i3456786 | m68k | s390*) + gt_cv_int_divbyzero_sigfpe="guessing yes";; + *) + gt_cv_int_divbyzero_sigfpe="guessing no";; + esac + +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include + +static void +#ifdef __cplusplus +sigfpe_handler (int sig) +#else +sigfpe_handler (sig) int sig; +#endif +{ + /* Exit with code 0 if SIGFPE, with code 1 if any other signal. */ + exit (sig != SIGFPE); +} + +int x = 1; +int y = 0; +int z; +int nan; + +int main () +{ + signal (SIGFPE, sigfpe_handler); +/* IRIX and AIX (when "xlc -qcheck" is used) yield signal SIGTRAP. */ +#if (defined (__sgi) || defined (_AIX)) && defined (SIGTRAP) + signal (SIGTRAP, sigfpe_handler); +#endif +/* Linux/SPARC yields signal SIGILL. */ +#if defined (__sparc__) && defined (__linux__) + signal (SIGILL, sigfpe_handler); +#endif + + z = x / y; + nan = y / y; + exit (1); +} + +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + gt_cv_int_divbyzero_sigfpe=yes +else + gt_cv_int_divbyzero_sigfpe=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_cv_int_divbyzero_sigfpe" >&5 +$as_echo "$gt_cv_int_divbyzero_sigfpe" >&6; } + case "$gt_cv_int_divbyzero_sigfpe" in + *yes) value=1;; + *) value=0;; + esac + +cat >>confdefs.h <<_ACEOF +#define INTDIV0_RAISES_SIGFPE $value +_ACEOF + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for inttypes.h" >&5 +$as_echo_n "checking for inttypes.h... " >&6; } +if ${jm_ac_cv_header_inttypes_h+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +int +main () +{ +uintmax_t i = (uintmax_t) -1; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + jm_ac_cv_header_inttypes_h=yes +else + jm_ac_cv_header_inttypes_h=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $jm_ac_cv_header_inttypes_h" >&5 +$as_echo "$jm_ac_cv_header_inttypes_h" >&6; } + if test $jm_ac_cv_header_inttypes_h = yes; then + +cat >>confdefs.h <<_ACEOF +#define HAVE_INTTYPES_H_WITH_UINTMAX 1 +_ACEOF + + fi + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for stdint.h" >&5 +$as_echo_n "checking for stdint.h... " >&6; } +if ${jm_ac_cv_header_stdint_h+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +int +main () +{ +uintmax_t i = (uintmax_t) -1; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + jm_ac_cv_header_stdint_h=yes +else + jm_ac_cv_header_stdint_h=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $jm_ac_cv_header_stdint_h" >&5 +$as_echo "$jm_ac_cv_header_stdint_h" >&6; } + if test $jm_ac_cv_header_stdint_h = yes; then + +cat >>confdefs.h <<_ACEOF +#define HAVE_STDINT_H_WITH_UINTMAX 1 +_ACEOF + + fi + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for unsigned long long" >&5 +$as_echo_n "checking for unsigned long long... " >&6; } +if ${ac_cv_type_unsigned_long_long+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +unsigned long long ull = 1; int i = 63; +int +main () +{ +unsigned long long ullmax = (unsigned long long) -1; + return ull << i | ull >> i | ullmax / ull | ullmax % ull; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_type_unsigned_long_long=yes +else + ac_cv_type_unsigned_long_long=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_unsigned_long_long" >&5 +$as_echo "$ac_cv_type_unsigned_long_long" >&6; } + if test $ac_cv_type_unsigned_long_long = yes; then + +$as_echo "#define HAVE_UNSIGNED_LONG_LONG 1" >>confdefs.h + + fi + + + + + if test $jm_ac_cv_header_inttypes_h = no && test $jm_ac_cv_header_stdint_h = no; then + + test $ac_cv_type_unsigned_long_long = yes \ + && ac_type='unsigned long long' \ + || ac_type='unsigned long' + +cat >>confdefs.h <<_ACEOF +#define uintmax_t $ac_type +_ACEOF + + else + +$as_echo "#define HAVE_UINTMAX_T 1" >>confdefs.h + + fi + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for inttypes.h" >&5 +$as_echo_n "checking for inttypes.h... " >&6; } +if ${gt_cv_header_inttypes_h+:} false; then : + $as_echo_n "(cached) " >&6 +else + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + gt_cv_header_inttypes_h=yes +else + gt_cv_header_inttypes_h=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_cv_header_inttypes_h" >&5 +$as_echo "$gt_cv_header_inttypes_h" >&6; } + if test $gt_cv_header_inttypes_h = yes; then + +cat >>confdefs.h <<_ACEOF +#define HAVE_INTTYPES_H 1 +_ACEOF + + fi + + + + if test $gt_cv_header_inttypes_h = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the inttypes.h PRIxNN macros are broken" >&5 +$as_echo_n "checking whether the inttypes.h PRIxNN macros are broken... " >&6; } +if ${gt_cv_inttypes_pri_broken+:} false; then : + $as_echo_n "(cached) " >&6 +else + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#ifdef PRId32 +char *p = PRId32; +#endif + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + gt_cv_inttypes_pri_broken=no +else + gt_cv_inttypes_pri_broken=yes +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_cv_inttypes_pri_broken" >&5 +$as_echo "$gt_cv_inttypes_pri_broken" >&6; } + fi + if test "$gt_cv_inttypes_pri_broken" = yes; then + +cat >>confdefs.h <<_ACEOF +#define PRI_MACROS_BROKEN 1 +_ACEOF + + fi + + + if test "X$prefix" = "XNONE"; then + acl_final_prefix="$ac_default_prefix" + else + acl_final_prefix="$prefix" + fi + if test "X$exec_prefix" = "XNONE"; then + acl_final_exec_prefix='${prefix}' + else + acl_final_exec_prefix="$exec_prefix" + fi + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + eval acl_final_exec_prefix=\"$acl_final_exec_prefix\" + prefix="$acl_save_prefix" + + +# Check whether --with-gnu-ld was given. +if test "${with_gnu_ld+set}" = set; then : + withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes +else + with_gnu_ld=no +fi + +# Prepare PATH_SEPARATOR. +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh +fi +ac_prog=ld +if test "$GCC" = yes; then + # Check if gcc -print-prog-name=ld gives a path. + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by GCC" >&5 +$as_echo_n "checking for ld used by GCC... " >&6; } + case $host in + *-*-mingw*) + # gcc leaves a trailing carriage return which upsets mingw + ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; + *) + ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; + esac + case $ac_prog in + # Accept absolute paths. + [\\/]* | [A-Za-z]:[\\/]*) + re_direlt='/[^/][^/]*/\.\./' + # Canonicalize the path of ld + ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'` + while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do + ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"` + done + test -z "$LD" && LD="$ac_prog" + ;; + "") + # If it fails, then pretend we aren't using GCC. + ac_prog=ld + ;; + *) + # If it is relative, then search for the first ld in PATH. + with_gnu_ld=unknown + ;; + esac +elif test "$with_gnu_ld" = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5 +$as_echo_n "checking for GNU ld... " >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5 +$as_echo_n "checking for non-GNU ld... " >&6; } +fi +if ${acl_cv_path_LD+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -z "$LD"; then + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}" + for ac_dir in $PATH; do + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then + acl_cv_path_LD="$ac_dir/$ac_prog" + # Check to see if the program is GNU ld. I'd rather use --version, + # but apparently some GNU ld's only accept -v. + # Break only if it was the GNU/non-GNU ld that we prefer. + if "$acl_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then + test "$with_gnu_ld" != no && break + else + test "$with_gnu_ld" != yes && break + fi + fi + done + IFS="$ac_save_ifs" +else + acl_cv_path_LD="$LD" # Let the user override the test with a path. +fi +fi + +LD="$acl_cv_path_LD" +if test -n "$LD"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD" >&5 +$as_echo "$LD" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi +test -z "$LD" && as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5 +$as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; } +if ${acl_cv_prog_gnu_ld+:} false; then : + $as_echo_n "(cached) " >&6 +else + # I'd rather use --version here, but apparently some GNU ld's only accept -v. +if $LD -v 2>&1 &5; then + acl_cv_prog_gnu_ld=yes +else + acl_cv_prog_gnu_ld=no +fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $acl_cv_prog_gnu_ld" >&5 +$as_echo "$acl_cv_prog_gnu_ld" >&6; } +with_gnu_ld=$acl_cv_prog_gnu_ld + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shared library run path origin" >&5 +$as_echo_n "checking for shared library run path origin... " >&6; } +if ${acl_cv_rpath+:} false; then : + $as_echo_n "(cached) " >&6 +else + + CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \ + ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh + . ./conftest.sh + rm -f ./conftest.sh + acl_cv_rpath=done + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $acl_cv_rpath" >&5 +$as_echo "$acl_cv_rpath" >&6; } + wl="$acl_cv_wl" + libext="$acl_cv_libext" + shlibext="$acl_cv_shlibext" + hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec" + hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator" + hardcode_direct="$acl_cv_hardcode_direct" + hardcode_minus_L="$acl_cv_hardcode_minus_L" + # Check whether --enable-rpath was given. +if test "${enable_rpath+set}" = set; then : + enableval=$enable_rpath; : +else + enable_rpath=yes +fi + + + + + + + + + use_additional=yes + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + + eval additional_includedir=\"$includedir\" + eval additional_libdir=\"$libdir\" + + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + +# Check whether --with-libiconv-prefix was given. +if test "${with_libiconv_prefix+set}" = set; then : + withval=$with_libiconv_prefix; + if test "X$withval" = "Xno"; then + use_additional=no + else + if test "X$withval" = "X"; then + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + + eval additional_includedir=\"$includedir\" + eval additional_libdir=\"$libdir\" + + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + else + additional_includedir="$withval/include" + additional_libdir="$withval/lib" + fi + fi + +fi + + LIBICONV= + LTLIBICONV= + INCICONV= + rpathdirs= + ltrpathdirs= + names_already_handled= + names_next_round='iconv ' + while test -n "$names_next_round"; do + names_this_round="$names_next_round" + names_next_round= + for name in $names_this_round; do + already_handled= + for n in $names_already_handled; do + if test "$n" = "$name"; then + already_handled=yes + break + fi + done + if test -z "$already_handled"; then + names_already_handled="$names_already_handled $name" + uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'` + eval value=\"\$HAVE_LIB$uppername\" + if test -n "$value"; then + if test "$value" = yes; then + eval value=\"\$LIB$uppername\" + test -z "$value" || LIBICONV="${LIBICONV}${LIBICONV:+ }$value" + eval value=\"\$LTLIB$uppername\" + test -z "$value" || LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }$value" + else + : + fi + else + found_dir= + found_la= + found_so= + found_a= + if test $use_additional = yes; then + if test "X$prefer_shared" = "Xyes" && test -n "$shlibext" && test -f "$additional_libdir/lib$name.$shlibext"; then + found_dir="$additional_libdir" + found_so="$additional_libdir/lib$name.$shlibext" + if test -f "$additional_libdir/lib$name.la"; then + found_la="$additional_libdir/lib$name.la" + fi + else + if test -f "$additional_libdir/lib$name.$libext"; then + found_dir="$additional_libdir" + found_a="$additional_libdir/lib$name.$libext" + if test -f "$additional_libdir/lib$name.la"; then + found_la="$additional_libdir/lib$name.la" + fi + fi + fi + fi + if test "X$found_dir" = "X"; then + for x in $LDFLAGS $LTLIBICONV; do + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + eval x=\"$x\" + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + case "$x" in + -L*) + dir=`echo "X$x" | sed -e 's/^X-L//'` + if test "X$prefer_shared" = "Xyes" && test -n "$shlibext" && test -f "$dir/lib$name.$shlibext"; then + found_dir="$dir" + found_so="$dir/lib$name.$shlibext" + if test -f "$dir/lib$name.la"; then + found_la="$dir/lib$name.la" + fi + else + if test -f "$dir/lib$name.$libext"; then + found_dir="$dir" + found_a="$dir/lib$name.$libext" + if test -f "$dir/lib$name.la"; then + found_la="$dir/lib$name.la" + fi + fi + fi + ;; + esac + if test "X$found_dir" != "X"; then + break + fi + done + fi + if test "X$found_dir" != "X"; then + LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }-L$found_dir -l$name" + if test "X$found_so" != "X"; then + if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/lib"; then + LIBICONV="${LIBICONV}${LIBICONV:+ }$found_so" + else + haveit= + for x in $ltrpathdirs; do + if test "X$x" = "X$found_dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + ltrpathdirs="$ltrpathdirs $found_dir" + fi + if test "$hardcode_direct" = yes; then + LIBICONV="${LIBICONV}${LIBICONV:+ }$found_so" + else + if test -n "$hardcode_libdir_flag_spec" && test "$hardcode_minus_L" = no; then + LIBICONV="${LIBICONV}${LIBICONV:+ }$found_so" + haveit= + for x in $rpathdirs; do + if test "X$x" = "X$found_dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + rpathdirs="$rpathdirs $found_dir" + fi + else + haveit= + for x in $LDFLAGS $LIBICONV; do + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + eval x=\"$x\" + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + if test "X$x" = "X-L$found_dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + LIBICONV="${LIBICONV}${LIBICONV:+ }-L$found_dir" + fi + if test "$hardcode_minus_L" != no; then + LIBICONV="${LIBICONV}${LIBICONV:+ }$found_so" + else + LIBICONV="${LIBICONV}${LIBICONV:+ }-l$name" + fi + fi + fi + fi + else + if test "X$found_a" != "X"; then + LIBICONV="${LIBICONV}${LIBICONV:+ }$found_a" + else + LIBICONV="${LIBICONV}${LIBICONV:+ }-L$found_dir -l$name" + fi + fi + additional_includedir= + case "$found_dir" in + */lib | */lib/) + basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e 's,/lib/*$,,'` + additional_includedir="$basedir/include" + ;; + esac + if test "X$additional_includedir" != "X"; then + if test "X$additional_includedir" != "X/usr/include"; then + haveit= + if test "X$additional_includedir" = "X/usr/local/include"; then + if test -n "$GCC"; then + case $host_os in + linux*) haveit=yes;; + esac + fi + fi + if test -z "$haveit"; then + for x in $CPPFLAGS $INCICONV; do + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + eval x=\"$x\" + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + if test "X$x" = "X-I$additional_includedir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test -d "$additional_includedir"; then + INCICONV="${INCICONV}${INCICONV:+ }-I$additional_includedir" + fi + fi + fi + fi + fi + if test -n "$found_la"; then + save_libdir="$libdir" + case "$found_la" in + */* | *\\*) . "$found_la" ;; + *) . "./$found_la" ;; + esac + libdir="$save_libdir" + for dep in $dependency_libs; do + case "$dep" in + -L*) + additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'` + if test "X$additional_libdir" != "X/usr/lib"; then + haveit= + if test "X$additional_libdir" = "X/usr/local/lib"; then + if test -n "$GCC"; then + case $host_os in + linux*) haveit=yes;; + esac + fi + fi + if test -z "$haveit"; then + haveit= + for x in $LDFLAGS $LIBICONV; do + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + eval x=\"$x\" + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + if test "X$x" = "X-L$additional_libdir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test -d "$additional_libdir"; then + LIBICONV="${LIBICONV}${LIBICONV:+ }-L$additional_libdir" + fi + fi + haveit= + for x in $LDFLAGS $LTLIBICONV; do + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + eval x=\"$x\" + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + if test "X$x" = "X-L$additional_libdir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test -d "$additional_libdir"; then + LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }-L$additional_libdir" + fi + fi + fi + fi + ;; + -R*) + dir=`echo "X$dep" | sed -e 's/^X-R//'` + if test "$enable_rpath" != no; then + haveit= + for x in $rpathdirs; do + if test "X$x" = "X$dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + rpathdirs="$rpathdirs $dir" + fi + haveit= + for x in $ltrpathdirs; do + if test "X$x" = "X$dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + ltrpathdirs="$ltrpathdirs $dir" + fi + fi + ;; + -l*) + names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'` + ;; + *.la) + names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'` + ;; + *) + LIBICONV="${LIBICONV}${LIBICONV:+ }$dep" + LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }$dep" + ;; + esac + done + fi + else + LIBICONV="${LIBICONV}${LIBICONV:+ }-l$name" + LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }-l$name" + fi + fi + fi + done + done + if test "X$rpathdirs" != "X"; then + if test -n "$hardcode_libdir_separator"; then + alldirs= + for found_dir in $rpathdirs; do + alldirs="${alldirs}${alldirs:+$hardcode_libdir_separator}$found_dir" + done + acl_save_libdir="$libdir" + libdir="$alldirs" + eval flag=\"$hardcode_libdir_flag_spec\" + libdir="$acl_save_libdir" + LIBICONV="${LIBICONV}${LIBICONV:+ }$flag" + else + for found_dir in $rpathdirs; do + acl_save_libdir="$libdir" + libdir="$found_dir" + eval flag=\"$hardcode_libdir_flag_spec\" + libdir="$acl_save_libdir" + LIBICONV="${LIBICONV}${LIBICONV:+ }$flag" + done + fi + fi + if test "X$ltrpathdirs" != "X"; then + for found_dir in $ltrpathdirs; do + LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }-R$found_dir" + done + fi + + + + + for ac_header in argz.h limits.h locale.h nl_types.h malloc.h stddef.h \ +stdlib.h string.h unistd.h sys/param.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + for ac_func in feof_unlocked fgets_unlocked getc_unlocked getcwd getegid \ +geteuid getgid getuid mempcpy munmap putenv setenv setlocale localeconv stpcpy \ +strcasecmp strdup strtoul tsearch __argz_count __argz_stringify __argz_next \ +__fsetlocking +do : + as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" +if eval test \"x\$"$as_ac_var"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + + + + + + + + am_save_CPPFLAGS="$CPPFLAGS" + + for element in $INCICONV; do + haveit= + for x in $CPPFLAGS; do + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + eval x=\"$x\" + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + if test "X$x" = "X$element"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }$element" + fi + done + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for iconv" >&5 +$as_echo_n "checking for iconv... " >&6; } +if ${am_cv_func_iconv+:} false; then : + $as_echo_n "(cached) " >&6 +else + + am_cv_func_iconv="no, consider installing GNU libiconv" + am_cv_lib_iconv=no + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +int +main () +{ +iconv_t cd = iconv_open("",""); + iconv(cd,NULL,NULL,NULL,NULL); + iconv_close(cd); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + am_cv_func_iconv=yes +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + if test "$am_cv_func_iconv" != yes; then + am_save_LIBS="$LIBS" + LIBS="$LIBS $LIBICONV" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +int +main () +{ +iconv_t cd = iconv_open("",""); + iconv(cd,NULL,NULL,NULL,NULL); + iconv_close(cd); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + am_cv_lib_iconv=yes + am_cv_func_iconv=yes +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + LIBS="$am_save_LIBS" + fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_func_iconv" >&5 +$as_echo "$am_cv_func_iconv" >&6; } + if test "$am_cv_func_iconv" = yes; then + +$as_echo "#define HAVE_ICONV 1" >>confdefs.h + + fi + if test "$am_cv_lib_iconv" = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to link with libiconv" >&5 +$as_echo_n "checking how to link with libiconv... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIBICONV" >&5 +$as_echo "$LIBICONV" >&6; } + else + CPPFLAGS="$am_save_CPPFLAGS" + LIBICONV= + LTLIBICONV= + fi + + + + if test "$am_cv_func_iconv" = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for iconv declaration" >&5 +$as_echo_n "checking for iconv declaration... " >&6; } + if ${am_cv_proto_iconv+:} false; then : + $as_echo_n "(cached) " >&6 +else + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include +extern +#ifdef __cplusplus +"C" +#endif +#if defined(__STDC__) || defined(__cplusplus) +size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft); +#else +size_t iconv(); +#endif + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + am_cv_proto_iconv_arg1="" +else + am_cv_proto_iconv_arg1="const" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);" +fi + + am_cv_proto_iconv=`echo "$am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'` + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${ac_t:- + }$am_cv_proto_iconv" >&5 +$as_echo "${ac_t:- + }$am_cv_proto_iconv" >&6; } + +cat >>confdefs.h <<_ACEOF +#define ICONV_CONST $am_cv_proto_iconv_arg1 +_ACEOF + + fi + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for nl_langinfo and CODESET" >&5 +$as_echo_n "checking for nl_langinfo and CODESET... " >&6; } +if ${am_cv_langinfo_codeset+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ +char* cs = nl_langinfo(CODESET); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + am_cv_langinfo_codeset=yes +else + am_cv_langinfo_codeset=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_langinfo_codeset" >&5 +$as_echo "$am_cv_langinfo_codeset" >&6; } + if test $am_cv_langinfo_codeset = yes; then + +$as_echo "#define HAVE_LANGINFO_CODESET 1" >>confdefs.h + + fi + + if test $ac_cv_header_locale_h = yes; then + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for LC_MESSAGES" >&5 +$as_echo_n "checking for LC_MESSAGES... " >&6; } +if ${am_cv_val_LC_MESSAGES+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ +return LC_MESSAGES + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + am_cv_val_LC_MESSAGES=yes +else + am_cv_val_LC_MESSAGES=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_val_LC_MESSAGES" >&5 +$as_echo "$am_cv_val_LC_MESSAGES" >&6; } + if test $am_cv_val_LC_MESSAGES = yes; then + +$as_echo "#define HAVE_LC_MESSAGES 1" >>confdefs.h + + fi + + fi + + for ac_prog in bison +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_INTLBISON+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$INTLBISON"; then + ac_cv_prog_INTLBISON="$INTLBISON" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_INTLBISON="$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +INTLBISON=$ac_cv_prog_INTLBISON +if test -n "$INTLBISON"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $INTLBISON" >&5 +$as_echo "$INTLBISON" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$INTLBISON" && break +done + + if test -z "$INTLBISON"; then + ac_verc_fail=yes + else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking version of bison" >&5 +$as_echo_n "checking version of bison... " >&6; } + ac_prog_version=`$INTLBISON --version 2>&1 | sed -n 's/^.*GNU Bison.* \([0-9]*\.[0-9.]*\).*$/\1/p'` + case $ac_prog_version in + '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;; + 1.2[6-9]* | 1.[3-9][0-9]* | [2-9].*) + ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;; + *) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;; + esac + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_prog_version" >&5 +$as_echo "$ac_prog_version" >&6; } + fi + if test $ac_verc_fail = yes; then + INTLBISON=: + fi + + + + + + + + + + + + + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether NLS is requested" >&5 +$as_echo_n "checking whether NLS is requested... " >&6; } + # Check whether --enable-nls was given. +if test "${enable_nls+set}" = set; then : + enableval=$enable_nls; USE_NLS=$enableval +else + USE_NLS=yes +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $USE_NLS" >&5 +$as_echo "$USE_NLS" >&6; } + + + + + BUILD_INCLUDED_LIBINTL=no + USE_INCLUDED_LIBINTL=no + + LIBINTL= + LTLIBINTL= + POSUB= + + if test "$USE_NLS" = "yes"; then + gt_use_preinstalled_gnugettext=no + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether included gettext is requested" >&5 +$as_echo_n "checking whether included gettext is requested... " >&6; } + +# Check whether --with-included-gettext was given. +if test "${with_included_gettext+set}" = set; then : + withval=$with_included_gettext; nls_cv_force_use_gnu_gettext=$withval +else + nls_cv_force_use_gnu_gettext=no +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $nls_cv_force_use_gnu_gettext" >&5 +$as_echo "$nls_cv_force_use_gnu_gettext" >&6; } + + nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext" + if test "$nls_cv_force_use_gnu_gettext" != "yes"; then + + + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU gettext in libc" >&5 +$as_echo_n "checking for GNU gettext in libc... " >&6; } +if ${gt_cv_func_gnugettext2_libc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +extern int _nl_msg_cat_cntr; +extern int *_nl_domain_bindings; +int +main () +{ +bindtextdomain ("", ""); +return (int) gettext ("") + (int) ngettext ("", "", 0) + _nl_msg_cat_cntr + *_nl_domain_bindings + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + gt_cv_func_gnugettext2_libc=yes +else + gt_cv_func_gnugettext2_libc=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_cv_func_gnugettext2_libc" >&5 +$as_echo "$gt_cv_func_gnugettext2_libc" >&6; } + + if test "$gt_cv_func_gnugettext2_libc" != "yes"; then + + + + use_additional=yes + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + + eval additional_includedir=\"$includedir\" + eval additional_libdir=\"$libdir\" + + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + +# Check whether --with-libintl-prefix was given. +if test "${with_libintl_prefix+set}" = set; then : + withval=$with_libintl_prefix; + if test "X$withval" = "Xno"; then + use_additional=no + else + if test "X$withval" = "X"; then + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + + eval additional_includedir=\"$includedir\" + eval additional_libdir=\"$libdir\" + + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + else + additional_includedir="$withval/include" + additional_libdir="$withval/lib" + fi + fi + +fi + + LIBINTL= + LTLIBINTL= + INCINTL= + rpathdirs= + ltrpathdirs= + names_already_handled= + names_next_round='intl ' + while test -n "$names_next_round"; do + names_this_round="$names_next_round" + names_next_round= + for name in $names_this_round; do + already_handled= + for n in $names_already_handled; do + if test "$n" = "$name"; then + already_handled=yes + break + fi + done + if test -z "$already_handled"; then + names_already_handled="$names_already_handled $name" + uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'` + eval value=\"\$HAVE_LIB$uppername\" + if test -n "$value"; then + if test "$value" = yes; then + eval value=\"\$LIB$uppername\" + test -z "$value" || LIBINTL="${LIBINTL}${LIBINTL:+ }$value" + eval value=\"\$LTLIB$uppername\" + test -z "$value" || LTLIBINTL="${LTLIBINTL}${LTLIBINTL:+ }$value" + else + : + fi + else + found_dir= + found_la= + found_so= + found_a= + if test $use_additional = yes; then + if test "X$prefer_shared" = "Xyes" && test -n "$shlibext" && test -f "$additional_libdir/lib$name.$shlibext"; then + found_dir="$additional_libdir" + found_so="$additional_libdir/lib$name.$shlibext" + if test -f "$additional_libdir/lib$name.la"; then + found_la="$additional_libdir/lib$name.la" + fi + else + if test -f "$additional_libdir/lib$name.$libext"; then + found_dir="$additional_libdir" + found_a="$additional_libdir/lib$name.$libext" + if test -f "$additional_libdir/lib$name.la"; then + found_la="$additional_libdir/lib$name.la" + fi + fi + fi + fi + if test "X$found_dir" = "X"; then + for x in $LDFLAGS $LTLIBINTL; do + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + eval x=\"$x\" + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + case "$x" in + -L*) + dir=`echo "X$x" | sed -e 's/^X-L//'` + if test "X$prefer_shared" = "Xyes" && test -n "$shlibext" && test -f "$dir/lib$name.$shlibext"; then + found_dir="$dir" + found_so="$dir/lib$name.$shlibext" + if test -f "$dir/lib$name.la"; then + found_la="$dir/lib$name.la" + fi + else + if test -f "$dir/lib$name.$libext"; then + found_dir="$dir" + found_a="$dir/lib$name.$libext" + if test -f "$dir/lib$name.la"; then + found_la="$dir/lib$name.la" + fi + fi + fi + ;; + esac + if test "X$found_dir" != "X"; then + break + fi + done + fi + if test "X$found_dir" != "X"; then + LTLIBINTL="${LTLIBINTL}${LTLIBINTL:+ }-L$found_dir -l$name" + if test "X$found_so" != "X"; then + if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/lib"; then + LIBINTL="${LIBINTL}${LIBINTL:+ }$found_so" + else + haveit= + for x in $ltrpathdirs; do + if test "X$x" = "X$found_dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + ltrpathdirs="$ltrpathdirs $found_dir" + fi + if test "$hardcode_direct" = yes; then + LIBINTL="${LIBINTL}${LIBINTL:+ }$found_so" + else + if test -n "$hardcode_libdir_flag_spec" && test "$hardcode_minus_L" = no; then + LIBINTL="${LIBINTL}${LIBINTL:+ }$found_so" + haveit= + for x in $rpathdirs; do + if test "X$x" = "X$found_dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + rpathdirs="$rpathdirs $found_dir" + fi + else + haveit= + for x in $LDFLAGS $LIBINTL; do + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + eval x=\"$x\" + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + if test "X$x" = "X-L$found_dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + LIBINTL="${LIBINTL}${LIBINTL:+ }-L$found_dir" + fi + if test "$hardcode_minus_L" != no; then + LIBINTL="${LIBINTL}${LIBINTL:+ }$found_so" + else + LIBINTL="${LIBINTL}${LIBINTL:+ }-l$name" + fi + fi + fi + fi + else + if test "X$found_a" != "X"; then + LIBINTL="${LIBINTL}${LIBINTL:+ }$found_a" + else + LIBINTL="${LIBINTL}${LIBINTL:+ }-L$found_dir -l$name" + fi + fi + additional_includedir= + case "$found_dir" in + */lib | */lib/) + basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e 's,/lib/*$,,'` + additional_includedir="$basedir/include" + ;; + esac + if test "X$additional_includedir" != "X"; then + if test "X$additional_includedir" != "X/usr/include"; then + haveit= + if test "X$additional_includedir" = "X/usr/local/include"; then + if test -n "$GCC"; then + case $host_os in + linux*) haveit=yes;; + esac + fi + fi + if test -z "$haveit"; then + for x in $CPPFLAGS $INCINTL; do + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + eval x=\"$x\" + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + if test "X$x" = "X-I$additional_includedir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test -d "$additional_includedir"; then + INCINTL="${INCINTL}${INCINTL:+ }-I$additional_includedir" + fi + fi + fi + fi + fi + if test -n "$found_la"; then + save_libdir="$libdir" + case "$found_la" in + */* | *\\*) . "$found_la" ;; + *) . "./$found_la" ;; + esac + libdir="$save_libdir" + for dep in $dependency_libs; do + case "$dep" in + -L*) + additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'` + if test "X$additional_libdir" != "X/usr/lib"; then + haveit= + if test "X$additional_libdir" = "X/usr/local/lib"; then + if test -n "$GCC"; then + case $host_os in + linux*) haveit=yes;; + esac + fi + fi + if test -z "$haveit"; then + haveit= + for x in $LDFLAGS $LIBINTL; do + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + eval x=\"$x\" + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + if test "X$x" = "X-L$additional_libdir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test -d "$additional_libdir"; then + LIBINTL="${LIBINTL}${LIBINTL:+ }-L$additional_libdir" + fi + fi + haveit= + for x in $LDFLAGS $LTLIBINTL; do + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + eval x=\"$x\" + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + if test "X$x" = "X-L$additional_libdir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test -d "$additional_libdir"; then + LTLIBINTL="${LTLIBINTL}${LTLIBINTL:+ }-L$additional_libdir" + fi + fi + fi + fi + ;; + -R*) + dir=`echo "X$dep" | sed -e 's/^X-R//'` + if test "$enable_rpath" != no; then + haveit= + for x in $rpathdirs; do + if test "X$x" = "X$dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + rpathdirs="$rpathdirs $dir" + fi + haveit= + for x in $ltrpathdirs; do + if test "X$x" = "X$dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + ltrpathdirs="$ltrpathdirs $dir" + fi + fi + ;; + -l*) + names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'` + ;; + *.la) + names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'` + ;; + *) + LIBINTL="${LIBINTL}${LIBINTL:+ }$dep" + LTLIBINTL="${LTLIBINTL}${LTLIBINTL:+ }$dep" + ;; + esac + done + fi + else + LIBINTL="${LIBINTL}${LIBINTL:+ }-l$name" + LTLIBINTL="${LTLIBINTL}${LTLIBINTL:+ }-l$name" + fi + fi + fi + done + done + if test "X$rpathdirs" != "X"; then + if test -n "$hardcode_libdir_separator"; then + alldirs= + for found_dir in $rpathdirs; do + alldirs="${alldirs}${alldirs:+$hardcode_libdir_separator}$found_dir" + done + acl_save_libdir="$libdir" + libdir="$alldirs" + eval flag=\"$hardcode_libdir_flag_spec\" + libdir="$acl_save_libdir" + LIBINTL="${LIBINTL}${LIBINTL:+ }$flag" + else + for found_dir in $rpathdirs; do + acl_save_libdir="$libdir" + libdir="$found_dir" + eval flag=\"$hardcode_libdir_flag_spec\" + libdir="$acl_save_libdir" + LIBINTL="${LIBINTL}${LIBINTL:+ }$flag" + done + fi + fi + if test "X$ltrpathdirs" != "X"; then + for found_dir in $ltrpathdirs; do + LTLIBINTL="${LTLIBINTL}${LTLIBINTL:+ }-R$found_dir" + done + fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU gettext in libintl" >&5 +$as_echo_n "checking for GNU gettext in libintl... " >&6; } +if ${gt_cv_func_gnugettext2_libintl+:} false; then : + $as_echo_n "(cached) " >&6 +else + gt_save_CPPFLAGS="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS $INCINTL" + gt_save_LIBS="$LIBS" + LIBS="$LIBS $LIBINTL" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +extern int _nl_msg_cat_cntr; +extern +#ifdef __cplusplus +"C" +#endif +const char *_nl_expand_alias (); +int +main () +{ +bindtextdomain ("", ""); +return (int) gettext ("") + (int) ngettext ("", "", 0) + _nl_msg_cat_cntr + *_nl_expand_alias (0) + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + gt_cv_func_gnugettext2_libintl=yes +else + gt_cv_func_gnugettext2_libintl=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + if test "$gt_cv_func_gnugettext2_libintl" != yes && test -n "$LIBICONV"; then + LIBS="$LIBS $LIBICONV" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +extern int _nl_msg_cat_cntr; +extern +#ifdef __cplusplus +"C" +#endif +const char *_nl_expand_alias (); +int +main () +{ +bindtextdomain ("", ""); +return (int) gettext ("") + (int) ngettext ("", "", 0) + _nl_msg_cat_cntr + *_nl_expand_alias (0) + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + LIBINTL="$LIBINTL $LIBICONV" + LTLIBINTL="$LTLIBINTL $LTLIBICONV" + gt_cv_func_gnugettext2_libintl=yes + +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + fi + CPPFLAGS="$gt_save_CPPFLAGS" + LIBS="$gt_save_LIBS" +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_cv_func_gnugettext2_libintl" >&5 +$as_echo "$gt_cv_func_gnugettext2_libintl" >&6; } + fi + + if test "$gt_cv_func_gnugettext2_libc" = "yes" \ + || { test "$gt_cv_func_gnugettext2_libintl" = "yes" \ + && test "$PACKAGE" != gettext-runtime \ + && test "$PACKAGE" != gettext-tools; }; then + gt_use_preinstalled_gnugettext=yes + else + LIBINTL= + LTLIBINTL= + INCINTL= + fi + + + if test "$gt_use_preinstalled_gnugettext" != "yes"; then + nls_cv_use_gnu_gettext=yes + fi + fi + + if test "$nls_cv_use_gnu_gettext" = "yes"; then + BUILD_INCLUDED_LIBINTL=yes + USE_INCLUDED_LIBINTL=yes + LIBINTL="lib/intl/libintl.a $LIBICONV" + LTLIBINTL="lib/intl/libintl.a $LTLIBICONV" + LIBS=`echo " $LIBS " | sed -e 's/ -lintl / /' -e 's/^ //' -e 's/ $//'` + fi + + if test "$gt_use_preinstalled_gnugettext" = "yes" \ + || test "$nls_cv_use_gnu_gettext" = "yes"; then + CATOBJEXT=.gmo + fi + + + if test "$gt_use_preinstalled_gnugettext" = "yes" \ + || test "$nls_cv_use_gnu_gettext" = "yes"; then + +$as_echo "#define ENABLE_NLS 1" >>confdefs.h + + else + USE_NLS=no + fi + fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to use NLS" >&5 +$as_echo_n "checking whether to use NLS... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $USE_NLS" >&5 +$as_echo "$USE_NLS" >&6; } + if test "$USE_NLS" = "yes"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking where the gettext function comes from" >&5 +$as_echo_n "checking where the gettext function comes from... " >&6; } + if test "$gt_use_preinstalled_gnugettext" = "yes"; then + if test "$gt_cv_func_gnugettext2_libintl" = "yes"; then + gt_source="external libintl" + else + gt_source="libc" + fi + else + gt_source="included intl directory" + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_source" >&5 +$as_echo "$gt_source" >&6; } + fi + + if test "$USE_NLS" = "yes"; then + + if test "$gt_use_preinstalled_gnugettext" = "yes"; then + if test "$gt_cv_func_gnugettext2_libintl" = "yes"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to link with libintl" >&5 +$as_echo_n "checking how to link with libintl... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIBINTL" >&5 +$as_echo "$LIBINTL" >&6; } + + for element in $INCINTL; do + haveit= + for x in $CPPFLAGS; do + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + eval x=\"$x\" + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + if test "X$x" = "X$element"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }$element" + fi + done + + fi + + +$as_echo "#define HAVE_GETTEXT 1" >>confdefs.h + + +$as_echo "#define HAVE_DCGETTEXT 1" >>confdefs.h + + fi + + POSUB=po + fi + + + if test "$PACKAGE" = gettext-runtime || test "$PACKAGE" = gettext-tools; then + BUILD_INCLUDED_LIBINTL=yes + fi + + + + + + nls_cv_header_intl= + nls_cv_header_libgt= + + DATADIRNAME=share + + + INSTOBJEXT=.mo + + + GENCAT=gencat + + + if test "$USE_INCLUDED_LIBINTL" = yes; then + INTLOBJS="\$(GETTOBJS)" + fi + + + INTL_LIBTOOL_SUFFIX_PREFIX= + + + + INTLLIBS="$LIBINTL" + + + + + + + +ac_header_dirent=no +for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h; do + as_ac_Header=`$as_echo "ac_cv_header_dirent_$ac_hdr" | $as_tr_sh` +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_hdr that defines DIR" >&5 +$as_echo_n "checking for $ac_hdr that defines DIR... " >&6; } +if eval \${$as_ac_Header+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include <$ac_hdr> + +int +main () +{ +if ((DIR *) 0) +return 0; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + eval "$as_ac_Header=yes" +else + eval "$as_ac_Header=no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +eval ac_res=\$$as_ac_Header + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_hdr" | $as_tr_cpp` 1 +_ACEOF + +ac_header_dirent=$ac_hdr; break +fi + +done +# Two versions of opendir et al. are in -ldir and -lx on SCO Xenix. +if test $ac_header_dirent = dirent.h; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing opendir" >&5 +$as_echo_n "checking for library containing opendir... " >&6; } +if ${ac_cv_search_opendir+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_func_search_save_LIBS=$LIBS +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char opendir (); +int +main () +{ +return opendir (); + ; + return 0; +} +_ACEOF +for ac_lib in '' dir; do + if test -z "$ac_lib"; then + ac_res="none required" + else + ac_res=-l$ac_lib + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + fi + if ac_fn_c_try_link "$LINENO"; then : + ac_cv_search_opendir=$ac_res +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext + if ${ac_cv_search_opendir+:} false; then : + break +fi +done +if ${ac_cv_search_opendir+:} false; then : + +else + ac_cv_search_opendir=no +fi +rm conftest.$ac_ext +LIBS=$ac_func_search_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_opendir" >&5 +$as_echo "$ac_cv_search_opendir" >&6; } +ac_res=$ac_cv_search_opendir +if test "$ac_res" != no; then : + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" + +fi + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing opendir" >&5 +$as_echo_n "checking for library containing opendir... " >&6; } +if ${ac_cv_search_opendir+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_func_search_save_LIBS=$LIBS +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char opendir (); +int +main () +{ +return opendir (); + ; + return 0; +} +_ACEOF +for ac_lib in '' x; do + if test -z "$ac_lib"; then + ac_res="none required" + else + ac_res=-l$ac_lib + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + fi + if ac_fn_c_try_link "$LINENO"; then : + ac_cv_search_opendir=$ac_res +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext + if ${ac_cv_search_opendir+:} false; then : + break +fi +done +if ${ac_cv_search_opendir+:} false; then : + +else + ac_cv_search_opendir=no +fi +rm conftest.$ac_ext +LIBS=$ac_func_search_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_opendir" >&5 +$as_echo "$ac_cv_search_opendir" >&6; } +ac_res=$ac_cv_search_opendir +if test "$ac_res" != no; then : + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" + +fi + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether time.h and sys/time.h may both be included" >&5 +$as_echo_n "checking whether time.h and sys/time.h may both be included... " >&6; } +if ${ac_cv_header_time+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#include + +int +main () +{ +if ((struct tm *) 0) +return 0; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_header_time=yes +else + ac_cv_header_time=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_time" >&5 +$as_echo "$ac_cv_header_time" >&6; } +if test $ac_cv_header_time = yes; then + +$as_echo "#define TIME_WITH_SYS_TIME 1" >>confdefs.h + +fi + + + + for ac_header in inttypes.h +do : + ac_fn_c_check_header_mongrel "$LINENO" "inttypes.h" "ac_cv_header_inttypes_h" "$ac_includes_default" +if test "x$ac_cv_header_inttypes_h" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_INTTYPES_H 1 +_ACEOF + +fi + +done + + + +for ac_header in unistd.h stdlib.h stdarg.h varargs.h limits.h string.h \ + memory.h locale.h termcap.h termio.h termios.h dlfcn.h \ + stdbool.h stddef.h stdint.h netdb.h pwd.h grp.h strings.h \ + regex.h syslog.h ulimit.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + +for ac_header in sys/pte.h sys/stream.h sys/select.h sys/file.h sys/ioctl.h \ + sys/param.h sys/socket.h sys/stat.h \ + sys/time.h sys/times.h sys/types.h sys/wait.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + +for ac_header in netinet/in.h arpa/inet.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + +ac_fn_c_check_header_compile "$LINENO" "sys/ptem.h" "ac_cv_header_sys_ptem_h" " +#if HAVE_SYS_STREAM_H +# include +#endif + +" +if test "x$ac_cv_header_sys_ptem_h" = xyes; then : + +fi + + + +ac_fn_c_check_header_compile "$LINENO" "sys/resource.h" "ac_cv_header_sys_resource_h" " +#if HAVE_SYS_TIME_H +# include +#endif + +" +if test "x$ac_cv_header_sys_resource_h" = xyes; then : + $as_echo "#define HAVE_SYS_RESOURCE_H 1" >>confdefs.h + +fi + + + +# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works +# for constant arguments. Useless! +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for working alloca.h" >&5 +$as_echo_n "checking for working alloca.h... " >&6; } +if ${ac_cv_working_alloca_h+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ +char *p = (char *) alloca (2 * sizeof (int)); + if (p) return 0; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_working_alloca_h=yes +else + ac_cv_working_alloca_h=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_working_alloca_h" >&5 +$as_echo "$ac_cv_working_alloca_h" >&6; } +if test $ac_cv_working_alloca_h = yes; then + +$as_echo "#define HAVE_ALLOCA_H 1" >>confdefs.h + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for alloca" >&5 +$as_echo_n "checking for alloca... " >&6; } +if ${ac_cv_func_alloca_works+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __GNUC__ +# define alloca __builtin_alloca +#else +# ifdef _MSC_VER +# include +# define alloca _alloca +# else +# ifdef HAVE_ALLOCA_H +# include +# else +# ifdef _AIX + #pragma alloca +# else +# ifndef alloca /* predefined by HP cc +Olibcalls */ +void *alloca (size_t); +# endif +# endif +# endif +# endif +#endif + +int +main () +{ +char *p = (char *) alloca (1); + if (p) return 0; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_func_alloca_works=yes +else + ac_cv_func_alloca_works=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_alloca_works" >&5 +$as_echo "$ac_cv_func_alloca_works" >&6; } + +if test $ac_cv_func_alloca_works = yes; then + +$as_echo "#define HAVE_ALLOCA 1" >>confdefs.h + +else + # The SVR3 libPW and SVR4 libucb both contain incompatible functions +# that cause trouble. Some versions do not even contain alloca or +# contain a buggy version. If you still want to use their alloca, +# use ar to extract alloca.o from them instead of compiling alloca.c. + +ALLOCA=\${LIBOBJDIR}alloca.$ac_objext + +$as_echo "#define C_ALLOCA 1" >>confdefs.h + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether \`alloca.c' needs Cray hooks" >&5 +$as_echo_n "checking whether \`alloca.c' needs Cray hooks... " >&6; } +if ${ac_cv_os_cray+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#if defined CRAY && ! defined CRAY2 +webecray +#else +wenotbecray +#endif + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "webecray" >/dev/null 2>&1; then : + ac_cv_os_cray=yes +else + ac_cv_os_cray=no +fi +rm -f conftest* + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_os_cray" >&5 +$as_echo "$ac_cv_os_cray" >&6; } +if test $ac_cv_os_cray = yes; then + for ac_func in _getb67 GETB67 getb67; do + as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" +if eval test \"x\$"$as_ac_var"\" = x"yes"; then : + +cat >>confdefs.h <<_ACEOF +#define CRAY_STACKSEG_END $ac_func +_ACEOF + + break +fi + + done +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking stack direction for C alloca" >&5 +$as_echo_n "checking stack direction for C alloca... " >&6; } +if ${ac_cv_c_stack_direction+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + ac_cv_c_stack_direction=0 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$ac_includes_default +int +find_stack_direction (int *addr, int depth) +{ + int dir, dummy = 0; + if (! addr) + addr = &dummy; + *addr = addr < &dummy ? 1 : addr == &dummy ? 0 : -1; + dir = depth ? find_stack_direction (addr, depth - 1) : 0; + return dir + dummy; +} + +int +main (int argc, char **argv) +{ + return find_stack_direction (0, argc + !argv + 20) < 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + ac_cv_c_stack_direction=1 +else + ac_cv_c_stack_direction=-1 +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_stack_direction" >&5 +$as_echo "$ac_cv_c_stack_direction" >&6; } +cat >>confdefs.h <<_ACEOF +#define STACK_DIRECTION $ac_cv_c_stack_direction +_ACEOF + + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for uid_t in sys/types.h" >&5 +$as_echo_n "checking for uid_t in sys/types.h... " >&6; } +if ${ac_cv_type_uid_t+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "uid_t" >/dev/null 2>&1; then : + ac_cv_type_uid_t=yes +else + ac_cv_type_uid_t=no +fi +rm -f conftest* + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_uid_t" >&5 +$as_echo "$ac_cv_type_uid_t" >&6; } +if test $ac_cv_type_uid_t = no; then + +$as_echo "#define uid_t int" >>confdefs.h + + +$as_echo "#define gid_t int" >>confdefs.h + +fi + +for ac_header in unistd.h +do : + ac_fn_c_check_header_mongrel "$LINENO" "unistd.h" "ac_cv_header_unistd_h" "$ac_includes_default" +if test "x$ac_cv_header_unistd_h" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_UNISTD_H 1 +_ACEOF + +fi + +done + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for working chown" >&5 +$as_echo_n "checking for working chown... " >&6; } +if ${ac_cv_func_chown_works+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + ac_cv_func_chown_works=no +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$ac_includes_default +#include + +int +main () +{ + char *f = "conftest.chown"; + struct stat before, after; + + if (creat (f, 0600) < 0) + return 1; + if (stat (f, &before) < 0) + return 1; + if (chown (f, (uid_t) -1, (gid_t) -1) == -1) + return 1; + if (stat (f, &after) < 0) + return 1; + return ! (before.st_uid == after.st_uid && before.st_gid == after.st_gid); + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + ac_cv_func_chown_works=yes +else + ac_cv_func_chown_works=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +rm -f conftest.chown + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_chown_works" >&5 +$as_echo "$ac_cv_func_chown_works" >&6; } +if test $ac_cv_func_chown_works = yes; then + +$as_echo "#define HAVE_CHOWN 1" >>confdefs.h + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether getpgrp requires zero arguments" >&5 +$as_echo_n "checking whether getpgrp requires zero arguments... " >&6; } +if ${ac_cv_func_getpgrp_void+:} false; then : + $as_echo_n "(cached) " >&6 +else + # Use it with a single arg. +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +getpgrp (0); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_func_getpgrp_void=no +else + ac_cv_func_getpgrp_void=yes +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_getpgrp_void" >&5 +$as_echo "$ac_cv_func_getpgrp_void" >&6; } +if test $ac_cv_func_getpgrp_void = yes; then + +$as_echo "#define GETPGRP_VOID 1" >>confdefs.h + +fi + +if ${ac_cv_func_setvbuf_reversed+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_cv_func_setvbuf_reversed=no +fi + + +for ac_func in vprintf +do : + ac_fn_c_check_func "$LINENO" "vprintf" "ac_cv_func_vprintf" +if test "x$ac_cv_func_vprintf" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_VPRINTF 1 +_ACEOF + +ac_fn_c_check_func "$LINENO" "_doprnt" "ac_cv_func__doprnt" +if test "x$ac_cv_func__doprnt" = xyes; then : + +$as_echo "#define HAVE_DOPRNT 1" >>confdefs.h + +fi + +fi +done + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for working strcoll" >&5 +$as_echo_n "checking for working strcoll... " >&6; } +if ${ac_cv_func_strcoll_works+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + ac_cv_func_strcoll_works=no +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +return (strcoll ("abc", "def") >= 0 || + strcoll ("ABC", "DEF") >= 0 || + strcoll ("123", "456") >= 0) + ; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + ac_cv_func_strcoll_works=yes +else + ac_cv_func_strcoll_works=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_strcoll_works" >&5 +$as_echo "$ac_cv_func_strcoll_works" >&6; } +if test $ac_cv_func_strcoll_works = yes; then + +$as_echo "#define HAVE_STRCOLL 1" >>confdefs.h + +fi + + + +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 + +if test "$ac_cv_func_vprintf" = no; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for declaration of vprintf in stdio.h" >&5 +$as_echo_n "checking for declaration of vprintf in stdio.h... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "[int[ ]*vprintf[^a-zA-Z0-9]]" >/dev/null 2>&1; then : + ac_cv_func_vprintf=yes +fi +rm -f conftest* + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_vprintf" >&5 +$as_echo "$ac_cv_func_vprintf" >&6; } + if test $ac_cv_func_vprintf = yes; then + $as_echo "#define HAVE_VPRINTF 1" >>confdefs.h + + fi +fi + +if test "$ac_cv_func_vprintf" = no && test "$ac_cv_func__doprnt" = "yes"; then + case " $LIBOBJS " in + *" vprint.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS vprint.$ac_objext" + ;; +esac + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking return type of signal handlers" >&5 +$as_echo_n "checking return type of signal handlers... " >&6; } +if ${ac_cv_type_signal+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include + +int +main () +{ +return *(signal (0, 0)) (0) == 1; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_type_signal=int +else + ac_cv_type_signal=void +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_signal" >&5 +$as_echo "$ac_cv_type_signal" >&6; } + +cat >>confdefs.h <<_ACEOF +#define RETSIGTYPE $ac_cv_type_signal +_ACEOF + + + +ac_fn_c_check_func "$LINENO" "__setostype" "ac_cv_func___setostype" +if test "x$ac_cv_func___setostype" = xyes; then : + $as_echo "#define HAVE_SETOSTYPE 1" >>confdefs.h + +fi + +ac_fn_c_check_func "$LINENO" "wait3" "ac_cv_func_wait3" +if test "x$ac_cv_func_wait3" = xyes; then : + $as_echo "#define HAVE_WAIT3 1" >>confdefs.h + +fi + + +ac_fn_c_check_func "$LINENO" "mkfifo" "ac_cv_func_mkfifo" +if test "x$ac_cv_func_mkfifo" = xyes; then : + $as_echo "#define HAVE_MKFIFO 1" >>confdefs.h + +else + $as_echo "#define MKFIFO_MISSING 1" >>confdefs.h + +fi + + +for ac_func in dup2 eaccess fcntl getdtablesize getgroups gethostname \ + getpagesize getpeername getrlimit getrusage gettimeofday \ + kill killpg lstat pselect readlink sbrk select setdtablesize \ + setitimer tcgetpgrp uname ulimit waitpid +do : + as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" +if eval test \"x\$"$as_ac_var"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + +ac_fn_c_check_func "$LINENO" "rename" "ac_cv_func_rename" +if test "x$ac_cv_func_rename" = xyes; then : + $as_echo "#define HAVE_RENAME 1" >>confdefs.h + +else + case " $LIBOBJS " in + *" rename.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS rename.$ac_objext" + ;; +esac + +fi + + + +for ac_func in bcopy bzero confstr faccessat fnmatch \ + getaddrinfo gethostbyname getservbyname getservent inet_aton \ + imaxdiv memmove pathconf putenv raise random regcomp regexec \ + setenv setlinebuf setlocale setvbuf siginterrupt strchr \ + sysconf syslog tcgetattr times ttyname tzset unsetenv +do : + as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" +if eval test \"x\$"$as_ac_var"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + + +for ac_func in vasprintf asprintf +do : + as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" +if eval test \"x\$"$as_ac_var"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + +for ac_func in isascii isblank isgraph isprint isspace isxdigit +do : + as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" +if eval test \"x\$"$as_ac_var"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + +for ac_func in getpwent getpwnam getpwuid +do : + as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" +if eval test \"x\$"$as_ac_var"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + +for ac_func in mkstemp +do : + ac_fn_c_check_func "$LINENO" "mkstemp" "ac_cv_func_mkstemp" +if test "x$ac_cv_func_mkstemp" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_MKSTEMP 1 +_ACEOF + +fi +done + +ac_fn_c_check_func "$LINENO" "getcwd" "ac_cv_func_getcwd" +if test "x$ac_cv_func_getcwd" = xyes; then : + $as_echo "#define HAVE_GETCWD 1" >>confdefs.h + +else + case " $LIBOBJS " in + *" getcwd.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS getcwd.$ac_objext" + ;; +esac + +fi + +ac_fn_c_check_func "$LINENO" "memset" "ac_cv_func_memset" +if test "x$ac_cv_func_memset" = xyes; then : + $as_echo "#define HAVE_MEMSET 1" >>confdefs.h + +else + case " $LIBOBJS " in + *" memset.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS memset.$ac_objext" + ;; +esac + +fi + + +ac_fn_c_check_func "$LINENO" "strcasecmp" "ac_cv_func_strcasecmp" +if test "x$ac_cv_func_strcasecmp" = xyes; then : + $as_echo "#define HAVE_STRCASECMP 1" >>confdefs.h + +else + case " $LIBOBJS " in + *" strcasecmp.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS strcasecmp.$ac_objext" + ;; +esac + +fi + +ac_fn_c_check_func "$LINENO" "strcasestr" "ac_cv_func_strcasestr" +if test "x$ac_cv_func_strcasestr" = xyes; then : + $as_echo "#define HAVE_STRCASESTR 1" >>confdefs.h + +else + case " $LIBOBJS " in + *" strcasestr.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS strcasestr.$ac_objext" + ;; +esac + +fi + +ac_fn_c_check_func "$LINENO" "strerror" "ac_cv_func_strerror" +if test "x$ac_cv_func_strerror" = xyes; then : + $as_echo "#define HAVE_STRERROR 1" >>confdefs.h + +else + case " $LIBOBJS " in + *" strerror.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS strerror.$ac_objext" + ;; +esac + +fi + +ac_fn_c_check_func "$LINENO" "strftime" "ac_cv_func_strftime" +if test "x$ac_cv_func_strftime" = xyes; then : + $as_echo "#define HAVE_STRFTIME 1" >>confdefs.h + +else + case " $LIBOBJS " in + *" strftime.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS strftime.$ac_objext" + ;; +esac + +fi + +ac_fn_c_check_func "$LINENO" "strnlen" "ac_cv_func_strnlen" +if test "x$ac_cv_func_strnlen" = xyes; then : + $as_echo "#define HAVE_STRNLEN 1" >>confdefs.h + +else + case " $LIBOBJS " in + *" strnlen.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS strnlen.$ac_objext" + ;; +esac + +fi + +ac_fn_c_check_func "$LINENO" "strpbrk" "ac_cv_func_strpbrk" +if test "x$ac_cv_func_strpbrk" = xyes; then : + $as_echo "#define HAVE_STRPBRK 1" >>confdefs.h + +else + case " $LIBOBJS " in + *" strpbrk.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS strpbrk.$ac_objext" + ;; +esac + +fi + +ac_fn_c_check_func "$LINENO" "strstr" "ac_cv_func_strstr" +if test "x$ac_cv_func_strstr" = xyes; then : + $as_echo "#define HAVE_STRSTR 1" >>confdefs.h + +else + case " $LIBOBJS " in + *" strstr.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS strstr.$ac_objext" + ;; +esac + +fi + + +ac_fn_c_check_func "$LINENO" "strtod" "ac_cv_func_strtod" +if test "x$ac_cv_func_strtod" = xyes; then : + $as_echo "#define HAVE_STRTOD 1" >>confdefs.h + +else + case " $LIBOBJS " in + *" strtod.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS strtod.$ac_objext" + ;; +esac + +fi + +ac_fn_c_check_func "$LINENO" "strtol" "ac_cv_func_strtol" +if test "x$ac_cv_func_strtol" = xyes; then : + $as_echo "#define HAVE_STRTOL 1" >>confdefs.h + +else + case " $LIBOBJS " in + *" strtol.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS strtol.$ac_objext" + ;; +esac + +fi + +ac_fn_c_check_func "$LINENO" "strtoul" "ac_cv_func_strtoul" +if test "x$ac_cv_func_strtoul" = xyes; then : + $as_echo "#define HAVE_STRTOUL 1" >>confdefs.h + +else + case " $LIBOBJS " in + *" strtoul.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS strtoul.$ac_objext" + ;; +esac + +fi + +ac_fn_c_check_func "$LINENO" "strtoll" "ac_cv_func_strtoll" +if test "x$ac_cv_func_strtoll" = xyes; then : + $as_echo "#define HAVE_STRTOLL 1" >>confdefs.h + +else + case " $LIBOBJS " in + *" strtoll.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS strtoll.$ac_objext" + ;; +esac + +fi + +ac_fn_c_check_func "$LINENO" "strtoull" "ac_cv_func_strtoull" +if test "x$ac_cv_func_strtoull" = xyes; then : + $as_echo "#define HAVE_STRTOULL 1" >>confdefs.h + +else + case " $LIBOBJS " in + *" strtoull.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS strtoull.$ac_objext" + ;; +esac + +fi + +ac_fn_c_check_func "$LINENO" "strtoimax" "ac_cv_func_strtoimax" +if test "x$ac_cv_func_strtoimax" = xyes; then : + $as_echo "#define HAVE_STRTOIMAX 1" >>confdefs.h + +else + case " $LIBOBJS " in + *" strtoimax.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS strtoimax.$ac_objext" + ;; +esac + +fi + +ac_fn_c_check_func "$LINENO" "strtoumax" "ac_cv_func_strtoumax" +if test "x$ac_cv_func_strtoumax" = xyes; then : + $as_echo "#define HAVE_STRTOUMAX 1" >>confdefs.h + +else + case " $LIBOBJS " in + *" strtoumax.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS strtoumax.$ac_objext" + ;; +esac + +fi + + +ac_fn_c_check_func "$LINENO" "dprintf" "ac_cv_func_dprintf" +if test "x$ac_cv_func_dprintf" = xyes; then : + $as_echo "#define HAVE_DPRINTF 1" >>confdefs.h + +else + case " $LIBOBJS " in + *" dprintf.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS dprintf.$ac_objext" + ;; +esac + +fi + + +ac_fn_c_check_func "$LINENO" "strchrnul" "ac_cv_func_strchrnul" +if test "x$ac_cv_func_strchrnul" = xyes; then : + $as_echo "#define HAVE_STRCHRNUL 1" >>confdefs.h + +else + case " $LIBOBJS " in + *" strchrnul.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS strchrnul.$ac_objext" + ;; +esac + +fi + + +ac_fn_c_check_func "$LINENO" "strdup" "ac_cv_func_strdup" +if test "x$ac_cv_func_strdup" = xyes; then : + $as_echo "#define HAVE_STRDUP 1" >>confdefs.h + +else + case " $LIBOBJS " in + *" strdup.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS strdup.$ac_objext" + ;; +esac + +fi + + + +for ac_header in libaudit.h +do : + ac_fn_c_check_header_mongrel "$LINENO" "libaudit.h" "ac_cv_header_libaudit_h" "$ac_includes_default" +if test "x$ac_cv_header_libaudit_h" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBAUDIT_H 1 +_ACEOF + +fi + +done + +ac_fn_c_check_decl "$LINENO" "AUDIT_USER_TTY" "ac_cv_have_decl_AUDIT_USER_TTY" "#include +" +if test "x$ac_cv_have_decl_AUDIT_USER_TTY" = xyes; then : + ac_have_decl=1 +else + ac_have_decl=0 +fi + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_AUDIT_USER_TTY $ac_have_decl +_ACEOF + + +ac_fn_c_check_decl "$LINENO" "confstr" "ac_cv_have_decl_confstr" "$ac_includes_default" +if test "x$ac_cv_have_decl_confstr" = xyes; then : + ac_have_decl=1 +else + ac_have_decl=0 +fi + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_CONFSTR $ac_have_decl +_ACEOF + +ac_fn_c_check_decl "$LINENO" "printf" "ac_cv_have_decl_printf" "$ac_includes_default" +if test "x$ac_cv_have_decl_printf" = xyes; then : + ac_have_decl=1 +else + ac_have_decl=0 +fi + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_PRINTF $ac_have_decl +_ACEOF + +ac_fn_c_check_decl "$LINENO" "sbrk" "ac_cv_have_decl_sbrk" "$ac_includes_default" +if test "x$ac_cv_have_decl_sbrk" = xyes; then : + ac_have_decl=1 +else + ac_have_decl=0 +fi + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_SBRK $ac_have_decl +_ACEOF + +ac_fn_c_check_decl "$LINENO" "setregid" "ac_cv_have_decl_setregid" "$ac_includes_default" +if test "x$ac_cv_have_decl_setregid" = xyes; then : + ac_have_decl=1 +else + ac_have_decl=0 +fi + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_SETREGID $ac_have_decl +_ACEOF + +ac_fn_c_check_decl "$LINENO" "strcpy" "ac_cv_have_decl_strcpy" "$ac_includes_default" +if test "x$ac_cv_have_decl_strcpy" = xyes; then : + ac_have_decl=1 +else + ac_have_decl=0 +fi + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_STRCPY $ac_have_decl +_ACEOF + +ac_fn_c_check_decl "$LINENO" "strsignal" "ac_cv_have_decl_strsignal" "$ac_includes_default" +if test "x$ac_cv_have_decl_strsignal" = xyes; then : + ac_have_decl=1 +else + ac_have_decl=0 +fi + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_STRSIGNAL $ac_have_decl +_ACEOF + + +ac_fn_c_check_decl "$LINENO" "strtold" "ac_cv_have_decl_strtold" "$ac_includes_default" +if test "x$ac_cv_have_decl_strtold" = xyes; then : + ac_have_decl=1 +else + ac_have_decl=0 +fi + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_STRTOLD $ac_have_decl +_ACEOF +if test $ac_have_decl = 1; then : + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for broken strtold" >&5 +$as_echo_n "checking for broken strtold... " >&6; } + if ${bash_cv_strtold_broken+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ +int main() { long double r; char *foo, bar; r = strtold(foo, &bar);} + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + bash_cv_strtold_broken=no +else + bash_cv_strtold_broken=yes +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $bash_cv_strtold_broken" >&5 +$as_echo "$bash_cv_strtold_broken" >&6; } + if test "$bash_cv_strtold_broken" = "yes" ; then + $as_echo "#define STRTOLD_BROKEN 1" >>confdefs.h + + fi + +fi + + + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for declaration of strtoimax" >&5 +$as_echo_n "checking for declaration of strtoimax... " >&6; } +if ${bash_cv_decl_strtoimax+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#if STDC_HEADERS +# include +#endif +#if HAVE_INTTYPES_H +# include +#endif + +int +main () +{ +return !strtoimax; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + bash_cv_decl_strtoimax=yes +else + bash_cv_decl_strtoimax=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bash_cv_decl_strtoimax" >&5 +$as_echo "$bash_cv_decl_strtoimax" >&6; } +bash_tr_func=HAVE_DECL_`echo strtoimax | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` +if test $bash_cv_decl_strtoimax = yes; then + cat >>confdefs.h <<_ACEOF +#define $bash_tr_func 1 +_ACEOF + +else + cat >>confdefs.h <<_ACEOF +#define $bash_tr_func 0 +_ACEOF + +fi + + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for declaration of strtol" >&5 +$as_echo_n "checking for declaration of strtol... " >&6; } +if ${bash_cv_decl_strtol+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#if STDC_HEADERS +# include +#endif +#if HAVE_INTTYPES_H +# include +#endif + +int +main () +{ +return !strtol; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + bash_cv_decl_strtol=yes +else + bash_cv_decl_strtol=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bash_cv_decl_strtol" >&5 +$as_echo "$bash_cv_decl_strtol" >&6; } +bash_tr_func=HAVE_DECL_`echo strtol | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` +if test $bash_cv_decl_strtol = yes; then + cat >>confdefs.h <<_ACEOF +#define $bash_tr_func 1 +_ACEOF + +else + cat >>confdefs.h <<_ACEOF +#define $bash_tr_func 0 +_ACEOF + +fi + + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for declaration of strtoll" >&5 +$as_echo_n "checking for declaration of strtoll... " >&6; } +if ${bash_cv_decl_strtoll+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#if STDC_HEADERS +# include +#endif +#if HAVE_INTTYPES_H +# include +#endif + +int +main () +{ +return !strtoll; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + bash_cv_decl_strtoll=yes +else + bash_cv_decl_strtoll=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bash_cv_decl_strtoll" >&5 +$as_echo "$bash_cv_decl_strtoll" >&6; } +bash_tr_func=HAVE_DECL_`echo strtoll | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` +if test $bash_cv_decl_strtoll = yes; then + cat >>confdefs.h <<_ACEOF +#define $bash_tr_func 1 +_ACEOF + +else + cat >>confdefs.h <<_ACEOF +#define $bash_tr_func 0 +_ACEOF + +fi + + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for declaration of strtoul" >&5 +$as_echo_n "checking for declaration of strtoul... " >&6; } +if ${bash_cv_decl_strtoul+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#if STDC_HEADERS +# include +#endif +#if HAVE_INTTYPES_H +# include +#endif + +int +main () +{ +return !strtoul; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + bash_cv_decl_strtoul=yes +else + bash_cv_decl_strtoul=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bash_cv_decl_strtoul" >&5 +$as_echo "$bash_cv_decl_strtoul" >&6; } +bash_tr_func=HAVE_DECL_`echo strtoul | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` +if test $bash_cv_decl_strtoul = yes; then + cat >>confdefs.h <<_ACEOF +#define $bash_tr_func 1 +_ACEOF + +else + cat >>confdefs.h <<_ACEOF +#define $bash_tr_func 0 +_ACEOF + +fi + + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for declaration of strtoull" >&5 +$as_echo_n "checking for declaration of strtoull... " >&6; } +if ${bash_cv_decl_strtoull+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#if STDC_HEADERS +# include +#endif +#if HAVE_INTTYPES_H +# include +#endif + +int +main () +{ +return !strtoull; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + bash_cv_decl_strtoull=yes +else + bash_cv_decl_strtoull=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bash_cv_decl_strtoull" >&5 +$as_echo "$bash_cv_decl_strtoull" >&6; } +bash_tr_func=HAVE_DECL_`echo strtoull | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` +if test $bash_cv_decl_strtoull = yes; then + cat >>confdefs.h <<_ACEOF +#define $bash_tr_func 1 +_ACEOF + +else + cat >>confdefs.h <<_ACEOF +#define $bash_tr_func 0 +_ACEOF + +fi + + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for declaration of strtoumax" >&5 +$as_echo_n "checking for declaration of strtoumax... " >&6; } +if ${bash_cv_decl_strtoumax+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#if STDC_HEADERS +# include +#endif +#if HAVE_INTTYPES_H +# include +#endif + +int +main () +{ +return !strtoumax; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + bash_cv_decl_strtoumax=yes +else + bash_cv_decl_strtoumax=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bash_cv_decl_strtoumax" >&5 +$as_echo "$bash_cv_decl_strtoumax" >&6; } +bash_tr_func=HAVE_DECL_`echo strtoumax | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` +if test $bash_cv_decl_strtoumax = yes; then + cat >>confdefs.h <<_ACEOF +#define $bash_tr_func 1 +_ACEOF + +else + cat >>confdefs.h <<_ACEOF +#define $bash_tr_func 0 +_ACEOF + +fi + + + + + + + + for ac_func in $ac_func_list +do : + as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" +if eval test \"x\$"$as_ac_var"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + + + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for working mktime" >&5 +$as_echo_n "checking for working mktime... " >&6; } +if ${ac_cv_func_working_mktime+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + ac_cv_func_working_mktime=no +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +/* Test program from Paul Eggert and Tony Leneis. */ +#ifdef TIME_WITH_SYS_TIME +# include +# include +#else +# ifdef HAVE_SYS_TIME_H +# include +# else +# include +# endif +#endif + +#include +#include + +#ifdef HAVE_UNISTD_H +# include +#endif + +#ifndef HAVE_ALARM +# define alarm(X) /* empty */ +#endif + +/* Work around redefinition to rpl_putenv by other config tests. */ +#undef putenv + +static time_t time_t_max; +static time_t time_t_min; + +/* Values we'll use to set the TZ environment variable. */ +static const char *tz_strings[] = { + (const char *) 0, "TZ=GMT0", "TZ=JST-9", + "TZ=EST+3EDT+2,M10.1.0/00:00:00,M2.3.0/00:00:00" +}; +#define N_STRINGS (sizeof (tz_strings) / sizeof (tz_strings[0])) + +/* Return 0 if mktime fails to convert a date in the spring-forward gap. + Based on a problem report from Andreas Jaeger. */ +static int +spring_forward_gap () +{ + /* glibc (up to about 1998-10-07) failed this test. */ + struct tm tm; + + /* Use the portable POSIX.1 specification "TZ=PST8PDT,M4.1.0,M10.5.0" + instead of "TZ=America/Vancouver" in order to detect the bug even + on systems that don't support the Olson extension, or don't have the + full zoneinfo tables installed. */ + putenv ((char*) "TZ=PST8PDT,M4.1.0,M10.5.0"); + + tm.tm_year = 98; + tm.tm_mon = 3; + tm.tm_mday = 5; + tm.tm_hour = 2; + tm.tm_min = 0; + tm.tm_sec = 0; + tm.tm_isdst = -1; + return mktime (&tm) != (time_t) -1; +} + +static int +mktime_test1 (time_t now) +{ + struct tm *lt; + return ! (lt = localtime (&now)) || mktime (lt) == now; +} + +static int +mktime_test (time_t now) +{ + return (mktime_test1 (now) + && mktime_test1 ((time_t) (time_t_max - now)) + && mktime_test1 ((time_t) (time_t_min + now))); +} + +static int +irix_6_4_bug () +{ + /* Based on code from Ariel Faigon. */ + struct tm tm; + tm.tm_year = 96; + tm.tm_mon = 3; + tm.tm_mday = 0; + tm.tm_hour = 0; + tm.tm_min = 0; + tm.tm_sec = 0; + tm.tm_isdst = -1; + mktime (&tm); + return tm.tm_mon == 2 && tm.tm_mday == 31; +} + +static int +bigtime_test (int j) +{ + struct tm tm; + time_t now; + tm.tm_year = tm.tm_mon = tm.tm_mday = tm.tm_hour = tm.tm_min = tm.tm_sec = j; + now = mktime (&tm); + if (now != (time_t) -1) + { + struct tm *lt = localtime (&now); + if (! (lt + && lt->tm_year == tm.tm_year + && lt->tm_mon == tm.tm_mon + && lt->tm_mday == tm.tm_mday + && lt->tm_hour == tm.tm_hour + && lt->tm_min == tm.tm_min + && lt->tm_sec == tm.tm_sec + && lt->tm_yday == tm.tm_yday + && lt->tm_wday == tm.tm_wday + && ((lt->tm_isdst < 0 ? -1 : 0 < lt->tm_isdst) + == (tm.tm_isdst < 0 ? -1 : 0 < tm.tm_isdst)))) + return 0; + } + return 1; +} + +static int +year_2050_test () +{ + /* The correct answer for 2050-02-01 00:00:00 in Pacific time, + ignoring leap seconds. */ + unsigned long int answer = 2527315200UL; + + struct tm tm; + time_t t; + tm.tm_year = 2050 - 1900; + tm.tm_mon = 2 - 1; + tm.tm_mday = 1; + tm.tm_hour = tm.tm_min = tm.tm_sec = 0; + tm.tm_isdst = -1; + + /* Use the portable POSIX.1 specification "TZ=PST8PDT,M4.1.0,M10.5.0" + instead of "TZ=America/Vancouver" in order to detect the bug even + on systems that don't support the Olson extension, or don't have the + full zoneinfo tables installed. */ + putenv ((char*) "TZ=PST8PDT,M4.1.0,M10.5.0"); + + t = mktime (&tm); + + /* Check that the result is either a failure, or close enough + to the correct answer that we can assume the discrepancy is + due to leap seconds. */ + return (t == (time_t) -1 + || (0 < t && answer - 120 <= t && t <= answer + 120)); +} + +int +main () +{ + time_t t, delta; + int i, j; + + /* This test makes some buggy mktime implementations loop. + Give up after 60 seconds; a mktime slower than that + isn't worth using anyway. */ + alarm (60); + + for (;;) + { + t = (time_t_max << 1) + 1; + if (t <= time_t_max) + break; + time_t_max = t; + } + time_t_min = - ((time_t) ~ (time_t) 0 == (time_t) -1) - time_t_max; + + delta = time_t_max / 997; /* a suitable prime number */ + for (i = 0; i < N_STRINGS; i++) + { + if (tz_strings[i]) + putenv ((char*) tz_strings[i]); + + for (t = 0; t <= time_t_max - delta; t += delta) + if (! mktime_test (t)) + return 1; + if (! (mktime_test ((time_t) 1) + && mktime_test ((time_t) (60 * 60)) + && mktime_test ((time_t) (60 * 60 * 24)))) + return 1; + + for (j = 1; ; j <<= 1) + if (! bigtime_test (j)) + return 1; + else if (INT_MAX / 2 < j) + break; + if (! bigtime_test (INT_MAX)) + return 1; + } + return ! (irix_6_4_bug () && spring_forward_gap () && year_2050_test ()); +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + ac_cv_func_working_mktime=yes +else + ac_cv_func_working_mktime=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_working_mktime" >&5 +$as_echo "$ac_cv_func_working_mktime" >&6; } +if test $ac_cv_func_working_mktime = no; then + case " $LIBOBJS " in + *" mktime.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS mktime.$ac_objext" + ;; +esac + +fi + + + +for ac_header in argz.h errno.h fcntl.h malloc.h stdio_ext.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + + +for ac_func in getpagesize +do : + ac_fn_c_check_func "$LINENO" "getpagesize" "ac_cv_func_getpagesize" +if test "x$ac_cv_func_getpagesize" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_GETPAGESIZE 1 +_ACEOF + +fi +done + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for working mmap" >&5 +$as_echo_n "checking for working mmap... " >&6; } +if ${ac_cv_func_mmap_fixed_mapped+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + ac_cv_func_mmap_fixed_mapped=no +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$ac_includes_default +/* malloc might have been renamed as rpl_malloc. */ +#undef malloc + +/* Thanks to Mike Haertel and Jim Avera for this test. + Here is a matrix of mmap possibilities: + mmap private not fixed + mmap private fixed at somewhere currently unmapped + mmap private fixed at somewhere already mapped + mmap shared not fixed + mmap shared fixed at somewhere currently unmapped + mmap shared fixed at somewhere already mapped + For private mappings, we should verify that changes cannot be read() + back from the file, nor mmap's back from the file at a different + address. (There have been systems where private was not correctly + implemented like the infamous i386 svr4.0, and systems where the + VM page cache was not coherent with the file system buffer cache + like early versions of FreeBSD and possibly contemporary NetBSD.) + For shared mappings, we should conversely verify that changes get + propagated back to all the places they're supposed to be. + + Grep wants private fixed already mapped. + The main things grep needs to know about mmap are: + * does it exist and is it safe to write into the mmap'd area + * how to use it (BSD variants) */ + +#include +#include + +#if !defined STDC_HEADERS && !defined HAVE_STDLIB_H +char *malloc (); +#endif + +/* This mess was copied from the GNU getpagesize.h. */ +#ifndef HAVE_GETPAGESIZE +# ifdef _SC_PAGESIZE +# define getpagesize() sysconf(_SC_PAGESIZE) +# else /* no _SC_PAGESIZE */ +# ifdef HAVE_SYS_PARAM_H +# include +# ifdef EXEC_PAGESIZE +# define getpagesize() EXEC_PAGESIZE +# else /* no EXEC_PAGESIZE */ +# ifdef NBPG +# define getpagesize() NBPG * CLSIZE +# ifndef CLSIZE +# define CLSIZE 1 +# endif /* no CLSIZE */ +# else /* no NBPG */ +# ifdef NBPC +# define getpagesize() NBPC +# else /* no NBPC */ +# ifdef PAGESIZE +# define getpagesize() PAGESIZE +# endif /* PAGESIZE */ +# endif /* no NBPC */ +# endif /* no NBPG */ +# endif /* no EXEC_PAGESIZE */ +# else /* no HAVE_SYS_PARAM_H */ +# define getpagesize() 8192 /* punt totally */ +# endif /* no HAVE_SYS_PARAM_H */ +# endif /* no _SC_PAGESIZE */ + +#endif /* no HAVE_GETPAGESIZE */ + +int +main () +{ + char *data, *data2, *data3; + const char *cdata2; + int i, pagesize; + int fd, fd2; + + pagesize = getpagesize (); + + /* First, make a file with some known garbage in it. */ + data = (char *) malloc (pagesize); + if (!data) + return 1; + for (i = 0; i < pagesize; ++i) + *(data + i) = rand (); + umask (0); + fd = creat ("conftest.mmap", 0600); + if (fd < 0) + return 2; + if (write (fd, data, pagesize) != pagesize) + return 3; + close (fd); + + /* Next, check that the tail of a page is zero-filled. File must have + non-zero length, otherwise we risk SIGBUS for entire page. */ + fd2 = open ("conftest.txt", O_RDWR | O_CREAT | O_TRUNC, 0600); + if (fd2 < 0) + return 4; + cdata2 = ""; + if (write (fd2, cdata2, 1) != 1) + return 5; + data2 = (char *) mmap (0, pagesize, PROT_READ | PROT_WRITE, MAP_SHARED, fd2, 0L); + if (data2 == MAP_FAILED) + return 6; + for (i = 0; i < pagesize; ++i) + if (*(data2 + i)) + return 7; + close (fd2); + if (munmap (data2, pagesize)) + return 8; + + /* Next, try to mmap the file at a fixed address which already has + something else allocated at it. If we can, also make sure that + we see the same garbage. */ + fd = open ("conftest.mmap", O_RDWR); + if (fd < 0) + return 9; + if (data2 != mmap (data2, pagesize, PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_FIXED, fd, 0L)) + return 10; + for (i = 0; i < pagesize; ++i) + if (*(data + i) != *(data2 + i)) + return 11; + + /* Finally, make sure that changes to the mapped area do not + percolate back to the file as seen by read(). (This is a bug on + some variants of i386 svr4.0.) */ + for (i = 0; i < pagesize; ++i) + *(data2 + i) = *(data2 + i) + 1; + data3 = (char *) malloc (pagesize); + if (!data3) + return 12; + if (read (fd, data3, pagesize) != pagesize) + return 13; + for (i = 0; i < pagesize; ++i) + if (*(data + i) != *(data3 + i)) + return 14; + close (fd); + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + ac_cv_func_mmap_fixed_mapped=yes +else + ac_cv_func_mmap_fixed_mapped=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_mmap_fixed_mapped" >&5 +$as_echo "$ac_cv_func_mmap_fixed_mapped" >&6; } +if test $ac_cv_func_mmap_fixed_mapped = yes; then + +$as_echo "#define HAVE_MMAP 1" >>confdefs.h + +fi +rm -f conftest.mmap conftest.txt + +for ac_func in __argz_count __argz_next __argz_stringify dcgettext mempcpy \ + munmap stpcpy strcspn +do : + as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" +if eval test \"x\$"$as_ac_var"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + + +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 + + + + + + +for ac_header in wctype.h +do : + ac_fn_c_check_header_mongrel "$LINENO" "wctype.h" "ac_cv_header_wctype_h" "$ac_includes_default" +if test "x$ac_cv_header_wctype_h" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_WCTYPE_H 1 +_ACEOF + +fi + +done + +for ac_header in wchar.h +do : + ac_fn_c_check_header_mongrel "$LINENO" "wchar.h" "ac_cv_header_wchar_h" "$ac_includes_default" +if test "x$ac_cv_header_wchar_h" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_WCHAR_H 1 +_ACEOF + +fi + +done + +for ac_header in langinfo.h +do : + ac_fn_c_check_header_mongrel "$LINENO" "langinfo.h" "ac_cv_header_langinfo_h" "$ac_includes_default" +if test "x$ac_cv_header_langinfo_h" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LANGINFO_H 1 +_ACEOF + +fi + +done + + +for ac_header in mbstr.h +do : + ac_fn_c_check_header_mongrel "$LINENO" "mbstr.h" "ac_cv_header_mbstr_h" "$ac_includes_default" +if test "x$ac_cv_header_mbstr_h" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_MBSTR_H 1 +_ACEOF + +fi + +done + + +ac_fn_c_check_func "$LINENO" "mbrlen" "ac_cv_func_mbrlen" +if test "x$ac_cv_func_mbrlen" = xyes; then : + $as_echo "#define HAVE_MBRLEN 1" >>confdefs.h + +fi + +ac_fn_c_check_func "$LINENO" "mbscasecmp" "ac_cv_func_mbscasecmp" +if test "x$ac_cv_func_mbscasecmp" = xyes; then : + $as_echo "#define HAVE_MBSCMP 1" >>confdefs.h + +fi + +ac_fn_c_check_func "$LINENO" "mbscmp" "ac_cv_func_mbscmp" +if test "x$ac_cv_func_mbscmp" = xyes; then : + $as_echo "#define HAVE_MBSCMP 1" >>confdefs.h + +fi + +ac_fn_c_check_func "$LINENO" "mbsnrtowcs" "ac_cv_func_mbsnrtowcs" +if test "x$ac_cv_func_mbsnrtowcs" = xyes; then : + $as_echo "#define HAVE_MBSNRTOWCS 1" >>confdefs.h + +fi + +ac_fn_c_check_func "$LINENO" "mbsrtowcs" "ac_cv_func_mbsrtowcs" +if test "x$ac_cv_func_mbsrtowcs" = xyes; then : + $as_echo "#define HAVE_MBSRTOWCS 1" >>confdefs.h + +fi + + +ac_fn_c_check_func "$LINENO" "mbschr" "ac_cv_func_mbschr" +if test "x$ac_cv_func_mbschr" = xyes; then : + $as_echo "#define HAVE_MBSCHR 1" >>confdefs.h + +else + case " $LIBOBJS " in + *" mbschr.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS mbschr.$ac_objext" + ;; +esac + +fi + + + +ac_fn_c_check_func "$LINENO" "wcrtomb" "ac_cv_func_wcrtomb" +if test "x$ac_cv_func_wcrtomb" = xyes; then : + $as_echo "#define HAVE_WCRTOMB 1" >>confdefs.h + +fi + +ac_fn_c_check_func "$LINENO" "wcscoll" "ac_cv_func_wcscoll" +if test "x$ac_cv_func_wcscoll" = xyes; then : + $as_echo "#define HAVE_WCSCOLL 1" >>confdefs.h + +fi + +ac_fn_c_check_func "$LINENO" "wcsdup" "ac_cv_func_wcsdup" +if test "x$ac_cv_func_wcsdup" = xyes; then : + $as_echo "#define HAVE_WCSDUP 1" >>confdefs.h + +fi + +ac_fn_c_check_func "$LINENO" "wcwidth" "ac_cv_func_wcwidth" +if test "x$ac_cv_func_wcwidth" = xyes; then : + $as_echo "#define HAVE_WCWIDTH 1" >>confdefs.h + +fi + +ac_fn_c_check_func "$LINENO" "wctype" "ac_cv_func_wctype" +if test "x$ac_cv_func_wctype" = xyes; then : + $as_echo "#define HAVE_WCTYPE 1" >>confdefs.h + +fi + + +ac_fn_c_check_func "$LINENO" "wcswidth" "ac_cv_func_wcswidth" +if test "x$ac_cv_func_wcswidth" = xyes; then : + $as_echo "#define HAVE_WCSWIDTH 1" >>confdefs.h + +else + case " $LIBOBJS " in + *" wcswidth.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS wcswidth.$ac_objext" + ;; +esac + +fi + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether mbrtowc and mbstate_t are properly declared" >&5 +$as_echo_n "checking whether mbrtowc and mbstate_t are properly declared... " >&6; } +if ${ac_cv_func_mbrtowc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ +wchar_t wc; + char const s[] = ""; + size_t n = 1; + mbstate_t state; + return ! (sizeof state && (mbrtowc) (&wc, s, n, &state)); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_func_mbrtowc=yes +else + ac_cv_func_mbrtowc=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_mbrtowc" >&5 +$as_echo "$ac_cv_func_mbrtowc" >&6; } + if test $ac_cv_func_mbrtowc = yes; then + +$as_echo "#define HAVE_MBRTOWC 1" >>confdefs.h + + fi + +if test $ac_cv_func_mbrtowc = yes; then + $as_echo "#define HAVE_MBSTATE_T 1" >>confdefs.h + +fi + +for ac_func in iswlower iswupper towlower towupper iswctype +do : + as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" +if eval test \"x\$"$as_ac_var"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for nl_langinfo and CODESET" >&5 +$as_echo_n "checking for nl_langinfo and CODESET... " >&6; } +if ${bash_cv_langinfo_codeset+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ +char* cs = nl_langinfo(CODESET); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + bash_cv_langinfo_codeset=yes +else + bash_cv_langinfo_codeset=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bash_cv_langinfo_codeset" >&5 +$as_echo "$bash_cv_langinfo_codeset" >&6; } +if test $bash_cv_langinfo_codeset = yes; then + $as_echo "#define HAVE_LANGINFO_CODESET 1" >>confdefs.h + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for wchar_t in wchar.h" >&5 +$as_echo_n "checking for wchar_t in wchar.h... " >&6; } +if ${bash_cv_type_wchar_t+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +int +main () +{ + + wchar_t foo; + foo = 0; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + bash_cv_type_wchar_t=yes +else + bash_cv_type_wchar_t=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bash_cv_type_wchar_t" >&5 +$as_echo "$bash_cv_type_wchar_t" >&6; } +if test $bash_cv_type_wchar_t = yes; then + +$as_echo "#define HAVE_WCHAR_T 1" >>confdefs.h + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for wctype_t in wctype.h" >&5 +$as_echo_n "checking for wctype_t in wctype.h... " >&6; } +if ${bash_cv_type_wctype_t+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ + + wctype_t foo; + foo = 0; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + bash_cv_type_wctype_t=yes +else + bash_cv_type_wctype_t=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bash_cv_type_wctype_t" >&5 +$as_echo "$bash_cv_type_wctype_t" >&6; } +if test $bash_cv_type_wctype_t = yes; then + +$as_echo "#define HAVE_WCTYPE_T 1" >>confdefs.h + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for wint_t in wctype.h" >&5 +$as_echo_n "checking for wint_t in wctype.h... " >&6; } +if ${bash_cv_type_wint_t+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ + + wint_t foo; + foo = 0; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + bash_cv_type_wint_t=yes +else + bash_cv_type_wint_t=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bash_cv_type_wint_t" >&5 +$as_echo "$bash_cv_type_wint_t" >&6; } +if test $bash_cv_type_wint_t = yes; then + +$as_echo "#define HAVE_WINT_T 1" >>confdefs.h + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for wcwidth broken with unicode combining characters" >&5 +$as_echo_n "checking for wcwidth broken with unicode combining characters... " >&6; } +if ${bash_cv_wcwidth_broken+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + bash_cv_wcwidth_broken=no +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include +#include + +#include +#include + +main(c, v) +int c; +char **v; +{ + int w; + + setlocale(LC_ALL, "en_US.UTF-8"); + w = wcwidth (0x0301); + exit (w == 0); /* exit 0 if wcwidth broken */ +} + +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + bash_cv_wcwidth_broken=yes +else + bash_cv_wcwidth_broken=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bash_cv_wcwidth_broken" >&5 +$as_echo "$bash_cv_wcwidth_broken" >&6; } +if test "$bash_cv_wcwidth_broken" = yes; then + +$as_echo "#define WCWIDTH_BROKEN 1" >>confdefs.h + +fi + +if test "$am_cv_func_iconv" = yes; then + OLDLIBS="$LIBS" + LIBS="$LIBS $LIBINTL $LIBICONV" + for ac_func in locale_charset +do : + ac_fn_c_check_func "$LINENO" "locale_charset" "ac_cv_func_locale_charset" +if test "x$ac_cv_func_locale_charset" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LOCALE_CHARSET 1 +_ACEOF + +fi +done + + LIBS="$OLDLIBS" +fi + + + +if test "$opt_static_link" != yes; then +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 +$as_echo_n "checking for dlopen in -ldl... " >&6; } +if ${ac_cv_lib_dl_dlopen+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldl $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char dlopen (); +int +main () +{ +return dlopen (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_dl_dlopen=yes +else + ac_cv_lib_dl_dlopen=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 +$as_echo "$ac_cv_lib_dl_dlopen" >&6; } +if test "x$ac_cv_lib_dl_dlopen" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBDL 1 +_ACEOF + + LIBS="-ldl $LIBS" + +fi + +for ac_func in dlopen dlclose dlsym +do : + as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" +if eval test \"x\$"$as_ac_var"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + +fi + +ac_fn_c_check_decl "$LINENO" "sys_siglist" "ac_cv_have_decl_sys_siglist" "#include +/* NetBSD declares sys_siglist in unistd.h. */ +#ifdef HAVE_UNISTD_H +# include +#endif + +" +if test "x$ac_cv_have_decl_sys_siglist" = xyes; then : + ac_have_decl=1 +else + ac_have_decl=0 +fi + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_SYS_SIGLIST $ac_have_decl +_ACEOF + + + +if test "$ac_cv_func_inet_aton" != 'yes'; then + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for inet_aton" >&5 +$as_echo_n "checking for inet_aton... " >&6; } +if ${bash_cv_func_inet_aton+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include +#include +struct in_addr ap; +int +main () +{ + inet_aton("127.0.0.1", &ap); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + bash_cv_func_inet_aton=yes +else + bash_cv_func_inet_aton=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bash_cv_func_inet_aton" >&5 +$as_echo "$bash_cv_func_inet_aton" >&6; } +if test $bash_cv_func_inet_aton = yes; then + $as_echo "#define HAVE_INET_ATON 1" >>confdefs.h + +else + case " $LIBOBJS " in + *" inet_aton.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS inet_aton.$ac_objext" + ;; +esac + +fi + +fi + +case "$host_os" in +irix4*) { $as_echo "$as_me:${as_lineno-$LINENO}: checking for getpwent in -lsun" >&5 +$as_echo_n "checking for getpwent in -lsun... " >&6; } +if ${ac_cv_lib_sun_getpwent+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lsun $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char getpwent (); +int +main () +{ +return getpwent (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_sun_getpwent=yes +else + ac_cv_lib_sun_getpwent=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_sun_getpwent" >&5 +$as_echo "$ac_cv_lib_sun_getpwent" >&6; } +if test "x$ac_cv_lib_sun_getpwent" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBSUN 1 +_ACEOF + + LIBS="-lsun $LIBS" + +fi + ;; +esac + +if test "$ac_cv_func_getpeername" = no; then + +if test "X$bash_cv_have_socklib" = "X"; then +_bash_needmsg= +else +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for socket library" >&5 +$as_echo_n "checking for socket library... " >&6; } +_bash_needmsg=yes +fi +if ${bash_cv_have_socklib+:} false; then : + $as_echo_n "(cached) " >&6 +else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for getpeername in -lsocket" >&5 +$as_echo_n "checking for getpeername in -lsocket... " >&6; } +if ${ac_cv_lib_socket_getpeername+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lsocket -lnsl $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char getpeername (); +int +main () +{ +return getpeername (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_socket_getpeername=yes +else + ac_cv_lib_socket_getpeername=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_socket_getpeername" >&5 +$as_echo "$ac_cv_lib_socket_getpeername" >&6; } +if test "x$ac_cv_lib_socket_getpeername" = xyes; then : + bash_cv_have_socklib=yes +else + bash_cv_have_socklib=no +fi + +fi + +if test "X$_bash_needmsg" = Xyes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $bash_cv_have_socklib" >&5 +$as_echo "$bash_cv_have_socklib" >&6; } + _bash_needmsg= +fi +if test $bash_cv_have_socklib = yes; then + # check for libnsl, add it to LIBS if present + if test "X$bash_cv_have_libnsl" = "X"; then + _bash_needmsg= + else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libnsl" >&5 +$as_echo_n "checking for libnsl... " >&6; } + _bash_needmsg=yes + fi + if ${bash_cv_have_libnsl+:} false; then : + $as_echo_n "(cached) " >&6 +else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for t_open in -lnsl" >&5 +$as_echo_n "checking for t_open in -lnsl... " >&6; } +if ${ac_cv_lib_nsl_t_open+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lnsl $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char t_open (); +int +main () +{ +return t_open (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_nsl_t_open=yes +else + ac_cv_lib_nsl_t_open=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_nsl_t_open" >&5 +$as_echo "$ac_cv_lib_nsl_t_open" >&6; } +if test "x$ac_cv_lib_nsl_t_open" = xyes; then : + bash_cv_have_libnsl=yes +else + bash_cv_have_libnsl=no +fi + +fi + + if test "X$_bash_needmsg" = Xyes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $bash_cv_have_libnsl" >&5 +$as_echo "$bash_cv_have_libnsl" >&6; } + _bash_needmsg= + fi + if test $bash_cv_have_libnsl = yes; then + LIBS="-lsocket -lnsl $LIBS" + else + LIBS="-lsocket $LIBS" + fi + $as_echo "#define HAVE_LIBSOCKET 1" >>confdefs.h + + $as_echo "#define HAVE_GETPEERNAME 1" >>confdefs.h + +fi + +fi +if test "$ac_cv_func_gethostbyname" = no; then + if test "X$bash_cv_have_gethostbyname" = "X"; then +_bash_needmsg=yes +else +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for gethostbyname in socket library" >&5 +$as_echo_n "checking for gethostbyname in socket library... " >&6; } +_bash_needmsg= +fi +if ${bash_cv_have_gethostbyname+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ + struct hostent *hp; + hp = gethostbyname("localhost"); + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + bash_cv_have_gethostbyname=yes +else + bash_cv_have_gethostbyname=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + +fi + +if test "X$_bash_needmsg" = Xyes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gethostbyname in socket library" >&5 +$as_echo_n "checking for gethostbyname in socket library... " >&6; } +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bash_cv_have_gethostbyname" >&5 +$as_echo "$bash_cv_have_gethostbyname" >&6; } +if test "$bash_cv_have_gethostbyname" = yes; then +$as_echo "#define HAVE_GETHOSTBYNAME 1" >>confdefs.h + +fi + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking type of array argument to getgroups" >&5 +$as_echo_n "checking type of array argument to getgroups... " >&6; } +if ${ac_cv_type_getgroups+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + ac_cv_type_getgroups=cross +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +/* Thanks to Mike Rendell for this test. */ +$ac_includes_default +#define NGID 256 +#undef MAX +#define MAX(x, y) ((x) > (y) ? (x) : (y)) + +int +main () +{ + gid_t gidset[NGID]; + int i, n; + union { gid_t gval; long int lval; } val; + + val.lval = -1; + for (i = 0; i < NGID; i++) + gidset[i] = val.gval; + n = getgroups (sizeof (gidset) / MAX (sizeof (int), sizeof (gid_t)) - 1, + gidset); + /* Exit non-zero if getgroups seems to require an array of ints. This + happens when gid_t is short int but getgroups modifies an array + of ints. */ + return n > 0 && gidset[n] != val.gval; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + ac_cv_type_getgroups=gid_t +else + ac_cv_type_getgroups=int +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +if test $ac_cv_type_getgroups = cross; then + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "getgroups.*int.*gid_t" >/dev/null 2>&1; then : + ac_cv_type_getgroups=gid_t +else + ac_cv_type_getgroups=int +fi +rm -f conftest* + +fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_getgroups" >&5 +$as_echo "$ac_cv_type_getgroups" >&6; } + +cat >>confdefs.h <<_ACEOF +#define GETGROUPS_T $ac_cv_type_getgroups +_ACEOF + + +ac_fn_c_check_type "$LINENO" "off_t" "ac_cv_type_off_t" "$ac_includes_default" +if test "x$ac_cv_type_off_t" = xyes; then : + +else + +cat >>confdefs.h <<_ACEOF +#define off_t long int +_ACEOF + +fi + +ac_fn_c_check_type "$LINENO" "mode_t" "ac_cv_type_mode_t" "$ac_includes_default" +if test "x$ac_cv_type_mode_t" = xyes; then : + +else + +cat >>confdefs.h <<_ACEOF +#define mode_t int +_ACEOF + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for uid_t in sys/types.h" >&5 +$as_echo_n "checking for uid_t in sys/types.h... " >&6; } +if ${ac_cv_type_uid_t+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "uid_t" >/dev/null 2>&1; then : + ac_cv_type_uid_t=yes +else + ac_cv_type_uid_t=no +fi +rm -f conftest* + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_uid_t" >&5 +$as_echo "$ac_cv_type_uid_t" >&6; } +if test $ac_cv_type_uid_t = no; then + +$as_echo "#define uid_t int" >>confdefs.h + + +$as_echo "#define gid_t int" >>confdefs.h + +fi + +ac_fn_c_check_type "$LINENO" "pid_t" "ac_cv_type_pid_t" "$ac_includes_default" +if test "x$ac_cv_type_pid_t" = xyes; then : + +else + +cat >>confdefs.h <<_ACEOF +#define pid_t int +_ACEOF + +fi + +ac_fn_c_check_type "$LINENO" "size_t" "ac_cv_type_size_t" "$ac_includes_default" +if test "x$ac_cv_type_size_t" = xyes; then : + +else + +cat >>confdefs.h <<_ACEOF +#define size_t unsigned int +_ACEOF + +fi + + + ac_fn_c_check_type "$LINENO" "uintptr_t" "ac_cv_type_uintptr_t" "$ac_includes_default" +if test "x$ac_cv_type_uintptr_t" = xyes; then : + +$as_echo "#define HAVE_UINTPTR_T 1" >>confdefs.h + +else + for ac_type in 'unsigned int' 'unsigned long int' \ + 'unsigned long long int'; do + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(sizeof (void *) <= sizeof ($ac_type))]; +test_array [0] = 0; +return test_array [0]; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + +cat >>confdefs.h <<_ACEOF +#define uintptr_t $ac_type +_ACEOF + + ac_type= +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + test -z "$ac_type" && break + done +fi + + + +ac_fn_c_check_type "$LINENO" "ssize_t" "ac_cv_type_ssize_t" "$ac_includes_default" +if test "x$ac_cv_type_ssize_t" = xyes; then : + +else + +cat >>confdefs.h <<_ACEOF +#define ssize_t int +_ACEOF + +fi + +ac_fn_c_check_type "$LINENO" "time_t" "ac_cv_type_time_t" "$ac_includes_default" +if test "x$ac_cv_type_time_t" = xyes; then : + +else + +cat >>confdefs.h <<_ACEOF +#define time_t long +_ACEOF + +fi + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for long long" >&5 +$as_echo_n "checking for long long... " >&6; } +if ${bash_cv_type_long_long+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +long long ll = 1; int i = 63; +int +main () +{ + +long long llm = (long long) -1; +return ll << i | ll >> i | llm / ll | llm % ll; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + bash_cv_type_long_long='long long' +else + bash_cv_type_long_long='long' +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bash_cv_type_long_long" >&5 +$as_echo "$bash_cv_type_long_long" >&6; } +if test "$bash_cv_type_long_long" = 'long long'; then + $as_echo "#define HAVE_LONG_LONG 1" >>confdefs.h + +fi + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for unsigned long long" >&5 +$as_echo_n "checking for unsigned long long... " >&6; } +if ${bash_cv_type_unsigned_long_long+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +unsigned long long ull = 1; int i = 63; +int +main () +{ + +unsigned long long ullmax = (unsigned long long) -1; +return ull << i | ull >> i | ullmax / ull | ullmax % ull; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + bash_cv_type_unsigned_long_long='unsigned long long' +else + bash_cv_type_unsigned_long_long='unsigned long' +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bash_cv_type_unsigned_long_long" >&5 +$as_echo "$bash_cv_type_unsigned_long_long" >&6; } +if test "$bash_cv_type_unsigned_long_long" = 'unsigned long long'; then + $as_echo "#define HAVE_UNSIGNED_LONG_LONG 1" >>confdefs.h + +fi + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking return type of signal handlers" >&5 +$as_echo_n "checking return type of signal handlers... " >&6; } +if ${ac_cv_type_signal+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include + +int +main () +{ +return *(signal (0, 0)) (0) == 1; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_type_signal=int +else + ac_cv_type_signal=void +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_signal" >&5 +$as_echo "$ac_cv_type_signal" >&6; } + +cat >>confdefs.h <<_ACEOF +#define RETSIGTYPE $ac_cv_type_signal +_ACEOF + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sig_atomic_t in signal.h" >&5 +$as_echo_n "checking for sig_atomic_t in signal.h... " >&6; } +if ${ac_cv_have_sig_atomic_t+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include + +int +main () +{ + sig_atomic_t x; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_have_sig_atomic_t=yes +else + ac_cv_have_sig_atomic_t=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_have_sig_atomic_t" >&5 +$as_echo "$ac_cv_have_sig_atomic_t" >&6; } +if test "$ac_cv_have_sig_atomic_t" = "no" +then + ac_fn_c_check_type "$LINENO" "sig_atomic_t" "ac_cv_type_sig_atomic_t" "$ac_includes_default" +if test "x$ac_cv_type_sig_atomic_t" = xyes; then : + +else + +cat >>confdefs.h <<_ACEOF +#define sig_atomic_t int +_ACEOF + +fi + +fi + + +# The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of char" >&5 +$as_echo_n "checking size of char... " >&6; } +if ${ac_cv_sizeof_char+:} false; then : + $as_echo_n "(cached) " >&6 +else + if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (char))" "ac_cv_sizeof_char" "$ac_includes_default"; then : + +else + if test "$ac_cv_type_char" = yes; then + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error 77 "cannot compute sizeof (char) +See \`config.log' for more details" "$LINENO" 5; } + else + ac_cv_sizeof_char=0 + fi +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_char" >&5 +$as_echo "$ac_cv_sizeof_char" >&6; } + + + +cat >>confdefs.h <<_ACEOF +#define SIZEOF_CHAR $ac_cv_sizeof_char +_ACEOF + + +# The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of short" >&5 +$as_echo_n "checking size of short... " >&6; } +if ${ac_cv_sizeof_short+:} false; then : + $as_echo_n "(cached) " >&6 +else + if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (short))" "ac_cv_sizeof_short" "$ac_includes_default"; then : + +else + if test "$ac_cv_type_short" = yes; then + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error 77 "cannot compute sizeof (short) +See \`config.log' for more details" "$LINENO" 5; } + else + ac_cv_sizeof_short=0 + fi +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_short" >&5 +$as_echo "$ac_cv_sizeof_short" >&6; } + + + +cat >>confdefs.h <<_ACEOF +#define SIZEOF_SHORT $ac_cv_sizeof_short +_ACEOF + + +# The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of int" >&5 +$as_echo_n "checking size of int... " >&6; } +if ${ac_cv_sizeof_int+:} false; then : + $as_echo_n "(cached) " >&6 +else + if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (int))" "ac_cv_sizeof_int" "$ac_includes_default"; then : + +else + if test "$ac_cv_type_int" = yes; then + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error 77 "cannot compute sizeof (int) +See \`config.log' for more details" "$LINENO" 5; } + else + ac_cv_sizeof_int=0 + fi +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_int" >&5 +$as_echo "$ac_cv_sizeof_int" >&6; } + + + +cat >>confdefs.h <<_ACEOF +#define SIZEOF_INT $ac_cv_sizeof_int +_ACEOF + + +# The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of long" >&5 +$as_echo_n "checking size of long... " >&6; } +if ${ac_cv_sizeof_long+:} false; then : + $as_echo_n "(cached) " >&6 +else + if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (long))" "ac_cv_sizeof_long" "$ac_includes_default"; then : + +else + if test "$ac_cv_type_long" = yes; then + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error 77 "cannot compute sizeof (long) +See \`config.log' for more details" "$LINENO" 5; } + else + ac_cv_sizeof_long=0 + fi +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_long" >&5 +$as_echo "$ac_cv_sizeof_long" >&6; } + + + +cat >>confdefs.h <<_ACEOF +#define SIZEOF_LONG $ac_cv_sizeof_long +_ACEOF + + +# The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of char *" >&5 +$as_echo_n "checking size of char *... " >&6; } +if ${ac_cv_sizeof_char_p+:} false; then : + $as_echo_n "(cached) " >&6 +else + if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (char *))" "ac_cv_sizeof_char_p" "$ac_includes_default"; then : + +else + if test "$ac_cv_type_char_p" = yes; then + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error 77 "cannot compute sizeof (char *) +See \`config.log' for more details" "$LINENO" 5; } + else + ac_cv_sizeof_char_p=0 + fi +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_char_p" >&5 +$as_echo "$ac_cv_sizeof_char_p" >&6; } + + + +cat >>confdefs.h <<_ACEOF +#define SIZEOF_CHAR_P $ac_cv_sizeof_char_p +_ACEOF + + +# The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of double" >&5 +$as_echo_n "checking size of double... " >&6; } +if ${ac_cv_sizeof_double+:} false; then : + $as_echo_n "(cached) " >&6 +else + if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (double))" "ac_cv_sizeof_double" "$ac_includes_default"; then : + +else + if test "$ac_cv_type_double" = yes; then + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error 77 "cannot compute sizeof (double) +See \`config.log' for more details" "$LINENO" 5; } + else + ac_cv_sizeof_double=0 + fi +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_double" >&5 +$as_echo "$ac_cv_sizeof_double" >&6; } + + + +cat >>confdefs.h <<_ACEOF +#define SIZEOF_DOUBLE $ac_cv_sizeof_double +_ACEOF + + +# The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of long long" >&5 +$as_echo_n "checking size of long long... " >&6; } +if ${ac_cv_sizeof_long_long+:} false; then : + $as_echo_n "(cached) " >&6 +else + if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (long long))" "ac_cv_sizeof_long_long" "$ac_includes_default"; then : + +else + if test "$ac_cv_type_long_long" = yes; then + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error 77 "cannot compute sizeof (long long) +See \`config.log' for more details" "$LINENO" 5; } + else + ac_cv_sizeof_long_long=0 + fi +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_long_long" >&5 +$as_echo "$ac_cv_sizeof_long_long" >&6; } + + + +cat >>confdefs.h <<_ACEOF +#define SIZEOF_LONG_LONG $ac_cv_sizeof_long_long +_ACEOF + + + +ac_fn_c_check_type "$LINENO" "u_int" "ac_cv_type_u_int" "$ac_includes_default" +if test "x$ac_cv_type_u_int" = xyes; then : + +else + +cat >>confdefs.h <<_ACEOF +#define u_int unsigned int +_ACEOF + +fi + +ac_fn_c_check_type "$LINENO" "u_long" "ac_cv_type_u_long" "$ac_includes_default" +if test "x$ac_cv_type_u_long" = xyes; then : + +else + +cat >>confdefs.h <<_ACEOF +#define u_long unsigned long +_ACEOF + +fi + + + +if test "$ac_cv_sizeof_short" = 2; then + ac_fn_c_check_type "$LINENO" "bits16_t" "ac_cv_type_bits16_t" "$ac_includes_default" +if test "x$ac_cv_type_bits16_t" = xyes; then : + +else + +cat >>confdefs.h <<_ACEOF +#define bits16_t short +_ACEOF + +fi + +elif test "$ac_cv_sizeof_char" = 2; then + ac_fn_c_check_type "$LINENO" "bits16_t" "ac_cv_type_bits16_t" "$ac_includes_default" +if test "x$ac_cv_type_bits16_t" = xyes; then : + +else + +cat >>confdefs.h <<_ACEOF +#define bits16_t char +_ACEOF + +fi + +else + ac_fn_c_check_type "$LINENO" "bits16_t" "ac_cv_type_bits16_t" "$ac_includes_default" +if test "x$ac_cv_type_bits16_t" = xyes; then : + +else + +cat >>confdefs.h <<_ACEOF +#define bits16_t short +_ACEOF + +fi + +fi + + +if test "$ac_cv_sizeof_short" = 2; then + ac_fn_c_check_type "$LINENO" "u_bits16_t" "ac_cv_type_u_bits16_t" "$ac_includes_default" +if test "x$ac_cv_type_u_bits16_t" = xyes; then : + +else + +cat >>confdefs.h <<_ACEOF +#define u_bits16_t unsigned short +_ACEOF + +fi + +elif test "$ac_cv_sizeof_char" = 2; then + ac_fn_c_check_type "$LINENO" "u_bits16_t" "ac_cv_type_u_bits16_t" "$ac_includes_default" +if test "x$ac_cv_type_u_bits16_t" = xyes; then : + +else + +cat >>confdefs.h <<_ACEOF +#define u_bits16_t unsigned char +_ACEOF + +fi + +else + ac_fn_c_check_type "$LINENO" "u_bits16_t" "ac_cv_type_u_bits16_t" "$ac_includes_default" +if test "x$ac_cv_type_u_bits16_t" = xyes; then : + +else + +cat >>confdefs.h <<_ACEOF +#define u_bits16_t unsigned short +_ACEOF + +fi + +fi + + +if test "$ac_cv_sizeof_int" = 4; then + ac_fn_c_check_type "$LINENO" "bits32_t" "ac_cv_type_bits32_t" "$ac_includes_default" +if test "x$ac_cv_type_bits32_t" = xyes; then : + +else + +cat >>confdefs.h <<_ACEOF +#define bits32_t int +_ACEOF + +fi + +elif test "$ac_cv_sizeof_long" = 4; then + ac_fn_c_check_type "$LINENO" "bits32_t" "ac_cv_type_bits32_t" "$ac_includes_default" +if test "x$ac_cv_type_bits32_t" = xyes; then : + +else + +cat >>confdefs.h <<_ACEOF +#define bits32_t long +_ACEOF + +fi + +else + ac_fn_c_check_type "$LINENO" "bits32_t" "ac_cv_type_bits32_t" "$ac_includes_default" +if test "x$ac_cv_type_bits32_t" = xyes; then : + +else + +cat >>confdefs.h <<_ACEOF +#define bits32_t int +_ACEOF + +fi + +fi + + +if test "$ac_cv_sizeof_int" = 4; then + ac_fn_c_check_type "$LINENO" "u_bits32_t" "ac_cv_type_u_bits32_t" "$ac_includes_default" +if test "x$ac_cv_type_u_bits32_t" = xyes; then : + +else + +cat >>confdefs.h <<_ACEOF +#define u_bits32_t unsigned int +_ACEOF + +fi + +elif test "$ac_cv_sizeof_long" = 4; then + ac_fn_c_check_type "$LINENO" "u_bits32_t" "ac_cv_type_u_bits32_t" "$ac_includes_default" +if test "x$ac_cv_type_u_bits32_t" = xyes; then : + +else + +cat >>confdefs.h <<_ACEOF +#define u_bits32_t unsigned long +_ACEOF + +fi + +else + ac_fn_c_check_type "$LINENO" "u_bits32_t" "ac_cv_type_u_bits32_t" "$ac_includes_default" +if test "x$ac_cv_type_u_bits32_t" = xyes; then : + +else + +cat >>confdefs.h <<_ACEOF +#define u_bits32_t unsigned int +_ACEOF + +fi + +fi + + +if test "$ac_cv_sizeof_char_p" = 8; then + ac_fn_c_check_type "$LINENO" "bits64_t" "ac_cv_type_bits64_t" "$ac_includes_default" +if test "x$ac_cv_type_bits64_t" = xyes; then : + +else + +cat >>confdefs.h <<_ACEOF +#define bits64_t char * +_ACEOF + +fi + +elif test "$ac_cv_sizeof_double" = 8; then + ac_fn_c_check_type "$LINENO" "bits64_t" "ac_cv_type_bits64_t" "$ac_includes_default" +if test "x$ac_cv_type_bits64_t" = xyes; then : + +else + +cat >>confdefs.h <<_ACEOF +#define bits64_t double +_ACEOF + +fi + +elif test -n "$ac_cv_type_long_long" && test "$ac_cv_sizeof_long_long" = 8; then + ac_fn_c_check_type "$LINENO" "bits64_t" "ac_cv_type_bits64_t" "$ac_includes_default" +if test "x$ac_cv_type_bits64_t" = xyes; then : + +else + +cat >>confdefs.h <<_ACEOF +#define bits64_t long long +_ACEOF + +fi + +elif test "$ac_cv_sizeof_long" = 8; then + ac_fn_c_check_type "$LINENO" "bits64_t" "ac_cv_type_bits64_t" "$ac_includes_default" +if test "x$ac_cv_type_bits64_t" = xyes; then : + +else + +cat >>confdefs.h <<_ACEOF +#define bits64_t long +_ACEOF + +fi + +else + ac_fn_c_check_type "$LINENO" "bits64_t" "ac_cv_type_bits64_t" "$ac_includes_default" +if test "x$ac_cv_type_bits64_t" = xyes; then : + +else + +cat >>confdefs.h <<_ACEOF +#define bits64_t double +_ACEOF + +fi + +fi + + + +if test "$ac_cv_sizeof_int" = "$ac_cv_sizeof_char_p"; then + ac_fn_c_check_type "$LINENO" "ptrdiff_t" "ac_cv_type_ptrdiff_t" "$ac_includes_default" +if test "x$ac_cv_type_ptrdiff_t" = xyes; then : + +else + +cat >>confdefs.h <<_ACEOF +#define ptrdiff_t int +_ACEOF + +fi + +elif test "$ac_cv_sizeof_long" = "$ac_cv_sizeof_char_p"; then + ac_fn_c_check_type "$LINENO" "ptrdiff_t" "ac_cv_type_ptrdiff_t" "$ac_includes_default" +if test "x$ac_cv_type_ptrdiff_t" = xyes; then : + +else + +cat >>confdefs.h <<_ACEOF +#define ptrdiff_t long +_ACEOF + +fi + +elif test "$ac_cv_type_long_long" = yes && test "$ac_cv_sizeof_long_long" = "$ac_cv_sizeof_char_p"; then + ac_fn_c_check_type "$LINENO" "ptrdiff_t" "ac_cv_type_ptrdiff_t" "$ac_includes_default" +if test "x$ac_cv_type_ptrdiff_t" = xyes; then : + +else + +cat >>confdefs.h <<_ACEOF +#define ptrdiff_t long long +_ACEOF + +fi + +else + ac_fn_c_check_type "$LINENO" "ptrdiff_t" "ac_cv_type_ptrdiff_t" "$ac_includes_default" +if test "x$ac_cv_type_ptrdiff_t" = xyes; then : + +else + +cat >>confdefs.h <<_ACEOF +#define ptrdiff_t int +_ACEOF + +fi + +fi + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stat file-mode macros are broken" >&5 +$as_echo_n "checking whether stat file-mode macros are broken... " >&6; } +if ${ac_cv_header_stat_broken+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include + +#if defined S_ISBLK && defined S_IFDIR +extern char c1[S_ISBLK (S_IFDIR) ? -1 : 1]; +#endif + +#if defined S_ISBLK && defined S_IFCHR +extern char c2[S_ISBLK (S_IFCHR) ? -1 : 1]; +#endif + +#if defined S_ISLNK && defined S_IFREG +extern char c3[S_ISLNK (S_IFREG) ? -1 : 1]; +#endif + +#if defined S_ISSOCK && defined S_IFREG +extern char c4[S_ISSOCK (S_IFREG) ? -1 : 1]; +#endif + +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_header_stat_broken=no +else + ac_cv_header_stat_broken=yes +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stat_broken" >&5 +$as_echo "$ac_cv_header_stat_broken" >&6; } +if test $ac_cv_header_stat_broken = yes; then + +$as_echo "#define STAT_MACROS_BROKEN 1" >>confdefs.h + +fi + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether #! works in shell scripts" >&5 +$as_echo_n "checking whether #! works in shell scripts... " >&6; } +if ${ac_cv_sys_interpreter+:} false; then : + $as_echo_n "(cached) " >&6 +else + echo '#! /bin/cat +exit 69 +' >conftest +chmod u+x conftest +(SHELL=/bin/sh; export SHELL; ./conftest >/dev/null 2>&1) +if test $? -ne 69; then + ac_cv_sys_interpreter=yes +else + ac_cv_sys_interpreter=no +fi +rm -f conftest +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_interpreter" >&5 +$as_echo "$ac_cv_sys_interpreter" >&6; } +interpval=$ac_cv_sys_interpreter + +if test $ac_cv_sys_interpreter = yes; then +$as_echo "#define HAVE_HASH_BANG_EXEC 1" >>confdefs.h + +fi + +if test "$ac_cv_func_lstat" = "no"; then +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for lstat" >&5 +$as_echo_n "checking for lstat... " >&6; } +if ${bash_cv_func_lstat+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include + +int +main () +{ + lstat(".",(struct stat *)0); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + bash_cv_func_lstat=yes +else + bash_cv_func_lstat=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bash_cv_func_lstat" >&5 +$as_echo "$bash_cv_func_lstat" >&6; } +if test $bash_cv_func_lstat = yes; then + $as_echo "#define HAVE_LSTAT 1" >>confdefs.h + +fi + +fi + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the ctype macros accept non-ascii characters" >&5 +$as_echo_n "checking whether the ctype macros accept non-ascii characters... " >&6; } +if ${bash_cv_func_ctype_nonascii+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cannot check ctype macros if cross compiling -- defaulting to no" >&5 +$as_echo "$as_me: WARNING: cannot check ctype macros if cross compiling -- defaulting to no" >&2;} + bash_cv_func_ctype_nonascii=no + +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#ifdef HAVE_LOCALE_H +#include +#endif +#include +#include + +main(c, v) +int c; +char *v[]; +{ + char *deflocale; + unsigned char x; + int r1, r2; + +#ifdef HAVE_SETLOCALE + /* We take a shot here. If that locale is not known, try the + system default. We try this one because '\342' (226) is + known to be a printable character in that locale. */ + deflocale = setlocale(LC_ALL, "en_US.ISO8859-1"); + if (deflocale == 0) + deflocale = setlocale(LC_ALL, ""); +#endif + + x = '\342'; + r1 = isprint(x); + x -= 128; + r2 = isprint(x); + exit (r1 == 0 || r2 == 0); +} + +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + bash_cv_func_ctype_nonascii=yes +else + bash_cv_func_ctype_nonascii=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bash_cv_func_ctype_nonascii" >&5 +$as_echo "$bash_cv_func_ctype_nonascii" >&6; } +if test $bash_cv_func_ctype_nonascii = yes; then +$as_echo "#define CTYPE_NON_ASCII 1" >>confdefs.h + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if dup2 fails to clear the close-on-exec flag" >&5 +$as_echo_n "checking if dup2 fails to clear the close-on-exec flag... " >&6; } +if ${bash_cv_dup2_broken+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cannot check dup2 if cross compiling -- defaulting to no" >&5 +$as_echo "$as_me: WARNING: cannot check dup2 if cross compiling -- defaulting to no" >&2;} + bash_cv_dup2_broken=no +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include +main() +{ + int fd1, fd2, fl; + fd1 = open("/dev/null", 2); + if (fcntl(fd1, 2, 1) < 0) + exit(1); + fd2 = dup2(fd1, 1); + if (fd2 < 0) + exit(2); + fl = fcntl(fd2, 1, 0); + /* fl will be 1 if dup2 did not reset the close-on-exec flag. */ + exit(fl != 1); +} + +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + bash_cv_dup2_broken=yes +else + bash_cv_dup2_broken=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bash_cv_dup2_broken" >&5 +$as_echo "$bash_cv_dup2_broken" >&6; } +if test $bash_cv_dup2_broken = yes; then +$as_echo "#define DUP2_BROKEN 1" >>confdefs.h + +fi + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether pgrps need synchronization" >&5 +$as_echo_n "checking whether pgrps need synchronization... " >&6; } +if ${bash_cv_pgrp_pipe+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cannot check pgrp synchronization if cross compiling -- defaulting to no" >&5 +$as_echo "$as_me: WARNING: cannot check pgrp synchronization if cross compiling -- defaulting to no" >&2;} + bash_cv_pgrp_pipe=no +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#ifdef HAVE_UNISTD_H +# include +#endif +main() +{ +# ifdef GETPGRP_VOID +# define getpgID() getpgrp() +# else +# define getpgID() getpgrp(0) +# define setpgid(x,y) setpgrp(x,y) +# endif + int pid1, pid2, fds[2]; + int status; + char ok; + + switch (pid1 = fork()) { + case -1: + exit(1); + case 0: + setpgid(0, getpid()); + exit(0); + } + setpgid(pid1, pid1); + + sleep(2); /* let first child die */ + + if (pipe(fds) < 0) + exit(2); + + switch (pid2 = fork()) { + case -1: + exit(3); + case 0: + setpgid(0, pid1); + ok = getpgID() == pid1; + write(fds[1], &ok, 1); + exit(0); + } + setpgid(pid2, pid1); + + close(fds[1]); + if (read(fds[0], &ok, 1) != 1) + exit(4); + wait(&status); + wait(&status); + exit(ok ? 0 : 5); +} + +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + bash_cv_pgrp_pipe=no +else + bash_cv_pgrp_pipe=yes +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bash_cv_pgrp_pipe" >&5 +$as_echo "$bash_cv_pgrp_pipe" >&6; } +if test $bash_cv_pgrp_pipe = yes; then +$as_echo "#define PGRP_PIPE 1" >>confdefs.h + +fi + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for type of signal functions" >&5 +$as_echo_n "checking for type of signal functions... " >&6; } +if ${bash_cv_signal_vintage+:} false; then : + $as_echo_n "(cached) " >&6 +else + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ + + sigset_t ss; + struct sigaction sa; + sigemptyset(&ss); sigsuspend(&ss); + sigaction(SIGINT, &sa, (struct sigaction *) 0); + sigprocmask(SIG_BLOCK, &ss, (sigset_t *) 0); + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + bash_cv_signal_vintage=posix +else + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ + + int mask = sigmask(SIGINT); + sigsetmask(mask); sigblock(mask); sigpause(mask); + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + bash_cv_signal_vintage=4.2bsd +else + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + #include + RETSIGTYPE foo() { } +int +main () +{ + + int mask = sigmask(SIGINT); + sigset(SIGINT, foo); sigrelse(SIGINT); + sighold(SIGINT); sigpause(SIGINT); + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + bash_cv_signal_vintage=svr3 +else + bash_cv_signal_vintage=v7 + +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bash_cv_signal_vintage" >&5 +$as_echo "$bash_cv_signal_vintage" >&6; } +if test "$bash_cv_signal_vintage" = posix; then +$as_echo "#define HAVE_POSIX_SIGNALS 1" >>confdefs.h + +elif test "$bash_cv_signal_vintage" = "4.2bsd"; then +$as_echo "#define HAVE_BSD_SIGNALS 1" >>confdefs.h + +elif test "$bash_cv_signal_vintage" = svr3; then +$as_echo "#define HAVE_USG_SIGHOLD 1" >>confdefs.h + +fi + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sys_errlist and sys_nerr" >&5 +$as_echo_n "checking for sys_errlist and sys_nerr... " >&6; } +if ${bash_cv_sys_errlist+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ +extern char *sys_errlist[]; + extern int sys_nerr; + char *msg = sys_errlist[sys_nerr - 1]; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + bash_cv_sys_errlist=yes +else + bash_cv_sys_errlist=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bash_cv_sys_errlist" >&5 +$as_echo "$bash_cv_sys_errlist" >&6; } +if test $bash_cv_sys_errlist = yes; then +$as_echo "#define HAVE_SYS_ERRLIST 1" >>confdefs.h + +fi + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sys_siglist in system C library" >&5 +$as_echo_n "checking for sys_siglist in system C library... " >&6; } +if ${bash_cv_sys_siglist+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cannot check for sys_siglist if cross compiling -- defaulting to no" >&5 +$as_echo "$as_me: WARNING: cannot check for sys_siglist if cross compiling -- defaulting to no" >&2;} + bash_cv_sys_siglist=no +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include +#ifdef HAVE_UNISTD_H +#include +#endif +#if !HAVE_DECL_SYS_SIGLIST +extern char *sys_siglist[]; +#endif +main() +{ +char *msg = sys_siglist[2]; +exit(msg == 0); +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + bash_cv_sys_siglist=yes +else + bash_cv_sys_siglist=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bash_cv_sys_siglist" >&5 +$as_echo "$bash_cv_sys_siglist" >&6; } +if test $bash_cv_sys_siglist = yes; then +$as_echo "#define HAVE_SYS_SIGLIST 1" >>confdefs.h + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for _sys_siglist in signal.h or unistd.h" >&5 +$as_echo_n "checking for _sys_siglist in signal.h or unistd.h... " >&6; } +if ${bash_cv_decl_under_sys_siglist+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include +#ifdef HAVE_UNISTD_H +#include +#endif +int +main () +{ + char *msg = _sys_siglist[2]; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + bash_cv_decl_under_sys_siglist=yes +else + bash_cv_decl_under_sys_siglist=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bash_cv_decl_under_sys_siglist" >&5 +$as_echo "$bash_cv_decl_under_sys_siglist" >&6; } +if test $bash_cv_decl_under_sys_siglist = yes; then +$as_echo "#define UNDER_SYS_SIGLIST_DECLARED 1" >>confdefs.h + +fi + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for _sys_siglist in system C library" >&5 +$as_echo_n "checking for _sys_siglist in system C library... " >&6; } +if ${bash_cv_under_sys_siglist+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cannot check for _sys_siglist if cross compiling -- defaulting to no" >&5 +$as_echo "$as_me: WARNING: cannot check for _sys_siglist if cross compiling -- defaulting to no" >&2;} + bash_cv_under_sys_siglist=no +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include +#ifdef HAVE_UNISTD_H +#include +#endif +#ifndef UNDER_SYS_SIGLIST_DECLARED +extern char *_sys_siglist[]; +#endif +main() +{ +char *msg = (char *)_sys_siglist[2]; +exit(msg == 0); +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + bash_cv_under_sys_siglist=yes +else + bash_cv_under_sys_siglist=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bash_cv_under_sys_siglist" >&5 +$as_echo "$bash_cv_under_sys_siglist" >&6; } +if test $bash_cv_under_sys_siglist = yes; then +$as_echo "#define HAVE_UNDER_SYS_SIGLIST 1" >>confdefs.h + +fi + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether signal handlers are of type void" >&5 +$as_echo_n "checking whether signal handlers are of type void... " >&6; } +if ${bash_cv_void_sighandler+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#ifdef signal +#undef signal +#endif +#ifdef __cplusplus +extern "C" +#endif +void (*signal ()) (); +int +main () +{ +int i; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + bash_cv_void_sighandler=yes +else + bash_cv_void_sighandler=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bash_cv_void_sighandler" >&5 +$as_echo "$bash_cv_void_sighandler" >&6; } +if test $bash_cv_void_sighandler = yes; then +$as_echo "#define VOID_SIGHANDLER 1" >>confdefs.h + +fi + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for clock_t" >&5 +$as_echo_n "checking for clock_t... " >&6; } +if ${bash_cv_type_clock_t+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#if STDC_HEADERS +#include +#include +#endif +#if HAVE_INTTYPES_H +#include +#endif +#if HAVE_STDINT_H +#include +#endif +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "clock_t" >/dev/null 2>&1; then : + bash_cv_type_clock_t=yes +else + bash_cv_type_clock_t=no +fi +rm -f conftest* + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bash_cv_type_clock_t" >&5 +$as_echo "$bash_cv_type_clock_t" >&6; } + +if test $bash_cv_type_clock_t = no; then + cat >>confdefs.h <<_ACEOF +#define clock_t long +_ACEOF + +fi + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sigset_t" >&5 +$as_echo_n "checking for sigset_t... " >&6; } +if ${bash_cv_type_sigset_t+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#if STDC_HEADERS +#include +#include +#endif +#if HAVE_INTTYPES_H +#include +#endif +#if HAVE_STDINT_H +#include +#endif +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "sigset_t" >/dev/null 2>&1; then : + bash_cv_type_sigset_t=yes +else + bash_cv_type_sigset_t=no +fi +rm -f conftest* + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bash_cv_type_sigset_t" >&5 +$as_echo "$bash_cv_type_sigset_t" >&6; } + +if test $bash_cv_type_sigset_t = no; then + cat >>confdefs.h <<_ACEOF +#define sigset_t int +_ACEOF + +fi + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sig_atomic_t" >&5 +$as_echo_n "checking for sig_atomic_t... " >&6; } +if ${bash_cv_type_sig_atomic_t+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#if STDC_HEADERS +#include +#include +#endif +#if HAVE_INTTYPES_H +#include +#endif +#if HAVE_STDINT_H +#include +#endif +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "sig_atomic_t" >/dev/null 2>&1; then : + bash_cv_type_sig_atomic_t=yes +else + bash_cv_type_sig_atomic_t=no +fi +rm -f conftest* + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bash_cv_type_sig_atomic_t" >&5 +$as_echo "$bash_cv_type_sig_atomic_t" >&6; } + +if test $bash_cv_type_sig_atomic_t = no; then + cat >>confdefs.h <<_ACEOF +#define sig_atomic_t int +_ACEOF + +fi + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for quad_t" >&5 +$as_echo_n "checking for quad_t... " >&6; } +if ${bash_cv_type_quad_t+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#if STDC_HEADERS +#include +#include +#endif +#if HAVE_INTTYPES_H +#include +#endif +#if HAVE_STDINT_H +#include +#endif + + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "quad_t" >/dev/null 2>&1; then : + bash_cv_type_quad_t=yes +else + bash_cv_type_quad_t=no +fi +rm -f conftest* + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bash_cv_type_quad_t" >&5 +$as_echo "$bash_cv_type_quad_t" >&6; } +if test $bash_cv_type_quad_t = yes; then + $as_echo "#define HAVE_QUAD_T 1" >>confdefs.h + + fi +if test $bash_cv_type_quad_t = no; then + cat >>confdefs.h <<_ACEOF +#define quad_t long +_ACEOF + +fi + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for intmax_t" >&5 +$as_echo_n "checking for intmax_t... " >&6; } +if ${bash_cv_type_intmax_t+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#if STDC_HEADERS +#include +#include +#endif +#if HAVE_INTTYPES_H +#include +#endif +#if HAVE_STDINT_H +#include +#endif + + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "intmax_t" >/dev/null 2>&1; then : + bash_cv_type_intmax_t=yes +else + bash_cv_type_intmax_t=no +fi +rm -f conftest* + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bash_cv_type_intmax_t" >&5 +$as_echo "$bash_cv_type_intmax_t" >&6; } + +if test $bash_cv_type_intmax_t = no; then + cat >>confdefs.h <<_ACEOF +#define intmax_t $bash_cv_type_long_long +_ACEOF + +fi + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for uintmax_t" >&5 +$as_echo_n "checking for uintmax_t... " >&6; } +if ${bash_cv_type_uintmax_t+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#if STDC_HEADERS +#include +#include +#endif +#if HAVE_INTTYPES_H +#include +#endif +#if HAVE_STDINT_H +#include +#endif + + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "uintmax_t" >/dev/null 2>&1; then : + bash_cv_type_uintmax_t=yes +else + bash_cv_type_uintmax_t=no +fi +rm -f conftest* + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bash_cv_type_uintmax_t" >&5 +$as_echo "$bash_cv_type_uintmax_t" >&6; } + +if test $bash_cv_type_uintmax_t = no; then + cat >>confdefs.h <<_ACEOF +#define uintmax_t $bash_cv_type_unsigned_long_long +_ACEOF + +fi + +if test "$ac_cv_header_sys_socket_h" = "yes"; then + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for socklen_t" >&5 +$as_echo_n "checking for socklen_t... " >&6; } +if ${bash_cv_type_socklen_t+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#if STDC_HEADERS +#include +#include +#endif +#if HAVE_INTTYPES_H +#include +#endif +#if HAVE_STDINT_H +#include +#endif +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "socklen_t" >/dev/null 2>&1; then : + bash_cv_type_socklen_t=yes +else + bash_cv_type_socklen_t=no +fi +rm -f conftest* + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bash_cv_type_socklen_t" >&5 +$as_echo "$bash_cv_type_socklen_t" >&6; } +if test $bash_cv_type_socklen_t = yes; then + $as_echo "#define HAVE_SOCKLEN_T 1" >>confdefs.h + + fi +if test $bash_cv_type_socklen_t = no; then + cat >>confdefs.h <<_ACEOF +#define socklen_t unsigned int +_ACEOF + +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for size and type of struct rlimit fields" >&5 +$as_echo_n "checking for size and type of struct rlimit fields... " >&6; } +if ${bash_cv_type_rlimit+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +int +main () +{ +rlim_t xxx; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + bash_cv_type_rlimit=rlim_t +else + +if test "$cross_compiling" = yes; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cannot check quad_t if cross compiling -- defaulting to long" >&5 +$as_echo "$as_me: WARNING: cannot check quad_t if cross compiling -- defaulting to long" >&2;} + bash_cv_type_rlimit=long +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include +#include +main() +{ +#ifdef HAVE_QUAD_T + struct rlimit rl; + if (sizeof(rl.rlim_cur) == sizeof(quad_t)) + exit(0); +#endif + exit(1); +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + bash_cv_type_rlimit=quad_t +else + bash_cv_type_rlimit=long +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bash_cv_type_rlimit" >&5 +$as_echo "$bash_cv_type_rlimit" >&6; } +if test $bash_cv_type_rlimit = quad_t; then +$as_echo "#define RLIMTYPE quad_t" >>confdefs.h + +elif test $bash_cv_type_rlimit = rlim_t; then +$as_echo "#define RLIMTYPE rlim_t" >>confdefs.h + +fi + + +# The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of intmax_t" >&5 +$as_echo_n "checking size of intmax_t... " >&6; } +if ${ac_cv_sizeof_intmax_t+:} false; then : + $as_echo_n "(cached) " >&6 +else + if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (intmax_t))" "ac_cv_sizeof_intmax_t" "$ac_includes_default"; then : + +else + if test "$ac_cv_type_intmax_t" = yes; then + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error 77 "cannot compute sizeof (intmax_t) +See \`config.log' for more details" "$LINENO" 5; } + else + ac_cv_sizeof_intmax_t=0 + fi +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_intmax_t" >&5 +$as_echo "$ac_cv_sizeof_intmax_t" >&6; } + + + +cat >>confdefs.h <<_ACEOF +#define SIZEOF_INTMAX_T $ac_cv_sizeof_intmax_t +_ACEOF + + + + +ac_fn_c_check_member "$LINENO" "struct termios" "c_line" "ac_cv_member_struct_termios_c_line" " +#include +#include + +" +if test "x$ac_cv_member_struct_termios_c_line" = xyes; then : + $as_echo "#define TERMIOS_LDISC 1" >>confdefs.h + +fi + + + +ac_fn_c_check_member "$LINENO" "struct termio" "c_line" "ac_cv_member_struct_termio_c_line" " +#include +#include + +" +if test "x$ac_cv_member_struct_termio_c_line" = xyes; then : + $as_echo "#define TERMIO_LDISC 1" >>confdefs.h + +fi + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for struct dirent.d_ino" >&5 +$as_echo_n "checking for struct dirent.d_ino... " >&6; } +if ${bash_cv_dirent_has_dino+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include +#ifdef HAVE_UNISTD_H +# include +#endif /* HAVE_UNISTD_H */ +#if defined(HAVE_DIRENT_H) +# include +#else +# define dirent direct +# ifdef HAVE_SYS_NDIR_H +# include +# endif /* SYSNDIR */ +# ifdef HAVE_SYS_DIR_H +# include +# endif /* SYSDIR */ +# ifdef HAVE_NDIR_H +# include +# endif +#endif /* HAVE_DIRENT_H */ + +int +main () +{ + +struct dirent d; int z; z = d.d_ino; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + bash_cv_dirent_has_dino=yes +else + bash_cv_dirent_has_dino=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bash_cv_dirent_has_dino" >&5 +$as_echo "$bash_cv_dirent_has_dino" >&6; } +if test $bash_cv_dirent_has_dino = yes; then +$as_echo "#define HAVE_STRUCT_DIRENT_D_INO 1" >>confdefs.h + +fi + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for struct dirent.d_fileno" >&5 +$as_echo_n "checking for struct dirent.d_fileno... " >&6; } +if ${bash_cv_dirent_has_d_fileno+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include +#ifdef HAVE_UNISTD_H +# include +#endif /* HAVE_UNISTD_H */ +#if defined(HAVE_DIRENT_H) +# include +#else +# define dirent direct +# ifdef HAVE_SYS_NDIR_H +# include +# endif /* SYSNDIR */ +# ifdef HAVE_SYS_DIR_H +# include +# endif /* SYSDIR */ +# ifdef HAVE_NDIR_H +# include +# endif +#endif /* HAVE_DIRENT_H */ + +int +main () +{ + +struct dirent d; int z; z = d.d_fileno; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + bash_cv_dirent_has_d_fileno=yes +else + bash_cv_dirent_has_d_fileno=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bash_cv_dirent_has_d_fileno" >&5 +$as_echo "$bash_cv_dirent_has_d_fileno" >&6; } +if test $bash_cv_dirent_has_d_fileno = yes; then +$as_echo "#define HAVE_STRUCT_DIRENT_D_FILENO 1" >>confdefs.h + +fi + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for struct dirent.d_namlen" >&5 +$as_echo_n "checking for struct dirent.d_namlen... " >&6; } +if ${bash_cv_dirent_has_d_namlen+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include +#ifdef HAVE_UNISTD_H +# include +#endif /* HAVE_UNISTD_H */ +#if defined(HAVE_DIRENT_H) +# include +#else +# define dirent direct +# ifdef HAVE_SYS_NDIR_H +# include +# endif /* SYSNDIR */ +# ifdef HAVE_SYS_DIR_H +# include +# endif /* SYSDIR */ +# ifdef HAVE_NDIR_H +# include +# endif +#endif /* HAVE_DIRENT_H */ + +int +main () +{ + +struct dirent d; int z; z = d.d_namlen; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + bash_cv_dirent_has_d_namlen=yes +else + bash_cv_dirent_has_d_namlen=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bash_cv_dirent_has_d_namlen" >&5 +$as_echo "$bash_cv_dirent_has_d_namlen" >&6; } +if test $bash_cv_dirent_has_d_namlen = yes; then +$as_echo "#define HAVE_STRUCT_DIRENT_D_NAMLEN 1" >>confdefs.h + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for struct winsize in sys/ioctl.h and termios.h" >&5 +$as_echo_n "checking for struct winsize in sys/ioctl.h and termios.h... " >&6; } +if ${bash_cv_struct_winsize_header+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +int +main () +{ +struct winsize x; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + bash_cv_struct_winsize_header=ioctl_h +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +int +main () +{ +struct winsize x; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + bash_cv_struct_winsize_header=termios_h +else + bash_cv_struct_winsize_header=other +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + +if test $bash_cv_struct_winsize_header = ioctl_h; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: sys/ioctl.h" >&5 +$as_echo "sys/ioctl.h" >&6; } + $as_echo "#define STRUCT_WINSIZE_IN_SYS_IOCTL 1" >>confdefs.h + +elif test $bash_cv_struct_winsize_header = termios_h; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: termios.h" >&5 +$as_echo "termios.h" >&6; } + $as_echo "#define STRUCT_WINSIZE_IN_TERMIOS 1" >>confdefs.h + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 +$as_echo "not found" >&6; } +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for struct timeval in sys/time.h and time.h" >&5 +$as_echo_n "checking for struct timeval in sys/time.h and time.h... " >&6; } +if ${bash_cv_struct_timeval+:} false; then : + $as_echo_n "(cached) " >&6 +else + +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "struct timeval" >/dev/null 2>&1; then : + bash_cv_struct_timeval=yes +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "struct timeval" >/dev/null 2>&1; then : + bash_cv_struct_timeval=yes +else + bash_cv_struct_timeval=no +fi +rm -f conftest* + +fi +rm -f conftest* + + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bash_cv_struct_timeval" >&5 +$as_echo "$bash_cv_struct_timeval" >&6; } +if test $bash_cv_struct_timeval = yes; then + $as_echo "#define HAVE_TIMEVAL 1" >>confdefs.h + +fi + +ac_fn_c_check_member "$LINENO" "struct stat" "st_blocks" "ac_cv_member_struct_stat_st_blocks" "$ac_includes_default" +if test "x$ac_cv_member_struct_stat_st_blocks" = xyes; then : + +cat >>confdefs.h <<_ACEOF +#define HAVE_STRUCT_STAT_ST_BLOCKS 1 +_ACEOF + + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether struct tm is in sys/time.h or time.h" >&5 +$as_echo_n "checking whether struct tm is in sys/time.h or time.h... " >&6; } +if ${ac_cv_struct_tm+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include + +int +main () +{ +struct tm tm; + int *p = &tm.tm_sec; + return !p; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_struct_tm=time.h +else + ac_cv_struct_tm=sys/time.h +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_struct_tm" >&5 +$as_echo "$ac_cv_struct_tm" >&6; } +if test $ac_cv_struct_tm = sys/time.h; then + +$as_echo "#define TM_IN_SYS_TIME 1" >>confdefs.h + +fi + +ac_fn_c_check_member "$LINENO" "struct tm" "tm_zone" "ac_cv_member_struct_tm_tm_zone" "#include +#include <$ac_cv_struct_tm> + +" +if test "x$ac_cv_member_struct_tm_tm_zone" = xyes; then : + +cat >>confdefs.h <<_ACEOF +#define HAVE_STRUCT_TM_TM_ZONE 1 +_ACEOF + + +fi + +if test "$ac_cv_member_struct_tm_tm_zone" = yes; then + +$as_echo "#define HAVE_TM_ZONE 1" >>confdefs.h + +else + ac_fn_c_check_decl "$LINENO" "tzname" "ac_cv_have_decl_tzname" "#include +" +if test "x$ac_cv_have_decl_tzname" = xyes; then : + ac_have_decl=1 +else + ac_have_decl=0 +fi + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_TZNAME $ac_have_decl +_ACEOF + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for tzname" >&5 +$as_echo_n "checking for tzname... " >&6; } +if ${ac_cv_var_tzname+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#if !HAVE_DECL_TZNAME +extern char *tzname[]; +#endif + +int +main () +{ +return tzname[0][0]; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_var_tzname=yes +else + ac_cv_var_tzname=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_var_tzname" >&5 +$as_echo "$ac_cv_var_tzname" >&6; } + if test $ac_cv_var_tzname = yes; then + +$as_echo "#define HAVE_TZNAME 1" >>confdefs.h + + fi +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for struct timezone in sys/time.h and time.h" >&5 +$as_echo_n "checking for struct timezone in sys/time.h and time.h... " >&6; } +if ${bash_cv_struct_timezone+:} false; then : + $as_echo_n "(cached) " >&6 +else + +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "struct timezone" >/dev/null 2>&1; then : + bash_cv_struct_timezone=yes +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "struct timezone" >/dev/null 2>&1; then : + bash_cv_struct_timezone=yes +else + bash_cv_struct_timezone=no +fi +rm -f conftest* + +fi +rm -f conftest* + + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bash_cv_struct_timezone" >&5 +$as_echo "$bash_cv_struct_timezone" >&6; } +if test $bash_cv_struct_timezone = yes; then + $as_echo "#define HAVE_STRUCT_TIMEZONE 1" >>confdefs.h + +fi + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for offset of exit status in return status from wait" >&5 +$as_echo_n "checking for offset of exit status in return status from wait... " >&6; } +if ${bash_cv_wexitstatus_offset+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cannot check WEXITSTATUS offset if cross compiling -- defaulting to 0" >&5 +$as_echo "$as_me: WARNING: cannot check WEXITSTATUS offset if cross compiling -- defaulting to 0" >&2;} + bash_cv_wexitstatus_offset=0 + +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include + +#include + +main(c, v) + int c; + char **v; +{ + pid_t pid, p; + int s, i, n; + + s = 0; + pid = fork(); + if (pid == 0) + exit (42); + + /* wait for the process */ + p = wait(&s); + if (p != pid) + exit (255); + + /* crack s */ + for (i = 0; i < (sizeof(s) - 8); i++) + { + n = (s >> i) & 0xff; + if (n == 42) + exit (i); + } + + exit (254); +} + +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + bash_cv_wexitstatus_offset=0 +else + bash_cv_wexitstatus_offset=$? +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi + +if test "$bash_cv_wexitstatus_offset" -gt 32 ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: bad exit status from test program -- defaulting to 0" >&5 +$as_echo "$as_me: WARNING: bad exit status from test program -- defaulting to 0" >&2;} + bash_cv_wexitstatus_offset=0 +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bash_cv_wexitstatus_offset" >&5 +$as_echo "$bash_cv_wexitstatus_offset" >&6; } + +cat >>confdefs.h <<_ACEOF +#define WEXITSTATUS_OFFSET $bash_cv_wexitstatus_offset +_ACEOF + + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for struct timespec in " >&5 +$as_echo_n "checking for struct timespec in ... " >&6; } +if ${bash_cv_sys_struct_timespec_in_time_h+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +int +main () +{ +static struct timespec x; x.tv_sec = x.tv_nsec; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + bash_cv_sys_struct_timespec_in_time_h=yes +else + bash_cv_sys_struct_timespec_in_time_h=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bash_cv_sys_struct_timespec_in_time_h" >&5 +$as_echo "$bash_cv_sys_struct_timespec_in_time_h" >&6; } + + HAVE_STRUCT_TIMESPEC=0 + TIME_H_DEFINES_STRUCT_TIMESPEC=0 + SYS_TIME_H_DEFINES_STRUCT_TIMESPEC=0 + PTHREAD_H_DEFINES_STRUCT_TIMESPEC=0 + if test $bash_cv_sys_struct_timespec_in_time_h = yes; then + $as_echo "#define HAVE_STRUCT_TIMESPEC 1" >>confdefs.h + + $as_echo "#define TIME_H_DEFINES_STRUCT_TIMESPEC 1" >>confdefs.h + + TIME_H_DEFINES_STRUCT_TIMESPEC=1 + else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for struct timespec in " >&5 +$as_echo_n "checking for struct timespec in ... " >&6; } +if ${bash_cv_sys_struct_timespec_in_sys_time_h+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +int +main () +{ +static struct timespec x; x.tv_sec = x.tv_nsec; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + bash_cv_sys_struct_timespec_in_sys_time_h=yes +else + bash_cv_sys_struct_timespec_in_sys_time_h=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bash_cv_sys_struct_timespec_in_sys_time_h" >&5 +$as_echo "$bash_cv_sys_struct_timespec_in_sys_time_h" >&6; } + if test $bash_cv_sys_struct_timespec_in_sys_time_h = yes; then + SYS_TIME_H_DEFINES_STRUCT_TIMESPEC=1 + $as_echo "#define HAVE_STRUCT_TIMESPEC 1" >>confdefs.h + + $as_echo "#define SYS_TIME_H_DEFINES_STRUCT_TIMESPEC 1" >>confdefs.h + + else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for struct timespec in " >&5 +$as_echo_n "checking for struct timespec in ... " >&6; } +if ${bash_cv_sys_struct_timespec_in_pthread_h+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +int +main () +{ +static struct timespec x; x.tv_sec = x.tv_nsec; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + bash_cv_sys_struct_timespec_in_pthread_h=yes +else + bash_cv_sys_struct_timespec_in_pthread_h=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bash_cv_sys_struct_timespec_in_pthread_h" >&5 +$as_echo "$bash_cv_sys_struct_timespec_in_pthread_h" >&6; } + if test $bash_cv_sys_struct_timespec_in_pthread_h = yes; then + PTHREAD_H_DEFINES_STRUCT_TIMESPEC=1 + $as_echo "#define HAVE_STRUCT_TIMESPEC 1" >>confdefs.h + + $as_echo "#define PTHREAD_H_DEFINES_STRUCT_TIMESPEC 1" >>confdefs.h + + fi + fi + fi + + + + + + + + + + ac_fn_c_check_member "$LINENO" "struct stat" "st_atim.tv_nsec" "ac_cv_member_struct_stat_st_atim_tv_nsec" "#include + #include +" +if test "x$ac_cv_member_struct_stat_st_atim_tv_nsec" = xyes; then : + +cat >>confdefs.h <<_ACEOF +#define HAVE_STRUCT_STAT_ST_ATIM_TV_NSEC 1 +_ACEOF + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether struct stat.st_atim is of type struct timespec" >&5 +$as_echo_n "checking whether struct stat.st_atim is of type struct timespec... " >&6; } +if ${ac_cv_typeof_struct_stat_st_atim_is_struct_timespec+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + #include + #include + #if HAVE_SYS_TIME_H + # include + #endif + #include + struct timespec ts; + struct stat st; + +int +main () +{ + + st.st_atim = ts; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_typeof_struct_stat_st_atim_is_struct_timespec=yes +else + ac_cv_typeof_struct_stat_st_atim_is_struct_timespec=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_typeof_struct_stat_st_atim_is_struct_timespec" >&5 +$as_echo "$ac_cv_typeof_struct_stat_st_atim_is_struct_timespec" >&6; } + if test $ac_cv_typeof_struct_stat_st_atim_is_struct_timespec = yes; then + +$as_echo "#define TYPEOF_STRUCT_STAT_ST_ATIM_IS_STRUCT_TIMESPEC 1" >>confdefs.h + + fi +else + ac_fn_c_check_member "$LINENO" "struct stat" "st_atimespec.tv_nsec" "ac_cv_member_struct_stat_st_atimespec_tv_nsec" "#include + #include +" +if test "x$ac_cv_member_struct_stat_st_atimespec_tv_nsec" = xyes; then : + +cat >>confdefs.h <<_ACEOF +#define HAVE_STRUCT_STAT_ST_ATIMESPEC_TV_NSEC 1 +_ACEOF + + +else + ac_fn_c_check_member "$LINENO" "struct stat" "st_atimensec" "ac_cv_member_struct_stat_st_atimensec" "#include + #include +" +if test "x$ac_cv_member_struct_stat_st_atimensec" = xyes; then : + +cat >>confdefs.h <<_ACEOF +#define HAVE_STRUCT_STAT_ST_ATIMENSEC 1 +_ACEOF + + +else + ac_fn_c_check_member "$LINENO" "struct stat" "st_atim.st__tim.tv_nsec" "ac_cv_member_struct_stat_st_atim_st__tim_tv_nsec" "#include + #include +" +if test "x$ac_cv_member_struct_stat_st_atim_st__tim_tv_nsec" = xyes; then : + +cat >>confdefs.h <<_ACEOF +#define HAVE_STRUCT_STAT_ST_ATIM_ST__TIM_TV_NSEC 1 +_ACEOF + + +fi + +fi + +fi + +fi + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for the existence of strsignal" >&5 +$as_echo_n "checking for the existence of strsignal... " >&6; } +if ${bash_cv_have_strsignal+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +int +main () +{ +char *s = (char *)strsignal(2); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + bash_cv_have_strsignal=yes +else + bash_cv_have_strsignal=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bash_cv_have_strsignal" >&5 +$as_echo "$bash_cv_have_strsignal" >&6; } +if test $bash_cv_have_strsignal = yes; then +$as_echo "#define HAVE_STRSIGNAL 1" >>confdefs.h + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if opendir() opens non-directories" >&5 +$as_echo_n "checking if opendir() opens non-directories... " >&6; } +if ${bash_cv_opendir_not_robust+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cannot check opendir if cross compiling -- defaulting to no" >&5 +$as_echo "$as_me: WARNING: cannot check opendir if cross compiling -- defaulting to no" >&2;} + bash_cv_opendir_not_robust=no + +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include +#include +#ifdef HAVE_UNISTD_H +# include +#endif /* HAVE_UNISTD_H */ +#if defined(HAVE_DIRENT_H) +# include +#else +# define dirent direct +# ifdef HAVE_SYS_NDIR_H +# include +# endif /* SYSNDIR */ +# ifdef HAVE_SYS_DIR_H +# include +# endif /* SYSDIR */ +# ifdef HAVE_NDIR_H +# include +# endif +#endif /* HAVE_DIRENT_H */ +main() +{ +DIR *dir; +int fd, err; +err = mkdir("bash-aclocal", 0700); +if (err < 0) { + perror("mkdir"); + exit(1); +} +unlink("bash-aclocal/not_a_directory"); +fd = open("bash-aclocal/not_a_directory", O_WRONLY|O_CREAT|O_EXCL, 0666); +write(fd, "\n", 1); +close(fd); +dir = opendir("bash-aclocal/not_a_directory"); +unlink("bash-aclocal/not_a_directory"); +rmdir("bash-aclocal"); +exit (dir == 0); +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + bash_cv_opendir_not_robust=yes +else + bash_cv_opendir_not_robust=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bash_cv_opendir_not_robust" >&5 +$as_echo "$bash_cv_opendir_not_robust" >&6; } +if test $bash_cv_opendir_not_robust = yes; then +$as_echo "#define OPENDIR_NOT_ROBUST 1" >>confdefs.h + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ulimit can substitute for getdtablesize" >&5 +$as_echo_n "checking whether ulimit can substitute for getdtablesize... " >&6; } +if ${bash_cv_ulimit_maxfds+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cannot check ulimit if cross compiling -- defaulting to no" >&5 +$as_echo "$as_me: WARNING: cannot check ulimit if cross compiling -- defaulting to no" >&2;} + bash_cv_ulimit_maxfds=no + +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +main() +{ +long maxfds = ulimit(4, 0L); +exit (maxfds == -1L); +} + +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + bash_cv_ulimit_maxfds=yes +else + bash_cv_ulimit_maxfds=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bash_cv_ulimit_maxfds" >&5 +$as_echo "$bash_cv_ulimit_maxfds" >&6; } +if test $bash_cv_ulimit_maxfds = yes; then +$as_echo "#define ULIMIT_MAXFDS 1" >>confdefs.h + +fi + + + + + + + + + ac_fn_c_check_decl "$LINENO" "fpurge" "ac_cv_have_decl_fpurge" "#include +" +if test "x$ac_cv_have_decl_fpurge" = xyes; then : + ac_have_decl=1 +else + ac_have_decl=0 +fi + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_FPURGE $ac_have_decl +_ACEOF + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking to see if getenv can be redefined" >&5 +$as_echo_n "checking to see if getenv can be redefined... " >&6; } +if ${bash_cv_getenv_redef+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cannot check getenv redefinition if cross compiling -- defaulting to yes" >&5 +$as_echo "$as_me: WARNING: cannot check getenv redefinition if cross compiling -- defaulting to yes" >&2;} + bash_cv_getenv_redef=yes + +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#ifdef HAVE_UNISTD_H +# include +#endif +#ifndef __STDC__ +# ifndef const +# define const +# endif +#endif +char * +getenv (name) +#if defined (__linux__) || defined (__bsdi__) || defined (convex) + const char *name; +#else + char const *name; +#endif /* !__linux__ && !__bsdi__ && !convex */ +{ +return "42"; +} +main() +{ +char *s; +/* The next allows this program to run, but does not allow bash to link + when it redefines getenv. I'm not really interested in figuring out + why not. */ +#if defined (NeXT) +exit(1); +#endif +s = getenv("ABCDE"); +exit(s == 0); /* force optimizer to leave getenv in */ +} + +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + bash_cv_getenv_redef=yes +else + bash_cv_getenv_redef=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bash_cv_getenv_redef" >&5 +$as_echo "$bash_cv_getenv_redef" >&6; } +if test $bash_cv_getenv_redef = yes; then +$as_echo "#define CAN_REDEFINE_GETENV 1" >>confdefs.h + +fi + +if test "$ac_cv_func_getcwd" = "yes"; then +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if getcwd() will dynamically allocate memory with 0 size" >&5 +$as_echo_n "checking if getcwd() will dynamically allocate memory with 0 size... " >&6; } +if ${bash_cv_getcwd_malloc+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cannot check whether getcwd allocates memory when cross-compiling -- defaulting to no" >&5 +$as_echo "$as_me: WARNING: cannot check whether getcwd allocates memory when cross-compiling -- defaulting to no" >&2;} + bash_cv_getcwd_malloc=no + +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#ifdef HAVE_UNISTD_H +#include +#endif + +main() +{ + char *xpwd; + xpwd = getcwd(0, 0); + exit (xpwd == 0); +} + +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + bash_cv_getcwd_malloc=yes +else + bash_cv_getcwd_malloc=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bash_cv_getcwd_malloc" >&5 +$as_echo "$bash_cv_getcwd_malloc" >&6; } +if test $bash_cv_getcwd_malloc = no; then +$as_echo "#define GETCWD_BROKEN 1" >>confdefs.h + +case " $LIBOBJS " in + *" getcwd.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS getcwd.$ac_objext" + ;; +esac + +fi + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for presence of POSIX-style sigsetjmp/siglongjmp" >&5 +$as_echo_n "checking for presence of POSIX-style sigsetjmp/siglongjmp... " >&6; } +if ${bash_cv_func_sigsetjmp+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cannot check for sigsetjmp/siglongjmp if cross-compiling -- defaulting to missing" >&5 +$as_echo "$as_me: WARNING: cannot check for sigsetjmp/siglongjmp if cross-compiling -- defaulting to missing" >&2;} + bash_cv_func_sigsetjmp=missing + +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#ifdef HAVE_UNISTD_H +#include +#endif +#include +#include +#include + +main() +{ +#if !defined (_POSIX_VERSION) || !defined (HAVE_POSIX_SIGNALS) +exit (1); +#else + +int code; +sigset_t set, oset; +sigjmp_buf xx; + +/* get the mask */ +sigemptyset(&set); +sigemptyset(&oset); +sigprocmask(SIG_BLOCK, (sigset_t *)NULL, &set); +sigprocmask(SIG_BLOCK, (sigset_t *)NULL, &oset); + +/* save it */ +code = sigsetjmp(xx, 1); +if (code) + exit(0); /* could get sigmask and compare to oset here. */ + +/* change it */ +sigaddset(&set, SIGINT); +sigprocmask(SIG_BLOCK, &set, (sigset_t *)NULL); + +/* and siglongjmp */ +siglongjmp(xx, 10); +exit(1); +#endif +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + bash_cv_func_sigsetjmp=present +else + bash_cv_func_sigsetjmp=missing +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bash_cv_func_sigsetjmp" >&5 +$as_echo "$bash_cv_func_sigsetjmp" >&6; } +if test $bash_cv_func_sigsetjmp = present; then +$as_echo "#define HAVE_POSIX_SIGSETJMP 1" >>confdefs.h + +fi + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether or not strcoll and strcmp differ" >&5 +$as_echo_n "checking whether or not strcoll and strcmp differ... " >&6; } +if ${bash_cv_func_strcoll_broken+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cannot check strcoll if cross compiling -- defaulting to no" >&5 +$as_echo "$as_me: WARNING: cannot check strcoll if cross compiling -- defaulting to no" >&2;} + bash_cv_func_strcoll_broken=no + +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#if defined (HAVE_LOCALE_H) +#include +#endif + +main(c, v) +int c; +char *v[]; +{ + int r1, r2; + char *deflocale, *defcoll; + +#ifdef HAVE_SETLOCALE + deflocale = setlocale(LC_ALL, ""); + defcoll = setlocale(LC_COLLATE, ""); +#endif + +#ifdef HAVE_STRCOLL + /* These two values are taken from tests/glob-test. */ + r1 = strcoll("abd", "aXd"); +#else + r1 = 0; +#endif + r2 = strcmp("abd", "aXd"); + + /* These two should both be greater than 0. It is permissible for + a system to return different values, as long as the sign is the + same. */ + + /* Exit with 1 (failure) if these two values are both > 0, since + this tests whether strcoll(3) is broken with respect to strcmp(3) + in the default locale. */ + exit (r1 > 0 && r2 > 0); +} + +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + bash_cv_func_strcoll_broken=yes +else + bash_cv_func_strcoll_broken=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bash_cv_func_strcoll_broken" >&5 +$as_echo "$bash_cv_func_strcoll_broken" >&6; } +if test $bash_cv_func_strcoll_broken = yes; then +$as_echo "#define STRCOLL_BROKEN 1" >>confdefs.h + +fi + + + + + + if test X$ac_cv_func_snprintf = Xyes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for standard-conformant snprintf" >&5 +$as_echo_n "checking for standard-conformant snprintf... " >&6; } +if ${bash_cv_func_snprintf+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cannot check standard snprintf if cross-compiling" >&5 +$as_echo "$as_me: WARNING: cannot check standard snprintf if cross-compiling" >&2;} + bash_cv_func_snprintf=yes + +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include + +main() +{ + int n; + n = snprintf (0, 0, "%s", "0123456"); + exit(n != 7); +} + +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + bash_cv_func_snprintf=yes +else + bash_cv_func_snprintf=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bash_cv_func_snprintf" >&5 +$as_echo "$bash_cv_func_snprintf" >&6; } + if test $bash_cv_func_snprintf = no; then + ac_cv_func_snprintf=no + fi + fi + if test $ac_cv_func_snprintf = no; then + +$as_echo "#define HAVE_SNPRINTF 0" >>confdefs.h + + fi + + + + + + if test X$ac_cv_func_vsnprintf = Xyes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for standard-conformant vsnprintf" >&5 +$as_echo_n "checking for standard-conformant vsnprintf... " >&6; } +if ${bash_cv_func_vsnprintf+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cannot check standard vsnprintf if cross-compiling" >&5 +$as_echo "$as_me: WARNING: cannot check standard vsnprintf if cross-compiling" >&2;} + bash_cv_func_vsnprintf=yes + +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#if HAVE_STDARG_H +#include +#else +#include +#endif +#include +#include + +static int +#if HAVE_STDARG_H +foo(const char *fmt, ...) +#else +foo(format, va_alist) + const char *format; + va_dcl +#endif +{ + va_list args; + int n; + +#if HAVE_STDARG_H + va_start(args, fmt); +#else + va_start(args); +#endif + n = vsnprintf(0, 0, fmt, args); + va_end (args); + return n; +} + +main() +{ + int n; + n = foo("%s", "0123456"); + exit(n != 7); +} + +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + bash_cv_func_vsnprintf=yes +else + bash_cv_func_vsnprintf=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bash_cv_func_vsnprintf" >&5 +$as_echo "$bash_cv_func_vsnprintf" >&6; } + if test $bash_cv_func_vsnprintf = no; then + ac_cv_func_vsnprintf=no + fi + fi + if test $ac_cv_func_vsnprintf = no; then + +$as_echo "#define HAVE_VSNPRINTF 0" >>confdefs.h + + fi + + + +if test "$ac_cv_func_putenv" = "yes"; then + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for standard-conformant putenv declaration" >&5 +$as_echo_n "checking for standard-conformant putenv declaration... " >&6; } +if ${bash_cv_std_putenv+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#if STDC_HEADERS +#include +#include +#endif +#ifndef __STDC__ +# ifndef const +# define const +# endif +#endif +#ifdef PROTOTYPES +extern int putenv (char *); +#else +extern int putenv (); +#endif + +int +main () +{ +return (putenv == 0); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + bash_cv_std_putenv=yes +else + bash_cv_std_putenv=no + +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bash_cv_std_putenv" >&5 +$as_echo "$bash_cv_std_putenv" >&6; } +if test $bash_cv_std_putenv = yes; then +$as_echo "#define HAVE_STD_PUTENV 1" >>confdefs.h + +fi + +else +$as_echo "#define HAVE_STD_PUTENV 1" >>confdefs.h + +fi +if test "$ac_cv_func_unsetenv" = "yes"; then + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for standard-conformant unsetenv declaration" >&5 +$as_echo_n "checking for standard-conformant unsetenv declaration... " >&6; } +if ${bash_cv_std_unsetenv+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#if STDC_HEADERS +#include +#include +#endif +#ifndef __STDC__ +# ifndef const +# define const +# endif +#endif +#ifdef PROTOTYPES +extern int unsetenv (const char *); +#else +extern int unsetenv (); +#endif + +int +main () +{ +return (unsetenv == 0); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + bash_cv_std_unsetenv=yes +else + bash_cv_std_unsetenv=no + +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bash_cv_std_unsetenv" >&5 +$as_echo "$bash_cv_std_unsetenv" >&6; } +if test $bash_cv_std_unsetenv = yes; then +$as_echo "#define HAVE_STD_UNSETENV 1" >>confdefs.h + +fi + +else +$as_echo "#define HAVE_STD_UNSETENV 1" >>confdefs.h + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for printf floating point output in hex notation" >&5 +$as_echo_n "checking for printf floating point output in hex notation... " >&6; } +if ${bash_cv_printf_a_format+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cannot check printf if cross compiling -- defaulting to no" >&5 +$as_echo "$as_me: WARNING: cannot check printf if cross compiling -- defaulting to no" >&2;} + bash_cv_printf_a_format=no + +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include + +int +main() +{ + double y = 0.0; + char abuf[1024]; + + sprintf(abuf, "%A", y); + exit(strchr(abuf, 'P') == (char *)0); +} + +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + bash_cv_printf_a_format=yes +else + bash_cv_printf_a_format=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bash_cv_printf_a_format" >&5 +$as_echo "$bash_cv_printf_a_format" >&6; } +if test $bash_cv_printf_a_format = yes; then +$as_echo "#define HAVE_PRINTF_A_FORMAT 1" >>confdefs.h + +fi + + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if signal handlers must be reinstalled when invoked" >&5 +$as_echo_n "checking if signal handlers must be reinstalled when invoked... " >&6; } +if ${bash_cv_must_reinstall_sighandlers+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cannot check signal handling if cross compiling -- defaulting to no" >&5 +$as_echo "$as_me: WARNING: cannot check signal handling if cross compiling -- defaulting to no" >&2;} + bash_cv_must_reinstall_sighandlers=no + +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#ifdef HAVE_UNISTD_H +#include +#endif + +typedef RETSIGTYPE sigfunc(); + +int nsigint; + +#ifdef HAVE_POSIX_SIGNALS +sigfunc * +set_signal_handler(sig, handler) + int sig; + sigfunc *handler; +{ + struct sigaction act, oact; + act.sa_handler = handler; + act.sa_flags = 0; + sigemptyset (&act.sa_mask); + sigemptyset (&oact.sa_mask); + sigaction (sig, &act, &oact); + return (oact.sa_handler); +} +#else +#define set_signal_handler(s, h) signal(s, h) +#endif + +RETSIGTYPE +sigint(s) +int s; +{ + nsigint++; +} + +main() +{ + nsigint = 0; + set_signal_handler(SIGINT, sigint); + kill((int)getpid(), SIGINT); + kill((int)getpid(), SIGINT); + exit(nsigint != 2); +} + +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + bash_cv_must_reinstall_sighandlers=no +else + bash_cv_must_reinstall_sighandlers=yes +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bash_cv_must_reinstall_sighandlers" >&5 +$as_echo "$bash_cv_must_reinstall_sighandlers" >&6; } +if test $bash_cv_must_reinstall_sighandlers = yes; then +$as_echo "#define MUST_REINSTALL_SIGHANDLERS 1" >>confdefs.h + +fi + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for presence of necessary job control definitions" >&5 +$as_echo_n "checking for presence of necessary job control definitions... " >&6; } +if ${bash_cv_job_control_missing+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cannot check job control if cross-compiling -- defaulting to missing" >&5 +$as_echo "$as_me: WARNING: cannot check job control if cross-compiling -- defaulting to missing" >&2;} + bash_cv_job_control_missing=missing + +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#ifdef HAVE_SYS_WAIT_H +#include +#endif +#ifdef HAVE_UNISTD_H +#include +#endif +#include + +/* Add more tests in here as appropriate. */ +main() +{ +/* signal type */ +#if !defined (HAVE_POSIX_SIGNALS) && !defined (HAVE_BSD_SIGNALS) +exit(1); +#endif + +/* signals and tty control. */ +#if !defined (SIGTSTP) || !defined (SIGSTOP) || !defined (SIGCONT) +exit (1); +#endif + +/* process control */ +#if !defined (WNOHANG) || !defined (WUNTRACED) +exit(1); +#endif + +/* Posix systems have tcgetpgrp and waitpid. */ +#if defined (_POSIX_VERSION) && !defined (HAVE_TCGETPGRP) +exit(1); +#endif + +#if defined (_POSIX_VERSION) && !defined (HAVE_WAITPID) +exit(1); +#endif + +/* Other systems have TIOCSPGRP/TIOCGPRGP and wait3. */ +#if !defined (_POSIX_VERSION) && !defined (HAVE_WAIT3) +exit(1); +#endif + +exit(0); +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + bash_cv_job_control_missing=present +else + bash_cv_job_control_missing=missing +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bash_cv_job_control_missing" >&5 +$as_echo "$bash_cv_job_control_missing" >&6; } +if test $bash_cv_job_control_missing = missing; then +$as_echo "#define JOB_CONTROL_MISSING 1" >>confdefs.h + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for presence of named pipes" >&5 +$as_echo_n "checking for presence of named pipes... " >&6; } +if ${bash_cv_sys_named_pipes+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cannot check for named pipes if cross-compiling -- defaulting to missing" >&5 +$as_echo "$as_me: WARNING: cannot check for named pipes if cross-compiling -- defaulting to missing" >&2;} + bash_cv_sys_named_pipes=missing + +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include +#ifdef HAVE_UNISTD_H +#include +#endif + +/* Add more tests in here as appropriate. */ +main() +{ +int fd, err; + +#if defined (HAVE_MKFIFO) +exit (0); +#endif + +#if !defined (S_IFIFO) && (defined (_POSIX_VERSION) && !defined (S_ISFIFO)) +exit (1); +#endif + +#if defined (NeXT) +exit (1); +#endif +err = mkdir("bash-aclocal", 0700); +if (err < 0) { + perror ("mkdir"); + exit(1); +} +fd = mknod ("bash-aclocal/sh-np-autoconf", 0666 | S_IFIFO, 0); +if (fd == -1) { + rmdir ("bash-aclocal"); + exit (1); +} +close(fd); +unlink ("bash-aclocal/sh-np-autoconf"); +rmdir ("bash-aclocal"); +exit(0); +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + bash_cv_sys_named_pipes=present +else + bash_cv_sys_named_pipes=missing +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bash_cv_sys_named_pipes" >&5 +$as_echo "$bash_cv_sys_named_pipes" >&6; } +if test $bash_cv_sys_named_pipes = missing; then +$as_echo "#define NAMED_PIPES_MISSING 1" >>confdefs.h + +fi + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether termios.h defines TIOCGWINSZ" >&5 +$as_echo_n "checking whether termios.h defines TIOCGWINSZ... " >&6; } +if ${ac_cv_sys_tiocgwinsz_in_termios_h+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#ifdef TIOCGWINSZ + yes +#endif + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "yes" >/dev/null 2>&1; then : + ac_cv_sys_tiocgwinsz_in_termios_h=yes +else + ac_cv_sys_tiocgwinsz_in_termios_h=no +fi +rm -f conftest* + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_tiocgwinsz_in_termios_h" >&5 +$as_echo "$ac_cv_sys_tiocgwinsz_in_termios_h" >&6; } + +if test $ac_cv_sys_tiocgwinsz_in_termios_h != yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether sys/ioctl.h defines TIOCGWINSZ" >&5 +$as_echo_n "checking whether sys/ioctl.h defines TIOCGWINSZ... " >&6; } +if ${ac_cv_sys_tiocgwinsz_in_sys_ioctl_h+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#ifdef TIOCGWINSZ + yes +#endif + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "yes" >/dev/null 2>&1; then : + ac_cv_sys_tiocgwinsz_in_sys_ioctl_h=yes +else + ac_cv_sys_tiocgwinsz_in_sys_ioctl_h=no +fi +rm -f conftest* + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_tiocgwinsz_in_sys_ioctl_h" >&5 +$as_echo "$ac_cv_sys_tiocgwinsz_in_sys_ioctl_h" >&6; } + + if test $ac_cv_sys_tiocgwinsz_in_sys_ioctl_h = yes; then + +$as_echo "#define GWINSZ_IN_SYS_IOCTL 1" >>confdefs.h + + fi +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for TIOCSTAT in sys/ioctl.h" >&5 +$as_echo_n "checking for TIOCSTAT in sys/ioctl.h... " >&6; } +if ${bash_cv_tiocstat_in_ioctl+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +int +main () +{ +int x = TIOCSTAT; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + bash_cv_tiocstat_in_ioctl=yes +else + bash_cv_tiocstat_in_ioctl=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bash_cv_tiocstat_in_ioctl" >&5 +$as_echo "$bash_cv_tiocstat_in_ioctl" >&6; } +if test $bash_cv_tiocstat_in_ioctl = yes; then +$as_echo "#define TIOCSTAT_IN_SYS_IOCTL 1" >>confdefs.h + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for FIONREAD in sys/ioctl.h" >&5 +$as_echo_n "checking for FIONREAD in sys/ioctl.h... " >&6; } +if ${bash_cv_fionread_in_ioctl+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +int +main () +{ +int x = FIONREAD; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + bash_cv_fionread_in_ioctl=yes +else + bash_cv_fionread_in_ioctl=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bash_cv_fionread_in_ioctl" >&5 +$as_echo "$bash_cv_fionread_in_ioctl" >&6; } +if test $bash_cv_fionread_in_ioctl = yes; then +$as_echo "#define FIONREAD_IN_SYS_IOCTL 1" >>confdefs.h + +fi + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether WCONTINUED flag to waitpid is unavailable or available but broken" >&5 +$as_echo_n "checking whether WCONTINUED flag to waitpid is unavailable or available but broken... " >&6; } +if ${bash_cv_wcontinued_broken+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cannot check WCONTINUED if cross compiling -- defaulting to no" >&5 +$as_echo "$as_me: WARNING: cannot check WCONTINUED if cross compiling -- defaulting to no" >&2;} + bash_cv_wcontinued_broken=no + +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include +#include +#include + +#ifndef errno +extern int errno; +#endif +main() +{ + int x; + + x = waitpid(-1, (int *)0, WNOHANG|WCONTINUED); + if (x == -1 && errno == EINVAL) + exit (1); + else + exit (0); +} + +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + bash_cv_wcontinued_broken=no +else + bash_cv_wcontinued_broken=yes +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bash_cv_wcontinued_broken" >&5 +$as_echo "$bash_cv_wcontinued_broken" >&6; } +if test $bash_cv_wcontinued_broken = yes; then +$as_echo "#define WCONTINUED_BROKEN 1" >>confdefs.h + +fi + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for speed_t in sys/types.h" >&5 +$as_echo_n "checking for speed_t in sys/types.h... " >&6; } +if ${bash_cv_speed_t_in_sys_types+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ +speed_t x; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + bash_cv_speed_t_in_sys_types=yes +else + bash_cv_speed_t_in_sys_types=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bash_cv_speed_t_in_sys_types" >&5 +$as_echo "$bash_cv_speed_t_in_sys_types" >&6; } +if test $bash_cv_speed_t_in_sys_types = yes; then +$as_echo "#define SPEED_T_IN_SYS_TYPES 1" >>confdefs.h + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether getpw functions are declared in pwd.h" >&5 +$as_echo_n "checking whether getpw functions are declared in pwd.h... " >&6; } +if ${bash_cv_getpw_declared+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#ifdef HAVE_UNISTD_H +# include +#endif +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "getpwuid" >/dev/null 2>&1; then : + bash_cv_getpw_declared=yes +else + bash_cv_getpw_declared=no +fi +rm -f conftest* + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bash_cv_getpw_declared" >&5 +$as_echo "$bash_cv_getpw_declared" >&6; } +if test $bash_cv_getpw_declared = yes; then +$as_echo "#define HAVE_GETPW_DECLS 1" >>confdefs.h + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for unusable real-time signals due to large values" >&5 +$as_echo_n "checking for unusable real-time signals due to large values... " >&6; } +if ${bash_cv_unusable_rtsigs+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cannot check real-time signals if cross compiling -- defaulting to yes" >&5 +$as_echo "$as_me: WARNING: cannot check real-time signals if cross compiling -- defaulting to yes" >&2;} + bash_cv_unusable_rtsigs=yes + +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include + +#ifndef NSIG +# define NSIG 64 +#endif + +main () +{ + int n_sigs = 2 * NSIG; +#ifdef SIGRTMIN + int rtmin = SIGRTMIN; +#else + int rtmin = 0; +#endif + + exit(rtmin < n_sigs); +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + bash_cv_unusable_rtsigs=yes +else + bash_cv_unusable_rtsigs=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bash_cv_unusable_rtsigs" >&5 +$as_echo "$bash_cv_unusable_rtsigs" >&6; } +if test $bash_cv_unusable_rtsigs = yes; then +$as_echo "#define UNUSABLE_RT_SIGNALS 1" >>confdefs.h + +fi + + + + + +if test "$bash_cv_sys_siglist" = no && test "$bash_cv_under_sys_siglist" = no && test "$bash_cv_have_strsignal" = no; then + SIGLIST_O=siglist.o +else + SIGLIST_O= +fi + + + +case "$host_os" in +hpux*) { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $host_os needs _KERNEL for RLIMIT defines" >&5 +$as_echo_n "checking whether $host_os needs _KERNEL for RLIMIT defines... " >&6; } +if ${bash_cv_kernel_rlimit+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include + +int +main () +{ + + int f; + f = RLIMIT_DATA; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + bash_cv_kernel_rlimit=no +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#define _KERNEL +#include +#undef _KERNEL + +int +main () +{ + + int f; + f = RLIMIT_DATA; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + bash_cv_kernel_rlimit=yes +else + bash_cv_kernel_rlimit=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bash_cv_kernel_rlimit" >&5 +$as_echo "$bash_cv_kernel_rlimit" >&6; } +if test $bash_cv_kernel_rlimit = yes; then +$as_echo "#define RLIMIT_NEEDS_KERNEL 1" >>confdefs.h + +fi + ;; +esac + +if test "$opt_readline" = yes; then +case "$host_os" in +aix*) prefer_curses=yes ;; +esac + +if test "X$bash_cv_termcap_lib" = "X"; then +_bash_needmsg=yes +else +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking which library has the termcap functions" >&5 +$as_echo_n "checking which library has the termcap functions... " >&6; } +_bash_needmsg= +fi +if ${bash_cv_termcap_lib+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_fn_c_check_func "$LINENO" "tgetent" "ac_cv_func_tgetent" +if test "x$ac_cv_func_tgetent" = xyes; then : + bash_cv_termcap_lib=libc +else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for tgetent in -ltermcap" >&5 +$as_echo_n "checking for tgetent in -ltermcap... " >&6; } +if ${ac_cv_lib_termcap_tgetent+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ltermcap $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char tgetent (); +int +main () +{ +return tgetent (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_termcap_tgetent=yes +else + ac_cv_lib_termcap_tgetent=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_termcap_tgetent" >&5 +$as_echo "$ac_cv_lib_termcap_tgetent" >&6; } +if test "x$ac_cv_lib_termcap_tgetent" = xyes; then : + bash_cv_termcap_lib=libtermcap +else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for tgetent in -ltinfo" >&5 +$as_echo_n "checking for tgetent in -ltinfo... " >&6; } +if ${ac_cv_lib_tinfo_tgetent+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ltinfo $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char tgetent (); +int +main () +{ +return tgetent (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_tinfo_tgetent=yes +else + ac_cv_lib_tinfo_tgetent=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_tinfo_tgetent" >&5 +$as_echo "$ac_cv_lib_tinfo_tgetent" >&6; } +if test "x$ac_cv_lib_tinfo_tgetent" = xyes; then : + bash_cv_termcap_lib=libtinfo +else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for tgetent in -lcurses" >&5 +$as_echo_n "checking for tgetent in -lcurses... " >&6; } +if ${ac_cv_lib_curses_tgetent+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lcurses $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char tgetent (); +int +main () +{ +return tgetent (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_curses_tgetent=yes +else + ac_cv_lib_curses_tgetent=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_curses_tgetent" >&5 +$as_echo "$ac_cv_lib_curses_tgetent" >&6; } +if test "x$ac_cv_lib_curses_tgetent" = xyes; then : + bash_cv_termcap_lib=libcurses +else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for tgetent in -lncurses" >&5 +$as_echo_n "checking for tgetent in -lncurses... " >&6; } +if ${ac_cv_lib_ncurses_tgetent+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lncurses $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char tgetent (); +int +main () +{ +return tgetent (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_ncurses_tgetent=yes +else + ac_cv_lib_ncurses_tgetent=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ncurses_tgetent" >&5 +$as_echo "$ac_cv_lib_ncurses_tgetent" >&6; } +if test "x$ac_cv_lib_ncurses_tgetent" = xyes; then : + bash_cv_termcap_lib=libncurses +else + bash_cv_termcap_lib=gnutermcap +fi + +fi + +fi + +fi + +fi + +fi + +if test "X$_bash_needmsg" = "Xyes"; then +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking which library has the termcap functions" >&5 +$as_echo_n "checking which library has the termcap functions... " >&6; } +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: using $bash_cv_termcap_lib" >&5 +$as_echo "using $bash_cv_termcap_lib" >&6; } +if test $bash_cv_termcap_lib = gnutermcap && test -z "$prefer_curses"; then +LDFLAGS="$LDFLAGS -L./lib/termcap" +TERMCAP_LIB="./lib/termcap/libtermcap.a" +TERMCAP_DEP="./lib/termcap/libtermcap.a" +elif test $bash_cv_termcap_lib = libtermcap && test -z "$prefer_curses"; then +TERMCAP_LIB=-ltermcap +TERMCAP_DEP= +elif test $bash_cv_termcap_lib = libtinfo; then +TERMCAP_LIB=-ltinfo +TERMCAP_DEP= +elif test $bash_cv_termcap_lib = libncurses; then +TERMCAP_LIB=-lncurses +TERMCAP_DEP= +elif test $bash_cv_termcap_lib = libc; then +TERMCAP_LIB= +TERMCAP_DEP= +else +TERMCAP_LIB=-lcurses +TERMCAP_DEP= +fi + +fi + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether /dev/fd is available" >&5 +$as_echo_n "checking whether /dev/fd is available... " >&6; } +if ${bash_cv_dev_fd+:} false; then : + $as_echo_n "(cached) " >&6 +else + bash_cv_dev_fd="" +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] + if (exec test -r /dev/fd/3 3&5 +$as_echo "$bash_cv_dev_fd" >&6; } +if test $bash_cv_dev_fd = "standard"; then + $as_echo "#define HAVE_DEV_FD 1" >>confdefs.h + + $as_echo "#define DEV_FD_PREFIX \"/dev/fd/\"" >>confdefs.h + +elif test $bash_cv_dev_fd = "whacky"; then + $as_echo "#define HAVE_DEV_FD 1" >>confdefs.h + + $as_echo "#define DEV_FD_PREFIX \"/proc/self/fd/\"" >>confdefs.h + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether /dev/stdin stdout stderr are available" >&5 +$as_echo_n "checking whether /dev/stdin stdout stderr are available... " >&6; } +if ${bash_cv_dev_stdin+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -d /dev/fd && (exec test -r /dev/stdin < /dev/null) ; then + bash_cv_dev_stdin=present + 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 + fi + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bash_cv_dev_stdin" >&5 +$as_echo "$bash_cv_dev_stdin" >&6; } +if test $bash_cv_dev_stdin = "present"; then + $as_echo "#define HAVE_DEV_STDIN 1" >>confdefs.h + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for default mail directory" >&5 +$as_echo_n "checking for default mail directory... " >&6; } +if ${bash_cv_mail_dir+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -d /var/mail; then + bash_cv_mail_dir=/var/mail + elif test -d /var/spool/mail; then + bash_cv_mail_dir=/var/spool/mail + elif test -d /usr/mail; then + bash_cv_mail_dir=/usr/mail + elif test -d /usr/spool/mail; then + bash_cv_mail_dir=/usr/spool/mail + else + bash_cv_mail_dir=unknown + fi + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bash_cv_mail_dir" >&5 +$as_echo "$bash_cv_mail_dir" >&6; } +cat >>confdefs.h <<_ACEOF +#define DEFAULT_MAIL_DIRECTORY "$bash_cv_mail_dir" +_ACEOF + + + +if test "$bash_cv_job_control_missing" = missing; then + opt_job_control=no +fi + +if test "$opt_job_control" = yes; then +$as_echo "#define JOB_CONTROL 1" >>confdefs.h + +JOBS_O=jobs.o +else +JOBS_O=nojobs.o +fi + + + + +LOCAL_DEFS=-DSHELL + + +case "${host_os}" in +sysv4.2*) $as_echo "#define SVR4_2 1" >>confdefs.h + + $as_echo "#define SVR4 1" >>confdefs.h + ;; +sysv4*) $as_echo "#define SVR4 1" >>confdefs.h + ;; +sysv5*) $as_echo "#define SVR5 1" >>confdefs.h + ;; +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 -DSOLARIS" ;; +solaris2.8*) LOCAL_CFLAGS=-DSOLARIS ;; +solaris2.9*) LOCAL_CFLAGS=-DSOLARIS ;; +solaris2.10*) LOCAL_CFLAGS=-DSOLARIS ;; +solaris2*) LOCAL_CFLAGS=-DSOLARIS ;; +lynxos*) LOCAL_CFLAGS=-DRECYCLES_PIDS ;; +linux*) LOCAL_LDFLAGS=-rdynamic # allow dynamic loading + case "`uname -r`" in + 2.[456789]*|[34]*) $as_echo "#define PGRP_PIPE 1" >>confdefs.h + ;; + 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 -D_ALL_SOURCE -DRECYCLES_PIDS" ;; +*openstep*) LOCAL_CFLAGS="-D__APPLE_CC__" ;; +esac + +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 +bsdi5*-*gcc*) LOCAL_LDFLAGS="-rdynamic" ;; # allow dynamic loading, like Linux +hpux11*-gcc*) LOCAL_LDFLAGS="-Wl,-E" ;; # allow dynamic loading +esac + +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 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking shared object configuration for loadable builtins" >&5 +$as_echo_n "checking shared object configuration for loadable builtins... " >&6; } + eval `${CONFIG_SHELL-/bin/sh} ${srcdir}/support/shobj-conf -C "${CC}" -c "${host_cpu}" -o "${host_os}" -v "${host_vendor}"` + + + + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $SHOBJ_STATUS" >&5 +$as_echo "$SHOBJ_STATUS" >&6; } +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 + +if test -z "$localedir"; then + localedir='${datarootdir}/locale' +fi +if test -z "$datarootdir"; then + datarootdir='${prefix}/share' +fi + + + + + + +# Some versions of autoconf don't substitute these automatically + + + +# directory where we install dynamically loadable builtins +if test -z "$loadablesdir"; then + loadablesdir='${libdir}/bash' +fi + +if test -z "$headersdir"; then + headersdir='$(includedir)/$(PACKAGE_NAME)' +fi + + + + + + + + + + + + + + + + + + + + +#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/Makefile.inc examples/loadables/perl/Makefile support/bash.pc" + +ac_config_commands="$ac_config_commands default" + +cat >confcache <<\_ACEOF +# This file is a shell script that caches the results of configure +# tests run on this system so they can be shared between configure +# scripts and configure runs, see configure's option --config-cache. +# It is not useful on other systems. If it contains results you don't +# want to keep, you may remove or edit it. +# +# config.status only pays attention to the cache file if you give it +# the --recheck option to rerun configure. +# +# `ac_cv_env_foo' variables (set or unset) will be overridden when +# loading this file, other *unset* `ac_cv_foo' will be assigned the +# following values. + +_ACEOF + +# The following way of writing the cache mishandles newlines in values, +# but we know of no workaround that is simple, portable, and efficient. +# So, we kill variables containing newlines. +# Ultrix sh set writes to stderr and can't be redirected directly, +# and sets the high bit in the cache file unless we assign to the vars. +( + for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 +$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( + *) { eval $ac_var=; unset $ac_var;} ;; + esac ;; + esac + done + + (set) 2>&1 | + case $as_nl`(ac_space=' '; set) 2>&1` in #( + *${as_nl}ac_space=\ *) + # `set' does not quote correctly, so add quotes: double-quote + # substitution turns \\\\ into \\, and sed turns \\ into \. + sed -n \ + "s/'/'\\\\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" + ;; #( + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" + ;; + esac | + sort +) | + sed ' + /^ac_cv_env_/b end + t clear + :clear + s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ + t end + s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ + :end' >>confcache +if diff "$cache_file" confcache >/dev/null 2>&1; then :; else + if test -w "$cache_file"; then + if test "x$cache_file" != "x/dev/null"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 +$as_echo "$as_me: updating cache $cache_file" >&6;} + if test ! -f "$cache_file" || test -h "$cache_file"; then + cat confcache >"$cache_file" + else + case $cache_file in #( + */* | ?:*) + mv -f confcache "$cache_file"$$ && + mv -f "$cache_file"$$ "$cache_file" ;; #( + *) + mv -f confcache "$cache_file" ;; + esac + fi + fi + else + { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 +$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} + fi +fi +rm -f confcache + +test "x$prefix" = xNONE && prefix=$ac_default_prefix +# Let make expand exec_prefix. +test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' + +DEFS=-DHAVE_CONFIG_H + +ac_libobjs= +ac_ltlibobjs= +U= +for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue + # 1. Remove the extension, and $U if already installed. + ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' + ac_i=`$as_echo "$ac_i" | sed "$ac_script"` + # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR + # will be set to the directory where LIBOBJS objects are built. + as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" + as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' +done +LIBOBJS=$ac_libobjs + +LTLIBOBJS=$ac_ltlibobjs + + + + +: "${CONFIG_STATUS=./config.status}" +ac_write_fail=0 +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files $CONFIG_STATUS" +{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 +$as_echo "$as_me: creating $CONFIG_STATUS" >&6;} +as_write_fail=0 +cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 +#! $SHELL +# Generated by $as_me. +# Run this file to recreate the current configuration. +# Compiler output produced by configure, useful for debugging +# configure, is in config.log if it exists. + +debug=false +ac_cs_recheck=false +ac_cs_silent=false + +SHELL=\${CONFIG_SHELL-$SHELL} +export SHELL +_ASEOF +cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 +## -------------------- ## +## M4sh Initialization. ## +## -------------------- ## + +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi + + +as_nl=' +' +export as_nl +# Printing a long string crashes Solaris 7 /usr/bin/printf. +as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo +# Prefer a ksh shell builtin over an external printf program on Solaris, +# but without wasting forks for bash or zsh. +if test -z "$BASH_VERSION$ZSH_VERSION" \ + && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='print -r --' + as_echo_n='print -rn --' +elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='printf %s\n' + as_echo_n='printf %s' +else + if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then + as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' + as_echo_n='/usr/ucb/echo -n' + else + as_echo_body='eval expr "X$1" : "X\\(.*\\)"' + as_echo_n_body='eval + arg=$1; + case $arg in #( + *"$as_nl"*) + expr "X$arg" : "X\\(.*\\)$as_nl"; + arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; + esac; + expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" + ' + export as_echo_n_body + as_echo_n='sh -c $as_echo_n_body as_echo' + fi + export as_echo_body + as_echo='sh -c $as_echo_body as_echo' +fi + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { + (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || + PATH_SEPARATOR=';' + } +fi + + +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +as_myself= +case $0 in #(( + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break + done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + exit 1 +fi + +# Unset variables that we do not need and which cause bugs (e.g. in +# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" +# suppresses any "Segmentation fault" message there. '((' could +# trigger a bug in pdksh 5.2.14. +for as_var in BASH_ENV ENV MAIL MAILPATH +do eval test x\${$as_var+set} = xset \ + && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : +done +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +LC_ALL=C +export LC_ALL +LANGUAGE=C +export LANGUAGE + +# CDPATH. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + + +# as_fn_error STATUS ERROR [LINENO LOG_FD] +# ---------------------------------------- +# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are +# provided, also output the error to LOG_FD, referencing LINENO. Then exit the +# script with STATUS, using 1 if that was 0. +as_fn_error () +{ + as_status=$1; test $as_status -eq 0 && as_status=1 + if test "$4"; then + as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 + fi + $as_echo "$as_me: error: $2" >&2 + as_fn_exit $as_status +} # as_fn_error + + +# as_fn_set_status STATUS +# ----------------------- +# Set $? to STATUS, without forking. +as_fn_set_status () +{ + return $1 +} # as_fn_set_status + +# as_fn_exit STATUS +# ----------------- +# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. +as_fn_exit () +{ + set +e + as_fn_set_status $1 + exit $1 +} # as_fn_exit + +# as_fn_unset VAR +# --------------- +# Portably unset VAR. +as_fn_unset () +{ + { eval $1=; unset $1;} +} +as_unset=as_fn_unset +# as_fn_append VAR VALUE +# ---------------------- +# Append the text in VALUE to the end of the definition contained in VAR. Take +# advantage of any shell optimizations that allow amortized linear growth over +# repeated appends, instead of the typical quadratic growth present in naive +# implementations. +if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : + eval 'as_fn_append () + { + eval $1+=\$2 + }' +else + as_fn_append () + { + eval $1=\$$1\$2 + } +fi # as_fn_append + +# as_fn_arith ARG... +# ------------------ +# Perform arithmetic evaluation on the ARGs, and store the result in the +# global $as_val. Take advantage of shells that can avoid forks. The arguments +# must be portable across $(()) and expr. +if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : + eval 'as_fn_arith () + { + as_val=$(( $* )) + }' +else + as_fn_arith () + { + as_val=`expr "$@" || test $? -eq 1` + } +fi # as_fn_arith + + +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in #((((( +-n*) + case `echo 'xy\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + xy) ECHO_C='\c';; + *) echo `echo ksh88 bug on AIX 6.1` > /dev/null + ECHO_T=' ';; + esac;; +*) + ECHO_N='-n';; +esac + +rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir 2>/dev/null +fi +if (echo >conf$$.file) 2>/dev/null; then + if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -pR'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -pR' + elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln + else + as_ln_s='cp -pR' + fi +else + as_ln_s='cp -pR' +fi +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null + + +# as_fn_mkdir_p +# ------------- +# Create "$as_dir" as a directory, including parents if necessary. +as_fn_mkdir_p () +{ + + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || eval $as_mkdir_p || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" + + +} # as_fn_mkdir_p +if mkdir -p . 2>/dev/null; then + as_mkdir_p='mkdir -p "$as_dir"' +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + + +# as_fn_executable_p FILE +# ----------------------- +# Test if FILE is an executable regular file. +as_fn_executable_p () +{ + test -f "$1" && test -x "$1" +} # as_fn_executable_p +as_test_x='test -x' +as_executable_p=as_fn_executable_p + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + +exec 6>&1 +## ----------------------------------- ## +## Main body of $CONFIG_STATUS script. ## +## ----------------------------------- ## +_ASEOF +test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# Save the log message, to keep $0 and so on meaningful, and to +# report actual input values of CONFIG_FILES etc. instead of their +# values after options handling. +ac_log=" +This file was extended by bash $as_me 4.4-release, which was +generated by GNU Autoconf 2.69. Invocation command line was + + CONFIG_FILES = $CONFIG_FILES + CONFIG_HEADERS = $CONFIG_HEADERS + CONFIG_LINKS = $CONFIG_LINKS + CONFIG_COMMANDS = $CONFIG_COMMANDS + $ $0 $@ + +on `(hostname || uname -n) 2>/dev/null | sed 1q` +" + +_ACEOF + +case $ac_config_files in *" +"*) set x $ac_config_files; shift; ac_config_files=$*;; +esac + +case $ac_config_headers in *" +"*) set x $ac_config_headers; shift; ac_config_headers=$*;; +esac + + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +# Files that config.status was made for. +config_files="$ac_config_files" +config_headers="$ac_config_headers" +config_commands="$ac_config_commands" + +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +ac_cs_usage="\ +\`$as_me' instantiates files and other configuration actions +from templates according to the current configuration. Unless the files +and actions are specified as TAGs, all are instantiated by default. + +Usage: $0 [OPTION]... [TAG]... + + -h, --help print this help, then exit + -V, --version print version number and configuration settings, then exit + --config print configuration, then exit + -q, --quiet, --silent + do not print progress messages + -d, --debug don't remove temporary files + --recheck update $as_me by reconfiguring in the same conditions + --file=FILE[:TEMPLATE] + instantiate the configuration file FILE + --header=FILE[:TEMPLATE] + instantiate the configuration header FILE + +Configuration files: +$config_files + +Configuration headers: +$config_headers + +Configuration commands: +$config_commands + +Report bugs to ." + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" +ac_cs_version="\\ +bash config.status 4.4-release +configured by $0, generated by GNU Autoconf 2.69, + with options \\"\$ac_cs_config\\" + +Copyright (C) 2012 Free Software Foundation, Inc. +This config.status script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it." + +ac_pwd='$ac_pwd' +srcdir='$srcdir' +INSTALL='$INSTALL' +test -n "\$AWK" || AWK=awk +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# The default lists apply if the user does not specify any file. +ac_need_defaults=: +while test $# != 0 +do + case $1 in + --*=?*) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` + ac_shift=: + ;; + --*=) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg= + ac_shift=: + ;; + *) + ac_option=$1 + ac_optarg=$2 + ac_shift=shift + ;; + esac + + case $ac_option in + # Handling of the options. + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + ac_cs_recheck=: ;; + --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) + $as_echo "$ac_cs_version"; exit ;; + --config | --confi | --conf | --con | --co | --c ) + $as_echo "$ac_cs_config"; exit ;; + --debug | --debu | --deb | --de | --d | -d ) + debug=: ;; + --file | --fil | --fi | --f ) + $ac_shift + case $ac_optarg in + *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + '') as_fn_error $? "missing file argument" ;; + esac + as_fn_append CONFIG_FILES " '$ac_optarg'" + ac_need_defaults=false;; + --header | --heade | --head | --hea ) + $ac_shift + case $ac_optarg in + *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + as_fn_append CONFIG_HEADERS " '$ac_optarg'" + ac_need_defaults=false;; + --he | --h) + # Conflict between --help and --header + as_fn_error $? "ambiguous option: \`$1' +Try \`$0 --help' for more information.";; + --help | --hel | -h ) + $as_echo "$ac_cs_usage"; exit ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil | --si | --s) + ac_cs_silent=: ;; + + # This is an error. + -*) as_fn_error $? "unrecognized option: \`$1' +Try \`$0 --help' for more information." ;; + + *) as_fn_append ac_config_targets " $1" + ac_need_defaults=false ;; + + esac + shift +done + +ac_configure_extra_args= + +if $ac_cs_silent; then + exec 6>/dev/null + ac_configure_extra_args="$ac_configure_extra_args --silent" +fi + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +if \$ac_cs_recheck; then + set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion + shift + \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 + CONFIG_SHELL='$SHELL' + export CONFIG_SHELL + exec "\$@" +fi + +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +exec 5>>config.log +{ + echo + sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX +## Running $as_me. ## +_ASBOX + $as_echo "$ac_log" +} >&5 + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +# +# INIT-COMMANDS +# +# Capture the value of obsolete ALL_LINGUAS because we need it to compute + # POFILES, GMOFILES, UPDATEPOFILES, DUMMYPOFILES, CATALOGS. But hide it + # from automake. + eval 'OBSOLETE_ALL_LINGUAS''="$ALL_LINGUAS"' + # Capture the value of LINGUAS because we need it to compute CATALOGS. + LINGUAS="${LINGUAS-%UNSET%}" + + +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 + +# Handling of arguments. +for ac_config_target in $ac_config_targets +do + case $ac_config_target in + "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; + "default-1") CONFIG_COMMANDS="$CONFIG_COMMANDS default-1" ;; + "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; + "builtins/Makefile") CONFIG_FILES="$CONFIG_FILES builtins/Makefile" ;; + "lib/readline/Makefile") CONFIG_FILES="$CONFIG_FILES lib/readline/Makefile" ;; + "lib/glob/Makefile") CONFIG_FILES="$CONFIG_FILES lib/glob/Makefile" ;; + "lib/intl/Makefile") CONFIG_FILES="$CONFIG_FILES lib/intl/Makefile" ;; + "lib/malloc/Makefile") CONFIG_FILES="$CONFIG_FILES lib/malloc/Makefile" ;; + "lib/sh/Makefile") CONFIG_FILES="$CONFIG_FILES lib/sh/Makefile" ;; + "lib/termcap/Makefile") CONFIG_FILES="$CONFIG_FILES lib/termcap/Makefile" ;; + "lib/tilde/Makefile") CONFIG_FILES="$CONFIG_FILES lib/tilde/Makefile" ;; + "doc/Makefile") CONFIG_FILES="$CONFIG_FILES doc/Makefile" ;; + "support/Makefile") CONFIG_FILES="$CONFIG_FILES support/Makefile" ;; + "po/Makefile.in") CONFIG_FILES="$CONFIG_FILES po/Makefile.in" ;; + "examples/loadables/Makefile") CONFIG_FILES="$CONFIG_FILES examples/loadables/Makefile" ;; + "examples/loadables/Makefile.inc") CONFIG_FILES="$CONFIG_FILES examples/loadables/Makefile.inc" ;; + "examples/loadables/perl/Makefile") CONFIG_FILES="$CONFIG_FILES examples/loadables/perl/Makefile" ;; + "support/bash.pc") CONFIG_FILES="$CONFIG_FILES support/bash.pc" ;; + "default") CONFIG_COMMANDS="$CONFIG_COMMANDS default" ;; + + *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; + esac +done + + +# If the user did not use the arguments to specify the items to instantiate, +# then the envvar interface is used. Set only those that are not. +# We use the long form for the default assignment because of an extremely +# bizarre bug on SunOS 4.1.3. +if $ac_need_defaults; then + test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files + test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers + test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands +fi + +# Have a temporary directory for convenience. Make it in the build tree +# simply because there is no reason against having it here, and in addition, +# creating and moving files from /tmp can sometimes cause problems. +# Hook for its removal unless debugging. +# Note that there is a small window in which the directory will not be cleaned: +# after its creation but before its name has been assigned to `$tmp'. +$debug || +{ + tmp= ac_tmp= + trap 'exit_status=$? + : "${ac_tmp:=$tmp}" + { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status +' 0 + trap 'as_fn_exit 1' 1 2 13 15 +} +# Create a (secure) tmp directory for tmp files. + +{ + tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && + test -d "$tmp" +} || +{ + tmp=./conf$$-$RANDOM + (umask 077 && mkdir "$tmp") +} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 +ac_tmp=$tmp + +# Set up the scripts for CONFIG_FILES section. +# No need to generate them if there are no CONFIG_FILES. +# This happens for instance with `./config.status config.h'. +if test -n "$CONFIG_FILES"; then + + +ac_cr=`echo X | tr X '\015'` +# On cygwin, bash can eat \r inside `` if the user requested igncr. +# But we know of no other shell where ac_cr would be empty at this +# point, so we can use a bashism as a fallback. +if test "x$ac_cr" = x; then + eval ac_cr=\$\'\\r\' +fi +ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` +if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then + ac_cs_awk_cr='\\r' +else + ac_cs_awk_cr=$ac_cr +fi + +echo 'BEGIN {' >"$ac_tmp/subs1.awk" && +_ACEOF + + +{ + echo "cat >conf$$subs.awk <<_ACEOF" && + echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && + echo "_ACEOF" +} >conf$$subs.sh || + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 +ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` +ac_delim='%!_!# ' +for ac_last_try in false false false false false :; do + . ./conf$$subs.sh || + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 + + ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` + if test $ac_delim_n = $ac_delim_num; then + break + elif $ac_last_try; then + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 + else + ac_delim="$ac_delim!$ac_delim _$ac_delim!! " + fi +done +rm -f conf$$subs.sh + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && +_ACEOF +sed -n ' +h +s/^/S["/; s/!.*/"]=/ +p +g +s/^[^!]*!// +:repl +t repl +s/'"$ac_delim"'$// +t delim +:nl +h +s/\(.\{148\}\)..*/\1/ +t more1 +s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ +p +n +b repl +:more1 +s/["\\]/\\&/g; s/^/"/; s/$/"\\/ +p +g +s/.\{148\}// +t nl +:delim +h +s/\(.\{148\}\)..*/\1/ +t more2 +s/["\\]/\\&/g; s/^/"/; s/$/"/ +p +b +:more2 +s/["\\]/\\&/g; s/^/"/; s/$/"\\/ +p +g +s/.\{148\}// +t delim +' >$CONFIG_STATUS || ac_write_fail=1 +rm -f conf$$subs.awk +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +_ACAWK +cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && + for (key in S) S_is_set[key] = 1 + FS = "" + +} +{ + line = $ 0 + nfields = split(line, field, "@") + substed = 0 + len = length(field[1]) + for (i = 2; i < nfields; i++) { + key = field[i] + keylen = length(key) + if (S_is_set[key]) { + value = S[key] + line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) + len += length(value) + length(field[++i]) + substed = 1 + } else + len += 1 + keylen + } + + print line +} + +_ACAWK +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then + sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" +else + cat +fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ + || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 +_ACEOF + +# VPATH may cause trouble with some makes, so we remove sole $(srcdir), +# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and +# trailing colons and then remove the whole line if VPATH becomes empty +# (actually we leave an empty line to preserve line numbers). +if test "x$srcdir" = x.; then + ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ +h +s/// +s/^/:/ +s/[ ]*$/:/ +s/:\$(srcdir):/:/g +s/:\${srcdir}:/:/g +s/:@srcdir@:/:/g +s/^:*// +s/:*$// +x +s/\(=[ ]*\).*/\1/ +G +s/\n// +s/^[^=]*=[ ]*$// +}' +fi + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +fi # test -n "$CONFIG_FILES" + +# Set up the scripts for CONFIG_HEADERS section. +# No need to generate them if there are no CONFIG_HEADERS. +# This happens for instance with `./config.status Makefile'. +if test -n "$CONFIG_HEADERS"; then +cat >"$ac_tmp/defines.awk" <<\_ACAWK || +BEGIN { +_ACEOF + +# Transform confdefs.h into an awk script `defines.awk', embedded as +# here-document in config.status, that substitutes the proper values into +# config.h.in to produce config.h. + +# Create a delimiter string that does not exist in confdefs.h, to ease +# handling of long lines. +ac_delim='%!_!# ' +for ac_last_try in false false :; do + ac_tt=`sed -n "/$ac_delim/p" confdefs.h` + if test -z "$ac_tt"; then + break + elif $ac_last_try; then + as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 + else + ac_delim="$ac_delim!$ac_delim _$ac_delim!! " + fi +done + +# For the awk script, D is an array of macro values keyed by name, +# likewise P contains macro parameters if any. Preserve backslash +# newline sequences. + +ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* +sed -n ' +s/.\{148\}/&'"$ac_delim"'/g +t rset +:rset +s/^[ ]*#[ ]*define[ ][ ]*/ / +t def +d +:def +s/\\$// +t bsnl +s/["\\]/\\&/g +s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ +D["\1"]=" \3"/p +s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p +d +:bsnl +s/["\\]/\\&/g +s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ +D["\1"]=" \3\\\\\\n"\\/p +t cont +s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p +t cont +d +:cont +n +s/.\{148\}/&'"$ac_delim"'/g +t clear +:clear +s/\\$// +t bsnlc +s/["\\]/\\&/g; s/^/"/; s/$/"/p +d +:bsnlc +s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p +b cont +' >$CONFIG_STATUS || ac_write_fail=1 + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 + for (key in D) D_is_set[key] = 1 + FS = "" +} +/^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { + line = \$ 0 + split(line, arg, " ") + if (arg[1] == "#") { + defundef = arg[2] + mac1 = arg[3] + } else { + defundef = substr(arg[1], 2) + mac1 = arg[2] + } + split(mac1, mac2, "(") #) + macro = mac2[1] + prefix = substr(line, 1, index(line, defundef) - 1) + if (D_is_set[macro]) { + # Preserve the white space surrounding the "#". + print prefix "define", macro P[macro] D[macro] + next + } else { + # Replace #undef with comments. This is necessary, for example, + # in the case of _POSIX_SOURCE, which is predefined and required + # on some systems where configure will not decide to define it. + if (defundef == "undef") { + print "/*", prefix defundef, macro, "*/" + next + } + } +} +{ print } +_ACAWK +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 + as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 +fi # test -n "$CONFIG_HEADERS" + + +eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS :C $CONFIG_COMMANDS" +shift +for ac_tag +do + case $ac_tag in + :[FHLC]) ac_mode=$ac_tag; continue;; + esac + case $ac_mode$ac_tag in + :[FHL]*:*);; + :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; + :[FH]-) ac_tag=-:-;; + :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; + esac + ac_save_IFS=$IFS + IFS=: + set x $ac_tag + IFS=$ac_save_IFS + shift + ac_file=$1 + shift + + case $ac_mode in + :L) ac_source=$1;; + :[FH]) + ac_file_inputs= + for ac_f + do + case $ac_f in + -) ac_f="$ac_tmp/stdin";; + *) # Look for the file first in the build tree, then in the source tree + # (if the path is not absolute). The absolute path cannot be DOS-style, + # because $ac_f cannot contain `:'. + test -f "$ac_f" || + case $ac_f in + [\\/$]*) false;; + *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; + esac || + as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; + esac + case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac + as_fn_append ac_file_inputs " '$ac_f'" + done + + # Let's still pretend it is `configure' which instantiates (i.e., don't + # use $as_me), people would be surprised to read: + # /* config.h. Generated by config.status. */ + configure_input='Generated from '` + $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' + `' by configure.' + if test x"$ac_file" != x-; then + configure_input="$ac_file. $configure_input" + { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 +$as_echo "$as_me: creating $ac_file" >&6;} + fi + # Neutralize special characters interpreted by sed in replacement strings. + case $configure_input in #( + *\&* | *\|* | *\\* ) + ac_sed_conf_input=`$as_echo "$configure_input" | + sed 's/[\\\\&|]/\\\\&/g'`;; #( + *) ac_sed_conf_input=$configure_input;; + esac + + case $ac_tag in + *:-:* | *:-) cat >"$ac_tmp/stdin" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; + esac + ;; + esac + + ac_dir=`$as_dirname -- "$ac_file" || +$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_file" : 'X\(//\)[^/]' \| \ + X"$ac_file" : 'X\(//\)$' \| \ + X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$ac_file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + as_dir="$ac_dir"; as_fn_mkdir_p + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix + +case $srcdir in + .) # We are building in place. + ac_srcdir=. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; +esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix + + + case $ac_mode in + :F) + # + # CONFIG_FILE + # + + case $INSTALL in + [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; + *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; + esac +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# If the template does not know about datarootdir, expand it. +# FIXME: This hack should be removed a few years after 2.60. +ac_datarootdir_hack=; ac_datarootdir_seen= +ac_sed_dataroot=' +/datarootdir/ { + p + q +} +/@datadir@/p +/@docdir@/p +/@infodir@/p +/@localedir@/p +/@mandir@/p' +case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in +*datarootdir*) ac_datarootdir_seen=yes;; +*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 +$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 + ac_datarootdir_hack=' + s&@datadir@&$datadir&g + s&@docdir@&$docdir&g + s&@infodir@&$infodir&g + s&@localedir@&$localedir&g + s&@mandir@&$mandir&g + s&\\\${datarootdir}&$datarootdir&g' ;; +esac +_ACEOF + +# Neutralize VPATH when `$srcdir' = `.'. +# Shell code in configure.ac might set extrasub. +# FIXME: do we really want to maintain this feature? +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +ac_sed_extra="$ac_vpsub +$extrasub +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +:t +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b +s|@configure_input@|$ac_sed_conf_input|;t t +s&@top_builddir@&$ac_top_builddir_sub&;t t +s&@top_build_prefix@&$ac_top_build_prefix&;t t +s&@srcdir@&$ac_srcdir&;t t +s&@abs_srcdir@&$ac_abs_srcdir&;t t +s&@top_srcdir@&$ac_top_srcdir&;t t +s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t +s&@builddir@&$ac_builddir&;t t +s&@abs_builddir@&$ac_abs_builddir&;t t +s&@abs_top_builddir@&$ac_abs_top_builddir&;t t +s&@INSTALL@&$ac_INSTALL&;t t +$ac_datarootdir_hack +" +eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ + >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + +test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && + { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && + { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ + "$ac_tmp/out"`; test -z "$ac_out"; } && + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined" >&5 +$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined" >&2;} + + rm -f "$ac_tmp/stdin" + case $ac_file in + -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; + *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; + esac \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + ;; + :H) + # + # CONFIG_HEADER + # + if test x"$ac_file" != x-; then + { + $as_echo "/* $configure_input */" \ + && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" + } >"$ac_tmp/config.h" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then + { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 +$as_echo "$as_me: $ac_file is unchanged" >&6;} + else + rm -f "$ac_file" + mv "$ac_tmp/config.h" "$ac_file" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + fi + else + $as_echo "/* $configure_input */" \ + && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ + || as_fn_error $? "could not create -" "$LINENO" 5 + fi + ;; + + :C) { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5 +$as_echo "$as_me: executing $ac_file commands" >&6;} + ;; + esac + + + case $ac_file$ac_mode in + "default-1":C) + for ac_file in $CONFIG_FILES; do + # Support "outfile[:infile[:infile...]]" + case "$ac_file" in + *:*) ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; + esac + # PO directories have a Makefile.in generated from Makefile.in.in. + case "$ac_file" in */Makefile.in) + # Adjust a relative srcdir. + ac_dir=`echo "$ac_file"|sed 's%/[^/][^/]*$%%'` + ac_dir_suffix="/`echo "$ac_dir"|sed 's%^\./%%'`" + ac_dots=`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'` + # In autoconf-2.13 it is called $ac_given_srcdir. + # In autoconf-2.50 it is called $srcdir. + test -n "$ac_given_srcdir" || ac_given_srcdir="$srcdir" + case "$ac_given_srcdir" in + .) top_srcdir=`echo $ac_dots|sed 's%/$%%'` ;; + /*) top_srcdir="$ac_given_srcdir" ;; + *) top_srcdir="$ac_dots$ac_given_srcdir" ;; + esac + if test -f "$ac_given_srcdir/$ac_dir/POTFILES.in"; then + rm -f "$ac_dir/POTFILES" + test -n "$as_me" && echo "$as_me: creating $ac_dir/POTFILES" || echo "creating $ac_dir/POTFILES" + cat "$ac_given_srcdir/$ac_dir/POTFILES.in" | sed -e "/^#/d" -e "/^[ ]*\$/d" -e "s,.*, $top_srcdir/& \\\\," | sed -e "\$s/\(.*\) \\\\/\1/" > "$ac_dir/POTFILES" + POMAKEFILEDEPS="POTFILES.in" + # ALL_LINGUAS, POFILES, GMOFILES, UPDATEPOFILES, DUMMYPOFILES depend + # on $ac_dir but don't depend on user-specified configuration + # parameters. + if test -f "$ac_given_srcdir/$ac_dir/LINGUAS"; then + # The LINGUAS file contains the set of available languages. + if test -n "$OBSOLETE_ALL_LINGUAS"; then + test -n "$as_me" && echo "$as_me: setting ALL_LINGUAS in configure.in is obsolete" || echo "setting ALL_LINGUAS in configure.in is obsolete" + fi + ALL_LINGUAS_=`sed -e "/^#/d" "$ac_given_srcdir/$ac_dir/LINGUAS"` + # Hide the ALL_LINGUAS assigment from automake. + eval 'ALL_LINGUAS''=$ALL_LINGUAS_' + POMAKEFILEDEPS="$POMAKEFILEDEPS LINGUAS" + else + # The set of available languages was given in configure.in. + eval 'ALL_LINGUAS''=$OBSOLETE_ALL_LINGUAS' + fi + case "$ac_given_srcdir" in + .) srcdirpre= ;; + *) srcdirpre='$(srcdir)/' ;; + esac + POFILES= + GMOFILES= + UPDATEPOFILES= + DUMMYPOFILES= + for lang in $ALL_LINGUAS; do + POFILES="$POFILES $srcdirpre$lang.po" + GMOFILES="$GMOFILES $srcdirpre$lang.gmo" + UPDATEPOFILES="$UPDATEPOFILES $lang.po-update" + DUMMYPOFILES="$DUMMYPOFILES $lang.nop" + done + # CATALOGS depends on both $ac_dir and the user's LINGUAS + # environment variable. + INST_LINGUAS= + if test -n "$ALL_LINGUAS"; then + for presentlang in $ALL_LINGUAS; do + useit=no + if test "%UNSET%" != "$LINGUAS"; then + desiredlanguages="$LINGUAS" + else + desiredlanguages="$ALL_LINGUAS" + fi + for desiredlang in $desiredlanguages; do + # Use the presentlang catalog if desiredlang is + # a. equal to presentlang, or + # b. a variant of presentlang (because in this case, + # presentlang can be used as a fallback for messages + # which are not translated in the desiredlang catalog). + case "$desiredlang" in + "$presentlang"*) useit=yes;; + esac + done + if test $useit = yes; then + INST_LINGUAS="$INST_LINGUAS $presentlang" + fi + done + fi + CATALOGS= + if test -n "$INST_LINGUAS"; then + for lang in $INST_LINGUAS; do + CATALOGS="$CATALOGS $lang.gmo" + done + fi + test -n "$as_me" && echo "$as_me: creating $ac_dir/Makefile" || echo "creating $ac_dir/Makefile" + sed -e "/^POTFILES =/r $ac_dir/POTFILES" -e "/^# Makevars/r $ac_given_srcdir/$ac_dir/Makevars" -e "s|@POFILES@|$POFILES|g" -e "s|@GMOFILES@|$GMOFILES|g" -e "s|@UPDATEPOFILES@|$UPDATEPOFILES|g" -e "s|@DUMMYPOFILES@|$DUMMYPOFILES|g" -e "s|@CATALOGS@|$CATALOGS|g" -e "s|@POMAKEFILEDEPS@|$POMAKEFILEDEPS|g" "$ac_dir/Makefile.in" > "$ac_dir/Makefile" + for f in "$ac_given_srcdir/$ac_dir"/Rules-*; do + if test -f "$f"; then + case "$f" in + *.orig | *.bak | *~) ;; + *) cat "$f" >> "$ac_dir/Makefile" ;; + esac + fi + done + fi + ;; + esac + done ;; + "default":C) +# Makefile uses this timestamp file to record whether config.h is up to date. +echo timestamp > stamp-h + ;; + + esac +done # for ac_tag + + +as_fn_exit 0 +_ACEOF +ac_clean_files=$ac_clean_files_save + +test $ac_write_fail = 0 || + as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 + + +# configure is writing to config.log, and then calls config.status. +# config.status does its own redirection, appending to config.log. +# Unfortunately, on DOS this fails, as config.log is still kept open +# by configure, so config.status won't be able to write to it; its +# output is simply discarded. So we exec the FD to /dev/null, +# effectively closing config.log, so it can be properly (re)opened and +# appended to by config.status. When coming back to configure, we +# need to make the FD available again. +if test "$no_create" != yes; then + ac_cs_success=: + ac_config_status_args= + test "$silent" = yes && + ac_config_status_args="$ac_config_status_args --quiet" + exec 5>/dev/null + $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false + exec 5>>config.log + # Use ||, not &&, to avoid exiting from the if with $? = 1, which + # would make configure fail if this is the last instruction. + $ac_cs_success || as_fn_exit 1 +fi +if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 +$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} +fi + diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..ce4e9b6 --- /dev/null +++ b/configure.ac @@ -0,0 +1,1234 @@ +dnl +dnl Configure script for bash-4.4 +dnl +dnl report bugs to chet@po.cwru.edu +dnl +dnl Process this file with autoconf to produce a configure script. + +# Copyright (C) 1987-2016 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 3 of the License, 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, see . + +AC_REVISION([for Bash 4.4, version 4.082])dnl + +define(bashvers, 4.4) +define(relstatus, release) + +AC_INIT([bash], bashvers-relstatus, [bug-bash@gnu.org]) + +dnl make sure we are using a recent autoconf version +AC_PREREQ(2.61) + +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*|releng*|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 +AC_CANONICAL_BUILD + +dnl configure defaults +opt_bash_malloc=yes +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 +*-mirbsd*) 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 +*-openstep*) opt_bash_malloc=no ;; # i386/Sparc/HP machines running Openstep +*-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 +*-nsk*) opt_bash_malloc=no ;; # HP NonStop +*-haiku*) opt_bash_malloc=no ;; # Haiku OS +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 +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) + +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_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_coproc=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 +opt_casemod_attrs=yes +opt_casemod_expansions=yes +opt_extglob_default=no +opt_dircomplete_expand_default=no +opt_globascii_default=no +opt_function_import=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 opt_coproc=no + opt_casemod_attrs=no opt_casemod_expansions=no opt_extglob_default=no + opt_globascii_default=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(casemod-attributes, AC_HELP_STRING([--enable-casemod-attributes], [include case-modifying variable attributes]), opt_casemod_attrs=$enableval) +AC_ARG_ENABLE(casemod-expansions, AC_HELP_STRING([--enable-casemod-expansions], [include case-modifying word expansions]), opt_casemod_expansions=$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 extended regular expression matching in conditional commands]), opt_cond_regexp=$enableval) +AC_ARG_ENABLE(coprocesses, AC_HELP_STRING([--enable-coprocesses], [enable coprocess support and the coproc reserved word]), opt_coproc=$enableval) +AC_ARG_ENABLE(debugger, AC_HELP_STRING([--enable-debugger], [enable support for bash debugger]), opt_debugger=$enableval) +AC_ARG_ENABLE(direxpand-default, AC_HELP_STRING([--enable-direxpand-default], [enable the direxpand shell option by default]), opt_dircomplete_expand_default=$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(extended-glob-default, AC_HELP_STRING([--enable-extended-glob-default], [force extended pattern matching to be enabled by default]), opt_extglob_default=$enableval) +AC_ARG_ENABLE(function-import, AC_HELP_STRING([--enable-function-import], [allow bash to import exported function definitions by default]), opt_function_import=$enableval) +AC_ARG_ENABLE(glob-asciiranges-default, AC_HELP_STRING([--enable-glob-asciiranges-default], [force bracket range expressions in pattern matching to use the C locale by default]), opt_globascii_default=$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 So-called `precious' variables +AC_ARG_VAR([CC_FOR_BUILD], [C compiler used when compiling binaries used only at build time]) +AC_ARG_VAR([CFLAGS_FOR_BUILD], [Compliation options (CFLAGS) used when compiling binaries used only at build time]) +AC_ARG_VAR([LDFLAGS_FOR_BUILD], [Linker options (LDFLAGS) used when compiling binaries used only at build time]) +AC_ARG_VAR([CPPFLAGS_FOR_BUILD], [C preprocessor options (CPPFLAGS) used when compiling binaries used only at build time]) + +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_extglob_default = yes; then +AC_DEFINE(EXTGLOB_DEFAULT, 1) +else +AC_DEFINE(EXTGLOB_DEFAULT, 0) +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_coproc = yes; then +AC_DEFINE(COPROCESS_SUPPORT) +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_casemod_attrs = yes; then +AC_DEFINE(CASEMOD_ATTRS) +fi +if test $opt_casemod_expansions = yes; then +AC_DEFINE(CASEMOD_EXPANSIONS) +fi +if test $opt_dircomplete_expand_default = yes; then +AC_DEFINE(DIRCOMPLETE_EXPAND_DEFAULT) +fi +if test $opt_globascii_default = yes; then +AC_DEFINE(GLOBASCII_DEFAULT, 1) +else +AC_DEFINE(GLOBASCII_DEFAULT, 0) +fi +if test $opt_function_import = yes; then +AC_DEFINE(FUNCTION_IMPORT) +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= HELPFILES_TARGET= +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' + HELPFILES_TARGET='helpdoc' +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(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(HELPFILES_TARGET) +AC_SUBST(HELPSTRINGS) + +dnl We want these before the checks, so the checks can modify their values. +if test -z "$CFLAGS"; then + AUTO_CFLAGS="-g ${GCC+-O2} ${GCC+-Wno-parentheses}" + AUTO_LDFLAGS="-g ${GCC+-O2}" +else + AUTO_CFLAGS= AUTO_LDFLAGS= +fi + +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) + +dnl END changes for cross-building + +dnl default values +CFLAGS=${CFLAGS-"$AUTO_CFLAGS"} +# LDFLAGS=${LDFLAGS="$AUTO_LDFLAGS"} # XXX + +# turn off paren warnings in gcc +if test "$GCC" = yes # && test -n "$DEBUG" +then + CFLAGS="$CFLAGS -Wno-parentheses -Wno-format-security" +fi + +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 + +prefer_shared=yes +prefer_static=no + +if test "$opt_static_link" = yes; then + prefer_static=yes + prefer_shared=no + # 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 + +# set the appropriate make variables for building the "build tools" +# modify defaults based on whether or not we are cross compiling, since the +# options for the target host may not be appropriate for the build host +if test "X$cross_compiling" = "Xno"; then + CC_FOR_BUILD=${CC_FOR_BUILD-'$(CC)'} + CPPFLAGS_FOR_BUILD=${CPPFLAGS_FOR_BUILD-"$CPPFLAGS"} # XXX - should it be '$(CPPFLAGS)' + LDFLAGS_FOR_BUILD=${LDFLAGS_FOR_BUILD-'$(LDFLAGS)'} + # CFLAGS set above to default value if not passed in environment + CFLAGS_FOR_BUILD=${CFLAGS-'$(CFLAGS)'} + LIBS_FOR_BUILD=${LIBS_FOR_BUILD-'$(LIBS)'} +else + CC_FOR_BUILD=${CC_FOR_BUILD-"gcc"} + CPPFLAGS_FOR_BUILD=${CPPFLAGS_FOR_BUILD-""} + LDFLAGS_FOR_BUILD=${LDFLAGS_FOR_BUILD-""} + CFLAGS_FOR_BUILD=${CFLAGS_FOR_BUILD="-g"} + LIBS_FOR_BUILD=${LIBS_FOR_BUILD-""} +fi + +AC_SUBST(CFLAGS) +AC_SUBST(CPPFLAGS) +AC_SUBST(LDFLAGS) +AC_SUBST(STATIC_LD) + +AC_SUBST(CC_FOR_BUILD) +AC_SUBST(CFLAGS_FOR_BUILD) +AC_SUBST(CPPFLAGS_FOR_BUILD) +AC_SUBST(LDFLAGS_FOR_BUILD) +AC_SUBST(LIBS_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 + darwin[[89]]*|darwin10*) 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 + darwin[[89]]*|darwin10*) 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_TOOL(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 "$ac_cv_prog_YACC" in +*bison*) ;; +*) AC_MSG_WARN([bison not available; needed to process parse.y]) ;; +esac + +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) + +m4_include([m4/stat-time.m4]) +m4_include([m4/timespec.m4]) + +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 +AC_C_VOLATILE +AC_C_RESTRICT + +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 \ + stdbool.h stddef.h stdint.h netdb.h pwd.h grp.h strings.h \ + regex.h syslog.h ulimit.h) +AC_CHECK_HEADERS(sys/pte.h sys/stream.h sys/select.h sys/file.h sys/ioctl.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 +#endif +]]) + +dnl SunOS 4 needs to include before to compile +dnl autoconf complains about presence but inability to compile +AC_CHECK_HEADER(sys/resource.h, AC_DEFINE(HAVE_SYS_RESOURCE_H), [], [[ +#if HAVE_SYS_TIME_H +# include +#endif +]]) + +dnl special checks for libc functions +AC_FUNC_ALLOCA +AC_FUNC_CHOWN +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)) + +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 pselect readlink sbrk select setdtablesize \ + setitimer tcgetpgrp uname ulimit waitpid) +AC_REPLACE_FUNCS(rename) + +dnl checks for c library functions +AC_CHECK_FUNCS(bcopy bzero confstr faccessat fnmatch \ + getaddrinfo gethostbyname getservbyname getservent inet_aton \ + imaxdiv memmove pathconf putenv raise random regcomp regexec \ + setenv setlinebuf setlocale setvbuf siginterrupt strchr \ + sysconf syslog tcgetattr times ttyname tzset unsetenv) + +AC_CHECK_FUNCS(vasprintf asprintf) +AC_CHECK_FUNCS(isascii isblank isgraph isprint isspace isxdigit) +AC_CHECK_FUNCS(getpwent getpwnam getpwuid) +AC_CHECK_FUNCS(mkstemp) +AC_REPLACE_FUNCS(getcwd memset) +AC_REPLACE_FUNCS(strcasecmp strcasestr strerror strftime strnlen strpbrk strstr) +AC_REPLACE_FUNCS(strtod strtol strtoul strtoll strtoull strtoimax strtoumax) +AC_REPLACE_FUNCS(dprintf) +AC_REPLACE_FUNCS(strchrnul) +AC_REPLACE_FUNCS(strdup) + +AC_CHECK_HEADERS(libaudit.h) +AC_CHECK_DECLS([AUDIT_USER_TTY],,, [[#include ]]) + +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 ], + [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]) + +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 HAVE_DECL_SYS_SIGLIST +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_TYPE_UINTPTR_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 +BASH_TYPE_SIG_ATOMIC_T + +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 ], long) +BASH_CHECK_TYPE(sigset_t, [#include ], int) +BASH_CHECK_TYPE(sig_atomic_t, [#include ], 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 ], [unsigned int], HAVE_SOCKLEN_T) +fi +BASH_TYPE_RLIMIT + +AC_CHECK_SIZEOF(intmax_t, 8) + +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 + +BASH_STRUCT_WEXITSTATUS_OFFSET + +BASH_CHECK_TYPE_STRUCT_TIMESPEC +BASH_STAT_TIME + +dnl presence and behavior of C library functions +BASH_FUNC_STRSIGNAL +BASH_FUNC_OPENDIR_CHECK +BASH_FUNC_ULIMIT_MAXFDS +BASH_FUNC_FPURGE +BASH_FUNC_GETENV +if test "$ac_cv_func_getcwd" = "yes"; then +BASH_FUNC_GETCWD +fi +BASH_FUNC_POSIX_SETJMP +BASH_FUNC_STRCOLL +BASH_FUNC_SNPRINTF +BASH_FUNC_VSNPRINTF + +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 or ld 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 -DSOLARIS" ;; +solaris2.8*) LOCAL_CFLAGS=-DSOLARIS ;; +solaris2.9*) LOCAL_CFLAGS=-DSOLARIS ;; +solaris2.10*) LOCAL_CFLAGS=-DSOLARIS ;; +solaris2*) LOCAL_CFLAGS=-DSOLARIS ;; +lynxos*) LOCAL_CFLAGS=-DRECYCLES_PIDS ;; +linux*) LOCAL_LDFLAGS=-rdynamic # allow dynamic loading + case "`uname -r`" in + 2.[[456789]]*|[[34]]*) 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 -D_ALL_SOURCE -DRECYCLES_PIDS" ;; +*openstep*) LOCAL_CFLAGS="-D__APPLE_CC__" ;; +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 +bsdi5*-*gcc*) LOCAL_LDFLAGS="-rdynamic" ;; # allow dynamic loading, like Linux +hpux11*-gcc*) LOCAL_LDFLAGS="-Wl,-E" ;; # allow dynamic loading +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 + +if test -z "$localedir"; then + localedir='${datarootdir}/locale' +fi +if test -z "$datarootdir"; then + datarootdir='${prefix}/share' +fi + +AC_SUBST(PROFILE_FLAGS) + +AC_SUBST(incdir) +AC_SUBST(BUILD_DIR) + +# Some versions of autoconf don't substitute these automatically +AC_SUBST(datarootdir) +AC_SUBST(localedir) + +# directory where we install dynamically loadable builtins +if test -z "$loadablesdir"; then + loadablesdir='${libdir}/bash' +fi +AC_SUBST(loadablesdir) +if test -z "$headersdir"; then + headersdir='$(includedir)/$(PACKAGE_NAME)' +fi +AC_SUBST(headersdir) + +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/Makefile.inc \ + examples/loadables/perl/Makefile \ + support/bash.pc], +[ +# Makefile uses this timestamp file to record whether config.h is up to date. +echo timestamp > stamp-h +]) diff --git a/conftypes.h b/conftypes.h new file mode 100644 index 0000000..1c8c548 --- /dev/null +++ b/conftypes.h @@ -0,0 +1,58 @@ +/* conftypes.h -- defines for build and host system. */ + +/* Copyright (C) 2001, 2005, 2008,2009 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 3 of the License, 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. If not, see . +*/ + +#if !defined (_CONFTYPES_H_) +#define _CONFTYPES_H_ + +/* Placeholder for future modifications if cross-compiling or building a + `fat' binary, e.g. on Apple Rhapsody. These values are used in multiple + files, so they appear here. */ +#if !defined (RHAPSODY) && !defined (MACOSX) +# define HOSTTYPE CONF_HOSTTYPE +# define OSTYPE CONF_OSTYPE +# define MACHTYPE CONF_MACHTYPE +#else /* RHAPSODY */ +# if defined(__powerpc__) || defined(__ppc__) +# define HOSTTYPE "powerpc" +# elif defined(__i386__) +# define HOSTTYPE "i386" +# else +# define HOSTTYPE CONF_HOSTTYPE +# endif + +# define OSTYPE CONF_OSTYPE +# define VENDOR CONF_VENDOR + +# define MACHTYPE HOSTTYPE "-" VENDOR "-" OSTYPE +#endif /* RHAPSODY */ + +#ifndef HOSTTYPE +# define HOSTTYPE "unknown" +#endif + +#ifndef OSTYPE +# define OSTYPE "unknown" +#endif + +#ifndef MACHTYPE +# define MACHTYPE "unknown" +#endif + +#endif /* _CONFTYPES_H_ */ diff --git a/copy_cmd.c b/copy_cmd.c new file mode 100644 index 0000000..826e0c3 --- /dev/null +++ b/copy_cmd.c @@ -0,0 +1,450 @@ +/* copy_command.c -- copy a COMMAND structure. This is needed + primarily for making function definitions, but I'm not sure + that anyone else will need it. */ + +/* Copyright (C) 1987-2009 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 3 of the License, 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. If not, see . +*/ + +#include "config.h" + +#include "bashtypes.h" + +#if defined (HAVE_UNISTD_H) +# include +#endif + +#include + +#include "shell.h" + +static PATTERN_LIST *copy_case_clause __P((PATTERN_LIST *)); +static PATTERN_LIST *copy_case_clauses __P((PATTERN_LIST *)); +static FOR_COM *copy_for_command __P((FOR_COM *)); +#if defined (ARITH_FOR_COMMAND) +static ARITH_FOR_COM *copy_arith_for_command __P((ARITH_FOR_COM *)); +#endif +static GROUP_COM *copy_group_command __P((GROUP_COM *)); +static SUBSHELL_COM *copy_subshell_command __P((SUBSHELL_COM *)); +static COPROC_COM *copy_coproc_command __P((COPROC_COM *)); +static CASE_COM *copy_case_command __P((CASE_COM *)); +static WHILE_COM *copy_while_command __P((WHILE_COM *)); +static IF_COM *copy_if_command __P((IF_COM *)); +#if defined (DPAREN_ARITHMETIC) +static ARITH_COM *copy_arith_command __P((ARITH_COM *)); +#endif +#if defined (COND_COMMAND) +static COND_COM *copy_cond_command __P((COND_COM *)); +#endif +static SIMPLE_COM *copy_simple_command __P((SIMPLE_COM *)); + +WORD_DESC * +copy_word (w) + WORD_DESC *w; +{ + WORD_DESC *new_word; + + new_word = make_bare_word (w->word); + new_word->flags = w->flags; + return (new_word); +} + +/* Copy the chain of words in LIST. Return a pointer to + the new chain. */ +WORD_LIST * +copy_word_list (list) + WORD_LIST *list; +{ + WORD_LIST *new_list; + + for (new_list = (WORD_LIST *)NULL; list; list = list->next) + new_list = make_word_list (copy_word (list->word), new_list); + + return (REVERSE_LIST (new_list, WORD_LIST *)); +} + +static PATTERN_LIST * +copy_case_clause (clause) + PATTERN_LIST *clause; +{ + PATTERN_LIST *new_clause; + + new_clause = (PATTERN_LIST *)xmalloc (sizeof (PATTERN_LIST)); + new_clause->patterns = copy_word_list (clause->patterns); + new_clause->action = copy_command (clause->action); + new_clause->flags = clause->flags; + return (new_clause); +} + +static PATTERN_LIST * +copy_case_clauses (clauses) + PATTERN_LIST *clauses; +{ + PATTERN_LIST *new_list, *new_clause; + + for (new_list = (PATTERN_LIST *)NULL; clauses; clauses = clauses->next) + { + new_clause = copy_case_clause (clauses); + new_clause->next = new_list; + new_list = new_clause; + } + return (REVERSE_LIST (new_list, PATTERN_LIST *)); +} + +/* Copy a single redirect. */ +REDIRECT * +copy_redirect (redirect) + REDIRECT *redirect; +{ + REDIRECT *new_redirect; + + new_redirect = (REDIRECT *)xmalloc (sizeof (REDIRECT)); +#if 0 + FASTCOPY ((char *)redirect, (char *)new_redirect, (sizeof (REDIRECT))); +#else + *new_redirect = *redirect; /* let the compiler do the fast structure copy */ +#endif + + if (redirect->rflags & REDIR_VARASSIGN) + new_redirect->redirector.filename = copy_word (redirect->redirector.filename); + + switch (redirect->instruction) + { + case r_reading_until: + case r_deblank_reading_until: + new_redirect->here_doc_eof = redirect->here_doc_eof ? savestring (redirect->here_doc_eof) : 0; + /*FALLTHROUGH*/ + case r_reading_string: + case r_appending_to: + case r_output_direction: + case r_input_direction: + case r_inputa_direction: + case r_err_and_out: + case r_append_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: + new_redirect->redirectee.filename = copy_word (redirect->redirectee.filename); + break; + case r_duplicating_input: + case r_duplicating_output: + case r_move_input: + case r_move_output: + case r_close_this: + break; + } + return (new_redirect); +} + +REDIRECT * +copy_redirects (list) + REDIRECT *list; +{ + REDIRECT *new_list, *temp; + + for (new_list = (REDIRECT *)NULL; list; list = list->next) + { + temp = copy_redirect (list); + temp->next = new_list; + new_list = temp; + } + return (REVERSE_LIST (new_list, REDIRECT *)); +} + +static FOR_COM * +copy_for_command (com) + FOR_COM *com; +{ + FOR_COM *new_for; + + new_for = (FOR_COM *)xmalloc (sizeof (FOR_COM)); + new_for->flags = com->flags; + new_for->line = com->line; + new_for->name = copy_word (com->name); + new_for->map_list = copy_word_list (com->map_list); + new_for->action = copy_command (com->action); + return (new_for); +} + +#if defined (ARITH_FOR_COMMAND) +static ARITH_FOR_COM * +copy_arith_for_command (com) + ARITH_FOR_COM *com; +{ + ARITH_FOR_COM *new_arith_for; + + new_arith_for = (ARITH_FOR_COM *)xmalloc (sizeof (ARITH_FOR_COM)); + new_arith_for->flags = com->flags; + new_arith_for->line = com->line; + new_arith_for->init = copy_word_list (com->init); + new_arith_for->test = copy_word_list (com->test); + new_arith_for->step = copy_word_list (com->step); + new_arith_for->action = copy_command (com->action); + return (new_arith_for); +} +#endif /* ARITH_FOR_COMMAND */ + +static GROUP_COM * +copy_group_command (com) + GROUP_COM *com; +{ + GROUP_COM *new_group; + + new_group = (GROUP_COM *)xmalloc (sizeof (GROUP_COM)); + new_group->command = copy_command (com->command); + return (new_group); +} + +static SUBSHELL_COM * +copy_subshell_command (com) + SUBSHELL_COM *com; +{ + SUBSHELL_COM *new_subshell; + + new_subshell = (SUBSHELL_COM *)xmalloc (sizeof (SUBSHELL_COM)); + new_subshell->command = copy_command (com->command); + new_subshell->flags = com->flags; + return (new_subshell); +} + +static COPROC_COM * +copy_coproc_command (com) + COPROC_COM *com; +{ + COPROC_COM *new_coproc; + + new_coproc = (COPROC_COM *)xmalloc (sizeof (COPROC_COM)); + new_coproc->name = savestring (com->name); + new_coproc->command = copy_command (com->command); + new_coproc->flags = com->flags; + return (new_coproc); +} + +static CASE_COM * +copy_case_command (com) + CASE_COM *com; +{ + CASE_COM *new_case; + + new_case = (CASE_COM *)xmalloc (sizeof (CASE_COM)); + new_case->flags = com->flags; + new_case->line = com->line; + new_case->word = copy_word (com->word); + new_case->clauses = copy_case_clauses (com->clauses); + return (new_case); +} + +static WHILE_COM * +copy_while_command (com) + WHILE_COM *com; +{ + WHILE_COM *new_while; + + new_while = (WHILE_COM *)xmalloc (sizeof (WHILE_COM)); + new_while->flags = com->flags; + new_while->test = copy_command (com->test); + new_while->action = copy_command (com->action); + return (new_while); +} + +static IF_COM * +copy_if_command (com) + IF_COM *com; +{ + IF_COM *new_if; + + new_if = (IF_COM *)xmalloc (sizeof (IF_COM)); + new_if->flags = com->flags; + new_if->test = copy_command (com->test); + new_if->true_case = copy_command (com->true_case); + new_if->false_case = com->false_case ? copy_command (com->false_case) : com->false_case; + return (new_if); +} + +#if defined (DPAREN_ARITHMETIC) +static ARITH_COM * +copy_arith_command (com) + ARITH_COM *com; +{ + ARITH_COM *new_arith; + + new_arith = (ARITH_COM *)xmalloc (sizeof (ARITH_COM)); + new_arith->flags = com->flags; + new_arith->exp = copy_word_list (com->exp); + new_arith->line = com->line; + + return (new_arith); +} +#endif + +#if defined (COND_COMMAND) +static COND_COM * +copy_cond_command (com) + COND_COM *com; +{ + COND_COM *new_cond; + + new_cond = (COND_COM *)xmalloc (sizeof (COND_COM)); + new_cond->flags = com->flags; + new_cond->line = com->line; + new_cond->type = com->type; + new_cond->op = com->op ? copy_word (com->op) : com->op; + new_cond->left = com->left ? copy_cond_command (com->left) : (COND_COM *)NULL; + new_cond->right = com->right ? copy_cond_command (com->right) : (COND_COM *)NULL; + + return (new_cond); +} +#endif + +static SIMPLE_COM * +copy_simple_command (com) + SIMPLE_COM *com; +{ + SIMPLE_COM *new_simple; + + new_simple = (SIMPLE_COM *)xmalloc (sizeof (SIMPLE_COM)); + new_simple->flags = com->flags; + new_simple->words = copy_word_list (com->words); + new_simple->redirects = com->redirects ? copy_redirects (com->redirects) : (REDIRECT *)NULL; + new_simple->line = com->line; + return (new_simple); +} + +FUNCTION_DEF * +copy_function_def_contents (old, new_def) + FUNCTION_DEF *old, *new_def; +{ + new_def->name = copy_word (old->name); + new_def->command = old->command ? copy_command (old->command) : old->command; + new_def->flags = old->flags; + new_def->line = old->line; + new_def->source_file = old->source_file ? savestring (old->source_file) : old->source_file; + return (new_def); +} + +FUNCTION_DEF * +copy_function_def (com) + FUNCTION_DEF *com; +{ + FUNCTION_DEF *new_def; + + new_def = (FUNCTION_DEF *)xmalloc (sizeof (FUNCTION_DEF)); + new_def = copy_function_def_contents (com, new_def); + return (new_def); +} + +/* Copy the command structure in COMMAND. Return a pointer to the + copy. Don't you forget to dispose_command () on this pointer + later! */ +COMMAND * +copy_command (command) + COMMAND *command; +{ + COMMAND *new_command; + + if (command == NULL) + return (command); + + new_command = (COMMAND *)xmalloc (sizeof (COMMAND)); + FASTCOPY ((char *)command, (char *)new_command, sizeof (COMMAND)); + new_command->flags = command->flags; + new_command->line = command->line; + + if (command->redirects) + new_command->redirects = copy_redirects (command->redirects); + + switch (command->type) + { + case cm_for: + new_command->value.For = copy_for_command (command->value.For); + break; + +#if defined (ARITH_FOR_COMMAND) + case cm_arith_for: + new_command->value.ArithFor = copy_arith_for_command (command->value.ArithFor); + break; +#endif + +#if defined (SELECT_COMMAND) + case cm_select: + new_command->value.Select = + (SELECT_COM *)copy_for_command ((FOR_COM *)command->value.Select); + break; +#endif + + case cm_group: + new_command->value.Group = copy_group_command (command->value.Group); + break; + + case cm_subshell: + new_command->value.Subshell = copy_subshell_command (command->value.Subshell); + break; + + case cm_coproc: + new_command->value.Coproc = copy_coproc_command (command->value.Coproc); + break; + + case cm_case: + new_command->value.Case = copy_case_command (command->value.Case); + break; + + case cm_until: + case cm_while: + new_command->value.While = copy_while_command (command->value.While); + break; + + case cm_if: + new_command->value.If = copy_if_command (command->value.If); + break; + +#if defined (DPAREN_ARITHMETIC) + case cm_arith: + new_command->value.Arith = copy_arith_command (command->value.Arith); + break; +#endif + +#if defined (COND_COMMAND) + case cm_cond: + new_command->value.Cond = copy_cond_command (command->value.Cond); + break; +#endif + + case cm_simple: + new_command->value.Simple = copy_simple_command (command->value.Simple); + break; + + case cm_connection: + { + CONNECTION *new_connection; + + new_connection = (CONNECTION *)xmalloc (sizeof (CONNECTION)); + new_connection->connector = command->value.Connection->connector; + new_connection->first = copy_command (command->value.Connection->first); + new_connection->second = copy_command (command->value.Connection->second); + new_command->value.Connection = new_connection; + break; + } + + case cm_function_def: + new_command->value.Function_def = copy_function_def (command->value.Function_def); + break; + } + return (new_command); +} diff --git a/cross-build/cygwin32.cache b/cross-build/cygwin32.cache new file mode 100644 index 0000000..36948da --- /dev/null +++ b/cross-build/cygwin32.cache @@ -0,0 +1,251 @@ +# This file is a shell script that caches the results of configure +# tests run on this system so they can be shared between configure +# scripts and configure runs, see configure's option --config-cache. +# It is not useful on other systems. If it contains results you don't +# want to keep, you may remove or edit it. +# +# config.status only pays attention to the cache file if you give it +# the --recheck option to rerun configure. +# +# `ac_cv_env_foo' variables (set or unset) will be overriden when +# loading this file, other *unset* `ac_cv_foo' will be assigned the +# following values. + +ac_cv_build=${ac_cv_build='i686-pc-cygwin'} +ac_cv_build_alias=${ac_cv_build_alias='i686-pc-cygwin'} +ac_cv_c_bigendian=${ac_cv_c_bigendian='no'} +ac_cv_c_char_unsigned=${ac_cv_c_char_unsigned='no'} +ac_cv_c_compiler_gnu=${ac_cv_c_compiler_gnu='yes'} +ac_cv_c_const=${ac_cv_c_const='yes'} +ac_cv_c_inline=${ac_cv_c_inline='inline'} +ac_cv_c_long_double=${ac_cv_c_long_double='yes'} +ac_cv_c_stringize=${ac_cv_c_stringize='yes'} +ac_cv_decl_sys_siglist=${ac_cv_decl_sys_siglist='no'} +ac_cv_exeext=${ac_cv_exeext='.exe'} +ac_cv_func___setostype=${ac_cv_func___setostype='no'} +ac_cv_func__doprnt=${ac_cv_func__doprnt='no'} +ac_cv_func_alloca_works=${ac_cv_func_alloca_works='yes'} +ac_cv_func_asprintf=${ac_cv_func_asprintf='no'} +ac_cv_func_bcopy=${ac_cv_func_bcopy='yes'} +ac_cv_func_bindtextdomain=${ac_cv_func_bindtextdomain='no'} +ac_cv_func_bzero=${ac_cv_func_bzero='yes'} +ac_cv_func_confstr=${ac_cv_func_confstr='no'} +ac_cv_func_dlclose=${ac_cv_func_dlclose='yes'} +ac_cv_func_dlopen=${ac_cv_func_dlopen='yes'} +ac_cv_func_dlsym=${ac_cv_func_dlsym='yes'} +ac_cv_func_dup2=${ac_cv_func_dup2='yes'} +ac_cv_func_fnmatch=${ac_cv_func_fnmatch='no'} +ac_cv_func_getaddrinfo=${ac_cv_func_getaddrinfo='no'} +ac_cv_func_getcwd=${ac_cv_func_getcwd='yes'} +ac_cv_func_getdtablesize=${ac_cv_func_getdtablesize='yes'} +ac_cv_func_getgroups=${ac_cv_func_getgroups='yes'} +ac_cv_func_gethostbyname=${ac_cv_func_gethostbyname='yes'} +ac_cv_func_gethostname=${ac_cv_func_gethostname='yes'} +ac_cv_func_getpagesize=${ac_cv_func_getpagesize='yes'} +ac_cv_func_getpeername=${ac_cv_func_getpeername='yes'} +ac_cv_func_getpgrp_void=${ac_cv_func_getpgrp_void='yes'} +ac_cv_func_getrlimit=${ac_cv_func_getrlimit='yes'} +ac_cv_func_getrusage=${ac_cv_func_getrusage='yes'} +ac_cv_func_getservbyname=${ac_cv_func_getservbyname='yes'} +ac_cv_func_gettext=${ac_cv_func_gettext='no'} +ac_cv_func_gettimeofday=${ac_cv_func_gettimeofday='yes'} +ac_cv_func_inet_aton=${ac_cv_func_inet_aton='yes'} +ac_cv_func_isascii=${ac_cv_func_isascii='yes'} +ac_cv_func_isblank=${ac_cv_func_isblank='no'} +ac_cv_func_isgraph=${ac_cv_func_isgraph='yes'} +ac_cv_func_isprint=${ac_cv_func_isprint='yes'} +ac_cv_func_isspace=${ac_cv_func_isspace='yes'} +ac_cv_func_isxdigit=${ac_cv_func_isxdigit='yes'} +ac_cv_func_killpg=${ac_cv_func_killpg='yes'} +ac_cv_func_lstat=${ac_cv_func_lstat='yes'} +ac_cv_func_memmove=${ac_cv_func_memmove='yes'} +ac_cv_func_mkfifo=${ac_cv_func_mkfifo='yes'} +ac_cv_func_pathconf=${ac_cv_func_pathconf='yes'} +ac_cv_func_putenv=${ac_cv_func_putenv='yes'} +ac_cv_func_readlink=${ac_cv_func_readlink='yes'} +ac_cv_func_rename=${ac_cv_func_rename='yes'} +ac_cv_func_sbrk=${ac_cv_func_sbrk='yes'} +ac_cv_func_select=${ac_cv_func_select='yes'} +ac_cv_func_setdtablesize=${ac_cv_func_setdtablesize='yes'} +ac_cv_func_setenv=${ac_cv_func_setenv='yes'} +ac_cv_func_setlinebuf=${ac_cv_func_setlinebuf='no'} +ac_cv_func_setlocale=${ac_cv_func_setlocale='yes'} +ac_cv_func_setvbuf=${ac_cv_func_setvbuf='yes'} +ac_cv_func_setvbuf_reversed=${ac_cv_func_setvbuf_reversed='no'} +ac_cv_func_siginterrupt=${ac_cv_func_siginterrupt='no'} +ac_cv_func_snprintf=${ac_cv_func_snprintf='yes'} +ac_cv_func_strcasecmp=${ac_cv_func_strcasecmp='yes'} +ac_cv_func_strchr=${ac_cv_func_strchr='yes'} +ac_cv_func_strcoll_works=${ac_cv_func_strcoll_works='yes'} +ac_cv_func_strerror=${ac_cv_func_strerror='yes'} +ac_cv_func_strpbrk=${ac_cv_func_strpbrk='yes'} +ac_cv_func_strtod=${ac_cv_func_strtod='yes'} +ac_cv_func_strtoimax=${ac_cv_func_strtoimax='no'} +ac_cv_func_strtol=${ac_cv_func_strtol='yes'} +ac_cv_func_strtoll=${ac_cv_func_strtoll='no'} +ac_cv_func_strtoul=${ac_cv_func_strtoul='yes'} +ac_cv_func_strtoull=${ac_cv_func_strtoull='no'} +ac_cv_func_strtoumax=${ac_cv_func_strtoumax='no'} +ac_cv_func_sysconf=${ac_cv_func_sysconf='yes'} +ac_cv_func_tcgetattr=${ac_cv_func_tcgetattr='yes'} +ac_cv_func_tcgetpgrp=${ac_cv_func_tcgetpgrp='yes'} +ac_cv_func_textdomain=${ac_cv_func_textdomain='no'} +ac_cv_func_times=${ac_cv_func_times='yes'} +ac_cv_func_ttyname=${ac_cv_func_ttyname='yes'} +ac_cv_func_tzset=${ac_cv_func_tzset='yes'} +ac_cv_func_ulimit=${ac_cv_func_ulimit='no'} +ac_cv_func_uname=${ac_cv_func_uname='yes'} +ac_cv_func_vasprintf=${ac_cv_func_vasprintf='no'} +ac_cv_func_vprintf=${ac_cv_func_vprintf='yes'} +ac_cv_func_vsnprintf=${ac_cv_func_vsnprintf='yes'} +ac_cv_func_wait3=${ac_cv_func_wait3='yes'} +ac_cv_func_waitpid=${ac_cv_func_waitpid='yes'} +ac_cv_have_decl_confstr=${ac_cv_have_decl_confstr='no'} +ac_cv_have_decl_printf=${ac_cv_have_decl_printf='yes'} +ac_cv_have_decl_sbrk=${ac_cv_have_decl_sbrk='yes'} +ac_cv_have_decl_strsignal=${ac_cv_have_decl_strsignal='yes'} +ac_cv_have_decl_strtold=${ac_cv_have_decl_strtold='no'} +ac_cv_header_arpa_inet_h=${ac_cv_header_arpa_inet_h='yes'} +ac_cv_header_dirent_dirent_h=${ac_cv_header_dirent_dirent_h='yes'} +ac_cv_header_dlfcn_h=${ac_cv_header_dlfcn_h='yes'} +ac_cv_header_grp_h=${ac_cv_header_grp_h='yes'} +ac_cv_header_inttypes_h=${ac_cv_header_inttypes_h='no'} +ac_cv_header_libintl_h=${ac_cv_header_libintl_h='yes'} +ac_cv_header_limits_h=${ac_cv_header_limits_h='yes'} +ac_cv_header_locale_h=${ac_cv_header_locale_h='yes'} +ac_cv_header_memory_h=${ac_cv_header_memory_h='yes'} +ac_cv_header_minix_config_h=${ac_cv_header_minix_config_h='no'} +ac_cv_header_netdb_h=${ac_cv_header_netdb_h='yes'} +ac_cv_header_netinet_in_h=${ac_cv_header_netinet_in_h='yes'} +ac_cv_header_stat_broken=${ac_cv_header_stat_broken='no'} +ac_cv_header_stdarg_h=${ac_cv_header_stdarg_h='yes'} +ac_cv_header_stdc=${ac_cv_header_stdc='yes'} +ac_cv_header_stddef_h=${ac_cv_header_stddef_h='yes'} +ac_cv_header_stdint_h=${ac_cv_header_stdint_h='no'} +ac_cv_header_stdlib_h=${ac_cv_header_stdlib_h='yes'} +ac_cv_header_string_h=${ac_cv_header_string_h='yes'} +ac_cv_header_strings_h=${ac_cv_header_strings_h='yes'} +ac_cv_header_sys_file_h=${ac_cv_header_sys_file_h='yes'} +ac_cv_header_sys_param_h=${ac_cv_header_sys_param_h='yes'} +ac_cv_header_sys_pte_h=${ac_cv_header_sys_pte_h='no'} +ac_cv_header_sys_ptem_h=${ac_cv_header_sys_ptem_h='no'} +ac_cv_header_sys_resource_h=${ac_cv_header_sys_resource_h='yes'} +ac_cv_header_sys_select_h=${ac_cv_header_sys_select_h='yes'} +ac_cv_header_sys_socket_h=${ac_cv_header_sys_socket_h='yes'} +ac_cv_header_sys_stat_h=${ac_cv_header_sys_stat_h='yes'} +ac_cv_header_sys_stream_h=${ac_cv_header_sys_stream_h='no'} +ac_cv_header_sys_time_h=${ac_cv_header_sys_time_h='yes'} +ac_cv_header_sys_times_h=${ac_cv_header_sys_times_h='yes'} +ac_cv_header_sys_types_h=${ac_cv_header_sys_types_h='yes'} +ac_cv_header_sys_wait_h=${ac_cv_header_sys_wait_h='yes'} +ac_cv_header_termcap_h=${ac_cv_header_termcap_h='yes'} +ac_cv_header_termio_h=${ac_cv_header_termio_h='yes'} +ac_cv_header_termios_h=${ac_cv_header_termios_h='yes'} +ac_cv_header_time=${ac_cv_header_time='yes'} +ac_cv_header_unistd_h=${ac_cv_header_unistd_h='yes'} +ac_cv_header_varargs_h=${ac_cv_header_varargs_h='yes'} +ac_cv_host=${ac_cv_host='i686-pc-cygwin'} +ac_cv_host_alias=${ac_cv_host_alias='i686-pc-cygwin'} +ac_cv_lib_dir_opendir=${ac_cv_lib_dir_opendir='no'} +ac_cv_lib_dl_dlopen=${ac_cv_lib_dl_dlopen='no'} +ac_cv_lib_intl_bindtextdomain=${ac_cv_lib_intl_bindtextdomain='yes'} +ac_cv_lib_termcap_tgetent=${ac_cv_lib_termcap_tgetent='yes'} +ac_cv_member_struct_stat_st_blocks=${ac_cv_member_struct_stat_st_blocks='yes'} +ac_cv_member_struct_termio_c_line=${ac_cv_member_struct_termio_c_line='yes'} +ac_cv_member_struct_termios_c_line=${ac_cv_member_struct_termios_c_line='yes'} +ac_cv_objext=${ac_cv_objext='o'} +ac_cv_path_install=${ac_cv_path_install='/usr/bin/install -c'} +ac_cv_prog_AR=${ac_cv_prog_AR='ar'} +ac_cv_prog_CPP=${ac_cv_prog_CPP='gcc -E'} +ac_cv_prog_YACC=${ac_cv_prog_YACC='bison -y'} +ac_cv_prog_ac_ct_CC=${ac_cv_prog_ac_ct_CC='gcc'} +ac_cv_prog_ac_ct_RANLIB=${ac_cv_prog_ac_ct_RANLIB='ranlib'} +ac_cv_prog_cc_g=${ac_cv_prog_cc_g='yes'} +ac_cv_prog_cc_stdc=${ac_cv_prog_cc_stdc=''} +ac_cv_prog_gcc_traditional=${ac_cv_prog_gcc_traditional='no'} +ac_cv_prog_make_make_set=${ac_cv_prog_make_make_set='yes'} +ac_cv_sizeof_char=${ac_cv_sizeof_char='1'} +ac_cv_sizeof_char_p=${ac_cv_sizeof_char_p='4'} +ac_cv_sizeof_double=${ac_cv_sizeof_double='8'} +ac_cv_sizeof_int=${ac_cv_sizeof_int='4'} +ac_cv_sizeof_long=${ac_cv_sizeof_long='4'} +ac_cv_sizeof_long_long=${ac_cv_sizeof_long_long='8'} +ac_cv_sizeof_short=${ac_cv_sizeof_short='2'} +ac_cv_sys_file_offset_bits=${ac_cv_sys_file_offset_bits='no'} +ac_cv_sys_interpreter=${ac_cv_sys_interpreter='yes'} +ac_cv_sys_large_files=${ac_cv_sys_large_files='no'} +ac_cv_sys_largefile_CC=${ac_cv_sys_largefile_CC='no'} +ac_cv_sys_posix_termios=${ac_cv_sys_posix_termios='yes'} +ac_cv_sys_tiocgwinsz_in_termios_h=${ac_cv_sys_tiocgwinsz_in_termios_h='yes'} +ac_cv_type_bits16_t=${ac_cv_type_bits16_t='no'} +ac_cv_type_bits32_t=${ac_cv_type_bits32_t='no'} +ac_cv_type_bits64_t=${ac_cv_type_bits64_t='no'} +ac_cv_type_char=${ac_cv_type_char='yes'} +ac_cv_type_char_p=${ac_cv_type_char_p='yes'} +ac_cv_type_double=${ac_cv_type_double='yes'} +ac_cv_type_getgroups=${ac_cv_type_getgroups='gid_t'} +ac_cv_type_int=${ac_cv_type_int='yes'} +ac_cv_type_long=${ac_cv_type_long='yes'} +ac_cv_type_long_long=${ac_cv_type_long_long='yes'} +ac_cv_type_mode_t=${ac_cv_type_mode_t='yes'} +ac_cv_type_off_t=${ac_cv_type_off_t='yes'} +ac_cv_type_pid_t=${ac_cv_type_pid_t='yes'} +ac_cv_type_ptrdiff_t=${ac_cv_type_ptrdiff_t='yes'} +ac_cv_type_short=${ac_cv_type_short='yes'} +ac_cv_type_signal=${ac_cv_type_signal='void'} +ac_cv_type_size_t=${ac_cv_type_size_t='yes'} +ac_cv_type_ssize_t=${ac_cv_type_ssize_t='yes'} +ac_cv_type_time_t=${ac_cv_type_time_t='yes'} +ac_cv_type_u_bits16_t=${ac_cv_type_u_bits16_t='no'} +ac_cv_type_u_bits32_t=${ac_cv_type_u_bits32_t='no'} +ac_cv_type_u_int=${ac_cv_type_u_int='yes'} +ac_cv_type_u_long=${ac_cv_type_u_long='yes'} +ac_cv_type_uid_t=${ac_cv_type_uid_t='yes'} +ac_cv_working_alloca_h=${ac_cv_working_alloca_h='no'} + +bash_cv_decl_strtoimax=${bash_cv_decl_strtoimax='no'} +bash_cv_decl_strtol=${bash_cv_decl_strtol='yes'} +bash_cv_decl_strtoll=${bash_cv_decl_strtoll='no'} +bash_cv_decl_strtoul=${bash_cv_decl_strtoul='yes'} +bash_cv_decl_strtoull=${bash_cv_decl_strtoull='no'} +bash_cv_decl_strtoumax=${bash_cv_decl_strtoumax='no'} +bash_cv_decl_under_sys_siglist=${bash_cv_decl_under_sys_siglist='no'} +bash_cv_dev_fd=${bash_cv_dev_fd='absent'} +bash_cv_dev_stdin=${bash_cv_dev_stdin='absent'} +bash_cv_dirent_has_d_fileno=${bash_cv_dirent_has_d_fileno='no'} +bash_cv_dirent_has_dino=${bash_cv_dirent_has_dino='yes'} +bash_cv_dup2_broken=${bash_cv_dup2_broken='no'} +bash_cv_fionread_in_ioctl=${bash_cv_fionread_in_ioctl='no'} +bash_cv_func_sigsetjmp=${bash_cv_func_sigsetjmp='present'} +bash_cv_func_strcoll_broken=${bash_cv_func_strcoll_broken='no'} +bash_cv_getenv_redef=${bash_cv_getenv_redef='yes'} +bash_cv_getpw_declared=${bash_cv_getpw_declared='yes'} +bash_cv_have_strsignal=${bash_cv_have_strsignal='yes'} +bash_cv_job_control_missing=${bash_cv_job_control_missing='present'} +bash_cv_mail_dir=${bash_cv_mail_dir='unknown'} +bash_cv_must_reinstall_sighandlers=${bash_cv_must_reinstall_sighandlers='no'} +bash_cv_opendir_not_robust=${bash_cv_opendir_not_robust='no'} +bash_cv_pgrp_pipe=${bash_cv_pgrp_pipe='no'} +bash_cv_printf_a_format=${bash_cv_printf_a_format='no'} +bash_cv_signal_vintage=${bash_cv_signal_vintage='posix'} +bash_cv_speed_t_in_sys_types=${bash_cv_speed_t_in_sys_types='no'} +bash_cv_struct_timeval=${bash_cv_struct_timeval='yes'} +bash_cv_struct_winsize_header=${bash_cv_struct_winsize_header='termios_h'} +bash_cv_sys_errlist=${bash_cv_sys_errlist='no'} +bash_cv_sys_named_pipes=${bash_cv_sys_named_pipes='present'} +bash_cv_sys_siglist=${bash_cv_sys_siglist='no'} +bash_cv_termcap_lib=${bash_cv_termcap_lib='libtermcap'} +bash_cv_tiocstat_in_ioctl=${bash_cv_tiocstat_in_ioctl='no'} +bash_cv_type_clock_t=${bash_cv_type_clock_t='yes'} +bash_cv_type_intmax_t=${bash_cv_type_intmax_t='no'} +bash_cv_type_long_long=${bash_cv_type_long_long='long long'} +bash_cv_type_quad_t=${bash_cv_type_quad_t='no'} +bash_cv_type_rlimit=${bash_cv_type_rlimit='rlim_t'} +bash_cv_type_sigset_t=${bash_cv_type_sigset_t='yes'} +bash_cv_type_socklen_t=${bash_cv_type_socklen_t='no'} +bash_cv_type_uintmax_t=${bash_cv_type_uintmax_t='no'} +bash_cv_type_unsigned_long_long=${bash_cv_type_unsigned_long_long='unsigned long long'} +bash_cv_ulimit_maxfds=${bash_cv_ulimit_maxfds='no'} +bash_cv_under_sys_siglist=${bash_cv_under_sys_siglist='no'} +bash_cv_unusable_rtsigs=${bash_cv_unusable_rtsigs='no'} +bash_cv_void_sighandler=${bash_cv_void_sighandler='yes'} diff --git a/cross-build/opennt.cache b/cross-build/opennt.cache new file mode 100644 index 0000000..ca5e7cd --- /dev/null +++ b/cross-build/opennt.cache @@ -0,0 +1,169 @@ +# This file is a shell script that caches the results of configure +# tests run on this system so they can be shared between configure +# scripts and configure runs. It is not useful on other systems. +# If it contains results you don't want to keep, you may remove or edit it. +# +# By default, configure uses ./config.cache as the cache file, +# creating it if it does not exist already. You can give configure +# the --cache-file=FILE option to use a different cache file; that is +# what configure does when it calls configure scripts in +# subdirectories, so they share the cache. +# Giving --cache-file=/dev/null disables caching, for debugging configure. +# config.status only pays attention to the cache file if you give it the +# --recheck option to rerun configure. +# +ac_cv_c_bigendian=${ac_cv_c_bigendian=no} +ac_cv_decl_sys_siglist=${ac_cv_decl_sys_siglist=no} +ac_cv_func___setostype=${ac_cv_func___setostype=no} +ac_cv_func_alloca_works=${ac_cv_func_alloca_works=yes} +ac_cv_func_bcopy=${ac_cv_func_bcopy=yes} +ac_cv_func_bindtextdomain=${ac_cv_func_bindtextdomain=no} +ac_cv_func_bzero=${ac_cv_func_bzero=yes} +ac_cv_func_confstr=${ac_cv_func_confstr=yes} +ac_cv_func_dlclose=${ac_cv_func_dlclose=no} +ac_cv_func_dlopen=${ac_cv_func_dlopen=no} +ac_cv_func_dlsym=${ac_cv_func_dlsym=no} +ac_cv_func_dup2=${ac_cv_func_dup2=yes} +ac_cv_func_getcwd=${ac_cv_func_getcwd=yes} +ac_cv_func_getdtablesize=${ac_cv_func_getdtablesize=no} +ac_cv_func_getgroups=${ac_cv_func_getgroups=yes} +ac_cv_func_gethostname=${ac_cv_func_gethostname=yes} +ac_cv_func_getpagesize=${ac_cv_func_getpagesize=yes} +ac_cv_func_getpeername=${ac_cv_func_getpeername=yes} +ac_cv_func_getpgrp_void=${ac_cv_func_getpgrp_void=yes} +ac_cv_func_getrlimit=${ac_cv_func_getrlimit=no} +ac_cv_func_getrusage=${ac_cv_func_getrusage=no} +ac_cv_func_gettext=${ac_cv_func_gettext=no} +ac_cv_func_gettimeofday=${ac_cv_func_gettimeofday=yes} +ac_cv_func_killpg=${ac_cv_func_killpg=yes} +ac_cv_func_lstat=${ac_cv_func_lstat=no} +ac_cv_func_memmove=${ac_cv_func_memmove=yes} +ac_cv_func_mkfifo=${ac_cv_func_mkfifo=yes} +ac_cv_func_putenv=${ac_cv_func_putenv=yes} +ac_cv_func_rename=${ac_cv_func_rename=yes} +ac_cv_func_sbrk=${ac_cv_func_sbrk=no} +ac_cv_func_select=${ac_cv_func_select=yes} +ac_cv_func_setdtablesize=${ac_cv_func_setdtablesize=no} +ac_cv_func_setenv=${ac_cv_func_setenv=yes} +ac_cv_func_setlinebuf=${ac_cv_func_setlinebuf=yes} +ac_cv_func_setlocale=${ac_cv_func_setlocale=yes} +ac_cv_func_setvbuf_reversed=${ac_cv_func_setvbuf_reversed=no} +ac_cv_func_siginterrupt=${ac_cv_func_siginterrupt=no} +ac_cv_func_strcasecmp=${ac_cv_func_strcasecmp=yes} +ac_cv_func_strchr=${ac_cv_func_strchr=yes} +ac_cv_func_strcoll_works=${ac_cv_func_strcoll_works=yes} +ac_cv_func_strerror=${ac_cv_func_strerror=yes} +ac_cv_func_strtod=${ac_cv_func_strtod=yes} +ac_cv_func_strtol=${ac_cv_func_strtol=yes} +ac_cv_func_strtoul=${ac_cv_func_strtoul=yes} +ac_cv_func_sysconf=${ac_cv_func_sysconf=yes} +ac_cv_func_tcgetattr=${ac_cv_func_tcgetattr=yes} +ac_cv_func_tcgetpgrp=${ac_cv_func_tcgetpgrp=yes} +ac_cv_func_textdomain=${ac_cv_func_textdomain=no} +ac_cv_func_times=${ac_cv_func_times=yes} +ac_cv_func_tzset=${ac_cv_func_tzset=yes} +ac_cv_func_ulimit=${ac_cv_func_ulimit=no} +ac_cv_func_uname=${ac_cv_func_uname=yes} +ac_cv_func_vprintf=${ac_cv_func_vprintf=yes} +ac_cv_func_wait3=${ac_cv_func_wait3=no} +ac_cv_func_wait3_rusage=${ac_cv_func_wait3_rusage=no} +ac_cv_func_waitpid=${ac_cv_func_waitpid=yes} +ac_cv_header_alloca_h=${ac_cv_header_alloca_h=no} +ac_cv_header_dirent_dirent_h=${ac_cv_header_dirent_dirent_h=yes} +ac_cv_header_dlfcn_h=${ac_cv_header_dlfcn_h=no} +ac_cv_header_libintl_h=${ac_cv_header_libintl_h=no} +ac_cv_header_limits_h=${ac_cv_header_limits_h=yes} +ac_cv_header_locale_h=${ac_cv_header_locale_h=yes} +ac_cv_header_memory_h=${ac_cv_header_memory_h=yes} +ac_cv_header_minix_config_h=${ac_cv_header_minix_config_h=no} +ac_cv_header_stat_broken=${ac_cv_header_stat_broken=no} +ac_cv_header_stdarg_h=${ac_cv_header_stdarg_h=yes} +ac_cv_header_stdc=${ac_cv_header_stdc=yes} +ac_cv_header_stdlib_h=${ac_cv_header_stdlib_h=yes} +ac_cv_header_string_h=${ac_cv_header_string_h=yes} +ac_cv_header_sys_file_h=${ac_cv_header_sys_file_h=yes} +ac_cv_header_sys_param_h=${ac_cv_header_sys_param_h=yes} +ac_cv_header_sys_pte_h=${ac_cv_header_sys_pte_h=no} +ac_cv_header_sys_ptem_h=${ac_cv_header_sys_ptem_h=no} +ac_cv_header_sys_resource_h=${ac_cv_header_sys_resource_h=no} +ac_cv_header_sys_select_h=${ac_cv_header_sys_select_h=no} +ac_cv_header_sys_socket_h=${ac_cv_header_sys_socket_h=yes} +ac_cv_header_sys_stream_h=${ac_cv_header_sys_stream_h=no} +ac_cv_header_sys_time_h=${ac_cv_header_sys_time_h=yes} +ac_cv_header_sys_times_h=${ac_cv_header_sys_times_h=yes} +ac_cv_header_sys_wait_h=${ac_cv_header_sys_wait_h=yes} +ac_cv_header_termcap_h=${ac_cv_header_termcap_h=no} +ac_cv_header_termio_h=${ac_cv_header_termio_h=no} +ac_cv_header_termios_h=${ac_cv_header_termios_h=yes} +ac_cv_header_time=${ac_cv_header_time=yes} +ac_cv_header_unistd_h=${ac_cv_header_unistd_h=yes} +ac_cv_header_varargs_h=${ac_cv_header_varargs_h=no} +ac_cv_lib_dir_opendir=${ac_cv_lib_dir_opendir=no} +ac_cv_lib_dl_dlopen=${ac_cv_lib_dl_dlopen=no} +ac_cv_lib_intl_bindtextdomain=${ac_cv_lib_intl_bindtextdomain=no} +ac_cv_lib_termcap_tgetent=${ac_cv_lib_termcap_tgetent=yes} +ac_cv_path_install=${ac_cv_path_install='$INTERIX_ROOT/bin/install -c'} +ac_cv_prog_AR=${ac_cv_prog_AR=ar} +ac_cv_prog_CC=${ac_cv_prog_CC=gcc} +ac_cv_prog_CPP=${ac_cv_prog_CPP='cc -E'} +ac_cv_prog_RANLIB=${ac_cv_prog_RANLIB=:} +ac_cv_prog_cc_cross=${ac_cv_prog_cc_cross=no} +ac_cv_prog_cc_g=${ac_cv_prog_cc_g=yes} +ac_cv_prog_cc_works=${ac_cv_prog_cc_works=yes} +ac_cv_prog_gcc=${ac_cv_prog_gcc=yes} +ac_cv_prog_gcc_traditional=${ac_cv_prog_gcc_traditional=no} +ac_cv_prog_make_make_set=${ac_cv_prog_make_make_set=yes} +ac_cv_sizeof_char_p=${ac_cv_sizeof_char_p=4} +ac_cv_sizeof_double=${ac_cv_sizeof_double=8} +ac_cv_sizeof_int=${ac_cv_sizeof_int=4} +ac_cv_sizeof_long=${ac_cv_sizeof_long=4} +ac_cv_sys_interpreter=${ac_cv_sys_interpreter=yes} +ac_cv_sys_restartable_syscalls=${ac_cv_sys_restartable_syscalls=no} +ac_cv_type_getgroups=${ac_cv_type_getgroups=gid_t} +ac_cv_type_mode_t=${ac_cv_type_mode_t=yes} +ac_cv_type_off_t=${ac_cv_type_off_t=yes} +ac_cv_type_pid_t=${ac_cv_type_pid_t=yes} +ac_cv_type_signal=${ac_cv_type_signal=void} +ac_cv_type_size_t=${ac_cv_type_size_t=yes} +ac_cv_type_time_t=${ac_cv_type_time_t=yes} +ac_cv_type_uid_t=${ac_cv_type_uid_t=yes} +bash_cv_can_redecl_getpw=${bash_cv_can_redecl_getpw=yes} +bash_cv_decl_under_sys_siglist=${bash_cv_decl_under_sys_siglist=no} +bash_cv_dev_fd=${bash_cv_dev_fd=absent} +bash_cv_dirent_has_d_fileno=${bash_cv_dirent_has_d_fileno=no} +bash_cv_dirent_has_dino=${bash_cv_dirent_has_dino=yes} +bash_cv_dup2_broken=${bash_cv_dup2_broken=no} +bash_cv_fionread_in_ioctl=${bash_cv_fionread_in_ioctl=yes} +bash_cv_func_lstat=${bash_cv_func_lstat=no} +bash_cv_func_sigsetjmp=${bash_cv_func_sigsetjmp=present} +bash_cv_func_strcoll_broken=${bash_cv_func_strcoll_broken=no} +bash_cv_getcwd_calls_popen=${bash_cv_getcwd_calls_popen=no} +bash_cv_getenv_redef=${bash_cv_getenv_redef=yes} +bash_cv_have_strsignal=${bash_cv_have_strsignal=yes} +bash_cv_job_control_missing=${bash_cv_job_control_missing=present} +bash_cv_mail_dir=${bash_cv_mail_dir=/usr/spool/mail} +bash_cv_must_reinstall_sighandlers=${bash_cv_must_reinstall_sighandlers=no} +bash_cv_opendir_not_robust=${bash_cv_opendir_not_robust=no} +bash_cv_pgrp_pipe=${bash_cv_pgrp_pipe=no} +bash_cv_printf_declared=${bash_cv_printf_declared=yes} +bash_cv_sbrk_declared=${bash_cv_sbrk_declared=no} +bash_cv_signal_vintage=${bash_cv_signal_vintage=posix} +bash_cv_speed_t_in_sys_types=${bash_cv_speed_t_in_sys_types=no} +bash_cv_struct_timeval=${bash_cv_struct_timeval=yes} +bash_cv_struct_winsize_header=${bash_cv_struct_winsize_header=ioctl_h} +bash_cv_struct_winsize_in_ioctl=${bash_cv_struct_winsize_in_ioctl=yes} +bash_cv_sys_errlist=${bash_cv_sys_errlist=yes} +bash_cv_sys_named_pipes=${bash_cv_sys_named_pipes=present} +bash_cv_sys_siglist=${bash_cv_sys_siglist=yes} +bash_cv_termcap_lib=${bash_cv_termcap_lib=libtermcap} +bash_cv_termio_ldisc=${bash_cv_termio_ldisc=no} +bash_cv_termios_ldisc=${bash_cv_termios_ldisc=no} +bash_cv_tiocgwinsz_in_ioctl=${bash_cv_tiocgwinsz_in_ioctl=yes} +bash_cv_tiocstat_in_ioctl=${bash_cv_tiocstat_in_ioctl=no} +bash_cv_type_clock_t=${bash_cv_type_clock_t=yes} +bash_cv_type_quad_t=${bash_cv_type_quad_t=yes} +bash_cv_type_rlimit=${bash_cv_type_rlimit=long} +bash_cv_type_sigset_t=${bash_cv_type_sigset_t=yes} +bash_cv_ulimit_maxfds=${bash_cv_ulimit_maxfds=no} +bash_cv_under_sys_siglist=${bash_cv_under_sys_siglist=no} +bash_cv_void_sighandler=${bash_cv_void_sighandler=yes} diff --git a/cross-build/x86-beos.cache b/cross-build/x86-beos.cache new file mode 100644 index 0000000..351aa21 --- /dev/null +++ b/cross-build/x86-beos.cache @@ -0,0 +1,45 @@ +# This file is a shell script that caches the results of configure +# tests for x86 BeOS so they don't need to be done when cross-compiling. + +# AC_FUNC_GETPGRP should also define GETPGRP_VOID +ac_cv_func_getpgrp_void=${ac_cv_func_getpgrp_void='yes'} +# AC_FUNC_SETVBUF_REVERSED should not define anything else +ac_cv_func_setvbuf_reversed=${ac_cv_func_setvbuf_reversed='no'} +# on BeOS, system calls do not restart +ac_cv_sys_restartable_syscalls=${ac_cv_sys_restartable_syscalls='no'} +bash_cv_sys_restartable_syscalls=${bash_cv_sys_restartable_syscalls='no'} + +ac_cv_func_tcgetattr=${ac_cv_func_tcgetattr='yes'} + +# x86 BeOS is little endian +ac_cv_c_bigendian=${ac_cv_c_bigendian='no'} +ac_cv_sizeof_char_p=${ac_cv_sizeof_char_p='4'} +ac_cv_sizeof_int=${ac_cv_sizeof_int='4'} +ac_cv_sizeof_long=${ac_cv_sizeof_long='4'} +ac_cv_sizeof_double=${ac_cv_sizeof_double='8'} + +bash_cv_dev_fd=${bash_cv_dev_fd='absent'} +bash_cv_dup2_broken=${bash_cv_dup2_broken='no'} +bash_cv_pgrp_pipe=${bash_cv_pgrp_pipe='no'} +bash_cv_type_rlimit=${bash_cv_type_rlimit='long'} +bash_cv_decl_under_sys_siglist=${bash_cv_decl_under_sys_siglist='no'} +bash_cv_under_sys_siglist=${bash_cv_under_sys_siglist='no'} +bash_cv_sys_siglist=${bash_cv_sys_siglist='yes'} +bash_cv_opendir_not_robust=${bash_cv_opendir_not_robust='no'} +bash_cv_getenv_redef=${bash_cv_getenv_redef='yes'} +bash_cv_printf_declared=${bash_cv_printf_declared='yes'} +bash_cv_ulimit_maxfds=${bash_cv_ulimit_maxfds='no'} +bash_cv_getcwd_calls_popen=${bash_cv_getcwd_calls_popen='no'} +bash_cv_must_reinstall_sighandlers=${bash_cv_must_reinstall_sighandlers='no'} +bash_cv_job_control_missing=${bash_cv_job_control_missing='present'} +bash_cv_sys_named_pipes=${bash_cv_sys_named_pipes='present'} +bash_cv_func_sigsetjmp=${bash_cv_func_sigsetjmp='missing'} +bash_cv_mail_dir=${bash_cv_mail_dir='unknown'} +bash_cv_func_strcoll_broken=${bash_cv_func_strcoll_broken='no'} + +bash_cv_type_int32_t=${bash_cv_type_int32_t='int'} +bash_cv_type_u_int32_t=${bash_cv_type_u_int32_t='int'} + +ac_cv_type_bits64_t=${ac_cv_type_bits64_t='no'} + +# end of cross-build/x86-beos.cache diff --git a/dispose_cmd.c b/dispose_cmd.c new file mode 100644 index 0000000..c624605 --- /dev/null +++ b/dispose_cmd.c @@ -0,0 +1,342 @@ +/* dispose_command.c -- dispose of a COMMAND structure. */ + +/* Copyright (C) 1987-2009 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 3 of the License, 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. If not, see . +*/ + +#include "config.h" + +#include "bashtypes.h" + +#if defined (HAVE_UNISTD_H) +# include +#endif + +#include "bashansi.h" +#include "shell.h" + +extern sh_obj_cache_t wdcache, wlcache; + +/* Dispose of the command structure passed. */ +void +dispose_command (command) + COMMAND *command; +{ + if (command == 0) + return; + + if (command->redirects) + dispose_redirects (command->redirects); + + switch (command->type) + { + case cm_for: +#if defined (SELECT_COMMAND) + case cm_select: +#endif + { + register FOR_COM *c; +#if defined (SELECT_COMMAND) + if (command->type == cm_select) + c = (FOR_COM *)command->value.Select; + else +#endif + c = command->value.For; + dispose_word (c->name); + dispose_words (c->map_list); + dispose_command (c->action); + free (c); + break; + } + +#if defined (ARITH_FOR_COMMAND) + case cm_arith_for: + { + register ARITH_FOR_COM *c; + + c = command->value.ArithFor; + dispose_words (c->init); + dispose_words (c->test); + dispose_words (c->step); + dispose_command (c->action); + free (c); + break; + } +#endif /* ARITH_FOR_COMMAND */ + + case cm_group: + { + dispose_command (command->value.Group->command); + free (command->value.Group); + break; + } + + case cm_subshell: + { + dispose_command (command->value.Subshell->command); + free (command->value.Subshell); + break; + } + + case cm_coproc: + { + free (command->value.Coproc->name); + dispose_command (command->value.Coproc->command); + free (command->value.Coproc); + break; + } + + case cm_case: + { + register CASE_COM *c; + PATTERN_LIST *t, *p; + + c = command->value.Case; + dispose_word (c->word); + + for (p = c->clauses; p; ) + { + dispose_words (p->patterns); + dispose_command (p->action); + t = p; + p = p->next; + free (t); + } + free (c); + break; + } + + case cm_until: + case cm_while: + { + register WHILE_COM *c; + + c = command->value.While; + dispose_command (c->test); + dispose_command (c->action); + free (c); + break; + } + + case cm_if: + { + register IF_COM *c; + + c = command->value.If; + dispose_command (c->test); + dispose_command (c->true_case); + dispose_command (c->false_case); + free (c); + break; + } + + case cm_simple: + { + register SIMPLE_COM *c; + + c = command->value.Simple; + dispose_words (c->words); + dispose_redirects (c->redirects); + free (c); + break; + } + + case cm_connection: + { + register CONNECTION *c; + + c = command->value.Connection; + dispose_command (c->first); + dispose_command (c->second); + free (c); + break; + } + +#if defined (DPAREN_ARITHMETIC) + case cm_arith: + { + register ARITH_COM *c; + + c = command->value.Arith; + dispose_words (c->exp); + free (c); + break; + } +#endif /* DPAREN_ARITHMETIC */ + +#if defined (COND_COMMAND) + case cm_cond: + { + register COND_COM *c; + + c = command->value.Cond; + dispose_cond_node (c); + break; + } +#endif /* COND_COMMAND */ + + case cm_function_def: + { + register FUNCTION_DEF *c; + + c = command->value.Function_def; + dispose_function_def (c); + break; + } + + default: + command_error ("dispose_command", CMDERR_BADTYPE, command->type, 0); + break; + } + free (command); +} + +#if defined (COND_COMMAND) +/* How to free a node in a conditional command. */ +void +dispose_cond_node (cond) + COND_COM *cond; +{ + if (cond) + { + if (cond->left) + dispose_cond_node (cond->left); + if (cond->right) + dispose_cond_node (cond->right); + if (cond->op) + dispose_word (cond->op); + free (cond); + } +} +#endif /* COND_COMMAND */ + +void +dispose_function_def_contents (c) + FUNCTION_DEF *c; +{ + dispose_word (c->name); + dispose_command (c->command); + FREE (c->source_file); +} + +void +dispose_function_def (c) + FUNCTION_DEF *c; +{ + dispose_function_def_contents (c); + free (c); +} + +/* How to free a WORD_DESC. */ +void +dispose_word (w) + WORD_DESC *w; +{ + FREE (w->word); + ocache_free (wdcache, WORD_DESC, w); +} + +/* Free a WORD_DESC, but not the word contained within. */ +void +dispose_word_desc (w) + WORD_DESC *w; +{ + w->word = 0; + ocache_free (wdcache, WORD_DESC, w); +} + +/* How to get rid of a linked list of words. A WORD_LIST. */ +void +dispose_words (list) + WORD_LIST *list; +{ + WORD_LIST *t; + + while (list) + { + t = list; + list = list->next; + dispose_word (t->word); +#if 0 + free (t); +#else + ocache_free (wlcache, WORD_LIST, t); +#endif + } +} + +#ifdef INCLUDE_UNUSED +/* How to dispose of an array of pointers to char. This is identical to + free_array in stringlib.c. */ +void +dispose_word_array (array) + char **array; +{ + register int count; + + if (array == 0) + return; + + for (count = 0; array[count]; count++) + free (array[count]); + + free (array); +} +#endif + +/* How to dispose of an list of redirections. A REDIRECT. */ +void +dispose_redirects (list) + REDIRECT *list; +{ + register REDIRECT *t; + + while (list) + { + t = list; + list = list->next; + + if (t->rflags & REDIR_VARASSIGN) + dispose_word (t->redirector.filename); + + switch (t->instruction) + { + case r_reading_until: + case r_deblank_reading_until: + free (t->here_doc_eof); + /*FALLTHROUGH*/ + case r_reading_string: + case r_output_direction: + case r_input_direction: + case r_inputa_direction: + case r_appending_to: + case r_err_and_out: + case r_append_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: + dispose_word (t->redirectee.filename); + /* FALLTHROUGH */ + default: + break; + } + free (t); + } +} diff --git a/dispose_cmd.h b/dispose_cmd.h new file mode 100644 index 0000000..0a3889c --- /dev/null +++ b/dispose_cmd.h @@ -0,0 +1,40 @@ +/* dispose_cmd.h -- Functions appearing in dispose_cmd.c. */ + +/* Copyright (C) 1993-2009 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 3 of the License, 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. If not, see . +*/ + +#if !defined (_DISPOSE_CMD_H_) +#define _DISPOSE_CMD_H_ + +#include "stdc.h" + +extern void dispose_command __P((COMMAND *)); +extern void dispose_word_desc __P((WORD_DESC *)); +extern void dispose_word __P((WORD_DESC *)); +extern void dispose_words __P((WORD_LIST *)); +extern void dispose_word_array __P((char **)); +extern void dispose_redirects __P((REDIRECT *)); + +#if defined (COND_COMMAND) +extern void dispose_cond_node __P((COND_COM *)); +#endif + +extern void dispose_function_def_contents __P((FUNCTION_DEF *)); +extern void dispose_function_def __P((FUNCTION_DEF *)); + +#endif /* !_DISPOSE_CMD_H_ */ diff --git a/doc/FAQ b/doc/FAQ new file mode 100644 index 0000000..87dbb2d --- /dev/null +++ b/doc/FAQ @@ -0,0 +1,2420 @@ +This is the Bash FAQ, version 4.14, for Bash version 4.4. + +[THIS FAQ IS NO LONGER MAINTAINED] + +This document contains a set of frequently-asked questions concerning +Bash, the GNU Bourne-Again Shell. Bash is a freely-available command +interpreter with advanced features for both interactive use and shell +programming. + +Another good source of basic information about shells is the collection +of FAQ articles periodically posted to comp.unix.shell. + +Questions and comments concerning this document should be sent to +chet.ramey@case.edu. + +This document is available for anonymous FTP with the URL + +ftp://ftp.cwru.edu/pub/bash/FAQ + +The Bash home page is http://cnswww.cns.cwru.edu/~chet/bash/bashtop.html + +---------- +Contents: + +Section A: The Basics + +A1) What is it? +A2) What's the latest version? +A3) Where can I get it? +A4) On what machines will bash run? +A5) Will bash run on operating systems other than Unix? +A6) How can I build bash with gcc? +A7) How can I make bash my login shell? +A8) I just changed my login shell to bash, and now I can't FTP into my + machine. Why not? +A9) What's the `POSIX Shell and Utilities standard'? +A10) What is the bash `posix mode'? + +Section B: The latest version + +B1) What's new in version 4.3? +B2) Are there any user-visible incompatibilities between bash-4.3 and + previous bash versions? + +Section C: Differences from other Unix shells + +C1) How does bash differ from sh, the Bourne shell? +C2) How does bash differ from the Korn shell, version ksh88? +C3) Which new features in ksh-93 are not in bash, and which are? + +Section D: Why does bash do some things differently than other Unix shells? + +D1) Why does bash run a different version of `command' than + `which command' says it will? +D2) Why doesn't bash treat brace expansions exactly like csh? +D3) Why doesn't bash have csh variable modifiers? +D4) How can I make my csh aliases work when I convert to bash? +D5) How can I pipe standard output and standard error from one command to + another, like csh does with `|&'? +D6) Now that I've converted from ksh to bash, are there equivalents to + ksh features like autoloaded functions and the `whence' command? + +Section E: Why does bash do certain things the way it does? + +E1) Why is the bash builtin `test' slightly different from /bin/test? +E2) Why does bash sometimes say `Broken pipe'? +E3) When I have terminal escape sequences in my prompt, why does bash + wrap lines at the wrong column? +E4) If I pipe the output of a command into `read variable', why doesn't + the output show up in $variable when the read command finishes? +E5) I have a bunch of shell scripts that use backslash-escaped characters + in arguments to `echo'. Bash doesn't interpret these characters. Why + not, and how can I make it understand them? +E6) Why doesn't a while or for loop get suspended when I type ^Z? +E7) What about empty for loops in Makefiles? +E8) Why does the arithmetic evaluation code complain about `08'? +E9) Why does the pattern matching expression [A-Z]* match files beginning + with every letter except `z'? +E10) Why does `cd //' leave $PWD as `//'? +E11) If I resize my xterm while another program is running, why doesn't bash + notice the change? +E12) Why don't negative offsets in substring expansion work like I expect? +E13) Why does filename completion misbehave if a colon appears in the filename? +E14) Why does quoting the pattern argument to the regular expression matching + conditional operator (=~) cause matching to stop working? +E15) Tell me more about the shell compatibility level. + +Section F: Things to watch out for on certain Unix versions + +F1) Why can't I use command line editing in my `cmdtool'? +F2) I built bash on Solaris 2. Why do globbing expansions and filename + completion chop off the first few characters of each filename? +F3) Why does bash dump core after I interrupt username completion or + `~user' tilde expansion on a machine running NIS? +F4) I'm running SVR4.2. Why is the line erased every time I type `@'? +F5) Why does bash report syntax errors when my C News scripts use a + redirection before a subshell command? +F6) Why can't I use vi-mode editing on Red Hat Linux 6.1? +F7) Why do bash-2.05a and bash-2.05b fail to compile `printf.def' on + HP/UX 11.x? + +Section G: How can I get bash to do certain common things? + +G1) How can I get bash to read and display eight-bit characters? +G2) How do I write a function `x' to replace builtin command `x', but + still invoke the command from within the function? +G3) How can I find the value of a shell variable whose name is the value + of another shell variable? +G4) How can I make the bash `time' reserved word print timing output that + looks like the output from my system's /usr/bin/time? +G5) How do I get the current directory into my prompt? +G6) How can I rename "*.foo" to "*.bar"? +G7) How can I translate a filename from uppercase to lowercase? +G8) How can I write a filename expansion (globbing) pattern that will match + all files in the current directory except "." and ".."? + +Section H: Where do I go from here? + +H1) How do I report bugs in bash, and where should I look for fixes and + advice? +H2) What kind of bash documentation is there? +H3) What's coming in future versions? +H4) What's on the bash `wish list'? +H5) When will the next release appear? + +---------- +Section A: The Basics + +A1) What is it? + +Bash is a Unix command interpreter (shell). It is an implementation of +the Posix 1003.2 shell standard, and resembles the Korn and System V +shells. + +Bash contains a number of enhancements over those shells, both +for interactive use and shell programming. Features geared +toward interactive use include command line editing, command +history, job control, aliases, and prompt expansion. Programming +features include additional variable expansions, shell +arithmetic, and a number of variables and options to control +shell behavior. + +Bash was originally written by Brian Fox of the Free Software +Foundation. The current developer and maintainer is Chet Ramey +of Case Western Reserve University. + +A2) What's the latest version? + +The latest version is 4.3, first made available on 26 February, 2014. + +A3) Where can I get it? + +Bash is the GNU project's shell, and so is available from the +master GNU archive site, ftp.gnu.org, and its mirrors. The +latest version is also available for FTP from ftp.cwru.edu. +The following URLs tell how to get version 4.3: + +ftp://ftp.gnu.org/pub/gnu/bash/bash-4.3.tar.gz +ftp://ftp.cwru.edu/pub/bash/bash-4.3.tar.gz + +Formatted versions of the documentation are available with the URLs: + +ftp://ftp.gnu.org/pub/gnu/bash/bash-doc-4.3.tar.gz +ftp://ftp.cwru.edu/pub/bash/bash-doc-4.3.tar.gz + +Any patches for the current version are available with the URL: + +ftp://ftp.cwru.edu/pub/bash/bash-4.3-patches/ + +A4) On what machines will bash run? + +Bash has been ported to nearly every version of Unix. All you +should have to do to build it on a machine for which a port +exists is to type `configure' and then `make'. The build process +will attempt to discover the version of Unix you have and tailor +itself accordingly, using a script created by GNU autoconf. + +More information appears in the file `INSTALL' in the distribution. + +The Bash web page (http://cnswww.cns.cwru.edu/~chet/bash/bashtop.html) +explains how to obtain binary versions of bash for most of the major +commercial Unix systems. + +A5) Will bash run on operating systems other than Unix? + +Configuration specifics for Unix-like systems such as QNX and +LynxOS are included in the distribution. Bash-2.05 and later +versions should compile and run on Minix 2.0 (patches were +contributed), but I don't believe anyone has built bash-2.x on +earlier Minix versions yet. + +Bash has been ported to versions of Windows implementing the Win32 +programming interface. This includes Windows 95 and Windows NT. +The port was done by Cygnus Solutions (now part of Red Hat) as part +of their CYGWIN project. For more information about the project, see +http://www.cygwin.com/. + +Cygnus originally ported bash-1.14.7, and that port was part of their +early GNU-Win32 (the original name) releases. Cygnus has also done +ports of bash-3.2 and bash-4.0 to the CYGWIN environment, and both +are available as part of their current release. + +Bash-2.05b and later versions should require no local Cygnus changes to +build and run under CYGWIN. + +DJ Delorie has a port of bash-2.x which runs under MS-DOS, as part +of the DJGPP project. For more information on the project, see + +http://www.delorie.com/djgpp/ + +I have been told that the original DJGPP port was done by Daisuke Aoyama. + +Mark Elbrecht has sent me notice that bash-2.04 +is available for DJGPP V2. The files are available as: + +ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2gnu/bsh204b.zip binary +ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2gnu/bsh204d.zip documentation +ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2gnu/bsh204s.zip source + +Mark began to work with bash-2.05, but I don't know the current status. + +Bash-3.0 compiles and runs with no modifications under Microsoft's Services +for Unix (SFU), once known as Interix. I do not anticipate any problems +with building bash-4.2 and later, but will gladly accept any patches that +are needed. + +A6) How can I build bash with gcc? + +Bash configures to use gcc by default if it is available. Read the +file INSTALL in the distribution for more information. + +A7) How can I make bash my login shell? + +Some machines let you use `chsh' to change your login shell. Other +systems use `passwd -s' or `passwd -e'. If one of these works for +you, that's all you need. Note that many systems require the full +pathname to a shell to appear in /etc/shells before you can make it +your login shell. For this, you may need the assistance of your +friendly local system administrator. + +If you cannot do this, you can still use bash as your login shell, but +you need to perform some tricks. The basic idea is to add a command +to your login shell's startup file to replace your login shell with +bash. + +For example, if your login shell is csh or tcsh, and you have installed +bash in /usr/gnu/bin/bash, add the following line to ~/.login: + + if ( -f /usr/gnu/bin/bash ) exec /usr/gnu/bin/bash --login + +(the `--login' tells bash that it is a login shell). + +It's not a good idea to put this command into ~/.cshrc, because every +csh you run without the `-f' option, even ones started to run csh scripts, +reads that file. If you must put the command in ~/.cshrc, use something +like + + if ( $?prompt ) exec /usr/gnu/bin/bash --login + +to ensure that bash is exec'd only when the csh is interactive. + +If your login shell is sh or ksh, you have to do two things. + +First, create an empty file in your home directory named `.bash_profile'. +The existence of this file will prevent the exec'd bash from trying to +read ~/.profile, and re-execing itself over and over again. ~/.bash_profile +is the first file bash tries to read initialization commands from when +it is invoked as a login shell. + +Next, add a line similar to the above to ~/.profile: + + [ -f /usr/gnu/bin/bash ] && [ -x /usr/gnu/bin/bash ] && \ + exec /usr/gnu/bin/bash --login + +This will cause login shells to replace themselves with bash running as +a login shell. Once you have this working, you can copy your initialization +code from ~/.profile to ~/.bash_profile. + +I have received word that the recipe supplied above is insufficient for +machines running CDE. CDE has a maze of twisty little startup files, all +slightly different. + +If you cannot change your login shell in the password file to bash, you +will have to (apparently) live with CDE using the shell in the password +file to run its startup scripts. If you have changed your shell to bash, +there is code in the CDE startup files (on Solaris, at least) that attempts +to do the right thing. It is, however, often broken, and may require that +you use the $BASH_ENV trick described below. + +`dtterm' claims to use $SHELL as the default program to start, so if you +can change $SHELL in the CDE startup files, you should be able to use bash +in your terminal windows. + +Setting DTSOURCEPROFILE in ~/.dtprofile will cause the `Xsession' program +to read your login shell's startup files. You may be able to use bash for +the rest of the CDE programs by setting SHELL to bash in ~/.dtprofile as +well, but I have not tried this. + +You can use the above `exec' recipe to start bash when not logging in with +CDE by testing the value of the DT variable: + + if [ -n "$DT" ]; then + [ -f /usr/gnu/bin/bash ] && exec /usr/gnu/bin/bash --login + fi + +If CDE starts its shells non-interactively during login, the login shell +startup files (~/.profile, ~/.bash_profile) will not be sourced at login. +To get around this problem, append a line similar to the following to your +~/.dtprofile: + + BASH_ENV=${HOME}/.bash_profile ; export BASH_ENV + +and add the following line to the beginning of ~/.bash_profile: + + unset BASH_ENV + +A8) I just changed my login shell to bash, and now I can't FTP into my + machine. Why not? + +You must add the full pathname to bash to the file /etc/shells. As +noted in the answer to the previous question, many systems require +this before you can make bash your login shell. + +Most versions of ftpd use this file to prohibit `special' users +such as `uucp' and `news' from using FTP. + +A9) What's the `POSIX Shell and Utilities standard'? + +POSIX is a name originally coined by Richard Stallman for a +family of open system standards based on UNIX. There are a +number of aspects of UNIX under consideration for +standardization, from the basic system services at the system +call and C library level to applications and tools to system +administration and management. Each area of standardization is +assigned to a working group in the 1003 series. + +The POSIX Shell and Utilities standard was originally developed by +IEEE Working Group 1003.2 (POSIX.2). Today it has been merged with +the original 1003.1 Working Group and is maintained by the Austin +Group (a joint working group of the IEEE, The Open Group and +ISO/IEC SC22/WG15). Today the Shell and Utilities are a volume +within the set of documents that make up IEEE Std 1003.1-2001, and +thus now the former POSIX.2 (from 1992) is now part of the current +POSIX.1 standard (POSIX 1003.1-2001). + +The Shell and Utilities volume concentrates on the command +interpreter interface and utility programs commonly executed from +the command line or by other programs. The standard is freely +available on the web at http://www.UNIX-systems.org/version3/ . +Work continues at the Austin Group on maintenance issues; see +http://www.opengroup.org/austin/ to join the discussions. + +Bash is concerned with the aspects of the shell's behavior defined +by the POSIX Shell and Utilities volume. The shell command +language has of course been standardized, including the basic flow +control and program execution constructs, I/O redirection and +pipelining, argument handling, variable expansion, and quoting. + +The `special' builtins, which must be implemented as part of the +shell to provide the desired functionality, are specified as +being part of the shell; examples of these are `eval' and +`export'. Other utilities appear in the sections of POSIX not +devoted to the shell which are commonly (and in some cases must +be) implemented as builtin commands, such as `read' and `test'. +POSIX also specifies aspects of the shell's interactive +behavior as part of the UPE, including job control and command +line editing. Only vi-style line editing commands have been +standardized; emacs editing commands were left out due to +objections. + +The latest version of the POSIX Shell and Utilities standard is +available (now updated to the 2004 Edition) as part of the Single +UNIX Specification Version 3 at + +http://www.UNIX-systems.org/version3/ + +A10) What is the bash `posix mode'? + +Although bash is an implementation of the POSIX shell +specification, there are areas where the bash default behavior +differs from that spec. The bash `posix mode' changes the bash +behavior in these areas so that it obeys the spec more closely. + +Posix mode is entered by starting bash with the --posix or +'-o posix' option or executing `set -o posix' after bash is running. + +The specific aspects of bash which change when posix mode is +active are listed in the file POSIX in the bash distribution. +They are also listed in a section in the Bash Reference Manual +(from which that file is generated). + +Section B: The latest version + +B1) What's new in version 4.3? + +Bash-4.3 is the third revision to the fourth major release of bash. + +Bash-4.3 contains the following new features (see the manual page for +complete descriptions and the CHANGES and NEWS files in the bash-4.3 +distribution): + +o The `helptopic' completion action now maps to all the help topics, not just + the shell builtins. + +o The `help' builtin no longer does prefix substring matching first, so + `help read' does not match `readonly', but will do it if exact string + matching fails. + +o The shell can be compiled to not display a message about processes that + terminate due to SIGTERM. + +o Non-interactive shells now react to the setting of checkwinsize and set + LINES and COLUMNS after a foreground job exits. + +o There is a new shell option, `globasciiranges', which, when set to on, + forces globbing range comparisons to use character ordering as if they + were run in the C locale. + +o There is a new shell option, `direxpand', which makes filename completion + expand variables in directory names in the way bash-4.1 did. + +o In Posix mode, the `command' builtin does not change whether or not a + builtin it shadows is treated as an assignment builtin. + +o The `return' and `exit' builtins accept negative exit status arguments. + +o The word completion code checks whether or not a filename containing a + shell variable expands to a directory name and appends `/' to the word + as appropriate. The same code expands shell variables in command names + when performing command completion. + +o In Posix mode, it is now an error to attempt to define a shell function + with the same name as a Posix special builtin. + +o When compiled for strict Posix conformance, history expansion is disabled + by default. + +o The history expansion character (!) does not cause history expansion when + followed by the closing quote in a double-quoted string. + +o `complete' and its siblings compgen/compopt now takes a new `-o noquote' + option to inhibit quoting of the completions. + +o Setting HISTSIZE to a value less than zero causes the history list to be + unlimited (setting it 0 zero disables the history list). + +o Setting HISTFILESIZE to a value less than zero causes the history file size + to be unlimited (setting it to 0 causes the history file to be truncated + to zero size). + +o The `read' builtin now skips NUL bytes in the input. + +o There is a new `bind -X' option to print all key sequences bound to Unix + commands. + +o When in Posix mode, `read' is interruptible by a trapped signal. After + running the trap handler, read returns 128+signal and throws away any + partially-read input. + +o The command completion code skips whitespace and assignment statements + before looking for the command name word to be completed. + +o The build process has a new mechanism for constructing separate help files + that better reflects the current set of compilation options. + +o The -nt and -ot options to test now work with files with nanosecond + timestamp resolution. + +o The shell saves the command history in any shell for which history is + enabled and HISTFILE is set, not just interactive shells. + +o The shell has `nameref' variables and new -n(/+n) options to declare and + unset to use them, and a `test -R' option to test for them. + +o The shell now allows assigning, referencing, and unsetting elements of + indexed arrays using negative subscripts (a[-1]=2, echo ${a[-1]}) which + count back from the last element of the array. + +o The {x} operators to the [[ conditional command now do string + comparison according to the current locale. + +o Programmable completion now uses the completion for `b' instead of `a' + when completion is attempted on a line like: a $(b c. + +o Force extglob on temporarily when parsing the pattern argument to + the == and != operators to the [[ command, for compatibility. + +o Changed the behavior of interrupting the wait builtin when a SIGCHLD is + received and a trap on SIGCHLD is set to be Posix-mode only. + +o The read builtin has a new `-N nchars' option, which reads exactly NCHARS + characters, ignoring delimiters like newline. + +o The mapfile/readarray builtin no longer stores the commands it invokes via + callbacks in the history list. + +o There is a new `compat40' shopt option. + +o The < and > operators to [[ do string comparisons using the current locale + only if the compatibility level is greater than 40 (set to 41 by default). + +o New bindable readline function: menu-complete-backward. + +o In the readline vi-mode insertion keymap, C-n is now bound to menu-complete + by default, and C-p to menu-complete-backward. + +o When in readline vi command mode, repeatedly hitting ESC now does nothing, + even when ESC introduces a bound key sequence. This is closer to how + historical vi behaves. + +o New bindable readline function: skip-csi-sequence. Can be used as a + default to consume key sequences generated by keys like Home and End + without having to bind all keys. + +o New bindable readline variable: skip-completed-text, active when + completing in the middle of a word. If enabled, it means that characters + in the completion that match characters in the remainder of the word are + "skipped" rather than inserted into the line. + +o The pre-readline-6.0 version of menu completion is available as + "old-menu-complete" for users who do not like the readline-6.0 version. + +o New bindable readline variable: echo-control-characters. If enabled, and + the tty ECHOCTL bit is set, controls the echoing of characters + corresponding to keyboard-generated signals. + +o New bindable readline variable: enable-meta-key. Controls whether or not + readline sends the smm/rmm sequences if the terminal indicates it has a + meta key that enables eight-bit characters. + +Bash-4.0 contained the following new features: + +o When using substring expansion on the positional parameters, a starting + index of 0 now causes $0 to be prefixed to the list. + +o There is a new variable, $BASHPID, which always returns the process id of + the current shell. + +o There is a new `autocd' option that, when enabled, causes bash to attempt + to `cd' to a directory name that is supplied as the first word of a + simple command. + +o There is a new `checkjobs' option that causes the shell to check for and + report any running or stopped jobs at exit. + +o The programmable completion code exports a new COMP_TYPE variable, set to + a character describing the type of completion being attempted. + +o The programmable completion code exports a new COMP_KEY variable, set to + the character that caused the completion to be invoked (e.g., TAB). + +o The programmable completion code now uses the same set of characters as + readline when breaking the command line into a list of words. + +o The block multiplier for the ulimit -c and -f options is now 512 when in + Posix mode, as Posix specifies. + +o Changed the behavior of the read builtin to save any partial input received + in the specified variable when the read builtin times out. This also + results in variables specified as arguments to read to be set to the empty + string when there is no input available. When the read builtin times out, + it returns an exit status greater than 128. + +o The shell now has the notion of a `compatibility level', controlled by + new variables settable by `shopt'. Setting this variable currently + restores the bash-3.1 behavior when processing quoted strings on the rhs + of the `=~' operator to the `[[' command. + +o The `ulimit' builtin now has new -b (socket buffer size) and -T (number + of threads) options. + +o There is a new `compopt' builtin that allows completion functions to modify + completion options for existing completions or the completion currently + being executed. + +o The `read' builtin has a new -i option which inserts text into the reply + buffer when using readline. + +o A new `-E' option to the complete builtin allows control of the default + behavior for completion on an empty line. + +o There is now limited support for completing command name words containing + globbing characters. + +o The `help' builtin now has a new -d option, to display a short description, + and a -m option, to print help information in a man page-like format. + +o There is a new `mapfile' builtin to populate an array with lines from a + given file. + +o If a command is not found, the shell attempts to execute a shell function + named `command_not_found_handle', supplying the command words as the + function arguments. + +o There is a new shell option: `globstar'. When enabled, the globbing code + treats `**' specially -- it matches all directories (and files within + them, when appropriate) recursively. + +o There is a new shell option: `dirspell'. When enabled, the filename + completion code performs spelling correction on directory names during + completion. + +o The `-t' option to the `read' builtin now supports fractional timeout + values. + +o Brace expansion now allows zero-padding of expanded numeric values and + will add the proper number of zeroes to make sure all values contain the + same number of digits. + +o There is a new bash-specific bindable readline function: `dabbrev-expand'. + It uses menu completion on a set of words taken from the history list. + +o The command assigned to a key sequence with `bind -x' now sets two new + variables in the environment of the executed command: READLINE_LINE_BUFFER + and READLINE_POINT. The command can change the current readline line + and cursor position by modifying READLINE_LINE_BUFFER and READLINE_POINT, + respectively. + +o There is a new >>& redirection operator, which appends the standard output + and standard error to the named file. + +o The parser now understands `|&' as a synonym for `2>&1 |', which redirects + the standard error for a command through a pipe. + +o The new `;&' case statement action list terminator causes execution to + continue with the action associated with the next pattern in the + statement rather than terminating the command. + +o The new `;;&' case statement action list terminator causes the shell to + test the next set of patterns after completing execution of the current + action, rather than terminating the command. + +o The shell understands a new variable: PROMPT_DIRTRIM. When set to an + integer value greater than zero, prompt expansion of \w and \W will + retain only that number of trailing pathname components and replace + the intervening characters with `...'. + +o There are new case-modifying word expansions: uppercase (^[^]) and + lowercase (,[,]). They can work on either the first character or + array element, or globally. They accept an optional shell pattern + that determines which characters to modify. There is an optionally- + configured feature to include capitalization operators. + +o The shell provides associative array variables, with the appropriate + support to create, delete, assign values to, and expand them. + +o The `declare' builtin now has new -l (convert value to lowercase upon + assignment) and -u (convert value to uppercase upon assignment) options. + There is an optionally-configurable -c option to capitalize a value at + assignment. + +o There is a new `coproc' reserved word that specifies a coprocess: an + asynchronous command run with two pipes connected to the creating shell. + Coprocs can be named. The input and output file descriptors and the + PID of the coprocess are available to the calling shell in variables + with coproc-specific names. + +o A value of 0 for the -t option to `read' now returns success if there is + input available to be read from the specified file descriptor. + +o CDPATH and GLOBIGNORE are ignored when the shell is running in privileged + mode. + +o New bindable readline functions shell-forward-word and shell-backward-word, + which move forward and backward words delimited by shell metacharacters + and honor shell quoting. + +o New bindable readline functions shell-backward-kill-word and shell-kill-word + which kill words backward and forward, but use the same word boundaries + as shell-forward-word and shell-backward-word. + +Bash-3.2 contained the following new features: + +o Bash-3.2 now checks shell scripts for NUL characters rather than non-printing + characters when deciding whether or not a script is a binary file. + +o Quoting the string argument to the [[ command's =~ (regexp) operator now + forces string matching, as with the other pattern-matching operators. + +Bash-3.1 contained the following new features: + +o Bash-3.1 may now be configured and built in a mode that enforces strict + POSIX compliance. + +o The `+=' assignment operator, which appends to the value of a string or + array variable, has been implemented. + +o It is now possible to ignore case when matching in contexts other than + filename generation using the new `nocasematch' shell option. + +Bash-3.0 contained the following new features: + +o Features to support the bash debugger have been implemented, and there + is a new `extdebug' option to turn the non-default options on + +o HISTCONTROL is now a colon-separated list of options and has been + extended with a new `erasedups' option that will result in only one + copy of a command being kept in the history list + +o Brace expansion has been extended with a new {x..y} form, producing + sequences of digits or characters + +o Timestamps are now kept with history entries, with an option to save + and restore them from the history file; there is a new HISTTIMEFORMAT + variable describing how to display the timestamps when listing history + entries + +o The `[[' command can now perform extended regular expression (egrep-like) + matching, with matched subexpressions placed in the BASH_REMATCH array + variable + +o A new `pipefail' option causes a pipeline to return a failure status if + any command in it fails + +o The `jobs', `kill', and `wait' builtins now accept job control notation + in their arguments even if job control is not enabled + +o The `gettext' package and libintl have been integrated, and the shell + messages may be translated into other languages + +Bash-2.05b introduced the following new features: + +o support for multibyte characters has been added to both bash and readline + +o the DEBUG trap is now run *before* simple commands, ((...)) commands, + [[...]] conditional commands, and for ((...)) loops + +o the shell now performs arithmetic in the largest integer size the machine + supports (intmax_t) + +o there is a new \D{...} prompt expansion; passes the `...' to strftime(3) + and inserts the result into the expanded prompt + +o there is a new `here-string' redirection operator: <<< word + +o when displaying variables, function attributes and definitions are shown + separately, allowing them to be re-used as input (attempting to re-use + the old output would result in syntax errors). + +o `read' has a new `-u fd' option to read from a specified file descriptor + +o the bash debugger in examples/bashdb has been modified to work with the + new DEBUG trap semantics, the command set has been made more gdb-like, + and the changes to $LINENO make debugging functions work better + +o the expansion of $LINENO inside a shell function is only relative to the + function start if the shell is interactive -- if the shell is running a + script, $LINENO expands to the line number in the script. This is as + POSIX-2001 requires + +Bash-2.05a introduced the following new features: + +o The `printf' builtin has undergone major work + +o There is a new read-only `shopt' option: login_shell, which is set by + login shells and unset otherwise + +o New `\A' prompt string escape sequence; expanding to time in 24-hour + HH:MM format + +o New `-A group/-g' option to complete and compgen; goes group name + completion + +o New [+-]O invocation option to set and unset `shopt' options at startup + +o ksh-like `ERR' trap + +o `for' loops now allow empty word lists after the `in' reserved word + +o new `hard' and `soft' arguments for the `ulimit' builtin + +o Readline can be configured to place the user at the same point on the line + when retrieving commands from the history list + +o Readline can be configured to skip `hidden' files (filenames with a leading + `.' on Unix) when performing completion + +Bash-2.05 introduced the following new features: + +o This version has once again reverted to using locales and strcoll(3) when + processing pattern matching bracket expressions, as POSIX requires. +o Added a new `--init-file' invocation argument as a synonym for `--rcfile', + per the new GNU coding standards. +o The /dev/tcp and /dev/udp redirections now accept service names as well as + port numbers. +o `complete' and `compgen' now take a `-o value' option, which controls some + of the aspects of that compspec. Valid values are: + + default - perform bash default completion if programmable + completion produces no matches + dirnames - perform directory name completion if programmable + completion produces no matches + filenames - tell readline that the compspec produces filenames, + so it can do things like append slashes to + directory names and suppress trailing spaces +o A new loadable builtin, realpath, which canonicalizes and expands symlinks + in pathname arguments. +o When `set' is called without options, it prints function defintions in a + way that allows them to be reused as input. This affects `declare' and + `declare -p' as well. This only happens when the shell is not in POSIX + mode, since POSIX.2 forbids this behavior. + +Bash-2.04 introduced the following new features: + +o Programmable word completion with the new `complete' and `compgen' builtins; + examples are provided in examples/complete/complete-examples +o `history' has a new `-d' option to delete a history entry +o `bind' has a new `-x' option to bind key sequences to shell commands +o The prompt expansion code has new `\j' and `\l' escape sequences +o The `no_empty_cmd_completion' shell option, if enabled, inhibits + command completion when TAB is typed on an empty line +o `help' has a new `-s' option to print a usage synopsis +o New arithmetic operators: var++, var--, ++var, --var, expr1,expr2 (comma) +o New ksh93-style arithmetic for command: + for ((expr1 ; expr2; expr3 )); do list; done +o `read' has new options: `-t', `-n', `-d', `-s' +o The redirection code handles several filenames specially: /dev/fd/N, + /dev/stdin, /dev/stdout, /dev/stderr +o The redirection code now recognizes /dev/tcp/HOST/PORT and + /dev/udp/HOST/PORT and tries to open a TCP or UDP socket, respectively, + to the specified port on the specified host +o The ${!prefix*} expansion has been implemented +o A new FUNCNAME variable, which expands to the name of a currently-executing + function +o The GROUPS variable is no longer readonly +o A new shopt `xpg_echo' variable, to control the behavior of echo with + respect to backslash-escape sequences at runtime +o The NON_INTERACTIVE_LOGIN_SHELLS #define has returned + +The version of Readline released with Bash-2.04, Readline-4.1, had several +new features as well: + +o Parentheses matching is always compiled into readline, and controllable + with the new `blink-matching-paren' variable +o The history-search-forward and history-search-backward functions now leave + point at the end of the line when the search string is empty, like + reverse-search-history, and forward-search-history +o A new function for applications: rl_on_new_line_with_prompt() +o New variables for applications: rl_already_prompted, and rl_gnu_readline_p + + +Bash-2.03 had very few new features, in keeping with the convention +that odd-numbered releases provide mainly bug fixes. A number of new +features were added to Readline, mostly at the request of the Cygnus +folks. + +A new shopt option, `restricted_shell', so that startup files can test + whether or not the shell was started in restricted mode +Filename generation is now performed on the words between ( and ) in + compound array assignments (this is really a bug fix) +OLDPWD is now auto-exported, as POSIX.2 requires +ENV and BASH_ENV are read-only variables in a restricted shell +Bash may now be linked against an already-installed Readline library, + as long as the Readline library is version 4 or newer +All shells begun with the `--login' option will source the login shell + startup files, even if the shell is not interactive + +There were lots of changes to the version of the Readline library released +along with Bash-2.03. For a complete list of the changes, read the file +CHANGES in the Bash-2.03 distribution. + +Bash-2.02 contained the following new features: + +a new version of malloc (based on the old GNU malloc code in previous + bash versions) that is more page-oriented, more conservative + with memory usage, does not `orphan' large blocks when they + are freed, is usable on 64-bit machines, and has allocation + checking turned on unconditionally +POSIX.2-style globbing character classes ([:alpha:], [:alnum:], etc.) +POSIX.2-style globbing equivalence classes +POSIX.2-style globbing collating symbols +the ksh [[...]] extended conditional command +the ksh egrep-style extended pattern matching operators +a new `printf' builtin +the ksh-like $(, &>, >|, <<<, [n]<&word-, [n]>&word-, >>& + prompt string special char translation and variable expansion + auto-export of variables in initial environment + command search finds functions before builtins + bash return builtin will exit a file sourced with `.' + builtins: cd -/-L/-P/-@, exec -l/-c/-a, echo -e/-E, hash -d/-l/-p/-t. + export -n/-f/-p/name=value, pwd -L/-P, + read -e/-p/-a/-t/-n/-d/-s/-u/-i/-N, + readonly -a/-f/name=value, trap -l, set +o, + set -b/-m/-o option/-h/-p/-B/-C/-H/-P, + unset -f/-n/-v, ulimit -i/-m/-p/-q/-u/-x, + type -a/-p/-t/-f/-P, suspend -f, kill -n, + test -o optname/s1 == s2/s1 < s2/s1 > s2/-nt/-ot/-ef/-O/-G/-S/-R + bash reads ~/.bashrc for interactive shells, $ENV for non-interactive + bash restricted shell mode is more extensive + bash allows functions and variables with the same name + brace expansion + tilde expansion + arithmetic expansion with $((...)) and `let' builtin + the `[[...]]' extended conditional command + process substitution + aliases and alias/unalias builtins + local variables in functions and `local' builtin + readline and command-line editing with programmable completion + command history and history/fc builtins + csh-like history expansion + other new bash builtins: bind, command, compgen, complete, builtin, + declare/typeset, dirs, enable, fc, help, + history, logout, popd, pushd, disown, shopt, + printf, compopt, mapfile + exported functions + filename generation when using output redirection (command >a*) + POSIX.2-style globbing character classes + POSIX.2-style globbing equivalence classes + POSIX.2-style globbing collating symbols + egrep-like extended pattern matching operators + case-insensitive pattern matching and globbing + variable assignments preceding commands affect only that command, + even for builtins and functions + posix mode and strict posix conformance + redirection to /dev/fd/N, /dev/stdin, /dev/stdout, /dev/stderr, + /dev/tcp/host/port, /dev/udp/host/port + debugger support, including `caller' builtin and new variables + RETURN trap + the `+=' assignment operator + autocd shell option and behavior + command-not-found hook with command_not_found_handle shell function + globstar shell option and `**' globbing behavior + |& synonym for `2>&1 |' + ;& and ;;& case action list terminators + case-modifying word expansions and variable attributes + associative arrays + coprocesses using the `coproc' reserved word and variables + shell assignment of a file descriptor used in a redirection to a variable + +Things sh has that bash does not: + uses variable SHACCT to do shell accounting + includes `stop' builtin (bash can use alias stop='kill -s STOP') + `newgrp' builtin + turns on job control if called as `jsh' + $TIMEOUT (like bash $TMOUT) + `^' is a synonym for `|' + new SVR4.2 sh builtins: mldmode, priv + +Implementation differences: + redirection to/from compound commands causes sh to create a subshell + bash does not allow unbalanced quotes; sh silently inserts them at EOF + bash does not mess with signal 11 + sh sets (euid, egid) to (uid, gid) if -p not supplied and uid < 100 + bash splits only the results of expansions on IFS, using POSIX.2 + field splitting rules; sh splits all words on IFS + sh does not allow MAILCHECK to be unset (?) + sh does not allow traps on SIGALRM or SIGCHLD + bash allows multiple option arguments when invoked (e.g. -x -v); + sh allows only a single option argument (`sh -x -v' attempts + to open a file named `-v', and, on SunOS 4.1.4, dumps core. + On Solaris 2.4 and earlier versions, sh goes into an infinite + loop.) + sh exits a script if any builtin fails; bash exits only if one of + the POSIX.2 `special' builtins fails + +C2) How does bash differ from the Korn shell, version ksh88? + +Things bash has or uses that ksh88 does not: + long invocation options + [-+]O invocation option + -l invocation option + `!' reserved word + arithmetic for command: for ((expr1 ; expr2; expr3 )); do list; done + arithmetic in largest machine-supported size (intmax_t) + posix mode and posix conformance + command hashing + tilde expansion for assignment statements that look like $PATH + process substitution with named pipes if /dev/fd is not available + the ${!param} indirect parameter expansion operator + the ${!param*} prefix expansion operator + the ${param:offset[:length]} parameter substring operator + the ${param/pat[/string]} parameter pattern substitution operator + variables: BASH, BASH_VERSION, BASH_VERSINFO, BASHPID, UID, EUID, SHLVL, + TIMEFORMAT, HISTCMD, HOSTTYPE, OSTYPE, MACHTYPE, + HISTFILESIZE, HISTIGNORE, HISTCONTROL, PROMPT_COMMAND, + IGNOREEOF, FIGNORE, INPUTRC, HOSTFILE, DIRSTACK, + PIPESTATUS, HOSTNAME, OPTERR, SHELLOPTS, GLOBIGNORE, + GROUPS, FUNCNAME, histchars, auto_resume, PROMPT_DIRTRIM + prompt expansion with backslash escapes and command substitution + redirection: &> (stdout and stderr), <<<, [n]<&word-, [n]>&word-, >>& + more extensive and extensible editing and programmable completion + builtins: bind, builtin, command, declare, dirs, echo -e/-E, enable, + exec -l/-c/-a, fc -s, export -n/-f/-p, hash, help, history, + jobs -x/-r/-s, kill -s/-n/-l, local, logout, popd, pushd, + read -e/-p/-a/-t/-n/-d/-s/-N, readonly -a/-n/-f/-p, + set -o braceexpand/-o histexpand/-o interactive-comments/ + -o notify/-o physical/-o posix/-o hashall/-o onecmd/ + -h/-B/-C/-b/-H/-P, set +o, suspend, trap -l, type, + typeset -a/-F/-p, ulimit -i/-q/-u/-x, umask -S, alias -p, + shopt, disown, printf, complete, compgen, compopt, mapfile + `!' csh-style history expansion + POSIX.2-style globbing character classes + POSIX.2-style globbing equivalence classes + POSIX.2-style globbing collating symbols + egrep-like extended pattern matching operators + case-insensitive pattern matching and globbing + `**' arithmetic operator to do exponentiation + redirection to /dev/fd/N, /dev/stdin, /dev/stdout, /dev/stderr + arrays of unlimited size + TMOUT is default timeout for `read' and `select' + debugger support, including the `caller' builtin + RETURN trap + Timestamps in history entries + {x..y} brace expansion + The `+=' assignment operator + autocd shell option and behavior + command-not-found hook with command_not_found_handle shell function + globstar shell option and `**' globbing behavior + |& synonym for `2>&1 |' + ;& and ;;& case action list terminators + case-modifying word expansions and variable attributes + associative arrays + coprocesses using the `coproc' reserved word and variables + shell assignment of a file descriptor used in a redirection to a variable + +Things ksh88 has or uses that bash does not: + tracked aliases (alias -t) + variables: ERRNO, FPATH, EDITOR, VISUAL + co-processes (bash uses different syntax) + weirdly-scoped functions + typeset +f to list all function names without definitions + text of command history kept in a file, not memory + builtins: alias -x, cd old new, newgrp, print, + read -p/-s/var?prompt, set -A/-o gmacs/ + -o bgnice/-o markdirs/-o trackall/-o viraw/-s, + typeset -H/-L/-R/-Z/-A/-ft/-fu/-fx/-t, whence + using environment to pass attributes of exported variables + arithmetic evaluation done on arguments to some builtins + reads .profile from $PWD when invoked as login shell + +Implementation differences: + ksh runs last command of a pipeline in parent shell context + bash has brace expansion by default (ksh88 compile-time option) + bash has fixed startup file for all interactive shells; ksh reads $ENV + bash has exported functions + bash command search finds functions before builtins + bash waits for all commands in pipeline to exit before returning status + emacs-mode editing has some slightly different key bindings + +C3) Which new features in ksh-93 are not in bash, and which are? + +This list is current through ksh93v (10/08/2013) + +New things in ksh-93 not in bash-4.3: + floating point arithmetic, variables, and constants + math library functions, including user-defined math functions + ${!name[sub]} name of subscript for associative array + `.' is allowed in variable names to create a hierarchical namespace + more extensive compound assignment syntax + discipline functions + KEYBD trap + variables: .sh.edchar, .sh.edmode, .sh.edcol, .sh.edtext, .sh.version, + .sh.name, .sh.subscript, .sh.value, .sh.match, HISTEDIT, + .sh.sig, .sh.stats, .sh.siginfo, .sh.pwdfd, .sh.op_astbin, + .sh.pool + backreferences in pattern matching (\N) + `&' operator in pattern lists for matching (match all instead of any) + exit statuses between 0 and 255 + FPATH and PATH mixing + lexical scoping for local variables in `ksh' functions + no scoping for local variables in `POSIX' functions + $'' \C[.collating-element.] escape sequence + -C/-I invocation options + print -f (bash uses printf) and rest of print builtin options + printf %(type)q, %#q + `fc' has been renamed to `hist' + `.' can execute shell functions + getopts -a + printf %B, %H, %P, %R, %Z modifiers, output base for %d, `=' flag + read -n/-N differ/-v/-S + set -o showme/-o multiline (bash default) + set -K + kill -Q/-q/-L + trap -a + `sleep' and `getconf' builtins (bash has loadable versions) + [[ -R name ]] (checks whether or not name is a nameref) + typeset -C/-S/-T/-X/-h/-s/-c/-M + experimental `type' definitions (a la typedef) using typeset + array expansions ${array[sub1..sub2]} and ${!array[sub1..sub2]} + associative array assignments using `;' as element separator + command substitution $(n<#) expands to current byte offset for fd N + new '${ ' form of command substitution, executed in current shell + new >;/<>;/<#pat/<##pat/<#/># redirections + brace expansion printf-like formats + CHLD trap triggered by SIGSTOP and SIGCONT + ~{fd} expansion, which replaces fd with the corresponding path name + $"string" expanded when referenced rather than when first parsed + job "pools", which allow a collection of jobs to be managed as a unit + +New things in ksh-93 present in bash-4.3: + associative arrays + [n]<&word- and [n]>&word- redirections (combination dup and close) + for (( expr1; expr2; expr3 )) ; do list; done - arithmetic for command + ?:, ++, --, `expr1 , expr2' arithmetic operators + expansions: ${!param}, ${param:offset[:len]}, ${param/pat[/str]}, + ${!param*} + compound array assignment + negative subscripts for indexed array variables + the `!' reserved word + loadable builtins -- but ksh uses `builtin' while bash uses `enable' + new $'...' and $"..." quoting + FIGNORE (but bash uses GLOBIGNORE), HISTCMD + brace expansion and set -B + changes to kill builtin + `command', `builtin', `disown' builtins + echo -e + exec -c/-a + printf %T modifier + read -A (bash uses read -a) + read -t/-d + trap -p + `.' restores the positional parameters when it completes + set -o notify/-C + set -o pipefail + set -G (-o globstar) and ** + POSIX.2 `test' + umask -S + unalias -a + command and arithmetic substitution performed on PS1, PS4, and ENV + command name completion, TAB displaying possible completions + ENV processed only for interactive shells + The `+=' assignment operator + the `;&' case statement "fallthrough" pattern list terminator + csh-style history expansion and set -H + negative offsets in ${param:offset:length} + redirection operators preceded with {varname} to store fd number in varname + DEBUG can force skipping following command + [[ -v var ]] operator (checks whether or not var is set) + typeset -n and `nameref' variables + process substitutions work without /dev/fd + +Section D: Why does bash do some things differently than other Unix shells? + +D1) Why does bash run a different version of `command' than + `which command' says it will? + +On many systems, `which' is actually a csh script that assumes +you're running csh. In tcsh, `which' and its cousin `where' +are builtins. On other Unix systems, `which' is a perl script +that uses the PATH environment variable. Many Linux distributions +use GNU `which', which is a C program that can understand shell +aliases. + +The csh script version reads the csh startup files from your +home directory and uses those to determine which `command' will +be invoked. Since bash doesn't use any of those startup files, +there's a good chance that your bash environment differs from +your csh environment. The bash `type' builtin does everything +`which' does, and will report correct results for the running +shell. If you're really wedded to the name `which', try adding +the following function definition to your .bashrc: + + which() + { + builtin type "$@" + } + +If you're moving from tcsh and would like to bring `where' along +as well, use this function: + + where() + { + builtin type -a "$@" + } + +D2) Why doesn't bash treat brace expansions exactly like csh? + +The only difference between bash and csh brace expansion is that +bash requires a brace expression to contain at least one unquoted +comma if it is to be expanded. Any brace-surrounded word not +containing an unquoted comma is left unchanged by the brace +expansion code. This affords the greatest degree of sh +compatibility. + +Bash, ksh, zsh, and pd-ksh all implement brace expansion this way. + +D3) Why doesn't bash have csh variable modifiers? + +Posix has specified a more powerful, albeit somewhat more cryptic, +mechanism cribbed from ksh, and bash implements it. + +${parameter%word} + Remove smallest suffix pattern. The WORD is expanded to produce + a pattern. It then expands to the value of PARAMETER, with the + smallest portion of the suffix matched by the pattern deleted. + + x=file.c + echo ${x%.c}.o + -->file.o + +${parameter%%word} + + Remove largest suffix pattern. The WORD is expanded to produce + a pattern. It then expands to the value of PARAMETER, with the + largest portion of the suffix matched by the pattern deleted. + + x=posix/src/std + echo ${x%%/*} + -->posix + +${parameter#word} + Remove smallest prefix pattern. The WORD is expanded to produce + a pattern. It then expands to the value of PARAMETER, with the + smallest portion of the prefix matched by the pattern deleted. + + x=$HOME/src/cmd + echo ${x#$HOME} + -->/src/cmd + +${parameter##word} + Remove largest prefix pattern. The WORD is expanded to produce + a pattern. It then expands to the value of PARAMETER, with the + largest portion of the prefix matched by the pattern deleted. + + x=/one/two/three + echo ${x##*/} + -->three + + +Given + a=/a/b/c/d + b=b.xxx + + csh bash result + --- ---- ------ + $a:h ${a%/*} /a/b/c + $a:t ${a##*/} d + $b:r ${b%.*} b + $b:e ${b##*.} xxx + + +D4) How can I make my csh aliases work when I convert to bash? + +Bash uses a different syntax to support aliases than csh does. +The details can be found in the documentation. We have provided +a shell script which does most of the work of conversion for you; +this script can be found in ./examples/misc/aliasconv.sh. Here is +how you use it: + +Start csh in the normal way for you. (e.g., `csh') + +Pipe the output of `alias' through `aliasconv.sh', saving the +results into `bash_aliases': + + alias | bash aliasconv.sh >bash_aliases + +Edit `bash_aliases', carefully reading through any created +functions. You will need to change the names of some csh specific +variables to the bash equivalents. The script converts $cwd to +$PWD, $term to $TERM, $home to $HOME, $user to $USER, and $prompt +to $PS1. You may also have to add quotes to avoid unwanted +expansion. + +For example, the csh alias: + + alias cd 'cd \!*; echo $cwd' + +is converted to the bash function: + + cd () { command cd "$@"; echo $PWD ; } + +The only thing that needs to be done is to quote $PWD: + + cd () { command cd "$@"; echo "$PWD" ; } + +Merge the edited file into your ~/.bashrc. + +There is an additional, more ambitious, script in +examples/misc/cshtobash that attempts to convert your entire csh +environment to its bash equivalent. This script can be run as +simply `cshtobash' to convert your normal interactive +environment, or as `cshtobash ~/.login' to convert your login +environment. + +D5) How can I pipe standard output and standard error from one command to + another, like csh does with `|&'? + +Use + command 2>&1 | command2 + +The key is to remember that piping is performed before redirection, so +file descriptor 1 points to the pipe when it is duplicated onto file +descriptor 2. + +D6) Now that I've converted from ksh to bash, are there equivalents to + ksh features like autoloaded functions and the `whence' command? + +There are features in ksh-88 and ksh-93 that do not have direct bash +equivalents. Most, however, can be emulated with very little trouble. + +ksh-88 feature Bash equivalent +-------------- --------------- +compiled-in aliases set up aliases in .bashrc; some ksh aliases are + bash builtins (hash, history, type) +coprocesses named pipe pairs (one for read, one for write) +typeset +f declare -F +cd, print, whence function substitutes in examples/functions/kshenv +autoloaded functions examples/functions/autoload is the same as typeset -fu +read var?prompt read -p prompt var + +ksh-93 feature Bash equivalent +-------------- --------------- +sleep, getconf Bash has loadable versions in examples/loadables +${.sh.version} $BASH_VERSION +print -f printf +hist alias hist=fc +$HISTEDIT $FCEDIT + +Section E: How can I get bash to do certain things, and why does bash do + things the way it does? + +E1) Why is the bash builtin `test' slightly different from /bin/test? + +The specific example used here is [ ! x -o x ], which is false. + +Bash's builtin `test' implements the Posix.2 spec, which can be +summarized as follows (the wording is due to David Korn): + +Here is the set of rules for processing test arguments. + + 0 Args: False + 1 Arg: True iff argument is not null. + 2 Args: If first arg is !, True iff second argument is null. + If first argument is unary, then true if unary test is true + Otherwise error. + 3 Args: If second argument is a binary operator, do binary test of $1 $3 + If first argument is !, negate two argument test of $2 $3 + If first argument is `(' and third argument is `)', do the + one-argument test of the second argument. + Otherwise error. + 4 Args: If first argument is !, negate three argument test of $2 $3 $4. + Otherwise unspecified + 5 or more Args: unspecified. (Historical shells would use their + current algorithm). + +The operators -a and -o are considered binary operators for the purpose +of the 3 Arg case. + +As you can see, the test becomes (not (x or x)), which is false. + +E2) Why does bash sometimes say `Broken pipe'? + +If a sequence of commands appears in a pipeline, and one of the +reading commands finishes before the writer has finished, the +writer receives a SIGPIPE signal. Many other shells special-case +SIGPIPE as an exit status in the pipeline and do not report it. +For example, in: + + ps -aux | head + +`head' can finish before `ps' writes all of its output, and ps +will try to write on a pipe without a reader. In that case, bash +will print `Broken pipe' to stderr when ps is killed by a +SIGPIPE. + +As of bash-3.1, bash does not report SIGPIPE errors by default. You +can build a version of bash that will report such errors. + +E3) When I have terminal escape sequences in my prompt, why does bash + wrap lines at the wrong column? + +Readline, the line editing library that bash uses, does not know +that the terminal escape sequences do not take up space on the +screen. The redisplay code assumes, unless told otherwise, that +each character in the prompt is a `printable' character that +takes up one character position on the screen. + +You can use the bash prompt expansion facility (see the PROMPTING +section in the manual page) to tell readline that sequences of +characters in the prompt strings take up no screen space. + +Use the \[ escape to begin a sequence of non-printing characters, +and the \] escape to signal the end of such a sequence. + +E4) If I pipe the output of a command into `read variable', why doesn't + the output show up in $variable when the read command finishes? + +This has to do with the parent-child relationship between Unix +processes. It affects all commands run in pipelines, not just +simple calls to `read'. For example, piping a command's output +into a `while' loop that repeatedly calls `read' will result in +the same behavior. + +Each element of a pipeline, even a builtin or shell function, +runs in a separate process, a child of the shell running the +pipeline. A subprocess cannot affect its parent's environment. +When the `read' command sets the variable to the input, that +variable is set only in the subshell, not the parent shell. When +the subshell exits, the value of the variable is lost. + +Many pipelines that end with `read variable' can be converted +into command substitutions, which will capture the output of +a specified command. The output can then be assigned to a +variable: + + grep ^gnu /usr/lib/news/active | wc -l | read ngroup + +can be converted into + + ngroup=$(grep ^gnu /usr/lib/news/active | wc -l) + +This does not, unfortunately, work to split the text among +multiple variables, as read does when given multiple variable +arguments. If you need to do this, you can either use the +command substitution above to read the output into a variable +and chop up the variable using the bash pattern removal +expansion operators or use some variant of the following +approach. + +Say /usr/local/bin/ipaddr is the following shell script: + +#! /bin/sh +host `hostname` | awk '/address/ {print $NF}' + +Instead of using + + /usr/local/bin/ipaddr | read A B C D + +to break the local machine's IP address into separate octets, use + + OIFS="$IFS" + IFS=. + set -- $(/usr/local/bin/ipaddr) + IFS="$OIFS" + A="$1" B="$2" C="$3" D="$4" + +Beware, however, that this will change the shell's positional +parameters. If you need them, you should save them before doing +this. + +This is the general approach -- in most cases you will not need to +set $IFS to a different value. + +Some other user-supplied alternatives include: + +read A B C D << HERE + $(IFS=.; echo $(/usr/local/bin/ipaddr)) +HERE + +and, where process substitution is available, + +read A B C D < <(IFS=.; echo $(/usr/local/bin/ipaddr)) + +E5) I have a bunch of shell scripts that use backslash-escaped characters + in arguments to `echo'. Bash doesn't interpret these characters. Why + not, and how can I make it understand them? + +This is the behavior of echo on most Unix System V machines. + +The bash builtin `echo' is modeled after the 9th Edition +Research Unix version of `echo'. It does not interpret +backslash-escaped characters in its argument strings by default; +it requires the use of the -e option to enable the +interpretation. The System V echo provides no way to disable the +special characters; the bash echo has a -E option to disable +them. + +There is a configuration option that will make bash behave like +the System V echo and interpret things like `\t' by default. Run +configure with the --enable-xpg-echo-default option to turn this +on. Be aware that this will cause some of the tests run when you +type `make tests' to fail. + +There is a shell option, `xpg_echo', settable with `shopt', that will +change the behavior of echo at runtime. Enabling this option turns +on expansion of backslash-escape sequences. + +E6) Why doesn't a while or for loop get suspended when I type ^Z? + +This is a consequence of how job control works on Unix. The only +thing that can be suspended is the process group. This is a single +command or pipeline of commands that the shell forks and executes. + +When you run a while or for loop, the only thing that the shell forks +and executes are any commands in the while loop test and commands in +the loop bodies. These, therefore, are the only things that can be +suspended when you type ^Z. + +If you want to be able to stop the entire loop, you need to put it +within parentheses, which will force the loop into a subshell that +may be stopped (and subsequently restarted) as a single unit. + +E7) What about empty for loops in Makefiles? + +It's fairly common to see constructs like this in automatically-generated +Makefiles: + +SUBDIRS = @SUBDIRS@ + + ... + +subdirs-clean: + for d in ${SUBDIRS}; do \ + ( cd $$d && ${MAKE} ${MFLAGS} clean ) \ + done + +When SUBDIRS is empty, this results in a command like this being passed to +bash: + + for d in ; do + ( cd $d && ${MAKE} ${MFLAGS} clean ) + done + +In versions of bash before bash-2.05a, this was a syntax error. If the +reserved word `in' was present, a word must follow it before the semicolon +or newline. The language in the manual page referring to the list of words +being empty referred to the list after it is expanded. These versions of +bash required that there be at least one word following the `in' when the +construct was parsed. + +The idiomatic Makefile solution is something like: + +SUBDIRS = @SUBDIRS@ + +subdirs-clean: + subdirs=$SUBDIRS ; for d in $$subdirs; do \ + ( cd $$d && ${MAKE} ${MFLAGS} clean ) \ + done + +The latest updated POSIX standard has changed this: the word list +is no longer required. Bash versions 2.05a and later accept the +new syntax. + +E8) Why does the arithmetic evaluation code complain about `08'? + +The bash arithmetic evaluation code (used for `let', $(()), (()), and in +other places), interprets a leading `0' in numeric constants as denoting +an octal number, and a leading `0x' as denoting hexadecimal. This is +in accordance with the POSIX.2 spec, section 2.9.2.1, which states that +arithmetic constants should be handled as signed long integers as defined +by the ANSI/ISO C standard. + +The POSIX.2 interpretation committee has confirmed this: + +http://www.pasc.org/interps/unofficial/db/p1003.2/pasc-1003.2-173.html + +E9) Why does the pattern matching expression [A-Z]* match files beginning + with every letter except `z'? + +Bash-2.03, Bash-2.05 and later versions honor the current locale setting +when processing ranges within pattern matching bracket expressions ([A-Z]). +This is what POSIX.2 and SUSv3/XPG6 specify. + +The behavior of the matcher in bash-2.05 and later versions depends on the +current LC_COLLATE setting. Setting this variable to `C' or `POSIX' will +result in the traditional behavior ([A-Z] matches all uppercase ASCII +characters). Many other locales, including the en_US locale (the default +on many US versions of Linux) collate the upper and lower case letters like +this: + + AaBb...Zz + +which means that [A-Z] matches every letter except `z'. Others collate like + + aAbBcC...zZ + +which means that [A-Z] matches every letter except `a'. + +The portable way to specify upper case letters is [:upper:] instead of +A-Z; lower case may be specified as [:lower:] instead of a-z. + +Look at the manual pages for setlocale(3), strcoll(3), and, if it is +present, locale(1). If you have locale(1), you can use it to find +your current locale information even if you do not have any of the +LC_ variables set. + +My advice is to put + + export LC_COLLATE=C + +into /etc/profile and inspect any shell scripts run from cron for +constructs like [A-Z]. This will prevent things like + + rm [A-Z]* + +from removing every file in the current directory except those beginning +with `z' and still allow individual users to change the collation order. +Users may put the above command into their own profiles as well, of course. + +E10) Why does `cd //' leave $PWD as `//'? + +POSIX.2, in its description of `cd', says that *three* or more leading +slashes may be replaced with a single slash when canonicalizing the +current working directory. + +This is, I presume, for historical compatibility. Certain versions of +Unix, and early network file systems, used paths of the form +//hostname/path to access `path' on server `hostname'. + +E11) If I resize my xterm while another program is running, why doesn't bash + notice the change? + +This is another issue that deals with job control. + +The kernel maintains a notion of a current terminal process group. Members +of this process group (processes whose process group ID is equal to the +current terminal process group ID) receive terminal-generated signals like +SIGWINCH. (For more details, see the JOB CONTROL section of the bash +man page.) + +If a terminal is resized, the kernel sends SIGWINCH to each member of +the terminal's current process group (the `foreground' process group). + +When bash is running with job control enabled, each pipeline (which may be +a single command) is run in its own process group, different from bash's +process group. This foreground process group receives the SIGWINCH; bash +does not. Bash has no way of knowing that the terminal has been resized. + +There is a `checkwinsize' option, settable with the `shopt' builtin, that +will cause bash to check the window size and adjust its idea of the +terminal's dimensions each time a process stops or exits and returns control +of the terminal to bash. Enable it with `shopt -s checkwinsize'. + +E12) Why don't negative offsets in substring expansion work like I expect? + +When substring expansion of the form ${param:offset[:length} is used, +an `offset' that evaluates to a number less than zero counts back from +the end of the expanded value of $param. + +When a negative `offset' begins with a minus sign, however, unexpected things +can happen. Consider + + a=12345678 + echo ${a:-4} + +intending to print the last four characters of $a. The problem is that +${param:-word} already has a well-defined meaning: expand to word if the +expanded value of param is unset or null, and $param otherwise. + +To use negative offsets that begin with a minus sign, separate the +minus sign and the colon with a space. + +E13) Why does filename completion misbehave if a colon appears in the filename? + +Filename completion (and word completion in general) may appear to behave +improperly if there is a colon in the word to be completed. + +The colon is special to readline's word completion code: it is one of the +characters that breaks words for the completer. Readline uses these characters +in sort of the same way that bash uses $IFS: they break or separate the words +the completion code hands to the application-specific or default word +completion functions. The original intent was to make it easy to edit +colon-separated lists (such as $PATH in bash) in various applications using +readline for input. + +This is complicated by the fact that some versions of the popular +`bash-completion' programmable completion package have problems with the +default completion behavior in the presence of colons. + +The current set of completion word break characters is available in bash as +the value of the COMP_WORDBREAKS variable. Removing `:' from that value is +enough to make the colon not special to completion: + +COMP_WORDBREAKS=${COMP_WORDBREAKS//:} + +You can also quote the colon with a backslash to achieve the same result +temporarily. + +E14) Why does quoting the pattern argument to the regular expression matching + conditional operator (=~) cause regexp matching to stop working? + +In versions of bash prior to bash-3.2, the effect of quoting the regular +expression argument to the [[ command's =~ operator was not specified. +The practical effect was that double-quoting the pattern argument required +backslashes to quote special pattern characters, which interfered with the +backslash processing performed by double-quoted word expansion and was +inconsistent with how the == shell pattern matching operator treated +quoted characters. + +In bash-3.2, the shell was changed to internally quote characters in single- +and double-quoted string arguments to the =~ operator, which suppresses the +special meaning of the characters special to regular expression processing +(`.', `[', `\', `(', `), `*', `+', `?', `{', `|', `^', and `$') and forces +them to be matched literally. This is consistent with how the `==' pattern +matching operator treats quoted portions of its pattern argument. + +Since the treatment of quoted string arguments was changed, several issues +have arisen, chief among them the problem of white space in pattern arguments +and the differing treatment of quoted strings between bash-3.1 and bash-3.2. +Both problems may be solved by using a shell variable to hold the pattern. +Since word splitting is not performed when expanding shell variables in all +operands of the [[ command, this allows users to quote patterns as they wish +when assigning the variable, then expand the values to a single string that +may contain whitespace. The first problem may be solved by using backslashes +or any other quoting mechanism to escape the white space in the patterns. + +Bash-4.0 introduces the concept of a `compatibility level', controlled by +several options to the `shopt' builtin. If the `compat31' option is enabled, +bash reverts to the bash-3.1 behavior with respect to quoting the rhs of +the =~ operator. + +E15) Tell me more about the shell compatibility level. + +Bash-4.0 introduced the concept of a `shell compatibility level', specified +as a set of options to the shopt builtin (compat31, compat32, compat40 at +this writing). There is only one current compatibility level -- each +option is mutually exclusive. This list does not mention behavior that is +standard for a particular version (e.g., setting compat32 means that quoting +the rhs of the regexp matching operator quotes special regexp characters in +the word, which is default behavior in bash-3.2 and above). + +compat31 set + - the < and > operators to the [[ command do not consider the current + locale when comparing strings + - quoting the rhs of the regexp matching operator (=~) has no + special effect + +compat32 set + - the < and > operators to the [[ command do not consider the current + locale when comparing strings + +compat40 set + - the < and > operators to the [[ command do not consider the current + locale when comparing strings + - interrupting a command list such as "a ; b ; c" causes the execution + of the entire list to be aborted (in versions before bash-4.0, + interrupting one command in a list caused the next to be executed) + +compat41 set + - interrupting a command list such as "a ; b ; c" causes the execution + of the entire list to be aborted (in versions before bash-4.1, + interrupting one command in a list caused the next to be executed) + - when in posix mode, single quotes in the `word' portion of a + double-quoted parameter expansion define a new quoting context and + are treated specially + +compat42 set + - the replacement string in double-quoted pattern substitution is not + run through quote removal, as in previous versions + +Section F: Things to watch out for on certain Unix versions + +F1) Why can't I use command line editing in my `cmdtool'? + +The problem is `cmdtool' and bash fighting over the input. When +scrolling is enabled in a cmdtool window, cmdtool puts the tty in +`raw mode' to permit command-line editing using the mouse for +applications that cannot do it themselves. As a result, bash and +cmdtool each try to read keyboard input immediately, with neither +getting enough of it to be useful. + +This mode also causes cmdtool to not implement many of the +terminal functions and control sequences appearing in the +`sun-cmd' termcap entry. For a more complete explanation, see +that file examples/suncmd.termcap in the bash distribution. + +`xterm' is a better choice, and gets along with bash much more +smoothly. + +If you must use cmdtool, you can use the termcap description in +examples/suncmd.termcap. Set the TERMCAP variable to the terminal +description contained in that file, i.e. + +TERMCAP='Mu|sun-cmd:am:bs:km:pt:li#34:co#80:cl=^L:ce=\E[K:cd=\E[J:rs=\E[s:' + +Then export TERMCAP and start a new cmdtool window from that shell. +The bash command-line editing should behave better in the new +cmdtool. If this works, you can put the assignment to TERMCAP +in your bashrc file. + +F2) I built bash on Solaris 2. Why do globbing expansions and filename + completion chop off the first few characters of each filename? + +This is the consequence of building bash on SunOS 5 and linking +with the libraries in /usr/ucblib, but using the definitions +and structures from files in /usr/include. + +The actual conflict is between the dirent structure in +/usr/include/dirent.h and the struct returned by the version of +`readdir' in libucb.a (a 4.3-BSD style `struct direct'). + +Make sure you've got /usr/ccs/bin ahead of /usr/ucb in your $PATH +when configuring and building bash. This will ensure that you +use /usr/ccs/bin/cc or acc instead of /usr/ucb/cc and that you +link with libc before libucb. + +If you have installed the Sun C compiler, you may also need to +put /usr/ccs/bin and /opt/SUNWspro/bin into your $PATH before +/usr/ucb. + +F3) Why does bash dump core after I interrupt username completion or + `~user' tilde expansion on a machine running NIS? + +This is a famous and long-standing bug in the SunOS YP (sorry, NIS) +client library, which is part of libc. + +The YP library code keeps static state -- a pointer into the data +returned from the server. When YP initializes itself (setpwent), +it looks at this pointer and calls free on it if it's non-null. +So far, so good. + +If one of the YP functions is interrupted during getpwent (the +exact function is interpretwithsave()), and returns NULL, the +pointer is freed without being reset to NULL, and the function +returns. The next time getpwent is called, it sees that this +pointer is non-null, calls free, and the bash free() blows up +because it's being asked to free freed memory. + +The traditional Unix mallocs allow memory to be freed multiple +times; that's probably why this has never been fixed. You can +run configure with the `--without-gnu-malloc' option to use +the C library malloc and avoid the problem. + +F4) I'm running SVR4.2. Why is the line erased every time I type `@'? + +The `@' character is the default `line kill' character in most +versions of System V, including SVR4.2. You can change this +character to whatever you want using `stty'. For example, to +change the line kill character to control-u, type + + stty kill ^U + +where the `^' and `U' can be two separate characters. + +F5) Why does bash report syntax errors when my C News scripts use a + redirection before a subshell command? + +The actual command in question is something like + + < file ( command ) + +According to the grammar given in the POSIX.2 standard, this construct +is, in fact, a syntax error. Redirections may only precede `simple +commands'. A subshell construct such as the above is one of the shell's +`compound commands'. A redirection may only follow a compound command. + +This affects the mechanical transformation of commands that use `cat' +to pipe a file into a command (a favorite Useless-Use-Of-Cat topic on +comp.unix.shell). While most commands of the form + + cat file | command + +can be converted to `< file command', shell control structures such as +loops and subshells require `command < file'. + +The file CWRU/sh-redir-hack in the bash distribution is an +(unofficial) patch to parse.y that will modify the grammar to +support this construct. It will not apply with `patch'; you must +modify parse.y by hand. Note that if you apply this, you must +recompile with -DREDIRECTION_HACK. This introduces a large +number of reduce/reduce conflicts into the shell grammar. + +F6) Why can't I use vi-mode editing on Red Hat Linux 6.1? + +The short answer is that Red Hat screwed up. + +The long answer is that they shipped an /etc/inputrc that only works +for emacs mode editing, and then screwed all the vi users by setting +INPUTRC to /etc/inputrc in /etc/profile. + +The short fix is to do one of the following: remove or rename +/etc/inputrc, set INPUTRC=~/.inputrc in ~/.bashrc (or .bash_profile, +but make sure you export it if you do), remove the assignment to +INPUTRC from /etc/profile, add + + set keymap emacs + +to the beginning of /etc/inputrc, or bracket the key bindings in +/etc/inputrc with these lines + + $if mode=emacs + [...] + $endif + +F7) Why do bash-2.05a and bash-2.05b fail to compile `printf.def' on + HP/UX 11.x? + +HP/UX's support for long double is imperfect at best. + +GCC will support it without problems, but the HP C library functions +like strtold(3) and printf(3) don't actually work with long doubles. +HP implemented a `long_double' type as a 4-element array of 32-bit +ints, and that is what the library functions use. The ANSI C +`long double' type is a 128-bit floating point scalar. + +The easiest fix, until HP fixes things up, is to edit the generated +config.h and #undef the HAVE_LONG_DOUBLE line. After doing that, +the compilation should complete successfully. + +Section G: How can I get bash to do certain common things? + +G1) How can I get bash to read and display eight-bit characters? + +This is a process requiring several steps. + +First, you must ensure that the `physical' data path is a full eight +bits. For xterms, for example, the `vt100' resources `eightBitInput' +and `eightBitOutput' should be set to `true'. + +Once you have set up an eight-bit path, you must tell the kernel and +tty driver to leave the eighth bit of characters alone when processing +keyboard input. Use `stty' to do this: + + stty cs8 -istrip -parenb + +For old BSD-style systems, you can use + + stty pass8 + +You may also need + + stty even odd + +Finally, you need to tell readline that you will be inputting and +displaying eight-bit characters. You use readline variables to do +this. convert-meta says what to do if you read a character with its +eighth bit set. input-meta says whether to permit characters with the +eighth bit at all. output-meta determines how to display characters +with the eighth bit set: if on, they are output directly; if it is off, +such characters are displayed as a meta-prefixed escape sequence. + +These variables can be set in your .inputrc or using the bash +`bind' builtin. Here's an example using `bind': + + bash$ bind 'set convert-meta off' + bash$ bind 'set input-meta on' + bash$ bind 'set output-meta on' + +The `set' commands between the single quotes may also be placed +in ~/.inputrc. + +The script examples/scripts.noah/meta.bash encapsulates the bind +commands in a shell function. + +G2) How do I write a function `x' to replace builtin command `x', but + still invoke the command from within the function? + +This is why the `command' and `builtin' builtins exist. The +`command' builtin executes the command supplied as its first +argument, skipping over any function defined with that name. The +`builtin' builtin executes the builtin command given as its first +argument directly. + +For example, to write a function to replace `cd' that writes the +hostname and current directory to an xterm title bar, use +something like the following: + + cd() + { + builtin cd "$@" && xtitle "$HOST: $PWD" + } + +This could also be written using `command' instead of `builtin'; +the version above is marginally more efficient. + +G3) How can I find the value of a shell variable whose name is the value + of another shell variable? + +Versions of Bash newer than Bash-2.0 support this directly. You can use + + ${!var} + +For example, the following sequence of commands will echo `z': + + var1=var2 + var2=z + echo ${!var1} + +For sh compatibility, use the `eval' builtin. The important +thing to remember is that `eval' expands the arguments you give +it again, so you need to quote the parts of the arguments that +you want `eval' to act on. + +For example, this expression prints the value of the last positional +parameter: + + eval echo \"\$\{$#\}\" + +The expansion of the quoted portions of this expression will be +deferred until `eval' runs, while the `$#' will be expanded +before `eval' is executed. In versions of bash later than bash-2.0, + + echo ${!#} + +does the same thing. + +This is not the same thing as ksh93 `nameref' variables, though the syntax +is similar. Namerefs are available bash version 4.3, and work as in ksh93. + +G4) How can I make the bash `time' reserved word print timing output that + looks like the output from my system's /usr/bin/time? + +The bash command timing code looks for a variable `TIMEFORMAT' and +uses its value as a format string to decide how to display the +timing statistics. + +The value of TIMEFORMAT is a string with `%' escapes expanded in a +fashion similar in spirit to printf(3). The manual page explains +the meanings of the escape sequences in the format string. + +If TIMEFORMAT is not set, bash acts as if the following assignment had +been performed: + + TIMEFORMAT=$'\nreal\t%3lR\nuser\t%3lU\nsys\t%3lS' + +The POSIX.2 default time format (used by `time -p command') is + + TIMEFORMAT=$'real %2R\nuser %2U\nsys %2S' + +The BSD /usr/bin/time format can be emulated with: + + TIMEFORMAT=$'\t%1R real\t%1U user\t%1S sys' + +The System V /usr/bin/time format can be emulated with: + + TIMEFORMAT=$'\nreal\t%1R\nuser\t%1U\nsys\t%1S' + +The ksh format can be emulated with: + + TIMEFORMAT=$'\nreal\t%2lR\nuser\t%2lU\nsys\t%2lS' + +G5) How do I get the current directory into my prompt? + +Bash provides a number of backslash-escape sequences which are expanded +when the prompt string (PS1 or PS2) is displayed. The full list is in +the manual page. + +The \w expansion gives the full pathname of the current directory, with +a tilde (`~') substituted for the current value of $HOME. The \W +expansion gives the basename of the current directory. To put the full +pathname of the current directory into the path without any tilde +subsitution, use $PWD. Here are some examples: + + PS1='\w$ ' # current directory with tilde + PS1='\W$ ' # basename of current directory + PS1='$PWD$ ' # full pathname of current directory + +The single quotes are important in the final example to prevent $PWD from +being expanded when the assignment to PS1 is performed. + +G6) How can I rename "*.foo" to "*.bar"? + +Use the pattern removal functionality described in D3. The following `for' +loop will do the trick: + + for f in *.foo; do + mv $f ${f%foo}bar + done + +G7) How can I translate a filename from uppercase to lowercase? + +The script examples/functions/lowercase, originally written by John DuBois, +will do the trick. The converse is left as an exercise. + +G8) How can I write a filename expansion (globbing) pattern that will match + all files in the current directory except "." and ".."? + +You must have set the `extglob' shell option using `shopt -s extglob' to use +this: + + echo .!(.|) * + +A solution that works without extended globbing is given in the Unix Shell +FAQ, posted periodically to comp.unix.shell. It's a variant of + + echo .[!.]* ..?* * + +(The ..?* catches files with names of three or more characters beginning +with `..') + +Section H: Where do I go from here? + +H1) How do I report bugs in bash, and where should I look for fixes and + advice? + +Use the `bashbug' script to report bugs. It is built and +installed at the same time as bash. It provides a standard +template for reporting a problem and automatically includes +information about your configuration and build environment. + +`bashbug' sends its reports to bug-bash@gnu.org, which +is a large mailing list gatewayed to the usenet newsgroup gnu.bash.bug. + +Bug fixes, answers to questions, and announcements of new releases +are all posted to gnu.bash.bug. Discussions concerning bash features +and problems also take place there. + +To reach the bash maintainers directly, send mail to +bash-maintainers@gnu.org. + +H2) What kind of bash documentation is there? + +First, look in the doc directory in the bash distribution. It should +contain at least the following files: + +bash.1 an extensive, thorough Unix-style manual page +builtins.1 a manual page covering just bash builtin commands +bashref.texi a reference manual in GNU tex`info format +bashref.info an info version of the reference manual +FAQ this file +article.ms text of an article written for The Linux Journal +readline.3 a man page describing readline + +Postscript, HTML, and ASCII files created from the above source are +available in the documentation distribution. + +There is additional documentation available for anonymous FTP from host +ftp.cwru.edu in the `pub/bash' directory. + +Cameron Newham and Bill Rosenblatt have written a book on bash, published +by O'Reilly and Associates. The book is based on Bill Rosenblatt's Korn +Shell book. The title is ``Learning the Bash Shell'', and the ISBN number +of the third edition, published in March, 2005, is 0-596-00965-8. Look for +it in fine bookstores near you. This edition of the book has been updated +to cover bash-3.0. + +The GNU Bash Reference Manual has been published as a printed book by +Network Theory Ltd (Paperback, ISBN: 0-9541617-7-7, Nov. 2006). It covers +bash-3.2 and is available from most online bookstores (see +http://www.network-theory.co.uk/bash/manual/ for details). The publisher +will donate $1 to the Free Software Foundation for each copy sold. + +Arnold Robbins and Nelson Beebe have written ``Classic Shell Scripting'', +published by O'Reilly. The first edition, with ISBN number 0-596-00595-4, +was published in May, 2005. + +Chris F. A. Johnson, a frequent contributor to comp.unix.shell and +gnu.bash.bug, has written ``Shell Scripting Recipes: A Problem-Solution +Approach,'' a new book on shell scripting, concentrating on features of +the POSIX standard helpful to shell script writers. The first edition from +Apress, with ISBN number 1-59059-471-1, was published in May, 2005. + +H3) What's coming in future versions? + +These are features I hope to include in a future version of bash. + +Rocky Bernstein's bash debugger (support is included with bash-4.0) + +H4) What's on the bash `wish list' for future versions? + +These are features that may or may not appear in a future version of bash. + +breaking some of the shell functionality into embeddable libraries +a module system like zsh's, using dynamic loading like builtins +a bash programmer's guide with a chapter on creating loadable builtins +a better loadable interface to perl with access to the shell builtins and + variables (contributions gratefully accepted) +ksh93-like `xx.yy' variables (including some of the .sh.* variables) and + associated disipline functions +Some of the new ksh93 pattern matching operators, like backreferencing + +H5) When will the next release appear? + +The next version will appear sometime in 2015. Never make predictions. + +This document is Copyright 1995-2014 by Chester Ramey. + +Permission is hereby granted, without written agreement and +without license or royalty fees, to use, copy, and distribute +this document for any purpose, provided that the above copyright +notice appears in all copies of this document and that the +contents of this document remain unaltered. diff --git a/doc/INTRO b/doc/INTRO new file mode 100644 index 0000000..29f208a --- /dev/null +++ b/doc/INTRO @@ -0,0 +1,187 @@ + BASH - The Bourne-Again Shell + +Bash is the shell, or command language interpreter, that will appear +in the GNU operating system. Bash is an sh-compatible shell that +incorporates useful features from the Korn shell (ksh) and C shell +(csh). It is intended to conform to the IEEE POSIX P1003.2/ISO 9945.2 +Shell and Tools standard. It offers functional improvements over sh +for both programming and interactive use. In addition, most sh scripts +can be run by Bash without modification. + +Bash is quite portable. It uses a configuration system that discovers +characteristics of the compilation platform at build time, and may +therefore be built on nearly every version of UNIX. Ports to +UNIX-like systems such as QNX and Minix and to non-UNIX systems such +as OS/2, Windows 95, and Windows NT are available. + +Bash includes the following features: + +Editing and Completion + +Bash offers a command-line editing facility which permits users to +edit command lines using familiar emacs or vi-style editing commands. +Editing allows corrections to be made without having to erase back +to the point of error or start the command line anew. The editing +facilities include a feature that allows users to complete command and +file names. + +The Bash line editing library is fully customizable. Users may define +their own key bindings -- the action taken when a key is pressed. A +number of variables to fine-tune editing behavior are also available. + +History and Command Re-entry + +The Bash history feature remembers commands entered to the shell and +allows them to be recalled and re-executed. The history list may be +of unlimited size. Bash allows users to search for previous commands +and reuse portions of those commands when composing new ones. The +history list may be saved across shell sessions. + +Bash allows users to control which commands are saved on the history +list. + +Job Control + +On systems that support it, Bash provides an interface to the +operating system's job control facilities, which allow processes +to be suspended and restarted, and moved between the foreground +and background. Bash allows users to selectively `forget' about +background jobs. + +Shell Functions and Aliases + +These mechanisms are available to bind a user-selected identifier to a +list of commands that will be executed when the identifier is used as +a command name. Functions allow local variables and recursion, and +have access to the environment of the calling shell. Aliases may be +used to create a mnemonic for a command name, expand a single word to +a complex command, or ensure that a command is called with a basic set +of options. + +Arrays + +Bash-2.0 supports indexed arrays of unlimited size. The subscript for +an array is an arithmetic expression. Arrays may be assigned to with +a new compound assignment syntax, and several builtins have options to +operate on array variables. Bash includes a number of built-in array +variables. + +Arithmetic + +Bash allows users to perform integer arithmetic in any base from two +to sixty-four. Nearly all of the C language arithmetic operators are +available with the same syntax and precedence as in C. Arithmetic +expansion allows an arithmetic expression to be evaluated and the +result substituted into the command line. Shell variables can be used +as operands, and the value of an expression may be assigned to a +variable. + +An arithmetic expression may be used as a command; the exit status of +the command is the value of the expression. + +ANSI-C Quoting + +There is a new quoting syntax that allows backslash-escaped characters +in strings to be expanded according to the ANSI C standard. + +Tilde Expansion + +Users' home directories may be expanded using this feature. Words +beginning with a tilde may also be expanded to the current or previous +working directory. + +Brace Expansion + +Brace expansion is a convenient way to generate a list of strings that +share a common prefix or suffix. + +Substring Capabilities + +Bash allows new strings to be created by removing leading or trailing +substrings from existing variable values, or by specifying a starting +offset and length. Portions of variable values may be matched against +shell patterns and the matching portion removed or a new value +substituted. + +Indirect Variable Expansion + +Bash makes it easy to find the value of a shell variable whose name is +the value of another variable. + +Expanded I/O Capabilities + +Bash provides several input and output features not available in sh, +including the ability to: + + o specify a file or file descriptor for both input and output + o read from or write to asynchronous processes using named pipes + o read lines ending in backslash + o display a prompt on the terminal before a read + o format menus and interpret responses to them + o echo lines exactly as input without escape processing + +Control of Builtin Commands + +Bash implements several builtin commands to give users more control +over which commands are executed. The enable builtin allows other +builtin commands to be selectively enabled or disabled. The command +and builtin builtins change the order in which the shell searches for +commands. + +On systems that provide dynamic loading, new builtins may be loaded +into a running shell from a shared object file. These new builtins +have access to all of the shell facilities. + +Help + +Bash includes a built-in help facility. + +Shell Optional Behavior + +There is a great deal of customizable shell behavior. The shopt +builtin command provides a unified interface that allows users to +alter shell defaults. + +Prompt Customization + +Bash allows the primary and secondary prompts to be customized by +interpreting a number of backslash-escaped special characters. +Parameter and variable expansion is also performed on the values of +the primary and secondary prompt strings before they are displayed. + +Security + +Bash provides a restricted shell environment. It is also possible to +control the execution of setuid/setgid scripts. + +Directory Stack + +Bash provides a `directory stack', to which directories may be added +and removed. The current directory may be changed to any directory in +the stack. It is easy to toggle between two directories in the stack. +The directory stack may be saved and restored across different shell +invocations. + +POSIX Mode + +Bash is nearly completely conformant to POSIX.2. POSIX mode changes +those few areas where the Bash default behavior differs from the +standard to match the standard. In POSIX mode, Bash is POSIX.2 +compliant. + +Internationalization + +Bash provides a new quoting syntax that allows strings to be +translated according to the current locale. The locale in which the +shell itself runs may also be changed, so that the shell messages +themselves may be language-specific. + +The command-line editing facilities allow the input of eight-bit +characters, so most of the ISO-8859 family of character sets are +supported. + +Command Timing + +Bash allows external commands, shell builtin commands and shell functions +to be timed. The format used to display the timing information may be +changed by the user. diff --git a/doc/Makefile.in b/doc/Makefile.in new file mode 100644 index 0000000..5f0756c --- /dev/null +++ b/doc/Makefile.in @@ -0,0 +1,341 @@ +# This Makefile is for the Bash/documentation directory -*- text -*-. +# +# Copyright (C) 2003-2015 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 3 of the License, 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, see . + +PACKAGE = @PACKAGE_NAME@ +VERSION = @PACKAGE_VERSION@ + +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_VERSION = @PACKAGE_VERSION@ + +PACKAGE_TARNAME = @PACKAGE_TARNAME@ + +# +SHELL = @MAKE_SHELL@ +RM = rm -f + +topdir = @top_srcdir@ +srcdir = @srcdir@ +VPATH = @srcdir@ + +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +datarootdir = @datarootdir@ + +infodir = @infodir@ + +docdir = @docdir@ + +# set this to a directory name to have the HTML files installed +htmldir = @htmldir@ + +# Support an alternate destination root directory for package building +DESTDIR = + +mandir = @mandir@ +manpfx = man + +man1ext = .1 +man1dir = $(mandir)/$(manpfx)1 +man3ext = .3 +man3dir = $(mandir)/$(manpfx)3 + +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +BUILD_DIR = @BUILD_DIR@ + +SUPPORT_SRCDIR = $(topdir)/support + +# bad style +RL_LIBDIR = $(topdir)/lib/readline + +# unused +TEXINDEX = texindex +TEX = tex + +MAKEINFO = makeinfo +TEXI2DVI = ${SUPPORT_SRCDIR}/texi2dvi +TEXI2HTML = ${SUPPORT_SRCDIR}/texi2html +MAN2HTML = ${BUILD_DIR}/support/man2html +HTMLPOST = ${srcdir}/htmlpost.sh +INFOPOST = ${srcdir}/infopost.sh +QUIETPS = #set this to -q to shut up dvips +PAPERSIZE = letter # change to a4 for A4-size paper +PSDPI = 600 # could be 300 if you like +DVIPS = dvips -D ${PSDPI} $(QUIETPS) -t ${PAPERSIZE} -o $@ # tricky +# experimental; uses external texi2dvi for now; this needs pdftex to be present +TEXI2PDF = texi2dvi --pdf + +TEXINPUTDIR = $(RL_LIBDIR)/doc +SET_TEXINPUTS = TEXINPUTS=.:$(TEXINPUTDIR):$$TEXINPUTS + +# These tools might not be available; they're not required +DVIPDF = dvipdfm -o $@ -p ${PAPERSIZE} +PSPDF = gs -sPAPERSIZE=${PAPERSIZE} -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -sOutputFile=$@ + +MKDIRS = ${SUPPORT_SRCDIR}/mkdirs + +# This should be a program that converts troff to an ascii-readable format +# added the -P -c for benefit of Mac OS X, which insists on adding colors if +# it's not present +NROFF = groff -Tascii -P -c + +# This should be a program that converts troff to postscript +GROFF = groff + +HSUSER = $(RL_LIBDIR)/doc/hsuser.texi +RLUSER = $(RL_LIBDIR)/doc/rluser.texi + +BASHREF_FILES = $(srcdir)/bashref.texi $(srcdir)/fdl.texi $(srcdir)/version.texi + +.SUFFIXES: .0 .1 .3 .ms .ps .txt .dvi .html .pdf + +.1.ps: + $(RM) $@ + -${GROFF} -man $< > $@ + +.1.0: + $(RM) $@ + -${NROFF} -man $< > $@ + +.1.html: + $(RM) $@ + -${MAN2HTML} $< | ${HTMLPOST} > $@ + +.ms.ps: + $(RM) $@ + -${GROFF} -ms $< > $@ + +.ms.txt: + $(RM) $@ + -${NROFF} -ms $< > $@ + +.3.ps: + $(RM) $@ + -${GROFF} -man $< > $@ + +.3.0: + $(RM) $@ + -${NROFF} -man $< > $@ + +.3.html: + $(RM) $@ + -${MAN2HTML} $< > $@ + +.ps.pdf: + $(RM) $@ + -${PSPDF} $< + +.dvi.pdf: + $(RM) $@ + -${DVIPDF} $< + +.dvi.ps: + ${RM} $@ + -${DVIPS} $< + +#.texi.pdf: +# $(RM) $@ +# -${TEXI2PDF} $< + +all: ps info dvi text html $(MAN2HTML) +nodvi: ps info text html +everything: all pdf + +PSFILES = bash.ps bashbug.ps article.ps builtins.ps rbash.ps +DVIFILES = bashref.dvi bashref.ps +INFOFILES = bashref.info bash.info +MAN0FILES = bash.0 bashbug.0 builtins.0 rbash.0 +HTMLFILES = bashref.html bash.html +PDFFILES = bash.pdf bashref.pdf article.pdf rose94.pdf + +ps: ${PSFILES} +dvi: ${DVIFILES} +info: ${INFOFILES} +text: ${MAN0FILES} +html: ${HTMLFILES} +pdf: ${PDFFILES} + +bashref.dvi: $(BASHREF_FILES) $(HSUSER) $(RLUSER) + ${SET_TEXINPUTS} $(TEXI2DVI) $(srcdir)/bashref.texi || { ${RM} $@ ; exit 1; } + +bashref.info: $(BASHREF_FILES) $(HSUSER) $(RLUSER) + $(MAKEINFO) --no-split -I$(TEXINPUTDIR) $(srcdir)/bashref.texi + +# experimental +bashref.pdf: $(BASHREF_FILES) $(HSUSER) $(RLUSER) + ${SET_TEXINPUTS} $(TEXI2PDF) $(srcdir)/bashref.texi || { ${RM} $@ ; exit 1; } + + +# can also use: +# $(TEXI2HTML) -menu -monolithic -I $(TEXINPUTDIR) $(srcdir)/bashref.texi +bashref.html: $(BASHREF_FILES) $(HSUSER) $(RLUSER) + $(MAKEINFO) --html --no-split -I$(TEXINPUTDIR) $(srcdir)/bashref.texi + +bash.info: bashref.info + ${SHELL} ${INFOPOST} < $(srcdir)/bashref.info > $@ ; \ + +bash.txt: bash.1 +bash.ps: bash.1 +bash.html: bash.1 +bashbug.ps: bashbug.1 +builtins.ps: builtins.1 bash.1 +rbash.ps: rbash.1 bash.1 +bash.0: bash.1 +bashbug.0: bashbug.1 +builtins.0: builtins.1 bash.1 +rbash.0: rbash.1 bash.1 +article.ps: article.ms + +bashref.ps: bashref.dvi + +article.pdf: article.ps +#bashref.pdf: bashref.dvi +# experimental +bashref.pdf: bashref.texi +bash.pdf: bash.ps +rose94.pdf: rose94.ps + +OTHER_DOCS = $(srcdir)/FAQ $(srcdir)/INTRO +OTHER_INSTALLED_DOCS = FAQ INTRO + +$(MAN2HTML): ${topdir}/support/man2html.c + -( cd ${BUILD_DIR}/support ; ${MAKE} ${MFLAGS} man2html) + +clean: + $(RM) *.aux *.bak *.cp *.fn *.ky *.log *.pg *.toc *.tp *.vr *.cps \ + *.pgs *.bt *.bts *.rw *.rws *.fns *.kys *.tps *.vrs *.o + ${RM} core *.core + +mostlyclean: clean + $(RM) Makefile + +distclean: clean maybe-clean + $(RM) Makefile + +maintainer-clean: clean + ${RM} ${PSFILES} ${DVIFILES} ${INFOFILES} ${MAN0FILES} ${HTMLFILES} + ${RM} ${CREATED_FAQ} + $(RM) Makefile + +maybe-clean: + -if test "X$(topdir)" != "X$(BUILD_DIR)"; then \ + $(RM) ${PSFILES} ${DVIFILES} ${INFOFILES} ${MAN0FILES} ${HTMLFILES}; \ + fi + +installdirs: + -$(SHELL) $(SUPPORT_SRCDIR)/mkinstalldirs $(DESTDIR)$(man1dir) + -$(SHELL) $(SUPPORT_SRCDIR)/mkinstalldirs $(DESTDIR)$(infodir) + -$(SHELL) $(SUPPORT_SRCDIR)/mkinstalldirs $(DESTDIR)$(docdir) + -if test -n "$(htmldir)" ; then \ + $(SHELL) $(SUPPORT_SRCDIR)/mkinstalldirs $(DESTDIR)$(htmldir) ; \ + fi + +install: info installdirs + -$(INSTALL_DATA) $(srcdir)/bash.1 $(DESTDIR)$(man1dir)/bash${man1ext} + -$(INSTALL_DATA) $(srcdir)/bashbug.1 $(DESTDIR)$(man1dir)/bashbug${man1ext} + -$(INSTALL_DATA) $(OTHER_DOCS) $(DESTDIR)$(docdir) +# uncomment the next lines to install the builtins man page +# sed 's:bash\.1:man1/&:' $(srcdir)/builtins.1 > $${TMPDIR:-/var/tmp}/builtins.1 +# -$(INSTALL_DATA) $${TMPDIR:-/var/tmp}/builtins.1 $(DESTDIR)$(man1dir)/bash_builtins${man1ext} +# -$(RM) $${TMPDIR:-/var/tmp}/builtins.1 + -if test -f bash.info; then d=.; else d=$(srcdir); fi; \ + $(INSTALL_DATA) $$d/bash.info $(DESTDIR)$(infodir)/bash.info +# run install-info if it is present to update the info directory + if $(SHELL) -c 'install-info --version' >/dev/null 2>&1; then \ + install-info --dir-file=$(DESTDIR)$(infodir)/dir $(DESTDIR)$(infodir)/bash.info; \ + else true; fi +# if htmldir is set, install the html files into that directory + -if test -n "${htmldir}" ; then \ + $(INSTALL_DATA) $(srcdir)/bash.html $(DESTDIR)$(htmldir) ; \ + $(INSTALL_DATA) $(srcdir)/bashref.html $(DESTDIR)$(htmldir) ; \ + fi + +install_builtins: installdirs + sed 's:bash\.1:man1/&:' $(srcdir)/builtins.1 > $${TMPDIR:-/var/tmp}/builtins.1 + -$(INSTALL_DATA) $${TMPDIR:-/var/tmp}/builtins.1 $(DESTDIR)$(man1dir)/bash_builtins${man1ext} + -$(RM) $${TMPDIR:-/var/tmp}/builtins.1 + +install_everything: install install_builtins + +install-html: html + -if test -n "${htmldir}" ; then \ + $(INSTALL_DATA) $(srcdir)/bash.html $(DESTDIR)$(htmldir) ; \ + $(INSTALL_DATA) $(srcdir)/bashref.html $(DESTDIR)$(htmldir) ; \ + fi + +uninstall: + -$(RM) $(DESTDIR)$(man1dir)/bash${man1ext} $(DESTDIR)$(man1dir)/bashbug${man1ext} + -$(RM) $(DESTDIR)$(man1dir)/bash_builtins${man1ext} + $(RM) $(DESTDIR)$(infodir)/bash.info +# run install-info if it is present to update the info directory + if $(SHELL) -c 'install-info --version' >/dev/null 2>&1; then \ + install-info --delete --dir-file=$(DESTDIR)$(infodir)/dir $(DESTDIR)$(infodir)/bash.info; \ + else true; fi + -( cd $(DESTDIR)$(docdir) && $(RM) $(OTHER_INSTALLED_DOCS) ) + -if test -n "$(htmldir)" ; then \ + $(RM) $(DESTDIR)$(htmldir)/bash.html ; \ + $(RM) $(DESTDIR)$(htmldir)/bashref.html ; \ + fi + +# for use by chet +CREATED_FAQ = faq.news faq.news2 faq.mail faq.version + +faq: ${CREATED_FAQ} + +faq.version: FAQ.version FAQ + sh mkfaqvers FAQ.version > $@ + +faq.headers.mail: FAQ.headers.mail FAQ + sh mkfaqvers FAQ.headers.mail > $@ + +faq.headers.news: FAQ.headers.news FAQ + sh mkfaqvers FAQ.headers.news > $@ + +faq.headers.news2: FAQ.headers.news2 FAQ + sh mkfaqvers FAQ.headers.news2 > $@ + +faq.news: FAQ faq.headers.news faq.version + $(RM) $@ + cat faq.headers.news faq.version FAQ > $@ + +faq.news2: FAQ faq.headers.news2 faq.version + $(RM) $@ + cat faq.headers.news2 faq.version FAQ > $@ + +faq.mail: FAQ faq.headers.mail faq.version + $(RM) $@ + cat faq.headers.mail faq.version FAQ > $@ + +inst: bashref.texi + $(SHELL) ./mkinstall + cmp -s INSTALL ../INSTALL || mv INSTALL ../INSTALL + $(RM) INSTALL + +posix: bashref.texi + $(SHELL) ./mkposix + cmp -s POSIX ../POSIX || mv POSIX ../POSIX + $(RM) POSIX + +rbash: bashref.texi + $(SH) ./mkrbash + cmp -s RBASH ../RBASH || mv RBASH ../RBASH + $(RM) RBASH + +xdist: everything inst posix rbash diff --git a/doc/README b/doc/README new file mode 100644 index 0000000..e3a1d24 --- /dev/null +++ b/doc/README @@ -0,0 +1,36 @@ +This directory contains the bash documentation. + +FAQ - a set of frequently-asked questions about Bash with answers +INTRO - a short introduction to bash +article.ms - an article I wrote about bash for The Linux Journal +bash.1 - the bash man page +builtins.1 - a man page that documents the builtins, extracted from bash.1 +bashref.texi - the `bash reference manual' +bashref.info - the `bash reference manual' processed by `makeinfo' +readline.3 - the readline man page + +The `.ps' files are postscript versions of the above. The `.html' +files are HTML versions of the man page and reference manual. The +`.0' files are formatted manual pages. The `.txt' versions are +ascii -- the output of `groff -Tascii'. + +The rest of this file explains how to use the `builtins.1' man page. + +For each command in the list of builtins create a file in man/man1 called: + +${command}.1 + +eg. +for.1 +type.1 +alias.1 +etc. + +All these files are identical as follows: + +jaws@jaws(264)$ cat alias.1 +.so man1/builtins.1 +jaws@jaws(265)$ + +Make sure you adjust the .so line in builtins.1 to reflect where you +put it. diff --git a/doc/aosa-bash-full.pdf b/doc/aosa-bash-full.pdf new file mode 100644 index 0000000..0181549 Binary files /dev/null and b/doc/aosa-bash-full.pdf differ diff --git a/doc/aosa-bash.pdf b/doc/aosa-bash.pdf new file mode 100644 index 0000000..4c8773a Binary files /dev/null and b/doc/aosa-bash.pdf differ diff --git a/doc/article.ms b/doc/article.ms new file mode 100644 index 0000000..d17bfa3 --- /dev/null +++ b/doc/article.ms @@ -0,0 +1,1114 @@ +.de SE \" start example +.sp .5 +.RS +.ft CR +.nf +.. +.de EE \" end example +.fi +.sp .5 +.RE +.ft R +.. +.TL +Bash \- The GNU shell* +.AU +Chet Ramey +Case Western Reserve University +chet@po.cwru.edu +.FS +*An earlier version of this article appeared in The Linux Journal. +.FE +.NH 1 +Introduction +.PP +.B Bash +is the shell, or command language interpreter, +that will appear in the GNU operating system. +The name is an acronym for +the \*QBourne-Again SHell\*U, a pun on Steve Bourne, the author +of the direct ancestor of the current +.UX +shell \fI/bin/sh\fP, +which appeared in the Seventh Edition Bell Labs Research version +of \s-1UNIX\s+1. +.PP +Bash is an \fBsh\fP\-compatible shell that incorporates useful +features from the Korn shell (\fBksh\fP) and the C shell (\fBcsh\fP), +described later in this article. It is ultimately intended to be a +conformant implementation of the IEEE POSIX Shell and Utilities +specification (IEEE Working Group 1003.2). It offers functional +improvements over sh for both interactive and programming use. +.PP +While the GNU operating system will most likely include a version +of the Berkeley shell csh, Bash will be the default shell. +Like other GNU software, Bash is quite portable. It currently runs +on nearly every version of +.UX +and a few other operating systems \- an independently-supported +port exists for OS/2, and there are rumors of ports to DOS and +Windows NT. Ports to \s-1UNIX\s+1-like systems such as QNX and Minix +are part of the distribution. +.PP +The original author of Bash +was Brian Fox, an employee of the Free Software Foundation. The +current developer and maintainer is Chet Ramey, a volunteer who +works at Case Western Reserve University. +.NH 1 +What's POSIX, anyway? +.PP +.I POSIX +is a name originally coined by Richard Stallman for a family of open +system standards based on \s-1UNIX\s+1. There are a number of aspects of \s-1UNIX\s+1 +under consideration for standardization, from the basic system services +at the system call and C library level to applications and tools to system +administration and management. Each area of standardization is +assigned to a working group in the 1003 series. +.PP +The POSIX Shell and Utilities standard has been developed by IEEE Working +Group 1003.2 (POSIX.2).\(dd +.FS +\(ddIEEE, \fIIEEE Standard for Information Technology -- Portable +Operating System Interface (POSIX) Part 2: Shell and Utilities\fP, +1992. +.FE +It concentrates on the command interpreter +interface and utility programs +commonly executed from the command line or by other programs. +An initial version of the standard has been +approved and published by the IEEE, and work is currently underway to +update it. +There are four primary areas of work in the 1003.2 standard: +.IP \(bu +Aspects of the shell's syntax and command language. +A number of special builtins such as +.B cd +and +.B exec +are being specified as part of the shell, since their +functionality usually cannot be implemented by a separate executable; +.IP \(bu +A set of utilities to be called by shell scripts and applications. +Examples are programs like +.I sed, +.I tr, +and +.I awk. +Utilities commonly implemented as shell builtins +are described in this section, such as +.B test +and +.B kill . +An expansion of this section's scope, termed the User Portability +Extension, or UPE, has standardized interactive programs such as +.I vi +and +.I mailx; +.IP \(bu +A group of functional interfaces to services provided by the +shell, such as the traditional \f(CRsystem()\fP +C library function. There are functions to perform shell word +expansions, perform filename expansion (\fIglobbing\fP), obtain values +of POSIX.2 system configuration variables, retrieve values of +environment variables (\f(CRgetenv()\fP\^), and other services; +.IP \(bu +A suite of \*Qdevelopment\*U utilities such as +.I c89 +(the POSIX.2 version of \fIcc\fP), +and +.I yacc. +.PP +Bash is concerned with the aspects of the shell's behavior +defined by POSIX.2. The shell command language has of +course been standardized, including the basic flow control +and program execution constructs, I/O redirection and +pipelining, argument handling, variable expansion, and quoting. +The +.I special +builtins, which must be implemented as part of the shell to +provide the desired functionality, are specified as being +part of the shell; examples of these are +.B eval +and +.B export . +Other utilities appear in the sections of POSIX.2 not +devoted to the shell which are commonly (and in some +cases must be) implemented as builtin commands, such as +.B read +and +.B test . +POSIX.2 also specifies aspects of the shell's +interactive behavior as part of +the UPE, including job control and command line editing. +Interestingly enough, only \fIvi\fP-style line editing commands +have been standardized; \fIemacs\fP editing commands were left +out due to objections. +.PP +While POSIX.2 includes much of what the shell has traditionally +provided, some important things have been omitted as being +\*Qbeyond its scope.\*U There is, for instance, no mention of +a difference between a +.I login +shell and any other interactive shell (since POSIX.2 does not +specify a login program). No fixed startup files are defined, +either \- the standard does not mention +.I .profile . +.NH 1 +Basic Bash features +.PP +Since the Bourne shell +provides Bash with most of its philosophical underpinnings, +Bash inherits most of its features and functionality from sh. +Bash implements all of the traditional sh flow +control constructs (\fIfor\fP, \fIif\fP, \fIwhile\fP, etc.). +All of the Bourne shell builtins, including those not specified in +the POSIX.2 standard, appear in Bash. Shell \fIfunctions\fP, +introduced in the SVR2 version of the Bourne shell, +are similar to shell scripts, but are defined using a special +syntax and are executed in the same process as the calling shell. +Bash has shell functions +which behave in a fashion upward-compatible with sh functions. +There are certain shell +variables that Bash interprets in the same way as sh, such as +.B PS1 , +.B IFS , +and +.B PATH . +Bash implements essentially the same grammar, parameter and +variable expansion semantics, redirection, and quoting as the +Bourne shell. Where differences appear between the POSIX.2 +standard and traditional sh behavior, Bash follows POSIX. +.PP +The Korn Shell (\fBksh\fP) is a descendant of the Bourne shell written +at AT&T Bell Laboratories by David Korn\(dg. It provides a number of +useful features that POSIX and Bash have adopted. Many of the +interactive facilities in POSIX.2 have their roots in the ksh: +for example, the POSIX and ksh job control facilities are nearly +identical. Bash includes features from the Korn Shell for both +interactive use and shell programming. For programming, Bash provides +variables such as +.B RANDOM +and +.B REPLY , +the +.B typeset +builtin, +the ability to remove substrings from variables based on patterns, +and shell arithmetic. +.FS +\(dgMorris Bolsky and David Korn, \fIThe KornShell Command and +Programming Language\fP, Prentice Hall, 1989. +.FE +.B RANDOM +expands to a random number each time it is referenced; assigning a +value to +.B RANDOM +seeds the random number generator. +.B REPLY +is the default variable used by the +.B read +builtin when no variable names are supplied as arguments. +The +.B typeset +builtin is used to define variables and give them attributes +such as \fBreadonly\fP. +Bash arithmetic allows the evaluation of an expression and the +substitution of the result. Shell variables may be used as operands, +and the result of an expression may be assigned to a variable. +Nearly all of the operators from the C language are available, +with the same precedence rules: +.SE +$ echo $((3 + 5 * 32)) +163 +.EE +.LP +For interactive use, Bash implements ksh-style aliases and builtins +such as +.B fc +(discussed below) and +.B jobs . +Bash aliases allow a string to be substituted for a command name. +They can be used to create a mnemonic for a \s-1UNIX\s+1 command +name (\f(CRalias del=rm\fP), to expand a single word to a complex command +(\f(CRalias news='xterm -g 80x45 -title trn -e trn -e -S1 -N &'\fP), or to +ensure that a command is invoked with a basic set of options +(\f(CRalias ls="/bin/ls -F"\fP). +.PP +The C shell (\fBcsh\fP)\(dg, originally written by Bill Joy while at +Berkeley, is widely used and quite popular for its interactive +facilities. Bash includes a csh-compatible history expansion +mechanism (\*Q! history\*U), brace expansion, access to a stack +of directories via the +.B pushd , +.B popd , +and +.B dirs +builtins, and tilde expansion, to generate users' home directories. +Tilde expansion has also been adopted by both the Korn Shell and +POSIX.2. +.FS +\(dgBill Joy, An Introduction to the C Shell, \fIUNIX User's Supplementary +Documents\fP, University of California at Berkeley, 1986. +.FE +.PP +There were certain areas in which POSIX.2 felt standardization +was necessary, but no existing implementation provided the proper +behavior. The working group invented and standardized functionality +in these areas, which Bash implements. The +.B command +builtin was invented so that shell functions could be written to +replace builtins; it makes the capabilities of the builtin +available to the function. The reserved word \*Q!\*U was added +to negate the return value of a command or pipeline; it was nearly +impossible to express \*Qif not x\*U cleanly using the sh language. +There exist multiple incompatible implementations of the +.B test +builtin, which tests files for type and other attributes and performs +arithmetic and string comparisons. +POSIX considered none of these correct, so the standard +behavior was specified in terms of the number of arguments to the +command. POSIX.2 dictates exactly what will happen when four or +fewer arguments are given to +.B test , +and leaves the behavior undefined when more arguments are supplied. +Bash uses the POSIX.2 algorithm, which was conceived by David Korn. +.NH 2 +Features not in the Bourne Shell +.PP +There are a number of minor differences between Bash and the +version of sh present on most other versions of \s-1UNIX\s+1. The majority +of these are due to the POSIX standard, but some are the result of +Bash adopting features from other shells. For instance, Bash +includes the new \*Q!\*U reserved word, the +.B command +builtin, the ability of the +.B read +builtin to correctly return a line ending with a backslash, symbolic +arguments to the +.B umask +builtin, variable substring removal, a way to get the length of a variable, +and the new algorithm for the +.B test +builtin from the POSIX.2 standard, none of which appear in sh. +.PP +Bash also implements the \*Q$(...)\*U command substitution syntax, +which supersedes the sh `...` construct. +The \*Q$(...)\*U construct expands to the output of the command +contained within the +parentheses, with trailing newlines removed. The sh syntax is +accepted for backwards compatibility, but the \*Q$(...)\*U form +is preferred because its quoting rules are much simpler and it +is easier to nest. +.PP +The Bourne shell does not provide such features as brace expansion, +the ability +to define a variable and a function with the same name, local variables +in shell functions, the ability to enable and disable individual +builtins or write a function to replace a builtin, or a means to +export a shell function to a child process. +.PP +Bash has closed +a long-standing shell security hole by not using the +.B $IFS +variable to split each word read by the shell, but splitting only +the results of expansion (ksh and the 4.4 BSD sh have fixed this +as well). Useful behavior such as a means to abort +execution of a script read with the \*Q.\*U command using the +\fBreturn\fP builtin or automatically +exporting variables in the shell's environment to children is also +not present in the Bourne shell. Bash provides a much more powerful +environment for both interactive use and programming. +.NH 1 +Bash-specific Features +.PP +This section details a few of the features which make Bash unique. +Most of them provide improved interactive use, but a few programming +improvements are present as well. Full descriptions of these +features can be found in the Bash documentation. +.NH 2 +Startup Files +.PP +Bash executes startup files differently than other shells. The Bash +behavior is a compromise between the csh principle of startup files +with fixed names executed for each shell and the sh +\*Qminimalist\*U behavior. An interactive instance of Bash started +as a login shell reads and executes +.I ~/.bash_profile +(the file .bash_profile in the user's home directory), if it exists. +An interactive non-login shell reads and executes +.I ~/.bashrc . +A non-interactive shell (one begun to execute a shell script, for +example) reads no fixed startup file, but uses the value of the variable +.B $ENV , +if set, as the name of a startup file. The ksh practice of reading +.B $ENV +for every shell, with the accompanying difficulty of defining the +proper variables and functions for interactive and non-interactive +shells or having the file read only for interactive shells, was +considered too complex. Ease of use won out here. Interestingly, +the next release of ksh will change to reading +.B $ENV +only for interactive shells. +.NH 2 +New Builtin Commands +.PP +There are a few builtins which are new or have been extended in Bash. +The +.B enable +builtin allows builtin commands to be turned on and off arbitrarily. +To use the version of +.I echo +found in a user's search path rather than the Bash builtin, +\f(CRenable -n echo\fP suffices. The +.B help +builtin provides +quick synopses of the shell facilities without requiring +access to a manual page. +.B Builtin +is similar to +.B command +in that it bypasses shell functions and directly executes builtin +commands. Access to a csh-style stack of directories is provided +via the +.B pushd , +.B popd , +and +.B dirs +builtins. +.B Pushd +and +.B popd +insert and remove directories from the stack, respectively, and +.B dirs +lists the stack contents. On systems that allow fine-grained control +of resources, the +.B ulimit +builtin can be used to tune these settings. +.B Ulimit +allows a user to control, +among other things, whether core dumps are to be generated, +how much memory the shell or a child process is allowed to allocate, +and how large a file created by a child process can grow. The +.B suspend +command will stop the shell process when job control is active; most +other shells do not allow themselves to be stopped like that. +.B Type, +the Bash answer to +.B which +and +.B whence, +shows what will happen when a word is typed as a command: +.SE +$ type export +export is a shell builtin +$ type -t export +builtin +$ type bash +bash is /bin/bash +$ type cd +cd is a function +cd () +{ + builtin cd ${1+"$@"} && xtitle $HOST: $PWD +} +.EE +.LP +Various +modes tell what a command word is (reserved word, alias, function, builtin, +or file) or which version of a command will be executed based on +a user's search path. Some of this functionality has been adopted +by POSIX.2 and folded into the +.B command +utility. +.NH 2 +Editing and Completion +.PP +One area in which Bash shines is command line editing. Bash uses the +.I readline +library to read and edit lines when interactive. Readline is a +powerful and flexible input facility that a user can configure to +individual tastes. It allows lines to be edited using either emacs +or vi commands, where those commands are appropriate. The full +capability of emacs is not present \- there is no way to execute +a named command with M-x, for instance \- but the existing commands +are more than adequate. The vi mode is compliant with +the command line editing standardized by POSIX.2. +.PP +Readline is fully customizable. In addition to the basic commands +and key bindings, the library allows users to define additional +key bindings using a startup file. The +.I inputrc +file, which defaults to the file +.I ~/.inputrc , +is read each time readline initializes, permitting users to +maintain a consistent interface across a set of programs. Readline +includes an extensible interface, so each program using the +library can add its own bindable commands and program-specific +key bindings. Bash uses this facility to add bindings +that perform history expansion or shell word expansions on the current +input line. +.PP +Readline interprets a number of +variables which further tune its behavior. Variables +exist to control whether or not eight-bit characters are directly +read as input or converted to meta-prefixed key sequences (a +meta-prefixed key sequence consists of the character with the +eighth bit zeroed, preceded by the +.I meta-prefix +character, usually escape, which selects an alternate keymap), to +decide whether to output characters with the eighth bit set +directly or as a meta-prefixed key sequence, whether or not to +wrap to a new screen line when a line being edited is longer than +the screen width, the keymap to which subsequent key bindings should +apply, or even what happens when readline wants to +ring the terminal's bell. All of these variables can be set in +the inputrc file. +.PP +The startup file understands a set of C +preprocessor-like conditional constructs which allow variables or +key bindings to be assigned based on the application using readline, +the terminal currently being used, or the editing mode. Users can +add program-specific bindings to make their lives easier: I have +bindings that let me edit the value of +.B $PATH +and double-quote the current or previous word: +.SE +# Macros that are convenient for shell interaction +$if Bash +# edit the path +"\eC-xp": "PATH=${PATH}\ee\eC-e\eC-a\eef\eC-f" +# prepare to type a quoted word -- insert open and close double +# quotes and move to just after the open quote +"\eC-x\e"": "\e"\e"\eC-b" +# Quote the current or previous word +"\eC-xq": "\eeb\e"\eef\e"" +$endif +.EE +.LP +There is a readline +command to re-read the file, so users can edit the file, change +some bindings, and begin to use them almost immediately. +.PP +Bash implements the +.B bind +builtin for more dynamic control of readline than the startup file +permits. +.B Bind +is used in several ways. In +.I list +mode, it can display the current key bindings, list all the +readline editing directives available for binding, list which keys +invoke a given directive, or output the current set of key +bindings in a format that can be incorporated directly into an inputrc +file. In +.I batch +mode, it reads a series of key bindings directly from a file and +passes them to readline. In its most common usage, +.B bind +takes a single string and passes it directly to readline, which +interprets the line as if it had just been read from the inputrc file. +Both key bindings and variable assignments may appear in the +string given to +.B bind . +.PP +The readline library also provides an interface for \fIword completion\fP. +When the +.I completion +character (usually TAB) is typed, readline looks at the word currently +being entered and computes the set of filenames of which the current +word is a valid prefix. +If there is only one possible completion, the +rest of the characters are inserted directly, otherwise the +common prefix of the set of filenames is added to the current word. +A second TAB character entered immediately after a non-unique +completion causes readline to list the possible completions; there is +an option to have the list displayed immediately. +Readline provides hooks so that applications can provide specific types +of completion before the default filename completion is attempted. +This is quite flexible, though it is not completely user-programmable. +Bash, for example, can complete filenames, command names (including aliases, +builtins, shell reserved words, shell functions, and executables found +in the file system), shell variables, usernames, and hostnames. It +uses a set of heuristics that, while not perfect, is generally quite +good at determining what type of completion to attempt. +.NH 2 +History +.PP +Access to the list of commands previously entered (the \fIcommand history\fP) +is provided jointly by Bash and the readline library. Bash provides +variables (\fB$HISTFILE\fP, \fB$HISTSIZE\fP, and \fB$HISTCONTROL\fP) +and the +.B history +and +.B fc +builtins to manipulate the history list. +The value of +.B $HISTFILE +specifies the file where Bash writes the command history on exit and +reads it on startup. +.B $HISTSIZE +is used to limit the number of commands saved in the history. +.B $HISTCONTROL +provides a crude form of control over which commands are saved on +the history list: a value of +.I ignorespace +means to not save commands which begin with a space; a value of +.I ignoredups +means to not save commands identical to the last command saved. +\fB$HISTCONTROL\fP was named \fB$history_control\fP in earlier +versions of Bash; the old name is still accepted for backwards +compatibility. The +.B history +command can read or write files containing the history list +and display the current list contents. The +.B fc +builtin, adopted from POSIX.2 and the Korn Shell, allows display +and re-execution, with optional editing, +of commands from the history list. The readline +library offers a set of commands to search the history list for +a portion of the current input line or a string typed by the user. +Finally, the +.I history +library, generally incorporated directly into the readline library, +implements a facility for history recall, expansion, and re-execution +of previous commands very similar to csh +(\*Qbang history\*U, so called because the exclamation point +introduces a history substitution): +.SE +$ echo a b c d e +a b c d e +$ !! f g h i +echo a b c d e f g h i +a b c d e f g h i +$ !-2 +echo a b c d e +a b c d e +$ echo !-2:1-4 +echo a b c d +a b c d +.EE +.LP +The command history is only +saved when the shell is interactive, so it is not available for use +by shell scripts. +.NH 2 +New Shell Variables +.PP +There are a number of convenience variables that Bash interprets +to make life easier. These include +.B FIGNORE , +which is a set of filename suffixes identifying files to exclude when +completing filenames; +.B HOSTTYPE , +which is automatically set to a string describing the type of +hardware on which Bash is currently executing; +.B command_oriented_history , +which directs Bash to save all lines of a multiple-line +command such as a \fIwhile\fP or \fIfor\fP loop in a single +history entry, allowing easy re-editing; and +.B IGNOREEOF , +whose value indicates the number of consecutive EOF characters that +an interactive shell will read before exiting \- an easy way to keep +yourself from being logged out accidentally. The +.B auto_resume +variable alters the way the shell treats simple command names: +if job control is active, and this variable is set, single-word +simple commands without redirections cause the shell to first +look for and restart a suspended job with that name before +starting a new process. +.NH 2 +Brace Expansion +.PP +Since sh offers no convenient way to generate arbitrary strings that +share a common prefix or suffix (filename expansion requires that +the filenames exist), Bash implements \fIbrace expansion\fP, a +capability picked up from csh. +Brace expansion is similar to filename expansion, but the strings +generated need not correspond to existing files. A brace expression +consists of an optional +.I preamble , +followed by a pair of braces enclosing a series of comma-separated +strings, and an optional +.I postamble . +The preamble is prepended to each string within the braces, and the +postamble is then appended to each resulting string: +.SE +$ echo a{d,c,b}e +ade ace abe +.EE +.LP +As this example demonstrates, the results of brace expansion are not +sorted, as they are by filename expansion. +.NH 2 +Process Substitution +.PP +On systems that can support it, Bash provides a facility known as +\fIprocess substitution\fP. Process substitution is similar to command +substitution in that its specification includes a command to execute, +but the shell does not collect the command's output and insert it into +the command line. Rather, Bash opens a pipe to the command, which +is run in the background. The shell uses named pipes (FIFOs) or the +.I /dev/fd +method of naming open files to expand the process +substitution to a filename which connects to the pipe when opened. +This filename becomes the result of the expansion. Process substitution +can be used to compare the outputs of two different versions of an +application as part of a regression test: +.SE +$ cmp <(old_prog) <(new_prog) +.EE +.NH 2 +Prompt Customization +.PP +One of the more popular interactive features that Bash provides is +the ability to customize the prompt. Both +.B $PS1 +and +.B $PS2, +the primary and secondary prompts, are expanded before being +displayed. Parameter and variable expansion is performed when +the prompt string is expanded, so any shell variable can be +put into the prompt (e.g., +.B $SHLVL , +which indicates how deeply the current shell is nested). +Bash specially interprets characters in the prompt string +preceded by a backslash. Some of these backslash escapes are +replaced with +the current time, the date, the current working directory, +the username, and the command number or history number of the command +being entered. There is even a backslash escape to cause the shell +to change its prompt when running as root after an \fIsu\fP. +Before printing each primary prompt, Bash expands the variable +.B $PROMPT_COMMAND +and, if it has a value, executes the expanded value as a command, +allowing additional prompt customization. For example, this assignment +causes the current user, the current host, the time, the last +component of the current working directory, the level of shell +nesting, and the history number of the current command to be embedded +into the primary prompt: +.SE +$ PS1='\eu@\eh [\et] \eW($SHLVL:\e!)\e$ ' +chet@odin [21:03:44] documentation(2:636)$ cd .. +chet@odin [21:03:54] src(2:637)$ +.EE +.LP +The string being assigned is surrounded by single quotes so that if +it is exported, the value of +.B $SHLVL +will be updated by a child shell: +.SE +chet@odin [21:17:35] src(2:638)$ export PS1 +chet@odin [21:17:40] src(2:639)$ bash +chet@odin [21:17:46] src(3:696)$ +.EE +.LP +The \fP\e$\fP escape is displayed +as \*Q\fB$\fP\*U when running as a normal user, but as \*Q\fB#\fP\*U when +running as root. +.NH 2 +File System Views +.PP +Since Berkeley introduced symbolic links in 4.2 BSD, one of their most +annoying properties has been the \*Qwarping\*U to a completely +different area of the file system when using +.B cd , +and the resultant non-intuitive behavior of \*Q\fBcd ..\fP\*U. +The \s-1UNIX\s+1 kernel treats symbolic links +.I physically . +When the kernel is translating a pathname +in which one component is a symbolic link, it replaces all or part +of the pathname while processing the link. If the contents of the symbolic +link begin with a slash, the kernel replaces the +pathname entirely; if not, the link contents replace +the current component. In either case, the symbolic link +is visible. If the link value is an absolute pathname, +the user finds himself in a completely different part of the file +system. +.PP +Bash provides a +.I logical +view of the file system. In this default mode, command and filename +completion and builtin commands such as +.B cd +and +.B pushd +which change the current working directory transparently follow +symbolic links as if they were directories. +The +.B $PWD +variable, which holds the shell's idea of the current working directory, +depends on the path used to reach the directory rather than its +physical location in the local file system hierarchy. For example: +.SE +$ cd /usr/local/bin +$ echo $PWD +/usr/local/bin +$ pwd +/usr/local/bin +$ /bin/pwd +/net/share/sun4/local/bin +$ cd .. +$ pwd +/usr/local +$ /bin/pwd +/net/share/sun4/local +$ cd .. +$ pwd +/usr +$ /bin/pwd +/usr +.EE +.LP +One problem with this, of +course, arises when programs that do not understand the shell's logical +notion of the file system interpret \*Q..\*U differently. This generally +happens when Bash completes filenames containing \*Q..\*U according to a +logical hierarchy which does not correspond to their physical location. +For users who find this troublesome, a corresponding +.I physical +view of the file system is available: +.SE +$ cd /usr/local/bin +$ pwd +/usr/local/bin +$ set -o physical +$ pwd +/net/share/sun4/local/bin +.EE +.NH 2 +Internationalization +.PP +One of the most significant improvements in version 1.13 of Bash was the +change to \*Qeight-bit cleanliness\*U. Previous versions used the +eighth bit of characters to mark whether or not they were +quoted when performing word expansions. While this did not affect +the majority of users, most of whom used only seven-bit ASCII characters, +some found it confining. Beginning with version 1.13, Bash +implemented a different quoting mechanism that did not alter the +eighth bit of characters. This allowed Bash +to manipulate files with \*Qodd\*U characters in their names, but +did nothing to help users enter those names, so +version 1.13 introduced changes to readline that +made it eight-bit clean as well. Options exist that force readline to +attach no special significance to characters with the eighth bit set +(the default behavior is to convert these characters to meta-prefixed +key sequences) and to output these characters without conversion to +meta-prefixed sequences. These changes, along with the expansion of +keymaps to a full eight bits, enable readline to work with most of the +ISO-8859 family of character sets, used by many European countries. +.NH 2 +POSIX Mode +.PP +Although Bash is intended to be POSIX.2 conformant, there are areas in +which the default behavior is not compatible with the standard. For +users who wish to operate in a strict POSIX.2 environment, Bash +implements a \fIPOSIX mode\fP. When this mode is active, Bash modifies +its default operation where it differs from POSIX.2 to match the +standard. POSIX mode is entered when Bash is started with the +.B -posix +option. This feature is also available as an option to the +\fBset\fP builtin, \fBset -o posix\fP. +For compatibility with other GNU software that attempts to be POSIX.2 +compliant, Bash also enters POSIX mode if the variable +.B $POSIXLY_CORRECT +is set when Bash is started or assigned a value during execution. +.B $POSIX_PEDANTIC +is accepted as well, to be compatible with some older GNU utilities. +When Bash is started in POSIX mode, for example, it sources the +file named by the value of +.B $ENV +rather than the \*Qnormal\*U startup files, and does not allow +reserved words to be aliased. +.NH 1 +New Features and Future Plans +.PP +There are several features introduced in the current +version of Bash, version 1.14, and a number under consideration +for future releases. This section will briefly detail the new +features in version 1.14 and describe several features +that may appear in later versions. +.NH 2 +New Features in Bash-1.14 +.PP +The new features available in Bash-1.14 answer several of +the most common requests for enhancements. Most notably, there +is a mechanism +for including non-visible character sequences in prompts, such as +those which cause a terminal to print characters in different +colors or in standout mode. There was nothing preventing the use +of these sequences in earlier +versions, but the readline redisplay algorithm assumed each +character occupied physical screen space and would wrap lines +prematurely. +.PP +Readline has a few new +variables, several new bindable commands, and some additional +emacs mode default key bindings. A new history search +mode has been implemented: in this mode, readline searches the +history for lines beginning with the characters between the +beginning of the current line and the cursor. The existing readline +incremental search commands no longer match identical lines more +than once. +Filename completion now expands variables in directory names. +The history expansion facilities are now nearly +completely csh-compatible: missing modifiers have been added and +history substitution has been extended. +.PP +Several of the features described earlier, such as +.B "set -o posix" +and +.B $POSIX_PEDANTIC , +are new in version 1.14. +There is a new shell variable, +.B OSTYPE , +to which Bash assigns a value that identifies the +version of \s-1UNIX\s+1 it's +running on (great for putting architecture-specific binary directories +into the \fB$PATH\fP). +Two variables have been renamed: +.B $HISTCONTROL +replaces +.B $history_control , +and +.B $HOSTFILE +replaces +.B $hostname_completion_file . +In both cases, the old names are accepted for backwards +compatibility. The ksh +.I select +construct, which allows the generation of simple menus, +has been implemented. New capabilities have been added +to existing variables: +.B $auto_resume +can now take values of +.I exact +or +.I substring , +and +.B $HISTCONTROL +understands the value +.I ignoreboth , +which combines the two previously acceptable values. The +.B dirs +builtin has acquired options to print out specific members of the +directory stack. The +.B $nolinks +variable, which forces a physical view of the file system, +has been superseded by the +.B \-P +option to the +.B set +builtin (equivalent to \fBset -o physical\fP); the variable is retained +for backwards compatibility. The version string contained in +.B $BASH_VERSION +now includes an indication of the patch level as well as the +\*Qbuild version\*U. +Some little-used features have +been removed: the +.B bye +synonym for +.B exit +and the +.B $NO_PROMPT_VARS +variable are gone. There is now an organized test suite that can be +run as a regression test when building a new version of Bash. +.PP +The documentation has been thoroughly overhauled: +there is a new manual page on the readline library and the \fIinfo\fP +file has been updated to reflect the current version. +As always, as many bugs as possible have been fixed, although some +surely remain. +.NH 2 +Other Features +.PP +There are a few features that I hope to include in later Bash releases. +Some are based on work already done in other shells. +.PP +In addition to simple variables, a future release of Bash will include +one-dimensional arrays, using the ksh +implementation of arrays as a model. Additions to the ksh syntax, +such as \fIvarname\fP=( ... ) to assign a list of words directly to +an array and a mechanism to allow +the +.B read +builtin to read a list of values directly into an array, would be +desirable. Given those extensions, the ksh +.B "set \-A" +syntax may not be worth supporting (the +.B \-A +option assigns a list of values to an array, but is a rather +peculiar special case). +.PP +Some shells include a means of \fIprogrammable\fP word +completion, where the user specifies on a per-command basis how the +arguments of the command are to be treated when completion is attempted: +as filenames, hostnames, executable files, and so on. The other +aspects of the current Bash implementation could remain as-is; the +existing heuristics would still be valid. Only when completing the +arguments to a simple command would the programmable completion be +in effect. +.PP +It would also be nice to give the user finer-grained +control over which commands are saved onto the history list. One +proposal is for a variable, tentatively named +.B HISTIGNORE , +which would contain a colon-separated list of commands. Lines beginning +with these commands, after the restrictions of +.B $HISTCONTROL +have been applied, would not be placed onto the history list. The +shell pattern-matching capabilities could also be available when +specifying the contents of +.B $HISTIGNORE . +.PP +One thing that newer shells such as +.B wksh +(also known as +.B dtksh ) +provide is a command to dynamically load code +implementing additional builtin commands into a running shell. +This new builtin would take an object file or shared library +implementing the \*Qbody\*U of the +builtin (\fIxxx_builtin()\fP for those familiar with Bash internals) +and a structure containing the name of the new command, the function +to call when the new builtin is invoked (presumably defined in the +shared object specified as an argument), and the documentation to be +printed by the +.B help +command (possibly present in the shared object as well). It would +manage the details of extending the internal table of builtins. +.PP +A few other builtins would also be desirable: two are the POSIX.2 +.B getconf +command, which prints the values of system configuration variables +defined by POSIX.2, and a +.B disown +builtin, which causes a shell running +with job control active to \*Qforget about\*U one or more +background jobs in its internal jobs table. Using +.B getconf , +for example, a user could retrieve a value for +.B $PATH +guaranteed to find all of the POSIX standard utilities, or +find out how long filenames may be in the file system containing +a specified directory. +.PP +There are no implementation timetables for any of these features, nor +are there concrete plans to include them. If anyone has comments on +these proposals, feel free to send me electronic mail. +.NH 1 +Reflections and Lessons Learned +.PP +The lesson that has been repeated most often during Bash +development is that there are dark corners in the Bourne shell, +and people use all of them. In the original description of the +Bourne shell, quoting and the shell grammar are both poorly +specified and incomplete; subsequent descriptions have not helped +much. The grammar presented in Bourne's paper describing +the shell distributed with the Seventh Edition of \s-1UNIX\s+1\(dg +is so far off that it does not allow the command \f(CWwho|wc\fP. +In fact, as Tom Duff states: +.QP +Nobody really knows what the +Bourne shell's grammar is. Even examination of the source code is +little help.\(dd +.FS +\(dgS. R. Bourne, \*QUNIX Time-Sharing System: The UNIX Shell\*U, +\fIBell System Technical Journal\fP, 57(6), July-August, 1978, pp. 1971-1990. +.FE +.FS +\(ddTom Duff, \*QRc \- A Shell for Plan 9 and \s-1UNIX\s+1 systems\*U, +\fIProc. of the Summer 1990 EUUG Conference\fP, London, July, 1990, +pp. 21-33. +.FE +.LP +The POSIX.2 standard includes a \fIyacc\fP grammar that comes close +to capturing the Bourne shell's behavior, but it disallows some +constructs which sh accepts without complaint \- and there are +scripts out there that use them. It took a few versions and +several bug reports before Bash implemented sh-compatible quoting, +and there are still some \*Qlegal\*U sh constructs which Bash flags as +syntax errors. Complete sh compatibility is a tough nut. +.PP +The shell is bigger and slower than I would like, though the current +version is substantially faster than previously. The readline library +could stand a substantial rewrite. A hand-written parser to replace +the current \fIyacc\fP-generated one would probably result in a speedup, +and would solve one glaring problem: the shell could parse +commands in \*Q$(...)\*U constructs +as they are entered, rather than reporting errors when the construct +is expanded. +.PP +As always, there is some chaff to go with the wheat. +Areas of duplicated functionality need to be cleaned +up. There are several cases where Bash treats a variable specially to +enable functionality available another way (\fB$notify\fP vs. +\fBset -o notify\fP and \fB$nolinks\fP vs. \fBset -o physical\fP, for +instance); the special treatment of the variable name should probably +be removed. A few more things could stand removal; the +.B $allow_null_glob_expansion +and +.B $glob_dot_filenames +variables are of particularly questionable value. +The \fB$[...]\fP arithmetic evaluation syntax is redundant now that +the POSIX-mandated \fB$((...))\fP construct has been implemented, +and could be deleted. +It would be nice if the text output by the +.B help +builtin were external to the shell rather than compiled into it. +The behavior enabled by +.B $command_oriented_history , +which causes the shell to attempt to save all lines of a multi-line +command in a single history entry, should be made the default and +the variable removed. +.NH 1 +Availability +.PP +As with all other +GNU software, Bash is available for anonymous FTP from +.I prep.ai.mit.edu:/pub/gnu +and from other GNU software mirror sites. The current version is in +.I bash-1.14.1.tar.gz +in that directory. Use +.I archie +to find the nearest archive site. The +latest version is always available for FTP from +.I bash.CWRU.Edu:/pub/dist. +Bash documentation is available for FTP from +.I bash.CWRU.Edu:/pub/bash. +.PP +The Free Software Foundation sells tapes and CD-ROMs +containing Bash; send electronic mail to +\f(CRgnu@prep.ai.mit.edu\fP or call \f(CR+1-617-876-3296\fP +for more information. +.PP +Bash is also distributed with several versions of \s-1UNIX\s+1-compatible +systems. It is included as /bin/sh and /bin/bash on several Linux +distributions (more about the difference in a moment), and as contributed +software in BSDI's BSD/386* and FreeBSD. +.FS +*BSD/386 is a trademark of Berkeley Software Design, Inc. +.FE +.PP +The Linux distribution deserves special mention. There are two +configurations included in the standard Bash distribution: a +\*Qnormal\*U configuration, in which all of the standard features +are included, and a \*Qminimal\*U configuration, which omits job +control, aliases, history and command line editing, the directory +stack and +.B pushd/popd/dirs, +process substitution, prompt string special character decoding, and the +.I select +construct. This minimal version is designed to be a drop-in replacement +for the traditional \s-1UNIX\s+1 /bin/sh, and is included as the Linux +/bin/sh in several packagings. +.NH 1 +Conclusion +.PP +Bash is a worthy successor to sh. +It is sufficiently portable +to run on nearly every version of \s-1UNIX\s+1 from +4.3 BSD to SVR4.2, and several \s-1UNIX\s+1 workalikes. +It is robust enough to replace sh on most of those systems, +and provides more functionality. It has several thousand regular users, +and their feedback has helped to make it as good as it is today \- a +testament to the benefits of free software. diff --git a/doc/article.pdf b/doc/article.pdf new file mode 100644 index 0000000..1272a90 Binary files /dev/null and b/doc/article.pdf differ diff --git a/doc/article.ps b/doc/article.ps new file mode 100644 index 0000000..adbeba0 --- /dev/null +++ b/doc/article.ps @@ -0,0 +1,1442 @@ +%!PS-Adobe-3.0 +%%Creator: groff version 1.19.2 +%%CreationDate: Tue Oct 22 11:07:52 2013 +%%DocumentNeededResources: font Times-Bold +%%+ font Times-Italic +%%+ font Times-Roman +%%+ font Courier +%%DocumentSuppliedResources: procset grops 1.19 2 +%%Pages: 11 +%%PageOrder: Ascend +%%DocumentMedia: Default 612 792 0 () () +%%Orientation: Portrait +%%EndComments +%%BeginDefaults +%%PageMedia: Default +%%EndDefaults +%%BeginProlog +%%BeginResource: procset grops 1.19 2 +%!PS-Adobe-3.0 Resource-ProcSet +/setpacking where{ +pop +currentpacking +true setpacking +}if +/grops 120 dict dup begin +/SC 32 def +/A/show load def +/B{0 SC 3 -1 roll widthshow}bind def +/C{0 exch ashow}bind def +/D{0 exch 0 SC 5 2 roll awidthshow}bind def +/E{0 rmoveto show}bind def +/F{0 rmoveto 0 SC 3 -1 roll widthshow}bind def +/G{0 rmoveto 0 exch ashow}bind def +/H{0 rmoveto 0 exch 0 SC 5 2 roll awidthshow}bind def +/I{0 exch rmoveto show}bind def +/J{0 exch rmoveto 0 SC 3 -1 roll widthshow}bind def +/K{0 exch rmoveto 0 exch ashow}bind def +/L{0 exch rmoveto 0 exch 0 SC 5 2 roll awidthshow}bind def +/M{rmoveto show}bind def +/N{rmoveto 0 SC 3 -1 roll widthshow}bind def +/O{rmoveto 0 exch ashow}bind def +/P{rmoveto 0 exch 0 SC 5 2 roll awidthshow}bind def +/Q{moveto show}bind def +/R{moveto 0 SC 3 -1 roll widthshow}bind def +/S{moveto 0 exch ashow}bind def +/T{moveto 0 exch 0 SC 5 2 roll awidthshow}bind def +/SF{ +findfont exch +[exch dup 0 exch 0 exch neg 0 0]makefont +dup setfont +[exch/setfont cvx]cvx bind def +}bind def +/MF{ +findfont +[5 2 roll +0 3 1 roll +neg 0 0]makefont +dup setfont +[exch/setfont cvx]cvx bind def +}bind def +/level0 0 def +/RES 0 def +/PL 0 def +/LS 0 def +/MANUAL{ +statusdict begin/manualfeed true store end +}bind def +/PLG{ +gsave newpath clippath pathbbox grestore +exch pop add exch pop +}bind def +/BP{ +/level0 save def +1 setlinecap +1 setlinejoin +72 RES div dup scale +LS{ +90 rotate +}{ +0 PL translate +}ifelse +1 -1 scale +}bind def +/EP{ +level0 restore +showpage +}def +/DA{ +newpath arcn stroke +}bind def +/SN{ +transform +.25 sub exch .25 sub exch +round .25 add exch round .25 add exch +itransform +}bind def +/DL{ +SN +moveto +SN +lineto stroke +}bind def +/DC{ +newpath 0 360 arc closepath +}bind def +/TM matrix def +/DE{ +TM currentmatrix pop +translate scale newpath 0 0 .5 0 360 arc closepath +TM setmatrix +}bind def +/RC/rcurveto load def +/RL/rlineto load def +/ST/stroke load def +/MT/moveto load def +/CL/closepath load def +/Fr{ +setrgbcolor fill +}bind def +/setcmykcolor where{ +pop +/Fk{ +setcmykcolor fill +}bind def +}if +/Fg{ +setgray fill +}bind def +/FL/fill load def +/LW/setlinewidth load def +/Cr/setrgbcolor load def +/setcmykcolor where{ +pop +/Ck/setcmykcolor load def +}if +/Cg/setgray load def +/RE{ +findfont +dup maxlength 1 index/FontName known not{1 add}if dict begin +{ +1 index/FID ne{def}{pop pop}ifelse +}forall +/Encoding exch def +dup/FontName exch def +currentdict end definefont pop +}bind def +/DEFS 0 def +/EBEGIN{ +moveto +DEFS begin +}bind def +/EEND/end load def +/CNT 0 def +/level1 0 def +/PBEGIN{ +/level1 save def +translate +div 3 1 roll div exch scale +neg exch neg exch translate +0 setgray +0 setlinecap +1 setlinewidth +0 setlinejoin +10 setmiterlimit +[]0 setdash +/setstrokeadjust where{ +pop +false setstrokeadjust +}if +/setoverprint where{ +pop +false setoverprint +}if +newpath +/CNT countdictstack def +userdict begin +/showpage{}def +/setpagedevice{}def +}bind def +/PEND{ +countdictstack CNT sub{end}repeat +level1 restore +}bind def +end def +/setpacking where{ +pop +setpacking +}if +%%EndResource +%%EndProlog +%%BeginSetup +%%BeginFeature: *PageSize Default +<< /PageSize [ 612 792 ] /ImagingBBox null >> setpagedevice +%%EndFeature +%%IncludeResource: font Times-Bold +%%IncludeResource: font Times-Italic +%%IncludeResource: font Times-Roman +%%IncludeResource: font Courier +grops begin/DEFS 1 dict def DEFS begin/u{.001 mul}bind def end/RES 72 +def/PL 792 def/LS false def/ENC0[/asciicircum/asciitilde/Scaron/Zcaron +/scaron/zcaron/Ydieresis/trademark/quotesingle/Euro/.notdef/.notdef +/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef +/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef +/.notdef/.notdef/space/exclam/quotedbl/numbersign/dollar/percent +/ampersand/quoteright/parenleft/parenright/asterisk/plus/comma/hyphen +/period/slash/zero/one/two/three/four/five/six/seven/eight/nine/colon +/semicolon/less/equal/greater/question/at/A/B/C/D/E/F/G/H/I/J/K/L/M/N/O +/P/Q/R/S/T/U/V/W/X/Y/Z/bracketleft/backslash/bracketright/circumflex +/underscore/quoteleft/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y +/z/braceleft/bar/braceright/tilde/.notdef/quotesinglbase/guillemotleft +/guillemotright/bullet/florin/fraction/perthousand/dagger/daggerdbl +/endash/emdash/ff/fi/fl/ffi/ffl/dotlessi/dotlessj/grave/hungarumlaut +/dotaccent/breve/caron/ring/ogonek/quotedblleft/quotedblright/oe/lslash +/quotedblbase/OE/Lslash/.notdef/exclamdown/cent/sterling/currency/yen +/brokenbar/section/dieresis/copyright/ordfeminine/guilsinglleft +/logicalnot/minus/registered/macron/degree/plusminus/twosuperior +/threesuperior/acute/mu/paragraph/periodcentered/cedilla/onesuperior +/ordmasculine/guilsinglright/onequarter/onehalf/threequarters +/questiondown/Agrave/Aacute/Acircumflex/Atilde/Adieresis/Aring/AE +/Ccedilla/Egrave/Eacute/Ecircumflex/Edieresis/Igrave/Iacute/Icircumflex +/Idieresis/Eth/Ntilde/Ograve/Oacute/Ocircumflex/Otilde/Odieresis +/multiply/Oslash/Ugrave/Uacute/Ucircumflex/Udieresis/Yacute/Thorn +/germandbls/agrave/aacute/acircumflex/atilde/adieresis/aring/ae/ccedilla +/egrave/eacute/ecircumflex/edieresis/igrave/iacute/icircumflex/idieresis +/eth/ntilde/ograve/oacute/ocircumflex/otilde/odieresis/divide/oslash +/ugrave/uacute/ucircumflex/udieresis/yacute/thorn/ydieresis]def +/Courier@0 ENC0/Courier RE/Times-Roman@0 ENC0/Times-Roman RE +/Times-Italic@0 ENC0/Times-Italic RE/Times-Bold@0 ENC0/Times-Bold RE +%%EndSetup +%%Page: 1 1 +%%BeginPageSetup +BP +%%EndPageSetup +/F0 12/Times-Bold@0 SF(Bash \255 The GNU shell*)227.904 123 Q/F1 10 +/Times-Italic@0 SF(Chet Rame)263.85 159 Q(y)-.3 E(Case W)221.72 171 Q +(estern Reserve Univer)-.92 E(sity)-.1 E -.15(ch)250.425 183 S +(et@po.cwru.edu).15 E/F2 10/Times-Bold@0 SF 2.5(1. Intr)72 219 R +(oduction)-.18 E(Bash)97 234.6 Q/F3 10/Times-Roman@0 SF .904 +(is the shell, or command language interpreter)3.404 F 3.404(,t)-.4 G +.904(hat will appear in the GNU operating system.)-3.404 F 1.075 +(The name is an acron)72 246.6 R 1.075(ym for the \231Bourne-Ag)-.15 F +1.075(ain SHell\232, a pun on Ste)-.05 F 1.375 -.15(ve B)-.25 H 1.075 +(ourne, the author of the direct).15 F .206(ancestor of the current)72 +258.6 R/F4 8/Times-Roman@0 SF(UNIX)2.706 E F3 2.706C(hell)-2.706 E +F1(/bin/sh)2.706 E F3 2.706(,w)C .205(hich appeared in the Se)-2.706 F +-.15(ve)-.25 G .205(nth Edition Bell Labs Research v).15 F(er)-.15 E(-) +-.2 E(sion of)72 270.6 Q/F5 9/Times-Roman@0 SF(UNIX)2.5 E F3(.)A .387 +(Bash is an)97 286.2 R F2(sh)2.887 E F3 .387 +(\255compatible shell that incorporates useful features from the K)B +.388(orn shell \()-.35 F F2(ksh)A F3 2.888(\)a)C .388(nd the C)-2.888 F +.023(shell \()72 298.2 R F2(csh)A F3 .023 +(\), described later in this article.)B .022 +(It is ultimately intended to be a conformant implementation of the) +5.022 F 3.568(IEEE POSIX Shell and Utilities speci\214cation \(IEEE W)72 +310.2 R 3.568(orking Group 1003.2\).)-.8 F 3.569(It of)8.569 F 3.569 +(fers functional)-.25 F(impro)72 322.2 Q -.15(ve)-.15 G(ments o).15 E +-.15(ve)-.15 G 2.5(rs).15 G 2.5(hf)-2.5 G(or both interacti)-2.5 E .3 +-.15(ve a)-.25 H(nd programming use.).15 E .697 +(While the GNU operating system will most lik)97 337.8 R .697 +(ely include a v)-.1 F .697(ersion of the Berk)-.15 F(ele)-.1 E 3.197 +(ys)-.15 G .696(hell csh, Bash)-3.197 F .015(will be the def)72 349.8 R +.015(ault shell.)-.1 F(Lik)5.015 E 2.515(eo)-.1 G .015(ther GNU softw) +-2.515 F .016(are, Bash is quite portable.)-.1 F .016 +(It currently runs on nearly e)5.016 F -.15(ve)-.25 G(ry).15 E -.15(ve) +72 361.8 S .523(rsion of).15 F F4(UNIX)3.023 E F3 .523(and a fe)3.023 F +3.023(wo)-.25 G .523 +(ther operating systems \255 an independently-supported port e)-3.023 F +.523(xists for OS/2, and)-.15 F .706 +(there are rumors of ports to DOS and W)72 373.8 R(indo)-.4 E .706 +(ws NT)-.25 F 5.706(.P)-.74 G .706(orts to)-5.706 F F5(UNIX)3.206 E F3 +(-lik)A 3.206(es)-.1 G .706(ystems such as QNX and Minix)-3.206 F +(are part of the distrib)72 385.8 Q(ution.)-.2 E .405 +(The original author of Bash w)97 401.4 R .405(as Brian F)-.1 F .405 +(ox, an emplo)-.15 F .405(yee of the Free Softw)-.1 F .405(are F)-.1 F +2.905(oundation. The)-.15 F(cur)2.905 E(-)-.2 E(rent de)72 413.4 Q -.15 +(ve)-.25 G(loper and maintainer is Chet Rame).15 E 1.3 -.65(y, a v)-.15 +H(olunteer who w).45 E(orks at Case W)-.1 E(estern Reserv)-.8 E 2.5(eU) +-.15 G(ni)-2.5 E -.15(ve)-.25 G(rsity).15 E(.)-.65 E F2 2.5(2. What')72 +437.4 R 2.5(sP)-.37 G(OSIX, anyway?)-2.5 E F1(POSIX)97 453 Q F3 .343 +(is a name originally coined by Richard Stallman for a f)2.843 F .343 +(amily of open system standards based)-.1 F(on)72 465 Q F5(UNIX)3.24 E +F3 5.74(.T)C .74(here are a number of aspects of)-5.74 F F5(UNIX)3.24 E +F3 .74(under consideration for standardization, from the basic)3.24 F +.192(system services at the system call and C library le)72 477 R -.15 +(ve)-.25 G 2.692(lt).15 G 2.692(oa)-2.692 G .192 +(pplications and tools to system administration and)-2.692 F 2.5 +(management. Each)72 489 R(area of standardization is assigned to a w) +2.5 E(orking group in the 1003 series.)-.1 E 2.814 +(The POSIX Shell and Utilities standard has been de)97 504.6 R -.15(ve) +-.25 G 2.814(loped by IEEE W).15 F 2.813(orking Group 1003.2)-.8 F .254 +(\(POSIX.2\).\210 It concentrates on the command interpreter interf)72 +516.6 R .253(ace and utility programs commonly e)-.1 F -.15(xe)-.15 G +(cuted).15 E 1.112(from the command line or by other programs.)72 528.6 +R 1.112(An initial v)6.112 F 1.113 +(ersion of the standard has been appro)-.15 F -.15(ve)-.15 G 3.613(da) +.15 G(nd)-3.613 E .365(published by the IEEE, and w)72 540.6 R .365 +(ork is currently underw)-.1 F .365(ay to update it.)-.1 F .365 +(There are four primary areas of w)5.365 F(ork)-.1 E +(in the 1003.2 standard:)72 552.6 Q 21.5<8341>72 568.2 S .835 +(spects of the shell')-21.5 F 3.335(ss)-.55 G .835 +(yntax and command language.)-3.335 F 3.335(An)5.835 G .835 +(umber of special b)-3.335 F .835(uiltins such as)-.2 F F2(cd)3.335 E F3 +(and)3.335 E F2(exec)97 580.2 Q F3 .545(are being speci\214ed as part o\ +f the shell, since their functionality usually cannot be implemented) +3.046 F(by a separate e)97 592.2 Q -.15(xe)-.15 G(cutable;).15 E 21.5 +<8341>72 607.8 S .926 +(set of utilities to be called by shell scripts and applications.) +-18.074 F .927(Examples are programs lik)5.927 F(e)-.1 E F1 .927 +(sed, tr)3.427 F(,)-1.11 E F3(and)97 619.8 Q F1(awk.)2.797 E F3 .297 +(Utilities commonly implemented as shell b)5.297 F .296 +(uiltins are described in this section, such as)-.2 F F2(test)2.796 E F3 +(and)97 631.8 Q F2(kill)3.422 E F3 5.922(.A)C 3.422(ne)-5.922 G .922 +(xpansion of this section')-3.572 F 3.423(ss)-.55 G .923 +(cope, termed the User Portability Extension, or UPE, has)-3.423 F +(standardized interacti)97 643.8 Q .3 -.15(ve p)-.25 H(rograms such as) +.15 E F1(vi)2.5 E F3(and)2.5 E F1(mailx;)2.5 E F3 21.5<8341>72 659.4 S +.288(group of functional interf)-18.712 F .287(aces to services pro)-.1 +F .287(vided by the shell, such as the traditional)-.15 F/F6 10 +/Courier@0 SF(system\(\))2.787 E F3 3.289(Cl)97 671.4 S .789 +(ibrary function.)-3.289 F .789(There are functions to perform shell w) +5.789 F .789(ord e)-.1 F .79(xpansions, perform \214lename e)-.15 F +(xpan-)-.15 E 3.624(sion \()97 683.4 R F1(globbing)A F3 3.624 +(\), obtain v)B 3.624(alues of POSIX.2 system con\214guration v)-.25 F +3.623(ariables, retrie)-.25 F 3.923 -.15(ve v)-.25 H 3.623(alues of)-.1 +F .32 LW 144 691.4 72 691.4 DL F4(*An earlier v)72 703.2 Q +(ersion of this article appeared in The Linux Journal.)-.12 E(\210IEEE,) +72 715 Q/F7 8/Times-Italic@0 SF 1.231(IEEE Standar)3.231 F 3.231(df) +-.296 G 1.231(or Information T)-3.231 F(ec)-.736 E(hnolo)-.12 E 1.231 +(gy -- P)-.08 F 1.231(ortable Oper)-.64 F 1.232 +(ating System Interface \(POSIX\) P)-.12 F 1.232(art 2:)-.64 F +(Shell and Utilities)72 725 Q F4 2(,1)C(992.)-2 E 0 Cg EP +%%Page: 2 2 +%%BeginPageSetup +BP +%%EndPageSetup +/F0 10/Times-Roman@0 SF(-2-)282.17 48 Q(en)97 84 Q(vironment v)-.4 E +(ariables \()-.25 E/F1 10/Courier@0 SF(getenv\(\))A F0 +(\), and other services;).833 E 21.5<8341>72 99.6 S(suite of \231de)-19 +E -.15(ve)-.25 G(lopment\232 utilities such as).15 E/F2 10 +/Times-Italic@0 SF(c89)2.5 E F0(\(the POSIX.2 v)2.5 E(ersion of)-.15 E +F2(cc)2.5 E F0(\), and)A F2(yacc.)2.5 E F0 .483 +(Bash is concerned with the aspects of the shell')97 115.2 R 2.983(sb) +-.55 G(eha)-2.983 E .484(vior de\214ned by POSIX.2.)-.2 F .484 +(The shell command)5.484 F 1.439 +(language has of course been standardized, including the basic \215o)72 +127.2 R 3.938(wc)-.25 G 1.438(ontrol and program e)-3.938 F -.15(xe)-.15 +G 1.438(cution con-).15 F 1.284 +(structs, I/O redirection and pipelining, ar)72 139.2 R 1.284 +(gument handling, v)-.18 F 1.284(ariable e)-.25 F 1.284 +(xpansion, and quoting.)-.15 F(The)6.285 E F2(special)3.785 E F0 -.2(bu) +72 151.2 S .676 +(iltins, which must be implemented as part of the shell to pro).2 F .676 +(vide the desired functionality)-.15 F 3.176(,a)-.65 G .676 +(re speci\214ed)-3.176 F .7(as being part of the shell; e)72 163.2 R .7 +(xamples of these are)-.15 F/F3 10/Times-Bold@0 SF -2.3 -.15(ev a)3.201 +H(l).15 E F0(and)3.201 E F3(export)3.201 E F0 5.701(.O)C .701 +(ther utilities appear in the sections of)-5.701 F .256(POSIX.2 not de) +72 175.2 R -.2(vo)-.25 G .256(ted to the shell which are commonly \(and\ + in some cases must be\) implemented as b).2 F(uiltin)-.2 E .213 +(commands, such as)72 187.2 R F3 -.18(re)2.713 G(ad).18 E F0(and)2.713 E +F3(test)2.713 E F0 5.213(.P)C .213 +(OSIX.2 also speci\214es aspects of the shell')-5.213 F 2.713(si)-.55 G +(nteracti)-2.713 E .513 -.15(ve b)-.25 H(eha).15 E .214(vior as part)-.2 +F .598(of the UPE, including job control and command line editing.)72 +199.2 R .598(Interestingly enough, only)5.598 F F2(vi)3.098 E F0 .598 +(-style line edit-)B(ing commands ha)72 211.2 Q .3 -.15(ve b)-.2 H +(een standardized;).15 E F2(emacs)2.5 E F0 +(editing commands were left out due to objections.)2.5 E 1.128 +(While POSIX.2 includes much of what the shell has traditionally pro)97 +226.8 R 1.129(vided, some important things)-.15 F(ha)72 238.8 Q .344 +-.15(ve b)-.2 H .044(een omitted as being \231be).15 F .044 +(yond its scope.)-.15 F 5.043<9a54>-.7 G .043 +(here is, for instance, no mention of a dif)-5.043 F .043 +(ference between a)-.25 F F2(lo)72 250.8 Q(gin)-.1 E F0 1.445 +(shell and an)3.945 F 3.945(yo)-.15 G 1.445(ther interacti)-3.945 F +1.745 -.15(ve s)-.25 H 1.446 +(hell \(since POSIX.2 does not specify a login program\).).15 F 1.446 +(No \214x)6.446 F(ed)-.15 E(startup \214les are de\214ned, either \255 \ +the standard does not mention)72 262.8 Q F2(.pr)2.5 E(o\214le)-.45 E F0 +(.)A F3 2.5(3. Basic)72 286.8 R(Bash featur)2.5 E(es)-.18 E F0 1.448 +(Since the Bourne shell pro)97 302.4 R 1.448 +(vides Bash with most of its philosophical underpinnings, Bash inherits) +-.15 F .64(most of its features and functionality from sh.)72 314.4 R +.641(Bash implements all of the traditional sh \215o)5.641 F 3.141(wc) +-.25 G .641(ontrol con-)-3.141 F .8(structs \()72 326.4 R F2(for)A F0(,) +A F2(if)3.3 E F0(,)A F2(while)3.3 E F0 3.3(,e)C 3.3(tc.\). All)-3.3 F +.799(of the Bourne shell b)3.3 F .799 +(uiltins, including those not speci\214ed in the POSIX.2)-.2 F .536 +(standard, appear in Bash.)72 338.4 R(Shell)5.536 E F2(functions)3.036 E +F0 3.036(,i)C .536(ntroduced in the SVR2 v)-3.036 F .537 +(ersion of the Bourne shell, are similar)-.15 F .779 +(to shell scripts, b)72 350.4 R .779 +(ut are de\214ned using a special syntax and are e)-.2 F -.15(xe)-.15 G +.779(cuted in the same process as the calling).15 F 2.841(shell. Bash)72 +362.4 R .341(has shell functions which beha)2.841 F .641 -.15(ve i)-.2 H +2.841(naf).15 G .341(ashion upw)-2.941 F .342 +(ard-compatible with sh functions.)-.1 F .342(There are)5.342 F 1.447 +(certain shell v)72 374.4 R 1.446 +(ariables that Bash interprets in the same w)-.25 F 1.446 +(ay as sh, such as)-.1 F F3(PS1)3.946 E F0(,)A F3(IFS)3.946 E F0 3.946 +(,a)C(nd)-3.946 E F3 -.74(PA)3.946 G(TH)-.21 E F0 6.446(.B)C(ash)-6.446 +E 1.423(implements essentially the same grammar)72 386.4 R 3.924(,p)-.4 +G 1.424(arameter and v)-3.924 F 1.424(ariable e)-.25 F 1.424 +(xpansion semantics, redirection, and)-.15 F 1.06 +(quoting as the Bourne shell.)72 398.4 R 1.06(Where dif)6.06 F 1.06 +(ferences appear between the POSIX.2 standard and traditional sh)-.25 F +(beha)72 410.4 Q(vior)-.2 E 2.5(,B)-.4 G(ash follo)-2.5 E(ws POSIX.)-.25 +E 1.608(The K)97 426 R 1.608(orn Shell \()-.35 F F3(ksh)A F0 4.108(\)i)C +4.108(sad)-4.108 G 1.608(escendant of the Bourne shell written at A) +-4.108 F 1.609(T&T Bell Laboratories by)-1.11 F(Da)72 438 Q 1.059(vid K) +-.2 F 3.559(orn\207. It)-.35 F(pro)3.559 E 1.059 +(vides a number of useful features that POSIX and Bash ha)-.15 F 1.359 +-.15(ve a)-.2 H 3.558(dopted. Man).15 F 3.558(yo)-.15 G 3.558(ft)-3.558 +G(he)-3.558 E(interacti)72 450 Q 1.312 -.15(ve f)-.25 H 1.012 +(acilities in POSIX.2 ha).05 F 1.312 -.15(ve t)-.2 H 1.012 +(heir roots in the ksh: for e).15 F 1.013 +(xample, the POSIX and ksh job control)-.15 F -.1(fa)72 462 S .513 +(cilities are nearly identical. Bash includes features from the K).1 F +.513(orn Shell for both interacti)-.35 F .813 -.15(ve u)-.25 H .513 +(se and shell).15 F 3.905(programming. F)72 474 R 1.405 +(or programming, Bash pro)-.15 F 1.405(vides v)-.15 F 1.405 +(ariables such as)-.25 F F3(RANDOM)3.905 E F0(and)3.905 E F3(REPL)3.905 +E(Y)-.92 E F0 3.905(,t)C(he)-3.905 E F3(typeset)3.905 E F0 -.2(bu)72 486 +S .398(iltin, the ability to remo).2 F .698 -.15(ve s)-.15 H .398 +(ubstrings from v).15 F .398 +(ariables based on patterns, and shell arithmetic.)-.25 F F3(RANDOM) +5.397 E F0 -.15(ex)72 498 S .489 +(pands to a random number each time it is referenced; assigning a v).15 +F .49(alue to)-.25 F F3(RANDOM)2.99 E F0 .49(seeds the random)2.99 F +.055(number generator)72 510 R(.)-.55 E F3(REPL)5.055 E(Y)-.92 E F0 .054 +(is the def)2.554 F .054(ault v)-.1 F .054(ariable used by the)-.25 F F3 +-.18(re)2.554 G(ad).18 E F0 -.2(bu)2.554 G .054(iltin when no v).2 F +.054(ariable names are sup-)-.25 F .742(plied as ar)72 522 R 3.243 +(guments. The)-.18 F F3(typeset)3.243 E F0 -.2(bu)3.243 G .743 +(iltin is used to de\214ne v).2 F .743(ariables and gi)-.25 F 1.043 -.15 +(ve t)-.25 H .743(hem attrib).15 F .743(utes such as)-.2 F F3 -.18(re) +3.243 G(ad-).18 E(only)72 534 Q F0 5.512(.B)C .512(ash arithmetic allo) +-5.512 F .512(ws the e)-.25 F -.25(va)-.25 G .511(luation of an e).25 F +.511(xpression and the substitution of the result.)-.15 F .511(Shell v) +5.511 F(ari-)-.25 E .222 +(ables may be used as operands, and the result of an e)72 546 R .222 +(xpression may be assigned to a v)-.15 F 2.722(ariable. Nearly)-.25 F +.222(all of)2.722 F(the operators from the C language are a)72 558 Q +-.25(va)-.2 G(ilable, with the same precedence rules:).25 E F1 6($e)97 +576 S(cho $\(\(3 + 5 * 32\)\))-6 E(163)97 588 Q F0 -.15(Fo)72 609.6 S +3.24(ri).15 G(nteracti)-3.24 E 1.04 -.15(ve u)-.25 H .74 +(se, Bash implements ksh-style aliases and b).15 F .74(uiltins such as) +-.2 F F3(fc)3.24 E F0 .74(\(discussed belo)3.24 F .74(w\) and)-.25 F F3 +(jobs)3.24 E F0(.)A .291(Bash aliases allo)72 621.6 R 2.791(was)-.25 G +.291(tring to be substituted for a command name.)-2.791 F(The)5.291 E +2.791(yc)-.15 G .291(an be used to create a mnemonic)-2.791 F .568 +(for a)72 633.6 R/F4 9/Times-Roman@0 SF(UNIX)3.068 E F0 .568 +(command name \()3.068 F F1 .568(alias del=rm)B F0 .568(\), to e)B .567 +(xpand a single w)-.15 F .567(ord to a comple)-.1 F 3.067(xc)-.15 G .567 +(ommand \()-3.067 F F1(alias)A .255 +(news='xterm -g 80x45 -title trn -e trn -e -S1 -N &')72 645.6 R F0 .255 +(\), or to ensure that a command)B(is in)72 657.6 Q -.2(vo)-.4 G -.1(ke) +.2 G 2.5(dw).1 G(ith a basic set of options \()-2.5 E F1 +(alias ls="/bin/ls -F")A F0(\).)A .293(The C shell \()97 673.2 R F3(csh) +A F0 .293(\)\207, originally written by Bill Jo)B 2.792(yw)-.1 G .292 +(hile at Berk)-2.792 F(ele)-.1 E 1.592 -.65(y, i)-.15 H 2.792(sw).65 G +.292(idely used and quite popular)-2.792 F 1.499(for its interacti)72 +685.2 R 1.799 -.15(ve f)-.25 H 3.999(acilities. Bash).05 F 1.499 +(includes a csh-compatible history e)3.999 F 1.5 +(xpansion mechanism \(\231! history\232\),)-.15 F .019(brace e)72 697.2 +R .018(xpansion, access to a stack of directories via the)-.15 F F3 +(pushd)2.518 E F0(,)A F3(popd)2.518 E F0 2.518(,a)C(nd)-2.518 E F3(dirs) +2.518 E F0 -.2(bu)2.518 G .018(iltins, and tilde e).2 F(xpansion,)-.15 E +1.293(to generate users' home directories.)72 709.2 R -.35(Ti)6.294 G +1.294(lde e).35 F 1.294(xpansion has also been adopted by both the K) +-.15 F 1.294(orn Shell and)-.35 F .32 LW 144 717.2 72 717.2 DL/F5 8 +/Times-Roman@0 SF(\207Morris Bolsk)72 727.2 Q 2(ya)-.12 G(nd Da)-2 E +(vid K)-.16 E(orn,)-.28 E/F6 8/Times-Italic@0 SF(The K)2 E +(ornShell Command and Pr)-.32 E -.08(og)-.36 G -.12(ra).08 G +(mming Langua).12 E -.08(ge)-.08 G F5 2(,P).08 G(rentice Hall, 1989.)-2 +E 0 Cg EP +%%Page: 3 3 +%%BeginPageSetup +BP +%%EndPageSetup +/F0 10/Times-Roman@0 SF(-3-)282.17 48 Q(POSIX.2.)72 84 Q .148 +(There were certain areas in which POSIX.2 felt standardization w)97 +99.6 R .149(as necessary)-.1 F 2.649(,b)-.65 G .149(ut no e)-2.849 F +.149(xisting imple-)-.15 F 1.598(mentation pro)72 111.6 R 1.598 +(vided the proper beha)-.15 F(vior)-.2 E 6.598(.T)-.55 G 1.598(he w) +-6.598 F 1.597(orking group in)-.1 F -.15(ve)-.4 G 1.597 +(nted and standardized functionality in).15 F .674 +(these areas, which Bash implements.)72 123.6 R(The)5.674 E/F1 10 +/Times-Bold@0 SF(command)3.174 E F0 -.2(bu)3.174 G .674(iltin w).2 F +.674(as in)-.1 F -.15(ve)-.4 G .674 +(nted so that shell functions could be).15 F .996(written to replace b) +72 135.6 R .996(uiltins; it mak)-.2 F .996(es the capabilities of the b) +-.1 F .995(uiltin a)-.2 F -.25(va)-.2 G .995(ilable to the function.).25 +F .995(The reserv)5.995 F(ed)-.15 E -.1(wo)72 147.6 S 1.731 +(rd \231!\232 w).1 F 1.731(as added to ne)-.1 F -.05(ga)-.15 G 1.731 +(te the return v).05 F 1.731(alue of a command or pipeline; it w)-.25 F +1.732(as nearly impossible to)-.1 F -.15(ex)72 159.6 S .286 +(press \231if not x\232 cleanly using the sh language.).15 F .286 +(There e)5.286 F .286(xist multiple incompatible implementations of the) +-.15 F F1(test)72 171.6 Q F0 -.2(bu)3.163 G .663 +(iltin, which tests \214les for type and other attrib).2 F .664 +(utes and performs arithmetic and string comparisons.)-.2 F .5 +(POSIX considered none of these correct, so the standard beha)72 183.6 R +.5(vior w)-.2 F .5(as speci\214ed in terms of the number of)-.1 F(ar)72 +195.6 Q .412(guments to the command.)-.18 F .412(POSIX.2 dictates e) +5.412 F .412(xactly what will happen when four or fe)-.15 F .412(wer ar) +-.25 F .412(guments are)-.18 F(gi)72 207.6 Q -.15(ve)-.25 G 5.01(nt).15 +G(o)-5.01 E F1(test)5.01 E F0 5.01(,a)C 2.51(nd lea)-5.01 F -.15(ve)-.2 +G 5.01(st).15 G 2.51(he beha)-5.01 F 2.51(vior unde\214ned when more ar) +-.2 F 2.51(guments are supplied.)-.18 F 2.51(Bash uses the)7.51 F +(POSIX.2 algorithm, which w)72 219.6 Q(as concei)-.1 E -.15(ve)-.25 G +2.5(db).15 G 2.5(yD)-2.5 G -.2(av)-2.5 G(id K).2 E(orn.)-.35 E F1 2.5 +(3.1. F)72 243.6 R(eatur)-.25 E(es not in the Bour)-.18 E(ne Shell)-.15 +E F0 .718(There are a number of minor dif)97 259.2 R .719 +(ferences between Bash and the v)-.25 F .719 +(ersion of sh present on most other)-.15 F -.15(ve)72 271.2 S .874 +(rsions of).15 F/F2 9/Times-Roman@0 SF(UNIX)3.374 E F0 5.873(.T)C .873 +(he majority of these are due to the POSIX standard, b)-5.873 F .873 +(ut some are the result of Bash)-.2 F .386 +(adopting features from other shells.)72 283.2 R -.15(Fo)5.386 G 2.886 +(ri).15 G .386(nstance, Bash includes the ne)-2.886 F 2.886<7799>-.25 G +.386(!\232 reserv)-2.886 F .386(ed w)-.15 F .386(ord, the)-.1 F F1 +(command)2.886 E F0 -.2(bu)72 295.2 S .116(iltin, the ability of the).2 +F F1 -.18(re)2.616 G(ad).18 E F0 -.2(bu)2.615 G .115 +(iltin to correctly return a line ending with a backslash, symbolic ar) +.2 F(guments)-.18 E .798(to the)72 307.2 R F1(umask)3.298 E F0 -.2(bu) +3.298 G .798(iltin, v).2 F .798(ariable substring remo)-.25 F -.25(va) +-.15 G .798(l, a w).25 F .799(ay to get the length of a v)-.1 F .799 +(ariable, and the ne)-.25 F 3.299(wa)-.25 G(lgo-)-3.299 E(rithm for the) +72 319.2 Q F1(test)2.5 E F0 -.2(bu)2.5 G +(iltin from the POSIX.2 standard, none of which appear in sh.).2 E 1.225 +(Bash also implements the \231$\(...\)\232 command substitution syntax,\ + which supersedes the sh `...` con-)97 334.8 R 2.851(struct. The)72 +346.8 R .351(\231$\(...\)\232 construct e)2.851 F .351(xpands to the ou\ +tput of the command contained within the parentheses, with)-.15 F .664 +(trailing ne)72 358.8 R .664(wlines remo)-.25 F -.15(ve)-.15 G 3.164 +(d. The).15 F .664(sh syntax is accepted for backw)3.164 F .664 +(ards compatibility)-.1 F 3.164(,b)-.65 G .664 +(ut the \231$\(...\)\232 form is)-3.364 F(preferred because its quoting\ + rules are much simpler and it is easier to nest.)72 370.8 Q .772 +(The Bourne shell does not pro)97 386.4 R .772 +(vide such features as brace e)-.15 F .772 +(xpansion, the ability to de\214ne a v)-.15 F(ariable)-.25 E .283 +(and a function with the same name, local v)72 398.4 R .282 +(ariables in shell functions, the ability to enable and disable indi-) +-.25 F 1.532(vidual b)72 410.4 R 1.532 +(uiltins or write a function to replace a b)-.2 F 1.533 +(uiltin, or a means to e)-.2 F 1.533(xport a shell function to a child) +-.15 F(process.)72 422.4 Q .32 +(Bash has closed a long-standing shell security hole by not using the)97 +438 R F1($IFS)2.82 E F0 -.25(va)2.82 G .32(riable to split each w).25 F +(ord)-.1 E 1.254(read by the shell, b)72 450 R 1.254 +(ut splitting only the results of e)-.2 F 1.255 +(xpansion \(ksh and the 4.4 BSD sh ha)-.15 F 1.555 -.15(ve \214)-.2 H +-.15(xe).15 G 3.755(dt).15 G 1.255(his as)-3.755 F 2.907(well\). Useful) +72 462 R(beha)2.907 E .407(vior such as a means to abort e)-.2 F -.15 +(xe)-.15 G .407(cution of a script read with the \231.).15 F 2.906<9a63> +-.7 G .406(ommand using the)-2.906 F F1 -.18(re)72 474 S(tur).18 E(n) +-.15 E F0 -.2(bu)2.742 G .242(iltin or automatically e).2 F .242 +(xporting v)-.15 F .243(ariables in the shell')-.25 F 2.743(se)-.55 G +-.4(nv)-2.743 G .243(ironment to children is also not present).4 F .969 +(in the Bourne shell.)72 486 R .968(Bash pro)5.968 F .968 +(vides a much more po)-.15 F .968(werful en)-.25 F .968 +(vironment for both interacti)-.4 F 1.268 -.15(ve u)-.25 H .968 +(se and pro-).15 F(gramming.)72 498 Q F1 2.5(4. Bash-speci\214c)72 522 R +-.25(Fe)2.5 G(atur).25 E(es)-.18 E F0 .491(This section details a fe)97 +537.6 R 2.991(wo)-.25 G 2.991(ft)-2.991 G .491(he features which mak) +-2.991 F 2.991(eB)-.1 G .491(ash unique.)-2.991 F .492(Most of them pro) +5.491 F .492(vide impro)-.15 F -.15(ve)-.15 G(d).15 E(interacti)72 549.6 +Q 1.182 -.15(ve u)-.25 H .882(se, b).15 F .882(ut a fe)-.2 F 3.382(wp) +-.25 G .882(rogramming impro)-3.382 F -.15(ve)-.15 G .882 +(ments are present as well.).15 F .882(Full descriptions of these fea-) +5.882 F(tures can be found in the Bash documentation.)72 561.6 Q F1 2.5 +(4.1. Startup)72 585.6 R(Files)2.5 E F0 .161(Bash e)97 601.2 R -.15(xe) +-.15 G .161(cutes startup \214les dif).15 F .161 +(ferently than other shells.)-.25 F .162(The Bash beha)5.161 F .162 +(vior is a compromise between)-.2 F .29 +(the csh principle of startup \214les with \214x)72 613.2 R .29 +(ed names e)-.15 F -.15(xe)-.15 G .29 +(cuted for each shell and the sh \231minimalist\232 beha).15 F(vior)-.2 +E(.)-.55 E 2.955(An interacti)72 625.2 R 3.255 -.15(ve i)-.25 H 2.955 +(nstance of Bash started as a login shell reads and e).15 F -.15(xe)-.15 +G(cutes).15 E/F3 10/Times-Italic@0 SF(~/.bash_pr)5.456 E(o\214le)-.45 E +F0 2.956(\(the \214le)5.456 F .954(.bash_pro\214le in the user')72 637.2 +R 3.454(sh)-.55 G .953(ome directory\), if it e)-3.454 F 3.453 +(xists. An)-.15 F(interacti)3.453 E 1.253 -.15(ve n)-.25 H .953 +(on-login shell reads and e).15 F -.15(xe)-.15 G(cutes).15 E F3 +(~/.bashr)72 649.2 Q(c)-.37 E F0 5.641(.A)C(non-interacti)-2.5 E .942 +-.15(ve s)-.25 H .642(hell \(one be).15 F .642(gun to e)-.15 F -.15(xe) +-.15 G .642(cute a shell script, for e).15 F .642 +(xample\) reads no \214x)-.15 F .642(ed startup)-.15 F .342(\214le, b)72 +661.2 R .342(ut uses the v)-.2 F .342(alue of the v)-.25 F(ariable)-.25 +E F1($ENV)2.842 E F0 2.841(,i)C 2.841(fs)-2.841 G .341 +(et, as the name of a startup \214le.)-2.841 F .341 +(The ksh practice of read-)5.341 F(ing)72 673.2 Q F1($ENV)3.114 E F0 +.614(for e)3.114 F -.15(ve)-.25 G .614(ry shell, with the accompan).15 F +.615(ying dif)-.15 F .615(\214culty of de\214ning the proper v)-.25 F +.615(ariables and functions)-.25 F .721(for interacti)72 685.2 R 1.021 +-.15(ve a)-.25 H .721(nd non-interacti).15 F 1.021 -.15(ve s)-.25 H .721 +(hells or ha).15 F .721(ving the \214le read only for interacti)-.2 F +1.02 -.15(ve s)-.25 H .72(hells, w).15 F .72(as considered)-.1 F .158 +(too comple)72 697.2 R 2.658(x. Ease)-.15 F .158(of use w)2.658 F .158 +(on out here.)-.1 F(Interestingly)5.158 E 2.658(,t)-.65 G .158(he ne) +-2.658 F .159(xt release of ksh will change to reading)-.15 F F1($ENV) +2.659 E .32 LW 144 705.2 72 705.2 DL/F4 8/Times-Roman@0 SF .559 +(\207Bill Jo)72 715.2 R 1.599 -.52(y, A)-.08 H 2.559(nI).52 G .559 +(ntroduction to the C Shell,)-2.559 F/F5 8/Times-Italic@0 SF .558 +(UNIX User')2.558 F 2.558(sS)-.32 G .558(upplementary Documents)-2.558 F +F4 2.558(,U)C(ni)-2.558 E -.12(ve)-.2 G .558(rsity of California at).12 +F(Berk)72 725.2 Q(ele)-.08 E 1.04 -.52(y, 1)-.12 H(986.).52 E 0 Cg EP +%%Page: 4 4 +%%BeginPageSetup +BP +%%EndPageSetup +/F0 10/Times-Roman@0 SF(-4-)282.17 48 Q(only for interacti)72 84 Q .3 +-.15(ve s)-.25 H(hells.).15 E/F1 10/Times-Bold@0 SF 2.5(4.2. New)72 108 +R(Builtin Commands)2.5 E F0 1.02(There are a fe)97 123.6 R 3.52(wb)-.25 +G 1.02(uiltins which are ne)-3.72 F 3.52(wo)-.25 G 3.52(rh)-3.52 G -2.25 +-.2(av e)-3.52 H 1.02(been e)3.72 F 1.02(xtended in Bash.)-.15 F(The) +6.02 E F1(enable)3.52 E F0 -.2(bu)3.52 G 1.02(iltin allo).2 F(ws)-.25 E +-.2(bu)72 135.6 S .824(iltin commands to be turned on and of).2 F 3.324 +(fa)-.25 G(rbitrarily)-3.324 E 5.824(.T)-.65 G 3.324(ou)-6.624 G .824 +(se the v)-3.324 F .824(ersion of)-.15 F/F2 10/Times-Italic@0 SF(ec) +3.324 E(ho)-.15 E F0 .825(found in a user')3.324 F 3.325(ss)-.55 G +(earch)-3.325 E .625(path rather than the Bash b)72 147.6 R(uiltin,)-.2 +E/F3 10/Courier@0 SF .625(enable -n echo)3.125 F F0(suf)3.125 E 3.125 +(\214ces. The)-.25 F F1(help)3.124 E F0 -.2(bu)3.124 G .624(iltin pro).2 +F .624(vides quick synopses)-.15 F .703(of the shell f)72 159.6 R .704 +(acilities without requiring access to a manual page.)-.1 F F1(Builtin) +5.704 E F0 .704(is similar to)3.204 F F1(command)3.204 E F0 .704 +(in that it)3.204 F .342(bypasses shell functions and directly e)72 +171.6 R -.15(xe)-.15 G .342(cutes b).15 F .342(uiltin commands.)-.2 F +.342(Access to a csh-style stack of directories)5.342 F .072(is pro)72 +183.6 R .073(vided via the)-.15 F F1(pushd)2.573 E F0(,)A F1(popd)2.573 +E F0 2.573(,a)C(nd)-2.573 E F1(dirs)2.573 E F0 -.2(bu)2.573 G(iltins.).2 +E F1(Pushd)5.073 E F0(and)2.573 E F1(popd)2.573 E F0 .073 +(insert and remo)2.573 F .373 -.15(ve d)-.15 H .073(irectories from the) +.15 F 2.858(stack, respecti)72 195.6 R -.15(ve)-.25 G(ly).15 E 5.358(,a) +-.65 G(nd)-5.358 E F1(dirs)5.358 E F0 2.858(lists the stack contents.) +5.358 F 2.858(On systems that allo)7.858 F 5.358<778c>-.25 G 2.857 +(ne-grained control of)-5.358 F 1.339(resources, the)72 207.6 R F1 +(ulimit)3.839 E F0 -.2(bu)3.839 G 1.339 +(iltin can be used to tune these settings.).2 F F1(Ulimit)6.34 E F0 +(allo)3.84 E 1.34(ws a user to control, among)-.25 F 1.086 +(other things, whether core dumps are to be generated, ho)72 219.6 R +3.586(wm)-.25 G 1.086(uch memory the shell or a child process is)-3.586 +F(allo)72 231.6 Q .496(wed to allocate, and ho)-.25 F 2.996(wl)-.25 G +(ar)-2.996 E .496(ge a \214le created by a child process can gro)-.18 F +4.296 -.65(w. T)-.25 H(he).65 E F1(suspend)2.996 E F0 .497(command will) +2.997 F .744(stop the shell process when job control is acti)72 243.6 R +-.15(ve)-.25 G 3.243(;m).15 G .743(ost other shells do not allo)-3.243 F +3.243(wt)-.25 G(hemselv)-3.243 E .743(es to be stopped)-.15 F(lik)72 +255.6 Q 2.717(et)-.1 G(hat.)-2.717 E F1 -.74(Ty)5.217 G(pe,).74 E F0 +.217(the Bash answer to)2.717 F F1(which)2.717 E F0(and)2.717 E F1 +(whence,)2.717 E F0(sho)2.717 E .218(ws what will happen when a w)-.25 F +.218(ord is typed as a)-.1 F(command:)72 267.6 Q F3 6($t)97 285.6 S +(ype export)-6 E(export is a shell builtin)97 297.6 Q 6($t)97 309.6 S +(ype -t export)-6 E(builtin)97 321.6 Q 6($t)97 333.6 S(ype bash)-6 E +(bash is /bin/bash)97 345.6 Q 6($t)97 357.6 S(ype cd)-6 E +(cd is a function)97 369.6 Q(cd \(\))97 381.6 Q({)97 393.6 Q +(builtin cd ${1+"$@"} && xtitle $HOST: $PWD)121 405.6 Q(})97 417.6 Q F0 +-1.11(Va)72 439.2 S .682(rious modes tell what a command w)1.11 F .681 +(ord is \(reserv)-.1 F .681(ed w)-.15 F .681(ord, alias, function, b)-.1 +F .681(uiltin, or \214le\) or which v)-.2 F(er)-.15 E(-)-.2 E 1.15 +(sion of a command will be e)72 451.2 R -.15(xe)-.15 G 1.15 +(cuted based on a user').15 F 3.65(ss)-.55 G 1.15(earch path.)-3.65 F +1.15(Some of this functionality has been)6.15 F +(adopted by POSIX.2 and folded into the)72 463.2 Q F1(command)2.5 E F0 +(utility)2.5 E(.)-.65 E F1 2.5(4.3. Editing)72 487.2 R(and Completion) +2.5 E F0 .682(One area in which Bash shines is command line editing.)97 +502.8 R .682(Bash uses the)5.682 F F2 -.37(re)3.182 G(adline).37 E F0 +.681(library to read and)3.181 F .942(edit lines when interacti)72 514.8 +R -.15(ve)-.25 G 5.942(.R).15 G .942(eadline is a po)-5.942 F .942 +(werful and \215e)-.25 F .942(xible input f)-.15 F .943 +(acility that a user can con\214gure to)-.1 F(indi)72 526.8 Q .732 +(vidual tastes.)-.25 F .732(It allo)5.732 F .732(ws lines to be edited \ +using either emacs or vi commands, where those commands)-.25 F .2 +(are appropriate.)72 538.8 R .2 +(The full capability of emacs is not present \255 there is no w)5.2 F .2 +(ay to e)-.1 F -.15(xe)-.15 G .2(cute a named command).15 F 1.15 +(with M-x, for instance \255 b)72 550.8 R 1.15(ut the e)-.2 F 1.149 +(xisting commands are more than adequate.)-.15 F 1.149 +(The vi mode is compliant)6.149 F +(with the command line editing standardized by POSIX.2.)72 562.8 Q 1.69 +(Readline is fully customizable.)97 578.4 R 1.691 +(In addition to the basic commands and k)6.69 F 1.991 -.15(ey b)-.1 H +1.691(indings, the library).15 F(allo)72 590.4 Q .028 +(ws users to de\214ne additional k)-.25 F .327 -.15(ey b)-.1 H .027 +(indings using a startup \214le.).15 F(The)5.027 E F2(inputr)2.527 E(c) +-.37 E F0 .027(\214le, which def)2.527 F .027(aults to the \214le)-.1 F +F2(~/.inputr)72 602.4 Q(c)-.37 E F0 3.002(,i)C 3.002(sr)-3.002 G .503(e\ +ad each time readline initializes, permitting users to maintain a consi\ +stent interf)-3.002 F .503(ace across a)-.1 F .893(set of programs.)72 +614.4 R .893(Readline includes an e)5.893 F .893(xtensible interf)-.15 F +.892(ace, so each program using the library can add its)-.1 F -.25(ow)72 +626.4 S 3.56(nb).25 G 1.06(indable commands and program-speci\214c k) +-3.56 F 1.361 -.15(ey b)-.1 H 3.561(indings. Bash).15 F 1.061 +(uses this f)3.561 F 1.061(acility to add bindings that)-.1 F +(perform history e)72 638.4 Q(xpansion or shell w)-.15 E(ord e)-.1 E +(xpansions on the current input line.)-.15 E .707 +(Readline interprets a number of v)97 654 R .706 +(ariables which further tune its beha)-.25 F(vior)-.2 E 5.706(.V)-.55 G +.706(ariables e)-6.816 F .706(xist to control)-.15 F .157 +(whether or not eight-bit characters are directly read as input or con) +72 666 R -.15(ve)-.4 G .158(rted to meta-pre\214x).15 F .158(ed k)-.15 F +.458 -.15(ey s)-.1 H .158(equences \(a).15 F(meta-pre\214x)72 678 Q .082 +(ed k)-.15 F .382 -.15(ey s)-.1 H .081(equence consists of the characte\ +r with the eighth bit zeroed, preceded by the).15 F F2(meta-pr)2.581 E +(e\214x)-.37 E F0(character)72 690 Q 3.233(,u)-.4 G .733 +(sually escape, which selects an alternate k)-3.233 F -.15(ey)-.1 G .734 +(map\), to decide whether to output characters with).15 F .624 +(the eighth bit set directly or as a meta-pre\214x)72 702 R .624(ed k) +-.15 F .924 -.15(ey s)-.1 H .623 +(equence, whether or not to wrap to a ne).15 F 3.123(ws)-.25 G .623 +(creen line)-3.123 F 1.196 +(when a line being edited is longer than the screen width, the k)72 714 +R -.15(ey)-.1 G 1.196(map to which subsequent k).15 F 1.496 -.15(ey b) +-.1 H(indings).15 E .531(should apply)72 726 R 3.031(,o)-.65 G 3.031(re) +-3.031 G -.15(ve)-3.281 G 3.031(nw).15 G .531 +(hat happens when readline w)-3.031 F .531(ants to ring the terminal') +-.1 F 3.03(sb)-.55 G 3.03(ell. All)-3.03 F .53(of these v)3.03 F +(ariables)-.25 E 0 Cg EP +%%Page: 5 5 +%%BeginPageSetup +BP +%%EndPageSetup +/F0 10/Times-Roman@0 SF(-5-)282.17 48 Q +(can be set in the inputrc \214le.)72 84 Q .284 +(The startup \214le understands a set of C preprocessor)97 99.6 R(-lik) +-.2 E 2.785(ec)-.1 G .285(onditional constructs which allo)-2.785 F +2.785(wv)-.25 G(ariables)-3.035 E .12(or k)72 111.6 R .42 -.15(ey b)-.1 +H .119(indings to be assigned based on the application using readline, \ +the terminal currently being used, or).15 F .338(the editing mode.)72 +123.6 R .338(Users can add program-speci\214c bindings to mak)5.338 F +2.838(et)-.1 G .338(heir li)-2.838 F -.15(ve)-.25 G 2.838(se).15 G 2.838 +(asier: I)-2.838 F(ha)2.838 E .639 -.15(ve b)-.2 H .339(indings that).15 +F(let me edit the v)72 135.6 Q(alue of)-.25 E/F1 10/Times-Bold@0 SF($P) +2.5 E -.95(AT)-.74 G(H).95 E F0(and double-quote the current or pre)2.5 +E(vious w)-.25 E(ord:)-.1 E/F2 10/Courier@0 SF 6(#M)97 153.6 S +(acros that are convenient for shell interaction)-6 E($if Bash)97 165.6 +Q 6(#e)97 177.6 S(dit the path)-6 E +("\\C-xp": "PATH=${PATH}\\e\\C-e\\C-a\\ef\\C-f")97 189.6 Q 6(#p)97 201.6 +S(repare to type a quoted word -- insert open and close double)-6 E 6 +(#q)97 213.6 S(uotes and move to just after the open quote)-6 E +("\\C-x\\"": "\\"\\"\\C-b")97 225.6 Q 6(#Q)97 237.6 S +(uote the current or previous word)-6 E("\\C-xq": "\\eb\\"\\ef\\"")97 +249.6 Q($endif)97 261.6 Q F0 .322(There is a readline command to re-rea\ +d the \214le, so users can edit the \214le, change some bindings, and b\ +e)72 283.2 R(gin)-.15 E(to use them almost immediately)72 295.2 Q(.)-.65 +E .518(Bash implements the)97 310.8 R F1(bind)3.018 E F0 -.2(bu)3.018 G +.518(iltin for more dynamic control of readline than the startup \214le\ + permits.).2 F F1(Bind)72 322.8 Q F0 .25(is used in se)2.75 F -.15(ve) +-.25 G .25(ral w).15 F 2.75(ays. In)-.1 F/F3 10/Times-Italic@0 SF(list) +2.75 E F0 .25(mode, it can display the current k)2.75 F .55 -.15(ey b) +-.1 H .25(indings, list all the readline edit-).15 F .149(ing directi)72 +334.8 R -.15(ve)-.25 G 2.649(sa).15 G -.25(va)-2.849 G .149 +(ilable for binding, list which k).25 F -.15(ey)-.1 G 2.649(si).15 G +-1.9 -.4(nv o)-2.649 H .349 -.1(ke a g).4 H -2.15 -.25(iv e).1 H 2.65 +(nd).25 G(irecti)-2.65 E -.15(ve)-.25 G 2.65(,o).15 G 2.65(ro)-2.65 G +.15(utput the current set of k)-2.65 F -.15(ey)-.1 G .042(bindings in a\ + format that can be incorporated directly into an inputrc \214le.)72 +346.8 R(In)5.041 E F3(batc)2.541 E(h)-.15 E F0 .041 +(mode, it reads a series of)2.541 F -.1(ke)72 358.8 S 2.858(yb)-.05 G +.359(indings directly from a \214le and passes them to readline.)-2.858 +F .359(In its most common usage,)5.359 F F1(bind)2.859 E F0(tak)2.859 E +.359(es a sin-)-.1 F 1.117(gle string and passes it directly to readlin\ +e, which interprets the line as if it had just been read from the)72 +370.8 R(inputrc \214le.)72 382.8 Q(Both k)5 E .3 -.15(ey b)-.1 H +(indings and v).15 E(ariable assignments may appear in the string gi) +-.25 E -.15(ve)-.25 G 2.5(nt).15 G(o)-2.5 E F1(bind)2.5 E F0(.)A .53 +(The readline library also pro)97 398.4 R .53(vides an interf)-.15 F .53 +(ace for)-.1 F F3(wor)3.03 E 3.03(dc)-.37 G(ompletion)-3.03 E F0 5.53 +(.W)C .53(hen the)-5.53 F F3(completion)3.03 E F0(character)3.03 E 1.261 +(\(usually T)72 410.4 R 1.261(AB\) is typed, readline looks at the w) +-.93 F 1.26(ord currently being entered and computes the set of \214le-) +-.1 F .523(names of which the current w)72 422.4 R .523(ord is a v)-.1 F +.523(alid pre\214x.)-.25 F .524 +(If there is only one possible completion, the rest of the)5.523 F .358 +(characters are inserted directly)72 434.4 R 2.858(,o)-.65 G .358(therw\ +ise the common pre\214x of the set of \214lenames is added to the curre\ +nt)-2.858 F -.1(wo)72 446.4 S 3.199(rd. A).1 F .699(second T)3.199 F +.699(AB character entered immediately after a non-unique completion cau\ +ses readline to list)-.93 F 1.814 +(the possible completions; there is an option to ha)72 458.4 R 2.113 +-.15(ve t)-.2 H 1.813(he list displayed immediately).15 F 6.813(.R)-.65 +G 1.813(eadline pro)-6.813 F(vides)-.15 E .482 +(hooks so that applications can pro)72 470.4 R .482 +(vide speci\214c types of completion before the def)-.15 F .483 +(ault \214lename completion)-.1 F .132(is attempted.)72 482.4 R .132 +(This is quite \215e)5.132 F .132 +(xible, though it is not completely user)-.15 F 2.632 +(-programmable. Bash,)-.2 F .132(for e)2.632 F .132(xample, can)-.15 F +.37(complete \214lenames, command names \(including aliases, b)72 494.4 +R .37(uiltins, shell reserv)-.2 F .37(ed w)-.15 F .37 +(ords, shell functions, and)-.1 F -.15(exe)72 506.4 S .424 +(cutables found in the \214le system\), shell v).15 F .424 +(ariables, usernames, and hostnames.)-.25 F .423 +(It uses a set of heuristics)5.424 F(that, while not perfect, is genera\ +lly quite good at determining what type of completion to attempt.)72 +518.4 Q F1 2.5(4.4. History)72 542.4 R F0 .144 +(Access to the list of commands pre)97 558 R .144(viously entered \(the) +-.25 F F3 .144(command history)2.644 F F0 2.644(\)i)C 2.644(sp)-2.644 G +(ro)-2.644 E .144(vided jointly by Bash)-.15 F .078 +(and the readline library)72 570 R 5.077(.B)-.65 G .077(ash pro)-5.077 F +.077(vides v)-.15 F .077(ariables \()-.25 F F1($HISTFILE)A F0(,)A F1 +($HISTSIZE)2.577 E F0 2.577(,a)C(nd)-2.577 E F1($HISTCONTR)2.577 E(OL) +-.3 E F0 2.577(\)a)C(nd)-2.577 E(the)72 582 Q F1(history)2.759 E F0(and) +2.759 E F1(fc)2.759 E F0 -.2(bu)2.759 G .259 +(iltins to manipulate the history list.).2 F .26(The v)5.259 F .26 +(alue of)-.25 F F1($HISTFILE)2.76 E F0 .26(speci\214es the \214le where) +2.76 F .49(Bash writes the command history on e)72 594 R .489 +(xit and reads it on startup.)-.15 F F1($HISTSIZE)5.489 E F0 .489 +(is used to limit the number)2.989 F .642(of commands sa)72 606 R -.15 +(ve)-.2 G 3.142(di).15 G 3.142(nt)-3.142 G .642(he history)-3.142 F(.) +-.65 E F1($HISTCONTR)5.642 E(OL)-.3 E F0(pro)3.142 E .642 +(vides a crude form of control o)-.15 F -.15(ve)-.15 G 3.142(rw).15 G +.642(hich com-)-3.142 F .025(mands are sa)72 618 R -.15(ve)-.2 G 2.525 +(do).15 G 2.525(nt)-2.525 G .025(he history list: a v)-2.525 F .025 +(alue of)-.25 F F3(ignor)2.525 E(espace)-.37 E F0 .025(means to not sa) +2.525 F .324 -.15(ve c)-.2 H .024(ommands which be).15 F .024 +(gin with a)-.15 F .927(space; a v)72 630 R .927(alue of)-.25 F F3 +(ignor)3.427 E(edups)-.37 E F0 .927(means to not sa)3.427 F 1.228 -.15 +(ve c)-.2 H .928(ommands identical to the last command sa).15 F -.15(ve) +-.2 G(d.).15 E F1($HIST)5.928 E(-)-.92 E(CONTR)72 642 Q(OL)-.3 E F0 -.1 +(wa)3.778 G 3.778(sn).1 G(amed)-3.778 E F1($history_contr)3.778 E(ol) +-.18 E F0 1.278(in earlier v)3.778 F 1.278 +(ersions of Bash; the old name is still accepted for)-.15 F(backw)72 654 +Q .575(ards compatibility)-.1 F 5.575(.T)-.65 G(he)-5.575 E F1(history) +3.075 E F0 .575 +(command can read or write \214les containing the history list and dis-) +3.075 F .167(play the current list contents.)72 666 R(The)5.167 E F1(fc) +2.667 E F0 -.2(bu)2.667 G .167(iltin, adopted from POSIX.2 and the K).2 +F .167(orn Shell, allo)-.35 F .167(ws display and)-.25 F(re-e)72 678 Q +-.15(xe)-.15 G .58 +(cution, with optional editing, of commands from the history list.).15 F +.58(The readline library of)5.58 F .58(fers a set of)-.25 F 1.255(comma\ +nds to search the history list for a portion of the current input line \ +or a string typed by the user)72 690 R(.)-.55 E(Finally)72 702 Q 2.535 +(,t)-.65 G(he)-2.535 E F3(history)2.535 E F0(library)2.535 E 2.535(,g) +-.65 G .036(enerally incorporated directly into the readline library) +-2.535 F 2.536(,i)-.65 G .036(mplements a f)-2.536 F .036(acility for) +-.1 F 1.023(history recall, e)72 714 R 1.022(xpansion, and re-e)-.15 F +-.15(xe)-.15 G 1.022(cution of pre).15 F 1.022(vious commands v)-.25 F +1.022(ery similar to csh \(\231bang history\232, so)-.15 F +(called because the e)72 726 Q +(xclamation point introduces a history substitution\):)-.15 E 0 Cg EP +%%Page: 6 6 +%%BeginPageSetup +BP +%%EndPageSetup +/F0 10/Times-Roman@0 SF(-6-)282.17 48 Q/F1 10/Courier@0 SF 6($e)97 84 S +(cho a b c d e)-6 E 6(abcde)97 96 S 6($!)97 108 S 6(!fghi)-6 G +(echo a b c d e f g h i)97 120 Q 6(abcdefghi)97 132 S 6($!)97 144 S(-2) +-6 E(echo a b c d e)97 156 Q 6(abcde)97 168 S 6($e)97 180 S(cho !-2:1-4) +-6 E(echo a b c d)97 192 Q 6(abcd)97 204 S F0 1.456 +(The command history is only sa)72 225.6 R -.15(ve)-.2 G 3.957(dw).15 G +1.457(hen the shell is interacti)-3.957 F -.15(ve)-.25 G 3.957(,s).15 G +3.957(oi)-3.957 G 3.957(ti)-3.957 G 3.957(sn)-3.957 G 1.457(ot a)-3.957 +F -.25(va)-.2 G 1.457(ilable for use by shell).25 F(scripts.)72 237.6 Q +/F2 10/Times-Bold@0 SF 2.5(4.5. New)72 261.6 R(Shell V)2.5 E(ariables) +-.92 E F0 .59(There are a number of con)97 277.2 R -.15(ve)-.4 G .589 +(nience v).15 F .589(ariables that Bash interprets to mak)-.25 F 3.089 +(el)-.1 G .589(ife easier)-3.089 F 5.589(.T)-.55 G .589(hese include) +-5.589 F F2(FIGNORE)72 289.2 Q F0 3.973(,w)C 1.473 +(hich is a set of \214lename suf)-3.973 F<8c78>-.25 E 1.474 +(es identifying \214les to e)-.15 F 1.474 +(xclude when completing \214lenames;)-.15 F F2(HOSTTYPE)72 301.2 Q F0 +2.932(,w)C .432 +(hich is automatically set to a string describing the type of hardw) +-2.932 F .431(are on which Bash is cur)-.1 F(-)-.2 E .335(rently e)72 +313.2 R -.15(xe)-.15 G(cuting;).15 E F2(command_oriented_history)2.835 E +F0 2.835(,w)C .335(hich directs Bash to sa)-2.835 F .635 -.15(ve a)-.2 H +.336(ll lines of a multiple-line com-).15 F 1.071(mand such as a)72 +325.2 R/F3 10/Times-Italic@0 SF(while)3.571 E F0(or)3.571 E F3(for)3.571 +E F0 1.071(loop in a single history entry)3.571 F 3.57(,a)-.65 G(llo) +-3.57 E 1.07(wing easy re-editing; and)-.25 F F2(IGNOREEOF)3.57 E F0(,)A +.747(whose v)72 337.2 R .747(alue indicates the number of consecuti)-.25 +F 1.047 -.15(ve E)-.25 H .747(OF characters that an interacti).15 F +1.048 -.15(ve s)-.25 H .748(hell will read before).15 F -.15(ex)72 349.2 +S 1.432(iting \255 an easy w).15 F 1.432(ay to k)-.1 F 1.432 +(eep yourself from being logged out accidentally)-.1 F 6.432(.T)-.65 G +(he)-6.432 E F2(auto_r)3.932 E(esume)-.18 E F0 -.25(va)3.932 G(riable) +.25 E .571(alters the w)72 361.2 R .571 +(ay the shell treats simple command names: if job control is acti)-.1 F +-.15(ve)-.25 G 3.071(,a).15 G .571(nd this v)-3.071 F .571 +(ariable is set, sin-)-.25 F(gle-w)72 373.2 Q .239(ord simple commands \ +without redirections cause the shell to \214rst look for and restart a \ +suspended job)-.1 F(with that name before starting a ne)72 385.2 Q 2.5 +(wp)-.25 G(rocess.)-2.5 E F2 2.5(4.6. Brace)72 409.2 R(Expansion)2.5 E +F0 .653(Since sh of)97 424.8 R .653(fers no con)-.25 F -.15(ve)-.4 G +.653(nient w).15 F .653 +(ay to generate arbitrary strings that share a common pre\214x or suf) +-.1 F<8c78>-.25 E 2.124(\(\214lename e)72 436.8 R 2.124 +(xpansion requires that the \214lenames e)-.15 F 2.123 +(xist\), Bash implements)-.15 F F3(br)4.623 E 2.123(ace e)-.15 F +(xpansion)-.2 E F0 4.623(,ac)C(apability)-4.623 E(pick)72 448.8 Q .773 +(ed up from csh.)-.1 F .774(Brace e)5.773 F .774 +(xpansion is similar to \214lename e)-.15 F .774(xpansion, b)-.15 F .774 +(ut the strings generated need not)-.2 F 1.211(correspond to e)72 460.8 +R 1.211(xisting \214les.)-.15 F 3.711(Ab)6.211 G 1.211(race e)-3.711 F +1.211(xpression consists of an optional)-.15 F F3(pr)3.71 E(eamble)-.37 +E F0 3.71(,f)C(ollo)-3.71 E 1.21(wed by a pair of)-.25 F 2.938 +(braces enclosing a series of comma-separated strings, and an optional) +72 472.8 R F3(postamble)5.438 E F0 7.938(.T)C 2.938(he preamble is) +-7.938 F(prepended to each string within the braces, and the postamble \ +is then appended to each resulting string:)72 484.8 Q F1 6($e)97 502.8 S +(cho a{d,c,b}e)-6 E(ade ace abe)97 514.8 Q F0 .306(As this e)72 536.4 R +.306(xample demonstrates, the results of brace e)-.15 F .305 +(xpansion are not sorted, as the)-.15 F 2.805(ya)-.15 G .305 +(re by \214lename e)-2.805 F(xpan-)-.15 E(sion.)72 548.4 Q F2 2.5 +(4.7. Pr)72 572.4 R(ocess Substitution)-.18 E F0 .457 +(On systems that can support it, Bash pro)97 588 R .457(vides a f)-.15 F +.457(acility kno)-.1 F .458(wn as)-.25 F F3(pr)2.958 E .458 +(ocess substitution)-.45 F F0 5.458(.P)C .458(rocess sub-)-5.458 F .347 +(stitution is similar to command substitution in that its speci\214cati\ +on includes a command to e)72 600 R -.15(xe)-.15 G .346(cute, b).15 F +.346(ut the)-.2 F .181(shell does not collect the command')72 612 R +2.681(so)-.55 G .181(utput and insert it into the command line.)-2.681 F +(Rather)5.181 E 2.681(,B)-.4 G .182(ash opens a pipe)-2.681 F 1.861 +(to the command, which is run in the background.)72 624 R 1.861 +(The shell uses named pipes \(FIFOs\) or the)6.861 F F3(/de)4.361 E +(v/fd)-.15 E F0 .961(method of naming open \214les to e)72 636 R .962(x\ +pand the process substitution to a \214lename which connects to the pip\ +e)-.15 F .104(when opened.)72 648 R .103 +(This \214lename becomes the result of the e)5.104 F 2.603 +(xpansion. Process)-.15 F .103(substitution can be used to com-)2.603 F +(pare the outputs of tw)72 660 Q 2.5(od)-.1 G(if)-2.5 E(ferent v)-.25 E +(ersions of an application as part of a re)-.15 E(gression test:)-.15 E +F1 6($c)97 678 S(mp <\(old_prog\) <\(new_prog\))-6 E 0 Cg EP +%%Page: 7 7 +%%BeginPageSetup +BP +%%EndPageSetup +/F0 10/Times-Roman@0 SF(-7-)282.17 48 Q/F1 10/Times-Bold@0 SF 2.5 +(4.8. Pr)72 84 R(ompt Customization)-.18 E F0 2.229 +(One of the more popular interacti)97 99.6 R 2.529 -.15(ve f)-.25 H +2.229(eatures that Bash pro).15 F 2.23 +(vides is the ability to customize the)-.15 F 3.234(prompt. Both)72 +111.6 R F1($PS1)3.234 E F0(and)3.234 E F1($PS2,)3.234 E F0 .734 +(the primary and secondary prompts, are e)3.234 F .733 +(xpanded before being displayed.)-.15 F -.15(Pa)72 123.6 S .804 +(rameter and v).15 F .804(ariable e)-.25 F .805 +(xpansion is performed when the prompt string is e)-.15 F .805 +(xpanded, so an)-.15 F 3.305(ys)-.15 G .805(hell v)-3.305 F(ariable)-.25 +E .729(can be put into the prompt \(e.g.,)72 135.6 R F1($SHL)3.228 E(VL) +-.92 E F0 3.228(,w)C .728(hich indicates ho)-3.228 F 3.228(wd)-.25 G +.728(eeply the current shell is nested\).)-3.228 F(Bash)5.728 E 1.895(s\ +pecially interprets characters in the prompt string preceded by a backs\ +lash.)72 147.6 R 1.895(Some of these backslash)6.895 F .874 +(escapes are replaced with the current time, the date, the current w)72 +159.6 R .874(orking directory)-.1 F 3.373(,t)-.65 G .873 +(he username, and the)-3.373 F .78 +(command number or history number of the command being entered.)72 171.6 +R .781(There is e)5.781 F -.15(ve)-.25 G 3.281(nab).15 G .781 +(ackslash escape to)-3.281 F .007 +(cause the shell to change its prompt when running as root after an)72 +183.6 R/F2 10/Times-Italic@0 SF(su)2.507 E F0 5.007(.B)C .007 +(efore printing each primary prompt,)-5.007 F .305(Bash e)72 195.6 R +.305(xpands the v)-.15 F(ariable)-.25 E F1($PR)2.805 E(OMPT_COMMAND)-.3 +E F0 .305(and, if it has a v)2.805 F .306(alue, e)-.25 F -.15(xe)-.15 G +.306(cutes the e).15 F .306(xpanded v)-.15 F .306(alue as)-.25 F 3.735 +(ac)72 207.6 S 1.235(ommand, allo)-3.735 F 1.234 +(wing additional prompt customization.)-.25 F -.15(Fo)6.234 G 3.734(re) +.15 G 1.234(xample, this assignment causes the current)-3.884 F(user)72 +219.6 Q 2.917(,t)-.4 G .417 +(he current host, the time, the last component of the current w)-2.917 F +.417(orking directory)-.1 F 2.917(,t)-.65 G .418(he le)-2.917 F -.15(ve) +-.25 G 2.918(lo).15 G 2.918(fs)-2.918 G .418(hell nest-)-2.918 F(ing, a\ +nd the history number of the current command to be embedded into the pr\ +imary prompt:)72 231.6 Q/F3 10/Courier@0 SF 6($P)97 249.6 S +(S1='\\u@\\h [\\t] \\W\($SHLVL:\\!\)\\$ ')-6 E +(chet@odin [21:03:44] documentation\(2:636\)$ cd ..)97 261.6 Q +(chet@odin [21:03:54] src\(2:637\)$)97 273.6 Q F0 .146(The string being\ + assigned is surrounded by single quotes so that if it is e)72 295.2 R +.146(xported, the v)-.15 F .146(alue of)-.25 F F1($SHL)2.646 E(VL)-.92 E +F0(will)2.646 E(be updated by a child shell:)72 307.2 Q F3 +(chet@odin [21:17:35] src\(2:638\)$ export PS1)97 325.2 Q +(chet@odin [21:17:40] src\(2:639\)$ bash)97 337.2 Q +(chet@odin [21:17:46] src\(3:696\)$)97 349.2 Q F0 +(The \\$ escape is displayed as \231)72 370.8 Q F1($)A F0 2.5<9a77>C +(hen running as a normal user)-2.5 E 2.5(,b)-.4 G(ut as \231)-2.7 E F1 +(#)A F0 2.5<9a77>C(hen running as root.)-2.5 E F1 2.5(4.9. File)72 394.8 +R(System V)2.5 E(iews)-.37 E F0 .029(Since Berk)97 410.4 R(ele)-.1 E +2.529(yi)-.15 G .029 +(ntroduced symbolic links in 4.2 BSD, one of their most anno)-2.529 F +.03(ying properties has been)-.1 F .764(the \231w)72 422.4 R .764 +(arping\232 to a completely dif)-.1 F .764 +(ferent area of the \214le system when using)-.25 F F1(cd)3.263 E F0 +3.263(,a)C .763(nd the resultant non-intu-)-3.263 F(iti)72 434.4 Q .704 +-.15(ve b)-.25 H(eha).15 E .405(vior of \231)-.2 F F1 .405(cd ..)B F0 +2.905(\232. The)B/F4 9/Times-Roman@0 SF(UNIX)2.905 E F0 -.1(ke)2.905 G +.405(rnel treats symbolic links).1 F F2(physically)2.905 E F0 5.405(.W)C +.405(hen the k)-5.405 F .405(ernel is translating)-.1 F 3.223(ap)72 +446.4 S .723(athname in which one component is a symbolic link, it repl\ +aces all or part of the pathname while pro-)-3.223 F .668 +(cessing the link.)72 458.4 R .668 +(If the contents of the symbolic link be)5.668 F .669 +(gin with a slash, the k)-.15 F .669(ernel replaces the pathname)-.1 F +.219(entirely; if not, the link contents replace the current component.) +72 470.4 R .219(In either case, the symbolic link is visible.)5.219 F +.058(If the link v)72 482.4 R .058(alue is an absolute pathname, the us\ +er \214nds himself in a completely dif)-.25 F .059 +(ferent part of the \214le sys-)-.25 F(tem.)72 494.4 Q .704(Bash pro)97 +510 R .704(vides a)-.15 F F2(lo)3.203 E(gical)-.1 E F0(vie)3.203 E 3.203 +(wo)-.25 G 3.203(ft)-3.203 G .703(he \214le system.)-3.203 F .703 +(In this def)5.703 F .703(ault mode, command and \214lename com-)-.1 F +.522(pletion and b)72 522 R .522(uiltin commands such as)-.2 F F1(cd) +3.022 E F0(and)3.022 E F1(pushd)3.022 E F0 .522 +(which change the current w)3.022 F .522(orking directory transpar)-.1 F +(-)-.2 E .127(ently follo)72 534 R 2.627(ws)-.25 G .127 +(ymbolic links as if the)-2.627 F 2.627(yw)-.15 G .127(ere directories.) +-2.627 F(The)5.126 E F1($PWD)2.626 E F0 -.25(va)2.626 G .126 +(riable, which holds the shell').25 F 2.626(si)-.55 G .126(dea of)-2.626 +F .366(the current w)72 546 R .366(orking directory)-.1 F 2.866(,d)-.65 +G .367 +(epends on the path used to reach the directory rather than its ph) +-2.866 F .367(ysical loca-)-.05 F +(tion in the local \214le system hierarch)72 558 Q 3.8 -.65(y. F)-.05 H +(or e).5 E(xample:)-.15 E F3 6($c)97 576 S 6(d/)-6 G(usr/local/bin)-6 E +6($e)97 588 S(cho $PWD)-6 E(/usr/local/bin)97 600 Q 6($p)97 612 S(wd)-6 +E(/usr/local/bin)97 624 Q 6($/)97 636 S(bin/pwd)-6 E +(/net/share/sun4/local/bin)97 648 Q 6($c)97 660 S 6(d.)-6 G(.)-6 E 6($p) +97 672 S(wd)-6 E(/usr/local)97 684 Q 6($/)97 696 S(bin/pwd)-6 E +(/net/share/sun4/local)97 708 Q 6($c)97 720 S 6(d.)-6 G(.)-6 E 0 Cg EP +%%Page: 8 8 +%%BeginPageSetup +BP +%%EndPageSetup +/F0 10/Times-Roman@0 SF(-8-)282.17 48 Q/F1 10/Courier@0 SF 6($p)97 84 S +(wd)-6 E(/usr)97 96 Q 6($/)97 108 S(bin/pwd)-6 E(/usr)97 120 Q F0 .3(On\ +e problem with this, of course, arises when programs that do not unders\ +tand the shell')72 141.6 R 2.8(sl)-.55 G .3(ogical notion of)-2.8 F .217 +(the \214le system interpret \231..)72 153.6 R 2.718<9a64>-.7 G(if) +-2.718 E(ferently)-.25 E 5.218(.T)-.65 G .218 +(his generally happens when Bash completes \214lenames containing)-5.218 +F(\231..)72 165.6 Q 3.384<9a61>-.7 G .884 +(ccording to a logical hierarch)-3.384 F 3.384(yw)-.05 G .884 +(hich does not correspond to their ph)-3.384 F .883(ysical location.) +-.05 F -.15(Fo)5.883 G 3.383(ru).15 G .883(sers who)-3.383 F +(\214nd this troublesome, a corresponding)72 177.6 Q/F2 10 +/Times-Italic@0 SF(physical)2.5 E F0(vie)2.5 E 2.5(wo)-.25 G 2.5(ft)-2.5 +G(he \214le system is a)-2.5 E -.25(va)-.2 G(ilable:).25 E F1 6($c)97 +195.6 S 6(d/)-6 G(usr/local/bin)-6 E 6($p)97 207.6 S(wd)-6 E +(/usr/local/bin)97 219.6 Q 6($s)97 231.6 S(et -o physical)-6 E 6($p)97 +243.6 S(wd)-6 E(/net/share/sun4/local/bin)97 255.6 Q/F3 10/Times-Bold@0 +SF 2.5(4.10. Inter)72 285.6 R(nationalization)-.15 E F0 .145 +(One of the most signi\214cant impro)97 301.2 R -.15(ve)-.15 G .145 +(ments in v).15 F .145(ersion 1.13 of Bash w)-.15 F .145 +(as the change to \231eight-bit clean-)-.1 F 2.933(liness\232. Pre)72 +313.2 R .433(vious v)-.25 F .432 +(ersions used the eighth bit of characters to mark whether or not the) +-.15 F 2.932(yw)-.15 G .432(ere quoted when)-2.932 F 1.495(performing w) +72 325.2 R 1.495(ord e)-.1 F 3.995(xpansions. While)-.15 F 1.495 +(this did not af)3.995 F 1.496 +(fect the majority of users, most of whom used only)-.25 F(se)72 337.2 Q +-.15(ve)-.25 G 1.236(n-bit ASCII characters, some found it con\214ning.) +.15 F(Be)6.236 E 1.236(ginning with v)-.15 F 1.236 +(ersion 1.13, Bash implemented a)-.15 F(dif)72 349.2 Q .02(ferent quoti\ +ng mechanism that did not alter the eighth bit of characters.)-.25 F +.021(This allo)5.021 F .021(wed Bash to manipulate)-.25 F .427 +(\214les with \231odd\232 characters in their names, b)72 361.2 R .427 +(ut did nothing to help users enter those names, so v)-.2 F .426 +(ersion 1.13)-.15 F 1.458 +(introduced changes to readline that made it eight-bit clean as well.)72 +373.2 R 1.458(Options e)6.458 F 1.458(xist that force readline to)-.15 F +.744(attach no special signi\214cance to characters with the eighth bit\ + set \(the def)72 385.2 R .744(ault beha)-.1 F .744(vior is to con)-.2 F +-.15(ve)-.4 G .744(rt these).15 F .641(characters to meta-pre\214x)72 +397.2 R .641(ed k)-.15 F .941 -.15(ey s)-.1 H .642 +(equences\) and to output these characters without con).15 F -.15(ve)-.4 +G .642(rsion to meta-pre-).15 F<8c78>72 409.2 Q .008(ed sequences.)-.15 +F .007(These changes, along with the e)5.007 F .007(xpansion of k)-.15 F +-.15(ey)-.1 G .007(maps to a full eight bits, enable readline to).15 F +-.1(wo)72 421.2 S(rk with most of the ISO-8859 f).1 E +(amily of character sets, used by man)-.1 E 2.5(yE)-.15 G +(uropean countries.)-2.5 E F3 2.5(4.11. POSIX)72 445.2 R(Mode)2.5 E F0 +.584(Although Bash is intended to be POSIX.2 conformant, there are area\ +s in which the def)97 460.8 R .584(ault beha)-.1 F(vior)-.2 E .463 +(is not compatible with the standard.)72 472.8 R -.15(Fo)5.463 G 2.962 +(ru).15 G .462(sers who wish to operate in a strict POSIX.2 en)-2.962 F +.462(vironment, Bash)-.4 F .505(implements a)72 484.8 R F2 .505 +(POSIX mode)3.005 F F0 5.505(.W)C .505(hen this mode is acti)-5.505 F +-.15(ve)-.25 G 3.005(,B).15 G .505(ash modi\214es its def)-3.005 F .505 +(ault operation where it dif)-.1 F(fers)-.25 E .267 +(from POSIX.2 to match the standard.)72 496.8 R .266 +(POSIX mode is entered when Bash is started with the)5.267 F F3(-posix) +2.766 E F0(option.)2.766 E .149(This feature is also a)72 508.8 R -.25 +(va)-.2 G .149(ilable as an option to the).25 F F3(set)2.649 E F0 -.2 +(bu)2.649 G(iltin,).2 E F3 .149(set -o posix)2.649 F F0 5.149(.F)C .149 +(or compatibility with other GNU)-5.299 F(softw)72 520.8 Q 4.02(are tha\ +t attempts to be POSIX.2 compliant, Bash also enters POSIX mode if the \ +v)-.1 F(ariable)-.25 E F3($POSIXL)72 532.8 Q(Y_CORRECT)-.92 E F0 5.824 +(is set when Bash is started or assigned a v)8.324 F 5.825 +(alue during e)-.25 F -.15(xe)-.15 G(cution.).15 E F3($POSIX_PED)72 +544.8 Q(ANTIC)-.35 E F0 .27 +(is accepted as well, to be compatible with some older GNU utilities.) +2.77 F .27(When Bash is)5.27 F .506(started in POSIX mode, for e)72 +556.8 R .506(xample, it sources the \214le named by the v)-.15 F .507 +(alue of)-.25 F F3($ENV)3.007 E F0 .507(rather than the \231nor)3.007 F +(-)-.2 E(mal\232 startup \214les, and does not allo)72 568.8 Q 2.5(wr) +-.25 G(eserv)-2.5 E(ed w)-.15 E(ords to be aliased.)-.1 E F3 2.5(5. New) +72 592.8 R -.25(Fe)2.5 G(atur).25 E(es and Futur)-.18 E 2.5(eP)-.18 G +(lans)-2.5 E F0 1.632(There are se)97 608.4 R -.15(ve)-.25 G 1.632 +(ral features introduced in the current v).15 F 1.631(ersion of Bash, v) +-.15 F 1.631(ersion 1.14, and a number)-.15 F .241 +(under consideration for future releases.)72 620.4 R .242 +(This section will brie\215y detail the ne)5.242 F 2.742(wf)-.25 G .242 +(eatures in v)-2.742 F .242(ersion 1.14 and)-.15 F(describe se)72 632.4 +Q -.15(ve)-.25 G(ral features that may appear in later v).15 E(ersions.) +-.15 E F3 2.5(5.1. New)72 656.4 R -.25(Fe)2.5 G(atur).25 E +(es in Bash-1.14)-.18 E F0 .884(The ne)97 672 R 3.384(wf)-.25 G .884 +(eatures a)-3.384 F -.25(va)-.2 G .884(ilable in Bash-1.14 answer se).25 +F -.15(ve)-.25 G .883(ral of the most common requests for enhance-).15 F +2.931(ments. Most)72 684 R(notably)2.931 E 2.931(,t)-.65 G .432(here is\ + a mechanism for including non-visible character sequences in prompts, \ +such)-2.931 F .136 +(as those which cause a terminal to print characters in dif)72 696 R +.135(ferent colors or in standout mode.)-.25 F .135(There w)5.135 F .135 +(as noth-)-.1 F .558(ing pre)72 708 R -.15(ve)-.25 G .558 +(nting the use of these sequences in earlier v).15 F .559(ersions, b) +-.15 F .559(ut the readline redisplay algorithm assumed)-.2 F +(each character occupied ph)72 720 Q(ysical screen space and w)-.05 E +(ould wrap lines prematurely)-.1 E(.)-.65 E 0 Cg EP +%%Page: 9 9 +%%BeginPageSetup +BP +%%EndPageSetup +/F0 10/Times-Roman@0 SF(-9-)282.17 48 Q .13(Readline has a fe)97 84 R +2.63(wn)-.25 G .63 -.25(ew va)-2.63 H .13(riables, se).25 F -.15(ve)-.25 +G .13(ral ne).15 F 2.63(wb)-.25 G .13 +(indable commands, and some additional emacs mode)-2.63 F(def)72 96 Q +.918(ault k)-.1 F 1.218 -.15(ey b)-.1 H 3.418(indings. A).15 F(ne)3.418 +E 3.418(wh)-.25 G .919(istory search mode has been implemented: in this\ + mode, readline searches)-3.418 F .336(the history for lines be)72 108 R +.336(ginning with the characters between the be)-.15 F .336 +(ginning of the current line and the cursor)-.15 F(.)-.55 E .555(The e) +72 120 R .556(xisting readline incremental search commands no longer ma\ +tch identical lines more than once.)-.15 F(File-)5.556 E 1.979 +(name completion no)72 132 R 4.479(we)-.25 G 1.979(xpands v)-4.629 F +1.979(ariables in directory names.)-.25 F 1.978(The history e)6.978 F +1.978(xpansion f)-.15 F 1.978(acilities are no)-.1 F(w)-.25 E 1.449 +(nearly completely csh-compatible: missing modi\214ers ha)72 144 R 1.749 +-.15(ve b)-.2 H 1.449(een added and history substitution has been).15 F +-.15(ex)72 156 S(tended.).15 E(Se)97 171.6 Q -.15(ve)-.25 G .474 +(ral of the features described earlier).15 F 2.973(,s)-.4 G .473(uch as) +-2.973 F/F1 10/Times-Bold@0 SF .473(set -o posix)2.973 F F0(and)2.973 E +F1($POSIX_PED)2.973 E(ANTIC)-.35 E F0 2.973(,a)C .473(re ne)-2.973 F +2.973(wi)-.25 G(n)-2.973 E -.15(ve)72 183.6 S .106(rsion 1.14.).15 F +.106(There is a ne)5.106 F 2.606(ws)-.25 G .106(hell v)-2.606 F +(ariable,)-.25 E F1(OSTYPE)2.606 E F0 2.606(,t)C 2.606(ow)-2.606 G .106 +(hich Bash assigns a v)-2.606 F .106(alue that identi\214es the v)-.25 F +(er)-.15 E(-)-.2 E 1.38(sion of)72 195.6 R/F2 9/Times-Roman@0 SF(UNIX) +3.88 E F0(it')3.88 E 3.879(sr)-.55 G 1.379(unning on \(great for puttin\ +g architecture-speci\214c binary directories into the)-3.879 F F1($P) +3.879 E -.95(AT)-.74 G(H).95 E F0(\).)A -1 -.8(Tw o)72 207.6 T -.25(va) +6.215 G 2.915(riables ha).25 F 3.215 -.15(ve b)-.2 H 2.915(een renamed:) +.15 F F1($HISTCONTR)5.416 E(OL)-.3 E F0(replaces)5.416 E F1 +($history_contr)5.416 E(ol)-.18 E F0 5.416(,a)C(nd)-5.416 E F1 +($HOSTFILE)5.416 E F0(replaces)72 219.6 Q F1 +($hostname_completion_\214le)2.521 E F0 5.021(.I)C 2.521(nb)-5.021 G +.021(oth cases, the old names are accepted for backw)-2.521 F .02 +(ards compatibil-)-.1 F(ity)72 231.6 Q 5.788(.T)-.65 G .788(he ksh) +-5.788 F/F3 10/Times-Italic@0 SF(select)3.288 E F0 .788 +(construct, which allo)3.288 F .788 +(ws the generation of simple menus, has been implemented.)-.25 F(Ne) +5.788 E(w)-.25 E 1.496(capabilities ha)72 243.6 R 1.796 -.15(ve b)-.2 H +1.496(een added to e).15 F 1.495(xisting v)-.15 F(ariables:)-.25 E F1 +($auto_r)3.995 E(esume)-.18 E F0 1.495(can no)3.995 F 3.995(wt)-.25 G +(ak)-3.995 E 3.995(ev)-.1 G 1.495(alues of)-4.245 F F3 -.2(ex)3.995 G +(act).2 E F0(or)3.995 E F3(sub-)3.995 E(string)72 255.6 Q F0 4.843(,a)C +(nd)-4.843 E F1($HISTCONTR)4.843 E(OL)-.3 E F0 2.343(understands the v) +4.843 F(alue)-.25 E F3(ignor)4.844 E(eboth)-.37 E F0 4.844(,w)C 2.344 +(hich combines the tw)-4.844 F 4.844(op)-.1 G(re)-4.844 E(viously)-.25 E +1.556(acceptable v)72 267.6 R 4.056(alues. The)-.25 F F1(dirs)4.056 E F0 +-.2(bu)4.056 G 1.556(iltin has acquired options to print out speci\214c\ + members of the directory).2 F 3.062(stack. The)72 279.6 R F1($nolinks) +3.062 E F0 -.25(va)3.062 G .562(riable, which forces a ph).25 F .562 +(ysical vie)-.05 F 3.062(wo)-.25 G 3.062(ft)-3.062 G .563 +(he \214le system, has been superseded by the)-3.062 F F172 291.6 +Q F0 .494(option to the)2.994 F F1(set)2.994 E F0 -.2(bu)2.994 G .494 +(iltin \(equi).2 F -.25(va)-.25 G .494(lent to).25 F F1 .494(set -o ph) +2.994 F(ysical)-.15 E F0 .493(\); the v)B .493 +(ariable is retained for backw)-.25 F .493(ards compati-)-.1 F(bility)72 +303.6 Q 5.196(.T)-.65 G .196(he v)-5.196 F .196 +(ersion string contained in)-.15 F F1($B)2.696 E(ASH_VERSION)-.3 E F0 +(no)2.696 E 2.696(wi)-.25 G .196(ncludes an indication of the patch le) +-2.696 F -.15(ve)-.25 G 2.696(la).15 G(s)-2.696 E .85(well as the \231b) +72 315.6 R .85(uild v)-.2 F 3.35(ersion\232. Some)-.15 F .85 +(little-used features ha)3.35 F 1.15 -.15(ve b)-.2 H .85(een remo).15 F +-.15(ve)-.15 G 3.35(d: the).15 F F1(by)3.35 E(e)-.1 E F0(synon)3.35 E +.85(ym for)-.15 F F1(exit)3.35 E F0(and)3.35 E(the)72 327.6 Q F1($NO_PR) +3.498 E(OMPT_V)-.3 E(ARS)-1.35 E F0 -.25(va)3.498 G .998 +(riable are gone.).25 F .998(There is no)5.998 F 3.498(wa)-.25 G 3.498 +(no)-3.498 G -2.19 -.18(rg a)-3.498 H .998 +(nized test suite that can be run as a).18 F(re)72 339.6 Q +(gression test when b)-.15 E(uilding a ne)-.2 E 2.5(wv)-.25 G +(ersion of Bash.)-2.65 E 1.696(The documentation has been thoroughly o) +97 355.2 R -.15(ve)-.15 G 1.696(rhauled: there is a ne).15 F 4.196(wm) +-.25 G 1.695(anual page on the readline)-4.196 F .467(library and the)72 +367.2 R F3(info)2.967 E F0 .467 +(\214le has been updated to re\215ect the current v)2.967 F 2.968 +(ersion. As)-.15 F(al)2.968 E -.1(wa)-.1 G .468(ys, as man).1 F 2.968 +(yb)-.15 G .468(ugs as possi-)-3.168 F(ble ha)72 379.2 Q .3 -.15(ve b) +-.2 H(een \214x).15 E(ed, although some surely remain.)-.15 E F1 2.5 +(5.2. Other)72 403.2 R -.25(Fe)2.5 G(atur).25 E(es)-.18 E F0 1.68 +(There are a fe)97 418.8 R 4.18(wf)-.25 G 1.68 +(eatures that I hope to include in later Bash releases.)-4.18 F 1.68 +(Some are based on w)6.68 F(ork)-.1 E(already done in other shells.)72 +430.8 Q .958(In addition to simple v)97 446.4 R .959(ariables, a future\ + release of Bash will include one-dimensional arrays, using)-.25 F .206 +(the ksh implementation of arrays as a model.)72 458.4 R .205 +(Additions to the ksh syntax, such as)5.205 F F3(varname)2.705 E F0 .205 +(=\( ... \) to assign)B 2.587(al)72 470.4 S .087(ist of w)-2.587 F .088 +(ords directly to an array and a mechanism to allo)-.1 F 2.588(wt)-.25 G +(he)-2.588 E F1 -.18(re)2.588 G(ad).18 E F0 -.2(bu)2.588 G .088 +(iltin to read a list of v).2 F .088(alues directly)-.25 F .092 +(into an array)72 482.4 R 2.592(,w)-.65 G .092(ould be desirable.)-2.692 +F(Gi)5.092 E -.15(ve)-.25 G 2.592(nt).15 G .092(hose e)-2.592 F .092 +(xtensions, the ksh)-.15 F F1 .092(set \255A)2.592 F F0 .091 +(syntax may not be w)2.591 F .091(orth support-)-.1 F(ing \(the)72 494.4 +Q F12.5 E F0(option assigns a list of v)2.5 E(alues to an array) +-.25 E 2.5(,b)-.65 G(ut is a rather peculiar special case\).)-2.7 E .76 +(Some shells include a means of)97 510 R F3(pr)3.26 E -.1(og)-.45 G -.15 +(ra).1 G(mmable).15 E F0 -.1(wo)3.26 G .76 +(rd completion, where the user speci\214es on a per).1 F(-)-.2 E .163 +(command basis ho)72 522 R 2.663(wt)-.25 G .163(he ar)-2.663 F .163(gum\ +ents of the command are to be treated when completion is attempted: as \ +\214le-)-.18 F .194(names, hostnames, e)72 534 R -.15(xe)-.15 G .194 +(cutable \214les, and so on.).15 F .195 +(The other aspects of the current Bash implementation could)5.195 F .482 +(remain as-is; the e)72 546 R .482(xisting heuristics w)-.15 F .481 +(ould still be v)-.1 F 2.981(alid. Only)-.25 F .481 +(when completing the ar)2.981 F .481(guments to a simple)-.18 F +(command w)72 558 Q(ould the programmable completion be in ef)-.1 E +(fect.)-.25 E .479(It w)97 573.6 R .479(ould also be nice to gi)-.1 F +.779 -.15(ve t)-.25 H .479(he user \214ner).15 F .479 +(-grained control o)-.2 F -.15(ve)-.15 G 2.98(rw).15 G .48 +(hich commands are sa)-2.98 F -.15(ve)-.2 G 2.98(do).15 G .48(nto the) +-2.98 F 1.786(history list.)72 585.6 R 1.786(One proposal is for a v) +6.786 F 1.786(ariable, tentati)-.25 F -.15(ve)-.25 G 1.786(ly named).15 +F F1(HISTIGNORE)4.286 E F0 4.285(,w)C 1.785(hich w)-4.285 F 1.785 +(ould contain a)-.1 F .496(colon-separated list of commands.)72 597.6 R +.496(Lines be)5.496 F .496 +(ginning with these commands, after the restrictions of)-.15 F F1($HIST) +2.997 E(-)-.92 E(CONTR)72 609.6 Q(OL)-.3 E F0(ha)2.65 E .45 -.15(ve b) +-.2 H .15(een applied, w).15 F .15 +(ould not be placed onto the history list.)-.1 F .15 +(The shell pattern-matching capa-)5.15 F(bilities could also be a)72 +621.6 Q -.25(va)-.2 G(ilable when specifying the contents of).25 E F1 +($HISTIGNORE)2.5 E F0(.)A .729(One thing that ne)97 637.2 R .729 +(wer shells such as)-.25 F F1(wksh)3.229 E F0 .729(\(also kno)3.229 F +.729(wn as)-.25 F F1(dtksh)3.23 E F0 3.23(\)p)C(ro)-3.23 E .73 +(vide is a command to dynami-)-.15 F 1.189 +(cally load code implementing additional b)72 649.2 R 1.189 +(uiltin commands into a running shell.)-.2 F 1.188(This ne)6.188 F 3.688 +(wb)-.25 G 1.188(uiltin w)-3.888 F(ould)-.1 E(tak)72 661.2 Q 2.875(ea) +-.1 G 2.875(no)-2.875 G .375 +(bject \214le or shared library implementing the \231body\232 of the b) +-2.875 F .375(uiltin \()-.2 F F3(xxx_b)A(uiltin\(\))-.2 E F0 .375 +(for those f)2.875 F(amiliar)-.1 E .052 +(with Bash internals\) and a structure containing the name of the ne)72 +673.2 R 2.552(wc)-.25 G .051(ommand, the function to call when the) +-2.552 F(ne)72 685.2 Q 3.458(wb)-.25 G .958(uiltin is in)-3.658 F -.2 +(vo)-.4 G -.1(ke).2 G 3.458(d\().1 G .959 +(presumably de\214ned in the shared object speci\214ed as an ar)-3.458 F +.959(gument\), and the docu-)-.18 F 1.352 +(mentation to be printed by the)72 697.2 R F1(help)3.851 E F0 1.351 +(command \(possibly present in the shared object as well\).)3.851 F +1.351(It w)6.351 F(ould)-.1 E(manage the details of e)72 709.2 Q +(xtending the internal table of b)-.15 E(uiltins.)-.2 E 0 Cg EP +%%Page: 10 10 +%%BeginPageSetup +BP +%%EndPageSetup +/F0 10/Times-Roman@0 SF(-10-)279.67 48 Q 3.291(Af)97 84 S 1.291 -.25 +(ew o)-3.291 H .791(ther b).25 F .791(uiltins w)-.2 F .791 +(ould also be desirable: tw)-.1 F 3.291(oa)-.1 G .791(re the POSIX.2) +-3.291 F/F1 10/Times-Bold@0 SF(getconf)3.292 E F0 .792 +(command, which prints)3.292 F 1.412(the v)72 96 R 1.412 +(alues of system con\214guration v)-.25 F 1.411 +(ariables de\214ned by POSIX.2, and a)-.25 F F1(diso)3.911 E(wn)-.1 E F0 +-.2(bu)3.911 G 1.411(iltin, which causes a).2 F .547 +(shell running with job control acti)72 108 R .847 -.15(ve t)-.25 H +3.047<6f99>.15 G(for)-3.047 E .547 +(get about\232 one or more background jobs in its internal jobs ta-)-.18 +F 3.866(ble. Using)72 120 R F1(getconf)3.866 E F0 3.866(,f)C 1.366(or e) +-3.866 F 1.366(xample, a user could retrie)-.15 F 1.666 -.15(ve a v)-.25 +H 1.365(alue for)-.1 F F1($P)3.865 E -.95(AT)-.74 G(H).95 E F0 1.365 +(guaranteed to \214nd all of the)3.865 F .884 +(POSIX standard utilities, or \214nd out ho)72 132 R 3.385(wl)-.25 G +.885 +(ong \214lenames may be in the \214le system containing a speci\214ed) +-3.385 F(directory)72 144 Q(.)-.65 E 1.521 +(There are no implementation timetables for an)97 159.6 R 4.021(yo)-.15 +G 4.021(ft)-4.021 G 1.52(hese features, nor are there concrete plans to) +-4.021 F(include them.)72 171.6 Q(If an)5 E(yone has comments on these \ +proposals, feel free to send me electronic mail.)-.15 E F1 2.5 +(6. Re\215ections)72 195.6 R(and Lessons Lear)2.5 E(ned)-.15 E F0 .433 +(The lesson that has been repeated most often during Bash de)97 211.2 R +-.15(ve)-.25 G .433(lopment is that there are dark corners).15 F .181 +(in the Bourne shell, and people use all of them.)72 223.2 R .18 +(In the original description of the Bourne shell, quoting and)5.181 F +.073(the shell grammar are both poorly speci\214ed and incomplete; subs\ +equent descriptions ha)72 235.2 R .373 -.15(ve n)-.2 H .073 +(ot helped much.).15 F 1.856(The grammar presented in Bourne')72 247.2 R +4.356(sp)-.55 G 1.856(aper describing the shell distrib)-4.356 F 1.855 +(uted with the Se)-.2 F -.15(ve)-.25 G 1.855(nth Edition of).15 F/F2 9 +/Times-Roman@0 SF(UNIX)72 259.2 Q F0 2.5<8769>C 2.5(ss)-2.5 G 2.5(of) +-2.5 G(ar of)-2.6 E 2.5(ft)-.25 G(hat it does not allo)-2.5 E 2.5(wt) +-.25 G(he command)-2.5 E/F3 10/Courier@0 SF(who|wc)2.5 E F0 5(.I)C 2.5 +(nf)-5 G(act, as T)-2.6 E(om Duf)-.8 E 2.5(fs)-.25 G(tates:)-2.5 E 1.375 +(Nobody really kno)97 274.8 R 1.375(ws what the Bourne shell')-.25 F +3.875(sg)-.55 G 1.375(rammar is.)-3.875 F(Ev)6.376 E 1.376(en e)-.15 F +1.376(xamination of the source)-.15 F(code is little help.\210)97 286.8 +Q .382(The POSIX.2 standard includes a)72 302.4 R/F4 10/Times-Italic@0 +SF(yacc)2.882 E F0 .382 +(grammar that comes close to capturing the Bourne shell')2.882 F 2.882 +(sb)-.55 G(eha)-2.882 E(vior)-.2 E(,)-.4 E -.2(bu)72 314.4 S 3.246(ti).2 +G 3.246(td)-3.246 G(isallo)-3.246 E .747(ws some constructs which sh ac\ +cepts without complaint \255 and there are scripts out there that)-.25 F +.501(use them.)72 326.4 R .501(It took a fe)5.501 F 3.001(wv)-.25 G .501 +(ersions and se)-3.151 F -.15(ve)-.25 G .501(ral b).15 F .5 +(ug reports before Bash implemented sh-compatible quoting,)-.2 F .279 +(and there are still some \231le)72 338.4 R -.05(ga)-.15 G .279 +(l\232 sh constructs which Bash \215ags as syntax errors.).05 F .28 +(Complete sh compatibility)5.28 F(is a tough nut.)72 350.4 Q 1.231 +(The shell is bigger and slo)97 366 R 1.231(wer than I w)-.25 F 1.231 +(ould lik)-.1 F 1.23(e, though the current v)-.1 F 1.23 +(ersion is substantially f)-.15 F(aster)-.1 E .086(than pre)72 378 R +(viously)-.25 E 5.086(.T)-.65 G .087 +(he readline library could stand a substantial re)-5.086 F 2.587 +(write. A)-.25 F .087(hand-written parser to replace the)2.587 F +(current)72 390 Q F4(yacc)2.978 E F0 .478(-generated one w)B .477 +(ould probably result in a speedup, and w)-.1 F .477(ould solv)-.1 F +2.977(eo)-.15 G .477(ne glaring problem:)-2.977 F(the)5.477 E .384 +(shell could parse commands in \231$\(...\)\232 constructs as the)72 402 +R 2.884(ya)-.15 G .385 +(re entered, rather than reporting errors when the)-2.884 F +(construct is e)72 414 Q(xpanded.)-.15 E 1.064(As al)97 429.6 R -.1(wa) +-.1 G 1.064(ys, there is some chaf).1 F 3.564(ft)-.25 G 3.564(og)-3.564 +G 3.564(ow)-3.564 G 1.064(ith the wheat.)-3.564 F 1.063 +(Areas of duplicated functionality need to be)6.063 F .382(cleaned up.) +72 441.6 R .382(There are se)5.382 F -.15(ve)-.25 G .382 +(ral cases where Bash treats a v).15 F .382 +(ariable specially to enable functionality a)-.25 F -.25(va)-.2 G +(ilable).25 E .185(another w)72 453.6 R .185(ay \()-.1 F F1($notify)A F0 +(vs.)2.684 E F1 .184(set -o notify)5.184 F F0(and)2.684 E F1($nolinks) +2.684 E F0(vs.)2.684 E F1 .184(set -o ph)2.684 F(ysical)-.15 E F0 2.684 +(,f)C .184(or instance\); the special treatment)-2.684 F 3.421(of the v) +72 465.6 R 3.421(ariable name should probably be remo)-.25 F -.15(ve) +-.15 G 5.921(d. A).15 F(fe)5.921 E 5.921(wm)-.25 G 3.422 +(ore things could stand remo)-5.921 F -.25(va)-.15 G 3.422(l; the).25 F +F1($allo)72 477.6 Q(w_null_glob_expansion)-.1 E F0(and)4.112 E F1 +($glob_dot_\214lenames)4.112 E F0 -.25(va)4.111 G 1.611 +(riables are of particularly questionable v).25 F(alue.)-.25 E(The)72 +489.6 Q F1($[...])3.977 E F0 1.477(arithmetic e)3.977 F -.25(va)-.25 G +1.478(luation syntax is redundant no).25 F 3.978(wt)-.25 G 1.478 +(hat the POSIX-mandated)-3.978 F F1($\(\(...\)\))3.978 E F0 1.478 +(construct has)3.978 F .326(been implemented, and could be deleted.)72 +501.6 R .326(It w)5.326 F .326(ould be nice if the te)-.1 F .326 +(xt output by the)-.15 F F1(help)2.825 E F0 -.2(bu)2.825 G .325 +(iltin were e).2 F(xter)-.15 E(-)-.2 E .061 +(nal to the shell rather than compiled into it.)72 513.6 R .062 +(The beha)5.062 F .062(vior enabled by)-.2 F F1 +($command_oriented_history)2.562 E F0 2.562(,w)C(hich)-2.562 E 1.125 +(causes the shell to attempt to sa)72 525.6 R 1.424 -.15(ve a)-.2 H +1.124(ll lines of a multi-line command in a single history entry).15 F +3.624(,s)-.65 G 1.124(hould be)-3.624 F(made the def)72 537.6 Q +(ault and the v)-.1 E(ariable remo)-.25 E -.15(ve)-.15 G(d.).15 E F1 2.5 +(7. A)72 561.6 R -.1(va)-1 G(ilability).1 E F0 .047 +(As with all other GNU softw)97 577.2 R .047(are, Bash is a)-.1 F -.25 +(va)-.2 G .047(ilable for anon).25 F .047(ymous FTP from)-.15 F F4(pr) +2.547 E(ep.ai.mit.edu:/pub/gnu)-.37 E F0 1.05(and from other GNU softw) +72 589.2 R 1.05(are mirror sites.)-.1 F 1.049(The current v)6.049 F +1.049(ersion is in)-.15 F F4(bash-1.14.1.tar)3.549 E(.gz)-1.11 E F0 +1.049(in that directory)3.549 F(.)-.65 E(Use)72 601.2 Q F4(ar)5.965 E +-.15(ch)-.37 G(ie).15 E F0 3.465(to \214nd the nearest archi)5.965 F +3.766 -.15(ve s)-.25 H 5.966(ite. The).15 F 3.466(latest v)5.966 F 3.466 +(ersion is al)-.15 F -.1(wa)-.1 G 3.466(ys a).1 F -.25(va)-.2 G 3.466 +(ilable for FTP from).25 F F4(bash.CWR)72 613.2 Q -.25(U.)-.4 G +(Edu:/pub/dist.).25 E F0(Bash documentation is a)5 E -.25(va)-.2 G +(ilable for FTP from).25 E F4(bash.CWR)2.5 E -.25(U.)-.4 G +(Edu:/pub/bash.).25 E F0 1.169(The Free Softw)97 628.8 R 1.169(are F)-.1 +F 1.169(oundation sells tapes and CD-R)-.15 F 1.168 +(OMs containing Bash; send electronic mail to)-.4 F F3 +(gnu@prep.ai.mit.edu)72 640.8 Q F0(or call)2.5 E F3(+1-617-876-3296)2.5 +E F0(for more information.)2.5 E .694(Bash is also distrib)97 656.4 R +.694(uted with se)-.2 F -.15(ve)-.25 G .694(ral v).15 F .694(ersions of) +-.15 F F2(UNIX)3.194 E F0 .694(-compatible systems.)B .695 +(It is included as /bin/sh)5.694 F .948(and /bin/bash on se)72 668.4 R +-.15(ve)-.25 G .948(ral Linux distrib).15 F .948 +(utions \(more about the dif)-.2 F .948 +(ference in a moment\), and as contrib)-.25 F(uted)-.2 E .32 LW 144 +678.2 72 678.2 DL/F5 8/Times-Roman@0 SF .781 +(\207S. R. Bourne, \231UNIX T)72 688.2 R .781(ime-Sharing System:)-.28 F +.781(The UNIX Shell\232,)4.781 F/F6 8/Times-Italic@0 SF .78 +(Bell System T)2.78 F(ec)-.736 E .78(hnical J)-.12 F(ournal)-.2 E F5 +2.78(,5)C .78(7\(6\), July-)-2.78 F(August, 1978, pp. 1971-1990.)72 +698.2 Q<8854>72 710 Q .431(om Duf)-.64 F .431 +(f, \231Rc \255 A Shell for Plan 9 and)-.2 F/F7 7/Times-Roman@0 SF(UNIX) +2.432 E F5(systems\232,)2.432 E F6(Pr)2.432 E .432 +(oc. of the Summer 1990 EUUG Confer)-.36 F(ence)-.296 E F5 2.432(,L)C +(on-)-2.432 E(don, July)72 720 Q 2(,1)-.52 G(990, pp. 21-33.)-2 E 0 Cg +EP +%%Page: 11 11 +%%BeginPageSetup +BP +%%EndPageSetup +/F0 10/Times-Roman@0 SF(-11-)279.67 48 Q(softw)72 84 Q(are in BSDI')-.1 +E 2.5(sB)-.55 G(SD/386* and FreeBSD.)-2.5 E .598(The Linux distrib)97 +99.6 R .598(ution deserv)-.2 F .598(es special mention.)-.15 F .598 +(There are tw)5.598 F 3.099(oc)-.1 G .599 +(on\214gurations included in the stan-)-3.099 F .733(dard Bash distrib) +72 111.6 R .732(ution: a \231normal\232 con\214guration, in which all o\ +f the standard features are included, and a)-.2 F .519(\231minimal\232 \ +con\214guration, which omits job control, aliases, history and command \ +line editing, the directory)72 123.6 R .886(stack and)72 135.6 R/F1 10 +/Times-Bold@0 SF(pushd/popd/dirs,)3.386 E F0 .886(process substitution,\ + prompt string special character decoding, and the)3.386 F/F2 10 +/Times-Italic@0 SF(select)3.385 E F0 3.368(construct. This)72 147.6 R +.868(minimal v)3.368 F .869 +(ersion is designed to be a drop-in replacement for the traditional)-.15 +F/F3 9/Times-Roman@0 SF(UNIX)3.369 E F0(/bin/sh,)3.369 E +(and is included as the Linux /bin/sh in se)72 159.6 Q -.15(ve)-.25 G +(ral packagings.).15 E F1 2.5(8. Conclusion)72 183.6 R F0 .8 +(Bash is a w)97 199.2 R(orth)-.1 E 3.3(ys)-.05 G .8(uccessor to sh.)-3.3 +F .8(It is suf)5.8 F .8(\214ciently portable to run on nearly e)-.25 F +-.15(ve)-.25 G .8(ry v).15 F .8(ersion of)-.15 F F3(UNIX)3.299 E F0 .31 +(from 4.3 BSD to SVR4.2, and se)72 211.2 R -.15(ve)-.25 G(ral).15 E F3 +(UNIX)2.81 E F0 -.1(wo)2.81 G(rkalik).1 E 2.81(es. It)-.1 F .311(is rob) +2.81 F .311(ust enough to replace sh on most of those)-.2 F 1.515 +(systems, and pro)72 223.2 R 1.515(vides more functionality)-.15 F 6.515 +(.I)-.65 G 4.015(th)-6.515 G 1.515(as se)-4.015 F -.15(ve)-.25 G 1.515 +(ral thousand re).15 F 1.515(gular users, and their feedback has)-.15 F +(helped to mak)72 235.2 Q 2.5(ei)-.1 G 2.5(ta)-2.5 G 2.5(sg)-2.5 G +(ood as it is today \255 a testament to the bene\214ts of free softw) +-2.5 E(are.)-.1 E .32 LW 144 710 72 710 DL/F4 8/Times-Roman@0 SF +(*BSD/386 is a trademark of Berk)72 720 Q(ele)-.08 E 2(yS)-.12 G(oftw)-2 +E(are Design, Inc.)-.08 E 0 Cg EP +%%Trailer +end +%%EOF diff --git a/doc/article.txt b/doc/article.txt new file mode 100644 index 0000000..c19ff92 --- /dev/null +++ b/doc/article.txt @@ -0,0 +1,1111 @@ + + + + + + + + + + Bash - The GNU shell* + + + Chet Ramey + Case Western Reserve University + chet@po.cwru.edu + + + + + + +_1. _I_n_t_r_o_d_u_c_t_i_o_n + + _B_a_s_h is the shell, or command language interpreter, +that will appear in the GNU operating system. The name is +an acronym for the "Bourne-Again SHell", a pun on Steve +Bourne, the author of the direct ancestor of the current +UNIX|- shell /_b_i_n/_s_h, which appeared in the Seventh Edition +Bell Labs Research version of UNIX. + + Bash is an sh-compatible shell that incorporates useful +features from the Korn shell (ksh) and the C shell (csh), +described later in this article. It is ultimately intended +to be a conformant implementation of the IEEE POSIX Shell +and Utilities specification (IEEE Working Group 1003.2). It +offers functional improvements over sh for both interactive +and programming use. + + While the GNU operating system will most likely include +a version of the Berkeley shell csh, Bash will be the +default shell. Like other GNU software, Bash is quite port- +able. It currently runs on nearly every version of UNIX and +a few other operating systems - an independently-supported +port exists for OS/2, and there are rumors of ports to DOS +and Windows NT. Ports to UNIX-like systems such as QNX and +Minix are part of the distribution. + + The original author of Bash was Brian Fox, an employee +of the Free Software Foundation. The current developer and +maintainer is Chet Ramey, a volunteer who works at Case +Western Reserve University. + +_2. _W_h_a_t'_s _P_O_S_I_X, _a_n_y_w_a_y? + + _P_O_S_I_X is a name originally coined by Richard Stallman +_________________________ +*An earlier version of this article appeared in The +Linux Journal. +|- UNIX is a trademark of Bell Laboratories. + + + + + October 28, 1994 + + + + + + - 2 - + + +for a family of open system standards based on UNIX. There +are a number of aspects of UNIX under consideration for +standardization, from the basic system services at the sys- +tem call and C library level to applications and tools to +system administration and management. Each area of stan- +dardization is assigned to a working group in the 1003 +series. + + The POSIX Shell and Utilities standard has been +developed by IEEE Working Group 1003.2 (POSIX.2).|= It con- +centrates on the command interpreter interface and utility +programs commonly executed from the command line or by other +programs. An initial version of the standard has been +approved and published by the IEEE, and work is currently +underway to update it. There are four primary areas of work +in the 1003.2 standard: + +o+ Aspects of the shell's syntax and command language. A + number of special builtins such as _c_d and _e_x_e_c are + being specified as part of the shell, since their func- + tionality usually cannot be implemented by a separate + executable; + +o+ A set of utilities to be called by shell scripts and + applications. Examples are programs like _s_e_d, _t_r, and + _a_w_k. Utilities commonly implemented as shell builtins + are described in this section, such as _t_e_s_t and _k_i_l_l. + An expansion of this section's scope, termed the User + Portability Extension, or UPE, has standardized + interactive programs such as _v_i and _m_a_i_l_x; + +o+ A group of functional interfaces to services provided + by the shell, such as the traditional system() C + library function. There are functions to perform shell + word expansions, perform filename expansion (_g_l_o_b_b_i_n_g), + obtain values of POSIX.2 system configuration vari- + ables, retrieve values of environment variables + (getenv()), _a_n_d _o_t_h_e_r _s_e_r_v_i_c_e_s; + +o+ A suite of "development" utilities such as _c_8_9 (the + POSIX.2 version of _c_c), and _y_a_c_c. + + Bash is concerned with the aspects of the shell's +behavior defined by POSIX.2. The shell command language has +of course been standardized, including the basic flow con- +trol and program execution constructs, I/O redirection and +pipelining, argument handling, variable expansion, and quot- +ing. The _s_p_e_c_i_a_l builtins, which must be implemented as +part of the shell to provide the desired functionality, are +_________________________ +|=IEEE, _I_E_E_E _S_t_a_n_d_a_r_d _f_o_r _I_n_f_o_r_m_a_t_i_o_n _T_e_c_h_n_o_l_o_g_y -- +_P_o_r_t_a_b_l_e _O_p_e_r_a_t_i_n_g _S_y_s_t_e_m _I_n_t_e_r_f_a_c_e (_P_O_S_I_X) _P_a_r_t _2: +_S_h_e_l_l _a_n_d _U_t_i_l_i_t_i_e_s, 1992. + + + + + October 28, 1994 + + + + + + - 3 - + + +specified as being part of the shell; examples of these are +_e_v_a_l and _e_x_p_o_r_t. Other utilities appear in the sections of +POSIX.2 not devoted to the shell which are commonly (and in +some cases must be) implemented as builtin commands, such as +_r_e_a_d and _t_e_s_t. POSIX.2 also specifies aspects of the +shell's interactive behavior as part of the UPE, including +job control and command line editing. Interestingly enough, +only _v_i-style line editing commands have been standardized; +_e_m_a_c_s editing commands were left out due to objections. + + While POSIX.2 includes much of what the shell has trad- +itionally provided, some important things have been omitted +as being "beyond its scope." There is, for instance, no +mention of a difference between a _l_o_g_i_n shell and any other +interactive shell (since POSIX.2 does not specify a login +program). No fixed startup files are defined, either - the +standard does not mention ._p_r_o_f_i_l_e. + +_3. _B_a_s_i_c _B_a_s_h _f_e_a_t_u_r_e_s + + Since the Bourne shell provides Bash with most of its +philosophical underpinnings, Bash inherits most of its +features and functionality from sh. Bash implements all of +the traditional sh flow control constructs (_f_o_r, _i_f, _w_h_i_l_e, +etc.). All of the Bourne shell builtins, including those +not specified in the POSIX.2 standard, appear in Bash. +Shell _f_u_n_c_t_i_o_n_s, introduced in the SVR2 version of the +Bourne shell, are similar to shell scripts, but are defined +using a special syntax and are executed in the same process +as the calling shell. Bash has shell functions which behave +in a fashion upward-compatible with sh functions. There are +certain shell variables that Bash interprets in the same way +as sh, such as _P_S_1, _I_F_S, and _P_A_T_H. Bash implements essen- +tially the same grammar, parameter and variable expansion +semantics, redirection, and quoting as the Bourne shell. +Where differences appear between the POSIX.2 standard and +traditional sh behavior, Bash follows POSIX. + + The Korn Shell (ksh) is a descendent of the Bourne +shell written at AT&T Bell Laboratories by David Korn|-. It +provides a number of useful features that POSIX and Bash +have adopted. Many of the interactive facilities in POSIX.2 +have their roots in the ksh: for example, the POSIX and ksh +job control facilities are nearly identical. Bash includes +features from the Korn Shell for both interactive use and +shell programming. For programming, Bash provides variables +such as _R_A_N_D_O_M and _R_E_P_L_Y, the _t_y_p_e_s_e_t builtin, the ability +to remove substrings from variables based on patterns, and +shell arithmetic. _R_A_N_D_O_M expands to a random number each +time it is referenced; assigning a value to _R_A_N_D_O_M seeds the +_________________________ +|-Morris Bolsky and David Korn, _T_h_e _K_o_r_n_S_h_e_l_l _C_o_m_m_a_n_d +_a_n_d _P_r_o_g_r_a_m_m_i_n_g _L_a_n_g_u_a_g_e, Prentice Hall, 1989. + + + + + October 28, 1994 + + + + + + - 4 - + + +random number generator. _R_E_P_L_Y is the default variable used +by the _r_e_a_d builtin when no variable names are supplied as +arguments. The _t_y_p_e_s_e_t builtin is used to define variables +and give them attributes such as readonly. Bash arithmetic +allows the evaluation of an expression and the substitution +of the result. Shell variables may be used as operands, and +the result of an expression may be assigned to a variable. +Nearly all of the operators from the C language are avail- +able, with the same precedence rules: +9 $ echo $((3 + 5 * 32)) + 163 +9 +For interactive use, Bash implements ksh-style aliases and +builtins such as _f_c (discussed below) and _j_o_b_s. Bash +aliases allow a string to be substituted for a command name. +They can be used to create a mnemonic for a UNIX command +name (alias del=rm), to expand a single word to a complex +command (alias news='xterm -g 80x45 -title trn -e trn -e -S1 +-N &'), or to ensure that a command is invoked with a basic +set of options (alias ls="/bin/ls -F"). + + The C shell (csh)|-, originally written by Bill Joy +while at Berkeley, is widely used and quite popular for its +interactive facilities. Bash includes a csh-compatible his- +tory expansion mechanism ("! history"), brace expansion, +access to a stack of directories via the _p_u_s_h_d, _p_o_p_d, and +_d_i_r_s builtins, and tilde expansion, to generate users' home +directories. Tilde expansion has also been adopted by both +the Korn Shell and POSIX.2. + + There were certain areas in which POSIX.2 felt stan- +dardization was necessary, but no existing implementation +provided the proper behavior. The working group invented +and standardized functionality in these areas, which Bash +implements. The _c_o_m_m_a_n_d builtin was invented so that shell +functions could be written to replace builtins; it makes the +capabilities of the builtin available to the function. The +reserved word "!" was added to negate the return value of a +command or pipeline; it was nearly impossible to express "if +not x" cleanly using the sh language. There exist multiple +incompatible implementations of the _t_e_s_t builtin, which +tests files for type and other attributes and performs +arithmetic and string comparisons. POSIX considered none of +these correct, so the standard behavior was specified in +terms of the number of arguments to the command. POSIX.2 +dictates exactly what will happen when four or fewer argu- +ments are given to _t_e_s_t, and leaves the behavior undefined +when more arguments are supplied. Bash uses the POSIX.2 +_________________________ +|-Bill Joy, An Introduction to the C Shell, _U_N_I_X _U_s_e_r'_s +_S_u_p_p_l_e_m_e_n_t_a_r_y _D_o_c_u_m_e_n_t_s, University of California at +Berkeley, 1986. + + + + + October 28, 1994 + + + + + + - 5 - + + +algorithm, which was conceived by David Korn. + +_3._1. _F_e_a_t_u_r_e_s _n_o_t _i_n _t_h_e _B_o_u_r_n_e _S_h_e_l_l + + There are a number of minor differences between Bash +and the version of sh present on most other versions of +UNIX. The majority of these are due to the POSIX standard, +but some are the result of Bash adopting features from other +shells. For instance, Bash includes the new "!" reserved +word, the _c_o_m_m_a_n_d builtin, the ability of the _r_e_a_d builtin +to correctly return a line ending with a backslash, symbolic +arguments to the _u_m_a_s_k builtin, variable substring removal, +a way to get the length of a variable, and the new algorithm +for the _t_e_s_t builtin from the POSIX.2 standard, none of +which appear in sh. + + Bash also implements the "$(...)" command substitution +syntax, which supersedes the sh `...` construct. The +"$(...)" construct expands to the output of the command con- +tained within the parentheses, with trailing newlines +removed. The sh syntax is accepted for backwards compati- +bility, but the "$(...)" form is preferred because its quot- +ing rules are much simpler and it is easier to nest. + + The Bourne shell does not provide such features as +brace expansion, the ability to define a variable and a +function with the same name, local variables in shell func- +tions, the ability to enable and disable individual builtins +or write a function to replace a builtin, or a means to +export a shell function to a child process. + + Bash has closed a long-standing shell security hole by +not using the $_I_F_S variable to split each word read by the +shell, but splitting only the results of expansion (ksh and +the 4.4 BSD sh have fixed this as well). Useful behavior +such as a means to abort execution of a script read with the +"." command using the return builtin or automatically +exporting variables in the shell's environment to children +is also not present in the Bourne shell. Bash provides a +much more powerful environment for both interactive use and +programming. + +_4. _B_a_s_h-_s_p_e_c_i_f_i_c _F_e_a_t_u_r_e_s + + This section details a few of the features which make +Bash unique. Most of them provide improved interactive use, +but a few programming improvements are present as well. +Full descriptions of these features can be found in the Bash +documentation. + +_4._1. _S_t_a_r_t_u_p _F_i_l_e_s + + Bash executes startup files differently than other +shells. The Bash behavior is a compromise between the csh + + + + October 28, 1994 + + + + + + - 6 - + + +principle of startup files with fixed names executed for +each shell and the sh "minimalist" behavior. An interactive +instance of Bash started as a login shell reads and executes +~/._b_a_s_h__p_r_o_f_i_l_e (the file .bash_profile in the user's home +directory), if it exists. An interactive non-login shell +reads and executes ~/._b_a_s_h_r_c. A non-interactive shell (one +begun to execute a shell script, for example) reads no fixed +startup file, but uses the value of the variable $_E_N_V, if +set, as the name of a startup file. The ksh practice of +reading $_E_N_V for every shell, with the accompanying diffi- +culty of defining the proper variables and functions for +interactive and non-interactive shells or having the file +read only for interactive shells, was considered too com- +plex. Ease of use won out here. Interestingly, the next +release of ksh will change to reading $_E_N_V only for interac- +tive shells. + +_4._2. _N_e_w _B_u_i_l_t_i_n _C_o_m_m_a_n_d_s + + There are a few builtins which are new or have been +extended in Bash. The _e_n_a_b_l_e builtin allows builtin com- +mands to be turned on and off arbitrarily. To use the ver- +sion of _e_c_h_o found in a user's search path rather than the +Bash builtin, enable -n echo suffices. The _h_e_l_p builtin +provides quick synopses of the shell facilities without +requiring access to a manual page. _B_u_i_l_t_i_n is similar to +_c_o_m_m_a_n_d in that it bypasses shell functions and directly +executes builtin commands. Access to a csh-style stack of +directories is provided via the _p_u_s_h_d, _p_o_p_d, and _d_i_r_s buil- +tins. _P_u_s_h_d and _p_o_p_d insert and remove directories from the +stack, respectively, and _d_i_r_s lists the stack contents. On +systems that allow fine-grained control of resources, the +_u_l_i_m_i_t builtin can be used to tune these settings. _U_l_i_m_i_t +allows a user to control, among other things, whether core +dumps are to be generated, how much memory the shell or a +child process is allowed to allocate, and how large a file +created by a child process can grow. The _s_u_s_p_e_n_d command +will stop the shell process when job control is active; most +other shells do not allow themselves to be stopped like +that. _T_y_p_e, the Bash answer to _w_h_i_c_h and _w_h_e_n_c_e, shows what +will happen when a word is typed as a command: +9 $ type export + export is a shell builtin + $ type -t export + builtin + $ type bash + bash is /bin/bash + $ type cd + cd is a function + cd () + { + builtin cd ${1+"$@"} && xtitle $HOST: $PWD + } +9 + + + October 28, 1994 + + + + + + - 7 - + + +Various modes tell what a command word is (reserved word, +alias, function, builtin, or file) or which version of a +command will be executed based on a user's search path. +Some of this functionality has been adopted by POSIX.2 and +folded into the _c_o_m_m_a_n_d utility. + +_4._3. _E_d_i_t_i_n_g _a_n_d _C_o_m_p_l_e_t_i_o_n + + One area in which Bash shines is command line editing. +Bash uses the _r_e_a_d_l_i_n_e library to read and edit lines when +interactive. Readline is a powerful and flexible input +facility that a user can configure to individual tastes. It +allows lines to be edited using either emacs or vi commands, +where those commands are appropriate. The full capability +of emacs is not present - there is no way to execute a named +command with M-x, for instance - but the existing commands +are more than adequate. The vi mode is compliant with the +command line editing standardized by POSIX.2. + + Readline is fully customizable. In addition to the +basic commands and key bindings, the library allows users to +define additional key bindings using a startup file. The +_i_n_p_u_t_r_c file, which defaults to the file ~/._i_n_p_u_t_r_c, is read +each time readline initializes, permitting users to maintain +a consistent interface across a set of programs. Readline +includes an extensible interface, so each program using the +library can add its own bindable commands and program- +specific key bindings. Bash uses this facility to add bind- +ings that perform history expansion or shell word expansions +on the current input line. + + Readline interprets a number of variables which further +tune its behavior. Variables exist to control whether or +not eight-bit characters are directly read as input or con- +verted to meta-prefixed key sequences (a meta-prefixed key +sequence consists of the character with the eighth bit +zeroed, preceded by the _m_e_t_a-_p_r_e_f_i_x character, usually +escape, which selects an alternate keymap), to decide +whether to output characters with the eighth bit set +directly or as a meta-prefixed key sequence, whether or not +to wrap to a new screen line when a line being edited is +longer than the screen width, the keymap to which subsequent +key bindings should apply, or even what happens when read- +line wants to ring the terminal's bell. All of these vari- +ables can be set in the inputrc file. + + The startup file understands a set of C preprocessor- +like conditional constructs which allow variables or key +bindings to be assigned based on the application using read- +line, the terminal currently being used, or the editing +mode. Users can add program-specific bindings to make their +lives easier: I have bindings that let me edit the value of +$_P_A_T_H and double-quote the current or previous word: +9 # Macros that are convenient for shell interaction + + +9 October 28, 1994 + + + + + + - 8 - + + + $if Bash + # edit the path + "\C-xp": "PATH=${PATH}\e\C-e\C-a\ef\C-f" + # prepare to type a quoted word -- insert open and close double + # quotes and move to just after the open quote + "\C-x\"": "\"\"\C-b" + # Quote the current or previous word + "\C-xq": "\eb\"\ef\"" + $endif +9 +There is a readline command to re-read the file, so users +can edit the file, change some bindings, and begin to use +them almost immediately. + + Bash implements the _b_i_n_d builtin for more dyamic con- +trol of readline than the startup file permits. _B_i_n_d is +used in several ways. In _l_i_s_t mode, it can display the +current key bindings, list all the readline editing direc- +tives available for binding, list which keys invoke a given +directive, or output the current set of key bindings in a +format that can be incorporated directly into an inputrc +file. In _b_a_t_c_h mode, it reads a series of key bindings +directly from a file and passes them to readline. In its +most common usage, _b_i_n_d takes a single string and passes it +directly to readline, which interprets the line as if it had +just been read from the inputrc file. Both key bindings and +variable assignments may appear in the string given to _b_i_n_d. + + The readline library also provides an interface for +_w_o_r_d _c_o_m_p_l_e_t_i_o_n. When the _c_o_m_p_l_e_t_i_o_n character (usually +TAB) is typed, readline looks at the word currently being +entered and computes the set of filenames of which the +current word is a valid prefix. If there is only one possi- +ble completion, the rest of the characters are inserted +directly, otherwise the common prefix of the set of +filenames is added to the current word. A second TAB char- +acter entered immediately after a non-unique completion +causes readline to list the possible completions; there is +an option to have the list displayed immediately. Readline +provides hooks so that applications can provide specific +types of completion before the default filename completion +is attempted. This is quite flexible, though it is not com- +pletely user-programmable. Bash, for example, can complete +filenames, command names (including aliases, builtins, shell +reserved words, shell functions, and executables found in +the file system), shell variables, usernames, and hostnames. +It uses a set of heuristics that, while not perfect, is gen- +erally quite good at determining what type of completion to +attempt. + +_4._4. _H_i_s_t_o_r_y + + Access to the list of commands previously entered (the +_c_o_m_m_a_n_d _h_i_s_t_o_r_y) is provided jointly by Bash and the + + +9 October 28, 1994 + + + + + + - 9 - + + +readline library. Bash provides variables ($HISTFILE, +$HISTSIZE, and $HISTCONTROL) and the _h_i_s_t_o_r_y and _f_c builtins +to manipulate the history list. The value of $_H_I_S_T_F_I_L_E +specifes the file where Bash writes the command history on +exit and reads it on startup. $_H_I_S_T_S_I_Z_E is used to limit +the number of commands saved in the history. $_H_I_S_T_C_O_N_T_R_O_L +provides a crude form of control over which commands are +saved on the history list: a value of _i_g_n_o_r_e_s_p_a_c_e means to +not save commands which begin with a space; a value of +_i_g_n_o_r_e_d_u_p_s means to not save commands identical to the last +command saved. $HISTCONTROL was named $history_control in +earlier versions of Bash; the old name is still accepted for +backwards compatibility. The _h_i_s_t_o_r_y command can read or +write files containing the history list and display the +current list contents. The _f_c builtin, adopted from POSIX.2 +and the Korn Shell, allows display and re-execution, with +optional editing, of commands from the history list. The +readline library offers a set of commands to search the his- +tory list for a portion of the current input line or a +string typed by the user. Finally, the _h_i_s_t_o_r_y library, +generally incorporated directly into the readline library, +implements a facility for history recall, expansion, and +re-execution of previous commands very similar to csh ("bang +history", so called because the exclamation point introduces +a history substitution): +9 $ echo a b c d e + a b c d e + $ !! f g h i + echo a b c d e f g h i + a b c d e f g h i + $ !-2 + echo a b c d e + a b c d e + $ echo !-2:1-4 + echo a b c d + a b c d +9 +The command history is only saved when the shell is interac- +tive, so it is not available for use by shell scripts. + +_4._5. _N_e_w _S_h_e_l_l _V_a_r_i_a_b_l_e_s + + There are a number of convenience variables that Bash +interprets to make life easier. These include _F_I_G_N_O_R_E, +which is a set of filename suffixes identifying files to +exclude when completing filenames; _H_O_S_T_T_Y_P_E, which is +automatically set to a string describing the type of +hardware on which Bash is currently executing; +_c_o_m_m_a_n_d__o_r_i_e_n_t_e_d__h_i_s_t_o_r_y, which directs Bash to save all +lines of a multiple-line command such as a _w_h_i_l_e or _f_o_r loop +in a single history entry, allowing easy re-editing; and +_I_G_N_O_R_E_E_O_F, whose value indicates the number of consecutive +EOF characters that an interactive shell will read before + + + + October 28, 1994 + + + + + + - 10 - + + +exiting - an easy way to keep yourself from being logged out +accidentally. The _a_u_t_o__r_e_s_u_m_e variable alters the way the +shell treats simple command names: if job control is active, +and this variable is set, single-word simple commands +without redirections cause the shell to first look for and +restart a suspended job with that name before starting a new +process. + +_4._6. _B_r_a_c_e _E_x_p_a_n_s_i_o_n + + Since sh offers no convenient way to generate arbitrary +strings that share a common prefix or suffix (filename +expansion requires that the filenames exist), Bash imple- +ments _b_r_a_c_e _e_x_p_a_n_s_i_o_n, a capability picked up from csh. +Brace expansion is similar to filename expansion, but the +strings generated need not correspond to existing files. A +brace expression consists of an optional _p_r_e_a_m_b_l_e, followed +by a pair of braces enclosing a series of comma-separated +strings, and an optional _p_o_s_t_a_m_b_l_e. The preamble is +prepended to each string within the braces, and the postam- +ble is then appended to each resulting string: +9 $ echo a{d,c,b}e + ade ace abe +9 +As this example demonstrates, the results of brace expansion +are not sorted, as they are by filename expansion. + +_4._7. _P_r_o_c_e_s_s _S_u_b_s_t_i_t_u_t_i_o_n + + On systems that can support it, Bash provides a facil- +ity known as _p_r_o_c_e_s_s _s_u_b_s_t_i_t_u_t_i_o_n. Process substitution is +similar to command substitution in that its specification +includes a command to execute, but the shell does not col- +lect the command's output and insert it into the command +line. Rather, Bash opens a pipe to the command, which is +run in the background. The shell uses named pipes (FIFOs) +or the /_d_e_v/_f_d method of naming open files to expand the +process substitution to a filename which connects to the +pipe when opened. This filename becomes the result of the +expansion. Process substitution can be used to compare the +outputs of two different versions of an application as part +of a regression test: +9 $ cmp <(old_prog) <(new_prog) +9 +_4._8. _P_r_o_m_p_t _C_u_s_t_o_m_i_z_a_t_i_o_n + + One of the more popular interactive features that Bash +provides is the ability to customize the prompt. Both $_P_S_1 +and $_P_S_2, the primary and secondary prompts, are expanded +before being displayed. Parameter and variable expansion is +performed when the prompt string is expanded, so any shell +variable can be put into the prompt (e.g., $_S_H_L_V_L, which + + + + October 28, 1994 + + + + + + - 11 - + + +indicates how deeply the current shell is nested). Bash +specially interprets characters in the prompt string pre- +ceded by a backslash. Some of these backslash escapes are +replaced with the current time, the date, the current work- +ing directory, the username, and the command number or his- +tory number of the command being entered. There is even a +backslash escape to cause the shell to change its prompt +when running as root after an _s_u. Before printing each pri- +mary prompt, Bash expands the variable $_P_R_O_M_P_T__C_O_M_M_A_N_D and, +if it has a value, executes the expanded value as a command, +allowing additional prompt customization. For example, this +assignment causes the current user, the current host, the +time, the last component of the current working directory, +the level of shell nesting, and the history number of the +current command to be embedded into the primary prompt: +9 $ PS1='\u@\h [\t] \W($SHLVL:\!)\$ ' + chet@odin [21:03:44] documentation(2:636)$ cd .. + chet@odin [21:03:54] src(2:637)$ +9 +The string being assigned is surrounded by single quotes so +that if it is exported, the value of $_S_H_L_V_L will be updated +by a child shell: +9 chet@odin [21:17:35] src(2:638)$ export PS1 + chet@odin [21:17:40] src(2:639)$ bash + chet@odin [21:17:46] src(3:696)$ +9 +The \$ escape is displayed as "$" when running as a normal +user, but as "#" when running as root. + +_4._9. _F_i_l_e _S_y_s_t_e_m _V_i_e_w_s + + Since Berkeley introduced symbolic links in 4.2 BSD, +one of their most annoying properties has been the "warping" +to a completely different area of the file system when using +_c_d, and the resultant non-intuitive behavior of "cd ..". +The UNIX kernel treats symbolic links _p_h_y_s_i_c_a_l_l_y. When the +kernel is translating a pathname in which one component is a +symbolic link, it replaces all or part of the pathname while +processing the link. If the contents of the symbolic link +begin with a slash, the kernel replaces the pathname +entirely; if not, the link contents replace the current com- +ponent. In either case, the symbolic link is visible. If +the link value is an absolute pathname, the user finds him- +self in a completely different part of the file system. + + Bash provides a _l_o_g_i_c_a_l view of the file system. In +this default mode, command and filename completion and buil- +tin commands such as _c_d and _p_u_s_h_d which change the current +working directory transparently follow symbolic links as if +they were directories. The $_P_W_D variable, which holds the +shell's idea of the current working directory, depends on +the path used to reach the directory rather than its + + + + October 28, 1994 + + + + + + - 12 - + + +physical location in the local file system hierarchy. For +example: +9 $ cd /usr/local/bin + $ echo $PWD + /usr/local/bin + $ pwd + /usr/local/bin + $ /bin/pwd + /net/share/sun4/local/bin + $ cd .. + $ pwd + /usr/local + $ /bin/pwd + /net/share/sun4/local + $ cd .. + $ pwd + /usr + $ /bin/pwd + /usr +9 +One problem with this, of course, arises when programs that +do not understand the shell's logical notion of the file +system interpret ".." differently. This generally happens +when Bash completes filenames containing ".." according to a +logical hierarchy which does not correspond to their physi- +cal location. For users who find this troublesome, a +corresponding _p_h_y_s_i_c_a_l view of the file system is available: +9 $ cd /usr/local/bin + $ pwd + /usr/local/bin + $ set -o physical + $ pwd + /net/share/sun4/local/bin +9 +_4._1_0. _I_n_t_e_r_n_a_t_i_o_n_a_l_i_z_a_t_i_o_n + + One of the most significant improvements in version +1.13 of Bash was the change to "eight-bit cleanliness". +Previous versions used the eighth bit of characters to mark +whether or not they were quoted when performing word expan- +sions. While this did not affect the majority of users, +most of whom used only seven-bit ASCII characters, some +found it confining. Beginning with version 1.13, Bash +implemented a different quoting mechanism that did not alter +the eighth bit of characters. This allowed Bash to manipu- +late files with "odd" characters in their names, but did +nothing to help users enter those names, so version 1.13 +introduced changes to readline that made it eight-bit clean +as well. Options exist that force readline to attach no +special significance to characters with the eighth bit set +(the default behavior is to convert these characters to +meta-prefixed key sequences) and to output these characters + + + + October 28, 1994 + + + + + + - 13 - + + +without conversion to meta-prefixed sequences. These +changes, along with the expansion of keymaps to a full eight +bits, enable readline to work with most of the ISO-8859 fam- +ily of character sets, used by many European countries. + +_4._1_1. _P_O_S_I_X _M_o_d_e + + Although Bash is intended to be POSIX.2 conformant, +there are areas in which the default behavior is not compa- +tible with the standard. For users who wish to operate in a +strict POSIX.2 environment, Bash implements a _P_O_S_I_X _m_o_d_e. +When this mode is active, Bash modifies its default opera- +tion where it differs from POSIX.2 to match the standard. +POSIX mode is entered when Bash is started with the -_p_o_s_i_x +option. This feature is also available as an option to the +set builtin, set -o posix. For compatibility with other GNU +software that attempts to be POSIX.2 compliant, Bash also +enters POSIX mode if the variable $_P_O_S_I_X_L_Y__C_O_R_R_E_C_T is set +when Bash is started or assigned a value during execution. +$_P_O_S_I_X__P_E_D_A_N_T_I_C is accepted as well, to be compatible with +some older GNU utilities. When Bash is started in POSIX +mode, for example, it sources the file named by the value of +$_E_N_V rather than the "normal" startup files, and does not +allow reserved words to be aliased. + +_5. _N_e_w _F_e_a_t_u_r_e_s _a_n_d _F_u_t_u_r_e _P_l_a_n_s + + There are several features introduced in the current +version of Bash, version 1.14, and a number under considera- +tion for future releases. This section will briefly detail +the new features in version 1.14 and describe several +features that may appear in later versions. + +_5._1. _N_e_w _F_e_a_t_u_r_e_s _i_n _B_a_s_h-_1._1_4 + + The new features available in Bash-1.14 answer several +of the most common requests for enhancements. Most notably, +there is a mechanism for including non-visible character +sequences in prompts, such as those which cause a terminal +to print characters in different colors or in standout mode. +There was nothing preventing the use of these sequences in +earlier versions, but the readline redisplay algorithm +assumed each character occupied physical screen space and +would wrap lines prematurely. + + Readline has a few new variables, several new bindable +commands, and some additional emacs mode default key bind- +ings. A new history search mode has been implemented: in +this mode, readline searches the history for lines beginning +with the characters between the beginning of the current +line and the cursor. The existing readline incremental +search commands no longer match identical lines more than +once. Filename completion now expands variables in direc- +tory names. The history expansion facilities are now nearly + + + + October 28, 1994 + + + + + + - 14 - + + +completely csh-compatible: missing modifiers have been added +and history substitution has been extended. + + Several of the features described earlier, such as _s_e_t +-_o _p_o_s_i_x and $_P_O_S_I_X__P_E_D_A_N_T_I_C, are new in version 1.14. +There is a new shell variable, _O_S_T_Y_P_E, to which Bash assigns +a value that identifies the version of UNIX it's running on +(great for putting architecture-specific binary directories +into the $PATH). Two variables have been renamed: $_H_I_S_T_C_O_N_- +_T_R_O_L replaces $_h_i_s_t_o_r_y__c_o_n_t_r_o_l, and $_H_O_S_T_F_I_L_E replaces +$_h_o_s_t_n_a_m_e__c_o_m_p_l_e_t_i_o_n__f_i_l_e. In both cases, the old names are +accepted for backwards compatibility. The ksh _s_e_l_e_c_t con- +struct, which allows the generation of simple menus, has +been implemented. New capabilities have been added to +existing variables: $_a_u_t_o__r_e_s_u_m_e can now take values of +_e_x_a_c_t or _s_u_b_s_t_r_i_n_g, and $_H_I_S_T_C_O_N_T_R_O_L understands the value +_i_g_n_o_r_e_b_o_t_h, which combines the two previously acceptable +values. The _d_i_r_s builtin has acquired options to print out +specific members of the directory stack. The $_n_o_l_i_n_k_s vari- +able, which forces a physical view of the file system, has +been superseded by the -_P option to the _s_e_t builtin +(equivalent to set -o physical); the variable is retained +for backwards compatibility. The version string contained +in $_B_A_S_H__V_E_R_S_I_O_N now includes an indication of the patch +level as well as the "build version". Some little-used +features have been removed: the _b_y_e synonym for _e_x_i_t and +the $_N_O__P_R_O_M_P_T__V_A_R_S variable are gone. There is now an +organized test suite that can be run as a regression test +when building a new version of Bash. + + The documentation has been thoroughly overhauled: there +is a new manual page on the readline library and the _i_n_f_o +file has been updated to reflect the current version. As +always, as many bugs as possible have been fixed, although +some surely remain. + +_5._2. _O_t_h_e_r _F_e_a_t_u_r_e_s + + There are a few features that I hope to include in +later Bash releases. Some are based on work already done in +other shells. + + In addition to simple variables, a future release of +Bash will include one-dimensional arrays, using the ksh +implementation of arrays as a model. Additions to the ksh +syntax, such as _v_a_r_n_a_m_e=( ... ) to assign a list of words +directly to an array and a mechanism to allow the _r_e_a_d buil- +tin to read a list of values directly into an array, would +be desirable. Given those extensions, the ksh _s_e_t -_A syntax +may not be worth supporting (the -_A option assigns a list of +values to an array, but is a rather peculiar special case). + + Some shells include a means of _p_r_o_g_r_a_m_m_a_b_l_e word com- +pletion, where the user specifies on a per-command basis how + + + + October 28, 1994 + + + + + + - 15 - + + +the arguments of the command are to be treated when comple- +tion is attempted: as filenames, hostnames, executable +files, and so on. The other aspects of the current Bash +implementation could remain as-is; the existing heuristics +would still be valid. Only when completing the arguments to +a simple command would the programmable completion be in +effect. + + It would also be nice to give the user finer-grained +control over which commands are saved onto the history list. +One proposal is for a variable, tentatively named _H_I_S_T_I_G_- +_N_O_R_E, which would contain a colon-separated list of com- +mands. Lines beginning with these commands, after the res- +trictions of $_H_I_S_T_C_O_N_T_R_O_L have been applied, would not be +placed onto the history list. The shell pattern-matching +capabilities could also be available when specifying the +contents of $_H_I_S_T_I_G_N_O_R_E. + + One thing that newer shells such as _w_k_s_h (also known as +_d_t_k_s_h) provide is a command to dynamically load code imple- +menting additional builtin commands into a running shell. +This new builtin would take an object file or shared library +implementing the "body" of the builtin (_x_x_x__b_u_i_l_t_i_n() for +those familiar with Bash internals) and a structure contain- +ing the name of the new command, the function to call when +the new builtin is invoked (presumably defined in the shared +object specified as an argument), and the documentation to +be printed by the _h_e_l_p command (possibly present in the +shared object as well). It would manage the details of +extending the internal table of builtins. + + A few other builtins would also be desirable: two are +the POSIX.2 _g_e_t_c_o_n_f command, which prints the values of sys- +tem configuration variables defined by POSIX.2, and a _d_i_s_o_w_n +builtin, which causes a shell running with job control +active to "forget about" one or more background jobs in its +internal jobs table. Using _g_e_t_c_o_n_f, for example, a user +could retrieve a value for $_P_A_T_H guaranteed to find all of +the POSIX standard utilities, or find out how long filenames +may be in the file system containing a specified directory. + + There are no implementation timetables for any of these +features, nor are there concrete plans to include them. If +anyone has comments on these proposals, feel free to send me +electronic mail. + +_6. _R_e_f_l_e_c_t_i_o_n_s _a_n_d _L_e_s_s_o_n_s _L_e_a_r_n_e_d + + The lesson that has been repeated most often during +Bash development is that there are dark corners in the +Bourne shell, and people use all of them. In the original +description of the Bourne shell, quoting and the shell gram- +mar are both poorly specified and incomplete; subsequent +descriptions have not helped much. The grammar presented in + + + + October 28, 1994 + + + + + + - 16 - + + +Bourne's paper describing the shell distributed with the +Seventh Edition of UNIX|- is so far off that it does not +allow the command who|wc. In fact, as Tom Duff states: + + Nobody really knows what the Bourne shell's gram- + mar is. Even examination of the source code is + little help.|= + +The POSIX.2 standard includes a _y_a_c_c grammar that comes +close to capturing the Bourne shell's behavior, but it +disallows some constructs which sh accepts without complaint +- and there are scripts out there that use them. It took a +few versions and several bug reports before Bash implemented +sh-compatible quoting, and there are still some "legal" sh +constructs which Bash flags as syntax errors. Complete sh +compatibility is a tough nut. + + The shell is bigger and slower than I would like, +though the current version is substantially faster than pre- +viously. The readline library could stand a substantial +rewrite. A hand-written parser to replace the current +_y_a_c_c-generated one would probably result in a speedup, and +would solve one glaring problem: the shell could parse com- +mands in "$(...)" constructs as they are entered, rather +than reporting errors when the construct is expanded. + + As always, there is some chaff to go with the wheat. +Areas of duplicated functionality need to be cleaned up. +There are several cases where Bash treats a variable spe- +cially to enable functionality available another way +($notify vs. set -o notify and $nolinks vs. set -o physi- +cal, for instance); the special treatment of the variable +name should probably be removed. A few more things could +stand removal; the $_a_l_l_o_w__n_u_l_l__g_l_o_b__e_x_p_a_n_s_i_o_n and +$_g_l_o_b__d_o_t__f_i_l_e_n_a_m_e_s variables are of particularly question- +able value. The $[...] arithmetic evaluation syntax is +redundant now that the POSIX-mandated $((...)) construct has +been implemented, and could be deleted. It would be nice if +the text output by the _h_e_l_p builtin were external to the +shell rather than compiled into it. The behavior enabled by +$_c_o_m_m_a_n_d__o_r_i_e_n_t_e_d__h_i_s_t_o_r_y, which causes the shell to attempt +to save all lines of a multi-line command in a single his- +tory entry, should be made the default and the variable +removed. + + +_________________________ +|-S. R. Bourne, "UNIX Time-Sharing System: The UNIX +Shell", _B_e_l_l _S_y_s_t_e_m _T_e_c_h_n_i_c_a_l _J_o_u_r_n_a_l, 57(6), July- +August, 1978, pp. 1971-1990. +|=Tom Duff, "Rc - A Shell for Plan 9 and UNIX systems", +_P_r_o_c. _o_f _t_h_e _S_u_m_m_e_r _1_9_9_0 _E_U_U_G _C_o_n_f_e_r_e_n_c_e, London, July, +1990, pp. 21-33. + + + + + October 28, 1994 + + + + + + - 17 - + + +_7. _A_v_a_i_l_a_b_i_l_i_t_y + + As with all other GNU software, Bash is available for +anonymous FTP from _p_r_e_p._a_i._m_i_t._e_d_u:/_p_u_b/_g_n_u and from other +GNU software mirror sites. The current version is in _b_a_s_h- +_1._1_4._1._t_a_r._g_z in that directory. Use _a_r_c_h_i_e to find the +nearest archive site. The latest version is always avail- +able for FTP from _b_a_s_h._C_W_R_U._E_d_u:/_p_u_b/_d_i_s_t. Bash documenta- +tion is available for FTP from _b_a_s_h._C_W_R_U._E_d_u:/_p_u_b/_b_a_s_h. + + The Free Software Foundation sells tapes and CD-ROMs +containing Bash; send electronic mail to gnu@prep.ai.mit.edu +or call +1-617-876-3296 for more information. + + Bash is also distributed with several versions of +UNIX-compatible systems. It is included as /bin/sh and +/bin/bash on several Linux distributions (more about the +difference in a moment), and as contributed software in +BSDI's BSD/386* and FreeBSD. + + The Linux distribution deserves special mention. There +are two configurations included in the standard Bash distri- +bution: a "normal" configuration, in which all of the stan- +dard features are included, and a "minimal" configuration, +which omits job control, aliases, history and command line +editing, the directory stack and _p_u_s_h_d/_p_o_p_d/_d_i_r_s, process +substitution, prompt string special character decoding, and +the _s_e_l_e_c_t construct. This minimal version is designed to +be a drop-in replacement for the traditional UNIX /bin/sh, +and is included as the Linux /bin/sh in several packagings. + +_8. _C_o_n_c_l_u_s_i_o_n + + Bash is a worthy successor to sh. It is sufficiently +portable to run on nearly every version of UNIX from 4.3 BSD +to SVR4.2, and several UNIX workalikes. It is robust enough +to replace sh on most of those systems, and provides more +functionality. It has several thousand regular users, and +their feedback has helped to make it as good as it is today +- a testament to the benefits of free software. + + + + + + + + + + +_________________________ +*BSD/386 is a trademark of Berkeley Software Design, +Inc. + + + + + October 28, 1994 + + diff --git a/doc/bash.0 b/doc/bash.0 new file mode 100644 index 0000000..031be8a --- /dev/null +++ b/doc/bash.0 @@ -0,0 +1,5938 @@ +BASH(1) General Commands Manual BASH(1) + + + +NNAAMMEE + bash - GNU Bourne-Again SHell + +SSYYNNOOPPSSIISS + bbaasshh [options] [command_string | file] + +CCOOPPYYRRIIGGHHTT + Bash is Copyright (C) 1989-2016 by the Free Software Foundation, Inc. + +DDEESSCCRRIIPPTTIIOONN + BBaasshh is an sshh-compatible command language interpreter that executes + commands read from the standard input or from a file. BBaasshh also incor- + porates useful features from the _K_o_r_n and _C shells (kksshh and ccsshh). + + BBaasshh is intended to be a conformant implementation of the Shell and + Utilities portion of the IEEE POSIX specification (IEEE Standard + 1003.1). BBaasshh can be configured to be POSIX-conformant by default. + +OOPPTTIIOONNSS + All of the single-character shell options documented in the description + of the sseett builtin command can be used as options when the shell is + invoked. In addition, bbaasshh interprets the following options when it is + invoked: + + --cc If the --cc option is present, then commands are read from the + first non-option argument _c_o_m_m_a_n_d___s_t_r_i_n_g. If there are argu- + ments after the _c_o_m_m_a_n_d___s_t_r_i_n_g, the first argument is + assigned to $$00 and any remaining arguments are assigned to + the positional parameters. The assignment to $$00 sets the + name of the shell, which is used in warning and error mes- + sages. + --ii If the --ii option is present, the shell is _i_n_t_e_r_a_c_t_i_v_e. + --ll Make bbaasshh act as if it had been invoked as a login shell (see + IINNVVOOCCAATTIIOONN below). + --rr If the --rr option is present, the shell becomes _r_e_s_t_r_i_c_t_e_d + (see RREESSTTRRIICCTTEEDD SSHHEELLLL below). + --ss If the --ss 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. + --DD A list of all double-quoted strings preceded by $$ is printed + on the standard output. These are the strings that are sub- + ject to language translation when the current locale is not CC + or PPOOSSIIXX. This implies the --nn option; no commands will be + executed. + [[--++]]OO [[_s_h_o_p_t___o_p_t_i_o_n]] + _s_h_o_p_t___o_p_t_i_o_n is one of the shell options accepted by the + sshhoopptt builtin (see SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS below). If + _s_h_o_p_t___o_p_t_i_o_n is present, --OO sets the value of that option; ++OO + unsets it. If _s_h_o_p_t___o_p_t_i_o_n is not supplied, the names and + values of the shell options accepted by sshhoopptt are printed on + the standard output. If the invocation option is ++OO, the + output is displayed in a format that may be reused as input. + ---- A ---- signals the end of options and disables further option + processing. Any arguments after the ---- are treated as file- + names and arguments. An argument of -- is equivalent to ----. + + BBaasshh also interprets a number of multi-character options. These + options must appear on the command line before the single-character + options to be recognized. + + ----ddeebbuuggggeerr + Arrange for the debugger profile to be executed before the shell + starts. Turns on extended debugging mode (see the description + of the eexxttddeebbuugg option to the sshhoopptt builtin below). + ----dduummpp--ppoo--ssttrriinnggss + Equivalent to --DD, but the output is in the GNU _g_e_t_t_e_x_t ppoo (por- + table object) file format. + ----dduummpp--ssttrriinnggss + Equivalent to --DD. + ----hheellpp Display a usage message on standard output and exit success- + fully. + ----iinniitt--ffiillee _f_i_l_e + ----rrccffiillee _f_i_l_e + Execute commands from _f_i_l_e instead of the standard personal ini- + tialization file _~_/_._b_a_s_h_r_c if the shell is interactive (see + IINNVVOOCCAATTIIOONN below). + + ----llooggiinn + Equivalent to --ll. + + ----nnooeeddiittiinngg + Do not use the GNU rreeaaddlliinnee library to read command lines when + the shell is interactive. + + ----nnoopprrooffiillee + Do not read either the system-wide startup file _/_e_t_c_/_p_r_o_f_i_l_e or + any of the personal initialization files _~_/_._b_a_s_h___p_r_o_f_i_l_e, + _~_/_._b_a_s_h___l_o_g_i_n, or _~_/_._p_r_o_f_i_l_e. By default, bbaasshh reads these + files when it is invoked as a login shell (see IINNVVOOCCAATTIIOONN + below). + + ----nnoorrcc Do not read and execute the personal initialization file + _~_/_._b_a_s_h_r_c if the shell is interactive. This option is on by + default if the shell is invoked as sshh. + + ----ppoossiixx + Change the behavior of bbaasshh where the default operation differs + from the POSIX standard to match the standard (_p_o_s_i_x _m_o_d_e). See + SSEEEE AALLSSOO below for a reference to a document that details how + posix mode affects bash's behavior. + + ----rreessttrriicctteedd + The shell becomes restricted (see RREESSTTRRIICCTTEEDD SSHHEELLLL below). + + ----vveerrbboossee + Equivalent to --vv. + + ----vveerrssiioonn + Show version information for this instance of bbaasshh on the stan- + dard output and exit successfully. + +AARRGGUUMMEENNTTSS + If arguments remain after option processing, and neither the --cc nor the + --ss option has been supplied, the first argument is assumed to be the + name of a file containing shell commands. If bbaasshh is invoked in this + fashion, $$00 is set to the name of the file, and the positional parame- + ters are set to the remaining arguments. BBaasshh reads and executes com- + mands from this file, then exits. BBaasshh's exit status is the exit sta- + tus of the last command executed in the script. If no commands are + executed, the exit status is 0. An attempt is first made to open the + file in the current directory, and, if no file is found, then the shell + searches the directories in PPAATTHH for the script. + +IINNVVOOCCAATTIIOONN + A _l_o_g_i_n _s_h_e_l_l is one whose first character of argument zero is a --, or + one started with the ----llooggiinn option. + + An _i_n_t_e_r_a_c_t_i_v_e shell is one started without non-option arguments + (unless --ss is specified) and without the --cc option whose standard input + and error are both connected to terminals (as determined by _i_s_a_t_t_y(3)), + or one started with the --ii option. PPSS11 is set and $$-- includes ii if + bbaasshh is interactive, allowing a shell script or a startup file to test + this state. + + The following paragraphs describe how bbaasshh executes its startup files. + If any of the files exist but cannot be read, bbaasshh reports an error. + Tildes are expanded in filenames as described below under TTiillddee EExxppaann-- + ssiioonn in the EEXXPPAANNSSIIOONN section. + + When bbaasshh is invoked as an interactive login shell, or as a non-inter- + active shell with the ----llooggiinn option, it first reads and executes com- + mands from the file _/_e_t_c_/_p_r_o_f_i_l_e, if that file exists. After reading + that file, it looks for _~_/_._b_a_s_h___p_r_o_f_i_l_e, _~_/_._b_a_s_h___l_o_g_i_n, and _~_/_._p_r_o_f_i_l_e, + in that order, and reads and executes commands from the first one that + exists and is readable. The ----nnoopprrooffiillee option may be used when the + shell is started to inhibit this behavior. + + When an interactive login shell exits, or a non-interactive login shell + executes the eexxiitt builtin command, bbaasshh reads and executes commands + from the file _~_/_._b_a_s_h___l_o_g_o_u_t, if it exists. + + When an interactive shell that is not a login shell is started, bbaasshh + reads and executes commands from _~_/_._b_a_s_h_r_c, if that file exists. This + may be inhibited by using the ----nnoorrcc option. The ----rrccffiillee _f_i_l_e option + will force bbaasshh to read and execute commands from _f_i_l_e instead of + _~_/_._b_a_s_h_r_c. + + When bbaasshh is started non-interactively, to run a shell script, for + example, it looks for the variable BBAASSHH__EENNVV 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. BBaasshh behaves as if the following com- + mand were executed: + if [ -n "$BASH_ENV" ]; then . "$BASH_ENV"; fi + but the value of the PPAATTHH variable is not used to search for the file- + name. + + If bbaasshh is invoked with the name sshh, it tries to mimic the startup + behavior of historical versions of sshh as closely as possible, while + conforming to the POSIX standard as well. When invoked as an interac- + tive login shell, or a non-interactive shell with the ----llooggiinn option, + it first attempts to read and execute commands from _/_e_t_c_/_p_r_o_f_i_l_e and + _~_/_._p_r_o_f_i_l_e, in that order. The ----nnoopprrooffiillee option may be used to + inhibit this behavior. When invoked as an interactive shell with the + name sshh, bbaasshh looks for the variable EENNVV, 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 sshh does not attempt to read and exe- + cute commands from any other startup files, the ----rrccffiillee option has no + effect. A non-interactive shell invoked with the name sshh does not + attempt to read any other startup files. When invoked as sshh, bbaasshh + enters _p_o_s_i_x mode after the startup files are read. + + When bbaasshh is started in _p_o_s_i_x mode, as with the ----ppoossiixx command line + option, it follows the POSIX standard for startup files. In this mode, + interactive shells expand the EENNVV variable and commands are read and + executed from the file whose name is the expanded value. No other + startup files are read. + + BBaasshh attempts to determine when it is being run with its standard input + connected to a network connection, as when executed by the remote shell + daemon, usually _r_s_h_d, or the secure shell daemon _s_s_h_d. If bbaasshh deter- + mines it is being run in this fashion, it reads and executes commands + from _~_/_._b_a_s_h_r_c, if that file exists and is readable. It will not do + this if invoked as sshh. The ----nnoorrcc option may be used to inhibit this + behavior, and the ----rrccffiillee option may be used to force another file to + be read, but neither _r_s_h_d nor _s_s_h_d generally invoke the shell with + those options or allow them to be specified. + + If the shell is started with the effective user (group) id not equal to + the real user (group) id, and the --pp option is not supplied, no startup + files are read, shell functions are not inherited from the environment, + the SSHHEELLLLOOPPTTSS, BBAASSHHOOPPTTSS, CCDDPPAATTHH, and GGLLOOBBIIGGNNOORREE variables, if they + appear in the environment, are ignored, and the effective user id is + set to the real user id. If the --pp option is supplied at invocation, + the startup behavior is the same, but the effective user id is not + reset. + +DDEEFFIINNIITTIIOONNSS + The following definitions are used throughout the rest of this docu- + ment. + bbllaannkk A space or tab. + wwoorrdd A sequence of characters considered as a single unit by the + shell. Also known as a ttookkeenn. + nnaammee A _w_o_r_d consisting only of alphanumeric characters and under- + scores, and beginning with an alphabetic character or an under- + score. Also referred to as an iiddeennttiiffiieerr. + mmeettaacchhaarraacctteerr + A character that, when unquoted, separates words. One of the + following: + || && ;; (( )) << >> ssppaaccee ttaabb nneewwlliinnee + ccoonnttrrooll ooppeerraattoorr + A _t_o_k_e_n that performs a control function. It is one of the fol- + lowing symbols: + |||| && &&&& ;; ;;;; ;;&& ;;;;&& (( )) || ||&& <> + +RREESSEERRVVEEDD WWOORRDDSS + _R_e_s_e_r_v_e_d _w_o_r_d_s are words that have a special meaning to the shell. The + following words are recognized as reserved when unquoted and either the + first word of a simple command (see SSHHEELLLL GGRRAAMMMMAARR below) or the third + word of a ccaassee or ffoorr command: + + !! ccaassee ccoopprroocc ddoo ddoonnee eelliiff eellssee eessaacc ffii ffoorr ffuunnccttiioonn iiff iinn sseelleecctt + tthheenn uunnttiill wwhhiillee {{ }} ttiimmee [[[[ ]]]] + +SSHHEELLLL GGRRAAMMMMAARR + SSiimmppllee CCoommmmaannddss + A _s_i_m_p_l_e _c_o_m_m_a_n_d is a sequence of optional variable assignments fol- + lowed by bbllaannkk-separated words and redirections, and terminated by a + _c_o_n_t_r_o_l _o_p_e_r_a_t_o_r. The first word specifies the command to be executed, + and is passed as argument zero. The remaining words are passed as + arguments to the invoked command. + + The return value of a _s_i_m_p_l_e _c_o_m_m_a_n_d is its exit status, or 128+_n if + the command is terminated by signal _n. + + PPiippeelliinneess + A _p_i_p_e_l_i_n_e is a sequence of one or more commands separated by one of + the control operators || or ||&&. The format for a pipeline is: + + [ttiimmee [--pp]] [ ! ] _c_o_m_m_a_n_d [ [|||||&&] _c_o_m_m_a_n_d_2 ... ] + + The standard output of _c_o_m_m_a_n_d is connected via a pipe to the standard + input of _c_o_m_m_a_n_d_2. This connection is performed before any redirec- + tions specified by the command (see RREEDDIIRREECCTTIIOONN below). If ||&& is used, + _c_o_m_m_a_n_d's standard error, in addition to its standard output, is con- + nected to _c_o_m_m_a_n_d_2's standard input through the pipe; it is shorthand + for 22>>&&11 ||. This implicit redirection of the standard error to the + standard output is performed after any redirections specified by the + command. + + The return status of a pipeline is the exit status of the last command, + unless the ppiippeeffaaiill option is enabled. If ppiippeeffaaiill 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 success- + fully. If the reserved word !! precedes a pipeline, the exit status of + that pipeline 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. + + If the ttiimmee reserved word precedes a pipeline, the elapsed as well as + user and system time consumed by its execution are reported when the + pipeline terminates. The --pp option changes the output format to that + specified by POSIX. When the shell is in _p_o_s_i_x _m_o_d_e, it does not rec- + ognize ttiimmee as a reserved word if the next token begins with a `-'. + The TTIIMMEEFFOORRMMAATT variable may be set to a format string that specifies + how the timing information should be displayed; see the description of + TTIIMMEEFFOORRMMAATT under SShheellll VVaarriiaabblleess below. + + When the shell is in _p_o_s_i_x _m_o_d_e, ttiimmee may be followed by a newline. In + this case, the shell displays the total user and system time consumed + by the shell and its children. The TTIIMMEEFFOORRMMAATT variable may be used to + specify the format of the time information. + + Each command in a pipeline is executed as a separate process (i.e., in + a subshell). + + LLiissttss + A _l_i_s_t is a sequence of one or more pipelines separated by one of the + operators ;;, &&, &&&&, or ||||, and optionally terminated by one of ;;, &&, or + <>. + + Of these list operators, &&&& and |||| have equal precedence, followed by ;; + and &&, which have equal precedence. + + A sequence of one or more newlines may appear in a _l_i_s_t instead of a + semicolon to delimit commands. + + If a command is terminated by the control operator &&, the shell exe- + cutes the command in the _b_a_c_k_g_r_o_u_n_d in a subshell. The shell does not + wait for the command to finish, and the return status is 0. Commands + separated by a ;; 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. + + AND and OR lists are sequences of one or more pipelines separated by + the &&&& and |||| control operators, respectively. AND and OR lists are + executed with left associativity. An AND list has the form + + _c_o_m_m_a_n_d_1 &&&& _c_o_m_m_a_n_d_2 + + _c_o_m_m_a_n_d_2 is executed if, and only if, _c_o_m_m_a_n_d_1 returns an exit status + of zero. + + An OR list has the form + + _c_o_m_m_a_n_d_1 |||| _c_o_m_m_a_n_d_2 + + _c_o_m_m_a_n_d_2 is executed if and only if _c_o_m_m_a_n_d_1 returns a non-zero exit + status. The return status of AND and OR lists is the exit status of + the last command executed in the list. + + CCoommppoouunndd CCoommmmaannddss + A _c_o_m_p_o_u_n_d _c_o_m_m_a_n_d is one of the following. In most cases a _l_i_s_t in a + command's description may be separated from the rest of the command by + one or more newlines, and may be followed by a newline in place of a + semicolon. + + (_l_i_s_t) _l_i_s_t is executed in a subshell environment (see CCOOMMMMAANNDD EEXXEECCUU-- + TTIIOONN EENNVVIIRROONNMMEENNTT below). Variable assignments and builtin com- + mands that affect the shell's environment do not remain in + effect after the command completes. The return status is the + exit status of _l_i_s_t. + + { _l_i_s_t; } + _l_i_s_t is simply executed in the current shell environment. _l_i_s_t + must be terminated with a newline or semicolon. This is known + as a _g_r_o_u_p _c_o_m_m_a_n_d. The return status is the exit status of + _l_i_s_t. Note that unlike the metacharacters (( and )), {{ and }} are + _r_e_s_e_r_v_e_d _w_o_r_d_s and must occur where a reserved word is permitted + to be recognized. Since they do not cause a word break, they + must be separated from _l_i_s_t by whitespace or another shell + metacharacter. + + ((_e_x_p_r_e_s_s_i_o_n)) + The _e_x_p_r_e_s_s_i_o_n is evaluated according to the rules described + below under AARRIITTHHMMEETTIICC EEVVAALLUUAATTIIOONN. If the value of the expres- + sion is non-zero, the return status is 0; otherwise the return + status is 1. This is exactly equivalent to lleett ""_e_x_p_r_e_s_s_i_o_n"". + + [[[[ _e_x_p_r_e_s_s_i_o_n ]]]] + Return a status of 0 or 1 depending on the evaluation of the + conditional expression _e_x_p_r_e_s_s_i_o_n. Expressions are composed of + the primaries described below under CCOONNDDIITTIIOONNAALL EEXXPPRREESSSSIIOONNSS. + Word splitting and pathname expansion are not performed on the + words between the [[[[ and ]]]]; tilde expansion, parameter and + variable expansion, arithmetic expansion, command substitution, + process substitution, and quote removal are performed. Condi- + tional operators such as --ff must be unquoted to be recognized as + primaries. + + When used with [[[[, the << and >> operators sort lexicographically + using the current locale. + + When the ==== and !!== operators are used, the string to the right + of the operator is considered a pattern and matched according to + the rules described below under PPaatttteerrnn MMaattcchhiinngg, as if the eexxtt-- + gglloobb shell option were enabled. The == operator is equivalent to + ====. If the nnooccaasseemmaattcchh shell option is enabled, the match is + performed without regard to the case of alphabetic characters. + The return value is 0 if the string matches (====) or does not + match (!!==) the pattern, and 1 otherwise. Any part of the pat- + tern may be quoted to force the quoted portion to be matched as + a string. + + An additional binary operator, ==~~, is available, with the same + precedence as ==== and !!==. When it is used, the string to the + right of the operator is considered an extended regular expres- + sion and matched accordingly (as in _r_e_g_e_x(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 nnooccaasseemmaattcchh shell option + is enabled, the match is performed without regard to the case of + alphabetic characters. Any part of the pattern may be quoted to + force the quoted portion to be matched as a string. Bracket + expressions in regular expressions must be treated carefully, + since normal quoting characters lose their meanings between + brackets. If the pattern is stored in a shell variable, quoting + the variable expansion forces the entire pattern to be matched + as a string. Substrings matched by parenthesized subexpressions + within the regular expression are saved in the array variable + BBAASSHH__RREEMMAATTCCHH. The element of BBAASSHH__RREEMMAATTCCHH with index 0 is the + portion of the string matching the entire regular expression. + The element of BBAASSHH__RREEMMAATTCCHH with index _n is the portion of the + string matching the _nth parenthesized subexpression. + + Expressions may be combined using the following operators, + listed in decreasing order of precedence: + + (( _e_x_p_r_e_s_s_i_o_n )) + Returns the value of _e_x_p_r_e_s_s_i_o_n. This may be used to + override the normal precedence of operators. + !! _e_x_p_r_e_s_s_i_o_n + True if _e_x_p_r_e_s_s_i_o_n is false. + _e_x_p_r_e_s_s_i_o_n_1 &&&& _e_x_p_r_e_s_s_i_o_n_2 + True if both _e_x_p_r_e_s_s_i_o_n_1 and _e_x_p_r_e_s_s_i_o_n_2 are true. + _e_x_p_r_e_s_s_i_o_n_1 |||| _e_x_p_r_e_s_s_i_o_n_2 + True if either _e_x_p_r_e_s_s_i_o_n_1 or _e_x_p_r_e_s_s_i_o_n_2 is true. + + The &&&& and |||| operators do not evaluate _e_x_p_r_e_s_s_i_o_n_2 if the value + of _e_x_p_r_e_s_s_i_o_n_1 is sufficient to determine the return value of + the entire conditional expression. + + ffoorr _n_a_m_e [ [ iinn [ _w_o_r_d _._._. ] ] ; ] ddoo _l_i_s_t ; ddoonnee + The list of words following iinn is expanded, generating a list of + items. The variable _n_a_m_e is set to each element of this list in + turn, and _l_i_s_t is executed each time. If the iinn _w_o_r_d is omit- + ted, the ffoorr command executes _l_i_s_t once for each positional + parameter that is set (see PPAARRAAMMEETTEERRSS below). The return status + is the exit status of the last command that executes. If the + expansion of the items following iinn results in an empty list, no + commands are executed, and the return status is 0. + + ffoorr (( _e_x_p_r_1 ; _e_x_p_r_2 ; _e_x_p_r_3 )) ; ddoo _l_i_s_t ; ddoonnee + First, the arithmetic expression _e_x_p_r_1 is evaluated according to + the rules described below under AARRIITTHHMMEETTIICC EEVVAALLUUAATTIIOONN. The + arithmetic expression _e_x_p_r_2 is then evaluated repeatedly until + it evaluates to zero. Each time _e_x_p_r_2 evaluates to a non-zero + value, _l_i_s_t is executed and the arithmetic expression _e_x_p_r_3 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 _l_i_s_t that is executed, or false if any of the expres- + sions is invalid. + + sseelleecctt _n_a_m_e [ iinn _w_o_r_d ] ; ddoo _l_i_s_t ; ddoonnee + The list of words following iinn is expanded, generating a list of + items. The set of expanded words is printed on the standard + error, each preceded by a number. If the iinn _w_o_r_d is omitted, + the positional parameters are printed (see PPAARRAAMMEETTEERRSS below). + The PPSS33 prompt is then displayed and a line read from the stan- + dard input. If the line consists of a number corresponding to + one of the displayed words, then the value of _n_a_m_e is set to + that word. If the line is empty, the words and prompt are dis- + played again. If EOF is read, the command completes. Any other + value read causes _n_a_m_e to be set to null. The line read is + saved in the variable RREEPPLLYY. The _l_i_s_t is executed after each + selection until a bbrreeaakk command is executed. The exit status of + sseelleecctt is the exit status of the last command executed in _l_i_s_t, + or zero if no commands were executed. + + ccaassee _w_o_r_d iinn [ [(] _p_a_t_t_e_r_n [ || _p_a_t_t_e_r_n ] ... ) _l_i_s_t ;; ] ... eessaacc + A ccaassee command first expands _w_o_r_d, and tries to match it against + each _p_a_t_t_e_r_n in turn, using the same matching rules as for path- + name expansion (see PPaatthhnnaammee EExxppaannssiioonn below). The _w_o_r_d is + expanded using tilde expansion, parameter and variable expan- + sion, arithmetic expansion, command substitution, process sub- + stitution and quote removal. Each _p_a_t_t_e_r_n examined is expanded + using tilde expansion, parameter and variable expansion, arith- + metic expansion, command substitution, and process substitution. + If the nnooccaasseemmaattcchh shell option is enabled, the match is per- + formed without regard to the case of alphabetic characters. + When a match is found, the corresponding _l_i_s_t is executed. If + the ;;;; operator is used, no subsequent matches are attempted + after the first pattern match. Using ;;&& in place of ;;;; causes + execution to continue with the _l_i_s_t associated with the next set + of patterns. Using ;;;;&& in place of ;;;; causes the shell to test + the next pattern list in the statement, if any, and execute any + associated _l_i_s_t on a successful match. The exit status is zero + if no pattern matches. Otherwise, it is the exit status of the + last command executed in _l_i_s_t. + + iiff _l_i_s_t; tthheenn _l_i_s_t; [ eelliiff _l_i_s_t; tthheenn _l_i_s_t; ] ... [ eellssee _l_i_s_t; ] ffii + The iiff _l_i_s_t is executed. If its exit status is zero, the tthheenn + _l_i_s_t is executed. Otherwise, each eelliiff _l_i_s_t is executed in + turn, and if its exit status is zero, the corresponding tthheenn + _l_i_s_t is executed and the command completes. Otherwise, the eellssee + _l_i_s_t is executed, if present. The exit status is the exit sta- + tus of the last command executed, or zero if no condition tested + true. + + wwhhiillee _l_i_s_t_-_1; ddoo _l_i_s_t_-_2; ddoonnee + uunnttiill _l_i_s_t_-_1; ddoo _l_i_s_t_-_2; ddoonnee + The wwhhiillee command continuously executes the list _l_i_s_t_-_2 as long + as the last command in the list _l_i_s_t_-_1 returns an exit status of + zero. The uunnttiill command is identical to the wwhhiillee command, + except that the test is negated: _l_i_s_t_-_2 is executed as long as + the last command in _l_i_s_t_-_1 returns a non-zero exit status. The + exit status of the wwhhiillee and uunnttiill commands is the exit status + of the last command executed in _l_i_s_t_-_2, or zero if none was exe- + cuted. + + CCoopprroocceesssseess + A _c_o_p_r_o_c_e_s_s is a shell command preceded by the ccoopprroocc reserved word. A + coprocess is executed asynchronously in a subshell, as if the command + had been terminated with the && control operator, with a two-way pipe + established between the executing shell and the coprocess. + + The format for a coprocess is: + + ccoopprroocc [_N_A_M_E] _c_o_m_m_a_n_d [_r_e_d_i_r_e_c_t_i_o_n_s] + + This creates a coprocess named _N_A_M_E. If _N_A_M_E is not supplied, the + default name is CCOOPPRROOCC. _N_A_M_E must not be supplied if _c_o_m_m_a_n_d is a _s_i_m_- + _p_l_e _c_o_m_m_a_n_d (see above); otherwise, it is interpreted as the first word + of the simple command. When the coprocess is executed, the shell cre- + ates an array variable (see AArrrraayyss below) named _N_A_M_E in the context of + the executing shell. The standard output of _c_o_m_m_a_n_d is connected via a + pipe to a file descriptor in the executing shell, and that file + descriptor is assigned to _N_A_M_E[0]. The standard input of _c_o_m_m_a_n_d is + connected via a pipe to a file descriptor in the executing shell, and + that file descriptor is assigned to _N_A_M_E[1]. This pipe is established + before any redirections specified by the command (see RREEDDIIRREECCTTIIOONN + below). The file descriptors can be utilized as arguments to shell + commands and redirections using standard word expansions. The file + descriptors are not available in subshells. The process ID of the + shell spawned to execute the coprocess is available as the value of the + variable _N_A_M_E_PID. The wwaaiitt builtin command may be used to wait for + the coprocess to terminate. + + Since the coprocess is created as an asynchronous command, the ccoopprroocc + command always returns success. The return status of a coprocess is + the exit status of _c_o_m_m_a_n_d. + + SShheellll FFuunnccttiioonn DDeeffiinniittiioonnss + A shell function is an object that is called like a simple command and + executes a compound command with a new set of positional parameters. + Shell functions are declared as follows: + + _n_a_m_e () _c_o_m_p_o_u_n_d_-_c_o_m_m_a_n_d [_r_e_d_i_r_e_c_t_i_o_n] + ffuunnccttiioonn _n_a_m_e [()] _c_o_m_p_o_u_n_d_-_c_o_m_m_a_n_d [_r_e_d_i_r_e_c_t_i_o_n] + This defines a function named _n_a_m_e. The reserved word ffuunnccttiioonn + is optional. If the ffuunnccttiioonn reserved word is supplied, the + parentheses are optional. The _b_o_d_y of the function is the com- + pound command _c_o_m_p_o_u_n_d_-_c_o_m_m_a_n_d (see CCoommppoouunndd CCoommmmaannddss above). + That command is usually a _l_i_s_t of commands between { and }, but + may be any command listed under CCoommppoouunndd CCoommmmaannddss above, with + one exception: If the ffuunnccttiioonn reserved word is used, but the + parentheses are not supplied, the braces are required. _c_o_m_- + _p_o_u_n_d_-_c_o_m_m_a_n_d is executed whenever _n_a_m_e is specified as the name + of a simple command. When in _p_o_s_i_x _m_o_d_e, _n_a_m_e may not be the + name of one of the POSIX _s_p_e_c_i_a_l _b_u_i_l_t_i_n_s. Any redirections + (see RREEDDIIRREECCTTIIOONN below) specified when a function is defined are + performed when the function is executed. 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 exe- + cuted, the exit status of a function is the exit status of the + last command executed in the body. (See FFUUNNCCTTIIOONNSS below.) + +CCOOMMMMEENNTTSS + In a non-interactive shell, or an interactive shell in which the iinntteerr-- + aaccttiivvee__ccoommmmeennttss option to the sshhoopptt builtin is enabled (see SSHHEELLLL + BBUUIILLTTIINN CCOOMMMMAANNDDSS below), a word beginning with ## causes that word and + all remaining characters on that line to be ignored. An interactive + shell without the iinntteerraaccttiivvee__ccoommmmeennttss option enabled does not allow + comments. The iinntteerraaccttiivvee__ccoommmmeennttss option is on by default in interac- + tive shells. + +QQUUOOTTIINNGG + _Q_u_o_t_i_n_g 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 _m_e_t_a_c_h_a_r_a_c_t_e_r_s listed above under DDEEFFIINNIITTIIOONNSS 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 (see HHIISS-- + TTOORRYY EEXXPPAANNSSIIOONN below), the _h_i_s_t_o_r_y _e_x_p_a_n_s_i_o_n character, usually !!, must + be quoted to prevent history expansion. + + There are three quoting mechanisms: the _e_s_c_a_p_e _c_h_a_r_a_c_t_e_r, single + quotes, and double quotes. + + A non-quoted backslash (\\) is the _e_s_c_a_p_e _c_h_a_r_a_c_t_e_r. It preserves the + literal value of the next character that follows, with the exception of + . If a \\ pair appears, and the backslash is not + itself quoted, the \\ is treated as a line continuation (that + is, it is removed from the input stream and effectively ignored). + + Enclosing characters in single quotes 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. + + Enclosing characters in double quotes preserves the literal value of + all characters within the quotes, with the exception of $$, ``, \\, and, + when history expansion is enabled, !!. When the shell is in _p_o_s_i_x _m_o_d_e, + the !! has no special meaning within double quotes, even when history + expansion is enabled. The characters $$ and `` retain their special + meaning within double quotes. The backslash retains its special mean- + ing only when followed by one of the following characters: $$, ``, "", \\, + or <>. A double quote may be quoted within double quotes by + preceding it with a backslash. If enabled, history expansion will be + performed unless an !! appearing in double quotes is escaped using a + backslash. The backslash preceding the !! is not removed. + + The special parameters ** and @@ have special meaning when in double + quotes (see PPAARRAAMMEETTEERRSS below). + + Words of the form $$'_s_t_r_i_n_g' are treated specially. The word expands to + _s_t_r_i_n_g, with backslash-escaped characters replaced as specified by the + ANSI C standard. Backslash escape sequences, if present, are decoded + as follows: + \\aa alert (bell) + \\bb backspace + \\ee + \\EE an escape character + \\ff form feed + \\nn new line + \\rr carriage return + \\tt horizontal tab + \\vv vertical tab + \\\\ backslash + \\'' single quote + \\"" double quote + \\?? question mark + \\_n_n_n the eight-bit character whose value is the octal value + _n_n_n (one to three digits) + \\xx_H_H the eight-bit character whose value is the hexadecimal + value _H_H (one or two hex digits) + \\uu_H_H_H_H the Unicode (ISO/IEC 10646) character whose value is the + hexadecimal value _H_H_H_H (one to four hex digits) + \\UU_H_H_H_H_H_H_H_H + the Unicode (ISO/IEC 10646) character whose value is the + hexadecimal value _H_H_H_H_H_H_H_H (one to eight hex digits) + \\cc_x a control-_x character + + The expanded result is single-quoted, as if the dollar sign had not + been present. + + A double-quoted string preceded by a dollar sign ($$"_s_t_r_i_n_g") will cause + the string to be translated according to the current locale. If the + current locale is CC or PPOOSSIIXX, the dollar sign is ignored. If the + string is translated and replaced, the replacement is double-quoted. + +PPAARRAAMMEETTEERRSS + A _p_a_r_a_m_e_t_e_r is an entity that stores values. It can be a _n_a_m_e, a num- + ber, or one of the special characters listed below under SSppeecciiaall PPaarraamm-- + eetteerrss. A _v_a_r_i_a_b_l_e is a parameter denoted by a _n_a_m_e. A variable has a + _v_a_l_u_e and zero or more _a_t_t_r_i_b_u_t_e_s. Attributes are assigned using the + ddeeccllaarree builtin command (see ddeeccllaarree below in SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS). + + 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 uunnsseett builtin command (see SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS below). + + A _v_a_r_i_a_b_l_e may be assigned to by a statement of the form + + _n_a_m_e=[_v_a_l_u_e] + + If _v_a_l_u_e is not given, the variable is assigned the null string. All + _v_a_l_u_e_s undergo tilde expansion, parameter and variable expansion, com- + mand substitution, arithmetic expansion, and quote removal (see EEXXPPAANN-- + SSIIOONN below). If the variable has its iinntteeggeerr attribute set, then _v_a_l_u_e + is evaluated as an arithmetic expression even if the $((...)) expansion + is not used (see AArriitthhmmeettiicc EExxppaannssiioonn below). Word splitting is not + performed, with the exception of ""$$@@"" as explained below under SSppeecciiaall + PPaarraammeetteerrss. Pathname expansion is not performed. Assignment state- + ments may also appear as arguments to the aalliiaass, ddeeccllaarree, ttyyppeesseett, + eexxppoorrtt, rreeaaddoonnllyy, and llooccaall builtin commands (_d_e_c_l_a_r_a_t_i_o_n commands). + When in _p_o_s_i_x _m_o_d_e, these builtins may appear in a command after one or + more instances of the ccoommmmaanndd builtin and retain these assignment + statement properties. + + In the context where an assignment statement is assigning a value to a + shell variable or array index, the += operator can be used to append to + or add to the variable's previous value. This includes arguments to + builtin commands such as ddeeccllaarree that accept assignment statements + (_d_e_c_l_a_r_a_t_i_o_n commands). When += is applied to a variable for which the + _i_n_t_e_g_e_r attribute has been set, _v_a_l_u_e is evaluated as an arithmetic + expression and added to the variable's current value, which is also + evaluated. When += is applied to an array variable using compound + assignment (see AArrrraayyss below), the variable's value is not unset (as it + is when using =), and new values are appended to the array beginning at + one greater than the array's maximum index (for indexed arrays) or + added as additional key-value pairs in an associative array. When + applied to a string-valued variable, _v_a_l_u_e is expanded and appended to + the variable's value. + + A variable can be assigned the _n_a_m_e_r_e_f attribute using the --nn option to + the ddeeccllaarree or llooccaall builtin commands (see the descriptions of ddeeccllaarree + and llooccaall below) to create a _n_a_m_e_r_e_f, or a reference to another vari- + able. This allows variables to be manipulated indirectly. Whenever + the nameref variable is referenced, assigned to, unset, or has its + attributes modified (other than using or changing the _n_a_m_e_r_e_f attribute + itself), the operation is actually performed on the variable specified + by the nameref variable's value. A nameref is commonly used within + shell functions to refer to a variable whose name is passed as an argu- + ment to the function. For instance, if a variable name is passed to a + shell function as its first argument, running + declare -n ref=$1 + inside the function creates a nameref variable rreeff whose value is the + variable name passed as the first argument. References and assignments + to rreeff, and changes to its attributes, are treated as references, + assignments, and attribute modifications to the variable whose name was + passed as $$11. If the control variable in a ffoorr loop has the nameref + attribute, the list of words can be a list of shell variables, and a + name reference will be established for each word in the list, in turn, + when the loop is executed. Array variables cannot be given the nnaammeerreeff + attribute. However, nameref variables can reference array variables + and subscripted array variables. Namerefs can be unset using the --nn + option to the uunnsseett builtin. Otherwise, if uunnsseett is executed with the + name of a nameref variable as an argument, the variable referenced by + the nameref variable will be unset. + + PPoossiittiioonnaall PPaarraammeetteerrss + A _p_o_s_i_t_i_o_n_a_l _p_a_r_a_m_e_t_e_r is a parameter denoted by one or more digits, + other than the single digit 0. Positional parameters are assigned from + the shell's arguments when it is invoked, and may be reassigned using + the sseett builtin command. Positional parameters may not be assigned to + with assignment statements. The positional parameters are temporarily + replaced when a shell function is executed (see FFUUNNCCTTIIOONNSS below). + + When a positional parameter consisting of more than a single digit is + expanded, it must be enclosed in braces (see EEXXPPAANNSSIIOONN below). + + SSppeecciiaall PPaarraammeetteerrss + The shell treats several parameters specially. These parameters may + only be referenced; assignment to them is not allowed. + ** Expands to the positional parameters, starting from one. When + the expansion is not within double quotes, each positional + parameter expands to a separate word. In contexts where it is + performed, those words are subject to further word splitting and + pathname expansion. 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 IIFFSS special + variable. That is, "$$**" is equivalent to "$$11_c$$22_c......", where _c + is the first character of the value of the IIFFSS variable. If IIFFSS + is unset, the parameters are separated by spaces. If IIFFSS is + null, the parameters are joined without intervening separators. + @@ Expands to the positional parameters, starting from one. When + the expansion occurs within double quotes, each parameter + expands to a separate word. That is, "$$@@" is equivalent to "$$11" + "$$22" ... If the double-quoted expansion occurs within a word, + the expansion of the first parameter is joined with the begin- + ning 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, "$$@@" and $$@@ expand to + nothing (i.e., they are removed). + ## Expands to the number of positional parameters in decimal. + ?? Expands to the exit status of the most recently executed fore- + ground pipeline. + -- Expands to the current option flags as specified upon invoca- + tion, by the sseett builtin command, or those set by the shell + itself (such as the --ii option). + $$ Expands to the process ID of the shell. In a () subshell, it + expands to the process ID of the current shell, not the sub- + shell. + !! Expands to the process ID of the job most recently placed into + the background, whether executed as an asynchronous command or + using the bbgg builtin (see JJOOBB CCOONNTTRROOLL below). + 00 Expands to the name of the shell or shell script. This is set + at shell initialization. If bbaasshh is invoked with a file of com- + mands, $$00 is set to the name of that file. If bbaasshh is started + with the --cc option, then $$00 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 bbaasshh, as given by argument + zero. + __ At shell startup, set to the absolute pathname used to invoke + the shell or shell script being executed as passed in the envi- + ronment 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 check- + ing mail, this parameter holds the name of the mail file cur- + rently being checked. + + SShheellll VVaarriiaabblleess + The following variables are set by the shell: + + BBAASSHH Expands to the full filename used to invoke this instance of + bbaasshh. + BBAASSHHOOPPTTSS + A colon-separated list of enabled shell options. Each word in + the list is a valid argument for the --ss option to the sshhoopptt + builtin command (see SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS below). The options + appearing in BBAASSHHOOPPTTSS are those reported as _o_n by sshhoopptt. If + this variable is in the environment when bbaasshh starts up, each + shell option in the list will be enabled before reading any + startup files. This variable is read-only. + BBAASSHHPPIIDD + Expands to the process ID of the current bbaasshh process. This + differs from $$$$ under certain circumstances, such as subshells + that do not require bbaasshh to be re-initialized. + BBAASSHH__AALLIIAASSEESS + An associative array variable whose members correspond to the + internal list of aliases as maintained by the aalliiaass builtin. + Elements added to this array appear in the alias list; however, + unsetting array elements currently does not cause aliases to be + removed from the alias list. If BBAASSHH__AALLIIAASSEESS is unset, it loses + its special properties, even if it is subsequently reset. + BBAASSHH__AARRGGCC + An array variable whose values are the number of parameters in + each frame of the current bbaasshh execution call stack. The number + of parameters to the current subroutine (shell function or + script executed with .. or ssoouurrccee) is at the top of the stack. + When a subroutine is executed, the number of parameters passed + is pushed onto BBAASSHH__AARRGGCC. The shell sets BBAASSHH__AARRGGCC only when in + extended debugging mode (see the description of the eexxttddeebbuugg + option to the sshhoopptt builtin below) + BBAASSHH__AARRGGVV + An array variable containing all of the parameters in the cur- + rent bbaasshh 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 exe- + cuted, the parameters supplied are pushed onto BBAASSHH__AARRGGVV. The + shell sets BBAASSHH__AARRGGVV only when in extended debugging mode (see + the description of the eexxttddeebbuugg option to the sshhoopptt builtin + below) + BBAASSHH__CCMMDDSS + An associative array variable whose members correspond to the + internal hash table of commands as maintained by the hhaasshh + builtin. Elements added to this array appear in the hash table; + however, unsetting array elements currently does not cause com- + mand names to be removed from the hash table. If BBAASSHH__CCMMDDSS is + unset, it loses its special properties, even if it is subse- + quently reset. + BBAASSHH__CCOOMMMMAANNDD + 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. + BBAASSHH__EEXXEECCUUTTIIOONN__SSTTRRIINNGG + The command argument to the --cc invocation option. + BBAASSHH__LLIINNEENNOO + An array variable whose members are the line numbers in source + files where each corresponding member of FFUUNNCCNNAAMMEE was invoked. + $${{BBAASSHH__LLIINNEENNOO[[_$_i]]}} is the line number in the source file + ($${{BBAASSHH__SSOOUURRCCEE[[_$_i_+_1]]}}) where $${{FFUUNNCCNNAAMMEE[[_$_i]]}} was called (or + $${{BBAASSHH__LLIINNEENNOO[[_$_i_-_1]]}} if referenced within another shell func- + tion). Use LLIINNEENNOO to obtain the current line number. + BBAASSHH__LLOOAADDAABBLLEESS__PPAATTHH + A colon-separated list of directories in which the shell looks + for dynamically loadable builtins specified by the eennaabbllee com- + mand. + BBAASSHH__RREEMMAATTCCHH + An array variable whose members are assigned by the ==~~ binary + operator to the [[[[ conditional command. The element with index + 0 is the portion of the string matching the entire regular + expression. The element with index _n is the portion of the + string matching the _nth parenthesized subexpression. This vari- + able is read-only. + BBAASSHH__SSOOUURRCCEE + An array variable whose members are the source filenames where + the corresponding shell function names in the FFUUNNCCNNAAMMEE array + variable are defined. The shell function $${{FFUUNNCCNNAAMMEE[[_$_i]]}} is + defined in the file $${{BBAASSHH__SSOOUURRCCEE[[_$_i]]}} and called from + $${{BBAASSHH__SSOOUURRCCEE[[_$_i_+_1]]}}. + BBAASSHH__SSUUBBSSHHEELLLL + Incremented by one within each subshell or subshell environment + when the shell begins executing in that environment. The ini- + tial value is 0. + BBAASSHH__VVEERRSSIINNFFOO + A readonly array variable whose members hold version information + for this instance of bbaasshh. The values assigned to the array + members are as follows: + BBAASSHH__VVEERRSSIINNFFOO[[0]] The major version number (the _r_e_l_e_a_s_e). + BBAASSHH__VVEERRSSIINNFFOO[[1]] The minor version number (the _v_e_r_s_i_o_n). + BBAASSHH__VVEERRSSIINNFFOO[[2]] The patch level. + BBAASSHH__VVEERRSSIINNFFOO[[3]] The build version. + BBAASSHH__VVEERRSSIINNFFOO[[4]] The release status (e.g., _b_e_t_a_1). + BBAASSHH__VVEERRSSIINNFFOO[[5]] The value of MMAACCHHTTYYPPEE. + BBAASSHH__VVEERRSSIIOONN + Expands to a string describing the version of this instance of + bbaasshh. + CCOOMMPP__CCWWOORRDD + An index into $${{CCOOMMPP__WWOORRDDSS}} of the word containing the current + cursor position. This variable is available only in shell func- + tions invoked by the programmable completion facilities (see + PPrrooggrraammmmaabbllee CCoommpplleettiioonn below). + CCOOMMPP__KKEEYY + The key (or final key of a key sequence) used to invoke the cur- + rent completion function. + CCOOMMPP__LLIINNEE + The current command line. This variable is available only in + shell functions and external commands invoked by the program- + mable completion facilities (see PPrrooggrraammmmaabbllee CCoommpplleettiioonn below). + CCOOMMPP__PPOOIINNTT + The index of the current cursor position relative to the begin- + ning 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 $${{##CCOOMMPP__LLIINNEE}}. This variable is available only in + shell functions and external commands invoked by the program- + mable completion facilities (see PPrrooggrraammmmaabbllee CCoommpplleettiioonn below). + CCOOMMPP__TTYYPPEE + Set to an integer value corresponding to the type of completion + attempted that caused a completion function to be called: _T_A_B, + for normal completion, _?, for listing completions after succes- + sive tabs, _!, for listing alternatives on partial word comple- + tion, _@, to list completions if the word is not unmodified, or + _%, for menu completion. This variable is available only in + shell functions and external commands invoked by the program- + mable completion facilities (see PPrrooggrraammmmaabbllee CCoommpplleettiioonn below). + CCOOMMPP__WWOORRDDBBRREEAAKKSS + The set of characters that the rreeaaddlliinnee library treats as word + separators when performing word completion. If CCOOMMPP__WWOORRDDBBRREEAAKKSS + is unset, it loses its special properties, even if it is subse- + quently reset. + CCOOMMPP__WWOORRDDSS + An array variable (see AArrrraayyss below) consisting of the individ- + ual words in the current command line. The line is split into + words as rreeaaddlliinnee would split it, using CCOOMMPP__WWOORRDDBBRREEAAKKSS as + described above. This variable is available only in shell func- + tions invoked by the programmable completion facilities (see + PPrrooggrraammmmaabbllee CCoommpplleettiioonn below). + CCOOPPRROOCC An array variable (see AArrrraayyss below) created to hold the file + descriptors for output from and input to an unnamed coprocess + (see CCoopprroocceesssseess above). + DDIIRRSSTTAACCKK + An array variable (see AArrrraayyss below) containing the current con- + tents of the directory stack. Directories appear in the stack + in the order they are displayed by the ddiirrss builtin. Assigning + to members of this array variable may be used to modify directo- + ries already in the stack, but the ppuusshhdd and ppooppdd builtins must + be used to add and remove directories. Assignment to this vari- + able will not change the current directory. If DDIIRRSSTTAACCKK is + unset, it loses its special properties, even if it is subse- + quently reset. + EEUUIIDD Expands to the effective user ID of the current user, initial- + ized at shell startup. This variable is readonly. + FFUUNNCCNNAAMMEE + 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 bot- + tom-most element (the one with the highest index) is "main". + This variable exists only when a shell function is executing. + Assignments to FFUUNNCCNNAAMMEE have no effect. If FFUUNNCCNNAAMMEE is unset, + it loses its special properties, even if it is subsequently + reset. + + This variable can be used with BBAASSHH__LLIINNEENNOO and BBAASSHH__SSOOUURRCCEE. + Each element of FFUUNNCCNNAAMMEE has corresponding elements in + BBAASSHH__LLIINNEENNOO and BBAASSHH__SSOOUURRCCEE to describe the call stack. For + instance, $${{FFUUNNCCNNAAMMEE[[_$_i]]}} was called from the file + $${{BBAASSHH__SSOOUURRCCEE[[_$_i_+_1]]}} at line number $${{BBAASSHH__LLIINNEENNOO[[_$_i]]}}. The + ccaalllleerr builtin displays the current call stack using this infor- + mation. + GGRROOUUPPSS An array variable containing the list of groups of which the + current user is a member. Assignments to GGRROOUUPPSS have no effect. + If GGRROOUUPPSS is unset, it loses its special properties, even if it + is subsequently reset. + HHIISSTTCCMMDD + The history number, or index in the history list, of the current + command. If HHIISSTTCCMMDD is unset, it loses its special properties, + even if it is subsequently reset. + HHOOSSTTNNAAMMEE + Automatically set to the name of the current host. + HHOOSSTTTTYYPPEE + Automatically set to a string that uniquely describes the type + of machine on which bbaasshh is executing. The default is system- + dependent. + LLIINNEENNOO Each time this parameter is referenced, the shell substitutes a + decimal number representing the current sequential line number + (starting with 1) within a script or function. When not in a + script or function, the value substituted is not guaranteed to + be meaningful. If LLIINNEENNOO is unset, it loses its special proper- + ties, even if it is subsequently reset. + MMAACCHHTTYYPPEE + Automatically set to a string that fully describes the system + type on which bbaasshh is executing, in the standard GNU _c_p_u_-_c_o_m_- + _p_a_n_y_-_s_y_s_t_e_m format. The default is system-dependent. + MMAAPPFFIILLEE + An array variable (see AArrrraayyss below) created to hold the text + read by the mmaappffiillee builtin when no variable name is supplied. + OOLLDDPPWWDD The previous working directory as set by the ccdd command. + OOPPTTAARRGG The value of the last option argument processed by the ggeettooppttss + builtin command (see SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS below). + OOPPTTIINNDD The index of the next argument to be processed by the ggeettooppttss + builtin command (see SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS below). + OOSSTTYYPPEE Automatically set to a string that describes the operating sys- + tem on which bbaasshh is executing. The default is system-depen- + dent. + PPIIPPEESSTTAATTUUSS + An array variable (see AArrrraayyss below) containing a list of exit + status values from the processes in the most-recently-executed + foreground pipeline (which may contain only a single command). + PPPPIIDD The process ID of the shell's parent. This variable is read- + only. + PPWWDD The current working directory as set by the ccdd command. + RRAANNDDOOMM Each time this parameter is referenced, a random integer between + 0 and 32767 is generated. The sequence of random numbers may be + initialized by assigning a value to RRAANNDDOOMM. If RRAANNDDOOMM is unset, + it loses its special properties, even if it is subsequently + reset. + RREEAADDLLIINNEE__LLIINNEE + The contents of the rreeaaddlliinnee line buffer, for use with "bind -x" + (see SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS below). + RREEAADDLLIINNEE__PPOOIINNTT + The position of the insertion point in the rreeaaddlliinnee line buffer, + for use with "bind -x" (see SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS below). + RREEPPLLYY Set to the line of input read by the rreeaadd builtin command when + no arguments are supplied. + SSEECCOONNDDSS + Each time this parameter is referenced, the number of seconds + since shell invocation is returned. If a value is assigned to + SSEECCOONNDDSS, the value returned upon subsequent references is the + number of seconds since the assignment plus the value assigned. + If SSEECCOONNDDSS is unset, it loses its special properties, even if it + is subsequently reset. + SSHHEELLLLOOPPTTSS + A colon-separated list of enabled shell options. Each word in + the list is a valid argument for the --oo option to the sseett + builtin command (see SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS below). The options + appearing in SSHHEELLLLOOPPTTSS are those reported as _o_n by sseett --oo. If + this variable is in the environment when bbaasshh starts up, each + shell option in the list will be enabled before reading any + startup files. This variable is read-only. + SSHHLLVVLL Incremented by one each time an instance of bbaasshh is started. + UUIIDD Expands to the user ID of the current user, initialized at shell + startup. This variable is readonly. + + The following variables are used by the shell. In some cases, bbaasshh + assigns a default value to a variable; these cases are noted below. + + BBAASSHH__CCOOMMPPAATT + The value is used to set the shell's compatibility level. See + the description of the sshhoopptt builtin below under SSHHEELLLL BBUUIILLTTIINN + CCOOMMMMAANNDDSS for a description of the various compatibility levels + and their effects. The value may be a decimal number (e.g., + 4.2) or an integer (e.g., 42) corresponding to the desired com- + patibility level. If BBAASSHH__CCOOMMPPAATT is unset or set to the empty + string, the compatibility level is set to the default for the + current version. If BBAASSHH__CCOOMMPPAATT is set to a value that is not + one of the valid compatibility levels, the shell prints an error + message and sets the compatibility level to the default for the + current version. The valid compatibility levels correspond to + the compatibility options accepted by the sshhoopptt builtin + described below (for example, ccoommppaatt4422 means that 4.2 and 42 are + valid values). The current version is also a valid value. + BBAASSHH__EENNVV + If this parameter is set when bbaasshh is executing a shell script, + its value is interpreted as a filename containing commands to + initialize the shell, as in _~_/_._b_a_s_h_r_c. The value of BBAASSHH__EENNVV is + subjected to parameter expansion, command substitution, and + arithmetic expansion before being interpreted as a filename. + PPAATTHH is not used to search for the resultant filename. + BBAASSHH__XXTTRRAACCEEFFDD + If set to an integer corresponding to a valid file descriptor, + bbaasshh will write the trace output generated when _s_e_t _-_x is + enabled to that file descriptor. The file descriptor is closed + when BBAASSHH__XXTTRRAACCEEFFDD is unset or assigned a new value. Unsetting + BBAASSHH__XXTTRRAACCEEFFDD or assigning it the empty string causes the trace + output to be sent to the standard error. Note that setting + BBAASSHH__XXTTRRAACCEEFFDD to 2 (the standard error file descriptor) and then + unsetting it will result in the standard error being closed. + CCDDPPAATTHH The search path for the ccdd command. This is a colon-separated + list of directories in which the shell looks for destination + directories specified by the ccdd command. A sample value is + ".:~:/usr". + CCHHIILLDD__MMAAXX + Set the number of exited child status values for the shell to + remember. Bash will not allow this value to be decreased below + a POSIX-mandated minimum, and there is a maximum value (cur- + rently 8192) that this may not exceed. The minimum value is + system-dependent. + CCOOLLUUMMNNSS + Used by the sseelleecctt compound command to determine the terminal + width when printing selection lists. Automatically set if the + cchheecckkwwiinnssiizzee option is enabled or in an interactive shell upon + receipt of a SSIIGGWWIINNCCHH. + CCOOMMPPRREEPPLLYY + An array variable from which bbaasshh reads the possible completions + generated by a shell function invoked by the programmable com- + pletion facility (see PPrrooggrraammmmaabbllee CCoommpplleettiioonn below). Each + array element contains one possible completion. + EEMMAACCSS If bbaasshh finds this variable in the environment when the shell + starts with value "t", it assumes that the shell is running in + an Emacs shell buffer and disables line editing. + EENNVV Similar to BBAASSHH__EENNVV; used when the shell is invoked in POSIX + mode. + EEXXEECCIIGGNNOORREE + A colon-separated list of shell patterns (see PPaatttteerrnn MMaattcchhiinngg) + defining the list of filenames to be ignored by command search + using PPAATTHH. Files whose full pathnames match one of these pat- + terns are not considered executable files for the purposes of + completion and command execution via PPAATTHH lookup. This does not + affect the behavior of the [[, tteesstt, and [[[[ commands. Full path- + names in the command hash table are not subject to EEXXEECCIIGGNNOORREE. + Use this variable to ignore shared library files that have the + executable bit set, but are not executable files. The pattern + matching honors the setting of the eexxttgglloobb shell option. + FFCCEEDDIITT The default editor for the ffcc builtin command. + FFIIGGNNOORREE + A colon-separated list of suffixes to ignore when performing + filename completion (see RREEAADDLLIINNEE below). A filename whose suf- + fix matches one of the entries in FFIIGGNNOORREE is excluded from the + list of matched filenames. A sample value is ".o:~". + FFUUNNCCNNEESSTT + If set to a numeric value greater than 0, defines a maximum + function nesting level. Function invocations that exceed this + nesting level will cause the current command to abort. + GGLLOOBBIIGGNNOORREE + A colon-separated list of patterns defining the set of filenames + to be ignored by pathname expansion. If a filename matched by a + pathname expansion pattern also matches one of the patterns in + GGLLOOBBIIGGNNOORREE, it is removed from the list of matches. + HHIISSTTCCOONNTTRROOLL + A colon-separated list of values controlling how commands are + saved on the history list. If the list of values includes + _i_g_n_o_r_e_s_p_a_c_e, lines which begin with a ssppaaccee character are not + saved in the history list. A value of _i_g_n_o_r_e_d_u_p_s causes lines + matching the previous history entry to not be saved. A value of + _i_g_n_o_r_e_b_o_t_h is shorthand for _i_g_n_o_r_e_s_p_a_c_e and _i_g_n_o_r_e_d_u_p_s. A value + of _e_r_a_s_e_d_u_p_s 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 HHIISSTTCCOONNTTRROOLL 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 HHIISSTTIIGGNNOORREE. 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 HHIISSTTCCOONNTTRROOLL. + HHIISSTTFFIILLEE + The name of the file in which command history is saved (see HHIISS-- + TTOORRYY below). The default value is _~_/_._b_a_s_h___h_i_s_t_o_r_y. If unset, + the command history is not saved when a shell exits. + HHIISSTTFFIILLEESSIIZZEE + The maximum number of lines contained in the history file. When + this variable is assigned a value, the history file is trun- + cated, if necessary, to contain no more than that number of + lines by removing the oldest entries. The history file is also + truncated to this size after writing it when a shell exits. If + the value is 0, the history file is truncated to zero size. + Non-numeric values and numeric values less than zero inhibit + truncation. The shell sets the default value to the value of + HHIISSTTSSIIZZEE after reading any startup files. + HHIISSTTIIGGNNOORREE + 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 com- + plete line (no implicit `**' is appended). Each pattern is + tested against the line after the checks specified by HHIISSTTCCOONN-- + TTRROOLL are applied. In addition to the normal shell pattern + matching characters, `&&' matches the previous history line. `&&' + 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 HHIISSTTIIGGNNOORREE. The pattern + matching honors the setting of the eexxttgglloobb shell option. + HHIISSTTSSIIZZEE + The number of commands to remember in the command history (see + HHIISSTTOORRYY below). If the value is 0, commands are not saved in + the history list. Numeric values less than zero result in every + command being saved on the history list (there is no limit). + The shell sets the default value to 500 after reading any + startup files. + HHIISSTTTTIIMMEEFFOORRMMAATT + If this variable is set and not null, its value is used as a + format string for _s_t_r_f_t_i_m_e(3) to print the time stamp associated + with each history entry displayed by the hhiissttoorryy builtin. If + this variable is set, time stamps are written to the history + file so they may be preserved across shell sessions. This uses + the history comment character to distinguish timestamps from + other history lines. + HHOOMMEE The home directory of the current user; the default argument for + the ccdd builtin command. The value of this variable is also used + when performing tilde expansion. + HHOOSSTTFFIILLEE + Contains the name of a file in the same format as _/_e_t_c_/_h_o_s_t_s + 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, bbaasshh adds the contents of + the new file to the existing list. If HHOOSSTTFFIILLEE is set, but has + no value, or does not name a readable file, bbaasshh attempts to + read _/_e_t_c_/_h_o_s_t_s to obtain the list of possible hostname comple- + tions. When HHOOSSTTFFIILLEE is unset, the hostname list is cleared. + IIFFSS The _I_n_t_e_r_n_a_l _F_i_e_l_d _S_e_p_a_r_a_t_o_r that is used for word splitting + after expansion and to split lines into words with the rreeaadd + builtin command. The default value is ``''. + IIGGNNOORREEEEOOFF + Controls the action of an interactive shell on receipt of an EEOOFF + character as the sole input. If set, the value is the number of + consecutive EEOOFF characters which must be typed as the first + characters on an input line before bbaasshh exits. If the variable + exists but does not have a numeric value, or has no value, the + default value is 10. If it does not exist, EEOOFF signifies the + end of input to the shell. + IINNPPUUTTRRCC + The filename for the rreeaaddlliinnee startup file, overriding the + default of _~_/_._i_n_p_u_t_r_c (see RREEAADDLLIINNEE below). + LLAANNGG Used to determine the locale category for any category not + specifically selected with a variable starting with LLCC__. + LLCC__AALLLL This variable overrides the value of LLAANNGG and any other LLCC__ + variable specifying a locale category. + LLCC__CCOOLLLLAATTEE + This variable determines the collation order used when sorting + the results of pathname expansion, and determines the behavior + of range expressions, equivalence classes, and collating + sequences within pathname expansion and pattern matching. + LLCC__CCTTYYPPEE + This variable determines the interpretation of characters and + the behavior of character classes within pathname expansion and + pattern matching. + LLCC__MMEESSSSAAGGEESS + This variable determines the locale used to translate double- + quoted strings preceded by a $$. + LLCC__NNUUMMEERRIICC + This variable determines the locale category used for number + formatting. + LLCC__TTIIMMEE + This variable determines the locale category used for data and + time formatting. + LLIINNEESS Used by the sseelleecctt compound command to determine the column + length for printing selection lists. Automatically set if the + cchheecckkwwiinnssiizzee option is enabled or in an interactive shell upon + receipt of a SSIIGGWWIINNCCHH. + MMAAIILL If this parameter is set to a file or directory name and the + MMAAIILLPPAATTHH variable is not set, bbaasshh informs the user of the + arrival of mail in the specified file or Maildir-format direc- + tory. + MMAAIILLCCHHEECCKK + Specifies how often (in seconds) bbaasshh checks for mail. The + default is 60 seconds. When it is time to check for mail, the + shell does so before displaying the primary prompt. If this + variable is unset, or set to a value that is not a number + greater than or equal to zero, the shell disables mail checking. + MMAAIILLPPAATTHH + A colon-separated list of filenames to be checked for mail. The + message to be printed when mail arrives in a particular file may + be specified by separating the filename from the message with a + `?'. When used in the text of the message, $$__ expands to the + name of the current mailfile. Example: + MMAAIILLPPAATTHH='/var/mail/bfox?"You have mail":~/shell-mail?"$_ has + mail!"' + BBaasshh can be configured to supply a default value for this vari- + able (there is no value by default), but the location of the + user mail files that it uses is system dependent (e.g., + /var/mail/$$UUSSEERR). + OOPPTTEERRRR If set to the value 1, bbaasshh displays error messages generated by + the ggeettooppttss builtin command (see SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS below). + OOPPTTEERRRR is initialized to 1 each time the shell is invoked or a + shell script is executed. + PPAATTHH The search path for commands. It is a colon-separated list of + directories in which the shell looks for commands (see CCOOMMMMAANNDD + EEXXEECCUUTTIIOONN below). A zero-length (null) directory name in the + value of PPAATTHH indicates the current directory. A null directory + name may appear as two adjacent colons, or as an initial or + trailing colon. The default path is system-dependent, and is + set by the administrator who installs bbaasshh. A common value is + ``/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin''. + PPOOSSIIXXLLYY__CCOORRRREECCTT + If this variable is in the environment when bbaasshh starts, the + shell enters _p_o_s_i_x _m_o_d_e before reading the startup files, as if + the ----ppoossiixx invocation option had been supplied. If it is set + while the shell is running, bbaasshh enables _p_o_s_i_x _m_o_d_e, as if the + command _s_e_t _-_o _p_o_s_i_x had been executed. + PPRROOMMPPTT__CCOOMMMMAANNDD + If set, the value is executed as a command prior to issuing each + primary prompt. + PPRROOMMPPTT__DDIIRRTTRRIIMM + If set to a number greater than zero, the value is used as the + number of trailing directory components to retain when expanding + the \\ww and \\WW prompt string escapes (see PPRROOMMPPTTIINNGG below). + Characters removed are replaced with an ellipsis. + PPSS00 The value of this parameter is expanded (see PPRROOMMPPTTIINNGG below) + and displayed by interactive shells after reading a command and + before the command is executed. + PPSS11 The value of this parameter is expanded (see PPRROOMMPPTTIINNGG below) + and used as the primary prompt string. The default value is + ``\\ss--\\vv\\$$ ''. + PPSS22 The value of this parameter is expanded as with PPSS11 and used as + the secondary prompt string. The default is ``>> ''. + PPSS33 The value of this parameter is used as the prompt for the sseelleecctt + command (see SSHHEELLLL GGRRAAMMMMAARR above). + PPSS44 The value of this parameter is expanded as with PPSS11 and the + value is printed before each command bbaasshh displays during an + execution trace. The first character of PPSS44 is replicated mul- + tiple times, as necessary, to indicate multiple levels of indi- + rection. The default is ``++ ''. + SSHHEELLLL The full pathname to the shell is kept in this environment vari- + able. If it is not set when the shell starts, bbaasshh assigns to + it the full pathname of the current user's login shell. + TTIIMMEEFFOORRMMAATT + The value of this parameter is used as a format string specify- + ing how the timing information for pipelines prefixed with the + ttiimmee reserved word should be displayed. The %% character intro- + duces 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. + %%%% A literal %%. + %%[[_p]][[ll]]RR The elapsed time in seconds. + %%[[_p]][[ll]]UU The number of CPU seconds spent in user mode. + %%[[_p]][[ll]]SS The number of CPU seconds spent in system mode. + %%PP The CPU percentage, computed as (%U + %S) / %R. + + The optional _p is a digit specifying the _p_r_e_c_i_s_i_o_n, 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 _p greater + than 3 are changed to 3. If _p is not specified, the value 3 is + used. + + The optional ll specifies a longer format, including minutes, of + the form _M_Mm_S_S._F_Fs. The value of _p determines whether or not + the fraction is included. + + If this variable is not set, bbaasshh acts as if it had the value + $$''\\nnrreeaall\\tt%%33llRR\\nnuusseerr\\tt%%33llUU\\nnssyyss\\tt%%33llSS''. If the value is null, + no timing information is displayed. A trailing newline is added + when the format string is displayed. + TTMMOOUUTT If set to a value greater than zero, TTMMOOUUTT is treated as the + default timeout for the rreeaadd builtin. The sseelleecctt command termi- + nates if input does not arrive after TTMMOOUUTT seconds when input is + coming from a terminal. In an interactive shell, the value is + interpreted as the number of seconds to wait for a line of input + after issuing the primary prompt. BBaasshh terminates after waiting + for that number of seconds if a complete line of input does not + arrive. + TTMMPPDDIIRR If set, bbaasshh uses its value as the name of a directory in which + bbaasshh creates temporary files for the shell's use. + aauuttoo__rreessuummee + This variable controls how the shell interacts with the user and + job control. If this variable is set, single word simple com- + mands without redirections are treated as candidates for resump- + tion of an existing stopped job. There is no ambiguity allowed; + if there is more than one job beginning with the string typed, + the job most recently accessed is selected. The _n_a_m_e of a + stopped job, in this context, is the command line used to start + it. If set to the value _e_x_a_c_t, the string supplied must match + the name of a stopped job exactly; if set to _s_u_b_s_t_r_i_n_g, the + string supplied needs to match a substring of the name of a + stopped job. The _s_u_b_s_t_r_i_n_g value provides functionality analo- + gous to the %%?? job identifier (see JJOOBB CCOONNTTRROOLL below). 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 + %%_s_t_r_i_n_g job identifier. + hhiissttcchhaarrss + The two or three characters which control history expansion and + tokenization (see HHIISSTTOORRYY EEXXPPAANNSSIIOONN below). The first character + is the _h_i_s_t_o_r_y _e_x_p_a_n_s_i_o_n character, the character which signals + the start of a history expansion, normally `!!'. The second + character is the _q_u_i_c_k _s_u_b_s_t_i_t_u_t_i_o_n character, which is used as + shorthand for re-running the previous command entered, substi- + tuting one string for another in the command. The default is + `^^'. The optional third character is the character which indi- + cates that the remainder of the line is a comment when found as + the first character of a word, normally `##'. The history com- + ment 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. + + AArrrraayyss + BBaasshh provides one-dimensional indexed and associative array variables. + Any variable may be used as an indexed array; the ddeeccllaarree 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 con- + tiguously. Indexed arrays are referenced using integers (including + arithmetic expressions) and are zero-based; associative arrays are ref- + erenced using arbitrary strings. Unless otherwise noted, indexed array + indices must be non-negative integers. + + An indexed array is created automatically if any variable is assigned + to using the syntax _n_a_m_e[_s_u_b_s_c_r_i_p_t]=_v_a_l_u_e. The _s_u_b_s_c_r_i_p_t is treated as + an arithmetic expression that must evaluate to a number. To explicitly + declare an indexed array, use ddeeccllaarree --aa _n_a_m_e (see SSHHEELLLL BBUUIILLTTIINN CCOOMM-- + MMAANNDDSS below). ddeeccllaarree --aa _n_a_m_e[[_s_u_b_s_c_r_i_p_t]] is also accepted; the _s_u_b_- + _s_c_r_i_p_t is ignored. + + Associative arrays are created using ddeeccllaarree --AA _n_a_m_e. + + Attributes may be specified for an array variable using the ddeeccllaarree and + rreeaaddoonnllyy builtins. Each attribute applies to all members of an array. + + Arrays are assigned to using compound assignments of the form + _n_a_m_e=((value_1 ... value_n)), where each _v_a_l_u_e is of the form [_s_u_b_- + _s_c_r_i_p_t]=_s_t_r_i_n_g. Indexed array assignments do not require anything but + _s_t_r_i_n_g. When assigning to indexed arrays, if the optional brackets and + subscript are 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. + + When assigning to an associative array, the subscript is required. + + This syntax is also accepted by the ddeeccllaarree builtin. Individual array + elements may be assigned to using the _n_a_m_e[_s_u_b_s_c_r_i_p_t]=_v_a_l_u_e syntax + introduced above. When assigning to an indexed array, if _n_a_m_e is sub- + scripted by a negative number, that number is interpreted as relative + to one greater than the maximum index of _n_a_m_e, so negative indices + count back from the end of the array, and an index of -1 references the + last element. + + Any element of an array may be referenced using ${_n_a_m_e[_s_u_b_s_c_r_i_p_t]}. + The braces are required to avoid conflicts with pathname expansion. If + _s_u_b_s_c_r_i_p_t is @@ or **, the word expands to all members of _n_a_m_e. These + subscripts differ only when the word appears within double quotes. If + the word is double-quoted, ${_n_a_m_e[*]} expands to a single word with the + value of each array member separated by the first character of the IIFFSS + special variable, and ${_n_a_m_e[@]} expands each element of _n_a_m_e to a sep- + arate word. When there are no array members, ${_n_a_m_e[@]} 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 ** and @@ (see SSppeecciiaall PPaarraammeetteerrss + above). ${#_n_a_m_e[_s_u_b_s_c_r_i_p_t]} expands to the length of ${_n_a_m_e[_s_u_b_- + _s_c_r_i_p_t]}. If _s_u_b_s_c_r_i_p_t is ** or @@, the expansion is the number of ele- + ments in the array. If the _s_u_b_s_c_r_i_p_t used to reference an element of + an indexed array evaluates to a number less than zero, it is inter- + preted as relative to one greater than the maximum index of the array, + so negative indices count back from the end of the array, and an index + of -1 references the last element. + + Referencing an array variable without a subscript is equivalent to ref- + erencing the array with a subscript of 0. Any reference to a variable + using a valid subscript is legal, and bbaasshh will create an array if nec- + essary. + + An array variable is considered set if a subscript has been assigned a + value. The null string is a valid value. + + It is possible to obtain the keys (indices) of an array as well as the + values. ${!!_n_a_m_e[_@]} and ${!!_n_a_m_e[_*]} expand to the indices assigned in + array variable _n_a_m_e. The treatment when in double quotes is similar to + the expansion of the special parameters _@ and _* within double quotes. + + The uunnsseett builtin is used to destroy arrays. uunnsseett _n_a_m_e[_s_u_b_s_c_r_i_p_t] + destroys the array element at index _s_u_b_s_c_r_i_p_t. Negative subscripts to + indexed arrays are interpreted as described above. Care must be taken + to avoid unwanted side effects caused by pathname expansion. uunnsseett + _n_a_m_e, where _n_a_m_e is an array, or uunnsseett _n_a_m_e[_s_u_b_s_c_r_i_p_t], where _s_u_b_s_c_r_i_p_t + is ** or @@, removes the entire array. + + The ddeeccllaarree, llooccaall, and rreeaaddoonnllyy builtins each accept a --aa option to + specify an indexed array and a --AA option to specify an associative + array. If both options are supplied, --AA takes precedence. The rreeaadd + builtin accepts a --aa option to assign a list of words read from the + standard input to an array. The sseett and ddeeccllaarree builtins display array + values in a way that allows them to be reused as assignments. + +EEXXPPAANNSSIIOONN + Expansion is performed on the command line after it has been split into + words. There are seven kinds of expansion performed: _b_r_a_c_e _e_x_p_a_n_s_i_o_n, + _t_i_l_d_e _e_x_p_a_n_s_i_o_n, _p_a_r_a_m_e_t_e_r _a_n_d _v_a_r_i_a_b_l_e _e_x_p_a_n_s_i_o_n, _c_o_m_m_a_n_d _s_u_b_s_t_i_t_u_- + _t_i_o_n, _a_r_i_t_h_m_e_t_i_c _e_x_p_a_n_s_i_o_n, _w_o_r_d _s_p_l_i_t_t_i_n_g, and _p_a_t_h_n_a_m_e _e_x_p_a_n_s_i_o_n. + + The order of expansions is: brace expansion; tilde expansion, parameter + and variable expansion, arithmetic expansion, and command substitution + (done in a left-to-right fashion); word splitting; and pathname expan- + sion. + + On systems that can support it, there is an additional expansion avail- + able: _p_r_o_c_e_s_s _s_u_b_s_t_i_t_u_t_i_o_n. This is performed at the same time as + tilde, parameter, variable, and arithmetic expansion and command sub- + stitution. + + After these expansions are performed, quote characters present in the + original word are removed unless they have been quoted themselves + (_q_u_o_t_e _r_e_m_o_v_a_l). + + Only brace expansion, word splitting, and pathname 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 "$$@@" and "$${{_n_a_m_e[[@@]]}}" as explained above (see PPAARRAAMMEETTEERRSS). + + BBrraaccee EExxppaannssiioonn + _B_r_a_c_e _e_x_p_a_n_s_i_o_n is a mechanism by which arbitrary strings may be gener- + ated. This mechanism is similar to _p_a_t_h_n_a_m_e _e_x_p_a_n_s_i_o_n, but the file- + names generated need not exist. Patterns to be brace expanded take the + form of an optional _p_r_e_a_m_b_l_e, followed by either a series of comma-sep- + arated strings or a sequence expression between a pair of braces, fol- + lowed by an optional _p_o_s_t_s_c_r_i_p_t. 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, + a{{d,c,b}}e expands into `ade ace abe'. + + A sequence expression takes the form {{_x...._y[[...._i_n_c_r]]}}, where _x and _y are + either integers or single characters, and _i_n_c_r, an optional increment, + is an integer. When integers are supplied, the expression expands to + each number between _x and _y, inclusive. Supplied integers may be pre- + fixed with _0 to force each term to have the same width. When either _x + or _y begins with a zero, the shell attempts to force all generated + terms to contain the same number of digits, zero-padding where neces- + sary. When characters are supplied, the expression expands to each + character lexicographically between _x and _y, inclusive, using the + default C locale. Note that both _x and _y must be of the same type. + When the increment is supplied, it is used as the difference between + each term. The default increment is 1 or -1 as appropriate. + + Brace expansion is performed before any other expansions, and any char- + acters special to other expansions are preserved in the result. It is + strictly textual. BBaasshh does not apply any syntactic interpretation to + the context of the expansion or the text between the braces. + + 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 ,, may be quoted with a backslash to prevent its being considered + part of a brace expression. To avoid conflicts with parameter expan- + sion, the string $${{ 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: + + mkdir /usr/local/src/bash/{old,new,dist,bugs} + or + chown root /usr/{ucb/{ex,edit},lib/{ex?.?*,how_ex}} + + Brace expansion introduces a slight incompatibility with historical + versions of sshh. sshh does not treat opening or closing braces specially + when they appear as part of a word, and preserves them in the output. + BBaasshh removes braces from words as a consequence of brace expansion. + For example, a word entered to sshh as _f_i_l_e_{_1_,_2_} appears identically in + the output. The same word is output as _f_i_l_e_1 _f_i_l_e_2 after expansion by + bbaasshh. If strict compatibility with sshh is desired, start bbaasshh with the + ++BB option or disable brace expansion with the ++BB option to the sseett com- + mand (see SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS below). + + TTiillddee EExxppaannssiioonn + If a word begins with an unquoted tilde character (`~~'), all of the + characters preceding the first unquoted slash (or all characters, if + there is no unquoted slash) are considered a _t_i_l_d_e_-_p_r_e_f_i_x. 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 _l_o_g_i_n _n_a_m_e. + If this login name is the null string, the tilde is replaced with the + value of the shell parameter HHOOMMEE. If HHOOMMEE is unset, the home direc- + tory of the user executing the shell is substituted instead. Other- + wise, the tilde-prefix is replaced with the home directory associated + with the specified login name. + + If the tilde-prefix is a `~+', the value of the shell variable PPWWDD + replaces the tilde-prefix. If the tilde-prefix is a `~-', the value of + the shell variable OOLLDDPPWWDD, if it is set, is substituted. If the char- + acters following the tilde in the tilde-prefix consist of a number _N, + optionally prefixed by a `+' or a `-', the tilde-prefix is replaced + with the corresponding element from the directory stack, as it would be + displayed by the ddiirrss builtin invoked with the tilde-prefix as an argu- + ment. If the characters following the tilde in the tilde-prefix con- + sist of a number without a leading `+' or `-', `+' is assumed. + + If the login name is invalid, or the tilde expansion fails, the word is + unchanged. + + Each variable assignment is checked for unquoted tilde-prefixes immedi- + ately following a :: or the first ==. In these cases, tilde expansion is + also performed. Consequently, one may use filenames with tildes in + assignments to PPAATTHH, MMAAIILLPPAATTHH, and CCDDPPAATTHH, and the shell assigns the + expanded value. + + PPaarraammeetteerr EExxppaannssiioonn + The `$$' 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 `}}' not + escaped by a backslash or within a quoted string, and not within an + embedded arithmetic expansion, command substitution, or parameter + expansion. + + ${_p_a_r_a_m_e_t_e_r} + The value of _p_a_r_a_m_e_t_e_r is substituted. The braces are required + when _p_a_r_a_m_e_t_e_r is a positional parameter with more than one + digit, or when _p_a_r_a_m_e_t_e_r is followed by a character which is not + to be interpreted as part of its name. The _p_a_r_a_m_e_t_e_r is a shell + parameter as described above PPAARRAAMMEETTEERRSS) or an array reference + (AArrrraayyss). + + If the first character of _p_a_r_a_m_e_t_e_r is an exclamation point (!!), and + _p_a_r_a_m_e_t_e_r is not a _n_a_m_e_r_e_f, it introduces a level of variable indirec- + tion. BBaasshh uses the value of the variable formed from the rest of + _p_a_r_a_m_e_t_e_r 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 _p_a_r_a_m_e_t_e_r itself. This is known as _i_n_d_i_r_e_c_t _e_x_p_a_n_s_i_o_n. If + _p_a_r_a_m_e_t_e_r is a nameref, this expands to the name of the variable refer- + enced by _p_a_r_a_m_e_t_e_r instead of performing the complete indirect expan- + sion. The exceptions to this are the expansions of ${!!_p_r_e_f_i_x**} and + ${!!_n_a_m_e[_@]} described below. The exclamation point must immediately + follow the left brace in order to introduce indirection. + + In each of the cases below, _w_o_r_d is subject to tilde expansion, parame- + ter expansion, command substitution, and arithmetic expansion. + + When not performing substring expansion, using the forms documented + below (e.g., ::--), bbaasshh tests for a parameter that is unset or null. + Omitting the colon results in a test only for a parameter that is + unset. + + ${_p_a_r_a_m_e_t_e_r::--_w_o_r_d} + UUssee DDeeffaauulltt VVaalluueess. If _p_a_r_a_m_e_t_e_r is unset or null, the expan- + sion of _w_o_r_d is substituted. Otherwise, the value of _p_a_r_a_m_e_t_e_r + is substituted. + ${_p_a_r_a_m_e_t_e_r::==_w_o_r_d} + AAssssiiggnn DDeeffaauulltt VVaalluueess. If _p_a_r_a_m_e_t_e_r is unset or null, the + expansion of _w_o_r_d is assigned to _p_a_r_a_m_e_t_e_r. The value of _p_a_r_a_m_- + _e_t_e_r is then substituted. Positional parameters and special + parameters may not be assigned to in this way. + ${_p_a_r_a_m_e_t_e_r::??_w_o_r_d} + DDiissppllaayy EErrrroorr iiff NNuullll oorr UUnnsseett. If _p_a_r_a_m_e_t_e_r is null or unset, + the expansion of _w_o_r_d (or a message to that effect if _w_o_r_d is + not present) is written to the standard error and the shell, if + it is not interactive, exits. Otherwise, the value of _p_a_r_a_m_e_t_e_r + is substituted. + ${_p_a_r_a_m_e_t_e_r::++_w_o_r_d} + UUssee AAlltteerrnnaattee VVaalluuee. If _p_a_r_a_m_e_t_e_r is null or unset, nothing is + substituted, otherwise the expansion of _w_o_r_d is substituted. + ${_p_a_r_a_m_e_t_e_r::_o_f_f_s_e_t} + ${_p_a_r_a_m_e_t_e_r::_o_f_f_s_e_t::_l_e_n_g_t_h} + SSuubbssttrriinngg EExxppaannssiioonn. Expands to up to _l_e_n_g_t_h characters of the + value of _p_a_r_a_m_e_t_e_r starting at the character specified by _o_f_f_- + _s_e_t. If _p_a_r_a_m_e_t_e_r is @@, an indexed array subscripted by @@ or **, + or an associative array name, the results differ as described + below. If _l_e_n_g_t_h is omitted, expands to the substring of the + value of _p_a_r_a_m_e_t_e_r starting at the character specified by _o_f_f_s_e_t + and extending to the end of the value. _l_e_n_g_t_h and _o_f_f_s_e_t are + arithmetic expressions (see AARRIITTHHMMEETTIICC EEVVAALLUUAATTIIOONN below). + + If _o_f_f_s_e_t evaluates to a number less than zero, the value is + used as an offset in characters from the end of the value of + _p_a_r_a_m_e_t_e_r. If _l_e_n_g_t_h evaluates to a number less than zero, it + is interpreted as an offset in characters from the end of the + value of _p_a_r_a_m_e_t_e_r rather than a number of characters, and the + expansion is the characters between _o_f_f_s_e_t and that result. + Note that a negative offset must be separated from the colon by + at least one space to avoid being confused with the ::-- expan- + sion. + + If _p_a_r_a_m_e_t_e_r is @@, the result is _l_e_n_g_t_h positional parameters + beginning at _o_f_f_s_e_t. A negative _o_f_f_s_e_t is taken relative to one + greater than the greatest positional parameter, so an offset of + -1 evaluates to the last positional parameter. It is an expan- + sion error if _l_e_n_g_t_h evaluates to a number less than zero. + + If _p_a_r_a_m_e_t_e_r is an indexed array name subscripted by @ or *, the + result is the _l_e_n_g_t_h members of the array beginning with + ${_p_a_r_a_m_e_t_e_r[_o_f_f_s_e_t]}. A negative _o_f_f_s_e_t is taken relative to + one greater than the maximum index of the specified array. It + is an expansion error if _l_e_n_g_t_h evaluates to a number less than + zero. + + Substring expansion applied to an associative array produces + undefined results. + + Substring indexing is zero-based unless the positional parame- + ters are used, in which case the indexing starts at 1 by + default. If _o_f_f_s_e_t is 0, and the positional parameters are + used, $$00 is prefixed to the list. + + ${!!_p_r_e_f_i_x**} + ${!!_p_r_e_f_i_x@@} + NNaammeess mmaattcchhiinngg pprreeffiixx. Expands to the names of variables whose + names begin with _p_r_e_f_i_x, separated by the first character of the + IIFFSS special variable. When _@ is used and the expansion appears + within double quotes, each variable name expands to a separate + word. + + ${!!_n_a_m_e[_@]} + ${!!_n_a_m_e[_*]} + LLiisstt ooff aarrrraayy kkeeyyss. If _n_a_m_e is an array variable, expands to + the list of array indices (keys) assigned in _n_a_m_e. If _n_a_m_e is + not an array, expands to 0 if _n_a_m_e is set and null otherwise. + When _@ is used and the expansion appears within double quotes, + each key expands to a separate word. + + ${##_p_a_r_a_m_e_t_e_r} + PPaarraammeetteerr lleennggtthh. The length in characters of the value of + _p_a_r_a_m_e_t_e_r is substituted. If _p_a_r_a_m_e_t_e_r is ** or @@, the value + substituted is the number of positional parameters. If _p_a_r_a_m_e_- + _t_e_r is an array name subscripted by ** or @@, the value substi- + tuted is the number of elements in the array. If _p_a_r_a_m_e_t_e_r is + an indexed array name subscripted by a negative number, that + number is interpreted as relative to one greater than the maxi- + mum index of _p_a_r_a_m_e_t_e_r, so negative indices count back from the + end of the array, and an index of -1 references the last ele- + ment. + + ${_p_a_r_a_m_e_t_e_r##_w_o_r_d} + ${_p_a_r_a_m_e_t_e_r####_w_o_r_d} + RReemmoovvee mmaattcchhiinngg pprreeffiixx ppaatttteerrnn. The _w_o_r_d is expanded to produce + a pattern just as in pathname expansion. If the pattern matches + the beginning of the value of _p_a_r_a_m_e_t_e_r, then the result of the + expansion is the expanded value of _p_a_r_a_m_e_t_e_r with the shortest + matching pattern (the ``##'' case) or the longest matching pat- + tern (the ``####'' case) deleted. If _p_a_r_a_m_e_t_e_r is @@ or **, the + pattern removal operation is applied to each positional parame- + ter in turn, and the expansion is the resultant list. If _p_a_r_a_m_- + _e_t_e_r is an array variable subscripted with @@ or **, the pattern + removal operation is applied to each member of the array in + turn, and the expansion is the resultant list. + + ${_p_a_r_a_m_e_t_e_r%%_w_o_r_d} + ${_p_a_r_a_m_e_t_e_r%%%%_w_o_r_d} + RReemmoovvee mmaattcchhiinngg ssuuffffiixx ppaatttteerrnn. The _w_o_r_d is expanded to produce + a pattern just as in pathname expansion. If the pattern matches + a trailing portion of the expanded value of _p_a_r_a_m_e_t_e_r, then the + result of the expansion is the expanded value of _p_a_r_a_m_e_t_e_r with + the shortest matching pattern (the ``%%'' case) or the longest + matching pattern (the ``%%%%'' case) deleted. If _p_a_r_a_m_e_t_e_r is @@ + or **, the pattern removal operation is applied to each posi- + tional parameter in turn, and the expansion is the resultant + list. If _p_a_r_a_m_e_t_e_r is an array variable subscripted with @@ or + **, the pattern removal operation is applied to each member of + the array in turn, and the expansion is the resultant list. + + ${_p_a_r_a_m_e_t_e_r//_p_a_t_t_e_r_n//_s_t_r_i_n_g} + PPaatttteerrnn ssuubbssttiittuuttiioonn. The _p_a_t_t_e_r_n is expanded to produce a pat- + tern just as in pathname expansion. _P_a_r_a_m_e_t_e_r is expanded and + the longest match of _p_a_t_t_e_r_n against its value is replaced with + _s_t_r_i_n_g. If _p_a_t_t_e_r_n begins with //, all matches of _p_a_t_t_e_r_n are + replaced with _s_t_r_i_n_g. Normally only the first match is + replaced. If _p_a_t_t_e_r_n begins with ##, it must match at the begin- + ning of the expanded value of _p_a_r_a_m_e_t_e_r. If _p_a_t_t_e_r_n begins with + %%, it must match at the end of the expanded value of _p_a_r_a_m_e_t_e_r. + If _s_t_r_i_n_g is null, matches of _p_a_t_t_e_r_n are deleted and the // fol- + lowing _p_a_t_t_e_r_n may be omitted. If the nnooccaasseemmaattcchh shell option + is enabled, the match is performed without regard to the case of + alphabetic characters. If _p_a_r_a_m_e_t_e_r is @@ or **, the substitution + operation is applied to each positional parameter in turn, and + the expansion is the resultant list. If _p_a_r_a_m_e_t_e_r is an array + variable subscripted with @@ or **, the substitution operation is + applied to each member of the array in turn, and the expansion + is the resultant list. + + ${_p_a_r_a_m_e_t_e_r^^_p_a_t_t_e_r_n} + ${_p_a_r_a_m_e_t_e_r^^^^_p_a_t_t_e_r_n} + ${_p_a_r_a_m_e_t_e_r,,_p_a_t_t_e_r_n} + ${_p_a_r_a_m_e_t_e_r,,,,_p_a_t_t_e_r_n} + CCaassee mmooddiiffiiccaattiioonn. This expansion modifies the case of alpha- + betic characters in _p_a_r_a_m_e_t_e_r. The _p_a_t_t_e_r_n is expanded to pro- + duce a pattern just as in pathname expansion. Each character in + the expanded value of _p_a_r_a_m_e_t_e_r is tested against _p_a_t_t_e_r_n, and, + if it matches the pattern, its case is converted. The pattern + should not attempt to match more than one character. The ^^ + operator converts lowercase letters matching _p_a_t_t_e_r_n to upper- + case; the ,, operator converts matching uppercase letters to low- + ercase. The ^^^^ and ,,,, expansions convert each matched character + in the expanded value; the ^^ and ,, expansions match and convert + only the first character in the expanded value. If _p_a_t_t_e_r_n is + omitted, it is treated like a ??, which matches every character. + If _p_a_r_a_m_e_t_e_r is @@ or **, the case modification operation is + applied to each positional parameter in turn, and the expansion + is the resultant list. If _p_a_r_a_m_e_t_e_r is an array variable sub- + scripted with @@ or **, the case modification operation is applied + to each member of the array in turn, and the expansion is the + resultant list. + + ${_p_a_r_a_m_e_t_e_r@@_o_p_e_r_a_t_o_r} + PPaarraammeetteerr ttrraannssffoorrmmaattiioonn. The expansion is either a transforma- + tion of the value of _p_a_r_a_m_e_t_e_r or information about _p_a_r_a_m_e_t_e_r + itself, depending on the value of _o_p_e_r_a_t_o_r. Each _o_p_e_r_a_t_o_r is a + single letter: + + QQ The expansion is a string that is the value of _p_a_r_a_m_e_t_e_r + quoted in a format that can be reused as input. + EE The expansion is a string that is the value of _p_a_r_a_m_e_t_e_r + with backslash escape sequences expanded as with the + $$''......'' quoting mechansim. + PP The expansion is a string that is the result of expanding + the value of _p_a_r_a_m_e_t_e_r as if it were a prompt string (see + PPRROOMMPPTTIINNGG below). + AA The expansion is a string in the form of an assignment + statement or ddeeccllaarree command that, if evaluated, will + recreate _p_a_r_a_m_e_t_e_r with its attributes and value. + aa The expansion is a string consisting of flag values rep- + resenting _p_a_r_a_m_e_t_e_r's attributes. + + If _p_a_r_a_m_e_t_e_r is @@ or **, the operation is applied to each posi- + tional parameter in turn, and the expansion is the resultant + list. If _p_a_r_a_m_e_t_e_r is an array variable subscripted with @@ or + **, the case modification operation is applied to each member of + the array in turn, and the expansion is the resultant list. + + The result of the expansion is subject to word splitting and + pathname expansion as described below. + + CCoommmmaanndd SSuubbssttiittuuttiioonn + _C_o_m_m_a_n_d _s_u_b_s_t_i_t_u_t_i_o_n allows the output of a command to replace the com- + mand name. There are two forms: + + $$((_c_o_m_m_a_n_d)) + or + ``_c_o_m_m_a_n_d`` + + BBaasshh performs the expansion by executing _c_o_m_m_a_n_d in a subshell environ- + ment 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 com- + mand substitution $$((ccaatt _f_i_l_e)) can be replaced by the equivalent but + faster $$((<< _f_i_l_e)). + + When the old-style backquote form of substitution is used, backslash + retains its literal meaning except when followed by $$, ``, or \\. The + first backquote not preceded by a backslash terminates the command sub- + stitution. When using the $(_c_o_m_m_a_n_d) 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 + pathname expansion are not performed on the results. + + AArriitthhmmeettiicc EExxppaannssiioonn + Arithmetic expansion allows the evaluation of an arithmetic expression + and the substitution of the result. The format for arithmetic expan- + sion is: + + $$((((_e_x_p_r_e_s_s_i_o_n)))) + + The _e_x_p_r_e_s_s_i_o_n 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 and variable expansion, com- + mand substitution, and quote removal. The result is treated as the + arithmetic expression to be evaluated. Arithmetic expansions may be + nested. + + The evaluation is performed according to the rules listed below under + AARRIITTHHMMEETTIICC EEVVAALLUUAATTIIOONN. If _e_x_p_r_e_s_s_i_o_n is invalid, bbaasshh prints a message + indicating failure and no substitution occurs. + + PPrroocceessss SSuubbssttiittuuttiioonn + _P_r_o_c_e_s_s _s_u_b_s_t_i_t_u_t_i_o_n allows a process's input or output to be referred + to using a filename. It takes the form of <<((_l_i_s_t)) or >>((_l_i_s_t)). The + process _l_i_s_t is run asynchronously, and its input or output appears as + a filename. This filename is passed as an argument to the current com- + mand as the result of the expansion. If the >>((_l_i_s_t)) form is used, + writing to the file will provide input for _l_i_s_t. If the <<((_l_i_s_t)) form + is used, the file passed as an argument should be read to obtain the + output of _l_i_s_t. Process substitution is supported on systems that sup- + port named pipes (_F_I_F_O_s) or the //ddeevv//ffdd method of naming open files. + + When available, process substitution is performed simultaneously with + parameter and variable expansion, command substitution, and arithmetic + expansion. + + WWoorrdd SSpplliittttiinngg + The shell scans the results of parameter expansion, command substitu- + tion, and arithmetic expansion that did not occur within double quotes + for _w_o_r_d _s_p_l_i_t_t_i_n_g. + + The shell treats each character of IIFFSS as a delimiter, and splits the + results of the other expansions into words using these characters as + field terminators. If IIFFSS is unset, or its value is exactly + <><><>, the default, then sequences of <>, <>, + and <> at the beginning and end of the results of the previous + expansions are ignored, and any sequence of IIFFSS characters not at the + beginning or end serves to delimit words. If IIFFSS has a value other + than the default, then sequences of the whitespace characters ssppaaccee, + ttaabb, and nneewwlliinnee are ignored at the beginning and end of the word, as + long as the whitespace character is in the value of IIFFSS (an IIFFSS white- + space character). Any character in IIFFSS that is not IIFFSS whitespace, + along with any adjacent IIFFSS whitespace characters, delimits a field. A + sequence of IIFFSS whitespace characters is also treated as a delimiter. + If the value of IIFFSS is null, no word splitting occurs. + + Explicit null arguments ("""" or '''') are retained and passed to commands + as empty strings. Unquoted implicit null arguments, resulting from the + expansion of parameters that have no values, are removed. If a parame- + ter with no value is expanded within double quotes, a null argument + results and is retained and passed to a command as an empty string. + When a quoted null argument appears as part of a word whose expansion + is non-null, the null argument is removed. That is, the word -d'' + becomes -d after word splitting and null argument removal. + + Note that if no expansion occurs, no splitting is performed. + + PPaatthhnnaammee EExxppaannssiioonn + After word splitting, unless the --ff option has been set, bbaasshh scans + each word for the characters **, ??, and [[. If one of these characters + appears, then the word is regarded as a _p_a_t_t_e_r_n, and replaced with an + alphabetically sorted list of filenames matching the pattern (see PPaatt-- + tteerrnn MMaattcchhiinngg below). If no matching filenames are found, and the + shell option nnuullllgglloobb is not enabled, the word is left unchanged. If + the nnuullllgglloobb option is set, and no matches are found, the word is + removed. If the ffaaiillgglloobb shell option is set, and no matches are + found, an error message is printed and the command is not executed. If + the shell option nnooccaasseegglloobb is enabled, the match is performed without + regard to the case of alphabetic characters. When a pattern is used + for pathname expansion, the character ````..'''' at the start of a name or + immediately following a slash must be matched explicitly, unless the + shell option ddoottgglloobb is set. When matching a pathname, the slash char- + acter must always be matched explicitly. In other cases, the ````..'''' + character is not treated specially. See the description of sshhoopptt below + under SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS for a description of the nnooccaasseegglloobb, nnuullll-- + gglloobb, ffaaiillgglloobb, and ddoottgglloobb shell options. + + The GGLLOOBBIIGGNNOORREE shell variable may be used to restrict the set of file- + names matching a _p_a_t_t_e_r_n. If GGLLOOBBIIGGNNOORREE is set, each matching filename + that also matches one of the patterns in GGLLOOBBIIGGNNOORREE is removed from the + list of matches. If the nnooccaasseegglloobb option is set, the matching against + the patterns in GGLLOOBBIIGGNNOORREE is performed without regard to case. The + filenames ````..'''' and ````....'''' are always ignored when GGLLOOBBIIGGNNOORREE is set + and not null. However, setting GGLLOOBBIIGGNNOORREE to a non-null value has the + effect of enabling the ddoottgglloobb shell option, so all other filenames + beginning with a ````..'''' will match. To get the old behavior of ignor- + ing filenames beginning with a ````..'''', make ````..**'''' one of the patterns + in GGLLOOBBIIGGNNOORREE. The ddoottgglloobb option is disabled when GGLLOOBBIIGGNNOORREE is + unset. The pattern matching honors the setting of the eexxttgglloobb shell + option. + + PPaatttteerrnn MMaattcchhiinngg + + Any character that appears in a pattern, other than the special pattern + characters described below, matches itself. The 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: + + ** Matches any string, including the null string. When the + gglloobbssttaarr shell option is enabled, and ** is used in a + pathname expansion context, two adjacent **s used as a + single pattern will match all files and zero or more + directories and subdirectories. If followed by a //, two + adjacent **s will match only directories and subdirecto- + ries. + ?? Matches any single character. + [[......]] Matches any one of the enclosed characters. A pair of + characters separated by a hyphen denotes a _r_a_n_g_e _e_x_p_r_e_s_- + _s_i_o_n; any character that falls between those two charac- + ters, inclusive, using the current locale's collating + sequence and character set, is matched. If the first + character following the [[ is a !! or a ^^ then any charac- + ter not enclosed is matched. The sorting order of char- + acters in range expressions is determined by the current + locale and the values of the LLCC__CCOOLLLLAATTEE or LLCC__AALLLL shell + variables, if set. To obtain the traditional interpreta- + tion of range expressions, where [[aa--dd]] is equivalent to + [[aabbccdd]], set value of the LLCC__AALLLL shell variable to CC, or + enable the gglloobbaasscciiiirraannggeess shell option. A -- may be + matched by including it as the first or last character in + the set. A ]] may be matched by including it as the first + character in the set. + + Within [[ and ]], _c_h_a_r_a_c_t_e_r _c_l_a_s_s_e_s can be specified using + the syntax [[::_c_l_a_s_s::]], where _c_l_a_s_s is one of the following + classes defined in the POSIX standard: + aallnnuumm aallpphhaa aasscciiii bbllaannkk ccnnttrrll ddiiggiitt ggrraapphh lloowweerr pprriinntt + ppuunncctt ssppaaccee uuppppeerr wwoorrdd xxddiiggiitt + A character class matches any character belonging to that + class. The wwoorrdd character class matches letters, digits, + and the character _. + + Within [[ and ]], an _e_q_u_i_v_a_l_e_n_c_e _c_l_a_s_s can be specified + using the syntax [[==_c==]], which matches all characters with + the same collation weight (as defined by the current + locale) as the character _c. + + Within [[ and ]], the syntax [[.._s_y_m_b_o_l..]] matches the collat- + ing symbol _s_y_m_b_o_l. + + If the eexxttgglloobb shell option is enabled using the sshhoopptt builtin, several + extended pattern matching operators are recognized. In the following + description, a _p_a_t_t_e_r_n_-_l_i_s_t is a list of one or more patterns separated + by a ||. Composite patterns may be formed using one or more of the fol- + lowing sub-patterns: + + ??((_p_a_t_t_e_r_n_-_l_i_s_t)) + Matches zero or one occurrence of the given patterns + **((_p_a_t_t_e_r_n_-_l_i_s_t)) + Matches zero or more occurrences of the given patterns + ++((_p_a_t_t_e_r_n_-_l_i_s_t)) + Matches one or more occurrences of the given patterns + @@((_p_a_t_t_e_r_n_-_l_i_s_t)) + Matches one of the given patterns + !!((_p_a_t_t_e_r_n_-_l_i_s_t)) + Matches anything except one of the given patterns + + QQuuoottee RReemmoovvaall + After the preceding expansions, all unquoted occurrences of the charac- + ters \\, '', and "" that did not result from one of the above expansions + are removed. + +RREEDDIIRREECCTTIIOONN + Before a command is executed, its input and output may be _r_e_d_i_r_e_c_t_e_d + using a special notation interpreted by the shell. Redirection allows + commands' file handles to be duplicated, opened, closed, made to refer + to different files, and can change the files the command reads from and + writes to. Redirection may also be used to modify file handles in the + current shell execution environment. The following redirection opera- + tors may precede or appear anywhere within a _s_i_m_p_l_e _c_o_m_m_a_n_d or may fol- + low a _c_o_m_m_a_n_d. Redirections are processed in the order they appear, + from left to right. + + Each redirection that may be preceded by a file descriptor number may + instead be preceded by a word of the form {_v_a_r_n_a_m_e}. In this case, for + each redirection operator except >&- and <&-, the shell will allocate a + file descriptor greater than or equal to 10 and assign it to _v_a_r_n_a_m_e. + If >&- or <&- is preceded by {_v_a_r_n_a_m_e}, the value of _v_a_r_n_a_m_e defines + the file descriptor to close. + + In the following descriptions, if the file descriptor number is omit- + ted, and the first character of the redirection operator is <<, the re- + direction refers to the standard input (file descriptor 0). If the + first character of the redirection operator is >>, the redirection + refers to the standard output (file descriptor 1). + + The word following the redirection operator in the following descrip- + tions, unless otherwise noted, is subjected to brace expansion, tilde + expansion, parameter and variable expansion, command substitution, + arithmetic expansion, quote removal, pathname expansion, and word + splitting. If it expands to more than one word, bbaasshh reports an error. + + Note that the order of redirections is significant. For example, the + command + + ls >> dirlist 2>>&&1 + + directs both standard output and standard error to the file _d_i_r_l_i_s_t, + while the command + + ls 2>>&&1 >> dirlist + + directs only the standard output to file _d_i_r_l_i_s_t, because the standard + error was duplicated from the standard output before the standard out- + put was redirected to _d_i_r_l_i_s_t. + + BBaasshh handles several filenames specially when they are used in redirec- + tions, as described in the following table. If the operating system on + which bbaasshh is running provides these special files, bash will use them; + otherwise it will emulate them internally with the behavior described + below. + + //ddeevv//ffdd//_f_d + If _f_d is a valid integer, file descriptor _f_d is dupli- + cated. + //ddeevv//ssttddiinn + File descriptor 0 is duplicated. + //ddeevv//ssttddoouutt + File descriptor 1 is duplicated. + //ddeevv//ssttddeerrrr + File descriptor 2 is duplicated. + //ddeevv//ttccpp//_h_o_s_t//_p_o_r_t + If _h_o_s_t is a valid hostname or Internet address, and _p_o_r_t + is an integer port number or service name, bbaasshh attempts + to open the corresponding TCP socket. + //ddeevv//uuddpp//_h_o_s_t//_p_o_r_t + If _h_o_s_t is a valid hostname or Internet address, and _p_o_r_t + is an integer port number or service name, bbaasshh attempts + to open the corresponding UDP 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 inter- + nally. + + RReeddiirreeccttiinngg IInnppuutt + Redirection of input causes the file whose name results from the expan- + sion of _w_o_r_d to be opened for reading on file descriptor _n, or the + standard input (file descriptor 0) if _n is not specified. + + The general format for redirecting input is: + + [_n]<<_w_o_r_d + + RReeddiirreeccttiinngg OOuuttppuutt + Redirection of output causes the file whose name results from the + expansion of _w_o_r_d to be opened for writing on file descriptor _n, or the + standard output (file descriptor 1) if _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: + + [_n]>>_w_o_r_d + + If the redirection operator is >>, and the nnoocclloobbbbeerr option to the sseett + builtin has been enabled, the redirection will fail if the file whose + name results from the expansion of _w_o_r_d exists and is a regular file. + If the redirection operator is >>||, or the redirection operator is >> and + the nnoocclloobbbbeerr option to the sseett builtin command is not enabled, the re- + direction is attempted even if the file named by _w_o_r_d exists. + + AAppppeennddiinngg RReeddiirreecctteedd OOuuttppuutt + Redirection of output in this fashion causes the file whose name + results from the expansion of _w_o_r_d to be opened for appending on file + descriptor _n, or the standard output (file descriptor 1) if _n is not + specified. If the file does not exist it is created. + + The general format for appending output is: + + [_n]>>>>_w_o_r_d + + RReeddiirreeccttiinngg SSttaannddaarrdd OOuuttppuutt aanndd SSttaannddaarrdd EErrrroorr + This construct 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 _w_o_r_d. + + There are two formats for redirecting standard output and standard + error: + + &&>>_w_o_r_d + and + >>&&_w_o_r_d + + Of the two forms, the first is preferred. This is semantically equiva- + lent to + + >>_w_o_r_d 2>>&&1 + + When using the second form, _w_o_r_d may not expand to a number or --. If + it does, other redirection operators apply (see DDuupplliiccaattiinngg FFiillee + DDeessccrriippttoorrss below) for compatibility reasons. + + AAppppeennddiinngg SSttaannddaarrdd OOuuttppuutt aanndd SSttaannddaarrdd EErrrroorr + This construct allows both the standard output (file descriptor 1) and + the standard error output (file descriptor 2) to be appended to the + file whose name is the expansion of _w_o_r_d. + + The format for appending standard output and standard error is: + + &&>>>>_w_o_r_d + + This is semantically equivalent to + + >>>>_w_o_r_d 2>>&&1 + + (see DDuupplliiccaattiinngg FFiillee DDeessccrriippttoorrss below). + + HHeerree DDooccuummeennttss + This type of redirection instructs the shell to read input from the + current source until a line containing only _d_e_l_i_m_i_t_e_r (with no trailing + blanks) is seen. All of the lines read up to that point are then used + as the standard input (or file descriptor _n if _n is specified) for a + command. + + The format of here-documents is: + + [_n]<<<<[--]_w_o_r_d + _h_e_r_e_-_d_o_c_u_m_e_n_t + _d_e_l_i_m_i_t_e_r + + No parameter and variable expansion, command substitution, arithmetic + expansion, or pathname expansion is performed on _w_o_r_d. If any part of + _w_o_r_d is quoted, the _d_e_l_i_m_i_t_e_r is the result of quote removal on _w_o_r_d, + and the lines in the here-document are not expanded. If _w_o_r_d is + unquoted, all lines of the here-document are subjected to parameter + expansion, command substitution, and arithmetic expansion, the charac- + ter sequence \\<> is ignored, and \\ must be used to quote the + characters \\, $$, and ``. + + If the redirection operator is <<<<--, then all leading tab characters are + stripped from input lines and the line containing _d_e_l_i_m_i_t_e_r. This + allows here-documents within shell scripts to be indented in a natural + fashion. + + HHeerree SSttrriinnggss + A variant of here documents, the format is: + + [_n]<<<<<<_w_o_r_d + + The _w_o_r_d undergoes brace expansion, tilde expansion, parameter and + variable expansion, command substitution, arithmetic expansion, and + quote removal. Pathname expansion and word splitting are not per- + formed. The result is supplied as a single string, with a newline + appended, to the command on its standard input (or file descriptor _n if + _n is specified). + + DDuupplliiccaattiinngg FFiillee DDeessccrriippttoorrss + The redirection operator + + [_n]<<&&_w_o_r_d + + is used to duplicate input file descriptors. If _w_o_r_d expands to one or + more digits, the file descriptor denoted by _n is made to be a copy of + that file descriptor. If the digits in _w_o_r_d do not specify a file + descriptor open for input, a redirection error occurs. If _w_o_r_d evalu- + ates to --, file descriptor _n is closed. If _n is not specified, the + standard input (file descriptor 0) is used. + + The operator + + [_n]>>&&_w_o_r_d + + is used similarly to duplicate output file descriptors. If _n is not + specified, the standard output (file descriptor 1) is used. If the + digits in _w_o_r_d do not specify a file descriptor open for output, a re- + direction error occurs. If _w_o_r_d evaluates to --, file descriptor _n is + closed. As a special case, if _n is omitted, and _w_o_r_d does not expand + to one or more digits or --, the standard output and standard error are + redirected as described previously. + + MMoovviinngg FFiillee DDeessccrriippttoorrss + The redirection operator + + [_n]<<&&_d_i_g_i_t-- + + moves the file descriptor _d_i_g_i_t to file descriptor _n, or the standard + input (file descriptor 0) if _n is not specified. _d_i_g_i_t is closed after + being duplicated to _n. + + Similarly, the redirection operator + + [_n]>>&&_d_i_g_i_t-- + + moves the file descriptor _d_i_g_i_t to file descriptor _n, or the standard + output (file descriptor 1) if _n is not specified. + + OOppeenniinngg FFiillee DDeessccrriippttoorrss ffoorr RReeaaddiinngg aanndd WWrriittiinngg + The redirection operator + + [_n]<<>>_w_o_r_d + + causes the file whose name is the expansion of _w_o_r_d to be opened for + both reading and writing on file descriptor _n, or on file descriptor 0 + if _n is not specified. If the file does not exist, it is created. + +AALLIIAASSEESS + _A_l_i_a_s_e_s 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 aalliiaass and uunnaalliiaass builtin + commands (see SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS below). 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 //, + $$, ``, and == and any of the shell _m_e_t_a_c_h_a_r_a_c_t_e_r_s 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 llss to llss --FF, for instance, and + bbaasshh does not try to recursively expand the replacement text. If the + last character of the alias value is a _b_l_a_n_k, then the next command + word following the alias is also checked for alias expansion. + + Aliases are created and listed with the aalliiaass command, and removed with + the uunnaalliiaass command. + + There is no mechanism for using arguments in the replacement text. If + arguments are needed, a shell function should be used (see FFUUNNCCTTIIOONNSS + below). + + Aliases are not expanded when the shell is not interactive, unless the + eexxppaanndd__aalliiaasseess shell option is set using sshhoopptt (see the description of + sshhoopptt under SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS below). + + The rules concerning the definition and use of aliases are somewhat + confusing. BBaasshh 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 com- + mand. As a consequence, aliases defined in a function are not avail- + able until after that function is executed. To be safe, always put + alias definitions on a separate line, and do not use aalliiaass in compound + commands. + + For almost every purpose, aliases are superseded by shell functions. + +FFUUNNCCTTIIOONNSS + A shell function, defined as described above under SSHHEELLLL GGRRAAMMMMAARR, + stores a series of commands for later execution. 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. Functions are executed + in the context of the current shell; no new process is created to + interpret them (contrast this with the execution of a shell script). + When a function is executed, the arguments to the function become the + positional parameters during its execution. The special parameter ## is + updated to reflect the change. Special parameter 00 is unchanged. The + first element of the FFUUNNCCNNAAMMEE variable is set to the name of the func- + tion while the function is executing. + + All other aspects of the shell execution environment are identical + between a function and its caller with these exceptions: the DDEEBBUUGG and + RREETTUURRNN traps (see the description of the ttrraapp builtin under SSHHEELLLL + BBUUIILLTTIINN CCOOMMMMAANNDDSS below) are not inherited unless the function has been + given the ttrraaccee attribute (see the description of the ddeeccllaarree builtin + below) or the --oo ffuunnccttrraaccee shell option has been enabled with the sseett + builtin (in which case all functions inherit the DDEEBBUUGG and RREETTUURRNN + traps), and the EERRRR trap is not inherited unless the --oo eerrrrttrraaccee shell + option has been enabled. + + Variables local to the function may be declared with the llooccaall builtin + command. Ordinarily, variables and their values are shared between the + function and its caller. + + The FFUUNNCCNNEESSTT variable, if set to a numeric value greater than 0, + defines a maximum function nesting level. Function invocations that + exceed the limit cause the entire command to abort. + + If the builtin command rreettuurrnn is executed in a function, the function + completes and execution resumes with the next command after the func- + tion call. Any command associated with the RREETTUURRNN trap is executed + before execution resumes. When a function completes, the values of the + positional parameters and the special parameter ## are restored to the + values they had prior to the function's execution. + + Function names and definitions may be listed with the --ff option to the + ddeeccllaarree or ttyyppeesseett builtin commands. The --FF option to ddeeccllaarree or ttyyppee-- + sseett will list the function names only (and optionally the source file + and line number, if the eexxttddeebbuugg shell option is enabled). Functions + may be exported so that subshells automatically have them defined with + the --ff option to the eexxppoorrtt builtin. A function definition may be + deleted using the --ff option to the uunnsseett builtin. Note that shell + functions and variables with the same name may result in multiple iden- + tically-named entries in the environment passed to the shell's chil- + dren. Care should be taken in cases where this may cause a problem. + + Functions may be recursive. The FFUUNNCCNNEESSTT variable may be used to limit + the depth of the function call stack and restrict the number of func- + tion invocations. By default, no limit is imposed on the number of + recursive calls. + +AARRIITTHHMMEETTIICC EEVVAALLUUAATTIIOONN + The shell allows arithmetic expressions to be evaluated, under certain + circumstances (see the lleett and ddeeccllaarree builtin commands, the (((( com- + pound command, and AArriitthhmmeettiicc EExxppaannssiioonn). 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 fol- + lowing list of operators is grouped into levels of equal-precedence + operators. The levels are listed in order of decreasing precedence. + + _i_d++++ _i_d---- + variable post-increment and post-decrement + ++++_i_d ----_i_d + variable pre-increment and pre-decrement + -- ++ unary minus and plus + !! ~~ logical and bitwise negation + **** exponentiation + ** // %% multiplication, division, remainder + ++ -- addition, subtraction + <<<< >>>> left and right bitwise shifts + <<== >>== << >> + comparison + ==== !!== equality and inequality + && bitwise AND + ^^ bitwise exclusive OR + || bitwise OR + &&&& logical AND + |||| logical OR + _e_x_p_r??_e_x_p_r::_e_x_p_r + conditional operator + == **== //== %%== ++== --== <<<<== >>>>== &&== ^^== ||== + assignment + _e_x_p_r_1 ,, _e_x_p_r_2 + comma + + Shell variables are allowed as operands; parameter expansion is per- + formed 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 _i_n_t_e_g_e_r + attribute using ddeeccllaarree --ii is assigned a value. A null value evaluates + to 0. A shell variable need not have its _i_n_t_e_g_e_r attribute turned on + to be used in an expression. + + Constants with a leading 0 are interpreted as octal numbers. A leading + 0x or 0X denotes hexadecimal. Otherwise, numbers take the form + [_b_a_s_e_#]n, where the optional _b_a_s_e is a decimal number between 2 and 64 + representing the arithmetic base, and _n is a number in that base. If + _b_a_s_e_# is omitted, then base 10 is used. When specifying _n, the digits + greater than 9 are represented by the lowercase letters, the uppercase + letters, @, and _, in that order. If _b_a_s_e is less than or equal to 36, + lowercase and uppercase letters may be used interchangeably to repre- + sent 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. + +CCOONNDDIITTIIOONNAALL EEXXPPRREESSSSIIOONNSS + Conditional expressions are used by the [[[[ compound command and the + tteesstt and [[ builtin commands to test file attributes and perform string + and arithmetic comparisons. Expressions are formed from the following + unary or binary primaries. BBaasshh handles several filenames specially + when they are used in expressions. If the operating system on which + bbaasshh is running provides these special files, bash will use them; oth- + erwise it will emulate them internally with this behavior: If any _f_i_l_e + argument to one of the primaries is of the form _/_d_e_v_/_f_d_/_n, then file + descriptor _n is checked. If the _f_i_l_e argument to one of the primaries + is one of _/_d_e_v_/_s_t_d_i_n, _/_d_e_v_/_s_t_d_o_u_t, or _/_d_e_v_/_s_t_d_e_r_r, file descriptor 0, + 1, or 2, respectively, is checked. + + Unless otherwise specified, primaries that operate on files follow sym- + bolic links and operate on the target of the link, rather than the link + itself. + + When used with [[[[, the << and >> operators sort lexicographically using + the current locale. The tteesstt command sorts using ASCII ordering. + + --aa _f_i_l_e + True if _f_i_l_e exists. + --bb _f_i_l_e + True if _f_i_l_e exists and is a block special file. + --cc _f_i_l_e + True if _f_i_l_e exists and is a character special file. + --dd _f_i_l_e + True if _f_i_l_e exists and is a directory. + --ee _f_i_l_e + True if _f_i_l_e exists. + --ff _f_i_l_e + True if _f_i_l_e exists and is a regular file. + --gg _f_i_l_e + True if _f_i_l_e exists and is set-group-id. + --hh _f_i_l_e + True if _f_i_l_e exists and is a symbolic link. + --kk _f_i_l_e + True if _f_i_l_e exists and its ``sticky'' bit is set. + --pp _f_i_l_e + True if _f_i_l_e exists and is a named pipe (FIFO). + --rr _f_i_l_e + True if _f_i_l_e exists and is readable. + --ss _f_i_l_e + True if _f_i_l_e exists and has a size greater than zero. + --tt _f_d True if file descriptor _f_d is open and refers to a terminal. + --uu _f_i_l_e + True if _f_i_l_e exists and its set-user-id bit is set. + --ww _f_i_l_e + True if _f_i_l_e exists and is writable. + --xx _f_i_l_e + True if _f_i_l_e exists and is executable. + --GG _f_i_l_e + True if _f_i_l_e exists and is owned by the effective group id. + --LL _f_i_l_e + True if _f_i_l_e exists and is a symbolic link. + --NN _f_i_l_e + True if _f_i_l_e exists and has been modified since it was last + read. + --OO _f_i_l_e + True if _f_i_l_e exists and is owned by the effective user id. + --SS _f_i_l_e + True if _f_i_l_e exists and is a socket. + _f_i_l_e_1 --eeff _f_i_l_e_2 + True if _f_i_l_e_1 and _f_i_l_e_2 refer to the same device and inode num- + bers. + _f_i_l_e_1 -nntt _f_i_l_e_2 + True if _f_i_l_e_1 is newer (according to modification date) than + _f_i_l_e_2, or if _f_i_l_e_1 exists and _f_i_l_e_2 does not. + _f_i_l_e_1 -oott _f_i_l_e_2 + True if _f_i_l_e_1 is older than _f_i_l_e_2, or if _f_i_l_e_2 exists and _f_i_l_e_1 + does not. + --oo _o_p_t_n_a_m_e + True if the shell option _o_p_t_n_a_m_e is enabled. See the list of + options under the description of the --oo option to the sseett + builtin below. + --vv _v_a_r_n_a_m_e + True if the shell variable _v_a_r_n_a_m_e is set (has been assigned a + value). + --RR _v_a_r_n_a_m_e + True if the shell variable _v_a_r_n_a_m_e is set and is a name refer- + ence. + --zz _s_t_r_i_n_g + True if the length of _s_t_r_i_n_g is zero. + _s_t_r_i_n_g + --nn _s_t_r_i_n_g + True if the length of _s_t_r_i_n_g is non-zero. + + _s_t_r_i_n_g_1 ==== _s_t_r_i_n_g_2 + _s_t_r_i_n_g_1 == _s_t_r_i_n_g_2 + True if the strings are equal. == should be used with the tteesstt + command for POSIX conformance. When used with the [[[[ command, + this performs pattern matching as described above (CCoommppoouunndd CCoomm-- + mmaannddss). + + _s_t_r_i_n_g_1 !!== _s_t_r_i_n_g_2 + True if the strings are not equal. + + _s_t_r_i_n_g_1 << _s_t_r_i_n_g_2 + True if _s_t_r_i_n_g_1 sorts before _s_t_r_i_n_g_2 lexicographically. + + _s_t_r_i_n_g_1 >> _s_t_r_i_n_g_2 + True if _s_t_r_i_n_g_1 sorts after _s_t_r_i_n_g_2 lexicographically. + + _a_r_g_1 OOPP _a_r_g_2 + OOPP is one of --eeqq, --nnee, --lltt, --llee, --ggtt, or --ggee. These arithmetic + binary operators return true if _a_r_g_1 is equal to, not equal to, + less than, less than or equal to, greater than, or greater than + or equal to _a_r_g_2, respectively. _A_r_g_1 and _a_r_g_2 may be positive + or negative integers. + +SSIIMMPPLLEE CCOOMMMMAANNDD EEXXPPAANNSSIIOONN + When a simple command is executed, the shell performs the following + expansions, assignments, and redirections, from left to right. + + 1. The words that the parser has marked as variable assignments + (those preceding the command name) and redirections are saved + for later processing. + + 2. The words that are not variable assignments or redirections are + expanded. 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. + + 3. Redirections are performed as described above under RREEDDIIRREECCTTIIOONN. + + 4. The text after the == in each variable assignment undergoes tilde + expansion, parameter expansion, command substitution, arithmetic + expansion, and quote removal before being assigned to the vari- + able. + + If no command name results, the variable assignments affect the current + shell environment. Otherwise, the variables are added to the environ- + ment of the executed command and do not affect the current shell envi- + ronment. 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 expan- + sions 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. + +CCOOMMMMAANNDD EEXXEECCUUTTIIOONN + 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. + + 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 above in FFUUNNCCTTIIOONNSS. 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. + + If the name is neither a shell function nor a builtin, and contains no + slashes, bbaasshh searches each element of the PPAATTHH for a directory con- + taining an executable file by that name. BBaasshh uses a hash table to + remember the full pathnames of executable files (see hhaasshh under SSHHEELLLL + BBUUIILLTTIINN CCOOMMMMAANNDDSS below). A full search of the directories in PPAATTHH is + performed only if the command is not found in the hash table. If the + search is unsuccessful, the shell searches for a defined shell function + named ccoommmmaanndd__nnoott__ffoouunndd__hhaannddllee. If that function exists, it is invoked + with the original command and the original command's arguments as its + arguments, and the function's exit status becomes the exit status of + the shell. If that function is not defined, the shell prints an error + message and returns an exit status of 127. + + If the search is successful, or if the command name contains one or + more slashes, the shell executes the named program in a separate execu- + tion environment. Argument 0 is set to the name given, and the remain- + ing arguments to the command are set to the arguments given, if any. + + 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 _s_h_e_l_l _s_c_r_i_p_t, a + file containing shell commands. A subshell is spawned to execute it. + This subshell reinitializes itself, so that the effect is as if a new + shell had been invoked to handle the script, with the exception that + the locations of commands remembered by the parent (see hhaasshh below + under SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS) are retained by the child. + + If the program is a file beginning with ##!!, the remainder of the first + line specifies an interpreter for the program. The shell executes the + specified interpreter on operating systems that do not handle this exe- + cutable format themselves. The arguments to the interpreter consist of + a single optional argument following the interpreter name on the first + line of the program, followed by the name of the program, followed by + the command arguments, if any. + +CCOOMMMMAANNDD EEXXEECCUUTTIIOONN EENNVVIIRROONNMMEENNTT + The shell has an _e_x_e_c_u_t_i_o_n _e_n_v_i_r_o_n_m_e_n_t, which consists of the follow- + ing: + + +o open files inherited by the shell at invocation, as modified by + redirections supplied to the eexxeecc builtin + + +o the current working directory as set by ccdd, ppuusshhdd, or ppooppdd, or + inherited by the shell at invocation + + +o the file creation mode mask as set by uummaasskk or inherited from + the shell's parent + + +o current traps set by ttrraapp + + +o shell parameters that are set by variable assignment or with sseett + or inherited from the shell's parent in the environment + + +o shell functions defined during execution or inherited from the + shell's parent in the environment + + +o options enabled at invocation (either by default or with com- + mand-line arguments) or by sseett + + +o options enabled by sshhoopptt + + +o shell aliases defined with aalliiaass + + +o various process IDs, including those of background jobs, the + value of $$$$, and the value of PPPPIIDD + + When a simple command other than a builtin or shell function is to be + executed, it is invoked in a separate execution environment that con- + sists of the following. Unless otherwise noted, the values are inher- + ited from the shell. + + + +o the shell's open files, plus any modifications and additions + specified by redirections to the command + + +o the current working directory + + +o the file creation mode mask + + +o shell variables and functions marked for export, along with + variables exported for the command, passed in the environment + + +o traps caught by the shell are reset to the values inherited from + the 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, commands grouped with parentheses, and asynchro- + nous 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 invoca- + tion. Builtin commands that are invoked as part of a pipeline are also + executed in a subshell environment. Changes made to the subshell envi- + ronment cannot affect the shell's execution environment. + + Subshells spawned to execute command substitutions inherit the value of + the --ee option from the parent shell. When not in _p_o_s_i_x mode, bbaasshh + clears the --ee option in such subshells. + + If a command is followed by a && and job control is not active, the + default standard input for the command is the empty file _/_d_e_v_/_n_u_l_l. + Otherwise, the invoked command inherits the file descriptors of the + calling shell as modified by redirections. + +EENNVVIIRROONNMMEENNTT + When a program is invoked it is given an array of strings called the + _e_n_v_i_r_o_n_m_e_n_t. This is a list of _n_a_m_e-_v_a_l_u_e pairs, of the form + _n_a_m_e=_v_a_l_u_e. + + The shell 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 _e_x_p_o_r_t to child pro- + cesses. Executed commands inherit the environment. The eexxppoorrtt and + ddeeccllaarree --xx commands allow parameters and functions to be added to and + deleted from the environment. If the value of a parameter in the envi- + ronment 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 modi- + fied in the shell, less any pairs removed by the uunnsseett command, plus + any additions via the eexxppoorrtt and ddeeccllaarree --xx commands. + + The environment for any _s_i_m_p_l_e _c_o_m_m_a_n_d or function may be augmented + temporarily by prefixing it with parameter assignments, as described + above in PPAARRAAMMEETTEERRSS. These assignment statements affect only the envi- + ronment seen by that command. + + If the --kk option is set (see the sseett builtin command below), then _a_l_l + parameter assignments are placed in the environment for a command, not + just those that precede the command name. + + When bbaasshh invokes an external command, the variable __ is set to the + full filename of the command and passed to that command in its environ- + ment. + +EEXXIITT SSTTAATTUUSS + The exit status of an executed command is the value returned by the + _w_a_i_t_p_i_d system call or equivalent function. Exit statuses fall between + 0 and 255, though, as explained below, the shell may use values above + 125 specially. Exit statuses from shell builtins and compound commands + are also limited to this range. Under certain circumstances, the shell + will use special values to indicate specific failure modes. + + For the shell's purposes, a command which exits with a zero exit status + has succeeded. An exit status of zero indicates success. A non-zero + exit status indicates failure. When a command terminates on a fatal + signal _N, bbaasshh uses the value of 128+_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. + + Shell builtin commands return a status of 0 (_t_r_u_e) if successful, and + non-zero (_f_a_l_s_e) if an error occurs while they execute. All builtins + return an exit status of 2 to indicate incorrect usage, generally + invalid options or missing arguments. + + BBaasshh itself returns the exit status of the last command executed, + unless a syntax error occurs, in which case it exits with a non-zero + value. See also the eexxiitt builtin command below. + +SSIIGGNNAALLSS + When bbaasshh is interactive, in the absence of any traps, it ignores + SSIIGGTTEERRMM (so that kkiillll 00 does not kill an interactive shell), and SSIIGGIINNTT + is caught and handled (so that the wwaaiitt builtin is interruptible). In + all cases, bbaasshh ignores SSIIGGQQUUIITT. If job control is in effect, bbaasshh + ignores SSIIGGTTTTIINN, SSIIGGTTTTOOUU, and SSIIGGTTSSTTPP. + + Non-builtin commands run by bbaasshh have signal handlers set to the values + inherited by the shell from its parent. When job control is not in + effect, asynchronous commands ignore SSIIGGIINNTT and SSIIGGQQUUIITT in addition to + these inherited handlers. Commands run as a result of command substi- + tution ignore the keyboard-generated job control signals SSIIGGTTTTIINN, SSIIGGTT-- + TTOOUU, and SSIIGGTTSSTTPP. + + The shell exits by default upon receipt of a SSIIGGHHUUPP. Before exiting, + an interactive shell resends the SSIIGGHHUUPP to all jobs, running or + stopped. Stopped jobs are sent SSIIGGCCOONNTT to ensure that they receive the + SSIIGGHHUUPP. To prevent the shell from sending the signal to a particular + job, it should be removed from the jobs table with the ddiissoowwnn builtin + (see SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS below) or marked to not receive SSIIGGHHUUPP + using ddiissoowwnn --hh. + + If the hhuuppoonneexxiitt shell option has been set with sshhoopptt, bbaasshh sends a + SSIIGGHHUUPP to all jobs when an interactive login shell exits. + + If bbaasshh 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 com- + mand completes. When bbaasshh is waiting for an asynchronous command via + the wwaaiitt builtin, the reception of a signal for which a trap has been + set will cause the wwaaiitt builtin to return immediately with an exit sta- + tus greater than 128, immediately after which the trap is executed. + +JJOOBB CCOONNTTRROOLL + _J_o_b _c_o_n_t_r_o_l refers to the ability to selectively stop (_s_u_s_p_e_n_d) the + execution of processes and continue (_r_e_s_u_m_e) their execution at a later + point. A user typically employs this facility via an interactive + interface supplied jointly by the operating system kernel's terminal + driver and bbaasshh. + + The shell associates a _j_o_b with each pipeline. It keeps a table of + currently executing jobs, which may be listed with the jjoobbss command. + When bbaasshh starts a job asynchronously (in the _b_a_c_k_g_r_o_u_n_d), it prints a + line that looks like: + + [1] 25647 + + indicating that this job is job number 1 and that the process 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. BBaasshh + uses the _j_o_b 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 _c_u_r_r_e_n_t _t_e_r_m_i_n_a_l _p_r_o_c_e_s_s + _g_r_o_u_p _I_D. Members of this process group (processes whose process group + ID is equal to the current terminal process group ID) receive keyboard- + generated signals such as SSIIGGIINNTT. These processes are said to be in + the _f_o_r_e_g_r_o_u_n_d. _B_a_c_k_g_r_o_u_n_d processes are those whose process group ID + differs from the terminal's; such processes are immune to keyboard-gen- + erated signals. Only foreground processes are allowed to read from or, + if the user so specifies with stty tostop, write to the terminal. + Background processes which attempt to read from (write to when stty + tostop is in effect) the terminal are sent a SSIIGGTTTTIINN ((SSIIGGTTTTOOUU)) signal + by the kernel's terminal driver, which, unless caught, suspends the + process. + + If the operating system on which bbaasshh is running supports job control, + bbaasshh contains facilities to use it. Typing the _s_u_s_p_e_n_d character (typ- + ically ^^ZZ, Control-Z) while a process is running causes that process to + be stopped and returns control to bbaasshh. Typing the _d_e_l_a_y_e_d _s_u_s_p_e_n_d + character (typically ^^YY, Control-Y) causes the process to be stopped + when it attempts to read input from the terminal, and control to be + returned to bbaasshh. The user may then manipulate the state of this job, + using the bbgg command to continue it in the background, the ffgg command + to continue it in the foreground, or the kkiillll command to kill it. A ^^ZZ + 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 charac- + ter %% introduces a job specification (_j_o_b_s_p_e_c). Job number _n may be + referred to as %%nn. 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, %%ccee refers to a stopped ccee job. If a prefix + matches more than one job, bbaasshh reports an error. Using %%??ccee, on the + other hand, refers to any job containing the string ccee in its command + line. If the substring matches more than one job, bbaasshh reports an + error. The symbols %%%% and %%++ refer to the shell's notion of the _c_u_r_- + _r_e_n_t _j_o_b, which is the last job stopped while it was in the foreground + or started in the background. The _p_r_e_v_i_o_u_s _j_o_b may be referenced using + %%--. If there is only a single job, %%++ and %%-- can both be used to refer + to that job. In output pertaining to jobs (e.g., the output of the + jjoobbss command), the current job is always flagged with a ++, and the pre- + vious job with a --. A single % (with no accompanying job specifica- + tion) also refers to the current job. + + Simply naming a job can be used to bring it into the foreground: %%11 is + a synonym for ````ffgg %%11'''', bringing job 1 from the background into the + foreground. Similarly, ````%%11 &&'''' resumes job 1 in the background, + equivalent to ````bbgg %%11''''. + + The shell learns immediately whenever a job changes state. Normally, + bbaasshh 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 --bb + option to the sseett builtin command is enabled, bbaasshh reports such changes + immediately. Any trap on SSIIGGCCHHLLDD is executed for each child that + exits. + + If an attempt to exit bbaasshh is made while jobs are stopped (or, if the + cchheecckkjjoobbss shell option has been enabled using the sshhoopptt builtin, run- + ning), the shell prints a warning message, and, if the cchheecckkjjoobbss option + is enabled, lists the jobs and their statuses. The jjoobbss 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 any stopped jobs are terminated. + +PPRROOMMPPTTIINNGG + When executing interactively, bbaasshh displays the primary prompt PPSS11 when + it is ready to read a command, and the secondary prompt PPSS22 when it + needs more input to complete a command. BBaasshh displays PPSS00 after it + reads a command but before executing it. BBaasshh allows these prompt + strings to be customized by inserting a number of backslash-escaped + special characters that are decoded as follows: + \\aa an ASCII bell character (07) + \\dd the date in "Weekday Month Date" format (e.g., "Tue May + 26") + \\DD{{_f_o_r_m_a_t}} + the _f_o_r_m_a_t is passed to _s_t_r_f_t_i_m_e(3) and the result is + inserted into the prompt string; an empty _f_o_r_m_a_t results + in a locale-specific time representation. The braces are + required + \\ee an ASCII escape character (033) + \\hh the hostname up to the first `.' + \\HH the hostname + \\jj the number of jobs currently managed by the shell + \\ll the basename of the shell's terminal device name + \\nn newline + \\rr carriage return + \\ss the name of the shell, the basename of $$00 (the portion + following the final slash) + \\tt the current time in 24-hour HH:MM:SS format + \\TT the current time in 12-hour HH:MM:SS format + \\@@ the current time in 12-hour am/pm format + \\AA the current time in 24-hour HH:MM format + \\uu the username of the current user + \\vv the version of bbaasshh (e.g., 2.00) + \\VV the release of bbaasshh, version + patch level (e.g., 2.00.0) + \\ww the current working directory, with $$HHOOMMEE abbreviated + with a tilde (uses the value of the PPRROOMMPPTT__DDIIRRTTRRIIMM vari- + able) + \\WW the basename of the current working directory, with $$HHOOMMEE + abbreviated with a tilde + \\!! the history number of this command + \\## the command number of this command + \\$$ if the effective UID is 0, a ##, otherwise a $$ + \\_n_n_n the character corresponding to the octal number _n_n_n + \\\\ a backslash + \\[[ begin a sequence of non-printing characters, which could + be used to embed a terminal control sequence into the + prompt + \\]] end a sequence of non-printing characters + + 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 (see HHIISSTTOORRYY + below), 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 substitu- + tion, arithmetic expansion, and quote removal, subject to the value of + the pprroommppttvvaarrss shell option (see the description of the sshhoopptt command + under SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS below). + +RREEAADDLLIINNEE + This is the library that handles reading input when using an interac- + tive shell, unless the ----nnooeeddiittiinngg option is given at shell invocation. + Line editing is also used when using the --ee option to the rreeaadd builtin. + By default, the line editing commands are similar to those of Emacs. A + vi-style line editing interface is also available. Line editing can be + enabled at any time using the --oo eemmaaccss or --oo vvii options to the sseett + builtin (see SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS below). To turn off line editing + after the shell is running, use the ++oo eemmaaccss or ++oo vvii options to the + sseett builtin. + + RReeaaddlliinnee NNoottaattiioonn + In this section, the Emacs-style notation is used to denote keystrokes. + Control keys are denoted by C-_k_e_y, e.g., C-n means Control-N. Simi- + larly, _m_e_t_a keys are denoted by M-_k_e_y, so M-x means Meta-X. (On key- + boards without a _m_e_t_a key, M-_x means ESC _x, i.e., press the Escape key + then the _x key. This makes ESC the _m_e_t_a _p_r_e_f_i_x. The combination M-C-_x + means ESC-Control-_x, or press the Escape key then hold the Control key + while pressing the _x key.) + + Readline commands may be given numeric _a_r_g_u_m_e_n_t_s, which normally act as + a repeat count. Sometimes, however, it is the sign of the argument + that is significant. Passing a negative argument to a command that + acts in the forward direction (e.g., kkiillll--lliinnee) causes that command to + act in a backward direction. Commands whose behavior with arguments + deviates from this are noted below. + + When a command is described as _k_i_l_l_i_n_g text, the text deleted is saved + for possible future retrieval (_y_a_n_k_i_n_g). The killed text is saved in a + _k_i_l_l _r_i_n_g. Consecutive kills cause the text to be accumulated into one + unit, which can be yanked all at once. Commands which do not kill text + separate the chunks of text on the kill ring. + + RReeaaddlliinnee IInniittiiaalliizzaattiioonn + Readline is customized by putting commands in an initialization file + (the _i_n_p_u_t_r_c file). The name of this file is taken from the value of + the IINNPPUUTTRRCC variable. If that variable is unset, the default is + _~_/_._i_n_p_u_t_r_c. When a program which uses the readline library starts up, + the initialization file is read, and the key bindings and variables are + set. There are only a few basic constructs allowed in the readline + initialization file. Blank lines are ignored. Lines beginning with a + ## are comments. Lines beginning with a $$ indicate conditional con- + structs. Other lines denote key bindings and variable settings. + + The default key-bindings may be changed with an _i_n_p_u_t_r_c file. Other + programs that use this library may add their own commands and bindings. + + For example, placing + + M-Control-u: universal-argument + or + C-Meta-u: universal-argument + into the _i_n_p_u_t_r_c would make M-C-u execute the readline command _u_n_i_v_e_r_- + _s_a_l_-_a_r_g_u_m_e_n_t. + + The following symbolic character names are recognized: _R_U_B_O_U_T, _D_E_L, + _E_S_C, _L_F_D, _N_E_W_L_I_N_E, _R_E_T, _R_E_T_U_R_N, _S_P_C, _S_P_A_C_E, and _T_A_B. + + In addition to command names, readline allows keys to be bound to a + string that is inserted when the key is pressed (a _m_a_c_r_o). + + RReeaaddlliinnee KKeeyy BBiinnddiinnggss + The syntax for controlling key bindings in the _i_n_p_u_t_r_c file is simple. + All that is required is the name of the command or the text of a macro + and a key sequence to which it should be bound. The name may be speci- + fied in one of two ways: as a symbolic key name, possibly with _M_e_t_a_- or + _C_o_n_t_r_o_l_- prefixes, or as a key sequence. + + When using the form kkeeyynnaammee:_f_u_n_c_t_i_o_n_-_n_a_m_e or _m_a_c_r_o, _k_e_y_n_a_m_e is the name + of a key spelled out in English. For example: + + Control-u: universal-argument + Meta-Rubout: backward-kill-word + Control-o: "> output" + + In the above example, _C_-_u is bound to the function uunniivveerrssaall--aarrgguummeenntt, + _M_-_D_E_L is bound to the function bbaacckkwwaarrdd--kkiillll--wwoorrdd, and _C_-_o is bound to + run the macro expressed on the right hand side (that is, to insert the + text ``> output'' into the line). + + In the second form, ""kkeeyysseeqq"":_f_u_n_c_t_i_o_n_-_n_a_m_e or _m_a_c_r_o, kkeeyysseeqq differs + from kkeeyynnaammee above in that strings denoting an entire key sequence may + be specified by placing the sequence within double quotes. Some GNU + Emacs style key escapes can be used, as in the following example, but + the symbolic character names are not recognized. + + "\C-u": universal-argument + "\C-x\C-r": re-read-init-file + "\e[11~": "Function Key 1" + + In this example, _C_-_u is again bound to the function uunniivveerrssaall--aarrgguummeenntt. + _C_-_x _C_-_r is bound to the function rree--rreeaadd--iinniitt--ffiillee, and _E_S_C _[ _1 _1 _~ is + bound to insert the text ``Function Key 1''. + + The full set of GNU Emacs style escape sequences is + \\CC-- control prefix + \\MM-- meta prefix + \\ee an escape character + \\\\ backslash + \\"" literal " + \\'' literal ' + + In addition to the GNU Emacs style escape sequences, a second set of + backslash escapes is available: + \\aa alert (bell) + \\bb backspace + \\dd delete + \\ff form feed + \\nn newline + \\rr carriage return + \\tt horizontal tab + \\vv vertical tab + \\_n_n_n the eight-bit character whose value is the octal value + _n_n_n (one to three digits) + \\xx_H_H the eight-bit character whose value is the hexadecimal + value _H_H (one or two hex digits) + + When entering the text of a macro, single or double quotes must be used + to indicate a macro definition. Unquoted text is assumed to be a func- + tion name. In the macro body, the backslash escapes described above + are expanded. Backslash will quote any other character in the macro + text, including " and '. + + BBaasshh allows the current readline key bindings to be displayed or modi- + fied with the bbiinndd builtin command. The editing mode may be switched + during interactive use by using the --oo option to the sseett builtin com- + mand (see SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS below). + + RReeaaddlliinnee VVaarriiaabblleess + Readline has variables that can be used to further customize its behav- + ior. A variable may be set in the _i_n_p_u_t_r_c file with a statement of the + form + + sseett _v_a_r_i_a_b_l_e_-_n_a_m_e _v_a_l_u_e + + Except where noted, readline variables can take the values OOnn or OOffff + (without regard to case). Unrecognized variable names are ignored. + When a variable value is read, empty or null values, "on" (case-insen- + sitive), and "1" are equivalent to OOnn. All other values are equivalent + to OOffff. The variables and their default values are: + + bbeellll--ssttyyllee ((aauuddiibbllee)) + Controls what happens when readline wants to ring the terminal + bell. If set to nnoonnee, readline never rings the bell. If set to + vviissiibbllee, readline uses a visible bell if one is available. If + set to aauuddiibbllee, readline attempts to ring the terminal's bell. + bbiinndd--ttttyy--ssppeecciiaall--cchhaarrss ((OOnn)) + If set to OOnn, readline attempts to bind the control characters + treated specially by the kernel's terminal driver to their read- + line equivalents. + bblliinnkk--mmaattcchhiinngg--ppaarreenn ((OOffff)) + If set to OOnn, readline attempts to briefly move the cursor to an + opening parenthesis when a closing parenthesis is inserted. + ccoolloorreedd--ccoommpplleettiioonn--pprreeffiixx ((OOffff)) + If set to OOnn, when listing completions, readline displays the + common prefix of the set of possible completions using a differ- + ent color. The color definitions are taken from the value of + the LLSS__CCOOLLOORRSS environment variable. + ccoolloorreedd--ssttaattss ((OOffff)) + If set to OOnn, readline displays possible completions using dif- + ferent colors to indicate their file type. The color defini- + tions are taken from the value of the LLSS__CCOOLLOORRSS environment + variable. + ccoommmmeenntt--bbeeggiinn ((````##'''')) + The string that is inserted when the readline iinnsseerrtt--ccoommmmeenntt + command is executed. This command is bound to MM--## in emacs mode + and to ## in vi command mode. + ccoommpplleettiioonn--ddiissppllaayy--wwiiddtthh ((--11)) + The number of screen columns used to display possible matches + when performing completion. The value is ignored if it is less + than 0 or greater than the terminal screen width. A value of 0 + will cause matches to be displayed one per line. The default + value is -1. + ccoommpplleettiioonn--iiggnnoorree--ccaassee ((OOffff)) + If set to OOnn, readline performs filename matching and completion + in a case-insensitive fashion. + ccoommpplleettiioonn--mmaapp--ccaassee ((OOffff)) + If set to OOnn, and ccoommpplleettiioonn--iiggnnoorree--ccaassee is enabled, readline + treats hyphens (_-) and underscores (__) as equivalent when per- + forming case-insensitive filename matching and completion. + ccoommpplleettiioonn--pprreeffiixx--ddiissppllaayy--lleennggtthh ((00)) + The length in characters of the common prefix of a list of pos- + sible completions that is displayed without modification. When + set to a value greater than zero, common prefixes longer than + this value are replaced with an ellipsis when displaying possi- + ble completions. + ccoommpplleettiioonn--qquueerryy--iitteemmss ((110000)) + This determines when the user is queried about viewing the num- + ber of possible completions generated by the ppoossssiibbllee--ccoommppllee-- + ttiioonnss command. It may be set to any integer value greater than + or equal to zero. If the number of possible completions is + greater than or equal to the value of this variable, the user is + asked whether or not he wishes to view them; otherwise they are + simply listed on the terminal. + ccoonnvveerrtt--mmeettaa ((OOnn)) + If set to OOnn, readline will convert characters with the eighth + bit set to an ASCII key sequence by stripping the eighth bit and + prefixing an escape character (in effect, using escape as the + _m_e_t_a _p_r_e_f_i_x). The default is _O_n, but readline will set it to + _O_f_f if the locale contains eight-bit characters. + ddiissaabbllee--ccoommpplleettiioonn ((OOffff)) + If set to OOnn, readline will inhibit word completion. Completion + characters will be inserted into the line as if they had been + mapped to sseellff--iinnsseerrtt. + eecchhoo--ccoonnttrrooll--cchhaarraacctteerrss ((OOnn)) + When set to OOnn, on operating systems that indicate they support + it, readline echoes a character corresponding to a signal gener- + ated from the keyboard. + eeddiittiinngg--mmooddee ((eemmaaccss)) + Controls whether readline begins with a set of key bindings sim- + ilar to _E_m_a_c_s or _v_i. eeddiittiinngg--mmooddee can be set to either eemmaaccss or + vvii. + eennaabbllee--bbrraacckkeetteedd--ppaassttee ((OOffff)) + When set to OOnn, readline will configure the terminal in a way + that will enable it to insert each paste into the editing buffer + as a single string of characters, instead of treating each char- + acter as if it had been read from the keyboard. This can pre- + vent pasted characters from being interpreted as editing com- + mands. + eennaabbllee--kkeeyyppaadd ((OOffff)) + When set to OOnn, readline will try to enable the application key- + pad when it is called. Some systems need this to enable the + arrow keys. + eennaabbllee--mmeettaa--kkeeyy ((OOnn)) + When set to OOnn, readline will try to enable any meta modifier + key the terminal claims to support when it is called. On many + terminals, the meta key is used to send eight-bit characters. + eexxppaanndd--ttiillddee ((OOffff)) + If set to OOnn, tilde expansion is performed when readline + attempts word completion. + hhiissttoorryy--pprreesseerrvvee--ppooiinntt ((OOffff)) + If set to OOnn, the history code attempts to place point at the + same location on each history line retrieved with pprreevviioouuss--hhiiss-- + ttoorryy or nneexxtt--hhiissttoorryy. + hhiissttoorryy--ssiizzee ((uunnsseett)) + Set the maximum number of history entries saved in the history + list. If set to zero, any existing history entries are deleted + and no new entries are saved. If set to a value less than zero, + the number of history entries is not limited. By default, the + number of history entries is set to the value of the HHIISSTTSSIIZZEE + shell variable. If an attempt is made to set _h_i_s_t_o_r_y_-_s_i_z_e to a + non-numeric value, the maximum number of history entries will be + set to 500. + hhoorriizzoonnttaall--ssccrroollll--mmooddee ((OOffff)) + When set to OOnn, makes readline use a single line for display, + scrolling the input horizontally on a single screen line when it + becomes longer than the screen width rather than wrapping to a + new line. + iinnppuutt--mmeettaa ((OOffff)) + If set to OOnn, readline will enable eight-bit input (that is, it + will not strip the eighth bit from the characters it reads), + regardless of what the terminal claims it can support. The name + mmeettaa--ffllaagg is a synonym for this variable. The default is _O_f_f, + but readline will set it to _O_n if the locale contains eight-bit + characters. + iisseeaarrcchh--tteerrmmiinnaattoorrss ((````CC--[[CC--JJ'''')) + The string of characters that should terminate an incremental + search without subsequently executing the character as a com- + mand. If this variable has not been given a value, the charac- + ters _E_S_C and _C_-_J will terminate an incremental search. + kkeeyymmaapp ((eemmaaccss)) + Set the current readline keymap. The set of valid keymap names + is _e_m_a_c_s_, _e_m_a_c_s_-_s_t_a_n_d_a_r_d_, _e_m_a_c_s_-_m_e_t_a_, _e_m_a_c_s_-_c_t_l_x_, _v_i_, _v_i_-_c_o_m_- + _m_a_n_d, and _v_i_-_i_n_s_e_r_t. _v_i is equivalent to _v_i_-_c_o_m_m_a_n_d; _e_m_a_c_s is + equivalent to _e_m_a_c_s_-_s_t_a_n_d_a_r_d. The default value is _e_m_a_c_s; the + value of eeddiittiinngg--mmooddee also affects the default keymap. + eemmaaccss--mmooddee--ssttrriinngg ((@@)) + This string is displayed immediately before the last line of the + primary prompt when emacs editing mode is active. The value is + expanded like a key binding, so the standard set of meta- and + control prefixes and backslash escape sequences is available. + Use the \1 and \2 escapes to begin and end sequences of non- + printing characters, which can be used to embed a terminal con- + trol sequence into the mode string. + kkeeyysseeqq--ttiimmeeoouutt ((550000)) + Specifies the duration _r_e_a_d_l_i_n_e will wait for a character when + reading an ambiguous key sequence (one that can form a complete + key sequence using the input read so far, or can take additional + input to complete a longer key sequence). If no input is + received within the timeout, _r_e_a_d_l_i_n_e will use the shorter but + complete key sequence. The value is specified in milliseconds, + so a value of 1000 means that _r_e_a_d_l_i_n_e will wait one second for + additional input. If this variable is set to a value less than + or equal to zero, or to a non-numeric value, _r_e_a_d_l_i_n_e will wait + until another key is pressed to decide which key sequence to + complete. + mmaarrkk--ddiirreeccttoorriieess ((OOnn)) + If set to OOnn, completed directory names have a slash appended. + mmaarrkk--mmooddiiffiieedd--lliinneess ((OOffff)) + If set to OOnn, history lines that have been modified are dis- + played with a preceding asterisk (**). + mmaarrkk--ssyymmlliinnkkeedd--ddiirreeccttoorriieess ((OOffff)) + If set to OOnn, completed names which are symbolic links to direc- + tories have a slash appended (subject to the value of + mmaarrkk--ddiirreeccttoorriieess). + mmaattcchh--hhiiddddeenn--ffiilleess ((OOnn)) + This variable, when set to OOnn, causes readline to match files + whose names begin with a `.' (hidden files) when performing + filename completion. If set to OOffff, the leading `.' must be + supplied by the user in the filename to be completed. + mmeennuu--ccoommpplleettee--ddiissppllaayy--pprreeffiixx ((OOffff)) + If set to OOnn, menu completion displays the common prefix of the + list of possible completions (which may be empty) before cycling + through the list. + oouuttppuutt--mmeettaa ((OOffff)) + If set to OOnn, readline will display characters with the eighth + bit set directly rather than as a meta-prefixed escape sequence. + The default is _O_f_f, but readline will set it to _O_n if the locale + contains eight-bit characters. + ppaaggee--ccoommpplleettiioonnss ((OOnn)) + If set to OOnn, readline uses an internal _m_o_r_e-like pager to dis- + play a screenful of possible completions at a time. + pprriinntt--ccoommpplleettiioonnss--hhoorriizzoonnttaallllyy ((OOffff)) + If set to OOnn, readline will display completions with matches + sorted horizontally in alphabetical order, rather than down the + screen. + rreevveerrtt--aallll--aatt--nneewwlliinnee ((OOffff)) + If set to OOnn, readline will undo all changes to history lines + before returning when aacccceepptt--lliinnee is executed. By default, his- + tory lines may be modified and retain individual undo lists + across calls to rreeaaddlliinnee. + sshhooww--aallll--iiff--aammbbiigguuoouuss ((OOffff)) + This alters the default behavior of the completion functions. + If set to OOnn, words which have more than one possible completion + cause the matches to be listed immediately instead of ringing + the bell. + sshhooww--aallll--iiff--uunnmmooddiiffiieedd ((OOffff)) + This alters the default behavior of the completion functions in + a fashion similar to sshhooww--aallll--iiff--aammbbiigguuoouuss. If set to OOnn, words + which have more than one possible completion without any possi- + ble partial completion (the possible completions don't share a + common prefix) cause the matches to be listed immediately + instead of ringing the bell. + sshhooww--mmooddee--iinn--pprroommpptt ((OOffff)) + If set to OOnn, add a character to the beginning of the prompt + indicating the editing mode: emacs (@), vi command (:) or vi + insertion (+). + sskkiipp--ccoommpplleetteedd--tteexxtt ((OOffff)) + If set to OOnn, this alters the default completion behavior when + inserting a single match into the line. It's only active when + performing completion in the middle of a word. If enabled, + readline does not insert characters from the completion that + match characters after point in the word being completed, so + portions of the word following the cursor are not duplicated. + vvii--ccmmdd--mmooddee--ssttrriinngg ((((ccmmdd)))) + This string is displayed immediately before the last line of the + primary prompt when vi editing mode is active and in command + mode. The value is expanded like a key binding, so the standard + set of meta- and control prefixes and backslash escape sequences + is available. Use the \1 and \2 escapes to begin and end + sequences of non-printing characters, which can be used to embed + a terminal control sequence into the mode string. + vvii--iinnss--mmooddee--ssttrriinngg ((((iinnss)))) + This string is displayed immediately before the last line of the + primary prompt when vi editing mode is active and in insertion + mode. The value is expanded like a key binding, so the standard + set of meta- and control prefixes and backslash escape sequences + is available. Use the \1 and \2 escapes to begin and end + sequences of non-printing characters, which can be used to embed + a terminal control sequence into the mode string. + vviissiibbllee--ssttaattss ((OOffff)) + If set to OOnn, a character denoting a file's type as reported by + _s_t_a_t(2) is appended to the filename when listing possible com- + pletions. + + RReeaaddlliinnee CCoonnddiittiioonnaall CCoonnssttrruuccttss + Readline implements a facility similar in spirit to the conditional + compilation features of the C preprocessor which allows key bindings + and variable settings to be performed as the result of tests. There + are four parser directives used. + + $$iiff The $$iiff construct allows bindings to be made based on the edit- + ing mode, the terminal being used, or the application using + readline. The text of the test extends to the end of the line; + no characters are required to isolate it. + + mmooddee The mmooddee== form of the $$iiff directive is used to test + whether readline is in emacs or vi mode. This may be + used in conjunction with the sseett kkeeyymmaapp command, for + instance, to set bindings in the _e_m_a_c_s_-_s_t_a_n_d_a_r_d and + _e_m_a_c_s_-_c_t_l_x keymaps only if readline is starting out in + emacs mode. + + tteerrmm The tteerrmm== form may be used to include terminal-specific + key bindings, perhaps to bind the key sequences output by + the terminal's function keys. The word on the right side + of the == is tested against both the full name of the ter- + minal and the portion of the terminal name before the + first --. This allows _s_u_n to match both _s_u_n and _s_u_n_-_c_m_d, + for instance. + + aapppplliiccaattiioonn + The aapppplliiccaattiioonn construct is used to include application- + specific settings. Each program using the readline + library sets the _a_p_p_l_i_c_a_t_i_o_n _n_a_m_e, and an initialization + file can test for a particular value. This could be used + to bind key sequences to functions useful for a specific + program. For instance, the following command adds a key + sequence that quotes the current or previous word in + bbaasshh: + + $$iiff Bash + # Quote the current or previous word + "\C-xq": "\eb\"\ef\"" + $$eennddiiff + + $$eennddiiff This command, as seen in the previous example, terminates an $$iiff + command. + + $$eellssee Commands in this branch of the $$iiff directive are executed if the + test fails. + + $$iinncclluuddee + This directive takes a single filename as an argument and reads + commands and bindings from that file. For example, the follow- + ing directive would read _/_e_t_c_/_i_n_p_u_t_r_c: + + $$iinncclluuddee _/_e_t_c_/_i_n_p_u_t_r_c + + SSeeaarrcchhiinngg + Readline provides commands for searching through the command history + (see HHIISSTTOORRYY below) for lines containing a specified string. There are + two search modes: _i_n_c_r_e_m_e_n_t_a_l and _n_o_n_-_i_n_c_r_e_m_e_n_t_a_l. + + Incremental searches begin before the user has finished typing the + search string. As each character of the search string is typed, read- + line displays the next entry from the history matching the string typed + so far. An incremental search requires only as many characters as + needed to find the desired history entry. The characters present in + the value of the iisseeaarrcchh--tteerrmmiinnaattoorrss variable are used to terminate an + incremental search. If that variable has not been assigned a value the + Escape and Control-J characters will terminate an incremental search. + Control-G will abort an incremental search and restore the original + line. When the search is terminated, the history entry containing the + search string becomes the current line. + + To find other matching entries in the history list, type Control-S or + Control-R as appropriate. This will search backward or forward in the + history for the next entry matching the search string typed so far. + Any other key sequence bound to a readline command will terminate the + search and execute that command. For instance, a _n_e_w_l_i_n_e will termi- + nate the search and accept the line, thereby executing the command from + the history list. + + Readline remembers the last incremental search string. If two Control- + Rs are typed without any intervening characters defining a new search + string, any remembered search string is used. + + Non-incremental searches read the entire search string before starting + to search for matching history lines. The search string may be typed + by the user or be part of the contents of the current line. + + RReeaaddlliinnee CCoommmmaanndd NNaammeess + The following is a list of the names of the commands and the default + key sequences to which they are bound. Command names without an accom- + panying key sequence are unbound by default. In the following descrip- + tions, _p_o_i_n_t refers to the current cursor position, and _m_a_r_k refers to + a cursor position saved by the sseett--mmaarrkk command. The text between the + point and mark is referred to as the _r_e_g_i_o_n. + + CCoommmmaannddss ffoorr MMoovviinngg + bbeeggiinnnniinngg--ooff--lliinnee ((CC--aa)) + Move to the start of the current line. + eenndd--ooff--lliinnee ((CC--ee)) + Move to the end of the line. + ffoorrwwaarrdd--cchhaarr ((CC--ff)) + Move forward a character. + bbaacckkwwaarrdd--cchhaarr ((CC--bb)) + Move back a character. + ffoorrwwaarrdd--wwoorrdd ((MM--ff)) + Move forward to the end of the next word. Words are composed of + alphanumeric characters (letters and digits). + bbaacckkwwaarrdd--wwoorrdd ((MM--bb)) + Move back to the start of the current or previous word. Words + are composed of alphanumeric characters (letters and digits). + sshheellll--ffoorrwwaarrdd--wwoorrdd + Move forward to the end of the next word. Words are delimited + by non-quoted shell metacharacters. + sshheellll--bbaacckkwwaarrdd--wwoorrdd + Move back to the start of the current or previous word. Words + are delimited by non-quoted shell metacharacters. + cclleeaarr--ssccrreeeenn ((CC--ll)) + Clear the screen leaving the current line at the top of the + screen. With an argument, refresh the current line without + clearing the screen. + rreeddrraaww--ccuurrrreenntt--lliinnee + Refresh the current line. + + CCoommmmaannddss ffoorr MMaanniippuullaattiinngg tthhee HHiissttoorryy + aacccceepptt--lliinnee ((NNeewwlliinnee,, RReettuurrnn)) + Accept the line regardless of where the cursor is. If this line + is non-empty, add it to the history list according to the state + of the HHIISSTTCCOONNTTRROOLL variable. If the line is a modified history + line, then restore the history line to its original state. + pprreevviioouuss--hhiissttoorryy ((CC--pp)) + Fetch the previous command from the history list, moving back in + the list. + nneexxtt--hhiissttoorryy ((CC--nn)) + Fetch the next command from the history list, moving forward in + the list. + bbeeggiinnnniinngg--ooff--hhiissttoorryy ((MM--<<)) + Move to the first line in the history. + eenndd--ooff--hhiissttoorryy ((MM-->>)) + Move to the end of the input history, i.e., the line currently + being entered. + rreevveerrssee--sseeaarrcchh--hhiissttoorryy ((CC--rr)) + Search backward starting at the current line and moving `up' + through the history as necessary. This is an incremental + search. + ffoorrwwaarrdd--sseeaarrcchh--hhiissttoorryy ((CC--ss)) + Search forward starting at the current line and moving `down' + through the history as necessary. This is an incremental + search. + nnoonn--iinnccrreemmeennttaall--rreevveerrssee--sseeaarrcchh--hhiissttoorryy ((MM--pp)) + Search backward through the history starting at the current line + using a non-incremental search for a string supplied by the + user. + nnoonn--iinnccrreemmeennttaall--ffoorrwwaarrdd--sseeaarrcchh--hhiissttoorryy ((MM--nn)) + Search forward through the history using a non-incremental + search for a string supplied by the user. + hhiissttoorryy--sseeaarrcchh--ffoorrwwaarrdd + Search forward through the history for the string of characters + between the start of the current line and the point. This is a + non-incremental search. + hhiissttoorryy--sseeaarrcchh--bbaacckkwwaarrdd + Search backward through the history for the string of characters + between the start of the current line and the point. This is a + non-incremental search. + yyaannkk--nntthh--aarrgg ((MM--CC--yy)) + Insert the first argument to the previous command (usually the + second word on the previous line) at point. With an argument _n, + insert the _nth word from the previous command (the words in the + previous command begin with word 0). A negative argument + inserts the _nth word from the end of the previous command. Once + the argument _n is computed, the argument is extracted as if the + "!_n" history expansion had been specified. + yyaannkk--llaasstt--aarrgg ((MM--..,, MM--__)) + Insert the last argument to the previous command (the last word + of the previous history entry). With a numeric argument, behave + exactly like yyaannkk--nntthh--aarrgg. Successive calls to yyaannkk--llaasstt--aarrgg + move back through the history list, inserting the last word (or + the word specified by the argument to the first call) of each + line in turn. Any numeric argument supplied to these successive + calls determines the direction to move through the history. A + negative argument switches the direction through the history + (back or forward). The history expansion facilities are used to + extract the last word, as if the "!$" history expansion had been + specified. + sshheellll--eexxppaanndd--lliinnee ((MM--CC--ee)) + Expand the line as the shell does. This performs alias and his- + tory expansion as well as all of the shell word expansions. See + HHIISSTTOORRYY EEXXPPAANNSSIIOONN below for a description of history expansion. + hhiissttoorryy--eexxppaanndd--lliinnee ((MM--^^)) + Perform history expansion on the current line. See HHIISSTTOORRYY + EEXXPPAANNSSIIOONN below for a description of history expansion. + mmaaggiicc--ssppaaccee + Perform history expansion on the current line and insert a + space. See HHIISSTTOORRYY EEXXPPAANNSSIIOONN below for a description of history + expansion. + aalliiaass--eexxppaanndd--lliinnee + Perform alias expansion on the current line. See AALLIIAASSEESS above + for a description of alias expansion. + hhiissttoorryy--aanndd--aalliiaass--eexxppaanndd--lliinnee + Perform history and alias expansion on the current line. + iinnsseerrtt--llaasstt--aarrgguummeenntt ((MM--..,, MM--__)) + A synonym for yyaannkk--llaasstt--aarrgg. + ooppeerraattee--aanndd--ggeett--nneexxtt ((CC--oo)) + Accept the current line for execution and fetch the next line + relative to the current line from the history for editing. Any + argument is ignored. + eeddiitt--aanndd--eexxeeccuuttee--ccoommmmaanndd ((CC--xxCC--ee)) + Invoke an editor on the current command line, and execute the + result as shell commands. BBaasshh attempts to invoke $$VVIISSUUAALL, + $$EEDDIITTOORR, and _e_m_a_c_s as the editor, in that order. + + CCoommmmaannddss ffoorr CChhaannggiinngg TTeexxtt + _e_n_d_-_o_f_-_f_i_l_e ((uussuuaallllyy CC--dd)) + The character indicating end-of-file as set, for example, by + ``stty''. If this character is read when there are no charac- + ters on the line, and point is at the beginning of the line, + Readline interprets it as the end of input and returns EEOOFF. + ddeelleettee--cchhaarr ((CC--dd)) + Delete the character at point. If this function is bound to the + same character as the tty EEOOFF character, as CC--dd commonly is, see + above for the effects. + bbaacckkwwaarrdd--ddeelleettee--cchhaarr ((RRuubboouutt)) + Delete the character behind the cursor. When given a numeric + argument, save the deleted text on the kill ring. + ffoorrwwaarrdd--bbaacckkwwaarrdd--ddeelleettee--cchhaarr + Delete the character under the cursor, unless the cursor is at + the end of the line, in which case the character behind the cur- + sor is deleted. + qquuootteedd--iinnsseerrtt ((CC--qq,, CC--vv)) + Add the next character typed to the line verbatim. This is how + to insert characters like CC--qq, for example. + ttaabb--iinnsseerrtt ((CC--vv TTAABB)) + Insert a tab character. + sseellff--iinnsseerrtt ((aa,, bb,, AA,, 11,, !!,, ......)) + Insert the character typed. + ttrraannssppoossee--cchhaarrss ((CC--tt)) + Drag the character before point forward over the character at + point, moving point forward as well. If point is at the end of + the line, then this transposes the two characters before point. + Negative arguments have no effect. + ttrraannssppoossee--wwoorrddss ((MM--tt)) + Drag the word before point past the word after point, moving + point over that word as well. If point is at the end of the + line, this transposes the last two words on the line. + uuppccaassee--wwoorrdd ((MM--uu)) + Uppercase the current (or following) word. With a negative + argument, uppercase the previous word, but do not move point. + ddoowwnnccaassee--wwoorrdd ((MM--ll)) + Lowercase the current (or following) word. With a negative + argument, lowercase the previous word, but do not move point. + ccaappiittaalliizzee--wwoorrdd ((MM--cc)) + Capitalize the current (or following) word. With a negative + argument, capitalize the previous word, but do not move point. + oovveerrwwrriittee--mmooddee + Toggle overwrite mode. With an explicit positive numeric argu- + ment, switches to overwrite mode. With an explicit non-positive + numeric argument, switches to insert mode. This command affects + only eemmaaccss mode; vvii mode does overwrite differently. Each call + to _r_e_a_d_l_i_n_e_(_) starts in insert mode. In overwrite mode, charac- + ters bound to sseellff--iinnsseerrtt replace the text at point rather than + pushing the text to the right. Characters bound to bbaacckk-- + wwaarrdd--ddeelleettee--cchhaarr replace the character before point with a + space. By default, this command is unbound. + + KKiilllliinngg aanndd YYaannkkiinngg + kkiillll--lliinnee ((CC--kk)) + Kill the text from point to the end of the line. + bbaacckkwwaarrdd--kkiillll--lliinnee ((CC--xx RRuubboouutt)) + Kill backward to the beginning of the line. + uunniixx--lliinnee--ddiissccaarrdd ((CC--uu)) + Kill backward from point to the beginning of the line. The + killed text is saved on the kill-ring. + kkiillll--wwhhoollee--lliinnee + Kill all characters on the current line, no matter where point + is. + kkiillll--wwoorrdd ((MM--dd)) + Kill from point to the end of the current word, or if between + words, to the end of the next word. Word boundaries are the + same as those used by ffoorrwwaarrdd--wwoorrdd. + bbaacckkwwaarrdd--kkiillll--wwoorrdd ((MM--RRuubboouutt)) + Kill the word behind point. Word boundaries are the same as + those used by bbaacckkwwaarrdd--wwoorrdd. + sshheellll--kkiillll--wwoorrdd + Kill from point to the end of the current word, or if between + words, to the end of the next word. Word boundaries are the + same as those used by sshheellll--ffoorrwwaarrdd--wwoorrdd. + sshheellll--bbaacckkwwaarrdd--kkiillll--wwoorrdd + Kill the word behind point. Word boundaries are the same as + those used by sshheellll--bbaacckkwwaarrdd--wwoorrdd. + uunniixx--wwoorrdd--rruubboouutt ((CC--ww)) + Kill the word behind point, using white space as a word bound- + ary. The killed text is saved on the kill-ring. + uunniixx--ffiilleennaammee--rruubboouutt + Kill the word behind point, using white space and the slash + character as the word boundaries. The killed text is saved on + the kill-ring. + ddeelleettee--hhoorriizzoonnttaall--ssppaaccee ((MM--\\)) + Delete all spaces and tabs around point. + kkiillll--rreeggiioonn + Kill the text in the current region. + ccooppyy--rreeggiioonn--aass--kkiillll + Copy the text in the region to the kill buffer. + ccooppyy--bbaacckkwwaarrdd--wwoorrdd + Copy the word before point to the kill buffer. The word bound- + aries are the same as bbaacckkwwaarrdd--wwoorrdd. + ccooppyy--ffoorrwwaarrdd--wwoorrdd + Copy the word following point to the kill buffer. The word + boundaries are the same as ffoorrwwaarrdd--wwoorrdd. + yyaannkk ((CC--yy)) + Yank the top of the kill ring into the buffer at point. + yyaannkk--ppoopp ((MM--yy)) + Rotate the kill ring, and yank the new top. Only works follow- + ing yyaannkk or yyaannkk--ppoopp. + + NNuummeerriicc AArrgguummeennttss + ddiiggiitt--aarrgguummeenntt ((MM--00,, MM--11,, ......,, MM----)) + Add this digit to the argument already accumulating, or start a + new argument. M-- starts a negative argument. + uunniivveerrssaall--aarrgguummeenntt + This is another way to specify an argument. If this command is + followed by one or more digits, optionally with a leading minus + sign, those digits define the argument. If the command is fol- + lowed by digits, executing uunniivveerrssaall--aarrgguummeenntt again ends the + numeric argument, but is otherwise ignored. As a special case, + if this command is immediately followed by a character that is + neither a digit nor minus sign, the argument count for the next + command is multiplied by four. The argument count is initially + one, so executing this function the first time makes the argu- + ment count four, a second time makes the argument count sixteen, + and so on. + + CCoommpplleettiinngg + ccoommpplleettee ((TTAABB)) + Attempt to perform completion on the text before point. BBaasshh + attempts completion treating the text as a variable (if the text + begins with $$), username (if the text begins with ~~), hostname + (if the text begins with @@), or command (including aliases and + functions) in turn. If none of these produces a match, filename + completion is attempted. + ppoossssiibbllee--ccoommpplleettiioonnss ((MM--??)) + List the possible completions of the text before point. + iinnsseerrtt--ccoommpplleettiioonnss ((MM--**)) + Insert all completions of the text before point that would have + been generated by ppoossssiibbllee--ccoommpplleettiioonnss. + mmeennuu--ccoommpplleettee + Similar to ccoommpplleettee, but replaces the word to be completed with + a single match from the list of possible completions. Repeated + execution of mmeennuu--ccoommpplleettee steps through the list of possible + completions, inserting each match in turn. At the end of the + list of completions, the bell is rung (subject to the setting of + bbeellll--ssttyyllee) and the original text is restored. An argument of _n + moves _n positions forward in the list of matches; a negative + argument may be used to move backward through the list. This + command is intended to be bound to TTAABB, but is unbound by + default. + mmeennuu--ccoommpplleettee--bbaacckkwwaarrdd + Identical to mmeennuu--ccoommpplleettee, but moves backward through the list + of possible completions, as if mmeennuu--ccoommpplleettee had been given a + negative argument. This command is unbound by default. + ddeelleettee--cchhaarr--oorr--lliisstt + Deletes the character under the cursor if not at the beginning + or end of the line (like ddeelleettee--cchhaarr). If at the end of the + line, behaves identically to ppoossssiibbllee--ccoommpplleettiioonnss. This command + is unbound by default. + ccoommpplleettee--ffiilleennaammee ((MM--//)) + Attempt filename completion on the text before point. + ppoossssiibbllee--ffiilleennaammee--ccoommpplleettiioonnss ((CC--xx //)) + List the possible completions of the text before point, treating + it as a filename. + ccoommpplleettee--uusseerrnnaammee ((MM--~~)) + Attempt completion on the text before point, treating it as a + username. + ppoossssiibbllee--uusseerrnnaammee--ccoommpplleettiioonnss ((CC--xx ~~)) + List the possible completions of the text before point, treating + it as a username. + ccoommpplleettee--vvaarriiaabbllee ((MM--$$)) + Attempt completion on the text before point, treating it as a + shell variable. + ppoossssiibbllee--vvaarriiaabbllee--ccoommpplleettiioonnss ((CC--xx $$)) + List the possible completions of the text before point, treating + it as a shell variable. + ccoommpplleettee--hhoossttnnaammee ((MM--@@)) + Attempt completion on the text before point, treating it as a + hostname. + ppoossssiibbllee--hhoossttnnaammee--ccoommpplleettiioonnss ((CC--xx @@)) + List the possible completions of the text before point, treating + it as a hostname. + ccoommpplleettee--ccoommmmaanndd ((MM--!!)) + Attempt completion on the text before point, treating it as a + command name. Command completion attempts to match the text + against aliases, reserved words, shell functions, shell + builtins, and finally executable filenames, in that order. + ppoossssiibbllee--ccoommmmaanndd--ccoommpplleettiioonnss ((CC--xx !!)) + List the possible completions of the text before point, treating + it as a command name. + ddyynnaammiicc--ccoommpplleettee--hhiissttoorryy ((MM--TTAABB)) + Attempt completion on the text before point, comparing the text + against lines from the history list for possible completion + matches. + ddaabbbbrreevv--eexxppaanndd + Attempt menu completion on the text before point, comparing the + text against lines from the history list for possible completion + matches. + ccoommpplleettee--iinnttoo--bbrraacceess ((MM--{{)) + Perform filename completion and insert the list of possible com- + pletions enclosed within braces so the list is available to the + shell (see BBrraaccee EExxppaannssiioonn above). + + KKeeyybbooaarrdd MMaaccrrooss + ssttaarrtt--kkbbdd--mmaaccrroo ((CC--xx (()) + Begin saving the characters typed into the current keyboard + macro. + eenndd--kkbbdd--mmaaccrroo ((CC--xx )))) + Stop saving the characters typed into the current keyboard macro + and store the definition. + ccaallll--llaasstt--kkbbdd--mmaaccrroo ((CC--xx ee)) + Re-execute the last keyboard macro defined, by making the char- + acters in the macro appear as if typed at the keyboard. + pprriinntt--llaasstt--kkbbdd--mmaaccrroo (()) + Print the last keyboard macro defined in a format suitable for + the _i_n_p_u_t_r_c file. + + MMiisscceellllaanneeoouuss + rree--rreeaadd--iinniitt--ffiillee ((CC--xx CC--rr)) + Read in the contents of the _i_n_p_u_t_r_c file, and incorporate any + bindings or variable assignments found there. + aabboorrtt ((CC--gg)) + Abort the current editing command and ring the terminal's bell + (subject to the setting of bbeellll--ssttyyllee). + ddoo--uuppppeerrccaassee--vveerrssiioonn ((MM--aa,, MM--bb,, MM--_x,, ......)) + If the metafied character _x is lowercase, run the command that + is bound to the corresponding uppercase character. + pprreeffiixx--mmeettaa ((EESSCC)) + Metafy the next character typed. EESSCC ff is equivalent to MMeettaa--ff. + uunnddoo ((CC--__,, CC--xx CC--uu)) + Incremental undo, separately remembered for each line. + rreevveerrtt--lliinnee ((MM--rr)) + Undo all changes made to this line. This is like executing the + uunnddoo command enough times to return the line to its initial + state. + ttiillddee--eexxppaanndd ((MM--&&)) + Perform tilde expansion on the current word. + sseett--mmaarrkk ((CC--@@,, MM--<>)) + Set the mark to the point. If a numeric argument is supplied, + the mark is set to that position. + eexxcchhaannggee--ppooiinntt--aanndd--mmaarrkk ((CC--xx CC--xx)) + Swap the point with the mark. The current cursor position is + set to the saved position, and the old cursor position is saved + as the mark. + cchhaarraacctteerr--sseeaarrcchh ((CC--]])) + A character is read and point is moved to the next occurrence of + that character. A negative count searches for previous occur- + rences. + cchhaarraacctteerr--sseeaarrcchh--bbaacckkwwaarrdd ((MM--CC--]])) + A character is read and point is moved to the previous occur- + rence of that character. A negative count searches for subse- + quent occurrences. + sskkiipp--ccssii--sseeqquueennccee + Read enough characters to consume a multi-key sequence such as + those defined for keys like Home and End. Such sequences begin + with a Control Sequence Indicator (CSI), usually ESC-[. If this + sequence is bound to "\[", keys producing such sequences will + have no effect unless explicitly bound to a readline command, + instead of inserting stray characters into the editing buffer. + This is unbound by default, but usually bound to ESC-[. + iinnsseerrtt--ccoommmmeenntt ((MM--##)) + Without a numeric argument, the value of the readline ccoomm-- + mmeenntt--bbeeggiinn variable is inserted at the beginning of the current + line. If a numeric argument is supplied, this command acts as a + toggle: if the characters at the beginning of the line do not + match the value of ccoommmmeenntt--bbeeggiinn, the value is inserted, other- + wise the characters in ccoommmmeenntt--bbeeggiinn are deleted from the begin- + ning of the line. In either case, the line is accepted as if a + newline had been typed. The default value of ccoommmmeenntt--bbeeggiinn + causes this command to make the current line a shell comment. + If a numeric argument causes the comment character to be + removed, the line will be executed by the shell. + gglloobb--ccoommpplleettee--wwoorrdd ((MM--gg)) + The word before point is treated as a pattern for pathname + expansion, with an asterisk implicitly appended. This pattern + is used to generate a list of matching filenames for possible + completions. + gglloobb--eexxppaanndd--wwoorrdd ((CC--xx **)) + The word before point is treated as a pattern for pathname + expansion, and the list of matching filenames is inserted, + replacing the word. If a numeric argument is supplied, an + asterisk is appended before pathname expansion. + gglloobb--lliisstt--eexxppaannssiioonnss ((CC--xx gg)) + The list of expansions that would have been generated by + gglloobb--eexxppaanndd--wwoorrdd is displayed, and the line is redrawn. If a + numeric argument is supplied, an asterisk is appended before + pathname expansion. + dduummpp--ffuunnccttiioonnss + Print all of the functions and their key bindings to the read- + line output stream. If a numeric argument is supplied, the out- + put is formatted in such a way that it can be made part of an + _i_n_p_u_t_r_c file. + dduummpp--vvaarriiaabblleess + Print all of the settable readline variables and their values to + the readline output stream. If a numeric argument is supplied, + the output is formatted in such a way that it can be made part + of an _i_n_p_u_t_r_c file. + dduummpp--mmaaccrrooss + Print all of the readline key sequences bound to macros and the + strings they output. If a numeric argument is supplied, the + output is formatted in such a way that it can be made part of an + _i_n_p_u_t_r_c file. + ddiissppllaayy--sshheellll--vveerrssiioonn ((CC--xx CC--vv)) + Display version information about the current instance of bbaasshh. + + PPrrooggrraammmmaabbllee CCoommpplleettiioonn + When word completion is attempted for an argument to a command for + which a completion specification (a _c_o_m_p_s_p_e_c) has been defined using + the ccoommpplleettee builtin (see SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS below), the program- + mable completion facilities are invoked. + + First, the command name is identified. If the command word is the + empty string (completion attempted at the beginning of an empty line), + any compspec defined with the --EE option to ccoommpplleettee is used. If a + compspec has been defined for that command, the compspec is used to + generate the list of possible completions for the word. If the command + word is a full pathname, a compspec for the full pathname is searched + for first. If no compspec is found for the full pathname, an attempt + is made to find a compspec for the portion following the final slash. + If those searches do not result in a compspec, any compspec defined + with the --DD option to ccoommpplleettee is used as the default. + + Once a compspec has been found, it is used to generate the list of + matching words. If a compspec is not found, the default bbaasshh comple- + tion as described above under CCoommpplleettiinngg is performed. + + First, the actions specified by the compspec are used. Only matches + which are prefixed by the word being completed are returned. When the + --ff or --dd option is used for filename or directory name completion, the + shell variable FFIIGGNNOORREE is used to filter the matches. + + Any completions specified by a pathname expansion pattern to the --GG + option are generated next. The words generated by the pattern need not + match the word being completed. The GGLLOOBBIIGGNNOORREE shell variable is not + used to filter the matches, but the FFIIGGNNOORREE variable is used. + + Next, the string specified as the argument to the --WW option is consid- + ered. The string is first split using the characters in the IIFFSS spe- + cial variable as delimiters. Shell quoting is honored. Each word is + then expanded using brace expansion, tilde expansion, parameter and + variable expansion, command substitution, and arithmetic expansion, as + described above under EEXXPPAANNSSIIOONN. The results are split using the rules + described above under WWoorrdd SSpplliittttiinngg. The results of the expansion are + prefix-matched against the word being completed, and the matching words + become the possible completions. + + After these matches have been generated, any shell function or command + specified with the --FF and --CC options is invoked. When the command or + function is invoked, the CCOOMMPP__LLIINNEE, CCOOMMPP__PPOOIINNTT, CCOOMMPP__KKEEYY, and CCOOMMPP__TTYYPPEE + variables are assigned values as described above under SShheellll VVaarriiaabblleess. + If a shell function is being invoked, the CCOOMMPP__WWOORRDDSS and CCOOMMPP__CCWWOORRDD + variables are also set. When the function or command is invoked, the + first argument ($$11) is the name of the command whose arguments are + being completed, the second argument ($$22) is the word being completed, + and the third argument ($$33) is the word preceding the word being com- + pleted on the current command line. No filtering of the generated com- + pletions against the word being completed is performed; the function or + command has complete freedom in generating the matches. + + Any function specified with --FF is invoked first. The function may use + any of the shell facilities, including the ccoommppggeenn builtin described + below, to generate the matches. It must put the possible completions + in the CCOOMMPPRREEPPLLYY array variable, one per array element. + + Next, any command specified with the --CC option is invoked in an envi- + ronment equivalent to command substitution. It should print a list of + completions, one per line, to the standard output. Backslash may be + used to escape a newline, if necessary. + + After all of the possible completions are generated, any filter speci- + fied with the --XX option is applied to the list. The filter is a pat- + tern as used for pathname expansion; a && in the pattern is replaced + with the text of the word being completed. A literal && may be escaped + with a backslash; the backslash is removed before attempting a match. + Any completion that matches the pattern will be removed from the list. + A leading !! negates the pattern; in this case any completion not match- + ing the pattern will be removed. If the nnooccaasseemmaattcchh shell option is + enabled, the match is performed without regard to the case of alpha- + betic characters. + + Finally, any prefix and suffix specified with the --PP and --SS options are + added to each member of the completion list, and the result is returned + to the readline completion code as the list of possible completions. + + If the previously-applied actions do not generate any matches, and the + --oo ddiirrnnaammeess option was supplied to ccoommpplleettee when the compspec was + defined, directory name completion is attempted. + + If the --oo pplluussddiirrss option was supplied to ccoommpplleettee when the compspec + was defined, directory name completion is attempted and any matches are + added to the results of the other actions. + + By default, if a compspec is found, whatever it generates is returned + to the completion code as the full set of possible completions. The + default bbaasshh completions are not attempted, and the readline default of + filename completion is disabled. If the --oo bbaasshhddeeffaauulltt option was sup- + plied to ccoommpplleettee when the compspec was defined, the bbaasshh default com- + pletions are attempted if the compspec generates no matches. If the --oo + ddeeffaauulltt option was supplied to ccoommpplleettee when the compspec was defined, + readline's default completion will be performed if the compspec (and, + if attempted, the default bbaasshh completions) generate no matches. + + When a compspec indicates that directory name completion is desired, + the programmable completion functions force readline to append a slash + to completed names which are symbolic links to directories, subject to + the value of the mmaarrkk--ddiirreeccttoorriieess readline variable, regardless of the + setting of the mmaarrkk--ssyymmlliinnkkeedd--ddiirreeccttoorriieess readline variable. + + There is some support for dynamically modifying completions. This is + most useful when used in combination with a default completion speci- + fied with ccoommpplleettee --DD. It's possible for shell functions executed as + completion handlers to indicate that completion should be retried by + returning an exit status of 124. If a shell function returns 124, and + changes the compspec associated with the command on which completion is + being attempted (supplied as the first argument when the function is + executed), programmable completion restarts from the beginning, with an + attempt to find a new compspec for that command. This allows a set of + completions to be built dynamically as completion is attempted, rather + than being loaded all at once. + + For instance, assuming that there is a library of compspecs, each kept + in a file corresponding to the name of the command, the following + default completion function would load completions dynamically: + + _completion_loader() + { + . "/etc/bash_completion.d/$1.sh" >/dev/null 2>&1 && return 124 + } + complete -D -F _completion_loader -o bashdefault -o default + + +HHIISSTTOORRYY + When the --oo hhiissttoorryy option to the sseett builtin is enabled, the shell + provides access to the _c_o_m_m_a_n_d _h_i_s_t_o_r_y, the list of commands previously + typed. The value of the HHIISSTTSSIIZZEE variable is used as the number of + commands to save in a history list. The text of the last HHIISSTTSSIIZZEE com- + mands (default 500) is saved. The shell stores each command in the + history list prior to parameter and variable expansion (see EEXXPPAANNSSIIOONN + above) but after history expansion is performed, subject to the values + of the shell variables HHIISSTTIIGGNNOORREE and HHIISSTTCCOONNTTRROOLL. + + On startup, the history is initialized from the file named by the vari- + able HHIISSTTFFIILLEE (default _~_/_._b_a_s_h___h_i_s_t_o_r_y). The file named by the value + of HHIISSTTFFIILLEE is truncated, if necessary, to contain no more than the + number of lines specified by the value of HHIISSTTFFIILLEESSIIZZEE. If HHIISSTTFFIILLEE-- + SSIIZZEE is unset, or set to null, a non-numeric value, or a numeric value + less than zero, the history file is not truncated. When the history + file is read, lines beginning with the history comment character fol- + lowed immediately by a digit are interpreted as timestamps for the pre- + ceding history line. These timestamps are optionally displayed depend- + ing on the value of the HHIISSTTTTIIMMEEFFOORRMMAATT variable. When a shell with + history enabled exits, the last $$HHIISSTTSSIIZZEE lines are copied from the + history list to $$HHIISSTTFFIILLEE. If the hhiissttaappppeenndd shell option is enabled + (see the description of sshhoopptt under SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS below), the + lines are appended to the history file, otherwise the history file is + overwritten. If HHIISSTTFFIILLEE is unset, or if the history file is + unwritable, the history is not saved. If the HHIISSTTTTIIMMEEFFOORRMMAATT variable + is set, time stamps are written to the history file, marked with the + history comment character, so they may be preserved across shell ses- + sions. This uses the history comment character to distinguish time- + stamps from other history lines. After saving the history, the history + file is truncated to contain no more than HHIISSTTFFIILLEESSIIZZEE lines. If HHIISSTT-- + FFIILLEESSIIZZEE is unset, or set to null, a non-numeric value, or a numeric + value less than zero, the history file is not truncated. + + The builtin command ffcc (see SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS below) may be used + to list or edit and re-execute a portion of the history list. The hhiiss-- + ttoorryy builtin may be used to display or modify the history list and + manipulate the history file. When using command-line editing, search + commands are available in each editing mode that provide access to the + history list. + + The shell allows control over which commands are saved on the history + list. The HHIISSTTCCOONNTTRROOLL and HHIISSTTIIGGNNOORREE variables may be set to cause the + shell to save only a subset of the commands entered. The ccmmddhhiisstt shell + option, if enabled, causes the shell to attempt to save each line of a + multi-line command in the same history entry, adding semicolons where + necessary to preserve syntactic correctness. The lliitthhiisstt shell option + causes the shell to save the command with embedded newlines instead of + semicolons. See the description of the sshhoopptt builtin below under SSHHEELLLL + BBUUIILLTTIINN CCOOMMMMAANNDDSS for information on setting and unsetting shell + options. + +HHIISSTTOORRYY EEXXPPAANNSSIIOONN + The shell supports a history expansion feature that is similar to the + history expansion in ccsshh.. This section describes what syntax features + are available. This feature is enabled by default for interactive + shells, and can be disabled using the ++HH option to the sseett builtin com- + mand (see SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS below). Non-interactive shells do not + perform history expansion by default. + + History expansions introduce words from the history list into the input + stream, making it easy to repeat commands, insert the arguments to a + previous command into the current input line, or fix errors in previous + commands quickly. + + History expansion is performed immediately after a complete line is + read, before the shell breaks it into words. It takes place in two + parts. The first is to determine which line from the history list to + use during substitution. The second is to select portions of that line + for inclusion into the current one. The line selected from the history + is the _e_v_e_n_t, and the portions of that line that are acted upon are + _w_o_r_d_s. Various _m_o_d_i_f_i_e_r_s are available to manipulate the selected + words. The line is broken into words in the same fashion as when read- + ing input, so that several _m_e_t_a_c_h_a_r_a_c_t_e_r-separated words surrounded by + quotes are considered one word. History expansions are introduced by + the appearance of the history expansion character, which is !! by + default. Only backslash (\\) and single quotes can quote the history + expansion character, but the history expansion character is also + treated as quoted if it immediately precedes the closing double quote + in a double-quoted string. + + Several characters inhibit history expansion if found immediately fol- + lowing the history expansion character, even if it is unquoted: space, + tab, newline, carriage return, and ==. If the eexxttgglloobb shell option is + enabled, (( will also inhibit expansion. + + Several shell options settable with the sshhoopptt builtin may be used to + tailor the behavior of history expansion. If the hhiissttvveerriiffyy shell + option is enabled (see the description of the sshhoopptt builtin below), and + rreeaaddlliinnee is being used, history substitutions are not immediately + passed to the shell parser. Instead, the expanded line is reloaded + into the rreeaaddlliinnee editing buffer for further modification. If rreeaaddlliinnee + is being used, and the hhiissttrreeeeddiitt shell option is enabled, a failed + history substitution will be reloaded into the rreeaaddlliinnee editing buffer + for correction. The --pp option to the hhiissttoorryy builtin command may be + used to see what a history expansion will do before using it. The --ss + option to the hhiissttoorryy builtin may be used to add commands to the end of + the history list without actually executing them, so that they are + available for subsequent recall. + + The shell allows control of the various characters used by the history + expansion mechanism (see the description of hhiissttcchhaarrss above under SShheellll + VVaarriiaabblleess). The shell uses the history comment character to mark his- + tory timestamps when writing the history file. + + EEvveenntt DDeessiiggnnaattoorrss + An event designator is a reference to a command line entry in the his- + tory list. Unless the reference is absolute, events are relative to + the current position in the history list. + + !! Start a history substitution, except when followed by a bbllaannkk, + newline, carriage return, = or ( (when the eexxttgglloobb shell option + is enabled using the sshhoopptt builtin). + !!_n Refer to command line _n. + !!--_n Refer to the current command minus _n. + !!!! Refer to the previous command. This is a synonym for `!-1'. + !!_s_t_r_i_n_g + Refer to the most recent command preceding the current position + in the history list starting with _s_t_r_i_n_g. + !!??_s_t_r_i_n_g[[??]] + Refer to the most recent command preceding the current position + in the history list containing _s_t_r_i_n_g. The trailing ?? may be + omitted if _s_t_r_i_n_g is followed immediately by a newline. + ^^_s_t_r_i_n_g_1^^_s_t_r_i_n_g_2^^ + Quick substitution. Repeat the previous command, replacing + _s_t_r_i_n_g_1 with _s_t_r_i_n_g_2. Equivalent to ``!!:s/_s_t_r_i_n_g_1/_s_t_r_i_n_g_2/'' + (see MMooddiiffiieerrss below). + !!## The entire command line typed so far. + + WWoorrdd DDeessiiggnnaattoorrss + Word designators are used to select desired words from the event. A :: + separates the event specification from the word designator. It may be + omitted if the word designator begins with a ^^, $$, **, --, or %%. Words + are numbered from the beginning of the line, with the first word being + denoted by 0 (zero). Words are inserted into the current line sepa- + rated by single spaces. + + 00 ((zzeerroo)) + The zeroth word. For the shell, this is the command word. + _n The _nth word. + ^^ The first argument. That is, word 1. + $$ The last word. This is usually the last argument, but will + expand to the zeroth word if there is only one word in the line. + %% The word matched by the most recent `?_s_t_r_i_n_g?' search. + _x--_y A range of words; `-_y' abbreviates `0-_y'. + ** All of the words but the zeroth. This is a synonym for `_1_-_$'. + It is not an error to use ** if there is just one word in the + event; the empty string is returned in that case. + xx** Abbreviates _x_-_$. + xx-- Abbreviates _x_-_$ like xx**, but omits the last word. + + If a word designator is supplied without an event specification, the + previous command is used as the event. + + MMooddiiffiieerrss + After the optional word designator, there may appear a sequence of one + or more of the following modifiers, each preceded by a `:'. + + hh Remove a trailing filename component, leaving only the head. + tt Remove all leading filename components, leaving the tail. + rr Remove a trailing suffix of the form _._x_x_x, leaving the basename. + ee Remove all but the trailing suffix. + pp Print the new command but do not execute it. + qq Quote the substituted words, escaping further substitutions. + xx Quote the substituted words as with qq, but break into words at + bbllaannkkss and newlines. + ss//_o_l_d//_n_e_w// + Substitute _n_e_w for the first occurrence of _o_l_d in the event + line. Any delimiter can be used in place of /. The final + delimiter is optional if it is the last character of the event + line. The delimiter may be quoted in _o_l_d and _n_e_w with a single + backslash. If & appears in _n_e_w, it is replaced by _o_l_d. A sin- + gle backslash will quote the &. If _o_l_d is null, it is set to + the last _o_l_d substituted, or, if no previous history substitu- + tions took place, the last _s_t_r_i_n_g in a !!??_s_t_r_i_n_g[[??]] search. + && Repeat the previous substitution. + gg Cause changes to be applied over the entire event line. This is + used in conjunction with `::ss' (e.g., `::ggss//_o_l_d//_n_e_w//') or `::&&'. + If used with `::ss', any delimiter can be used in place of /, and + the final delimiter is optional if it is the last character of + the event line. An aa may be used as a synonym for gg. + GG Apply the following `ss' modifier once to each word in the event + line. + +SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS + Unless otherwise noted, each builtin command documented in this section + as accepting options preceded by -- accepts ---- to signify the end of the + options. The ::, ttrruuee, ffaallssee, and tteesstt builtins do not accept options + and do not treat ---- specially. The eexxiitt, llooggoouutt, rreettuurrnn, bbrreeaakk, ccoonn-- + ttiinnuuee, lleett, and sshhiifftt builtins accept and process arguments beginning + with -- without requiring ----. Other builtins that accept arguments but + are not specified as accepting options interpret arguments beginning + with -- as invalid options and require ---- to prevent this interpreta- + tion. + :: [_a_r_g_u_m_e_n_t_s] + No effect; the command does nothing beyond expanding _a_r_g_u_m_e_n_t_s + and performing any specified redirections. The return status is + zero. + + .. _f_i_l_e_n_a_m_e [_a_r_g_u_m_e_n_t_s] + ssoouurrccee _f_i_l_e_n_a_m_e [_a_r_g_u_m_e_n_t_s] + Read and execute commands from _f_i_l_e_n_a_m_e in the current shell + environment and return the exit status of the last command exe- + cuted from _f_i_l_e_n_a_m_e. If _f_i_l_e_n_a_m_e does not contain a slash, + filenames in PPAATTHH are used to find the directory containing + _f_i_l_e_n_a_m_e. The file searched for in PPAATTHH need not be executable. + When bbaasshh is not in _p_o_s_i_x _m_o_d_e, the current directory is + searched if no file is found in PPAATTHH. If the ssoouurrcceeppaatthh option + to the sshhoopptt builtin command is turned off, the PPAATTHH is not + searched. If any _a_r_g_u_m_e_n_t_s are supplied, they become the posi- + tional parameters when _f_i_l_e_n_a_m_e is executed. Otherwise the + positional parameters are unchanged. If the --TT option is + enabled, ssoouurrccee inherits any trap on DDEEBBUUGG; if it is not, any + DDEEBBUUGG trap string is saved and restored around the call to + ssoouurrccee, and ssoouurrccee unsets the DDEEBBUUGG trap while it executes. If + --TT is not set, and the sourced file changes the DDEEBBUUGG trap, the + new value is retained when ssoouurrccee completes. The return status + is the status of the last command exited within the script (0 if + no commands are executed), and false if _f_i_l_e_n_a_m_e is not found or + cannot be read. + + aalliiaass [--pp] [_n_a_m_e[=_v_a_l_u_e] ...] + AAlliiaass with no arguments or with the --pp option prints the list of + aliases in the form aalliiaass _n_a_m_e=_v_a_l_u_e on standard output. When + arguments are supplied, an alias is defined for each _n_a_m_e whose + _v_a_l_u_e is given. A trailing space in _v_a_l_u_e causes the next word + to be checked for alias substitution when the alias is expanded. + For each _n_a_m_e in the argument list for which no _v_a_l_u_e is sup- + plied, the name and value of the alias is printed. AAlliiaass + returns true unless a _n_a_m_e is given for which no alias has been + defined. + + bbgg [_j_o_b_s_p_e_c ...] + Resume each suspended job _j_o_b_s_p_e_c in the background, as if it + had been started with &&. If _j_o_b_s_p_e_c is not present, the shell's + notion of the _c_u_r_r_e_n_t _j_o_b is used. bbgg _j_o_b_s_p_e_c returns 0 unless + run when job control is disabled or, when run with job control + enabled, any specified _j_o_b_s_p_e_c was not found or was started + without job control. + + bbiinndd [--mm _k_e_y_m_a_p] [--llppssvvPPSSVVXX] + bbiinndd [--mm _k_e_y_m_a_p] [--qq _f_u_n_c_t_i_o_n] [--uu _f_u_n_c_t_i_o_n] [--rr _k_e_y_s_e_q] + bbiinndd [--mm _k_e_y_m_a_p] --ff _f_i_l_e_n_a_m_e + bbiinndd [--mm _k_e_y_m_a_p] --xx _k_e_y_s_e_q:_s_h_e_l_l_-_c_o_m_m_a_n_d + bbiinndd [--mm _k_e_y_m_a_p] _k_e_y_s_e_q:_f_u_n_c_t_i_o_n_-_n_a_m_e + bbiinndd [--mm _k_e_y_m_a_p] _k_e_y_s_e_q:_r_e_a_d_l_i_n_e_-_c_o_m_m_a_n_d + Display current rreeaaddlliinnee key and function bindings, bind a key + sequence to a rreeaaddlliinnee function or macro, or set a rreeaaddlliinnee + variable. Each non-option argument is a command as it would + appear in _._i_n_p_u_t_r_c, but each binding or command must be passed + as a separate argument; e.g., '"\C-x\C-r": re-read-init-file'. + Options, if supplied, have the following meanings: + --mm _k_e_y_m_a_p + Use _k_e_y_m_a_p as the keymap to be affected by the subsequent + bindings. Acceptable _k_e_y_m_a_p names are _e_m_a_c_s_, _e_m_a_c_s_-_s_t_a_n_- + _d_a_r_d_, _e_m_a_c_s_-_m_e_t_a_, _e_m_a_c_s_-_c_t_l_x_, _v_i_, _v_i_-_m_o_v_e_, _v_i_-_c_o_m_m_a_n_d, + and _v_i_-_i_n_s_e_r_t. _v_i is equivalent to _v_i_-_c_o_m_m_a_n_d (_v_i_-_m_o_v_e + is also a synonym); _e_m_a_c_s is equivalent to _e_m_a_c_s_-_s_t_a_n_- + _d_a_r_d. + --ll List the names of all rreeaaddlliinnee functions. + --pp Display rreeaaddlliinnee function names and bindings in such a + way that they can be re-read. + --PP List current rreeaaddlliinnee function names and bindings. + --ss Display rreeaaddlliinnee key sequences bound to macros and the + strings they output in such a way that they can be re- + read. + --SS Display rreeaaddlliinnee key sequences bound to macros and the + strings they output. + --vv Display rreeaaddlliinnee variable names and values in such a way + that they can be re-read. + --VV List current rreeaaddlliinnee variable names and values. + --ff _f_i_l_e_n_a_m_e + Read key bindings from _f_i_l_e_n_a_m_e. + --qq _f_u_n_c_t_i_o_n + Query about which keys invoke the named _f_u_n_c_t_i_o_n. + --uu _f_u_n_c_t_i_o_n + Unbind all keys bound to the named _f_u_n_c_t_i_o_n. + --rr _k_e_y_s_e_q + Remove any current binding for _k_e_y_s_e_q. + --xx _k_e_y_s_e_q::_s_h_e_l_l_-_c_o_m_m_a_n_d + Cause _s_h_e_l_l_-_c_o_m_m_a_n_d to be executed whenever _k_e_y_s_e_q is + entered. When _s_h_e_l_l_-_c_o_m_m_a_n_d is executed, the shell sets + the RREEAADDLLIINNEE__LLIINNEE variable to the contents of the rreeaadd-- + lliinnee line buffer and the RREEAADDLLIINNEE__PPOOIINNTT variable to the + current location of the insertion point. If the executed + command changes the value of RREEAADDLLIINNEE__LLIINNEE or RREEAADD-- + LLIINNEE__PPOOIINNTT, those new values will be reflected in the + editing state. + --XX List all key sequences bound to shell commands and the + associated commands in a format that can be reused as + input. + + The return value is 0 unless an unrecognized option is given or + an error occurred. + + bbrreeaakk [_n] + Exit from within a ffoorr, wwhhiillee, uunnttiill, or sseelleecctt loop. If _n is + specified, break _n levels. _n must be >= 1. If _n is greater + than the number of enclosing loops, all enclosing loops are + exited. The return value is 0 unless _n is not greater than or + equal to 1. + + bbuuiillttiinn _s_h_e_l_l_-_b_u_i_l_t_i_n [_a_r_g_u_m_e_n_t_s] + Execute the specified shell builtin, passing it _a_r_g_u_m_e_n_t_s, and + return its exit status. This is useful when defining a function + whose name is the same as a shell builtin, retaining the func- + tionality of the builtin within the function. The ccdd builtin is + commonly redefined this way. The return status is false if + _s_h_e_l_l_-_b_u_i_l_t_i_n is not a shell builtin command. + + ccaalllleerr [_e_x_p_r] + Returns the context of any active subroutine call (a shell func- + tion or a script executed with the .. or ssoouurrccee builtins). With- + out _e_x_p_r, ccaalllleerr displays the line number and source filename of + the current subroutine call. If a non-negative integer is sup- + plied as _e_x_p_r, ccaalllleerr 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 sub- + routine call or _e_x_p_r does not correspond to a valid position in + the call stack. + + ccdd [--LL|[--PP [--ee]] [-@]] [_d_i_r] + Change the current directory to _d_i_r. if _d_i_r is not supplied, + the value of the HHOOMMEE shell variable is the default. Any addi- + tional arguments following _d_i_r are ignored. The variable CCDDPPAATTHH + defines the search path for the directory containing _d_i_r: each + directory name in CCDDPPAATTHH is searched for _d_i_r. Alternative + directory names in CCDDPPAATTHH are separated by a colon (:). A null + directory name in CCDDPPAATTHH is the same as the current directory, + i.e., ``..''. If _d_i_r begins with a slash (/), then CCDDPPAATTHH is not + used. The --PP option causes ccdd to use the physical directory + structure by resolving symbolic links while traversing _d_i_r and + before processing instances of _._. in _d_i_r (see also the --PP option + to the sseett builtin command); the --LL option forces symbolic links + to be followed by resolving the link after processing instances + of _._. in _d_i_r. If _._. appears in _d_i_r, it is processed by removing + the immediately previous pathname component from _d_i_r, back to a + slash or the beginning of _d_i_r. If the --ee option is supplied + with --PP, and the current working directory cannot be success- + fully determined after a successful directory change, ccdd will + return an unsuccessful status. On systems that support it, the + --@@ option presents the extended attributes associated with a + file as a directory. An argument of -- is converted to $$OOLLDDPPWWDD + before the directory change is attempted. If a non-empty direc- + tory name from CCDDPPAATTHH is used, or if -- 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 value is true if the directory was successfully + changed; false otherwise. + + ccoommmmaanndd [--ppVVvv] _c_o_m_m_a_n_d [_a_r_g ...] + Run _c_o_m_m_a_n_d with _a_r_g_s suppressing the normal shell function + lookup. Only builtin commands or commands found in the PPAATTHH are + executed. If the --pp option is given, the search for _c_o_m_m_a_n_d is + performed using a default value for PPAATTHH that is guaranteed to + find all of the standard utilities. If either the --VV or --vv + option is supplied, a description of _c_o_m_m_a_n_d is printed. The --vv + option causes a single word indicating the command or filename + used to invoke _c_o_m_m_a_n_d to be displayed; the --VV option produces a + more verbose description. If the --VV or --vv option is supplied, + the exit status is 0 if _c_o_m_m_a_n_d was found, and 1 if not. If + neither option is supplied and an error occurred or _c_o_m_m_a_n_d can- + not be found, the exit status is 127. Otherwise, the exit sta- + tus of the ccoommmmaanndd builtin is the exit status of _c_o_m_m_a_n_d. + + ccoommppggeenn [_o_p_t_i_o_n] [_w_o_r_d] + Generate possible completion matches for _w_o_r_d according to the + _o_p_t_i_o_ns, which may be any option accepted by the ccoommpplleettee + builtin with the exception of --pp and --rr, and write the matches + to the standard output. When using the --FF or --CC options, the + various shell variables set by the programmable completion + facilities, while available, will not have useful values. + + The matches will be generated in the same way as if the program- + mable completion code had generated them directly from a comple- + tion specification with the same flags. If _w_o_r_d is specified, + only those completions matching _w_o_r_d will be displayed. + + The return value is true unless an invalid option is supplied, + or no matches were generated. + + ccoommpplleettee [--aabbccddeeffggjjkkssuuvv] [--oo _c_o_m_p_-_o_p_t_i_o_n] [--DDEE] [--AA _a_c_t_i_o_n] [--GG _g_l_o_b_- + _p_a_t] [--WW _w_o_r_d_l_i_s_t] [--FF _f_u_n_c_t_i_o_n] [--CC _c_o_m_m_a_n_d] + [--XX _f_i_l_t_e_r_p_a_t] [--PP _p_r_e_f_i_x] [--SS _s_u_f_f_i_x] _n_a_m_e [_n_a_m_e _._._.] + ccoommpplleettee --pprr [--DDEE] [_n_a_m_e ...] + Specify how arguments to each _n_a_m_e should be completed. If the + --pp option is supplied, or if no options are supplied, existing + completion specifications are printed in a way that allows them + to be reused as input. The --rr option removes a completion spec- + ification for each _n_a_m_e, or, if no _n_a_m_es are supplied, all com- + pletion specifications. The --DD option indicates that the + remaining options and actions should apply to the ``default'' + command completion; that is, completion attempted on a command + for which no completion has previously been defined. The --EE + option indicates that the remaining options and actions should + apply to ``empty'' command completion; that is, completion + attempted on a blank line. + + The process of applying these completion specifications when + word completion is attempted is described above under PPrrooggrraamm-- + mmaabbllee CCoommpplleettiioonn. + + Other options, if specified, have the following meanings. The + arguments to the --GG, --WW, and --XX options (and, if necessary, the + --PP and --SS options) should be quoted to protect them from expan- + sion before the ccoommpplleettee builtin is invoked. + --oo _c_o_m_p_-_o_p_t_i_o_n + The _c_o_m_p_-_o_p_t_i_o_n controls several aspects of the comp- + spec's behavior beyond the simple generation of comple- + tions. _c_o_m_p_-_o_p_t_i_o_n may be one of: + bbaasshhddeeffaauulltt + Perform the rest of the default bbaasshh completions + if the compspec generates no matches. + ddeeffaauulltt Use readline's default filename completion if + the compspec generates no matches. + ddiirrnnaammeess + Perform directory name completion if the comp- + spec generates no matches. + ffiilleennaammeess + Tell readline that the compspec generates file- + names, so it can perform any filename-specific + processing (like adding a slash to directory + names, quoting special characters, or suppress- + ing trailing spaces). Intended to be used with + shell functions. + nnooqquuoottee Tell readline not to quote the completed words + if they are filenames (quoting filenames is the + default). + nnoossoorrtt Tell readline not to sort the list of possible + completions alphabetically. + nnoossppaaccee Tell readline not to append a space (the + default) to words completed at the end of the + line. + pplluussddiirrss + After any matches defined by the compspec are + generated, directory name completion is + attempted and any matches are added to the + results of the other actions. + --AA _a_c_t_i_o_n + The _a_c_t_i_o_n may be one of the following to generate a + list of possible completions: + aalliiaass Alias names. May also be specified as --aa. + aarrrraayyvvaarr + Array variable names. + bbiinnddiinngg RReeaaddlliinnee key binding names. + bbuuiillttiinn Names of shell builtin commands. May also be + specified as --bb. + ccoommmmaanndd Command names. May also be specified as --cc. + ddiirreeccttoorryy + Directory names. May also be specified as --dd. + ddiissaabblleedd + Names of disabled shell builtins. + eennaabblleedd Names of enabled shell builtins. + eexxppoorrtt Names of exported shell variables. May also be + specified as --ee. + ffiillee File names. May also be specified as --ff. + ffuunnccttiioonn + Names of shell functions. + ggrroouupp Group names. May also be specified as --gg. + hheellppttooppiicc + Help topics as accepted by the hheellpp builtin. + hhoossttnnaammee + Hostnames, as taken from the file specified by + the HHOOSSTTFFIILLEE shell variable. + jjoobb Job names, if job control is active. May also + be specified as --jj. + kkeeyywwoorrdd Shell reserved words. May also be specified as + --kk. + rruunnnniinngg Names of running jobs, if job control is active. + sseerrvviiccee Service names. May also be specified as --ss. + sseettoopptt Valid arguments for the --oo option to the sseett + builtin. + sshhoopptt Shell option names as accepted by the sshhoopptt + builtin. + ssiiggnnaall Signal names. + ssttooppppeedd Names of stopped jobs, if job control is active. + uusseerr User names. May also be specified as --uu. + vvaarriiaabbllee + Names of all shell variables. May also be spec- + ified as --vv. + --CC _c_o_m_m_a_n_d + _c_o_m_m_a_n_d is executed in a subshell environment, and its + output is used as the possible completions. + --FF _f_u_n_c_t_i_o_n + The shell function _f_u_n_c_t_i_o_n is executed in the current + shell environment. When the function is executed, the + first argument ($$11) is the name of the command whose + arguments are being completed, the second argument ($$22) + is the word being completed, and the third argument ($$33) + is the word preceding the word being completed on the + current command line. When it finishes, the possible + completions are retrieved from the value of the CCOOMMPPRREE-- + PPLLYY array variable. + --GG _g_l_o_b_p_a_t + The pathname expansion pattern _g_l_o_b_p_a_t is expanded to + generate the possible completions. + --PP _p_r_e_f_i_x + _p_r_e_f_i_x is added at the beginning of each possible com- + pletion after all other options have been applied. + --SS _s_u_f_f_i_x + _s_u_f_f_i_x is appended to each possible completion after all + other options have been applied. + --WW _w_o_r_d_l_i_s_t + The _w_o_r_d_l_i_s_t is split using the characters in the IIFFSS + special variable as delimiters, and each resultant word + is expanded. The possible completions are the members + of the resultant list which match the word being com- + pleted. + --XX _f_i_l_t_e_r_p_a_t + _f_i_l_t_e_r_p_a_t is a pattern as used for pathname expansion. + It is applied to the list of possible completions gener- + ated by the preceding options and arguments, and each + completion matching _f_i_l_t_e_r_p_a_t is removed from the list. + A leading !! in _f_i_l_t_e_r_p_a_t negates the pattern; in this + case, any completion not matching _f_i_l_t_e_r_p_a_t is removed. + + The return value is true unless an invalid option is supplied, + an option other than --pp or --rr is supplied without a _n_a_m_e argu- + ment, an attempt is made to remove a completion specification + for a _n_a_m_e for which no specification exists, or an error occurs + adding a completion specification. + + ccoommppoopptt [--oo _o_p_t_i_o_n] [--DDEE] [++oo _o_p_t_i_o_n] [_n_a_m_e] + Modify completion options for each _n_a_m_e according to the + _o_p_t_i_o_ns, or for the currently-executing completion if no _n_a_m_es + are supplied. If no _o_p_t_i_o_ns are given, display the completion + options for each _n_a_m_e or the current completion. The possible + values of _o_p_t_i_o_n are those valid for the ccoommpplleettee builtin + described above. The --DD option indicates that the remaining + options should apply to the ``default'' command completion; that + is, completion attempted on a command for which no completion + has previously been defined. The --EE option indicates that the + remaining options should apply to ``empty'' command completion; + that is, completion attempted on a blank line. + + The return value is true unless an invalid option is supplied, + an attempt is made to modify the options for a _n_a_m_e for which no + completion specification exists, or an output error occurs. + + ccoonnttiinnuuee [_n] + Resume the next iteration of the enclosing ffoorr, wwhhiillee, uunnttiill, or + sseelleecctt loop. If _n is specified, resume at the _nth enclosing + loop. _n must be >= 1. If _n is greater than the number of + enclosing loops, the last enclosing loop (the ``top-level'' + loop) is resumed. The return value is 0 unless _n is not greater + than or equal to 1. + + ddeeccllaarree [--aaAAffFFggiillnnrrttuuxx] [--pp] [_n_a_m_e[=_v_a_l_u_e] ...] + ttyyppeesseett [--aaAAffFFggiillnnrrttuuxx] [--pp] [_n_a_m_e[=_v_a_l_u_e] ...] + Declare variables and/or give them attributes. If no _n_a_m_es are + given then display the values of variables. The --pp option will + display the attributes and values of each _n_a_m_e. When --pp is used + with _n_a_m_e arguments, additional options, other than --ff and --FF, + are ignored. When --pp is supplied without _n_a_m_e arguments, it + will display the attributes and values of all variables having + the attributes specified by the additional options. If no other + options are supplied with --pp, ddeeccllaarree will display the + attributes and values of all shell variables. The --ff option + will restrict the display to shell functions. The --FF option + inhibits the display of function definitions; only the function + name and attributes are printed. If the eexxttddeebbuugg shell option + is enabled using sshhoopptt, the source file name and line number + where each _n_a_m_e is defined are displayed as well. The --FF option + implies --ff. The --gg option forces variables to be created or + modified at the global scope, even when ddeeccllaarree is executed in a + shell function. It is ignored in all other cases. The follow- + ing options can be used to restrict output to variables with the + specified attribute or to give variables attributes: + --aa Each _n_a_m_e is an indexed array variable (see AArrrraayyss + above). + --AA Each _n_a_m_e is an associative array variable (see AArrrraayyss + above). + --ff Use function names only. + --ii The variable is treated as an integer; arithmetic evalua- + tion (see AARRIITTHHMMEETTIICC EEVVAALLUUAATTIIOONN above) is performed when + the variable is assigned a value. + --ll When the variable is assigned a value, all upper-case + characters are converted to lower-case. The upper-case + attribute is disabled. + --nn Give each _n_a_m_e the _n_a_m_e_r_e_f attribute, making it a name + reference to another variable. That other variable is + defined by the value of _n_a_m_e. All references, assign- + ments, and attribute modifications to _n_a_m_e, except those + using or changing the --nn attribute itself, are performed + on the variable referenced by _n_a_m_e's value. The nameref + attribute cannot be applied to array variables. + --rr Make _n_a_m_es readonly. These names cannot then be assigned + values by subsequent assignment statements or unset. + --tt Give each _n_a_m_e the _t_r_a_c_e attribute. Traced functions + inherit the DDEEBBUUGG and RREETTUURRNN traps from the calling + shell. The trace attribute has no special meaning for + variables. + --uu When the variable is assigned a value, all lower-case + characters are converted to upper-case. The lower-case + attribute is disabled. + --xx Mark _n_a_m_es for export to subsequent commands via the + environment. + + Using `+' instead of `-' turns off the attribute instead, with + the exceptions that ++aa may not be used to destroy an array vari- + able and ++rr will not remove the readonly attribute. When used + in a function, ddeeccllaarree and ttyyppeesseett make each _n_a_m_e local, as with + the llooccaall command, unless the --gg option is supplied. If a vari- + able name is followed by =_v_a_l_u_e, the value of the variable is + set to _v_a_l_u_e. When using --aa or --AA and the compound assignment + syntax to create array variables, additional attributes do not + take effect until subsequent assignments. The return value is 0 + unless an invalid option is encountered, an attempt is made to + define a function using ``-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 (see AArrrraayyss above), one of the _n_a_m_e_s is not a + valid shell variable name, an attempt is made to turn off read- + only 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 --ff. + + ddiirrss [[--ccllppvv]] [[++_n]] [[--_n]] + Without options, displays the list of currently remembered + directories. The default display is on a single line with + directory names separated by spaces. Directories are added to + the list with the ppuusshhdd command; the ppooppdd command removes + entries from the list. The current directory is always the + first directory in the stack. + --cc Clears the directory stack by deleting all of the + entries. + --ll Produces a listing using full pathnames; the default + listing format uses a tilde to denote the home directory. + --pp Print the directory stack with one entry per line. + --vv Print the directory stack with one entry per line, pre- + fixing each entry with its index in the stack. + ++_n Displays the _nth entry counting from the left of the list + shown by ddiirrss when invoked without options, starting with + zero. + --_n Displays the _nth entry counting from the right of the + list shown by ddiirrss when invoked without options, starting + with zero. + + The return value is 0 unless an invalid option is supplied or _n + indexes beyond the end of the directory stack. + + ddiissoowwnn [--aarr] [--hh] [_j_o_b_s_p_e_c ... | _p_i_d ... ] + Without options, remove each _j_o_b_s_p_e_c from the table of active + jobs. If _j_o_b_s_p_e_c is not present, and neither the --aa nor the --rr + option is supplied, the _c_u_r_r_e_n_t _j_o_b is used. If the --hh option + is given, each _j_o_b_s_p_e_c is not removed from the table, but is + marked so that SSIIGGHHUUPP is not sent to the job if the shell + receives a SSIIGGHHUUPP. If no _j_o_b_s_p_e_c is supplied, the --aa option + means to remove or mark all jobs; the --rr option without a _j_o_b_- + _s_p_e_c argument restricts operation to running jobs. The return + value is 0 unless a _j_o_b_s_p_e_c does not specify a valid job. + + eecchhoo [--nneeEE] [_a_r_g ...] + Output the _a_r_gs, separated by spaces, followed by a newline. + The return status is 0 unless a write error occurs. If --nn is + specified, the trailing newline is suppressed. If the --ee option + is given, interpretation of the following backslash-escaped + characters is enabled. The --EE option disables the interpreta- + tion of these escape characters, even on systems where they are + interpreted by default. The xxppgg__eecchhoo shell option may be used + to dynamically determine whether or not eecchhoo expands these + escape characters by default. eecchhoo does not interpret ---- to + mean the end of options. eecchhoo interprets the following escape + sequences: + \\aa alert (bell) + \\bb backspace + \\cc suppress further output + \\ee + \\EE an escape character + \\ff form feed + \\nn new line + \\rr carriage return + \\tt horizontal tab + \\vv vertical tab + \\\\ backslash + \\00_n_n_n the eight-bit character whose value is the octal value + _n_n_n (zero to three octal digits) + \\xx_H_H the eight-bit character whose value is the hexadecimal + value _H_H (one or two hex digits) + \\uu_H_H_H_H the Unicode (ISO/IEC 10646) character whose value is the + hexadecimal value _H_H_H_H (one to four hex digits) + \\UU_H_H_H_H_H_H_H_H + the Unicode (ISO/IEC 10646) character whose value is the + hexadecimal value _H_H_H_H_H_H_H_H (one to eight hex digits) + + eennaabbllee [--aa] [--ddnnppss] [--ff _f_i_l_e_n_a_m_e] [_n_a_m_e ...] + 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 --nn is used, each _n_a_m_e is disabled; otherwise, _n_a_m_e_s are + enabled. For example, to use the tteesstt binary found via the PPAATTHH + instead of the shell builtin version, run ``enable -n test''. + The --ff option means to load the new builtin command _n_a_m_e from + shared object _f_i_l_e_n_a_m_e, on systems that support dynamic loading. + The --dd option will delete a builtin previously loaded with --ff. + If no _n_a_m_e arguments are given, or if the --pp option is supplied, + a list of shell builtins is printed. With no other option argu- + ments, the list consists of all enabled shell builtins. If --nn + is supplied, only disabled builtins are printed. If --aa is sup- + plied, the list printed includes all builtins, with an indica- + tion of whether or not each is enabled. If --ss is supplied, the + output is restricted to the POSIX _s_p_e_c_i_a_l builtins. The return + value is 0 unless a _n_a_m_e is not a shell builtin or there is an + error loading a new builtin from a shared object. + + eevvaall [_a_r_g ...] + The _a_r_gs are read and concatenated together into a single com- + mand. This command is then read and executed by the shell, and + its exit status is returned as the value of eevvaall. If there are + no _a_r_g_s, or only null arguments, eevvaall returns 0. + + eexxeecc [--ccll] [--aa _n_a_m_e] [_c_o_m_m_a_n_d [_a_r_g_u_m_e_n_t_s]] + If _c_o_m_m_a_n_d is specified, it replaces the shell. No new process + is created. The _a_r_g_u_m_e_n_t_s become the arguments to _c_o_m_m_a_n_d. If + the --ll option is supplied, the shell places a dash at the begin- + ning of the zeroth argument passed to _c_o_m_m_a_n_d. This is what + _l_o_g_i_n(1) does. The --cc option causes _c_o_m_m_a_n_d to be executed with + an empty environment. If --aa is supplied, the shell passes _n_a_m_e + as the zeroth argument to the executed command. If _c_o_m_m_a_n_d can- + not be executed for some reason, a non-interactive shell exits, + unless the eexxeeccffaaiill shell option is enabled. In that case, it + returns failure. An interactive shell returns failure if the + file cannot be executed. If _c_o_m_m_a_n_d is not specified, any redi- + rections take effect in the current shell, and the return status + is 0. If there is a redirection error, the return status is 1. + + eexxiitt [_n] + Cause the shell to exit with a status of _n. If _n is omitted, + the exit status is that of the last command executed. A trap on + EEXXIITT is executed before the shell terminates. + + eexxppoorrtt [--ffnn] [_n_a_m_e[=_w_o_r_d]] ... + eexxppoorrtt --pp + The supplied _n_a_m_e_s are marked for automatic export to the envi- + ronment of subsequently executed commands. If the --ff option is + given, the _n_a_m_e_s refer to functions. If no _n_a_m_e_s are given, or + if the --pp option is supplied, a list of names of all exported + variables is printed. The --nn option causes the export property + to be removed from each _n_a_m_e. If a variable name is followed by + =_w_o_r_d, the value of the variable is set to _w_o_r_d. eexxppoorrtt returns + an exit status of 0 unless an invalid option is encountered, one + of the _n_a_m_e_s is not a valid shell variable name, or --ff is sup- + plied with a _n_a_m_e that is not a function. + + ffcc [--ee _e_n_a_m_e] [--llnnrr] [_f_i_r_s_t] [_l_a_s_t] + ffcc --ss [_p_a_t=_r_e_p] [_c_m_d] + The first form selects a range of commands from _f_i_r_s_t to _l_a_s_t + from the history list and displays or edits and re-executes + them. _F_i_r_s_t and _l_a_s_t may be specified as a string (to locate + the last command beginning with that string) or as a number (an + index into the history list, where a negative number is used as + an offset from the current command number). If _l_a_s_t is not + specified it is set to the current command for listing (so that + ``fc -l -10'' prints the last 10 commands) and to _f_i_r_s_t other- + wise. If _f_i_r_s_t is not specified it is set to the previous com- + mand for editing and -16 for listing. + + The --nn option suppresses the command numbers when listing. The + --rr option reverses the order of the commands. If the --ll option + is given, the commands are listed on standard output. Other- + wise, the editor given by _e_n_a_m_e is invoked on a file containing + those commands. If _e_n_a_m_e is not given, the value of the FFCCEEDDIITT + variable is used, and the value of EEDDIITTOORR if FFCCEEDDIITT is not set. + If neither variable is set, _v_i is used. When editing is com- + plete, the edited commands are echoed and executed. + + In the second form, _c_o_m_m_a_n_d is re-executed after each instance + of _p_a_t is replaced by _r_e_p. _C_o_m_m_a_n_d is intepreted the same as + _f_i_r_s_t above. A useful alias to use with this is ``r="fc -s"'', + so that typing ``r cc'' runs the last command beginning with + ``cc'' and typing ``r'' re-executes the last command. + + If the first form is used, the return value is 0 unless an + invalid option is encountered or _f_i_r_s_t or _l_a_s_t specify history + lines out of range. If the --ee option is supplied, the return + value is the value of the last command executed or failure if an + error occurs with the temporary file of commands. If the second + form is used, the return status is that of the command re-exe- + cuted, unless _c_m_d does not specify a valid history line, in + which case ffcc returns failure. + + ffgg [_j_o_b_s_p_e_c] + Resume _j_o_b_s_p_e_c in the foreground, and make it the current job. + If _j_o_b_s_p_e_c is not present, the shell's notion of the _c_u_r_r_e_n_t _j_o_b + is used. The return value is that of the command placed into + the foreground, or failure if run when job control is disabled + or, when run with job control enabled, if _j_o_b_s_p_e_c does not spec- + ify a valid job or _j_o_b_s_p_e_c specifies a job that was started + without job control. + + ggeettooppttss _o_p_t_s_t_r_i_n_g _n_a_m_e [_a_r_g_s] + ggeettooppttss is used by shell procedures to parse positional parame- + ters. _o_p_t_s_t_r_i_n_g contains the option characters to be recog- + nized; 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 and question mark characters may not + be used as option characters. Each time it is invoked, ggeettooppttss + places the next option in the shell variable _n_a_m_e, initializing + _n_a_m_e if it does not exist, and the index of the next argument to + be processed into the variable OOPPTTIINNDD. OOPPTTIINNDD is initialized to + 1 each time the shell or a shell script is invoked. When an + option requires an argument, ggeettooppttss places that argument into + the variable OOPPTTAARRGG. The shell does not reset OOPPTTIINNDD automati- + cally; it must be manually reset between multiple calls to + ggeettooppttss within the same shell invocation if a new set of parame- + ters is to be used. + + When the end of options is encountered, ggeettooppttss exits with a + return value greater than zero. OOPPTTIINNDD is set to the index of + the first non-option argument, and _n_a_m_e is set to ?. + + ggeettooppttss normally parses the positional parameters, but if more + arguments are given in _a_r_g_s, ggeettooppttss parses those instead. + + ggeettooppttss can report errors in two ways. If the first character + of _o_p_t_s_t_r_i_n_g is a colon, _s_i_l_e_n_t error reporting is used. In + normal operation, diagnostic messages are printed when invalid + options or missing option arguments are encountered. If the + variable OOPPTTEERRRR is set to 0, no error messages will be dis- + played, even if the first character of _o_p_t_s_t_r_i_n_g is not a colon. + + If an invalid option is seen, ggeettooppttss places ? into _n_a_m_e and, if + not silent, prints an error message and unsets OOPPTTAARRGG. If + ggeettooppttss is silent, the option character found is placed in + OOPPTTAARRGG and no diagnostic message is printed. + + If a required argument is not found, and ggeettooppttss is not silent, + a question mark (??) is placed in _n_a_m_e, OOPPTTAARRGG is unset, and a + diagnostic message is printed. If ggeettooppttss is silent, then a + colon (::) is placed in _n_a_m_e and OOPPTTAARRGG is set to the option + character found. + + ggeettooppttss returns true if an option, specified or unspecified, is + found. It returns false if the end of options is encountered or + an error occurs. + + hhaasshh [--llrr] [--pp _f_i_l_e_n_a_m_e] [--ddtt] [_n_a_m_e] + Each time hhaasshh is invoked, the full pathname of the command _n_a_m_e + is determined by searching the directories in $$PPAATTHH and remem- + bered. Any previously-remembered pathname is discarded. If the + --pp option is supplied, no path search is performed, and _f_i_l_e_n_a_m_e + is used as the full filename of the command. The --rr option + causes the shell to forget all remembered locations. The --dd + option causes the shell to forget the remembered location of + each _n_a_m_e. If the --tt option is supplied, the full pathname to + which each _n_a_m_e corresponds is printed. If multiple _n_a_m_e argu- + ments are supplied with --tt, the _n_a_m_e is printed before the + hashed full pathname. The --ll option causes output to be dis- + played in a format that may be reused as input. If no arguments + are given, or if only --ll is supplied, information about remem- + bered commands is printed. The return status is true unless a + _n_a_m_e is not found or an invalid option is supplied. + + hheellpp [--ddmmss] [_p_a_t_t_e_r_n] + Display helpful information about builtin commands. If _p_a_t_t_e_r_n + is specified, hheellpp gives detailed help on all commands matching + _p_a_t_t_e_r_n; otherwise help for all the builtins and shell control + structures is printed. + --dd Display a short description of each _p_a_t_t_e_r_n + --mm Display the description of each _p_a_t_t_e_r_n in a manpage-like + format + --ss Display only a short usage synopsis for each _p_a_t_t_e_r_n + + The return status is 0 unless no command matches _p_a_t_t_e_r_n. + + hhiissttoorryy [[_n]] + hhiissttoorryy --cc + hhiissttoorryy --dd _o_f_f_s_e_t + hhiissttoorryy --aannrrww [_f_i_l_e_n_a_m_e] + hhiissttoorryy --pp _a_r_g [_a_r_g _._._.] + hhiissttoorryy --ss _a_r_g [_a_r_g _._._.] + With no options, display the command history list with line num- + bers. Lines listed with a ** have been modified. An argument of + _n lists only the last _n lines. If the shell variable HHIISSTTTTIIMMEE-- + FFOORRMMAATT is set and not null, it is used as a format string for + _s_t_r_f_t_i_m_e(3) to display the time stamp associated with each dis- + played history entry. No intervening blank is printed between + the formatted time stamp and the history line. If _f_i_l_e_n_a_m_e is + supplied, it is used as the name of the history file; if not, + the value of HHIISSTTFFIILLEE is used. Options, if supplied, have the + following meanings: + --cc Clear the history list by deleting all the entries. + --dd _o_f_f_s_e_t + Delete the history entry at position _o_f_f_s_e_t. + --aa Append the ``new'' history lines to the history file. + These are history lines entered since the beginning of + the current bbaasshh session, but not already appended to the + history file. + --nn Read the history lines not already read from the history + file into the current history list. These are lines + appended to the history file since the beginning of the + current bbaasshh session. + --rr Read the contents of the history file and append them to + the current history list. + --ww Write the current history list to the history file, over- + writing the history file's contents. + --pp Perform history substitution on the following _a_r_g_s and + display the result on the standard output. Does not + store the results in the history list. Each _a_r_g must be + quoted to disable normal history expansion. + --ss Store the _a_r_g_s in the history list as a single entry. + The last command in the history list is removed before + the _a_r_g_s are added. + + If the HHIISSTTTTIIMMEEFFOORRMMAATT variable is set, the time stamp informa- + tion associated with each history entry is written to the his- + tory file, marked with the history comment character. When the + history file is read, lines beginning with the history comment + character followed immediately by a digit are interpreted as + timestamps for the following history entry. The return value is + 0 unless an invalid option is encountered, an error occurs while + reading or writing the history file, an invalid _o_f_f_s_e_t is sup- + plied as an argument to --dd, or the history expansion supplied as + an argument to --pp fails. + + jjoobbss [--llnnpprrss] [ _j_o_b_s_p_e_c ... ] + jjoobbss --xx _c_o_m_m_a_n_d [ _a_r_g_s ... ] + The first form lists the active jobs. The options have the fol- + lowing meanings: + --ll List process IDs in addition to the normal information. + --nn Display information only about jobs that have changed + status since the user was last notified of their status. + --pp List only the process ID of the job's process group + leader. + --rr Display only running jobs. + --ss Display only stopped jobs. + + If _j_o_b_s_p_e_c is given, output is restricted to information about + that job. The return status is 0 unless an invalid option is + encountered or an invalid _j_o_b_s_p_e_c is supplied. + + If the --xx option is supplied, jjoobbss replaces any _j_o_b_s_p_e_c found in + _c_o_m_m_a_n_d or _a_r_g_s with the corresponding process group ID, and + executes _c_o_m_m_a_n_d passing it _a_r_g_s, returning its exit status. + + kkiillll [--ss _s_i_g_s_p_e_c | --nn _s_i_g_n_u_m | --_s_i_g_s_p_e_c] [_p_i_d | _j_o_b_s_p_e_c] ... + kkiillll --ll|--LL [_s_i_g_s_p_e_c | _e_x_i_t___s_t_a_t_u_s] + Send the signal named by _s_i_g_s_p_e_c or _s_i_g_n_u_m to the processes + named by _p_i_d or _j_o_b_s_p_e_c. _s_i_g_s_p_e_c is either a case-insensitive + signal name such as SSIIGGKKIILLLL (with or without the SSIIGG prefix) or + a signal number; _s_i_g_n_u_m is a signal number. If _s_i_g_s_p_e_c is not + present, then SSIIGGTTEERRMM is assumed. An argument of --ll lists the + signal names. If any arguments are supplied when --ll is given, + the names of the signals corresponding to the arguments are + listed, and the return status is 0. The _e_x_i_t___s_t_a_t_u_s argument to + --ll is a number specifying either a signal number or the exit + status of a process terminated by a signal. The --LL option is + equivalent to --ll. kkiillll returns true if at least one signal was + successfully sent, or false if an error occurs or an invalid + option is encountered. + + lleett _a_r_g [_a_r_g ...] + Each _a_r_g is an arithmetic expression to be evaluated (see AARRIITTHH-- + MMEETTIICC EEVVAALLUUAATTIIOONN above). If the last _a_r_g evaluates to 0, lleett + returns 1; 0 is returned otherwise. + + llooccaall [_o_p_t_i_o_n] [_n_a_m_e[=_v_a_l_u_e] ... | - ] + For each argument, a local variable named _n_a_m_e is created, and + assigned _v_a_l_u_e. The _o_p_t_i_o_n can be any of the options accepted + by ddeeccllaarree. When llooccaall is used within a function, it causes the + variable _n_a_m_e to have a visible scope restricted to that func- + tion and its children. If _n_a_m_e is -, the set of shell options + is made local to the function in which llooccaall is invoked: shell + options changed using the sseett builtin inside the function are + restored to their original values when the function returns. + With no operands, llooccaall writes a list of local variables to the + standard output. It is an error to use llooccaall when not within a + function. The return status is 0 unless llooccaall is used outside a + function, an invalid _n_a_m_e is supplied, or _n_a_m_e is a readonly + variable. + + llooggoouutt Exit a login shell. + + mmaappffiillee [--dd _d_e_l_i_m] [--nn _c_o_u_n_t] [--OO _o_r_i_g_i_n] [--ss _c_o_u_n_t] [--tt] [--uu _f_d] [--CC + _c_a_l_l_b_a_c_k] [--cc _q_u_a_n_t_u_m] [_a_r_r_a_y] + rreeaaddaarrrraayy [--dd _d_e_l_i_m] [--nn _c_o_u_n_t] [--OO _o_r_i_g_i_n] [--ss _c_o_u_n_t] [--tt] [--uu _f_d] [--CC + _c_a_l_l_b_a_c_k] [--cc _q_u_a_n_t_u_m] [_a_r_r_a_y] + Read lines from the standard input into the indexed array vari- + able _a_r_r_a_y, or from file descriptor _f_d if the --uu option is sup- + plied. The variable MMAAPPFFIILLEE is the default _a_r_r_a_y. Options, if + supplied, have the following meanings: + --dd The first character of _d_e_l_i_m is used to terminate each + input line, rather than newline. + --nn Copy at most _c_o_u_n_t lines. If _c_o_u_n_t is 0, all lines are + copied. + --OO Begin assigning to _a_r_r_a_y at index _o_r_i_g_i_n. The default + index is 0. + --ss Discard the first _c_o_u_n_t lines read. + --tt Remove a trailing _d_e_l_i_m (default newline) from each line + read. + --uu Read lines from file descriptor _f_d instead of the stan- + dard input. + --CC Evaluate _c_a_l_l_b_a_c_k each time _q_u_a_n_t_u_m lines are read. The + --cc option specifies _q_u_a_n_t_u_m. + --cc Specify the number of lines read between each call to + _c_a_l_l_b_a_c_k. + + If --CC is specified without --cc, the default quantum is 5000. + When _c_a_l_l_b_a_c_k is evaluated, it is supplied the index of the next + array element to be assigned and the line to be assigned to that + element as additional arguments. _c_a_l_l_b_a_c_k is evaluated after + the line is read but before the array element is assigned. + + If not supplied with an explicit origin, mmaappffiillee will clear + _a_r_r_a_y before assigning to it. + + mmaappffiillee returns successfully unless an invalid option or option + argument is supplied, _a_r_r_a_y is invalid or unassignable, or if + _a_r_r_a_y is not an indexed array. + + ppooppdd [-nn] [+_n] [-_n] + Removes entries from the directory stack. With no arguments, + removes the top directory from the stack, and performs a ccdd to + the new top directory. Arguments, if supplied, have the follow- + ing meanings: + --nn Suppresses the normal change of directory when removing + directories from the stack, so that only the stack is + manipulated. + ++_n Removes the _nth entry counting from the left of the list + shown by ddiirrss, starting with zero. For example: ``popd + +0'' removes the first directory, ``popd +1'' the second. + --_n Removes the _nth entry counting from the right of the list + shown by ddiirrss, starting with zero. For example: ``popd + -0'' removes the last directory, ``popd -1'' the next to + last. + + If the ppooppdd command is successful, a ddiirrss is performed as well, + and the return status is 0. ppooppdd returns false if an invalid + option is encountered, the directory stack is empty, a non-exis- + tent directory stack entry is specified, or the directory change + fails. + + pprriinnttff [--vv _v_a_r] _f_o_r_m_a_t [_a_r_g_u_m_e_n_t_s] + Write the formatted _a_r_g_u_m_e_n_t_s to the standard output under the + control of the _f_o_r_m_a_t. The --vv option causes the output to be + assigned to the variable _v_a_r rather than being printed to the + standard output. + + The _f_o_r_m_a_t 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 _a_r_g_u_m_e_n_t. In + addition to the standard _p_r_i_n_t_f(1) format specifications, pprriinnttff + interprets the following extensions: + %%bb causes pprriinnttff to expand backslash escape sequences in the + corresponding _a_r_g_u_m_e_n_t in the same way as eecchhoo --ee. + %%qq causes pprriinnttff to output the corresponding _a_r_g_u_m_e_n_t in a + format that can be reused as shell input. + %%((_d_a_t_e_f_m_t))TT + causes pprriinnttff to output the date-time string resulting + from using _d_a_t_e_f_m_t as a format string for _s_t_r_f_t_i_m_e(3). + The corresponding _a_r_g_u_m_e_n_t is an integer representing the + number of seconds since the epoch. Two special argument + values may be used: -1 represents the current time, and + -2 represents the time the shell was invoked. If no + argument is specified, conversion behaves as if -1 had + been given. This is an exception to the usual pprriinnttff + behavior. + + Arguments to non-string format specifiers are treated as C con- + stants, except that a leading plus or minus sign is allowed, and + if the leading character is a single or double quote, the value + is the ASCII value of the following character. + + The _f_o_r_m_a_t is reused as necessary to consume all of the _a_r_g_u_- + _m_e_n_t_s. If the _f_o_r_m_a_t requires more _a_r_g_u_m_e_n_t_s 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. + + ppuusshhdd [--nn] [+_n] [-_n] + ppuusshhdd [--nn] [_d_i_r] + Adds a directory to the top of the directory stack, or rotates + the stack, making the new top of the stack the current working + directory. With no arguments, ppuusshhdd exchanges the top two + directories and returns 0, unless the directory stack is empty. + Arguments, if supplied, have the following meanings: + --nn Suppresses the normal change of directory when rotating + or adding directories to the stack, so that only the + stack is manipulated. + ++_n Rotates the stack so that the _nth directory (counting + from the left of the list shown by ddiirrss, starting with + zero) is at the top. + --_n Rotates the stack so that the _nth directory (counting + from the right of the list shown by ddiirrss, starting with + zero) is at the top. + _d_i_r Adds _d_i_r to the directory stack at the top, making it the + new current working directory as if it had been supplied + as the argument to the ccdd builtin. + + If the ppuusshhdd command is successful, a ddiirrss is performed as well. + If the first form is used, ppuusshhdd returns 0 unless the cd to _d_i_r + fails. With the second form, ppuusshhdd returns 0 unless the direc- + tory stack is empty, a non-existent directory stack element is + specified, or the directory change to the specified new current + directory fails. + + ppwwdd [--LLPP] + Print the absolute pathname of the current working directory. + The pathname printed contains no symbolic links if the --PP option + is supplied or the --oo pphhyyssiiccaall option to the sseett builtin command + is enabled. If the --LL option is used, the pathname printed may + contain symbolic links. The return status is 0 unless an error + occurs while reading the name of the current directory or an + invalid option is supplied. + + rreeaadd [--eerrss] [--aa _a_n_a_m_e] [--dd _d_e_l_i_m] [--ii _t_e_x_t] [--nn _n_c_h_a_r_s] [--NN _n_c_h_a_r_s] [--pp + _p_r_o_m_p_t] [--tt _t_i_m_e_o_u_t] [--uu _f_d] [_n_a_m_e ...] + One line is read from the standard input, or from the file + descriptor _f_d supplied as an argument to the --uu option, split + into words as described above under WWoorrdd SSpplliittttiinngg, and the + first word is assigned to the first _n_a_m_e, the second word to the + second _n_a_m_e, and so on. If there are more words than names, the + remaining words and their intervening delimiters are assigned to + the last _n_a_m_e. If there are fewer words read from the input + stream than names, the remaining names are assigned empty val- + ues. The characters in IIFFSS are used to split the line into + words using the same rules the shell uses for expansion + (described above under WWoorrdd SSpplliittttiinngg). The backslash character + (\\) may be used to remove any special meaning for the next char- + acter read and for line continuation. Options, if supplied, + have the following meanings: + --aa _a_n_a_m_e + The words are assigned to sequential indices of the array + variable _a_n_a_m_e, starting at 0. _a_n_a_m_e is unset before any + new values are assigned. Other _n_a_m_e arguments are + ignored. + --dd _d_e_l_i_m + The first character of _d_e_l_i_m is used to terminate the + input line, rather than newline. + --ee If the standard input is coming from a terminal, rreeaaddlliinnee + (see RREEAADDLLIINNEE above) is used to obtain the line. Read- + line uses the current (or default, if line editing was + not previously active) editing settings. + --ii _t_e_x_t + If rreeaaddlliinnee is being used to read the line, _t_e_x_t is + placed into the editing buffer before editing begins. + --nn _n_c_h_a_r_s + rreeaadd returns after reading _n_c_h_a_r_s characters rather than + waiting for a complete line of input, but honors a delim- + iter if fewer than _n_c_h_a_r_s characters are read before the + delimiter. + --NN _n_c_h_a_r_s + rreeaadd returns after reading exactly _n_c_h_a_r_s characters + rather than waiting for a complete line of input, unless + EOF is encountered or rreeaadd times out. Delimiter charac- + ters encountered in the input are not treated specially + and do not cause rreeaadd to return until _n_c_h_a_r_s characters + are read. The result is not split on the characters in + IIFFSS; the intent is that the variable is assigned exactly + the characters read (with the exception of backslash; see + the --rr option below). + --pp _p_r_o_m_p_t + Display _p_r_o_m_p_t on standard error, without a trailing new- + line, before attempting to read any input. The prompt is + displayed only if input is coming from a terminal. + --rr Backslash does not act as an escape character. The back- + slash is considered to be part of the line. In particu- + lar, a backslash-newline pair may not be used as a line + continuation. + --ss Silent mode. If input is coming from a terminal, charac- + ters are not echoed. + --tt _t_i_m_e_o_u_t + Cause rreeaadd to time out and return failure if a complete + line of input (or a specified number of characters) is + not read within _t_i_m_e_o_u_t seconds. _t_i_m_e_o_u_t may be a deci- + mal number with a fractional portion following the deci- + mal point. This option is only effective if rreeaadd is + reading input from a terminal, pipe, or other special + file; it has no effect when reading from regular files. + If rreeaadd times out, rreeaadd saves any partial input read into + the specified variable _n_a_m_e. If _t_i_m_e_o_u_t is 0, rreeaadd + returns immediately, without trying to read any data. + The exit status is 0 if input is available on the speci- + fied file descriptor, non-zero otherwise. The exit sta- + tus is greater than 128 if the timeout is exceeded. + --uu _f_d Read input from file descriptor _f_d. + + If no _n_a_m_e_s are supplied, the line read is assigned to the vari- + able RREEPPLLYY. The exit status is zero, unless end-of-file is + encountered, rreeaadd times out (in which case the status is greater + than 128), a variable assignment error (such as assigning to a + readonly variable) occurs, or an invalid file descriptor is sup- + plied as the argument to --uu. + + rreeaaddoonnllyy [--aaAAff] [--pp] [_n_a_m_e[=_w_o_r_d] ...] + The given _n_a_m_e_s are marked readonly; the values of these _n_a_m_e_s + may not be changed by subsequent assignment. If the --ff option + is supplied, the functions corresponding to the _n_a_m_e_s are so + marked. The --aa option restricts the variables to indexed + arrays; the --AA option restricts the variables to associative + arrays. If both options are supplied, --AA takes precedence. If + no _n_a_m_e arguments are given, or if the --pp option is supplied, a + list of all readonly names is printed. The other options may be + used to restrict the output to a subset of the set of readonly + names. The --pp option causes output to be displayed in a format + that may be reused as input. If a variable name is followed by + =_w_o_r_d, the value of the variable is set to _w_o_r_d. The return + status is 0 unless an invalid option is encountered, one of the + _n_a_m_e_s is not a valid shell variable name, or --ff is supplied with + a _n_a_m_e that is not a function. + + rreettuurrnn [_n] + Causes a function to stop executing and return the value speci- + fied by _n to its caller. If _n is omitted, the return status is + that of the last command executed in the function body. If + rreettuurrnn is executed by a trap handler, the last command used to + determine the status is the last command executed before the + trap handler. if rreettuurrnn is executed during a DDEEBBUUGG trap, the + last command used to determine the status is the last command + executed by the trap handler before rreettuurrnn was invoked. If + rreettuurrnn is used outside a function, but during execution of a + script by the .. (ssoouurrccee) command, it causes the shell to stop + executing that script and return either _n or the exit status of + the last command executed within the script as the exit status + of the script. If _n is supplied, the return value is its least + significant 8 bits. The return status is non-zero if rreettuurrnn is + supplied a non-numeric argument, or is used outside a function + and not during execution of a script by .. or ssoouurrccee. Any com- + mand associated with the RREETTUURRNN trap is executed before execu- + tion resumes after the function or script. + + sseett [----aabbeeffhhkkmmnnppttuuvvxxBBCCEEHHPPTT] [--oo _o_p_t_i_o_n_-_n_a_m_e] [_a_r_g ...] + sseett [++aabbeeffhhkkmmnnppttuuvvxxBBCCEEHHPPTT] [++oo _o_p_t_i_o_n_-_n_a_m_e] [_a_r_g ...] + 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. Read-only variables can- + not be reset. In _p_o_s_i_x mode, only shell variables are listed. + The output is sorted according to the current locale. When + options are specified, they set or unset shell attributes. Any + arguments remaining after option processing are treated as val- + ues for the positional parameters and are assigned, in order, to + $$11, $$22, ...... $$_n. Options, if specified, have the following + meanings: + --aa Each variable or function that is created or modified is + given the export attribute and marked for export to the + environment of subsequent commands. + --bb Report the status of terminated background jobs immedi- + ately, rather than before the next primary prompt. This + is effective only when job control is enabled. + --ee Exit immediately if a _p_i_p_e_l_i_n_e (which may consist of a + single _s_i_m_p_l_e _c_o_m_m_a_n_d), a _l_i_s_t, or a _c_o_m_p_o_u_n_d _c_o_m_m_a_n_d + (see SSHHEELLLL GGRRAAMMMMAARR above), exits with a non-zero status. + The shell does not exit if the command that fails is + part of the command list immediately following a wwhhiillee + or uunnttiill keyword, part of the test following the iiff or + eelliiff reserved words, part of any command executed in a + &&&& or |||| list except the command following the final &&&& + or ||||, any command in a pipeline but the last, or if the + command's return value is being inverted with !!. If a + compound command other than a subshell returns a non- + zero status because a command failed while --ee was being + ignored, the shell does not exit. A trap on EERRRR, if + set, is executed before the shell exits. This option + applies to the shell environment and each subshell envi- + ronment separately (see CCOOMMMMAANNDD EEXXEECCUUTTIIOONN EENNVVIIRROONNMMEENNTT + above), and may cause subshells to exit before executing + all the commands in the subshell. + + If a compound command or shell function executes in a + context where --ee is being ignored, none of the commands + executed within the compound command or function body + will be affected by the --ee setting, even if --ee is set + and a command returns a failure status. If a compound + command or shell function sets --ee while executing in a + context where --ee is ignored, that setting will not have + any effect until the compound command or the command + containing the function call completes. + --ff Disable pathname expansion. + --hh Remember the location of commands as they are looked up + for execution. This is enabled by default. + --kk All arguments in the form of assignment statements are + placed in the environment for a command, not just those + that precede the command name. + --mm Monitor mode. Job control is enabled. This option is + on by default for interactive shells on systems that + support it (see JJOOBB CCOONNTTRROOLL above). All processes run + in a separate process group. When a background job com- + pletes, the shell prints a line containing its exit sta- + tus. + --nn Read commands but do not execute them. This may be used + to check a shell script for syntax errors. This is + ignored by interactive shells. + --oo _o_p_t_i_o_n_-_n_a_m_e + The _o_p_t_i_o_n_-_n_a_m_e can be one of the following: + aalllleexxppoorrtt + Same as --aa. + bbrraacceeeexxppaanndd + Same as --BB. + eemmaaccss Use an emacs-style command line editing inter- + face. This is enabled by default when the shell + is interactive, unless the shell is started with + the ----nnooeeddiittiinngg option. This also affects the + editing interface used for rreeaadd --ee. + eerrrreexxiitt Same as --ee. + eerrrrttrraaccee + Same as --EE. + ffuunnccttrraaccee + Same as --TT. + hhaasshhaallll Same as --hh. + hhiisstteexxppaanndd + Same as --HH. + hhiissttoorryy Enable command history, as described above under + HHIISSTTOORRYY. This option is on by default in inter- + active shells. + iiggnnoorreeeeooff + The effect is as if the shell command + ``IGNOREEOF=10'' had been executed (see SShheellll + VVaarriiaabblleess above). + kkeeyywwoorrdd Same as --kk. + mmoonniittoorr Same as --mm. + nnoocclloobbbbeerr + Same as --CC. + nnooeexxeecc Same as --nn. + nnoogglloobb Same as --ff. + nnoolloogg Currently ignored. + nnoottiiffyy Same as --bb. + nnoouunnsseett Same as --uu. + oonneeccmmdd Same as --tt. + pphhyyssiiccaall + Same as --PP. + ppiippeeffaaiill + 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. + ppoossiixx Change the behavior of bbaasshh where the default + operation differs from the POSIX standard to + match the standard (_p_o_s_i_x _m_o_d_e). See SSEEEE AALLSSOO + below for a reference to a document that details + how posix mode affects bash's behavior. + pprriivviilleeggeedd + Same as --pp. + vveerrbboossee Same as --vv. + vvii Use a vi-style command line editing interface. + This also affects the editing interface used for + rreeaadd --ee. + xxttrraaccee Same as --xx. + If --oo is supplied with no _o_p_t_i_o_n_-_n_a_m_e, the values of the + current options are printed. If ++oo is supplied with no + _o_p_t_i_o_n_-_n_a_m_e, a series of sseett commands to recreate the + current option settings is displayed on the standard + output. + --pp Turn on _p_r_i_v_i_l_e_g_e_d mode. In this mode, the $$EENNVV and + $$BBAASSHH__EENNVV files are not processed, shell functions are + not inherited from the environment, and the SSHHEELLLLOOPPTTSS, + BBAASSHHOOPPTTSS, CCDDPPAATTHH, and GGLLOOBBIIGGNNOORREE variables, if they + appear in the environment, are ignored. If the shell is + started with the effective user (group) id not equal to + the real user (group) id, and the --pp option is not sup- + plied, these actions are taken and the effective user id + is set to the real user id. If the --pp option is sup- + plied 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. + --tt Exit after reading and executing one command. + --uu Treat unset variables and parameters other than the spe- + cial parameters "@" and "*" as an error when performing + parameter expansion. If expansion is attempted on an + unset variable or parameter, the shell prints an error + message, and, if not interactive, exits with a non-zero + status. + --vv Print shell input lines as they are read. + --xx After expanding each _s_i_m_p_l_e _c_o_m_m_a_n_d, ffoorr command, ccaassee + command, sseelleecctt command, or arithmetic ffoorr command, dis- + play the expanded value of PPSS44, followed by the command + and its expanded arguments or associated word list. + --BB The shell performs brace expansion (see BBrraaccee EExxppaannssiioonn + above). This is on by default. + --CC If set, bbaasshh does not overwrite an existing file with + the >>, >>&&, and <<>> redirection operators. This may be + overridden when creating output files by using the redi- + rection operator >>|| instead of >>. + --EE If set, any trap on EERRRR is inherited by shell functions, + command substitutions, and commands executed in a sub- + shell environment. The EERRRR trap is normally not inher- + ited in such cases. + --HH Enable !! style history substitution. This option is on + by default when the shell is interactive. + --PP If set, the shell does not resolve symbolic links when + executing commands such as ccdd that change the current + working directory. It uses the physical directory + structure instead. By default, bbaasshh follows the logical + chain of directories when performing commands which + change the current directory. + --TT If set, any traps on DDEEBBUUGG and RREETTUURRNN are inherited by + shell functions, command substitutions, and commands + executed in a subshell environment. The DDEEBBUUGG and + RREETTUURRNN traps are normally not inherited in such cases. + ---- If no arguments follow this option, then the positional + parameters are unset. Otherwise, the positional parame- + ters are set to the _a_r_gs, even if some of them begin + with a --. + -- Signal the end of options, cause all remaining _a_r_gs to + be assigned to the positional parameters. The --xx and --vv + options are turned off. If there are no _a_r_gs, the posi- + tional parameters remain unchanged. + + The options are off by default unless otherwise noted. Using + + rather than - causes these options to be turned off. The + options can also be specified as arguments to an invocation of + the shell. The current set of options may be found in $$--. The + return status is always true unless an invalid option is encoun- + tered. + + sshhiifftt [_n] + The positional parameters from _n+1 ... are renamed to $$11 ........ + Parameters represented by the numbers $$## down to $$##-_n+1 are + unset. _n must be a non-negative number less than or equal to + $$##. If _n is 0, no parameters are changed. If _n is not given, + it is assumed to be 1. If _n is greater than $$##, the positional + parameters are not changed. The return status is greater than + zero if _n is greater than $$## or less than zero; otherwise 0. + + sshhoopptt [--ppqqssuu] [--oo] [_o_p_t_n_a_m_e ...] + Toggle the values of settings controlling optional shell behav- + ior. The settings can be either those listed below, or, if the + --oo option is used, those available with the --oo option to the sseett + builtin command. With no options, or with the --pp option, a list + of all settable options is displayed, with an indication of + whether or not each is set. The --pp option causes output to be + displayed in a form that may be reused as input. Other options + have the following meanings: + --ss Enable (set) each _o_p_t_n_a_m_e. + --uu Disable (unset) each _o_p_t_n_a_m_e. + --qq Suppresses normal output (quiet mode); the return status + indicates whether the _o_p_t_n_a_m_e is set or unset. If multi- + ple _o_p_t_n_a_m_e arguments are given with --qq, the return sta- + tus is zero if all _o_p_t_n_a_m_e_s are enabled; non-zero other- + wise. + --oo Restricts the values of _o_p_t_n_a_m_e to be those defined for + the --oo option to the sseett builtin. + + If either --ss or --uu is used with no _o_p_t_n_a_m_e arguments, sshhoopptt + shows only those options which are set or unset, respectively. + Unless otherwise noted, the sshhoopptt options are disabled (unset) + by default. + + The return status when listing options is zero if all _o_p_t_n_a_m_e_s + are enabled, non-zero otherwise. When setting or unsetting + options, the return status is zero unless an _o_p_t_n_a_m_e is not a + valid shell option. + + The list of sshhoopptt options is: + + aauuttooccdd If set, a command name that is the name of a directory + is executed as if it were the argument to the ccdd com- + mand. This option is only used by interactive shells. + ccddaabbllee__vvaarrss + If set, an argument to the ccdd builtin command that is + not a directory is assumed to be the name of a variable + whose value is the directory to change to. + ccddssppeellll If set, minor errors in the spelling of a directory com- + ponent in a ccdd command will be corrected. The errors + checked for are transposed characters, a missing charac- + ter, and one character too many. If a correction is + found, the corrected filename is printed, and the com- + mand proceeds. This option is only used by interactive + shells. + cchheecckkhhaasshh + If set, bbaasshh checks that a command found in the hash ta- + ble exists before trying to execute it. If a hashed + command no longer exists, a normal path search is per- + formed. + cchheecckkjjoobbss + If set, bbaasshh 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 JJOOBB CCOONNTTRROOLL above). The shell always postpones + exiting if any jobs are stopped. + cchheecckkwwiinnssiizzee + If set, bbaasshh checks the window size after each command + and, if necessary, updates the values of LLIINNEESS and CCOOLL-- + UUMMNNSS. + ccmmddhhiisstt If set, bbaasshh attempts to save all lines of a multiple- + line command in the same history entry. This allows + easy re-editing of multi-line commands. + ccoommppaatt3311 + If set, bbaasshh changes its behavior to that of version 3.1 + with respect to quoted arguments to the [[[[ conditional + command's ==~~ operator and locale-specific string compar- + ison when using the [[[[ conditional command's << and >> + operators. Bash versions prior to bash-4.1 use ASCII + collation and _s_t_r_c_m_p(3); bash-4.1 and later use the cur- + rent locale's collation sequence and _s_t_r_c_o_l_l(3). + ccoommppaatt3322 + If set, bbaasshh changes its behavior to that of version 3.2 + with respect to locale-specific string comparison when + using the [[[[ conditional command's << and >> operators + (see previous item) and the effect of interrupting a + command list. Bash versions 3.2 and earlier continue + with the next command in the list after one terminates + due to an interrupt. + ccoommppaatt4400 + If set, bbaasshh changes its behavior to that of version 4.0 + with respect to locale-specific string comparison when + using the [[[[ conditional command's << and >> operators + (see description of ccoommppaatt3311) and the effect of inter- + rupting a command list. Bash versions 4.0 and later + interrupt the list as if the shell received the inter- + rupt; previous versions continue with the next command + in the list. + ccoommppaatt4411 + If set, bbaasshh, when in _p_o_s_i_x mode, treats a single quote + in a double-quoted parameter expansion as a special + character. The single quotes must match (an even num- + ber) and the characters between the single quotes are + considered quoted. This is the behavior of posix mode + through version 4.1. The default bash behavior remains + as in previous versions. + ccoommppaatt4422 + If set, bbaasshh does not process the replacement string in + the pattern substitution word expansion using quote + removal. + ccoommppaatt4433 + If set, bbaasshh does not print a warning message if an + attempt is made to use a quoted compound array assign- + ment as an argument to ddeeccllaarree, makes word expansion + errors non-fatal errors that cause the current command + to fail (the default behavior is to make them fatal + errors that cause the shell to exit), and does not reset + the loop state when a shell function is executed (this + allows bbrreeaakk or ccoonnttiinnuuee in a shell function to affect + loops in the caller's context). + ccoommpplleettee__ffuullllqquuoottee + If set, bbaasshh quotes all shell metacharacters in file- + names and directory names when performing completion. + If not set, bbaasshh removes metacharacters such as the dol- + lar sign from the set of characters that will be quoted + in completed filenames when these metacharacters appear + in shell variable references in words to be completed. + This means that dollar signs in variable names that + expand to directories will not be quoted; however, any + dollar signs appearing in filenames will not be quoted, + either. This is active only when bash is using back- + slashes to quote completed filenames. This variable is + set by default, which is the default bash behavior in + versions through 4.2. + ddiirreexxppaanndd + If set, bbaasshh replaces directory names with the results + of word expansion when performing filename completion. + This changes the contents of the readline editing buf- + fer. If not set, bbaasshh attempts to preserve what the + user typed. + ddiirrssppeellll + If set, bbaasshh attempts spelling correction on directory + names during word completion if the directory name ini- + tially supplied does not exist. + ddoottgglloobb If set, bbaasshh includes filenames beginning with a `.' in + the results of pathname expansion. + eexxeeccffaaiill + If set, a non-interactive shell will not exit if it can- + not execute the file specified as an argument to the + eexxeecc builtin command. An interactive shell does not + exit if eexxeecc fails. + eexxppaanndd__aalliiaasseess + If set, aliases are expanded as described above under + AALLIIAASSEESS. This option is enabled by default for interac- + tive shells. + eexxttddeebbuugg + If set at shell invocation, arrange to execute the + debugger profile before the shell starts, identical to + the ----ddeebbuuggggeerr option. If set after invocation, behav- + ior intended for use by debuggers is enabled: + 11.. The --FF option to the ddeeccllaarree builtin displays the + source file name and line number corresponding to + each function name supplied as an argument. + 22.. If the command run by the DDEEBBUUGG trap returns a + non-zero value, the next command is skipped and + not executed. + 33.. If the command run by the DDEEBBUUGG trap returns a + value of 2, and the shell is executing in a sub- + routine (a shell function or a shell script exe- + cuted by the .. or ssoouurrccee builtins), the shell + simulates a call to rreettuurrnn. + 44.. BBAASSHH__AARRGGCC and BBAASSHH__AARRGGVV are updated as described + in their descriptions above. + 55.. Function tracing is enabled: command substitu- + tion, shell functions, and subshells invoked with + (( _c_o_m_m_a_n_d )) inherit the DDEEBBUUGG and RREETTUURRNN traps. + 66.. Error tracing is enabled: command substitution, + shell functions, and subshells invoked with (( + _c_o_m_m_a_n_d )) inherit the EERRRR trap. + eexxttgglloobb If set, the extended pattern matching features described + above under PPaatthhnnaammee EExxppaannssiioonn are enabled. + eexxttqquuoottee + If set, $$'_s_t_r_i_n_g' and $$"_s_t_r_i_n_g" quoting is performed + within $${{_p_a_r_a_m_e_t_e_r}} expansions enclosed in double + quotes. This option is enabled by default. + ffaaiillgglloobb + If set, patterns which fail to match filenames during + pathname expansion result in an expansion error. + ffoorrccee__ffiiggnnoorree + If set, the suffixes specified by the FFIIGGNNOORREE shell + variable cause words to be ignored when performing word + completion even if the ignored words are the only possi- + ble completions. See SSHHEELLLL VVAARRIIAABBLLEESS above for a + description of FFIIGGNNOORREE. This option is enabled by + default. + gglloobbaasscciiiirraannggeess + If set, range expressions used in pattern matching + bracket expressions (see PPaatttteerrnn MMaattcchhiinngg above) behave + as if in the traditional C locale when performing com- + parisons. That is, the current locale's collating + sequence is not taken into account, so bb will not col- + late between AA and BB, and upper-case and lower-case + ASCII characters will collate together. + gglloobbssttaarr + If set, the pattern **** used in a pathname expansion con- + text will match all files and zero or more directories + and subdirectories. If the pattern is followed by a //, + only directories and subdirectories match. + ggnnuu__eerrrrffmmtt + If set, shell error messages are written in the standard + GNU error message format. + hhiissttaappppeenndd + If set, the history list is appended to the file named + by the value of the HHIISSTTFFIILLEE variable when the shell + exits, rather than overwriting the file. + hhiissttrreeeeddiitt + If set, and rreeaaddlliinnee is being used, a user is given the + opportunity to re-edit a failed history substitution. + hhiissttvveerriiffyy + If set, and rreeaaddlliinnee is being used, the results of his- + tory substitution are not immediately passed to the + shell parser. Instead, the resulting line is loaded + into the rreeaaddlliinnee editing buffer, allowing further modi- + fication. + hhoossttccoommpplleettee + If set, and rreeaaddlliinnee is being used, bbaasshh will attempt to + perform hostname completion when a word containing a @@ + is being completed (see CCoommpplleettiinngg under RREEAADDLLIINNEE + above). This is enabled by default. + hhuuppoonneexxiitt + If set, bbaasshh will send SSIIGGHHUUPP to all jobs when an inter- + active login shell exits. + iinnhheerriitt__eerrrreexxiitt + If set, command substitution inherits the value of the + eerrrreexxiitt option, instead of unsetting it in the subshell + environment. This option is enabled when _p_o_s_i_x _m_o_d_e is + enabled. + iinntteerraaccttiivvee__ccoommmmeennttss + If set, allow a word beginning with ## to cause that word + and all remaining characters on that line to be ignored + in an interactive shell (see CCOOMMMMEENNTTSS above). This + option is enabled by default. + llaassttppiippee + If set, and job control is not active, the shell runs + the last command of a pipeline not executed in the back- + ground in the current shell environment. + lliitthhiisstt If set, and the ccmmddhhiisstt option is enabled, multi-line + commands are saved to the history with embedded newlines + rather than using semicolon separators where possible. + llooggiinn__sshheellll + The shell sets this option if it is started as a login + shell (see IINNVVOOCCAATTIIOONN above). The value may not be + changed. + mmaaiillwwaarrnn + If set, and a file that bbaasshh is checking for mail has + been accessed since the last time it was checked, the + message ``The mail in _m_a_i_l_f_i_l_e has been read'' is dis- + played. + nnoo__eemmppttyy__ccmmdd__ccoommpplleettiioonn + If set, and rreeaaddlliinnee is being used, bbaasshh will not + attempt to search the PPAATTHH for possible completions when + completion is attempted on an empty line. + nnooccaasseegglloobb + If set, bbaasshh matches filenames in a case-insensitive + fashion when performing pathname expansion (see PPaatthhnnaammee + EExxppaannssiioonn above). + nnooccaasseemmaattcchh + If set, bbaasshh matches patterns in a case-insensitive + fashion when performing matching while executing ccaassee or + [[[[ conditional commands, when performing pattern substi- + tution word expansions, or when filtering possible com- + pletions as part of programmable completion. + nnuullllgglloobb + If set, bbaasshh allows patterns which match no files (see + PPaatthhnnaammee EExxppaannssiioonn above) to expand to a null string, + rather than themselves. + pprrooggccoommpp + If set, the programmable completion facilities (see PPrroo-- + ggrraammmmaabbllee CCoommpplleettiioonn above) are enabled. This option is + enabled by default. + pprroommppttvvaarrss + If set, prompt strings undergo parameter expansion, com- + mand substitution, arithmetic expansion, and quote + removal after being expanded as described in PPRROOMMPPTTIINNGG + above. This option is enabled by default. + rreessttrriicctteedd__sshheellll + The shell sets this option if it is started in + restricted mode (see RREESSTTRRIICCTTEEDD SSHHEELLLL below). The value + may not be changed. This is not reset when the startup + files are executed, allowing the startup files to dis- + cover whether or not a shell is restricted. + sshhiifftt__vveerrbboossee + If set, the sshhiifftt builtin prints an error message when + the shift count exceeds the number of positional parame- + ters. + ssoouurrcceeppaatthh + If set, the ssoouurrccee (..) builtin uses the value of PPAATTHH to + find the directory containing the file supplied as an + argument. This option is enabled by default. + xxppgg__eecchhoo + If set, the eecchhoo builtin expands backslash-escape + sequences by default. + + ssuussppeenndd [--ff] + Suspend the execution of this shell until it receives a SSIIGGCCOONNTT + signal. A login shell cannot be suspended; the --ff option can be + used to override this and force the suspension. The return sta- + tus is 0 unless the shell is a login shell and --ff is not sup- + plied, or if job control is not enabled. + + tteesstt _e_x_p_r + [[ _e_x_p_r ]] + Return a status of 0 (true) or 1 (false) depending on the evalu- + ation of the conditional expression _e_x_p_r. Each operator and op- + erand must be a separate argument. Expressions are composed of + the primaries described above under CCOONNDDIITTIIOONNAALL EEXXPPRREESSSSIIOONNSS. + tteesstt does not accept any options, nor does it accept and ignore + an argument of ---- as signifying the end of options. + + Expressions may be combined using the following operators, + listed in decreasing order of precedence. The evaluation + depends on the number of arguments; see below. Operator prece- + dence is used when there are five or more arguments. + !! _e_x_p_r True if _e_x_p_r is false. + (( _e_x_p_r )) + Returns the value of _e_x_p_r. This may be used to override + the normal precedence of operators. + _e_x_p_r_1 -aa _e_x_p_r_2 + True if both _e_x_p_r_1 and _e_x_p_r_2 are true. + _e_x_p_r_1 -oo _e_x_p_r_2 + True if either _e_x_p_r_1 or _e_x_p_r_2 is true. + + tteesstt and [[ evaluate conditional expressions using a set of rules + based on the number of arguments. + + 0 arguments + The expression is false. + 1 argument + The expression is true if and only if the argument is not + null. + 2 arguments + If the first argument is !!, the expression is true if and + only if the second argument is null. If the first argu- + ment is one of the unary conditional operators listed + above under CCOONNDDIITTIIOONNAALL EEXXPPRREESSSSIIOONNSS, the expression is + true if the unary test is true. If the first argument is + not a valid unary conditional operator, the expression is + false. + 3 arguments + The following conditions are applied in the order listed. + If the second argument is one of the binary conditional + operators listed above under CCOONNDDIITTIIOONNAALL EEXXPPRREESSSSIIOONNSS, the + result of the expression is the result of the binary test + using the first and third arguments as operands. The --aa + and --oo operators are considered binary operators when + there are three arguments. If the first argument is !!, + the value is the negation of the two-argument test using + the second and third arguments. If the first argument is + exactly (( and the third argument is exactly )), the result + is the one-argument test of the second argument. Other- + wise, the expression is false. + 4 arguments + If the first argument is !!, the result is the negation of + the three-argument expression composed of the remaining + arguments. Otherwise, the expression is parsed and eval- + uated according to precedence using the rules listed + above. + 5 or more arguments + The expression is parsed and evaluated according to + precedence using the rules listed above. + + When used with tteesstt or [[, the << and >> operators sort lexico- + graphically using ASCII ordering. + + ttiimmeess Print the accumulated user and system times for the shell and + for processes run from the shell. The return status is 0. + + ttrraapp [--llpp] [[_a_r_g] _s_i_g_s_p_e_c ...] + The command _a_r_g is to be read and executed when the shell + receives signal(s) _s_i_g_s_p_e_c. If _a_r_g is absent (and there is a + single _s_i_g_s_p_e_c) or --, each specified signal is reset to its + original disposition (the value it had upon entrance to the + shell). If _a_r_g is the null string the signal specified by each + _s_i_g_s_p_e_c is ignored by the shell and by the commands it invokes. + If _a_r_g is not present and --pp has been supplied, then the trap + commands associated with each _s_i_g_s_p_e_c are displayed. If no + arguments are supplied or if only --pp is given, ttrraapp prints the + list of commands associated with each signal. The --ll option + causes the shell to print a list of signal names and their cor- + responding numbers. Each _s_i_g_s_p_e_c is either a signal name + defined in <_s_i_g_n_a_l_._h>, or a signal number. Signal names are + case insensitive and the SSIIGG prefix is optional. + + If a _s_i_g_s_p_e_c is EEXXIITT (0) the command _a_r_g is executed on exit + from the shell. If a _s_i_g_s_p_e_c is DDEEBBUUGG, the command _a_r_g is exe- + cuted before every _s_i_m_p_l_e _c_o_m_m_a_n_d, _f_o_r command, _c_a_s_e command, + _s_e_l_e_c_t command, every arithmetic _f_o_r command, and before the + first command executes in a shell function (see SSHHEELLLL GGRRAAMMMMAARR + above). Refer to the description of the eexxttddeebbuugg option to the + sshhoopptt builtin for details of its effect on the DDEEBBUUGG trap. If a + _s_i_g_s_p_e_c is RREETTUURRNN, the command _a_r_g is executed each time a shell + function or a script executed with the .. or ssoouurrccee builtins fin- + ishes executing. + + If a _s_i_g_s_p_e_c is EERRRR, the command _a_r_g is executed whenever a + pipeline (which may consist of a single simple command), a list, + or a compound command returns a non-zero exit status, subject to + the following conditions. The EERRRR trap is not executed if the + failed command is part of the command list immediately following + a wwhhiillee or uunnttiill keyword, part of the test in an _i_f statement, + part of a command executed in a &&&& or |||| list except the command + following the final &&&& or ||||, any command in a pipeline but the + last, or if the command's return value is being inverted using + !!. These are the same conditions obeyed by the eerrrreexxiitt (--ee) + option. + + 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 subshell or subshell environment when + one is created. The return status is false if any _s_i_g_s_p_e_c is + invalid; otherwise ttrraapp returns true. + + ttyyppee [--aaffttppPP] _n_a_m_e [_n_a_m_e ...] + With no options, indicate how each _n_a_m_e would be interpreted if + used as a command name. If the --tt option is used, ttyyppee prints a + string which is one of _a_l_i_a_s, _k_e_y_w_o_r_d, _f_u_n_c_t_i_o_n, _b_u_i_l_t_i_n, or + _f_i_l_e if _n_a_m_e is an alias, shell reserved word, function, + builtin, or disk file, respectively. If the _n_a_m_e is not found, + then nothing is printed, and an exit status of false is + returned. If the --pp option is used, ttyyppee either returns the + name of the disk file that would be executed if _n_a_m_e were speci- + fied as a command name, or nothing if ``type -t name'' would not + return _f_i_l_e. The --PP option forces a PPAATTHH search for each _n_a_m_e, + even if ``type -t name'' would not return _f_i_l_e. If a command is + hashed, --pp and --PP print the hashed value, which is not necessar- + ily the file that appears first in PPAATTHH. If the --aa option is + used, ttyyppee prints all of the places that contain an executable + named _n_a_m_e. This includes aliases and functions, if and only if + the --pp option is not also used. The table of hashed commands is + not consulted when using --aa. The --ff option suppresses shell + function lookup, as with the ccoommmmaanndd builtin. ttyyppee returns true + if all of the arguments are found, false if any are not found. + + uulliimmiitt [--HHSSaabbccddeeffiikkllmmnnppqqrrssttuuvvxxPPTT [_l_i_m_i_t]] + Provides control over the resources available to the shell and + to processes started by it, on systems that allow such control. + The --HH and --SS options specify that the hard or soft limit is set + for the given resource. A hard limit cannot be increased by a + non-root user once it is set; a soft limit may be increased up + to the value of the hard limit. If neither --HH nor --SS is speci- + fied, both the soft and hard limits are set. The value of _l_i_m_i_t + can be a number in the unit specified for the resource or one of + the special values hhaarrdd, ssoofftt, or uunnlliimmiitteedd, which stand for the + current hard limit, the current soft limit, and no limit, + respectively. If _l_i_m_i_t is omitted, the current value of the + soft limit of the resource is printed, unless the --HH option is + given. When more than one resource is specified, the limit name + and unit are printed before the value. Other options are inter- + preted as follows: + --aa All current limits are reported + --bb The maximum socket buffer size + --cc The maximum size of core files created + --dd The maximum size of a process's data segment + --ee The maximum scheduling priority ("nice") + --ff The maximum size of files written by the shell and its + children + --ii The maximum number of pending signals + --kk The maximum number of kqueues that may be allocated + --ll The maximum size that may be locked into memory + --mm The maximum resident set size (many systems do not honor + this limit) + --nn The maximum number of open file descriptors (most systems + do not allow this value to be set) + --pp The pipe size in 512-byte blocks (this may not be set) + --qq The maximum number of bytes in POSIX message queues + --rr The maximum real-time scheduling priority + --ss The maximum stack size + --tt The maximum amount of cpu time in seconds + --uu The maximum number of processes available to a single + user + --vv The maximum amount of virtual memory available to the + shell and, on some systems, to its children + --xx The maximum number of file locks + --PP The maximum number of pseudoterminals + --TT The maximum number of threads + + If _l_i_m_i_t is given, and the --aa option is not used, _l_i_m_i_t is the + new value of the specified resource. If no option is given, + then --ff is assumed. Values are in 1024-byte increments, except + for --tt, which is in seconds; --pp, which is in units of 512-byte + blocks; --PP, --TT, --bb, --kk, --nn, and --uu, which are unscaled values; + and, when in Posix mode, --cc and --ff, which are in 512-byte incre- + ments. The return status is 0 unless an invalid option or argu- + ment is supplied, or an error occurs while setting a new limit. + + uummaasskk [--pp] [--SS] [_m_o_d_e] + The user file-creation mask is set to _m_o_d_e. If _m_o_d_e begins with + a digit, it is interpreted as an octal number; otherwise it is + interpreted as a symbolic mode mask similar to that accepted by + _c_h_m_o_d(1). If _m_o_d_e is omitted, the current value of the mask is + printed. The --SS option causes the mask to be printed in sym- + bolic form; the default output is an octal number. If the --pp + option is supplied, and _m_o_d_e is omitted, the output is in a form + that may be reused as input. The return status is 0 if the mode + was successfully changed or if no _m_o_d_e argument was supplied, + and false otherwise. + + uunnaalliiaass [-aa] [_n_a_m_e ...] + Remove each _n_a_m_e from the list of defined aliases. If --aa is + supplied, all alias definitions are removed. The return value + is true unless a supplied _n_a_m_e is not a defined alias. + + uunnsseett [-ffvv] [-nn] [_n_a_m_e ...] + For each _n_a_m_e, remove the corresponding variable or function. + If the --vv option is given, each _n_a_m_e refers to a shell variable, + and that variable is removed. Read-only variables may not be + unset. If --ff is specified, each _n_a_m_e refers to a shell func- + tion, and the function definition is removed. If the --nn option + is supplied, and _n_a_m_e is a variable with the _n_a_m_e_r_e_f attribute, + _n_a_m_e will be unset rather than the variable it references. --nn + has no effect if the --ff option is supplied. If no options are + supplied, each _n_a_m_e refers to a variable; if there is no vari- + able by that name, any function with that name is unset. Each + unset variable or function is removed from the environment + passed to subsequent commands. If any of CCOOMMPP__WWOORRDDBBRREEAAKKSS, RRAANN-- + DDOOMM, SSEECCOONNDDSS, LLIINNEENNOO, HHIISSTTCCMMDD, FFUUNNCCNNAAMMEE, GGRROOUUPPSS, or DDIIRRSSTTAACCKK are + unset, they lose their special properties, even if they are sub- + sequently reset. The exit status is true unless a _n_a_m_e is read- + only. + + wwaaiitt [--nn] [_n _._._.] + Wait for each specified child process and return its termination + status. Each _n may be a process ID or a job specification; if a + job spec is given, all processes in that job's pipeline are + waited for. If _n is not given, all currently active child pro- + cesses are waited for, and the return status is zero. If the --nn + option is supplied, wwaaiitt waits for any job to terminate and + returns its exit status. If _n specifies a non-existent process + or job, the return status is 127. Otherwise, the return status + is the exit status of the last process or job waited for. + +RREESSTTRRIICCTTEEDD SSHHEELLLL + If bbaasshh is started with the name rrbbaasshh, or the --rr 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. It + behaves identically to bbaasshh with the exception that the following are + disallowed or not performed: + + +o changing directories with ccdd + + +o setting or unsetting the values of SSHHEELLLL, PPAATTHH, EENNVV, or BBAASSHH__EENNVV + + +o specifying command names containing // + + +o specifying a filename containing a // as an argument to the .. + builtin command + + +o specifying a filename containing a slash as an argument to the + --pp option to the hhaasshh builtin command + + +o importing function definitions from the shell environment at + startup + + +o parsing the value of SSHHEELLLLOOPPTTSS from the shell environment at + startup + + +o redirecting output using the >, >|, <>, >&, &>, and >> redirect- + ion operators + + +o using the eexxeecc builtin command to replace the shell with another + command + + +o adding or deleting builtin commands with the --ff and --dd options + to the eennaabbllee builtin command + + +o using the eennaabbllee builtin command to enable disabled shell + builtins + + +o specifying the --pp option to the ccoommmmaanndd builtin command + + +o turning off restricted mode with sseett ++rr or sseett ++oo rreessttrriicctteedd. + + These restrictions are enforced after any startup files are read. + + When a command that is found to be a shell script is executed (see CCOOMM-- + MMAANNDD EEXXEECCUUTTIIOONN above), rrbbaasshh turns off any restrictions in the shell + spawned to execute the script. + +SSEEEE AALLSSOO + _B_a_s_h _R_e_f_e_r_e_n_c_e _M_a_n_u_a_l, Brian Fox and Chet Ramey + _T_h_e _G_n_u _R_e_a_d_l_i_n_e _L_i_b_r_a_r_y, Brian Fox and Chet Ramey + _T_h_e _G_n_u _H_i_s_t_o_r_y _L_i_b_r_a_r_y, Brian Fox and Chet Ramey + _P_o_r_t_a_b_l_e _O_p_e_r_a_t_i_n_g _S_y_s_t_e_m _I_n_t_e_r_f_a_c_e _(_P_O_S_I_X_) _P_a_r_t _2_: _S_h_e_l_l _a_n_d _U_t_i_l_i_- + _t_i_e_s, IEEE -- + http://pubs.opengroup.org/onlinepubs/9699919799/ + http://tiswww.case.edu/~chet/bash/POSIX -- a description of posix mode + _s_h(1), _k_s_h(1), _c_s_h(1) + _e_m_a_c_s(1), _v_i(1) + _r_e_a_d_l_i_n_e(3) + +FFIILLEESS + _/_b_i_n_/_b_a_s_h + The bbaasshh executable + _/_e_t_c_/_p_r_o_f_i_l_e + The systemwide initialization file, executed for login shells + _~_/_._b_a_s_h___p_r_o_f_i_l_e + The personal initialization file, executed for login shells + _~_/_._b_a_s_h_r_c + The individual per-interactive-shell startup file + _~_/_._b_a_s_h___l_o_g_o_u_t + The individual login shell cleanup file, executed when a login + shell exits + _~_/_._i_n_p_u_t_r_c + Individual _r_e_a_d_l_i_n_e initialization file + +AAUUTTHHOORRSS + Brian Fox, Free Software Foundation + bfox@gnu.org + + Chet Ramey, Case Western Reserve University + chet.ramey@case.edu + +BBUUGG RREEPPOORRTTSS + If you find a bug in bbaasshh,, you should report it. But first, you should + make sure that it really is a bug, and that it appears in the latest + version of bbaasshh. The latest version is always available from + _f_t_p_:_/_/_f_t_p_._g_n_u_._o_r_g_/_p_u_b_/_g_n_u_/_b_a_s_h_/. + + Once you have determined that a bug actually exists, use the _b_a_s_h_b_u_g + 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 _b_u_g_-_b_a_s_h_@_g_n_u_._o_r_g or posted to the Usenet newsgroup + ggnnuu..bbaasshh..bbuugg. + + ALL bug reports should include: + + The version number of bbaasshh + The hardware and operating system + The compiler used to compile + A description of the bug behaviour + A short script or `recipe' which exercises the bug + + _b_a_s_h_b_u_g inserts the first three items automatically into the template + it provides for filing a bug report. + + Comments and bug reports concerning this manual page should be directed + to _c_h_e_t_._r_a_m_e_y_@_c_a_s_e_._e_d_u. + +BBUUGGSS + It's too big and too slow. + + There are some subtle differences between bbaasshh and traditional versions + of sshh, mostly because of the PPOOSSIIXX specification. + + Aliases are confusing in some uses. + + Shell builtin commands and functions are not stoppable/restartable. + + Compound commands and command sequences of the form `a ; b ; c' are not + handled gracefully when process suspension is attempted. When a + process is stopped, the shell immediately executes the next command in + the sequence. It suffices to place the sequence of commands between + parentheses to force it into a subshell, which may be stopped as a + unit. + + Array variables may not (yet) be exported. + + There may be only one active coprocess at a time. + + + +GNU Bash 4.4 2016 August 26 BASH(1) diff --git a/doc/bash.1 b/doc/bash.1 new file mode 100644 index 0000000..9a7a384 --- /dev/null +++ b/doc/bash.1 @@ -0,0 +1,10643 @@ +.\" +.\" MAN PAGE COMMENTS to +.\" +.\" Chet Ramey +.\" Case Western Reserve University +.\" chet.ramey@case.edu +.\" +.\" Last Change: Fri Aug 26 09:45:10 EDT 2016 +.\" +.\" bash_builtins, strip all but Built-Ins section +.if \n(zZ=1 .ig zZ +.if \n(zY=1 .ig zY +.TH BASH 1 "2016 August 26" "GNU Bash 4.4" +.\" +.\" There's some problem with having a `@' +.\" in a tagged paragraph with the BSD man macros. +.\" It has to do with `@' appearing in the }1 macro. +.\" This is a problem on 4.3 BSD and Ultrix, but Sun +.\" appears to have fixed it. +.\" If you're seeing the characters +.\" `@u-3p' appearing before the lines reading +.\" `possible-hostname-completions +.\" and `complete-hostname' down in READLINE, +.\" then uncomment this redefinition. +.\" +.de }1 +.ds ]X \&\\*(]B\\ +.nr )E 0 +.if !"\\$1"" .nr )I \\$1n +.}f +.ll \\n(LLu +.in \\n()Ru+\\n(INu+\\n()Iu +.ti \\n(INu +.ie !\\n()Iu+\\n()Ru-\w\\*(]Xu-3p \{\\*(]X +.br\} +.el \\*(]X\h|\\n()Iu+\\n()Ru\c +.}f +.. +.\" +.\" File Name macro. This used to be `.PN', for Path Name, +.\" but Sun doesn't seem to like that very much. +.\" +.de FN +\fI\|\\$1\|\fP +.. +.SH NAME +bash \- GNU Bourne-Again SHell +.SH SYNOPSIS +.B bash +[options] +[command_string | file] +.SH COPYRIGHT +.if n Bash is Copyright (C) 1989-2016 by the Free Software Foundation, Inc. +.if t Bash is Copyright \(co 1989-2016 by the Free Software Foundation, Inc. +.SH DESCRIPTION +.B Bash +is an \fBsh\fR-compatible command language interpreter that +executes commands read from the standard input or from a file. +.B Bash +also incorporates useful features from the \fIKorn\fP and \fIC\fP +shells (\fBksh\fP and \fBcsh\fP). +.PP +.B Bash +is intended to be a conformant implementation of the +Shell and Utilities portion of the IEEE POSIX specification +(IEEE Standard 1003.1). +.B Bash +can be configured to be POSIX-conformant by default. +.SH OPTIONS +All of the single-character shell options documented in the +description of the \fBset\fR builtin command can be used as options +when the shell is invoked. +In addition, \fBbash\fR +interprets the following options when it is invoked: +.PP +.PD 0 +.TP 10 +.B \-c +If the +.B \-c +option is present, then commands are read from the first non-option argument +.IR command_string . +If there are arguments after the +.IR command_string , +the first argument is assigned to +.B $0 +and any remaining arguments are assigned to the positional parameters. +The assignment to +.B $0 +sets the name of the shell, which is used in warning and error messages. +.TP +.B \-i +If the +.B \-i +option is present, the shell is +.IR interactive . +.TP +.B \-l +Make +.B bash +act as if it had been invoked as a login shell (see +.SM +.B INVOCATION +below). +.TP +.B \-r +If the +.B \-r +option is present, the shell becomes +.I restricted +(see +.SM +.B "RESTRICTED SHELL" +below). +.TP +.B \-s +If the +.B \-s +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. +.TP +.B \-D +A list of all double-quoted strings preceded by \fB$\fP +is printed on the standard output. +These are the strings that +are subject to language translation when the current locale +is not \fBC\fP or \fBPOSIX\fP. +This implies the \fB\-n\fP option; no commands will be executed. +.TP +.B [\-+]O [\fIshopt_option\fP] +\fIshopt_option\fP is one of the shell options accepted by the +\fBshopt\fP builtin (see +.SM +.B SHELL BUILTIN COMMANDS +below). +If \fIshopt_option\fP is present, \fB\-O\fP sets the value of that option; +\fB+O\fP unsets it. +If \fIshopt_option\fP is not supplied, the names and values of the shell +options accepted by \fBshopt\fP are printed on the standard output. +If the invocation option is \fB+O\fP, the output is displayed in a format +that may be reused as input. +.TP +.B \-\- +A +.B \-\- +signals the end of options and disables further option processing. +Any arguments after the +.B \-\- +are treated as filenames and arguments. An argument of +.B \- +is equivalent to \fB\-\-\fP. +.PD +.PP +.B Bash +also interprets a number of multi-character options. +These options must appear on the command line before the +single-character options to be recognized. +.PP +.PD 0 +.TP +.B \-\-debugger +Arrange for the debugger profile to be executed before the shell +starts. +Turns on extended debugging mode (see the description of the +.B extdebug +option to the +.B shopt +builtin below). +.TP +.B \-\-dump\-po\-strings +Equivalent to \fB\-D\fP, but the output is in the GNU \fIgettext\fP +\fBpo\fP (portable object) file format. +.TP +.B \-\-dump\-strings +Equivalent to \fB\-D\fP. +.TP +.B \-\-help +Display a usage message on standard output and exit successfully. +.TP +\fB\-\-init\-file\fP \fIfile\fP +.PD 0 +.TP +\fB\-\-rcfile\fP \fIfile\fP +.PD +Execute commands from +.I file +instead of the standard personal initialization file +.I ~/.bashrc +if the shell is interactive (see +.SM +.B INVOCATION +below). +.TP +.B \-\-login +Equivalent to \fB\-l\fP. +.TP +.B \-\-noediting +Do not use the GNU +.B readline +library to read command lines when the shell is interactive. +.TP +.B \-\-noprofile +Do not read either the system-wide startup file +.FN /etc/profile +or any of the personal initialization files +.IR ~/.bash_profile , +.IR ~/.bash_login , +or +.IR ~/.profile . +By default, +.B bash +reads these files when it is invoked as a login shell (see +.SM +.B INVOCATION +below). +.TP +.B \-\-norc +Do not read and execute the personal initialization file +.I ~/.bashrc +if the shell is interactive. +This option is on by default if the shell is invoked as +.BR sh . +.TP +.B \-\-posix +Change the behavior of \fBbash\fP where the default operation differs +from the POSIX standard to match the standard (\fIposix mode\fP). +See +.SM +.B "SEE ALSO" +below for a reference to a document that details how posix mode affects +bash's behavior. +.TP +.B \-\-restricted +The shell becomes restricted (see +.SM +.B "RESTRICTED SHELL" +below). +.TP +.B \-\-verbose +Equivalent to \fB\-v\fP. +.TP +.B \-\-version +Show version information for this instance of +.B bash +on the standard output and exit successfully. +.PD +.SH ARGUMENTS +If arguments remain after option processing, and neither the +.B \-c +nor the +.B \-s +option has been supplied, the first argument is assumed to +be the name of a file containing shell commands. +If +.B bash +is invoked in this fashion, +.B $0 +is set to the name of the file, and the positional parameters +are set to the remaining arguments. +.B Bash +reads and executes commands from this file, then exits. +\fBBash\fP'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. +An attempt is first made to open the file in the current directory, and, +if no file is found, then the shell searches the directories in +.SM +.B PATH +for the script. +.SH INVOCATION +A \fIlogin shell\fP is one whose first character of argument zero is a +.BR \- , +or one started with the +.B \-\-login +option. +.PP +An \fIinteractive\fP shell is one started without non-option arguments +(unless \fB\-s\fP is specified) +and without the +.B \-c +option +whose standard input and error are +both connected to terminals (as determined by +.IR isatty (3)), +or one started with the +.B \-i +option. +.SM +.B PS1 +is set and +.B $\- +includes +.B i +if +.B bash +is interactive, +allowing a shell script or a startup file to test this state. +.PP +The following paragraphs describe how +.B bash +executes its startup files. +If any of the files exist but cannot be read, +.B bash +reports an error. +Tildes are expanded in filenames as described below under +.B "Tilde Expansion" +in the +.SM +.B EXPANSION +section. +.PP +When +.B bash +is invoked as an interactive login shell, or as a non-interactive shell +with the \fB\-\-login\fP option, it first reads and +executes commands from the file \fI/etc/profile\fP, if that +file exists. +After reading that file, it looks for \fI~/.bash_profile\fP, +\fI~/.bash_login\fP, and \fI~/.profile\fP, in that order, and reads +and executes commands from the first one that exists and is readable. +The +.B \-\-noprofile +option may be used when the shell is started to inhibit this behavior. +.PP +When an interactive login shell exits, +or a non-interactive login shell executes the \fBexit\fP builtin command, +.B bash +reads and executes commands from the file \fI~/.bash_logout\fP, if it +exists. +.PP +When an interactive shell that is not a login shell is started, +.B bash +reads and executes commands from \fI~/.bashrc\fP, if that file exists. +This may be inhibited by using the +.B \-\-norc +option. +The \fB\-\-rcfile\fP \fIfile\fP option will force +.B bash +to read and execute commands from \fIfile\fP instead of \fI~/.bashrc\fP. +.PP +When +.B bash +is started non-interactively, to run a shell script, for example, it +looks for the variable +.SM +.B 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. +.B Bash +behaves as if the following command were executed: +.sp .5 +.RS +.if t \f(CWif [ \-n "$BASH_ENV" ]; then . "$BASH_ENV"; fi\fP +.if n if [ \-n "$BASH_ENV" ]; then . "$BASH_ENV"; fi +.RE +.sp .5 +but the value of the +.SM +.B PATH +variable is not used to search for the filename. +.PP +If +.B bash +is invoked with the name +.BR sh , +it tries to mimic the startup behavior of historical versions of +.B sh +as closely as possible, +while conforming to the POSIX standard as well. +When invoked as an interactive login shell, or a non-interactive +shell with the \fB\-\-login\fP option, it first attempts to +read and execute commands from +.I /etc/profile +and +.IR ~/.profile , +in that order. +The +.B \-\-noprofile +option may be used to inhibit this behavior. +When invoked as an interactive shell with the name +.BR sh , +.B bash +looks for the variable +.SM +.BR 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 +.B sh +does not attempt to read and execute commands from any other startup +files, the +.B \-\-rcfile +option has no effect. +A non-interactive shell invoked with the name +.B sh +does not attempt to read any other startup files. +When invoked as +.BR sh , +.B bash +enters +.I posix +mode after the startup files are read. +.PP +When +.B bash +is started in +.I posix +mode, as with the +.B \-\-posix +command line option, it follows the POSIX standard for startup files. +In this mode, interactive shells expand the +.SM +.B ENV +variable and commands are read and executed from the file +whose name is the expanded value. +No other startup files are read. +.PP +.B Bash +attempts to determine when it is being run with its standard input +connected to a network connection, as when executed by the remote shell +daemon, usually \fIrshd\fP, or the secure shell daemon \fIsshd\fP. +If +.B bash +determines it is being run in this fashion, it reads and executes +commands from \fI~/.bashrc\fP, if that file exists and is readable. +It will not do this if invoked as \fBsh\fP. +The +.B \-\-norc +option may be used to inhibit this behavior, and the +.B \-\-rcfile +option may be used to force another file to be read, but neither +\fIrshd\fP nor \fIsshd\fP generally invoke the shell with those options +or allow them to be specified. +.PP +If the shell is started with the effective user (group) id not equal to the +real user (group) id, and the \fB\-p\fP option is not supplied, no startup +files are read, shell functions are not inherited from the environment, the +.SM +.BR SHELLOPTS , +.SM +.BR BASHOPTS , +.SM +.BR CDPATH , +and +.SM +.B GLOBIGNORE +variables, if they appear in the environment, are ignored, +and the effective user id is set to the real user id. +If the \fB\-p\fP option is supplied at invocation, the startup behavior is +the same, but the effective user id is not reset. +.SH DEFINITIONS +.PP +The following definitions are used throughout the rest of this +document. +.PD 0 +.TP +.B blank +A space or tab. +.TP +.B word +A sequence of characters considered as a single unit by the shell. +Also known as a +.BR token . +.TP +.B name +A +.I word +consisting only of alphanumeric characters and underscores, and +beginning with an alphabetic character or an underscore. Also +referred to as an +.BR identifier . +.TP +.B metacharacter +A character that, when unquoted, separates words. One of the following: +.br +.RS +.PP +.if t \fB| & ; ( ) < > space tab newline\fP +.if n \fB| & ; ( ) < > space tab newline\fP +.RE +.PP +.TP +.B control operator +A \fItoken\fP that performs a control function. It is one of the following +symbols: +.RS +.PP +.if t \fB|| & && ; ;; ;& ;;& ( ) | |& \fP +.if n \fB|| & && ; ;; ;& ;;& ( ) | |& \fP +.RE +.PD +.SH "RESERVED WORDS" +\fIReserved words\fP are words that have a special meaning to the shell. +The following words are recognized as reserved when unquoted and either +the first word of a simple command (see +.SM +.B SHELL GRAMMAR +below) or the third word of a +.B case +or +.B for +command: +.if t .RS +.PP +.B +.if n ! case coproc do done elif else esac fi for function if in select then until while { } time [[ ]] +.if t ! case coproc do done elif else esac fi for function if in select then until while { } time [[ ]] +.if t .RE +.SH "SHELL GRAMMAR" +.SS Simple Commands +.PP +A \fIsimple command\fP is a sequence of optional variable assignments +followed by \fBblank\fP-separated words and redirections, and +terminated by a \fIcontrol operator\fP. The first word +specifies the command to be executed, and is passed as argument zero. +The remaining words are passed as arguments to the invoked command. +.PP +The return value of a \fIsimple command\fP is its exit status, or +128+\fIn\^\fP if the command is terminated by signal +.IR n . +.SS Pipelines +.PP +A \fIpipeline\fP is a sequence of one or more commands separated by +one of the control operators +.B | +or \fB|&\fP. +The format for a pipeline is: +.RS +.PP +[\fBtime\fP [\fB\-p\fP]] [ ! ] \fIcommand\fP [ [\fB|\fP\(bv\fB|&\fP] \fIcommand2\fP ... ] +.RE +.PP +The standard output of +.I command +is connected via a pipe to the standard input of +.IR command2 . +This connection is performed before any redirections specified by the +command (see +.SM +.B REDIRECTION +below). +If \fB|&\fP is used, \fIcommand\fP's standard error, in addition to its +standard output, is connected to +\fIcommand2\fP's standard input through the pipe; +it is shorthand for \fB2>&1 |\fP. +This implicit redirection of the standard error to the standard output is +performed after any redirections specified by the command. +.PP +The return status of a pipeline is the exit status of the last +command, unless the \fBpipefail\fP option is enabled. +If \fBpipefail\fP 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 +.B ! +precedes a pipeline, the exit status of that pipeline 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. +.PP +If the +.B time +reserved word precedes a pipeline, the elapsed as well as user and +system time consumed by its execution are reported when the pipeline +terminates. +The \fB\-p\fP option changes the output format to that specified by POSIX. +When the shell is in \fIposix mode\fP, it does not recognize +\fBtime\fP as a reserved word if the next token begins with a `-'. +The +.SM +.B TIMEFORMAT +variable may be set to a format string that specifies how the timing +information should be displayed; see the description of +.SM +.B TIMEFORMAT +under +.B "Shell Variables" +below. +.PP +When the shell is in \fIposix mode\fP, \fBtime\fP +may be followed by a newline. In this case, the shell displays the +total user and system time consumed by the shell and its children. +The +.SM +.B TIMEFORMAT +variable may be used to specify the format of +the time information. +.PP +Each command in a pipeline is executed as a separate process (i.e., in a +subshell). +.SS Lists +.PP +A \fIlist\fP is a sequence of one or more pipelines separated by one +of the operators +.BR ; , +.BR & , +.BR && , +or +.BR || , +and optionally terminated by one of +.BR ; , +.BR & , +or +.BR . +.PP +Of these list operators, +.B && +and +.B || +have equal precedence, followed by +.B ; +and +.BR & , +which have equal precedence. +.PP +A sequence of one or more newlines may appear in a \fIlist\fP instead +of a semicolon to delimit commands. +.PP +If a command is terminated by the control operator +.BR & , +the shell executes the command in the \fIbackground\fP +in a subshell. The shell does not wait for the command to +finish, and the return status is 0. Commands separated by a +.B ; +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. +.PP +AND and OR lists are sequences of one or more pipelines separated by the +\fB&&\fP and \fB||\fP control operators, respectively. +AND and OR lists are executed with left associativity. +An AND list has the form +.RS +.PP +\fIcommand1\fP \fB&&\fP \fIcommand2\fP +.RE +.PP +.I command2 +is executed if, and only if, +.I command1 +returns an exit status of zero. +.PP +An OR list has the form +.RS +.PP +\fIcommand1\fP \fB||\fP \fIcommand2\fP +.PP +.RE +.PP +.I command2 +is executed if and only if +.I command1 +returns a non-zero exit status. +The return status of +AND and OR lists is the exit status of the last command +executed in the list. +.SS Compound Commands +.PP +A \fIcompound command\fP is one of the following. +In most cases a \fIlist\fP in a command's description may be separated from +the rest of the command by one or more newlines, and may be followed by a +newline in place of a semicolon. +.TP +(\fIlist\fP) +\fIlist\fP is executed in a subshell environment (see +.SM +\fBCOMMAND EXECUTION ENVIRONMENT\fP +below). +Variable assignments and builtin +commands that affect the shell's environment do not remain in effect +after the command completes. The return status is the exit status of +\fIlist\fP. +.TP +{ \fIlist\fP; } +\fIlist\fP is simply executed in the current shell environment. +\fIlist\fP must be terminated with a newline or semicolon. +This is known as a \fIgroup command\fP. +The return status is the exit status of +\fIlist\fP. +Note that unlike the metacharacters \fB(\fP and \fB)\fP, \fB{\fP and +\fB}\fP are \fIreserved words\fP and must occur where a reserved +word is permitted to be recognized. Since they do not cause a word +break, they must be separated from \fIlist\fP by whitespace or another +shell metacharacter. +.TP +((\fIexpression\fP)) +The \fIexpression\fP is evaluated according to the rules described +below under +.SM +.BR "ARITHMETIC EVALUATION" . +If the value of the expression is non-zero, the return status is 0; +otherwise the return status is 1. This is exactly equivalent to +\fBlet "\fIexpression\fP"\fR. +.TP +\fB[[\fP \fIexpression\fP \fB]]\fP +Return a status of 0 or 1 depending on the evaluation of +the conditional expression \fIexpression\fP. +Expressions are composed of the primaries described below under +.SM +.BR "CONDITIONAL EXPRESSIONS" . +Word splitting and pathname expansion are not performed on the words +between the \fB[[\fP and \fB]]\fP; tilde expansion, +parameter and variable expansion, +arithmetic expansion, command substitution, process +substitution, and quote removal are performed. +Conditional operators such as \fB\-f\fP must be unquoted to be recognized +as primaries. +.if t .sp 0.5 +.if n .sp 1 +When used with \fB[[\fP, the \fB<\fP and \fB>\fP operators sort +lexicographically using the current locale. +.if t .sp 0.5 +.if n .sp 1 +When the \fB==\fP and \fB!=\fP operators are used, the string to the +right of the operator is considered a pattern and matched according +to the rules described below under \fBPattern Matching\fP, +as if the \fBextglob\fP shell option were enabled. +The \fB=\fP operator is equivalent to \fB==\fP. +If the +.B nocasematch +shell option is enabled, the match is performed without regard to the case +of alphabetic characters. +The return value is 0 if the string matches (\fB==\fP) or does not match +(\fB!=\fP) the pattern, and 1 otherwise. +Any part of the pattern may be quoted to force the quoted portion +to be matched as a string. +.if t .sp 0.5 +.if n .sp 1 +An additional binary operator, \fB=~\fP, is available, with the same +precedence as \fB==\fP and \fB!=\fP. +When it is used, the string to the right of the operator is considered +an extended regular expression and matched accordingly (as in \fIregex\fP(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 +.B nocasematch +shell option is enabled, the match is performed without regard to the case +of alphabetic characters. +Any part of the pattern may be quoted to force the quoted portion +to be matched as a string. +Bracket expressions in regular expressions must be treated carefully, +since normal quoting characters lose their meanings between brackets. +If the pattern is stored in a shell variable, quoting the variable +expansion forces the entire pattern to be matched as a string. +Substrings matched by parenthesized subexpressions within the regular +expression are saved in the array variable +.SM +.BR BASH_REMATCH . +The element of +.SM +.B BASH_REMATCH +with index 0 is the portion of the string +matching the entire regular expression. +The element of +.SM +.B BASH_REMATCH +with index \fIn\fP is the portion of the +string matching the \fIn\fPth parenthesized subexpression. +.if t .sp 0.5 +.if n .sp 1 +Expressions may be combined using the following operators, listed +in decreasing order of precedence: +.if t .sp 0.5 +.if n .sp 1 +.RS +.PD 0 +.TP +.B ( \fIexpression\fP ) +Returns the value of \fIexpression\fP. +This may be used to override the normal precedence of operators. +.TP +.B ! \fIexpression\fP +True if +.I expression +is false. +.TP +\fIexpression1\fP \fB&&\fP \fIexpression2\fP +True if both +.I expression1 +and +.I expression2 +are true. +.TP +\fIexpression1\fP \fB||\fP \fIexpression2\fP +True if either +.I expression1 +or +.I expression2 +is true. +.PD +.LP +The \fB&&\fP and \fB||\fP +operators do not evaluate \fIexpression2\fP if the value of +\fIexpression1\fP is sufficient to determine the return value of +the entire conditional expression. +.RE +.TP +\fBfor\fP \fIname\fP [ [ \fBin\fP [ \fIword ...\fP ] ] ; ] \fBdo\fP \fIlist\fP ; \fBdone\fP +The list of words following \fBin\fP is expanded, generating a list +of items. +The variable \fIname\fP is set to each element of this list +in turn, and \fIlist\fP is executed each time. +If the \fBin\fP \fIword\fP is omitted, the \fBfor\fP command executes +\fIlist\fP once for each positional parameter that is set (see +.SM +.B PARAMETERS +below). +The return status is the exit status of the last command that executes. +If the expansion of the items following \fBin\fP results in an empty +list, no commands are executed, and the return status is 0. +.TP +\fBfor\fP (( \fIexpr1\fP ; \fIexpr2\fP ; \fIexpr3\fP )) ; \fBdo\fP \fIlist\fP ; \fBdone\fP +First, the arithmetic expression \fIexpr1\fP is evaluated according +to the rules described below under +.SM +.BR "ARITHMETIC EVALUATION" . +The arithmetic expression \fIexpr2\fP is then evaluated repeatedly +until it evaluates to zero. +Each time \fIexpr2\fP evaluates to a non-zero value, \fIlist\fP is +executed and the arithmetic expression \fIexpr3\fP 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 \fIlist\fP +that is executed, or false if any of the expressions is invalid. +.TP +\fBselect\fP \fIname\fP [ \fBin\fP \fIword\fP ] ; \fBdo\fP \fIlist\fP ; \fBdone\fP +The list of words following \fBin\fP is expanded, generating a list +of items. The set of expanded words is printed on the standard +error, each preceded by a number. If the \fBin\fP +\fIword\fP is omitted, the positional parameters are printed (see +.SM +.B PARAMETERS +below). The +.SM +.B PS3 +prompt is then displayed and a line read from the standard input. +If the line consists of a number corresponding to one of +the displayed words, then the value of +.I name +is set to that word. If the line is empty, the words and prompt +are displayed again. If EOF is read, the command completes. Any +other value read causes +.I name +to be set to null. The line read is saved in the variable +.SM +.BR REPLY . +The +.I list +is executed after each selection until a +.B break +command is executed. +The exit status of +.B select +is the exit status of the last command executed in +.IR list , +or zero if no commands were executed. +.TP +\fBcase\fP \fIword\fP \fBin\fP [ [(] \fIpattern\fP [ \fB|\fP \fIpattern\fP ] \ +... ) \fIlist\fP ;; ] ... \fBesac\fP +A \fBcase\fP command first expands \fIword\fP, and tries to match +it against each \fIpattern\fP in turn, using the same matching rules +as for pathname expansion (see +.B Pathname Expansion +below). +The \fIword\fP is expanded using tilde +expansion, parameter and variable expansion, arithmetic expansion, +command substitution, process substitution and quote removal. +Each \fIpattern\fP examined is expanded using tilde +expansion, parameter and variable expansion, arithmetic expansion, +command substitution, and process substitution. +If the +.B nocasematch +shell option is enabled, the match is performed without regard to the case +of alphabetic characters. +When a match is found, the corresponding \fIlist\fP is executed. +If the \fB;;\fP operator is used, no subsequent matches are attempted after +the first pattern match. +Using \fB;&\fP in place of \fB;;\fP causes execution to continue with +the \fIlist\fP associated with the next set of patterns. +Using \fB;;&\fP in place of \fB;;\fP causes the shell to test the next +pattern list in the statement, if any, and execute any associated \fIlist\fP +on a successful match. +The exit status is zero if no +pattern matches. Otherwise, it is the exit status of the +last command executed in \fIlist\fP. +.TP +\fBif\fP \fIlist\fP; \fBthen\fP \fIlist\fP; \ +[ \fBelif\fP \fIlist\fP; \fBthen\fP \fIlist\fP; ] ... \ +[ \fBelse\fP \fIlist\fP; ] \fBfi\fP +The +.B if +.I list +is executed. If its exit status is zero, the +\fBthen\fP \fIlist\fP is executed. Otherwise, each \fBelif\fP +\fIlist\fP is executed in turn, and if its exit status is zero, +the corresponding \fBthen\fP \fIlist\fP is executed and the +command completes. Otherwise, the \fBelse\fP \fIlist\fP is +executed, if present. The exit status is the exit status of the +last command executed, or zero if no condition tested true. +.TP +\fBwhile\fP \fIlist-1\fP; \fBdo\fP \fIlist-2\fP; \fBdone\fP +.PD 0 +.TP +\fBuntil\fP \fIlist-1\fP; \fBdo\fP \fIlist-2\fP; \fBdone\fP +.PD +The \fBwhile\fP command continuously executes the list +\fIlist-2\fP as long as the last command in the list \fIlist-1\fP returns +an exit status of zero. The \fBuntil\fP command is identical +to the \fBwhile\fP command, except that the test is negated: +.I list-2 +is executed as long as the last command in +.I list-1 +returns a non-zero exit status. +The exit status of the \fBwhile\fP and \fBuntil\fP commands +is the exit status +of the last command executed in \fIlist-2\fP, or zero if +none was executed. +.SS Coprocesses +.PP +A \fIcoprocess\fP is a shell command preceded by the \fBcoproc\fP reserved +word. +A coprocess is executed asynchronously in a subshell, as if the command +had been terminated with the \fB&\fP control operator, with a two-way pipe +established between the executing shell and the coprocess. +.PP +The format for a coprocess is: +.RS +.PP +\fBcoproc\fP [\fINAME\fP] \fIcommand\fP [\fIredirections\fP] +.RE +.PP +This creates a coprocess named \fINAME\fP. +If \fINAME\fP is not supplied, the default name is \fBCOPROC\fP. +\fINAME\fP must not be supplied if \fIcommand\fP is a \fIsimple +command\fP (see above); otherwise, it is interpreted as the first word +of the simple command. +When the coprocess is executed, the shell creates an array variable (see +.B Arrays +below) named \fINAME\fP in the context of the executing shell. +The standard output of +.I command +is connected via a pipe to a file descriptor in the executing shell, +and that file descriptor is assigned to \fINAME\fP[0]. +The standard input of +.I command +is connected via a pipe to a file descriptor in the executing shell, +and that file descriptor is assigned to \fINAME\fP[1]. +This pipe is established before any redirections specified by the +command (see +.SM +.B REDIRECTION +below). +The file descriptors can be utilized as arguments to shell commands +and redirections using standard word expansions. +The file descriptors are not available in subshells. +The process ID of the shell spawned to execute the coprocess is +available as the value of the variable \fINAME\fP_PID. +The \fBwait\fP +builtin command may be used to wait for the coprocess to terminate. +.PP +Since the coprocess is created as an asynchronous command, +the \fBcoproc\fP command always returns success. +The return status of a coprocess is the exit status of \fIcommand\fP. +.SS Shell Function Definitions +.PP +A shell function is an object that is called like a simple command and +executes a compound command with a new set of positional parameters. +Shell functions are declared as follows: +.TP +\fIname\fP () \fIcompound\-command\fP [\fIredirection\fP] +.PD 0 +.TP +\fBfunction\fP \fIname\fP [()] \fIcompound\-command\fP [\fIredirection\fP] +.PD +This defines a function named \fIname\fP. +The reserved word \fBfunction\fP is optional. +If the \fBfunction\fP reserved word is supplied, the parentheses are optional. +The \fIbody\fP of the function is the compound command +.I compound\-command +(see \fBCompound Commands\fP above). +That command is usually a \fIlist\fP of commands between { and }, but +may be any command listed under \fBCompound Commands\fP above, +with one exception: If the \fBfunction\fP reserved word is used, but the +parentheses are not supplied, the braces are required. +\fIcompound\-command\fP is executed whenever \fIname\fP is specified as the +name of a simple command. +When in \fIposix mode\fP, \fIname\fP may not be the name of one of the +POSIX \fIspecial builtins\fP. +Any redirections (see +.SM +.B REDIRECTION +below) specified when a function is defined are performed +when the function is executed. +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. (See +.SM +.B FUNCTIONS +below.) +.SH COMMENTS +In a non-interactive shell, or an interactive shell in which the +.B interactive_comments +option to the +.B shopt +builtin is enabled (see +.SM +.B "SHELL BUILTIN COMMANDS" +below), a word beginning with +.B # +causes that word and all remaining characters on that line to +be ignored. An interactive shell without the +.B interactive_comments +option enabled does not allow comments. The +.B interactive_comments +option is on by default in interactive shells. +.SH QUOTING +\fIQuoting\fP 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. +.PP +Each of the \fImetacharacters\fP listed above under +.SM +.B DEFINITIONS +has special meaning to the shell and must be quoted if it is to +represent itself. +.PP +When the command history expansion facilities are being used +(see +.SM +.B HISTORY EXPANSION +below), the +\fIhistory expansion\fP character, usually \fB!\fP, must be quoted +to prevent history expansion. +.PP +There are three quoting mechanisms: the +.IR "escape character" , +single quotes, and double quotes. +.PP +A non-quoted backslash (\fB\e\fP) is the +.IR "escape character" . +It preserves the literal value of the next character that follows, +with the exception of . If a \fB\e\fP pair +appears, and the backslash is not itself quoted, the \fB\e\fP +is treated as a line continuation (that is, it is removed from the +input stream and effectively ignored). +.PP +Enclosing characters in single quotes 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. +.PP +Enclosing characters in double quotes preserves the literal value +of all characters within the quotes, with the exception of +.BR $ , +.BR \` , +.BR \e , +and, when history expansion is enabled, +.BR ! . +When the shell is in \fIposix mode\fP, the \fB!\fP has no special meaning +within double quotes, even when history expansion is enabled. +The characters +.B $ +and +.B \` +retain their special meaning within double quotes. The backslash +retains its special meaning only when followed by one of the following +characters: +.BR $ , +.BR \` , +\^\fB"\fP\^, +.BR \e , +or +.BR . +A double quote may be quoted within double quotes by preceding it with +a backslash. +If enabled, history expansion will be performed unless an +.B ! +appearing in double quotes is escaped using a backslash. +The backslash preceding the +.B ! +is not removed. +.PP +The special parameters +.B * +and +.B @ +have special meaning when in double +quotes (see +.SM +.B PARAMETERS +below). +.PP +Words of the form \fB$\fP\(aq\fIstring\fP\(aq are treated specially. The +word expands to \fIstring\fP, with backslash-escaped characters replaced +as specified by the ANSI C standard. Backslash escape sequences, if +present, are decoded as follows: +.RS +.PD 0 +.TP +.B \ea +alert (bell) +.TP +.B \eb +backspace +.TP +.B \ee +.TP +.B \eE +an escape character +.TP +.B \ef +form feed +.TP +.B \en +new line +.TP +.B \er +carriage return +.TP +.B \et +horizontal tab +.TP +.B \ev +vertical tab +.TP +.B \e\e +backslash +.TP +.B \e\(aq +single quote +.TP +.B \e\(dq +double quote +.TP +.B \e? +question mark +.TP +.B \e\fInnn\fP +the eight-bit character whose value is the octal value \fInnn\fP +(one to three digits) +.TP +.B \ex\fIHH\fP +the eight-bit character whose value is the hexadecimal value \fIHH\fP +(one or two hex digits) +.TP +.B \eu\fIHHHH\fP +the Unicode (ISO/IEC 10646) character whose value is the hexadecimal value +\fIHHHH\fP (one to four hex digits) +.TP +.B \eU\fIHHHHHHHH\fP +the Unicode (ISO/IEC 10646) character whose value is the hexadecimal value +\fIHHHHHHHH\fP (one to eight hex digits) +.TP +.B \ec\fIx\fP +a control-\fIx\fP character +.PD +.RE +.LP +The expanded result is single-quoted, as if the dollar sign had +not been present. +.PP +A double-quoted string preceded by a dollar sign (\fB$\fP\(dq\fIstring\fP\(dq) +will cause the string to be translated according to the current locale. +If the current locale is \fBC\fP or \fBPOSIX\fP, the dollar sign +is ignored. +If the string is translated and replaced, the replacement is +double-quoted. +.SH PARAMETERS +A +.I parameter +is an entity that stores values. +It can be a +.IR name , +a number, or one of the special characters listed below under +.BR "Special Parameters" . +A +.I variable +is a parameter denoted by a +.IR name . +A variable has a \fIvalue\fP and zero or more \fIattributes\fP. +Attributes are assigned using the +.B declare +builtin command (see +.B declare +below in +.SM +.BR "SHELL BUILTIN COMMANDS" ). +.PP +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 +.B unset +builtin command (see +.SM +.B SHELL BUILTIN COMMANDS +below). +.PP +A +.I variable +may be assigned to by a statement of the form +.RS +.PP +\fIname\fP=[\fIvalue\fP] +.RE +.PP +If +.I value +is not given, the variable is assigned the null string. All +.I values +undergo tilde expansion, parameter and variable expansion, +command substitution, arithmetic expansion, and quote +removal (see +.SM +.B EXPANSION +below). If the variable has its +.B integer +attribute set, then +.I value +is evaluated as an arithmetic expression even if the $((...)) expansion is +not used (see +.B "Arithmetic Expansion" +below). +Word splitting is not performed, with the exception +of \fB"$@"\fP as explained below under +.BR "Special Parameters" . +Pathname expansion is not performed. +Assignment statements may also appear as arguments to the +.BR alias , +.BR declare , +.BR typeset , +.BR export , +.BR readonly , +and +.B local +builtin commands (\fIdeclaration\fP commands). +When in \fIposix mode\fP, these builtins may appear in a command after +one or more instances of the \fBcommand\fP builtin and retain these +assignment statement properties. +.PP +In the context where an assignment statement is assigning a value +to a shell variable or array index, the += operator can be used to +append to or add to the variable's previous value. +This includes arguments to builtin commands such as \fBdeclare\fP that +accept assignment statements (\fIdeclaration\fP commands). +When += is applied to a variable for which the \fIinteger\fP attribute has been +set, \fIvalue\fP is evaluated as an arithmetic expression and added to the +variable's current value, which is also evaluated. +When += is applied to an array variable using compound assignment (see +.B Arrays +below), the +variable's value is not unset (as it is when using =), and new values are +appended to the array beginning at one greater than the array's maximum index +(for indexed arrays) or added as additional key\-value pairs in an +associative array. +When applied to a string-valued variable, \fIvalue\fP is expanded and +appended to the variable's value. +.PP +A variable can be assigned the \fInameref\fP attribute using the +\fB\-n\fP option to the \fBdeclare\fP or \fBlocal\fP builtin commands +(see the descriptions of \fBdeclare\fP and \fBlocal\fP below) +to create a \fInameref\fP, or a reference to another variable. +This allows variables to be manipulated indirectly. +Whenever the nameref variable is referenced, assigned to, unset, or has +its attributes modified (other than using or changing the \fInameref\fP +attribute itself), the +operation is actually performed on the variable specified by the nameref +variable's value. +A nameref is commonly used within shell functions to refer to a variable +whose name is passed as an argument to the function. +For instance, if a variable name is passed to a shell function as its first +argument, running +.sp .5 +.RS +.if t \f(CWdeclare -n ref=$1\fP +.if n declare -n ref=$1 +.RE +.sp .5 +inside the function creates a nameref variable \fBref\fP whose value is +the variable name passed as the first argument. +References and assignments to \fBref\fP, and changes to its attributes, +are treated as references, assignments, and attribute modifications +to the variable whose name was passed as \fB$1\fP. +If the control variable in a \fBfor\fP loop has the nameref attribute, +the list of words can be a list of shell variables, and a name reference +will be established for each word in the list, in turn, when the loop is +executed. +Array variables cannot be given the \fBnameref\fP attribute. +However, nameref variables can reference array variables and subscripted +array variables. +Namerefs can be unset using the \fB\-n\fP option to the \fBunset\fP builtin. +Otherwise, if \fBunset\fP is executed with the name of a nameref variable +as an argument, the variable referenced by the nameref variable will be unset. +.SS Positional Parameters +.PP +A +.I positional parameter +is a parameter denoted by one or more +digits, other than the single digit 0. Positional parameters are +assigned from the shell's arguments when it is invoked, +and may be reassigned using the +.B set +builtin command. Positional parameters may not be assigned to +with assignment statements. The positional parameters are +temporarily replaced when a shell function is executed (see +.SM +.B FUNCTIONS +below). +.PP +When a positional parameter consisting of more than a single +digit is expanded, it must be enclosed in braces (see +.SM +.B EXPANSION +below). +.SS Special Parameters +.PP +The shell treats several parameters specially. These parameters may +only be referenced; assignment to them is not allowed. +.PD 0 +.TP +.B * +Expands to the positional parameters, starting from one. +When the expansion is not within double quotes, each positional parameter +expands to a separate word. +In contexts where it is performed, those words +are subject to further word splitting and pathname expansion. +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 +.SM +.B IFS +special variable. That is, "\fB$*\fP" is equivalent +to "\fB$1\fP\fIc\fP\fB$2\fP\fIc\fP\fB...\fP", where +.I c +is the first character of the value of the +.SM +.B IFS +variable. If +.SM +.B IFS +is unset, the parameters are separated by spaces. +If +.SM +.B IFS +is null, the parameters are joined without intervening separators. +.TP +.B @ +Expands to the positional parameters, starting from one. When the +expansion occurs within double quotes, each parameter expands to a +separate word. That is, "\fB$@\fP" is equivalent to +"\fB$1\fP" "\fB$2\fP" ... +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, "\fB$@\fP" and +.B $@ +expand to nothing (i.e., they are removed). +.TP +.B # +Expands to the number of positional parameters in decimal. +.TP +.B ? +Expands to the exit status of the most recently executed foreground +pipeline. +.TP +.B \- +Expands to the current option flags as specified upon invocation, +by the +.B set +builtin command, or those set by the shell itself +(such as the +.B \-i +option). +.TP +.B $ +Expands to the process ID of the shell. In a () subshell, it +expands to the process ID of the current shell, not the +subshell. +.TP +.B ! +Expands to the process ID of the job most recently placed into the +background, whether executed as an asynchronous command or using +the \fBbg\fP builtin (see +.SM +.B "JOB CONTROL" +below). +.TP +.B 0 +Expands to the name of the shell or shell script. This is set at +shell initialization. If +.B bash +is invoked with a file of commands, +.B $0 +is set to the name of that file. If +.B bash +is started with the +.B \-c +option, then +.B $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 +.BR bash , +as given by argument zero. +.TP +.B _ +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 +currently being checked. +.PD +.SS Shell Variables +.PP +The following variables are set by the shell: +.PP +.PD 0 +.TP +.B BASH +Expands to the full filename used to invoke this instance of +.BR bash . +.TP +.B BASHOPTS +A colon-separated list of enabled shell options. Each word in +the list is a valid argument for the +.B \-s +option to the +.B shopt +builtin command (see +.SM +.B "SHELL BUILTIN COMMANDS" +below). The options appearing in +.SM +.B BASHOPTS +are those reported as +.I on +by \fBshopt\fP. +If this variable is in the environment when +.B bash +starts up, each shell option in the list will be enabled before +reading any startup files. +This variable is read-only. +.TP +.B BASHPID +Expands to the process ID of the current \fBbash\fP process. +This differs from \fB$$\fP under certain circumstances, such as subshells +that do not require \fBbash\fP to be re-initialized. +.TP +.B BASH_ALIASES +An associative array variable whose members correspond to the internal +list of aliases as maintained by the \fBalias\fP builtin. +Elements added to this array appear in the alias list; however, +unsetting array elements currently does not cause aliases to be removed +from the alias list. +If +.B BASH_ALIASES +is unset, it loses its special properties, even if it is +subsequently reset. +.TP +.B BASH_ARGC +An array variable whose values are the number of parameters in each +frame of the current \fBbash\fP execution call stack. +The number of +parameters to the current subroutine (shell function or script executed +with \fB.\fP or \fBsource\fP) is at the top of the stack. +When a subroutine is executed, the number of parameters passed is pushed onto +.SM +.BR BASH_ARGC . +The shell sets +.SM +.B BASH_ARGC +only when in extended debugging mode (see the description of the +.B extdebug +option to the +.B shopt +builtin below) +.TP +.B BASH_ARGV +An array variable containing all of the parameters in the current \fBbash\fP +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 +.SM +.BR BASH_ARGV . +The shell sets +.SM +.B BASH_ARGV +only when in extended debugging mode +(see the description of the +.B extdebug +option to the +.B shopt +builtin below) +.TP +.B BASH_CMDS +An associative array variable whose members correspond to the internal +hash table of commands as maintained by the \fBhash\fP builtin. +Elements added to this array appear in the hash table; however, +unsetting array elements currently does not cause command names to be removed +from the hash table. +If +.B BASH_CMDS +is unset, it loses its special properties, even if it is +subsequently reset. +.TP +.B 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. +.TP +.B BASH_EXECUTION_STRING +The command argument to the \fB\-c\fP invocation option. +.TP +.B BASH_LINENO +An array variable whose members are the line numbers in source files +where each corresponding member of +.SM +.B FUNCNAME +was invoked. +\fB${BASH_LINENO[\fP\fI$i\fP\fB]}\fP is the line number in the source +file (\fB${BASH_SOURCE[\fP\fI$i+1\fP\fB]}\fP) where +\fB${FUNCNAME[\fP\fI$i\fP\fB]}\fP was called +(or \fB${BASH_LINENO[\fP\fI$i-1\fP\fB]}\fP if referenced within another +shell function). +Use +.SM +.B LINENO +to obtain the current line number. +.TP +.B BASH_LOADABLES_PATH +A colon-separated list of directories in which the shell looks for +dynamically loadable builtins specified by the +.B enable +command. +.TP +.B BASH_REMATCH +An array variable whose members are assigned by the \fB=~\fP binary +operator to the \fB[[\fP conditional command. +The element with index 0 is the portion of the string +matching the entire regular expression. +The element with index \fIn\fP is the portion of the +string matching the \fIn\fPth parenthesized subexpression. +This variable is read-only. +.TP +.B BASH_SOURCE +An array variable whose members are the source filenames +where the corresponding shell function names in the +.SM +.B FUNCNAME +array variable are defined. +The shell function +\fB${FUNCNAME[\fP\fI$i\fP\fB]}\fP is defined in the file +\fB${BASH_SOURCE[\fP\fI$i\fP\fB]}\fP and called from +\fB${BASH_SOURCE[\fP\fI$i+1\fP\fB]}\fP. +.TP +.B BASH_SUBSHELL +Incremented by one within each subshell or subshell environment when +the shell begins executing in that environment. +The initial value is 0. +.TP +.B BASH_VERSINFO +A readonly array variable whose members hold version information for +this instance of +.BR bash . +The values assigned to the array members are as follows: +.sp .5 +.RS +.TP 24 +.B BASH_VERSINFO[\fR0\fP] +The major version number (the \fIrelease\fP). +.TP +.B BASH_VERSINFO[\fR1\fP] +The minor version number (the \fIversion\fP). +.TP +.B BASH_VERSINFO[\fR2\fP] +The patch level. +.TP +.B BASH_VERSINFO[\fR3\fP] +The build version. +.TP +.B BASH_VERSINFO[\fR4\fP] +The release status (e.g., \fIbeta1\fP). +.TP +.B BASH_VERSINFO[\fR5\fP] +The value of +.SM +.BR MACHTYPE . +.RE +.TP +.B BASH_VERSION +Expands to a string describing the version of this instance of +.BR bash . +.TP +.B COMP_CWORD +An index into \fB${COMP_WORDS}\fP of the word containing the current +cursor position. +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 +commands invoked by the +programmable completion facilities (see \fBProgrammable Completion\fP +below). +.TP +.B 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 \fB${#COMP_LINE}\fP. +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_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 \fBreadline\fP library treats as word +separators when performing word completion. +If +.SM +.B COMP_WORDBREAKS +is unset, it loses its special properties, even if it is +subsequently reset. +.TP +.B COMP_WORDS +An array variable (see \fBArrays\fP below) consisting of the individual +words in the current command line. +The line is split into words as \fBreadline\fP would split it, using +.SM +.B COMP_WORDBREAKS +as described above. +This variable is available only in shell functions invoked by the +programmable completion facilities (see \fBProgrammable Completion\fP +below). +.TP +.B COPROC +An array variable (see \fBArrays\fP below) created to hold the file descriptors +for output from and input to an unnamed coprocess (see \fBCoprocesses\fP +above). +.TP +.B DIRSTACK +An array variable (see +.B Arrays +below) containing the current contents of the directory stack. +Directories appear in the stack in the order they are displayed by the +.B dirs +builtin. +Assigning to members of this array variable may be used to modify +directories already in the stack, but the +.B pushd +and +.B popd +builtins must be used to add and remove directories. +Assignment to this variable will not change the current directory. +If +.SM +.B DIRSTACK +is unset, it loses its special properties, even if it is +subsequently reset. +.TP +.B EUID +Expands to the effective user ID of the current user, initialized at +shell startup. This variable is readonly. +.TP +.B 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 (the one with the highest index) is +.if t \f(CW"main"\fP. +.if n "main". +This variable exists only when a shell function is executing. +Assignments to +.SM +.B FUNCNAME +have no effect. +If +.SM +.B FUNCNAME +is unset, it loses its special properties, even if it is +subsequently reset. +.if t .sp 0.5 +.if n .sp 1 +This variable can be used with \fBBASH_LINENO\fP and \fBBASH_SOURCE\fP. +Each element of \fBFUNCNAME\fP has corresponding elements in +\fBBASH_LINENO\fP and \fBBASH_SOURCE\fP to describe the call stack. +For instance, \fB${FUNCNAME[\fP\fI$i\fP\fB]}\fP was called from the file +\fB${BASH_SOURCE[\fP\fI$i+1\fP\fB]}\fP at line number +\fB${BASH_LINENO[\fP\fI$i\fP\fB]}\fP. +The \fBcaller\fP builtin displays the current call stack using this +information. +.TP +.B GROUPS +An array variable containing the list of groups of which the current +user is a member. +Assignments to +.SM +.B GROUPS +have no effect. +If +.SM +.B GROUPS +is unset, it loses its special properties, even if it is +subsequently reset. +.TP +.B HISTCMD +The history number, or index in the history list, of the current +command. +If +.SM +.B HISTCMD +is unset, it loses its special properties, even if it is +subsequently reset. +.TP +.B HOSTNAME +Automatically set to the name of the current host. +.TP +.B HOSTTYPE +Automatically set to a string that uniquely +describes the type of machine on which +.B bash +is executing. +The default is system-dependent. +.TP +.B LINENO +Each time this parameter is referenced, the shell substitutes +a decimal number representing the current sequential line number +(starting with 1) within a script or function. When not in a +script or function, the value substituted is not guaranteed to +be meaningful. +If +.SM +.B LINENO +is unset, it loses its special properties, even if it is +subsequently reset. +.TP +.B MACHTYPE +Automatically set to a string that fully describes the system +type on which +.B bash +is executing, in the standard GNU \fIcpu-company-system\fP format. +The default is system-dependent. +.TP +.B MAPFILE +An array variable (see \fBArrays\fP below) created to hold the text +read by the \fBmapfile\fP builtin when no variable name is supplied. +.TP +.B OLDPWD +The previous working directory as set by the +.B cd +command. +.TP +.B OPTARG +The value of the last option argument processed by the +.B getopts +builtin command (see +.SM +.B SHELL BUILTIN COMMANDS +below). +.TP +.B OPTIND +The index of the next argument to be processed by the +.B getopts +builtin command (see +.SM +.B SHELL BUILTIN COMMANDS +below). +.TP +.B OSTYPE +Automatically set to a string that +describes the operating system on which +.B bash +is executing. +The default is system-dependent. +.TP +.B PIPESTATUS +An array variable (see +.B Arrays +below) containing a list of exit status values from the processes +in the most-recently-executed foreground pipeline (which may +contain only a single command). +.TP +.B PPID +The process ID of the shell's parent. This variable is readonly. +.TP +.B PWD +The current working directory as set by the +.B cd +command. +.TP +.B RANDOM +Each time this parameter is referenced, a random integer between +0 and 32767 is +generated. The sequence of random numbers may be initialized by assigning +a value to +.SM +.BR RANDOM . +If +.SM +.B RANDOM +is unset, it loses its special properties, even if it is +subsequently reset. +.TP +.B READLINE_LINE +The contents of the +.B readline +line buffer, for use with +.if t \f(CWbind -x\fP +.if n "bind -x" +(see +.SM +.B "SHELL BUILTIN COMMANDS" +below). +.TP +.B READLINE_POINT +The position of the insertion point in the +.B readline +line buffer, for use with +.if t \f(CWbind -x\fP +.if n "bind -x" +(see +.SM +.B "SHELL BUILTIN COMMANDS" +below). +.TP +.B REPLY +Set to the line of input read by the +.B read +builtin command when no arguments are supplied. +.TP +.B SECONDS +Each time this parameter is +referenced, the number of seconds since shell invocation is returned. If a +value is assigned to +.SM +.BR SECONDS , +the value returned upon subsequent +references is +the number of seconds since the assignment plus the value assigned. +If +.SM +.B SECONDS +is unset, it loses its special properties, even if it is +subsequently reset. +.TP +.B SHELLOPTS +A colon-separated list of enabled shell options. Each word in +the list is a valid argument for the +.B \-o +option to the +.B set +builtin command (see +.SM +.B "SHELL BUILTIN COMMANDS" +below). The options appearing in +.SM +.B SHELLOPTS +are those reported as +.I on +by \fBset \-o\fP. +If this variable is in the environment when +.B bash +starts up, each shell option in the list will be enabled before +reading any startup files. +This variable is read-only. +.TP +.B SHLVL +Incremented by one each time an instance of +.B bash +is started. +.TP +.B UID +Expands to the user ID of the current user, initialized at shell startup. +This variable is readonly. +.PD +.PP +The following variables are used by the shell. In some cases, +.B bash +assigns a default value to a variable; these cases are noted +below. +.PP +.PD 0 +.TP +.B BASH_COMPAT +The value is used to set the shell's compatibility level. +See the description of the \fBshopt\fP builtin below under +\fBSHELL BUILTIN COMMANDS\fP +for a description of the various compatibility +levels and their effects. +The value may be a decimal number (e.g., 4.2) or an integer (e.g., 42) +corresponding to the desired compatibility level. +If \fBBASH_COMPAT\fP is unset or set to the empty string, the compatibility +level is set to the default for the current version. +If \fBBASH_COMPAT\fP is set to a value that is not one of the valid +compatibility levels, the shell prints an error message and sets the +compatibility level to the default for the current version. +The valid compatibility levels correspond to the compatibility options +accepted by the \fBshopt\fP builtin described below (for example, +\fBcompat42\fP means that 4.2 and 42 are valid values). +The current version is also a valid value. +.TP +.B BASH_ENV +If this parameter is set when \fBbash\fP is executing a shell script, +its value is interpreted as a filename containing commands to +initialize the shell, as in +.IR ~/.bashrc . +The value of +.SM +.B BASH_ENV +is subjected to parameter expansion, command substitution, and arithmetic +expansion before being interpreted as a filename. +.SM +.B PATH +is not used to search for the resultant filename. +.TP +.B BASH_XTRACEFD +If set to an integer corresponding to a valid file descriptor, \fBbash\fP +will write the trace output generated when +.if t \f(CWset -x\fP +.if n \fIset -x\fP +is enabled to that file descriptor. +The file descriptor is closed when +.SM +.B BASH_XTRACEFD +is unset or assigned a new value. +Unsetting +.SM +.B BASH_XTRACEFD +or assigning it the empty string causes the +trace output to be sent to the standard error. +Note that setting +.SM +.B BASH_XTRACEFD +to 2 (the standard error file +descriptor) and then unsetting it will result in the standard error +being closed. +.TP +.B CDPATH +The search path for the +.B cd +command. +This is a colon-separated list of directories in which the shell looks +for destination directories specified by the +.B cd +command. +A sample value is +.if t \f(CW".:~:/usr"\fP. +.if n ".:~:/usr". +.TP +.B CHILD_MAX +Set the number of exited child status values for the shell to remember. +Bash will not allow this value to be decreased below a POSIX-mandated +minimum, and there is a maximum value (currently 8192) that this may +not exceed. +The minimum value is system-dependent. +.TP +.B COLUMNS +Used by the \fBselect\fP compound command to determine the terminal width +when printing selection lists. +Automatically set if the +.B checkwinsize +option is enabled or in an interactive shell upon receipt of a +.SM +.BR SIGWINCH . +.TP +.B COMPREPLY +An array variable from which \fBbash\fP reads the possible completions +generated by a shell function invoked by the programmable completion +facility (see \fBProgrammable Completion\fP below). +Each array element contains one possible completion. +.TP +.B EMACS +If \fBbash\fP finds this variable in the environment when the shell starts +with value +.if t \f(CWt\fP, +.if n "t", +it assumes that the shell is running in an Emacs shell buffer and disables +line editing. +.TP +.B ENV +Similar to +.SM +.BR BASH_ENV ; +used when the shell is invoked in POSIX mode. +.TP +.B EXECIGNORE +A colon-separated list of shell patterns (see \fBPattern Matching\fP) +defining the list of filenames to be ignored by command search using +\fBPATH\fP. +Files whose full pathnames match one of these patterns are not considered +executable files for the purposes of completion and command execution +via \fBPATH\fP lookup. +This does not affect the behavior of the \fB[\fP, \fBtest\fP, and \fB[[\fP +commands. +Full pathnames in the command hash table are not subject to \fBEXECIGNORE\fP. +Use this variable to ignore shared library files that have the executable +bit set, but are not executable files. +The pattern matching honors the setting of the \fBextglob\fP shell +option. +.TP +.B FCEDIT +The default editor for the +.B fc +builtin command. +.TP +.B FIGNORE +A colon-separated list of suffixes to ignore when performing +filename completion (see +.SM +.B READLINE +below). +A filename whose suffix matches one of the entries in +.SM +.B FIGNORE +is excluded from the list of matched filenames. +A sample value is +.if t \f(CW".o:~"\fP. +.if n ".o:~". +.TP +.B FUNCNEST +If set to a numeric value greater than 0, defines a maximum function +nesting level. Function invocations that exceed this nesting level +will cause the current command to abort. +.TP +.B GLOBIGNORE +A colon-separated list of patterns defining the set of filenames to +be ignored by pathname expansion. +If a filename matched by a pathname expansion pattern also matches one +of the patterns in +.SM +.BR GLOBIGNORE , +it is removed from the list of matches. +.TP +.B HISTCONTROL +A colon-separated list of values controlling how commands are saved on +the history list. +If the list of values includes +.IR ignorespace , +lines which begin with a +.B space +character are not saved in the history list. +A value of +.I ignoredups +causes lines matching the previous history entry to not be saved. +A value of +.I ignoreboth +is shorthand for \fIignorespace\fP and \fIignoredups\fP. +A value of +.IR 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 +.SM +.B 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 +.SM +.BR 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 +.SM +.BR HISTCONTROL . +.TP +.B HISTFILE +The name of the file in which command history is saved (see +.SM +.B HISTORY +below). The default value is \fI~/.bash_history\fP. If unset, the +command history is not saved when a shell exits. +.TP +.B 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 by removing the oldest entries. +The history file is also truncated to this size after +writing it when a shell exits. +If the value is 0, the history file is truncated to zero size. +Non-numeric values and numeric values less than zero inhibit truncation. +The shell sets the default value to the value of \fBHISTSIZE\fP +after reading any startup files. +.TP +.B 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 +`\fB*\fP' is appended). Each pattern is tested against the line +after the checks specified by +.SM +.B HISTCONTROL +are applied. +In addition to the normal shell pattern matching characters, `\fB&\fP' +matches the previous history line. `\fB&\fP' 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 +.SM +.BR HISTIGNORE . +The pattern matching honors the setting of the \fBextglob\fP shell +option. +.TP +.B HISTSIZE +The number of commands to remember in the command history (see +.SM +.B HISTORY +below). +If the value is 0, commands are not saved in the history list. +Numeric values less than zero result in every command being saved +on the history list (there is no limit). +The shell sets the default value to 500 after reading any startup files. +.TP +.B HISTTIMEFORMAT +If this variable is set and not null, its value is used as a format string +for \fIstrftime\fP(3) to print the time stamp associated with each history +entry displayed by the \fBhistory\fP builtin. +If this variable is set, time stamps are written to the history file so +they may be preserved across shell sessions. +This uses the history comment character to distinguish timestamps from +other history lines. +.TP +.B HOME +The home directory of the current user; the default argument for the +\fBcd\fP builtin command. +The value of this variable is also used when performing tilde expansion. +.TP +.B HOSTFILE +Contains the name of a file in the same format as +.FN /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, +.B bash +adds the contents of the new file to the existing list. +If +.SM +.B HOSTFILE +is set, but has no value, or does not name a readable file, +\fBbash\fP attempts to read +.FN /etc/hosts +to obtain the list of possible hostname completions. +When +.SM +.B HOSTFILE +is unset, the hostname list is cleared. +.TP +.B IFS +The +.I Internal Field Separator +that is used +for word splitting after expansion and to +split lines into words with the +.B read +builtin command. The default value is +``''. +.TP +.B IGNOREEOF +Controls the +action of an interactive shell on receipt of an +.SM +.B EOF +character as the sole input. If set, the value is the number of +consecutive +.SM +.B EOF +characters which must be +typed as the first characters on an input line before +.B bash +exits. If the variable exists but does not have a numeric value, or +has no value, the default value is 10. If it does not exist, +.SM +.B EOF +signifies the end of input to the shell. +.TP +.B INPUTRC +The filename for the +.B readline +startup file, overriding the default of +.FN ~/.inputrc +(see +.SM +.B READLINE +below). +.TP +.B LANG +Used to determine the locale category for any category not specifically +selected with a variable starting with \fBLC_\fP. +.TP +.B LC_ALL +This variable overrides the value of +.SM +.B LANG +and any other +\fBLC_\fP variable specifying a locale category. +.TP +.B LC_COLLATE +This variable determines the collation order used when sorting the +results of pathname expansion, and determines the behavior of range +expressions, equivalence classes, and collating sequences within +pathname expansion and pattern matching. +.TP +.B LC_CTYPE +This variable determines the interpretation of characters and the +behavior of character classes within pathname expansion and pattern +matching. +.TP +.B LC_MESSAGES +This variable determines the locale used to translate double-quoted +strings preceded by a \fB$\fP. +.TP +.B LC_NUMERIC +This variable determines the locale category used for number formatting. +.TP +.B LC_TIME +This variable determines the locale category used for data and time +formatting. +.TP +.B LINES +Used by the \fBselect\fP compound command to determine the column length +for printing selection lists. +Automatically set if the +.B checkwinsize +option is enabled or in an interactive shell upon receipt of a +.SM +.BR SIGWINCH . +.TP +.B MAIL +If this parameter is set to a file or directory name and the +.SM +.B MAILPATH +variable is not set, +.B bash +informs the user of the arrival of mail in the specified file or +Maildir-format directory. +.TP +.B MAILCHECK +Specifies how +often (in seconds) +.B bash +checks for mail. The default is 60 seconds. When it is time to check +for mail, the shell does so before displaying the primary prompt. +If this variable is unset, or set to a value that is not a number +greater than or equal to zero, the shell disables mail checking. +.TP +.B MAILPATH +A colon-separated list of filenames to be checked for mail. +The message to be printed when mail arrives in a particular file +may be specified by separating the filename from the message with a `?'. +When used in the text of the message, \fB$_\fP expands to the name of +the current mailfile. +Example: +.RS +.PP +\fBMAILPATH\fP=\(aq/var/mail/bfox?"You have mail":~/shell\-mail?"$_ has mail!"\(aq +.PP +.B Bash +can be configured to supply +a default value for this variable (there is no value by default), +but the location of the user +mail files that it uses is system dependent (e.g., /var/mail/\fB$USER\fP). +.RE +.TP +.B OPTERR +If set to the value 1, +.B bash +displays error messages generated by the +.B getopts +builtin command (see +.SM +.B SHELL BUILTIN COMMANDS +below). +.SM +.B OPTERR +is initialized to 1 each time the shell is invoked or a shell +script is executed. +.TP +.B PATH +The search path for commands. It +is a colon-separated list of directories in which +the shell looks for commands (see +.SM +.B COMMAND EXECUTION +below). +A zero-length (null) directory name in the value of +.SM +.B PATH +indicates the current directory. +A null directory name may appear as two adjacent colons, or as an initial +or trailing colon. +The default path is system-dependent, +and is set by the administrator who installs +.BR bash . +A common value is +.na +.if t \f(CW/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin\fP. +.if n ``/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin''. +.ad +.TP +.B POSIXLY_CORRECT +If this variable is in the environment when \fBbash\fP starts, the shell +enters \fIposix mode\fP before reading the startup files, as if the +.B \-\-posix +invocation option had been supplied. If it is set while the shell is +running, \fBbash\fP enables \fIposix mode\fP, as if the command +.if t \f(CWset -o posix\fP +.if n \fIset -o posix\fP +had been executed. +.TP +.B PROMPT_COMMAND +If set, the value is executed as a command prior to issuing each primary +prompt. +.TP +.B PROMPT_DIRTRIM +If set to a number greater than zero, the value is used as the number of +trailing directory components to retain when expanding the \fB\ew\fP and +\fB\eW\fP prompt string escapes (see +.SM +.B PROMPTING +below). Characters removed are replaced with an ellipsis. +.TP +.B PS0 +The value of this parameter is expanded (see +.SM +.B PROMPTING +below) and displayed by interactive shells after reading a command +and before the command is executed. +.TP +.B PS1 +The value of this parameter is expanded (see +.SM +.B PROMPTING +below) and used as the primary prompt string. The default value is +``\fB\es\-\ev\e$ \fP''. +.TP +.B PS2 +The value of this parameter is expanded as with +.SM +.B PS1 +and used as the secondary prompt string. The default is +``\fB> \fP''. +.TP +.B PS3 +The value of this parameter is used as the prompt for the +.B select +command (see +.SM +.B SHELL GRAMMAR +above). +.TP +.B PS4 +The value of this parameter is expanded as with +.SM +.B PS1 +and the value is printed before each command +.B bash +displays during an execution trace. The first character of +.SM +.B PS4 +is replicated multiple times, as necessary, to indicate multiple +levels of indirection. The default is ``\fB+ \fP''. +.TP +.B SHELL +The full pathname to the shell is kept in this environment variable. +If it is not set when the shell starts, +.B bash +assigns to it the full pathname of the current user's login shell. +.TP +.B TIMEFORMAT +The value of this parameter is used as a format string specifying +how the timing information for pipelines prefixed with the +.B time +reserved word should be displayed. +The \fB%\fP 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. +.sp .5 +.RS +.PD 0 +.TP 10 +.B %% +A literal \fB%\fP. +.TP +.B %[\fIp\fP][l]R +The elapsed time in seconds. +.TP +.B %[\fIp\fP][l]U +The number of CPU seconds spent in user mode. +.TP +.B %[\fIp\fP][l]S +The number of CPU seconds spent in system mode. +.TP +.B %P +The CPU percentage, computed as (%U + %S) / %R. +.PD +.RE +.IP +The optional \fIp\fP is a digit specifying the \fIprecision\fP, +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 \fIp\fP greater than 3 are changed to 3. +If \fIp\fP is not specified, the value 3 is used. +.IP +The optional \fBl\fP specifies a longer format, including +minutes, of the form \fIMM\fPm\fISS\fP.\fIFF\fPs. +The value of \fIp\fP determines whether or not the fraction is +included. +.IP +If this variable is not set, \fBbash\fP acts as if it had the +value \fB$\(aq\enreal\et%3lR\enuser\et%3lU\ensys\et%3lS\(aq\fP. +If the value is null, no timing information is displayed. +A trailing newline is added when the format string is displayed. +.PD 0 +.TP +.B TMOUT +If set to a value greater than zero, +.SM +.B TMOUT +is treated as the +default timeout for the \fBread\fP builtin. +The \fBselect\fP command terminates if input does not arrive +after +.SM +.B 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 a line of input after issuing the +primary prompt. +.B Bash +terminates after waiting for that number of seconds if a complete +line of input does not arrive. +.TP +.B TMPDIR +If set, \fBbash\fP uses its value as the name of a directory in which +\fBbash\fP creates temporary files for the shell's use. +.TP +.B auto_resume +This variable controls how the shell interacts with the user and +job control. If this variable is set, single word simple +commands without redirections are treated as candidates for resumption +of an existing stopped job. There is no ambiguity allowed; if there is +more than one job beginning with the string typed, the job most recently +accessed is selected. The +.I name +of a stopped job, in this context, is the command line used to +start it. +If set to the value +.IR exact , +the string supplied must match the name of a stopped job exactly; +if set to +.IR substring , +the string supplied needs to match a substring of the name of a +stopped job. The +.I substring +value provides functionality analogous to the +.B %? +job identifier (see +.SM +.B JOB CONTROL +below). 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 \fB%\fP\fIstring\fP job identifier. +.TP +.B histchars +The two or three characters which control history expansion +and tokenization (see +.SM +.B HISTORY EXPANSION +below). The first character is the \fIhistory expansion\fP character, +the character which signals the start of a history +expansion, normally `\fB!\fP'. +The second character is the \fIquick substitution\fP +character, which is used as shorthand for re-running the previous +command entered, substituting one string for another in the command. +The default is `\fB^\fP'. +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, normally `\fB#\fP'. 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. +.PD +.SS Arrays +.B Bash +provides one-dimensional indexed and associative array variables. +Any variable may be used as an indexed array; the +.B 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. +Indexed arrays are referenced using integers (including arithmetic +expressions) and are zero-based; associative arrays are referenced +using arbitrary strings. +Unless otherwise noted, indexed array indices must be non-negative integers. +.PP +An indexed array is created automatically if any variable is assigned to +using the syntax \fIname\fP[\fIsubscript\fP]=\fIvalue\fP. The +.I subscript +is treated as an arithmetic expression that must evaluate to a number. +To explicitly declare an indexed array, use +.B declare \-a \fIname\fP +(see +.SM +.B SHELL BUILTIN COMMANDS +below). +.B declare \-a \fIname\fP[\fIsubscript\fP] +is also accepted; the \fIsubscript\fP is ignored. +.PP +Associative arrays are created using +.BR "declare \-A \fIname\fP" . +.PP +Attributes may be +specified for an array variable using the +.B declare +and +.B readonly +builtins. Each attribute applies to all members of an array. +.PP +Arrays are assigned to using compound assignments of the form +\fIname\fP=\fB(\fPvalue\fI1\fP ... value\fIn\fP\fB)\fP, where each +\fIvalue\fP is of the form [\fIsubscript\fP]=\fIstring\fP. +Indexed array assignments do not require anything but \fIstring\fP. +When assigning to indexed arrays, if the optional brackets and subscript +are 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. +.PP +When assigning to an associative array, the subscript is required. +.PP +This syntax is also accepted by the +.B declare +builtin. Individual array elements may be assigned to using the +\fIname\fP[\fIsubscript\fP]=\fIvalue\fP syntax introduced above. +When assigning to an indexed array, if +.I name +is subscripted by a negative number, that number is +interpreted as relative to one greater than the maximum index of +\fIname\fP, so negative indices count back from the end of the +array, and an index of \-1 references the last element. +.PP +Any element of an array may be referenced using +${\fIname\fP[\fIsubscript\fP]}. The braces are required to avoid +conflicts with pathname expansion. If +\fIsubscript\fP is \fB@\fP or \fB*\fP, the word expands to +all members of \fIname\fP. These subscripts differ only when the +word appears within double quotes. If the word is double-quoted, +${\fIname\fP[*]} expands to a single +word with the value of each array member separated by the first +character of the +.SM +.B IFS +special variable, and ${\fIname\fP[@]} expands each element of +\fIname\fP to a separate word. When there are no array members, +${\fIname\fP[@]} 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 \fB*\fP and \fB@\fP (see +.B Special Parameters +above). ${#\fIname\fP[\fIsubscript\fP]} expands to the length of +${\fIname\fP[\fIsubscript\fP]}. If \fIsubscript\fP is \fB*\fP or +\fB@\fP, the expansion is the number of elements in the array. +If the +.I subscript +used to reference an element of an indexed array +evaluates to a number less than zero, it is +interpreted as relative to one greater than the maximum index of the array, +so negative indices count back from the end of the +array, and an index of \-1 references the last element. +.PP +Referencing an array variable without a subscript is equivalent to +referencing the array with a subscript of 0. +Any reference to a variable using a valid subscript is legal, and +.B bash +will create an array if necessary. +.PP +An array variable is considered set if a subscript has been assigned a +value. The null string is a valid value. +.PP +It is possible to obtain the keys (indices) of an array as well as the values. +${\fB!\fP\fIname\fP[\fI@\fP]} and ${\fB!\fP\fIname\fP[\fI*\fP]} +expand to the indices assigned in array variable \fIname\fP. +The treatment when in double quotes is similar to the expansion of the +special parameters \fI@\fP and \fI*\fP within double quotes. +.PP +The +.B unset +builtin is used to destroy arrays. \fBunset\fP \fIname\fP[\fIsubscript\fP] +destroys the array element at index \fIsubscript\fP. +Negative subscripts to indexed arrays are interpreted as described above. +Care must be taken to avoid unwanted side effects caused by pathname +expansion. +\fBunset\fP \fIname\fP, where \fIname\fP is an array, or +\fBunset\fP \fIname\fP[\fIsubscript\fP], where +\fIsubscript\fP is \fB*\fP or \fB@\fP, removes the entire array. +.PP +The +.BR declare , +.BR local , +and +.B readonly +builtins each accept a +.B \-a +option to specify an indexed array and a +.B \-A +option to specify an associative array. +If both options are supplied, +.B \-A +takes precedence. +The +.B read +builtin accepts a +.B \-a +option to assign a list of words read from the standard input +to an array. The +.B set +and +.B declare +builtins display array values in a way that allows them to be +reused as assignments. +.SH EXPANSION +Expansion is performed on the command line after it has been split into +words. There are seven kinds of expansion performed: +.IR "brace expansion" , +.IR "tilde expansion" , +.IR "parameter and variable expansion" , +.IR "command substitution" , +.IR "arithmetic expansion" , +.IR "word splitting" , +and +.IR "pathname expansion" . +.PP +The order of expansions is: +brace expansion; +tilde expansion, parameter and variable expansion, arithmetic expansion, +and command substitution (done in a left-to-right fashion); +word splitting; +and pathname expansion. +.PP +On systems that can support it, there is an additional expansion +available: \fIprocess substitution\fP. +This is performed at the +same time as tilde, parameter, variable, and arithmetic expansion and +command substitution. +.PP +After these expansions are performed, quote characters present in the +original word are removed unless they have been quoted themselves +(\fIquote removal\fP). +.PP +Only brace expansion, word splitting, and pathname 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 +"\fB$@\fP" and "\fB${\fP\fIname\fP\fB[@]}\fP" +as explained above (see +.SM +.BR PARAMETERS ). +.SS Brace Expansion +.PP +.I "Brace expansion" +is a mechanism by which arbitrary strings +may be generated. This mechanism is similar to +\fIpathname expansion\fP, but the filenames generated +need not exist. Patterns to be brace expanded take +the form of an optional +.IR preamble , +followed by either a series of comma-separated strings or +a sequence expression between a pair of braces, followed by +an optional +.IR 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. +.PP +Brace expansions may be nested. The results of each expanded +string are not sorted; left to right order is preserved. +For example, a\fB{\fPd,c,b\fB}\fPe expands into `ade ace abe'. +.PP +A sequence expression takes the form +\fB{\fP\fIx\fP\fB..\fP\fIy\fP\fB[..\fP\fIincr\fP\fB]}\fP, +where \fIx\fP and \fIy\fP are either integers or single characters, +and \fIincr\fP, an optional increment, is an integer. +When integers are supplied, the expression expands to each number between +\fIx\fP and \fIy\fP, inclusive. +Supplied integers may be prefixed with \fI0\fP to force each term to have the +same width. +When either \fIx\fP or \fPy\fP begins with a zero, the shell +attempts to force all generated terms to contain the same number of digits, +zero-padding where necessary. +When characters are supplied, the expression expands to each character +lexicographically between \fIx\fP and \fIy\fP, inclusive, +using the default C locale. +Note that both \fIx\fP and \fIy\fP must be of the same type. +When the increment is supplied, it is used as the difference between +each term. The default increment is 1 or -1 as appropriate. +.PP +Brace expansion is performed before any other expansions, +and any characters special to other expansions are preserved +in the result. It is strictly textual. +.B Bash +does not apply any syntactic interpretation to the context of the +expansion or the text between the braces. +.PP +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 \fB{\fP or \fB,\fP may be quoted with a backslash to prevent its +being considered part of a brace expression. +To avoid conflicts with parameter expansion, the string \fB${\fP +is not considered eligible for brace expansion. +.PP +This construct is typically used as shorthand when the common +prefix of the strings to be generated is longer than in the +above example: +.RS +.PP +mkdir /usr/local/src/bash/{old,new,dist,bugs} +.RE +or +.RS +chown root /usr/{ucb/{ex,edit},lib/{ex?.?*,how_ex}} +.RE +.PP +Brace expansion introduces a slight incompatibility with +historical versions of +.BR sh . +.B sh +does not treat opening or closing braces specially when they +appear as part of a word, and preserves them in the output. +.B Bash +removes braces from words as a consequence of brace +expansion. For example, a word entered to +.B sh +as \fIfile{1,2}\fP +appears identically in the output. The same word is +output as +.I file1 file2 +after expansion by +.BR bash . +If strict compatibility with +.B sh +is desired, start +.B bash +with the +.B +B +option or disable brace expansion with the +.B +B +option to the +.B set +command (see +.SM +.B SHELL BUILTIN COMMANDS +below). +.SS Tilde Expansion +.PP +If a word begins with an unquoted tilde character (`\fB~\fP'), all of +the characters preceding the first unquoted slash (or all characters, +if there is no unquoted slash) are considered a \fItilde-prefix\fP. +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 \fIlogin name\fP. +If this login name is the null string, the tilde is replaced with the +value of the shell parameter +.SM +.BR HOME . +If +.SM +.B 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. +.PP +If the tilde-prefix is a `~+', the value of the shell variable +.SM +.B PWD +replaces the tilde-prefix. +If the tilde-prefix is a `~\-', the value of the shell variable +.SM +.BR OLDPWD , +if it is set, is substituted. +If the characters following the tilde in the tilde-prefix consist +of a number \fIN\fP, optionally prefixed +by a `+' or a `\-', the tilde-prefix is replaced with the corresponding +element from the directory stack, as it would be displayed by the +.B dirs +builtin invoked with the tilde-prefix as an argument. +If the characters following the tilde in the tilde-prefix consist of a +number without a leading `+' or `\-', `+' is assumed. +.PP +If the login name is invalid, or the tilde expansion fails, the word +is unchanged. +.PP +Each variable assignment is checked for unquoted tilde-prefixes immediately +following a +.B : +or the first +.BR = . +In these cases, tilde expansion is also performed. +Consequently, one may use filenames with tildes in assignments to +.SM +.BR PATH , +.SM +.BR MAILPATH , +and +.SM +.BR CDPATH , +and the shell assigns the expanded value. +.SS Parameter Expansion +.PP +The `\fB$\fP' 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. +.PP +When braces are used, the matching ending brace is the first `\fB}\fP' +not escaped by a backslash or within a quoted string, and not within an +embedded arithmetic expansion, command substitution, or parameter +expansion. +.PP +.PD 0 +.TP +${\fIparameter\fP} +The value of \fIparameter\fP is substituted. The braces are required +when +.I parameter +is a positional parameter with more than one digit, +or when +.I parameter +is followed by a character which is not to be +interpreted as part of its name. +The \fIparameter\fP is a shell parameter as described above +\fBPARAMETERS\fP) or an array reference (\fBArrays\fP). +.PD +.PP +If the first character of \fIparameter\fP is an exclamation point (\fB!\fP), +and \fIparameter\fP is not a \fInameref\fP, +it introduces a level of variable indirection. +\fBBash\fP uses the value of the variable formed from the rest of +\fIparameter\fP 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 \fIparameter\fP itself. +This is known as \fIindirect expansion\fP. +If \fIparameter\fP is a nameref, this expands to the name of the +variable referenced by \fIparameter\fP instead of performing the +complete indirect expansion. +The exceptions to this are the expansions of ${\fB!\fP\fIprefix\fP\fB*\fP} and +${\fB!\fP\fIname\fP[\fI@\fP]} described below. +The exclamation point must immediately follow the left brace in order to +introduce indirection. +.PP +In each of the cases below, \fIword\fP is subject to tilde expansion, +parameter expansion, command substitution, and arithmetic expansion. +.PP +When not performing substring expansion, using the forms documented below +(e.g., \fB:-\fP), +\fBbash\fP tests for a parameter that is unset or null. Omitting the colon +results in a test only for a parameter that is unset. +.PP +.PD 0 +.TP +${\fIparameter\fP\fB:\-\fP\fIword\fP} +\fBUse Default Values\fP. If +.I parameter +is unset or null, the expansion of +.I word +is substituted. Otherwise, the value of +.I parameter +is substituted. +.TP +${\fIparameter\fP\fB:=\fP\fIword\fP} +\fBAssign Default Values\fP. +If +.I parameter +is unset or null, the expansion of +.I word +is assigned to +.IR parameter . +The value of +.I parameter +is then substituted. Positional parameters and special parameters may +not be assigned to in this way. +.TP +${\fIparameter\fP\fB:?\fP\fIword\fP} +\fBDisplay Error if Null or Unset\fP. +If +.I parameter +is null or unset, the expansion of \fIword\fP (or a message to that effect +if +.I word +is not present) is written to the standard error and the shell, if it +is not interactive, exits. Otherwise, the value of \fIparameter\fP is +substituted. +.TP +${\fIparameter\fP\fB:+\fP\fIword\fP} +\fBUse Alternate Value\fP. +If +.I parameter +is null or unset, nothing is substituted, otherwise the expansion of +.I word +is substituted. +.TP +${\fIparameter\fP\fB:\fP\fIoffset\fP} +.PD 0 +.TP +${\fIparameter\fP\fB:\fP\fIoffset\fP\fB:\fP\fIlength\fP} +.PD +\fBSubstring Expansion\fP. +Expands to up to \fIlength\fP characters of the value of \fIparameter\fP +starting at the character specified by \fIoffset\fP. +If \fIparameter\fP is \fB@\fP, an indexed array subscripted by +\fB@\fP or \fB*\fP, or an associative array name, the results differ as +described below. +If \fIlength\fP is omitted, expands to the substring of the value of +\fIparameter\fP starting at the character specified by \fIoffset\fP +and extending to the end of the value. +\fIlength\fP and \fIoffset\fP are arithmetic expressions (see +.SM +.B +ARITHMETIC EVALUATION +below). +.sp 1 +If \fIoffset\fP evaluates to a number less than zero, the value +is used as an offset in characters +from the end of the value of \fIparameter\fP. +If \fIlength\fP evaluates to a number less than zero, +it is interpreted as an offset in characters +from the end of the value of \fIparameter\fP rather than +a number of characters, and the expansion is the characters between +\fIoffset\fP and that result. +Note that a negative offset must be separated from the colon by at least +one space to avoid being confused with the \fB:-\fP expansion. +.sp 1 +If \fIparameter\fP is \fB@\fP, the result is \fIlength\fP positional +parameters beginning at \fIoffset\fP. +A negative \fIoffset\fP is taken relative to one greater than the greatest +positional parameter, so an offset of -1 evaluates to the last positional +parameter. +It is an expansion error if \fIlength\fP evaluates to a number less than +zero. +.sp 1 +If \fIparameter\fP is an indexed array name subscripted by @ or *, +the result is the \fIlength\fP +members of the array beginning with ${\fIparameter\fP[\fIoffset\fP]}. +A negative \fIoffset\fP is taken relative to one greater than the maximum +index of the specified array. +It is an expansion error if \fIlength\fP evaluates to a number less than +zero. +.sp 1 +Substring expansion applied to an associative array produces undefined +results. +.sp 1 +Substring indexing is zero-based unless the positional parameters +are used, in which case the indexing starts at 1 by default. +If \fIoffset\fP is 0, and the positional parameters are used, \fB$0\fP is +prefixed to the list. +.TP +${\fB!\fP\fIprefix\fP\fB*\fP} +.PD 0 +.TP +${\fB!\fP\fIprefix\fP\fB@\fP} +.PD +\fBNames matching prefix\fP. +Expands to the names of variables whose names begin with \fIprefix\fP, +separated by the first character of the +.SM +.B IFS +special variable. +When \fI@\fP is used and the expansion appears within double quotes, each +variable name expands to a separate word. +.TP +${\fB!\fP\fIname\fP[\fI@\fP]} +.PD 0 +.TP +${\fB!\fP\fIname\fP[\fI*\fP]} +.PD +\fBList of array keys\fP. +If \fIname\fP is an array variable, expands to the list of array indices +(keys) assigned in \fIname\fP. +If \fIname\fP is not an array, expands to 0 if \fIname\fP is set and null +otherwise. +When \fI@\fP is used and the expansion appears within double quotes, each +key expands to a separate word. +.TP +${\fB#\fP\fIparameter\fP} +\fBParameter length\fP. +The length in characters of the value of \fIparameter\fP is substituted. +If +.I parameter +is +.B * +or +.BR @ , +the value substituted is the number of positional parameters. +If +.I parameter +is an array name subscripted by +.B * +or +.BR @ , +the value substituted is the number of elements in the array. +If +.I parameter +is an indexed array name subscripted by a negative number, that number is +interpreted as relative to one greater than the maximum index of +\fIparameter\fP, so negative indices count back from the end of the +array, and an index of \-1 references the last element. +.TP +${\fIparameter\fP\fB#\fP\fIword\fP} +.PD 0 +.TP +${\fIparameter\fP\fB##\fP\fIword\fP} +.PD +\fBRemove matching prefix pattern\fP. +The +.I word +is expanded to produce a pattern just as in pathname +expansion. If the pattern matches the beginning of +the value of +.IR parameter , +then the result of the expansion is the expanded value of +.I parameter +with the shortest matching pattern (the ``\fB#\fP'' case) or the +longest matching pattern (the ``\fB##\fP'' case) deleted. +If +.I parameter +is +.B @ +or +.BR * , +the pattern removal operation is applied to each positional +parameter in turn, and the expansion is the resultant list. +If +.I parameter +is an array variable subscripted with +.B @ +or +.BR * , +the pattern removal operation is applied to each member of the +array in turn, and the expansion is the resultant list. +.TP +${\fIparameter\fP\fB%\fP\fIword\fP} +.PD 0 +.TP +${\fIparameter\fP\fB%%\fP\fIword\fP} +.PD +\fBRemove matching suffix pattern\fP. +The \fIword\fP is expanded to produce a pattern just as in +pathname expansion. +If the pattern matches a trailing portion of the expanded value of +.IR parameter , +then the result of the expansion is the expanded value of +.I parameter +with the shortest matching pattern (the ``\fB%\fP'' case) or the +longest matching pattern (the ``\fB%%\fP'' case) deleted. +If +.I parameter +is +.B @ +or +.BR * , +the pattern removal operation is applied to each positional +parameter in turn, and the expansion is the resultant list. +If +.I parameter +is an array variable subscripted with +.B @ +or +.BR * , +the pattern removal operation is applied to each member of the +array in turn, and the expansion is the resultant list. +.TP +${\fIparameter\fP\fB/\fP\fIpattern\fP\fB/\fP\fIstring\fP} +\fBPattern substitution\fP. +The \fIpattern\fP is expanded to produce a pattern just as in +pathname expansion. +\fIParameter\fP is expanded and the longest match of \fIpattern\fP +against its value is replaced with \fIstring\fP. +If \fIpattern\fP begins with \fB/\fP, all matches of \fIpattern\fP are +replaced with \fIstring\fP. Normally only the first match is replaced. +If \fIpattern\fP begins with \fB#\fP, it must match at the beginning +of the expanded value of \fIparameter\fP. +If \fIpattern\fP begins with \fB%\fP, it must match at the end +of the expanded value of \fIparameter\fP. +If \fIstring\fP is null, matches of \fIpattern\fP are deleted +and the \fB/\fP following \fIpattern\fP may be omitted. +If the +.B nocasematch +shell option is enabled, the match is performed without regard to the case +of alphabetic characters. +If +.I parameter +is +.B @ +or +.BR * , +the substitution operation is applied to each positional +parameter in turn, and the expansion is the resultant list. +If +.I parameter +is an array variable subscripted with +.B @ +or +.BR * , +the substitution operation is applied to each member of the +array in turn, and the expansion is the resultant list. +.TP +${\fIparameter\fP\fB^\fP\fIpattern\fP} +.PD 0 +.TP +${\fIparameter\fP\fB^^\fP\fIpattern\fP} +.TP +${\fIparameter\fP\fB,\fP\fIpattern\fP} +.TP +${\fIparameter\fP\fB,,\fP\fIpattern\fP} +.PD +\fBCase modification\fP. +This expansion modifies the case of alphabetic characters in \fIparameter\fP. +The \fIpattern\fP is expanded to produce a pattern just as in +pathname expansion. +Each character in the expanded value of \fIparameter\fP is tested against +\fIpattern\fP, and, if it matches the pattern, its case is converted. +The pattern should not attempt to match more than one character. +The \fB^\fP operator converts lowercase letters matching \fIpattern\fP +to uppercase; the \fB,\fP operator converts matching uppercase letters +to lowercase. +The \fB^^\fP and \fB,,\fP expansions convert each matched character in the +expanded value; the \fB^\fP and \fB,\fP expansions match and convert only +the first character in the expanded value. +If \fIpattern\fP is omitted, it is treated like a \fB?\fP, which matches +every character. +If +.I parameter +is +.B @ +or +.BR * , +the case modification operation is applied to each positional +parameter in turn, and the expansion is the resultant list. +If +.I parameter +is an array variable subscripted with +.B @ +or +.BR * , +the case modification operation is applied to each member of the +array in turn, and the expansion is the resultant list. +.TP +${\fIparameter\fP\fB@\fP\fIoperator\fP} +\fBParameter transformation\fP. +The expansion is either a transformation of the value of \fIparameter\fP +or information about \fIparameter\fP itself, depending on the value of +\fIoperator\fP. Each \fIoperator\fP is a single letter: +.sp 1 +.RS +.PD 0 +.TP +.B Q +The expansion is a string that is the value of \fIparameter\fP quoted in a +format that can be reused as input. +.TP +.B E +The expansion is a string that is the value of \fIparameter\fP with backslash +escape sequences expanded as with the \fB$'...'\fP quoting mechansim. +.TP +.B P +The expansion is a string that is the result of expanding the value of +\fIparameter\fP as if it were a prompt string (see \fBPROMPTING\fP below). +.TP +.B A +The expansion is a string in the form of +an assignment statement or \fBdeclare\fP command that, if +evaluated, will recreate \fIparameter\fP with its attributes and value. +.TP +.B a +The expansion is a string consisting of flag values representing +\fIparameter\fP's attributes. +.PD +.PP +If +.I parameter +is +.B @ +or +.BR * , +the operation is applied to each positional +parameter in turn, and the expansion is the resultant list. +If +.I parameter +is an array variable subscripted with +.B @ +or +.BR * , +the case modification operation is applied to each member of the +array in turn, and the expansion is the resultant list. +.sp 1 +The result of the expansion is subject to word splitting and pathname +expansion as described below. +.RE +.SS Command Substitution +.PP +\fICommand substitution\fP allows the output of a command to replace +the command name. There are two forms: +.RS +.PP +\fB$(\fP\fIcommand\fP\|\fB)\fP +.RE +or +.RS +\fB\`\fP\fIcommand\fP\fB\`\fP +.RE +.PP +.B Bash +performs the expansion by executing \fIcommand\fP in a subshell environment +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 \fB$(cat \fIfile\fP)\fR can be replaced by +the equivalent but faster \fB$(< \fIfile\fP)\fR. +.PP +When the old-style backquote form of substitution is used, +backslash retains its literal meaning except when followed by +.BR $ , +.BR \` , +or +.BR \e . +The first backquote not preceded by a backslash terminates the +command substitution. +When using the $(\^\fIcommand\fP\|) form, all characters between the +parentheses make up the command; none are treated specially. +.PP +Command substitutions may be nested. To nest when using the backquoted form, +escape the inner backquotes with backslashes. +.PP +If the substitution appears within double quotes, word splitting and +pathname expansion are not performed on the results. +.SS Arithmetic Expansion +.PP +Arithmetic expansion allows the evaluation of an arithmetic expression +and the substitution of the result. The format for arithmetic expansion is: +.RS +.PP +\fB$((\fP\fIexpression\fP\fB))\fP +.RE +.PP +The +.I 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 and variable expansion, +command substitution, and quote removal. +The result is treated as the arithmetic expression to be evaluated. +Arithmetic expansions may be nested. +.PP +The evaluation is performed according to the rules listed below under +.SM +.BR "ARITHMETIC EVALUATION" . +If +.I expression +is invalid, +.B bash +prints a message indicating failure and no substitution occurs. +.SS Process Substitution +.PP +\fIProcess substitution\fP allows a process's input or output to be +referred to using a filename. +It takes the form of +\fB<(\fP\fIlist\^\fP\fB)\fP +or +\fB>(\fP\fIlist\^\fP\fB)\fP. +The process \fIlist\fP is run asynchronously, and its input or output +appears as a filename. +This filename is +passed as an argument to the current command as the result of the +expansion. +If the \fB>(\fP\fIlist\^\fP\fB)\fP form is used, writing to +the file will provide input for \fIlist\fP. If the +\fB<(\fP\fIlist\^\fP\fB)\fP form is used, the file passed as an +argument should be read to obtain the output of \fIlist\fP. +Process substitution is supported on systems that support named +pipes (\fIFIFOs\fP) or the \fB/dev/fd\fP method of naming open files. +.PP +When available, process substitution is performed +simultaneously with parameter and variable expansion, +command substitution, +and arithmetic expansion. +.SS Word Splitting +.PP +The shell scans the results of +parameter expansion, +command substitution, +and +arithmetic expansion +that did not occur within double quotes for +.IR "word splitting" . +.PP +The shell treats each character of +.SM +.B IFS +as a delimiter, and splits the results of the other +expansions into words using these characters as field terminators. +If +.SM +.B IFS +is unset, or its +value is exactly +.BR , +the default, then +sequences of +.BR , +.BR , +and +.B +at the beginning and end of the results of the previous +expansions are ignored, and +any sequence of +.SM +.B IFS +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 +the whitespace characters +.BR space , +.BR tab , +and +.B newline +are ignored at the beginning and end of the +word, as long as the whitespace character is in the +value of +.SM +.BR IFS +(an +.SM +.B IFS +whitespace character). +Any character in +.SM +.B IFS +that is not +.SM +.B IFS +whitespace, along with any adjacent +.SM +.B IFS +whitespace characters, delimits a field. +A sequence of +.SM +.B IFS +whitespace characters is also treated as a delimiter. +If the value of +.SM +.B IFS +is null, no word splitting occurs. +.PP +Explicit null arguments (\^\f3"\^"\fP or \^\f3\(aq\^\(aq\fP\^) are retained +and passed to commands as empty strings. +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 +and passed to a command as an empty string. +When a quoted null argument appears as part of a word whose expansion is +non-null, the null argument is removed. +That is, the word +\f(CW\-d\(aq\^\(aq\fP becomes \f(CW\-d\fP after word splitting and +null argument removal. +.PP +Note that if no expansion occurs, no splitting +is performed. +.SS Pathname Expansion +.PP +After word splitting, +unless the +.B \-f +option has been set, +.B bash +scans each word for the characters +.BR * , +.BR ? , +and +.BR [ . +If one of these characters appears, then the word is +regarded as a +.IR pattern , +and replaced with an alphabetically sorted list of +filenames matching the pattern +(see +.SM +.B "Pattern Matching" +below). +If no matching filenames are found, +and the shell option +.B nullglob +is not enabled, the word is left unchanged. +If the +.B nullglob +option is set, and no matches are found, +the word is removed. +If the +.B 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 +.B nocaseglob +is enabled, the match is performed without regard to the case +of alphabetic characters. +When a pattern is used for pathname expansion, +the character +.B ``.'' +at the start of a name or immediately following a slash +must be matched explicitly, unless the shell option +.B dotglob +is set. +When matching a pathname, the slash character must always be +matched explicitly. +In other cases, the +.B ``.'' +character is not treated specially. +See the description of +.B shopt +below under +.SM +.B SHELL BUILTIN COMMANDS +for a description of the +.BR nocaseglob , +.BR nullglob , +.BR failglob , +and +.B dotglob +shell options. +.PP +The +.SM +.B GLOBIGNORE +shell variable may be used to restrict the set of filenames matching a +.IR pattern . +If +.SM +.B GLOBIGNORE +is set, each matching filename that also matches one of the patterns in +.SM +.B GLOBIGNORE +is removed from the list of matches. +If the \fBnocaseglob\fP option is set, the matching against the patterns in +.SM +.B GLOBIGNORE +is performed without regard to case. +The filenames +.B ``.'' +and +.B ``..'' +are always ignored when +.SM +.B GLOBIGNORE +is set and not null. However, setting +.SM +.B GLOBIGNORE +to a non-null value has the effect of enabling the +.B dotglob +shell option, so all other filenames beginning with a +.B ``.'' +will match. +To get the old behavior of ignoring filenames beginning with a +.BR ``.'' , +make +.B ``.*'' +one of the patterns in +.SM +.BR GLOBIGNORE . +The +.B dotglob +option is disabled when +.SM +.B GLOBIGNORE +is unset. +The pattern matching honors the setting of the \fBextglob\fP shell +option. +.PP +\fBPattern Matching\fP +.PP +Any character that appears in a pattern, other than the special pattern +characters described below, matches itself. The 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. +.PP +The special pattern characters have the following meanings: +.PP +.PD 0 +.RS +.TP +.B * +Matches any string, including the null string. +When the \fBglobstar\fP shell option is enabled, and \fB*\fP is used in +a pathname expansion context, two adjacent \fB*\fPs used as a single +pattern will match all files and zero or more directories and +subdirectories. +If followed by a \fB/\fP, two adjacent \fB*\fPs will match only directories +and subdirectories. +.TP +.B ? +Matches any single character. +.TP +.B [...] +Matches any one of the enclosed characters. A pair of characters +separated by a hyphen denotes a +\fIrange expression\fP; +any character that falls between those two characters, inclusive, +using the current locale's collating sequence and character set, +is matched. If the first character following the +.B [ +is a +.B ! +or a +.B ^ +then any character not enclosed is matched. +The sorting order of characters in range expressions is determined by +the current locale and the values of the +.SM +.B LC_COLLATE +or +.SM +.B LC_ALL +shell variables, if set. +To obtain the traditional interpretation of range expressions, where +.B [a\-d] +is equivalent to +.BR [abcd] , +set value of the +.B LC_ALL +shell variable to +.BR C , +or enable the +.B globasciiranges +shell option. +A +.B \- +may be matched by including it as the first or last character +in the set. +A +.B ] +may be matched by including it as the first character +in the set. +.br +.if t .sp 0.5 +.if n .sp 1 +Within +.B [ +and +.BR ] , +\fIcharacter classes\fP can be specified using the syntax +\fB[:\fP\fIclass\fP\fB:]\fP, where \fIclass\fP is one of the +following classes defined in the POSIX standard: +.PP +.RS +.B +.if n alnum alpha ascii blank cntrl digit graph lower print punct space upper word xdigit +.if t alnum alpha ascii blank cntrl digit graph lower print punct space upper word xdigit +.br +A character class matches any character belonging to that class. +The \fBword\fP character class matches letters, digits, and the character _. +.br +.if t .sp 0.5 +.if n .sp 1 +Within +.B [ +and +.BR ] , +an \fIequivalence class\fP can be specified using the syntax +\fB[=\fP\fIc\fP\fB=]\fP, which matches all characters with the +same collation weight (as defined by the current locale) as +the character \fIc\fP. +.br +.if t .sp 0.5 +.if n .sp 1 +Within +.B [ +and +.BR ] , +the syntax \fB[.\fP\fIsymbol\fP\fB.]\fP matches the collating symbol +\fIsymbol\fP. +.RE +.RE +.PD +.PP +If the \fBextglob\fP shell option is enabled using the \fBshopt\fP +builtin, several extended pattern matching operators are recognized. +In the following description, a \fIpattern-list\fP is a list of one +or more patterns separated by a \fB|\fP. +Composite patterns may be formed using one or more of the following +sub-patterns: +.sp 1 +.PD 0 +.RS +.TP +\fB?(\fP\^\fIpattern-list\^\fP\fB)\fP +Matches zero or one occurrence of the given patterns +.TP +\fB*(\fP\^\fIpattern-list\^\fP\fB)\fP +Matches zero or more occurrences of the given patterns +.TP +\fB+(\fP\^\fIpattern-list\^\fP\fB)\fP +Matches one or more occurrences of the given patterns +.TP +\fB@(\fP\^\fIpattern-list\^\fP\fB)\fP +Matches one of the given patterns +.TP +\fB!(\fP\^\fIpattern-list\^\fP\fB)\fP +Matches anything except one of the given patterns +.RE +.PD +.SS Quote Removal +.PP +After the preceding expansions, all unquoted occurrences of the +characters +.BR \e , +.BR \(aq , +and \^\f3"\fP\^ that did not result from one of the above +expansions are removed. +.SH REDIRECTION +Before a command is executed, its input and output +may be +.I redirected +using a special notation interpreted by the shell. +Redirection allows commands' file handles to be +duplicated, opened, closed, +made to refer to different files, +and can change the files the command reads from and writes to. +Redirection may also be used to modify file handles in the +current shell execution environment. +The following redirection +operators may precede or appear anywhere within a +.I simple command +or may follow a +.IR command . +Redirections are processed in the order they appear, from +left to right. +.PP +Each redirection that may be preceded by a file descriptor number +may instead be preceded by a word of the form {\fIvarname\fP}. +In this case, for each redirection operator except +>&- and <&-, the shell will allocate a file descriptor greater +than or equal to 10 and assign it to \fIvarname\fP. +If >&- or <&- is preceded +by {\fIvarname\fP}, the value of \fIvarname\fP defines the file +descriptor to close. +.PP +In the following descriptions, if the file descriptor number is +omitted, and the first character of the redirection operator is +.BR < , +the redirection refers to the standard input (file descriptor +0). If the first character of the redirection operator is +.BR > , +the redirection refers to the standard output (file descriptor +1). +.PP +The word following the redirection operator in the following +descriptions, unless otherwise noted, is subjected to +brace expansion, tilde expansion, parameter and variable expansion, +command substitution, arithmetic expansion, quote removal, +pathname expansion, and word splitting. +If it expands to more than one word, +.B bash +reports an error. +.PP +Note that the order of redirections is significant. For example, +the command +.RS +.PP +ls \fB>\fP dirlist 2\fB>&\fP1 +.RE +.PP +directs both standard output and standard error to the file +.IR dirlist , +while the command +.RS +.PP +ls 2\fB>&\fP1 \fB>\fP dirlist +.RE +.PP +directs only the standard output to file +.IR dirlist , +because the standard error was duplicated from the standard output +before the standard output was redirected to +.IR dirlist . +.PP +\fBBash\fP handles several filenames specially when they are used in +redirections, as described in the following table. +If the operating system on which \fBbash\fP is running provides these +special files, bash will use them; otherwise it will emulate them +internally with the behavior described below. +.RS +.PP +.PD 0 +.TP +.B /dev/fd/\fIfd\fP +If \fIfd\fP is a valid integer, file descriptor \fIfd\fP is duplicated. +.TP +.B /dev/stdin +File descriptor 0 is duplicated. +.TP +.B /dev/stdout +File descriptor 1 is duplicated. +.TP +.B /dev/stderr +File descriptor 2 is duplicated. +.TP +.B /dev/tcp/\fIhost\fP/\fIport\fP +If \fIhost\fP is a valid hostname or Internet address, and \fIport\fP +is an integer port number or service name, \fBbash\fP attempts to open +the corresponding TCP socket. +.TP +.B /dev/udp/\fIhost\fP/\fIport\fP +If \fIhost\fP is a valid hostname or Internet address, and \fIport\fP +is an integer port number or service name, \fBbash\fP attempts to open +the corresponding UDP socket. +.PD +.RE +.PP +A failure to open or create a file causes the redirection to fail. +.PP +Redirections using file descriptors greater than 9 should be used with +care, as they may conflict with file descriptors the shell uses +internally. +.SS Redirecting Input +.PP +Redirection of input causes the file whose name results from +the expansion of +.I word +to be opened for reading on file descriptor +.IR n , +or the standard input (file descriptor 0) if +.I n +is not specified. +.PP +The general format for redirecting input is: +.RS +.PP +[\fIn\fP]\fB<\fP\fIword\fP +.RE +.SS Redirecting Output +.PP +Redirection of output causes the file whose name results from +the expansion of +.I word +to be opened for writing on file descriptor +.IR n , +or the standard output (file descriptor 1) if +.I n +is not specified. If the file does not exist it is created; +if it does exist it is truncated to zero size. +.PP +The general format for redirecting output is: +.RS +.PP +[\fIn\fP]\fB>\fP\fIword\fP +.RE +.PP +If the redirection operator is +.BR > , +and the +.B noclobber +option to the +.B set +builtin has been enabled, the redirection will fail if the file +whose name results from the expansion of \fIword\fP exists and is +a regular file. +If the redirection operator is +.BR >| , +or the redirection operator is +.B > +and the +.B noclobber +option to the +.B set +builtin command is not enabled, the redirection is attempted even +if the file named by \fIword\fP exists. +.SS Appending Redirected Output +.PP +Redirection of output in this fashion +causes the file whose name results from +the expansion of +.I word +to be opened for appending on file descriptor +.IR n , +or the standard output (file descriptor 1) if +.I n +is not specified. If the file does not exist it is created. +.PP +The general format for appending output is: +.RS +.PP +[\fIn\fP]\fB>>\fP\fIword\fP +.RE +.PP +.SS Redirecting Standard Output and Standard Error +.PP +This construct 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 +.IR word . +.PP +There are two formats for redirecting standard output and +standard error: +.RS +.PP +\fB&>\fP\fIword\fP +.RE +and +.RS +\fB>&\fP\fIword\fP +.RE +.PP +Of the two forms, the first is preferred. +This is semantically equivalent to +.RS +.PP +\fB>\fP\fIword\fP 2\fB>&\fP1 +.RE +.PP +When using the second form, \fIword\fP may not expand to a number or +\fB\-\fP. If it does, other redirection operators apply +(see \fBDuplicating File Descriptors\fP below) for compatibility +reasons. +.SS Appending Standard Output and Standard Error +.PP +This construct allows both the +standard output (file descriptor 1) and +the standard error output (file descriptor 2) +to be appended to the file whose name is the +expansion of +.IR word . +.PP +The format for appending standard output and standard error is: +.RS +.PP +\fB&>>\fP\fIword\fP +.RE +.PP +This is semantically equivalent to +.RS +.PP +\fB>>\fP\fIword\fP 2\fB>&\fP1 +.RE +.PP +(see \fBDuplicating File Descriptors\fP below). +.SS Here Documents +.PP +This type of redirection instructs the shell to read input from the +current source until a line containing only +.I delimiter +(with no trailing blanks) +is seen. All of +the lines read up to that point are then used as the standard +input (or file descriptor \fIn\fP if \fIn\fP is specified) for a command. +.PP +The format of here-documents is: +.RS +.PP +.nf +[\fIn\fP]\fB<<\fP[\fB\-\fP]\fIword\fP + \fIhere-document\fP +\fIdelimiter\fP +.fi +.RE +.PP +No parameter and variable expansion, command substitution, +arithmetic expansion, or pathname expansion is performed on +.IR word . +If any part of +.I word +is quoted, the +.I delimiter +is the result of quote removal on +.IR word , +and the lines in the here-document are not expanded. +If \fIword\fP is unquoted, +all lines of the here-document are subjected to +parameter expansion, command substitution, and arithmetic expansion, +the character sequence +.B \e +is ignored, and +.B \e +must be used to quote the characters +.BR \e , +.BR $ , +and +.BR \` . +.PP +If the redirection operator is +.BR <<\- , +then all leading tab characters are stripped from input lines and the +line containing +.IR delimiter . +This allows +here-documents within shell scripts to be indented in a +natural fashion. +.SS "Here Strings" +A variant of here documents, the format is: +.RS +.PP +.nf +[\fIn\fP]\fB<<<\fP\fIword\fP +.fi +.RE +.PP +The \fIword\fP undergoes +brace expansion, tilde expansion, parameter and variable expansion, +command substitution, arithmetic expansion, and quote removal. +Pathname expansion and word splitting are not performed. +The result is supplied as a single string, with a newline appended, +to the command on its +standard input (or file descriptor \fIn\fP if \fIn\fP is specified). +.SS "Duplicating File Descriptors" +.PP +The redirection operator +.RS +.PP +[\fIn\fP]\fB<&\fP\fIword\fP +.RE +.PP +is used to duplicate input file descriptors. +If +.I word +expands to one or more digits, the file descriptor denoted by +.I n +is made to be a copy of that file descriptor. +If the digits in +.I word +do not specify a file descriptor open for input, a redirection error occurs. +If +.I word +evaluates to +.BR \- , +file descriptor +.I n +is closed. If +.I n +is not specified, the standard input (file descriptor 0) is used. +.PP +The operator +.RS +.PP +[\fIn\fP]\fB>&\fP\fIword\fP +.RE +.PP +is used similarly to duplicate output file descriptors. If +.I n +is not specified, the standard output (file descriptor 1) is used. +If the digits in +.I word +do not specify a file descriptor open for output, a redirection error occurs. +If +.I word +evaluates to +.BR \- , +file descriptor +.I n +is closed. +As a special case, if \fIn\fP is omitted, and \fIword\fP does not +expand to one or more digits or \fB\-\fP, the standard output and standard +error are redirected as described previously. +.SS "Moving File Descriptors" +.PP +The redirection operator +.RS +.PP +[\fIn\fP]\fB<&\fP\fIdigit\fP\fB\-\fP +.RE +.PP +moves the file descriptor \fIdigit\fP to file descriptor +.IR n , +or the standard input (file descriptor 0) if \fIn\fP is not specified. +\fIdigit\fP is closed after being duplicated to \fIn\fP. +.PP +Similarly, the redirection operator +.RS +.PP +[\fIn\fP]\fB>&\fP\fIdigit\fP\fB\-\fP +.RE +.PP +moves the file descriptor \fIdigit\fP to file descriptor +.IR n , +or the standard output (file descriptor 1) if \fIn\fP is not specified. +.SS "Opening File Descriptors for Reading and Writing" +.PP +The redirection operator +.RS +.PP +[\fIn\fP]\fB<>\fP\fIword\fP +.RE +.PP +causes the file whose name is the expansion of +.I word +to be opened for both reading and writing on file descriptor +.IR n , +or on file descriptor 0 if +.I n +is not specified. If the file does not exist, it is created. +.SH ALIASES +\fIAliases\fP 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 +.B alias +and +.B unalias +builtin commands (see +.SM +.B SHELL BUILTIN COMMANDS +below). +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 \fB/\fP, \fB$\fP, \fB\`\fP, and \fB=\fP and +any of the shell \fImetacharacters\fP 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 +.B ls +to +.BR "ls \-F" , +for instance, and +.B bash +does not try to recursively expand the replacement text. +If the last character of the alias value is a +.IR blank , +then the next command +word following the alias is also checked for alias expansion. +.PP +Aliases are created and listed with the +.B alias +command, and removed with the +.B unalias +command. +.PP +There is no mechanism for using arguments in the replacement text. +If arguments are needed, a shell function should be used (see +.SM +.B FUNCTIONS +below). +.PP +Aliases are not expanded when the shell is not interactive, unless +the +.B expand_aliases +shell option is set using +.B shopt +(see the description of +.B shopt +under +.SM +\fBSHELL BUILTIN COMMANDS\fP +below). +.PP +The rules concerning the definition and use of aliases are +somewhat confusing. +.B 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 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 +.B alias +in compound commands. +.PP +For almost every purpose, aliases are superseded by +shell functions. +.SH FUNCTIONS +A shell function, defined as described above under +.SM +.BR "SHELL GRAMMAR" , +stores a series of commands for later execution. +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. +Functions are executed in the context of the +current shell; no new process is created to interpret +them (contrast this with the execution of a shell script). +When a function is executed, the arguments to the +function become the positional parameters +during its execution. +The special parameter +.B # +is updated to reflect the change. Special parameter \fB0\fP +is unchanged. +The first element of the +.SM +.B FUNCNAME +variable is set to the name of the function while the function +is executing. +.PP +All other aspects of the shell execution +environment are identical between a function and its caller +with these exceptions: the +.SM +.B DEBUG +and +.B RETURN +traps (see the description of the +.B trap +builtin under +.SM +.B SHELL BUILTIN COMMANDS +below) are not inherited unless the function has been given the +\fBtrace\fP attribute (see the description of the +.SM +.B declare +builtin below) or the +\fB\-o functrace\fP shell option has been enabled with +the \fBset\fP builtin +(in which case all functions inherit the \fBDEBUG\fP and \fBRETURN\fP traps), +and the +.SM +.B ERR +trap is not inherited unless the \fB\-o errtrace\fP shell option has +been enabled. +.PP +Variables local to the function may be declared with the +.B local +builtin command. Ordinarily, variables and their values +are shared between the function and its caller. +.PP +The \fBFUNCNEST\fP variable, if set to a numeric value greater +than 0, defines a maximum function nesting level. Function +invocations that exceed the limit cause the entire command to +abort. +.PP +If the builtin command +.B 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 \fBRETURN\fP trap is executed +before execution resumes. +When a function completes, the values of the +positional parameters and the special parameter +.B # +are restored to the values they had prior to the function's +execution. +.PP +Function names and definitions may be listed with the +.B \-f +option to the +.B declare +or +.B typeset +builtin commands. The +.B \-F +option to +.B declare +or +.B typeset +will list the function names only +(and optionally the source file and line number, if the \fBextdebug\fP +shell option is enabled). +Functions may be exported so that subshells +automatically have them defined with the +.B \-f +option to the +.B export +builtin. +A function definition may be deleted using the \fB\-f\fP option to +the +.B unset +builtin. +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. +.PP +Functions may be recursive. +The \fBFUNCNEST\fP variable may be used to limit the depth of the +function call stack and restrict the number of function invocations. +By default, no limit is imposed on the number of recursive calls. +.SH "ARITHMETIC EVALUATION" +The shell allows arithmetic expressions to be evaluated, under +certain circumstances (see the \fBlet\fP and \fBdeclare\fP builtin +commands, the \fB((\fP compound command, and \fBArithmetic Expansion\fP). +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. +.PP +.PD 0 +.TP +.B \fIid\fP++ \fIid\fP\-\- +variable post-increment and post-decrement +.TP +.B ++\fIid\fP \-\-\fIid\fP +variable pre-increment and pre-decrement +.TP +.B \- + +unary minus and plus +.TP +.B ! ~ +logical and bitwise negation +.TP +.B ** +exponentiation +.TP +.B * / % +multiplication, division, remainder +.TP +.B + \- +addition, subtraction +.TP +.B << >> +left and right bitwise shifts +.TP +.B <= >= < > +comparison +.TP +.B == != +equality and inequality +.TP +.B & +bitwise AND +.TP +.B ^ +bitwise exclusive OR +.TP +.B | +bitwise OR +.TP +.B && +logical AND +.TP +.B || +logical OR +.TP +.B \fIexpr\fP?\fIexpr\fP:\fIexpr\fP +conditional operator +.TP +.B = *= /= %= += \-= <<= >>= &= ^= |= +assignment +.TP +.B \fIexpr1\fP , \fIexpr2\fP +comma +.PD +.PP +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 +\fIinteger\fP attribute using \fBdeclare -i\fP is assigned a value. +A null value evaluates to 0. +A shell variable need not have its \fIinteger\fP attribute +turned on to be used in an expression. +.PP +Constants with a leading 0 are interpreted as octal numbers. +A leading 0x or 0X denotes hexadecimal. +Otherwise, numbers take the form [\fIbase#\fP]n, where the optional \fIbase\fP +is a decimal number between 2 and 64 representing the arithmetic +base, and \fIn\fP is a number in that base. +If \fIbase#\fP is omitted, then base 10 is used. +When specifying \fIn\fP, +the digits greater than 9 are represented by the lowercase letters, +the uppercase letters, @, and _, in that order. +If \fIbase\fP is less than or equal to 36, lowercase and uppercase +letters may be used interchangeably to represent numbers between 10 +and 35. +.PP +Operators are evaluated in order of precedence. Sub-expressions in +parentheses are evaluated first and may override the precedence +rules above. +.SH "CONDITIONAL EXPRESSIONS" +Conditional expressions are used by the \fB[[\fP compound command and +the \fBtest\fP and \fB[\fP builtin commands to test file attributes +and perform string and arithmetic comparisons. +Expressions are formed from the following unary or binary primaries. +\fBBash\fP handles several filenames specially when they are used in +expressions. +If the operating system on which \fBbash\fP is running provides these +special files, bash will use them; otherwise it will emulate them +internally with this behavior: +If any \fIfile\fP argument to one of the primaries is of the form +\fI/dev/fd/n\fP, then file descriptor \fIn\fP is checked. +If the \fIfile\fP argument to one of the primaries is one of +\fI/dev/stdin\fP, \fI/dev/stdout\fP, or \fI/dev/stderr\fP, file +descriptor 0, 1, or 2, respectively, is checked. +.PP +Unless otherwise specified, primaries that operate on files follow symbolic +links and operate on the target of the link, rather than the link itself. +.if t .sp 0.5 +.if n .sp 1 +When used with \fB[[\fP, the \fB<\fP and \fB>\fP operators sort +lexicographically using the current locale. +The \fBtest\fP command sorts using ASCII ordering. +.sp 1 +.PD 0 +.TP +.B \-a \fIfile\fP +True if \fIfile\fP exists. +.TP +.B \-b \fIfile\fP +True if \fIfile\fP exists and is a block special file. +.TP +.B \-c \fIfile\fP +True if \fIfile\fP exists and is a character special file. +.TP +.B \-d \fIfile\fP +True if \fIfile\fP exists and is a directory. +.TP +.B \-e \fIfile\fP +True if \fIfile\fP exists. +.TP +.B \-f \fIfile\fP +True if \fIfile\fP exists and is a regular file. +.TP +.B \-g \fIfile\fP +True if \fIfile\fP exists and is set-group-id. +.TP +.B \-h \fIfile\fP +True if \fIfile\fP exists and is a symbolic link. +.TP +.B \-k \fIfile\fP +True if \fIfile\fP exists and its ``sticky'' bit is set. +.TP +.B \-p \fIfile\fP +True if \fIfile\fP exists and is a named pipe (FIFO). +.TP +.B \-r \fIfile\fP +True if \fIfile\fP exists and is readable. +.TP +.B \-s \fIfile\fP +True if \fIfile\fP exists and has a size greater than zero. +.TP +.B \-t \fIfd\fP +True if file descriptor +.I fd +is open and refers to a terminal. +.TP +.B \-u \fIfile\fP +True if \fIfile\fP exists and its set-user-id bit is set. +.TP +.B \-w \fIfile\fP +True if \fIfile\fP exists and is writable. +.TP +.B \-x \fIfile\fP +True if \fIfile\fP exists and is executable. +.TP +.B \-G \fIfile\fP +True if \fIfile\fP exists and is owned by the effective group id. +.TP +.B \-L \fIfile\fP +True if \fIfile\fP exists and is a symbolic link. +.TP +.B \-N \fIfile\fP +True if \fIfile\fP exists and has been modified since it was last read. +.TP +.B \-O \fIfile\fP +True if \fIfile\fP exists and is owned by the effective user id. +.TP +.B \-S \fIfile\fP +True if \fIfile\fP exists and is a socket. +.TP +\fIfile1\fP \fB\-ef\fP \fIfile2\fP +True if \fIfile1\fP and \fIfile2\fP refer to the same device and +inode numbers. +.TP +\fIfile1\fP \-\fBnt\fP \fIfile2\fP +True if \fIfile1\fP is newer (according to modification date) than \fIfile2\fP, +or if \fIfile1\fP exists and \fPfile2\fP does not. +.TP +\fIfile1\fP \-\fBot\fP \fIfile2\fP +True if \fIfile1\fP is older than \fIfile2\fP, or if \fIfile2\fP exists +and \fIfile1\fP does not. +.TP +.B \-o \fIoptname\fP +True if the shell option +.I optname +is enabled. +See the list of options under the description of the +.B \-o +option to the +.B set +builtin below. +.TP +.B \-v \fIvarname\fP +True if the shell variable +.I varname +is set (has been assigned a value). +.TP +.B \-R \fIvarname\fP +True if the shell variable +.I varname +is set and is a name reference. +.TP +.B \-z \fIstring\fP +True if the length of \fIstring\fP is zero. +.TP +\fIstring\fP +.PD 0 +.TP +.B \-n \fIstring\fP +.PD +True if the length of +.I string +is non-zero. +.TP +\fIstring1\fP \fB==\fP \fIstring2\fP +.PD 0 +.TP +\fIstring1\fP \fB=\fP \fIstring2\fP +.PD +True if the strings are equal. \fB=\fP should be used +with the \fBtest\fP command for POSIX conformance. +When used with the \fB[[\fP command, this performs pattern matching as +described above (\fBCompound Commands\fP). +.TP +\fIstring1\fP \fB!=\fP \fIstring2\fP +True if the strings are not equal. +.TP +\fIstring1\fP \fB<\fP \fIstring2\fP +True if \fIstring1\fP sorts before \fIstring2\fP lexicographically. +.TP +\fIstring1\fP \fB>\fP \fIstring2\fP +True if \fIstring1\fP sorts after \fIstring2\fP lexicographically. +.TP +.I \fIarg1\fP \fBOP\fP \fIarg2\fP +.SM +.B OP +is one of +.BR \-eq , +.BR \-ne , +.BR \-lt , +.BR \-le , +.BR \-gt , +or +.BR \-ge . +These arithmetic binary operators return true if \fIarg1\fP +is equal to, not equal to, less than, less than or equal to, +greater than, or greater than or equal to \fIarg2\fP, respectively. +.I Arg1 +and +.I arg2 +may be positive or negative integers. +.PD +.SH "SIMPLE COMMAND EXPANSION" +When a simple command is executed, the shell performs the following +expansions, assignments, and redirections, from left to right. +.IP 1. +The words that the parser has marked as variable assignments (those +preceding the command name) and redirections are saved for later +processing. +.IP 2. +The words that are not variable assignments or redirections are +expanded. 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. +.IP 3. +Redirections are performed as described above under +.SM +.BR REDIRECTION . +.IP 4. +The text after the \fB=\fP in each variable assignment undergoes tilde +expansion, parameter expansion, command substitution, arithmetic expansion, +and quote removal before being assigned to the variable. +.PP +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. +.PP +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. +.PP +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. +.SH "COMMAND EXECUTION" +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. +.PP +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 above in +.SM +.BR FUNCTIONS . +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. +.PP +If the name is neither a shell function nor a builtin, +and contains no slashes, +.B bash +searches each element of the +.SM +.B PATH +for a directory containing an executable file by that name. +.B Bash +uses a hash table to remember the full pathnames of executable +files (see +.B hash +under +.SM +.B "SHELL BUILTIN COMMANDS" +below). +A full search of the directories in +.SM +.B PATH +is performed only if the command is not found in the hash table. +If the search is unsuccessful, the shell searches for a defined shell +function named \fBcommand_not_found_handle\fP. +If that function exists, it is invoked with the original command and +the original command's arguments as its arguments, and the function's +exit status becomes the exit status of the shell. +If that function is not defined, the shell prints an error +message and returns an exit status of 127. +.PP +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 given, if any. +.PP +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 \fIshell script\fP, a file +containing shell commands. A subshell is spawned to execute +it. This subshell reinitializes itself, so +that the effect is as if a new shell had been invoked +to handle the script, with the exception that the locations of +commands remembered by the parent (see +.B hash +below under +.SM +\fBSHELL BUILTIN COMMANDS\fP) +are retained by the child. +.PP +If the program is a file beginning with +.BR #! , +the remainder of the first line specifies an interpreter +for the program. The shell executes the +specified interpreter on operating systems that do not +handle this executable format themselves. The arguments to the +interpreter consist of a single optional argument following the +interpreter name on the first line of the program, followed +by the name of the program, followed by the command +arguments, if any. +.SH COMMAND EXECUTION ENVIRONMENT +The shell has an \fIexecution environment\fP, which consists of the +following: +.IP \(bu +open files inherited by the shell at invocation, as modified by +redirections supplied to the \fBexec\fP builtin +.IP \(bu +the current working directory as set by \fBcd\fP, \fBpushd\fP, or +\fBpopd\fP, or inherited by the shell at invocation +.IP \(bu +the file creation mode mask as set by \fBumask\fP or inherited from +the shell's parent +.IP \(bu +current traps set by \fBtrap\fP +.IP \(bu +shell parameters that are set by variable assignment or with \fBset\fP +or inherited from the shell's parent in the environment +.IP \(bu +shell functions defined during execution or inherited from the shell's +parent in the environment +.IP \(bu +options enabled at invocation (either by default or with command-line +arguments) or by \fBset\fP +.IP \(bu +options enabled by \fBshopt\fP +.IP \(bu +shell aliases defined with \fBalias\fP +.IP \(bu +various process IDs, including those of background jobs, the value +of \fB$$\fP, and the value of +.SM +.B PPID +.PP +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. +.if n .sp 1 +.IP \(bu +the shell's open files, plus any modifications and additions specified +by redirections to the command +.IP \(bu +the current working directory +.IP \(bu +the file creation mode mask +.IP \(bu +shell variables and functions marked for export, along with variables +exported for the command, passed in the environment +.IP \(bu +traps caught by the shell are reset to the values inherited from the +shell's parent, and traps ignored by the shell are ignored +.PP +A command invoked in this separate environment cannot affect the +shell's execution environment. +.PP +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. +.PP +Subshells spawned to execute command substitutions inherit the value of +the \fB\-e\fP option from the parent shell. When not in \fIposix\fP mode, +\fBbash\fP clears the \fB\-e\fP option in such subshells. +.PP +If a command is followed by a \fB&\fP and job control is not active, the +default standard input for the command is the empty file \fI/dev/null\fP. +Otherwise, the invoked command inherits the file descriptors of the calling +shell as modified by redirections. +.SH ENVIRONMENT +When a program is invoked it is given an array of strings +called the +.IR environment . +This is a list of +\fIname\fP\-\fIvalue\fP pairs, of the form +.IR "name\fR=\fPvalue" . +.PP +The shell 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 +.I export +to child processes. Executed commands inherit the environment. +The +.B export +and +.B 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 +.B unset +command, plus any additions via the +.B export +and +.B declare \-x +commands. +.PP +The environment for any +.I simple command +or function may be augmented temporarily by prefixing it with +parameter assignments, as described above in +.SM +.BR PARAMETERS . +These assignment statements affect only the environment seen +by that command. +.PP +If the +.B \-k +option is set (see the +.B set +builtin command below), then +.I all +parameter assignments are placed in the environment for a command, +not just those that precede the command name. +.PP +When +.B bash +invokes an external command, the variable +.B _ +is set to the full filename of the command and passed to that +command in its environment. +.SH "EXIT STATUS" +.PP +The exit status of an executed command is the value returned by the +\fIwaitpid\fP system call or equivalent function. Exit statuses +fall between 0 and 255, though, as explained below, the shell may +use values above 125 specially. Exit statuses from shell builtins and +compound commands are also limited to this range. Under certain +circumstances, the shell will use special values to indicate specific +failure modes. +.PP +For the shell's purposes, a command which exits with a +zero exit status has succeeded. An exit status of zero +indicates success. A non-zero exit status indicates failure. +When a command terminates on a fatal signal \fIN\fP, \fBbash\fP uses +the value of 128+\fIN\fP as the exit status. +.PP +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. +.PP +If a command fails because of an error during expansion or redirection, +the exit status is greater than zero. +.PP +Shell builtin commands return a status of 0 (\fItrue\fP) if +successful, and non-zero (\fIfalse\fP) if an error occurs +while they execute. +All builtins return an exit status of 2 to indicate incorrect usage, +generally invalid options or missing arguments. +.PP +\fBBash\fP itself returns the exit status of the last command +executed, unless a syntax error occurs, in which case it exits +with a non-zero value. See also the \fBexit\fP builtin +command below. +.SH SIGNALS +When \fBbash\fP is interactive, in the absence of any traps, it ignores +.SM +.B SIGTERM +(so that \fBkill 0\fP does not kill an interactive shell), +and +.SM +.B SIGINT +is caught and handled (so that the \fBwait\fP builtin is interruptible). +In all cases, \fBbash\fP ignores +.SM +.BR SIGQUIT . +If job control is in effect, +.B bash +ignores +.SM +.BR SIGTTIN , +.SM +.BR SIGTTOU , +and +.SM +.BR SIGTSTP . +.PP +Non-builtin commands run by \fBbash\fP have signal handlers +set to the values inherited by the shell from its parent. +When job control is not in effect, asynchronous commands +ignore +.SM +.B SIGINT +and +.SM +.B SIGQUIT +in addition to these inherited handlers. +Commands run as a result of command substitution ignore the +keyboard-generated job control signals +.SM +.BR SIGTTIN , +.SM +.BR SIGTTOU , +and +.SM +.BR SIGTSTP . +.PP +The shell exits by default upon receipt of a +.SM +.BR SIGHUP . +Before exiting, an interactive shell resends the +.SM +.B SIGHUP +to all jobs, running or stopped. +Stopped jobs are sent +.SM +.B SIGCONT +to ensure that they receive the +.SM +.BR SIGHUP . +To prevent the shell from +sending the signal to a particular job, it should be removed from the +jobs table with the +.B disown +builtin (see +.SM +.B "SHELL BUILTIN COMMANDS" +below) or marked +to not receive +.SM +.B SIGHUP +using +.BR "disown \-h" . +.PP +If the +.B huponexit +shell option has been set with +.BR shopt , +.B bash +sends a +.SM +.B SIGHUP +to all jobs when an interactive login shell exits. +.PP +If \fBbash\fP 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 \fBbash\fP is waiting for an asynchronous command via the \fBwait\fP +builtin, the reception of a signal for which a trap has been set will +cause the \fBwait\fP builtin to return immediately with an exit status +greater than 128, immediately after which the trap is executed. +.SH "JOB CONTROL" +.I Job control +refers to the ability to selectively stop (\fIsuspend\fP) +the execution of processes and continue (\fIresume\fP) +their execution at a later point. A user typically employs +this facility via an interactive interface supplied jointly +by the operating system kernel's terminal driver and +.BR bash . +.PP +The shell associates a +.I job +with each pipeline. It keeps a table of currently executing +jobs, which may be listed with the +.B jobs +command. When +.B bash +starts a job asynchronously (in the +.IR background ), +it prints a line that looks like: +.RS +.PP +[1] 25647 +.RE +.PP +indicating that this job is job number 1 and that the process 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. +.B Bash +uses the +.I job +abstraction as the basis for job control. +.PP +To facilitate the implementation of the user interface to job +control, the operating system maintains the notion of a \fIcurrent terminal +process group ID\fP. Members of this process group (processes whose +process group ID is equal to the current terminal process group ID) +receive keyboard-generated signals such as +.SM +.BR SIGINT . +These processes are said to be in the +.IR foreground . +.I Background +processes are those whose process group ID differs from the terminal's; +such processes are immune to keyboard-generated signals. +Only foreground processes are allowed to read from or, if the +user so specifies with \f(CWstty tostop\fP, write to the +terminal. +Background processes which attempt to read from (write to when +\f(CWstty tostop\fP is in effect) the +terminal are sent a +.SM +.B SIGTTIN (SIGTTOU) +signal by the kernel's terminal driver, +which, unless caught, suspends the process. +.PP +If the operating system on which +.B bash +is running supports +job control, +.B bash +contains facilities to use it. +Typing the +.I suspend +character (typically +.BR ^Z , +Control-Z) while a process is running +causes that process to be stopped and returns control to +.BR bash . +Typing the +.I "delayed suspend" +character (typically +.BR ^Y , +Control-Y) causes the process to be stopped when it +attempts to read input from the terminal, and control to +be returned to +.BR bash . +The user may then manipulate the state of this job, using the +.B bg +command to continue it in the background, the +.B fg +command to continue it in the foreground, or +the +.B kill +command to kill it. A \fB^Z\fP takes effect immediately, +and has the additional side effect of causing pending output +and typeahead to be discarded. +.PP +There are a number of ways to refer to a job in the shell. +The character +.B % +introduces a job specification (\fIjobspec\fP). Job number +.I n +may be referred to as +.BR %n . +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, +.B %ce +refers to a stopped +.B ce +job. If a prefix matches more than one job, +.B bash +reports an error. Using +.BR %?ce , +on the other hand, refers to any job containing the string +.B ce +in its command line. If the substring matches more than one job, +.B bash +reports an error. The symbols +.B %% +and +.B %+ +refer to the shell's notion of the +.IR "current job" , +which is the last job stopped while it was in +the foreground or started in the background. +The +.I "previous job" +may be referenced using +.BR %\- . +If there is only a single job, \fB%+\fP and \fB%\-\fP can both be used +to refer to that job. +In output pertaining to jobs (e.g., the output of the +.B jobs +command), the current job is always flagged with a +.BR + , +and the previous job with a +.BR \- . +A single % (with no accompanying job specification) also refers to the +current job. +.PP +Simply naming a job can be used to bring it into the +foreground: +.B %1 +is a synonym for +\fB``fg %1''\fP, +bringing job 1 from the background into the foreground. +Similarly, +.B ``%1 &'' +resumes job 1 in the background, equivalent to +\fB``bg %1''\fP. +.PP +The shell learns immediately whenever a job changes state. +Normally, +.B 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 +.B \-b +option to the +.B set +builtin command +is enabled, +.B bash +reports such changes immediately. +Any trap on +.SM +.B SIGCHLD +is executed for each child that exits. +.PP +If an attempt to exit +.B bash +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. +If a second attempt to exit is made without an intervening command, +the shell does not print another warning, and any stopped +jobs are terminated. +.SH PROMPTING +When executing interactively, +.B bash +displays the primary prompt +.SM +.B PS1 +when it is ready to read a command, and the secondary prompt +.SM +.B PS2 +when it needs more input to complete a command. +.B Bash +displays +.B PS0 +after it reads a command but before executing it. +.B Bash +allows these prompt strings to be customized by inserting a number of +backslash-escaped special characters that are decoded as follows: +.RS +.PD 0 +.TP +.B \ea +an ASCII bell character (07) +.TP +.B \ed +the date in "Weekday Month Date" format (e.g., "Tue May 26") +.TP +.B \eD{\fIformat\fP} +the \fIformat\fP is passed to \fIstrftime\fP(3) and the result is inserted +into the prompt string; an empty \fIformat\fP results in a locale-specific +time representation. The braces are required +.TP +.B \ee +an ASCII escape character (033) +.TP +.B \eh +the hostname up to the first `.' +.TP +.B \eH +the hostname +.TP +.B \ej +the number of jobs currently managed by the shell +.TP +.B \el +the basename of the shell's terminal device name +.TP +.B \en +newline +.TP +.B \er +carriage return +.TP +.B \es +the name of the shell, the basename of +.B $0 +(the portion following the final slash) +.TP +.B \et +the current time in 24-hour HH:MM:SS format +.TP +.B \eT +the current time in 12-hour HH:MM:SS format +.TP +.B \e@ +the current time in 12-hour am/pm format +.TP +.B \eA +the current time in 24-hour HH:MM format +.TP +.B \eu +the username of the current user +.TP +.B \ev +the version of \fBbash\fP (e.g., 2.00) +.TP +.B \eV +the release of \fBbash\fP, version + patch level (e.g., 2.00.0) +.TP +.B \ew +the current working directory, with +.SM +.B $HOME +abbreviated with a tilde +(uses the value of the +.SM +.B PROMPT_DIRTRIM +variable) +.TP +.B \eW +the basename of the current working directory, with +.SM +.B $HOME +abbreviated with a tilde +.TP +.B \e! +the history number of this command +.TP +.B \e# +the command number of this command +.TP +.B \e$ +if the effective UID is 0, a +.BR # , +otherwise a +.B $ +.TP +.B \e\fInnn\fP +the character corresponding to the octal number \fInnn\fP +.TP +.B \e\e +a backslash +.TP +.B \e[ +begin a sequence of non-printing characters, which could be used to +embed a terminal control sequence into the prompt +.TP +.B \e] +end a sequence of non-printing characters +.PD +.RE +.PP +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 +(see +.SM +.B HISTORY +below), 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 +.B promptvars +shell option (see the description of the +.B shopt +command under +.SM +.B "SHELL BUILTIN COMMANDS" +below). +.SH READLINE +This is the library that handles reading input when using an interactive +shell, unless the +.B \-\-noediting +option is given at shell invocation. +Line editing is also used when using the \fB\-e\fP option to the +\fBread\fP builtin. +By default, the line editing commands are similar to those of Emacs. +A vi-style line editing interface is also available. +Line editing can be enabled at any time using the +.B \-o emacs +or +.B \-o vi +options to the +.B set +builtin (see +.SM +.B SHELL BUILTIN COMMANDS +below). +To turn off line editing after the shell is running, use the +.B +o emacs +or +.B +o vi +options to the +.B set +builtin. +.SS "Readline Notation" +.PP +In this section, the Emacs-style notation is used to denote +keystrokes. Control keys are denoted by C\-\fIkey\fR, e.g., C\-n +means Control\-N. Similarly, +.I meta +keys are denoted by M\-\fIkey\fR, so M\-x means Meta\-X. (On keyboards +without a +.I meta +key, M\-\fIx\fP means ESC \fIx\fP, i.e., press the Escape key +then the +.I x +key. This makes ESC the \fImeta prefix\fP. +The combination M\-C\-\fIx\fP means ESC\-Control\-\fIx\fP, +or press the Escape key +then hold the Control key while pressing the +.I x +key.) +.PP +Readline commands may be given numeric +.IR arguments , +which normally act as a repeat count. +Sometimes, however, it is the sign of the argument that is significant. +Passing a negative argument to a command that acts in the forward +direction (e.g., \fBkill\-line\fP) causes that command to act in a +backward direction. +Commands whose behavior with arguments deviates from this are noted +below. +.PP +When a command is described as \fIkilling\fP text, the text +deleted is saved for possible future retrieval +(\fIyanking\fP). The killed text is saved in a +\fIkill ring\fP. Consecutive kills cause the text to be +accumulated into one unit, which can be yanked all at once. +Commands which do not kill text separate the chunks of text +on the kill ring. +.SS "Readline Initialization" +.PP +Readline is customized by putting commands in an initialization +file (the \fIinputrc\fP file). +The name of this file is taken from the value of the +.SM +.B INPUTRC +variable. If that variable is unset, the default is +.IR ~/.inputrc . +When a program which uses the readline library starts up, the +initialization file is read, and the key bindings and variables +are set. +There are only a few basic constructs allowed in the +readline initialization file. +Blank lines are ignored. +Lines beginning with a \fB#\fP are comments. +Lines beginning with a \fB$\fP indicate conditional constructs. +Other lines denote key bindings and variable settings. +.PP +The default key-bindings may be changed with an +.I inputrc +file. +Other programs that use this library may add their own commands +and bindings. +.PP +For example, placing +.RS +.PP +M\-Control\-u: universal\-argument +.RE +or +.RS +C\-Meta\-u: universal\-argument +.RE +into the +.I inputrc +would make M\-C\-u execute the readline command +.IR universal\-argument . +.PP +The following symbolic character names are recognized: +.IR RUBOUT , +.IR DEL , +.IR ESC , +.IR LFD , +.IR NEWLINE , +.IR RET , +.IR RETURN , +.IR SPC , +.IR SPACE , +and +.IR TAB . +.PP +In addition to command names, readline allows keys to be bound +to a string that is inserted when the key is pressed (a \fImacro\fP). +.SS "Readline Key Bindings" +.PP +The syntax for controlling key bindings in the +.I inputrc +file is simple. All that is required is the name of the +command or the text of a macro and a key sequence to which +it should be bound. The name may be specified in one of two ways: +as a symbolic key name, possibly with \fIMeta\-\fP or \fIControl\-\fP +prefixes, or as a key sequence. +.PP +When using the form \fBkeyname\fP:\^\fIfunction\-name\fP or \fImacro\fP, +.I keyname +is the name of a key spelled out in English. For example: +.sp +.RS +Control-u: universal\-argument +.br +Meta-Rubout: backward-kill-word +.br +Control-o: "> output" +.RE +.LP +In the above example, +.I C\-u +is bound to the function +.BR universal\-argument , +.I M\-DEL +is bound to the function +.BR backward\-kill\-word , +and +.I C\-o +is bound to run the macro +expressed on the right hand side (that is, to insert the text +.if t \f(CW> output\fP +.if n ``> output'' +into the line). +.PP +In the second form, \fB"keyseq"\fP:\^\fIfunction\-name\fP or \fImacro\fP, +.B keyseq +differs from +.B keyname +above in that strings denoting +an entire key sequence may be specified by placing the sequence +within double quotes. Some GNU Emacs style key escapes can be +used, as in the following example, but the symbolic character names +are not recognized. +.sp +.RS +"\eC\-u": universal\-argument +.br +"\eC\-x\eC\-r": re\-read\-init\-file +.br +"\ee[11~": "Function Key 1" +.RE +.PP +In this example, +.I C\-u +is again bound to the function +.BR universal\-argument . +.I "C\-x C\-r" +is bound to the function +.BR re\-read\-init\-file , +and +.I "ESC [ 1 1 ~" +is bound to insert the text +.if t \f(CWFunction Key 1\fP. +.if n ``Function Key 1''. +.PP +The full set of GNU Emacs style escape sequences is +.RS +.PD 0 +.TP +.B \eC\- +control prefix +.TP +.B \eM\- +meta prefix +.TP +.B \ee +an escape character +.TP +.B \e\e +backslash +.TP +.B \e" +literal " +.TP +.B \e\(aq +literal \(aq +.RE +.PD +.PP +In addition to the GNU Emacs style escape sequences, a second +set of backslash escapes is available: +.RS +.PD 0 +.TP +.B \ea +alert (bell) +.TP +.B \eb +backspace +.TP +.B \ed +delete +.TP +.B \ef +form feed +.TP +.B \en +newline +.TP +.B \er +carriage return +.TP +.B \et +horizontal tab +.TP +.B \ev +vertical tab +.TP +.B \e\fInnn\fP +the eight-bit character whose value is the octal value \fInnn\fP +(one to three digits) +.TP +.B \ex\fIHH\fP +the eight-bit character whose value is the hexadecimal value \fIHH\fP +(one or two hex digits) +.RE +.PD +.PP +When entering the text of a macro, single or double quotes must +be used to indicate a macro definition. +Unquoted text is assumed to be a function name. +In the macro body, the backslash escapes described above are expanded. +Backslash will quote any other character in the macro text, +including " and \(aq. +.PP +.B Bash +allows the current readline key bindings to be displayed or modified +with the +.B bind +builtin command. The editing mode may be switched during interactive +use by using the +.B \-o +option to the +.B set +builtin command (see +.SM +.B SHELL BUILTIN COMMANDS +below). +.SS "Readline Variables" +.PP +Readline has variables that can be used to further customize its +behavior. A variable may be set in the +.I inputrc +file with a statement of the form +.RS +.PP +\fBset\fP \fIvariable\-name\fP \fIvalue\fP +.RE +.PP +Except where noted, readline variables can take the values +.B On +or +.B Off +(without regard to case). +Unrecognized variable names are ignored. +When a variable value is read, empty or null values, "on" (case-insensitive), +and "1" are equivalent to \fBOn\fP. All other values are equivalent to +\fBOff\fP. +The variables and their default values are: +.PP +.PD 0 +.TP +.B bell\-style (audible) +Controls what happens when readline wants to ring the terminal bell. +If set to \fBnone\fP, readline never rings the bell. If set to +\fBvisible\fP, readline uses a visible bell if one is available. +If set to \fBaudible\fP, readline attempts to ring the terminal's bell. +.TP +.B bind\-tty\-special\-chars (On) +If set to \fBOn\fP, readline attempts to bind the control characters +treated specially by the kernel's terminal driver to their readline +equivalents. +.TP +.B blink\-matching\-paren (Off) +If set to \fBOn\fP, readline attempts to briefly move the cursor to an +opening parenthesis when a closing parenthesis is inserted. +.TP +.B colored\-completion\-prefix (Off) +If set to \fBOn\fP, when listing completions, readline displays the +common prefix of the set of possible completions using a different color. +The color definitions are taken from the value of the \fBLS_COLORS\fP +environment variable. +.TP +.B colored\-stats (Off) +If set to \fBOn\fP, readline displays possible completions using different +colors to indicate their file type. +The color definitions are taken from the value of the \fBLS_COLORS\fP +environment variable. +.TP +.B comment\-begin (``#'') +The string that is inserted when the readline +.B insert\-comment +command is executed. +This command is bound to +.B M\-# +in emacs mode and to +.B # +in vi command mode. +.TP +.B completion\-display\-width (-1) +The number of screen columns used to display possible matches +when performing completion. +The value is ignored if it is less than 0 or greater than the terminal +screen width. +A value of 0 will cause matches to be displayed one per line. +The default value is -1. +.TP +.B completion\-ignore\-case (Off) +If set to \fBOn\fP, readline performs filename matching and completion +in a case\-insensitive fashion. +.TP +.B completion\-map\-case (Off) +If set to \fBOn\fP, and \fBcompletion\-ignore\-case\fP is enabled, readline +treats hyphens (\fI\-\fP) and underscores (\fI_\fP) as equivalent when +performing case\-insensitive filename matching and completion. +.TP +.B completion\-prefix\-display\-length (0) +The length in characters of the common prefix of a list of possible +completions that is displayed without modification. When set to a +value greater than zero, common prefixes longer than this value are +replaced with an ellipsis when displaying possible completions. +.TP +.B completion\-query\-items (100) +This determines when the user is queried about viewing +the number of possible completions +generated by the \fBpossible\-completions\fP command. +It may be set to any integer value greater than or equal to +zero. If the number of possible completions is greater than +or equal to the value of this variable, the user is asked whether +or not he wishes to view them; otherwise they are simply listed +on the terminal. +.TP +.B convert\-meta (On) +If set to \fBOn\fP, readline will convert characters with the +eighth bit set to an ASCII key sequence +by stripping the eighth bit and prefixing an +escape character (in effect, using escape as the \fImeta prefix\fP). +The default is \fIOn\fP, but readline will set it to \fIOff\fP if the +locale contains eight-bit characters. +.TP +.B disable\-completion (Off) +If set to \fBOn\fP, readline will inhibit word completion. Completion +characters will be inserted into the line as if they had been +mapped to \fBself-insert\fP. +.TP +.B echo\-control\-characters (On) +When set to \fBOn\fP, on operating systems that indicate they support it, +readline echoes a character corresponding to a signal generated from the +keyboard. +.TP +.B editing\-mode (emacs) +Controls whether readline begins with a set of key bindings similar +to \fIEmacs\fP or \fIvi\fP. +.B editing\-mode +can be set to either +.B emacs +or +.BR vi . +.TP +.B enable\-bracketed\-paste (Off) +When set to \fBOn\fP, readline will configure the terminal in a way +that will enable it to insert each paste into the editing buffer as a +single string of characters, instead of treating each character as if +it had been read from the keyboard. This can prevent pasted characters +from being interpreted as editing commands. +.TP +.B enable\-keypad (Off) +When set to \fBOn\fP, readline will try to enable the application +keypad when it is called. Some systems need this to enable the +arrow keys. +.TP +.B enable\-meta\-key (On) +When set to \fBOn\fP, readline will try to enable any meta modifier +key the terminal claims to support when it is called. On many terminals, +the meta key is used to send eight-bit characters. +.TP +.B expand\-tilde (Off) +If set to \fBOn\fP, tilde expansion is performed when readline +attempts word completion. +.TP +.B history\-preserve\-point (Off) +If set to \fBOn\fP, the history code attempts to place point at the +same location on each history line retrieved with \fBprevious-history\fP +or \fBnext-history\fP. +.TP +.B history\-size (unset) +Set the maximum number of history entries saved in the history list. +If set to zero, any existing history entries are deleted and no new entries +are saved. +If set to a value less than zero, the number of history entries is not +limited. +By default, the number of history entries is set to the value of the +\fBHISTSIZE\fP shell variable. +If an attempt is made to set \fIhistory\-size\fP to a non-numeric value, +the maximum number of history entries will be set to 500. +.TP +.B horizontal\-scroll\-mode (Off) +When set to \fBOn\fP, makes readline use a single line for display, +scrolling the input horizontally on a single screen line when it +becomes longer than the screen width rather than wrapping to a new line. +.TP +.B input\-meta (Off) +If set to \fBOn\fP, readline will enable eight-bit input (that is, +it will not strip the eighth bit from the characters it reads), +regardless of what the terminal claims it can support. The name +.B meta\-flag +is a synonym for this variable. +The default is \fIOff\fP, but readline will set it to \fIOn\fP if the +locale contains eight-bit characters. +.TP +.B isearch\-terminators (``C\-[C\-J'') +The string of characters that should terminate an incremental +search without subsequently executing the character as a command. +If this variable has not been given a value, the characters +\fIESC\fP and \fIC\-J\fP will terminate an incremental search. +.TP +.B keymap (emacs) +Set the current readline keymap. The set of valid keymap names is +\fIemacs, emacs\-standard, emacs\-meta, emacs\-ctlx, vi, +vi\-command\fP, and +.IR vi\-insert . +\fIvi\fP is equivalent to \fIvi\-command\fP; \fIemacs\fP is +equivalent to \fIemacs\-standard\fP. The default value is +.IR emacs ; +the value of +.B editing\-mode +also affects the default keymap. +.TP +.B emacs\-mode\-string (@) +This string is displayed immediately before the last line of the primary +prompt when emacs editing mode is active. The value is expanded like a +key binding, so the standard set of meta- and control prefixes and +backslash escape sequences is available. +Use the \e1 and \e2 escapes to begin and end sequences of +non-printing characters, which can be used to embed a terminal control +sequence into the mode string. +.TP +.B keyseq\-timeout (500) +Specifies the duration \fIreadline\fP will wait for a character when reading an +ambiguous key sequence (one that can form a complete key sequence using +the input read so far, or can take additional input to complete a longer +key sequence). +If no input is received within the timeout, \fIreadline\fP will use the shorter +but complete key sequence. +The value is specified in milliseconds, so a value of 1000 means that +\fIreadline\fP will wait one second for additional input. +If this variable is set to a value less than or equal to zero, or to a +non-numeric value, \fIreadline\fP will wait until another key is pressed to +decide which key sequence to complete. +.TP +.B mark\-directories (On) +If set to \fBOn\fP, completed directory names have a slash +appended. +.TP +.B mark\-modified\-lines (Off) +If set to \fBOn\fP, history lines that have been modified are displayed +with a preceding asterisk (\fB*\fP). +.TP +.B mark\-symlinked\-directories (Off) +If set to \fBOn\fP, completed names which are symbolic links to directories +have a slash appended (subject to the value of +\fBmark\-directories\fP). +.TP +.B match\-hidden\-files (On) +This variable, when set to \fBOn\fP, causes readline to match files whose +names begin with a `.' (hidden files) when performing filename +completion. +If set to \fBOff\fP, the leading `.' must be +supplied by the user in the filename to be completed. +.TP +.B menu\-complete\-display\-prefix (Off) +If set to \fBOn\fP, menu completion displays the common prefix of the +list of possible completions (which may be empty) before cycling through +the list. +.TP +.B output\-meta (Off) +If set to \fBOn\fP, readline will display characters with the +eighth bit set directly rather than as a meta-prefixed escape +sequence. +The default is \fIOff\fP, but readline will set it to \fIOn\fP if the +locale contains eight-bit characters. +.TP +.B page\-completions (On) +If set to \fBOn\fP, readline uses an internal \fImore\fP-like pager +to display a screenful of possible completions at a time. +.TP +.B print\-completions\-horizontally (Off) +If set to \fBOn\fP, readline will display completions with matches +sorted horizontally in alphabetical order, rather than down the screen. +.TP +.B revert\-all\-at\-newline (Off) +If set to \fBOn\fP, readline will undo all changes to history lines +before returning when \fBaccept\-line\fP is executed. By default, +history lines may be modified and retain individual undo lists across +calls to \fBreadline\fP. +.TP +.B show\-all\-if\-ambiguous (Off) +This alters the default behavior of the completion functions. If +set to +.BR On , +words which have more than one possible completion cause the +matches to be listed immediately instead of ringing the bell. +.TP +.B show\-all\-if\-unmodified (Off) +This alters the default behavior of the completion functions in +a fashion similar to \fBshow\-all\-if\-ambiguous\fP. +If set to +.BR On , +words which have more than one possible completion without any +possible partial completion (the possible completions don't share +a common prefix) cause the matches to be listed immediately instead +of ringing the bell. +.TP +.B show\-mode\-in\-prompt (Off) +If set to \fBOn\fP, add a character to the beginning of the prompt +indicating the editing mode: emacs (@), vi command (:) or vi +insertion (+). +.TP +.B skip\-completed\-text (Off) +If set to \fBOn\fP, this alters the default completion behavior when +inserting a single match into the line. It's only active when +performing completion in the middle of a word. If enabled, readline +does not insert characters from the completion that match characters +after point in the word being completed, so portions of the word +following the cursor are not duplicated. +.TP +.B vi\-cmd\-mode\-string ((cmd)) +This string is displayed immediately before the last line of the primary +prompt when vi editing mode is active and in command mode. +The value is expanded like a +key binding, so the standard set of meta- and control prefixes and +backslash escape sequences is available. +Use the \e1 and \e2 escapes to begin and end sequences of +non-printing characters, which can be used to embed a terminal control +sequence into the mode string. +.TP +.B vi\-ins\-mode\-string ((ins)) +This string is displayed immediately before the last line of the primary +prompt when vi editing mode is active and in insertion mode. +The value is expanded like a +key binding, so the standard set of meta- and control prefixes and +backslash escape sequences is available. +Use the \e1 and \e2 escapes to begin and end sequences of +non-printing characters, which can be used to embed a terminal control +sequence into the mode string. +.TP +.B visible\-stats (Off) +If set to \fBOn\fP, a character denoting a file's type as reported +by \fIstat\fP(2) is appended to the filename when listing possible +completions. +.PD +.SS "Readline Conditional Constructs" +.PP +Readline implements a facility similar in spirit to the conditional +compilation features of the C preprocessor which allows key +bindings and variable settings to be performed as the result +of tests. There are four parser directives used. +.IP \fB$if\fP +The +.B $if +construct allows bindings to be made based on the +editing mode, the terminal being used, or the application using +readline. The text of the test extends to the end of the line; +no characters are required to isolate it. +.RS +.IP \fBmode\fP +The \fBmode=\fP form of the \fB$if\fP directive is used to test +whether readline is in emacs or vi mode. +This may be used in conjunction +with the \fBset keymap\fP command, for instance, to set bindings in +the \fIemacs\-standard\fP and \fIemacs\-ctlx\fP keymaps only if +readline is starting out in emacs mode. +.IP \fBterm\fP +The \fBterm=\fP form may be used to include terminal-specific +key bindings, perhaps to bind the key sequences output by the +terminal's function keys. The word on the right side of the +.B = +is tested against both the full name of the terminal and the portion +of the terminal name before the first \fB\-\fP. This allows +.I sun +to match both +.I sun +and +.IR sun\-cmd , +for instance. +.IP \fBapplication\fP +The \fBapplication\fP construct is used to include +application-specific settings. Each program using the readline +library sets the \fIapplication name\fP, and an initialization +file can test for a particular value. +This could be used to bind key sequences to functions useful for +a specific program. For instance, the following command adds a +key sequence that quotes the current or previous word in \fBbash\fP: +.sp 1 +.RS +.nf +\fB$if\fP Bash +# Quote the current or previous word +"\eC\-xq": "\eeb\e"\eef\e"" +\fB$endif\fP +.fi +.RE +.RE +.IP \fB$endif\fP +This command, as seen in the previous example, terminates an +\fB$if\fP command. +.IP \fB$else\fP +Commands in this branch of the \fB$if\fP directive are executed if +the test fails. +.IP \fB$include\fP +This directive takes a single filename as an argument and reads commands +and bindings from that file. For example, the following directive +would read \fI/etc/inputrc\fP: +.sp 1 +.RS +.nf +\fB$include\fP \^ \fI/etc/inputrc\fP +.fi +.RE +.SS Searching +.PP +Readline provides commands for searching through the command history +(see +.SM +.B HISTORY +below) for lines containing a specified string. +There are two search modes: +.I incremental +and +.IR non-incremental . +.PP +Incremental searches begin before the user has finished typing the +search string. +As each character of the search string is typed, readline displays +the next entry from the history matching the string typed so far. +An incremental search requires only as many characters as needed to +find the desired history entry. +The characters present in the value of the \fBisearch-terminators\fP +variable are used to terminate an incremental search. +If that variable has not been assigned a value the Escape and +Control-J characters will terminate an incremental search. +Control-G will abort an incremental search and restore the original +line. +When the search is terminated, the history entry containing the +search string becomes the current line. +.PP +To find other matching entries in the history list, type Control-S or +Control-R as appropriate. +This will search backward or forward in the history for the next +entry matching the search string typed so far. +Any other key sequence bound to a readline command will terminate +the search and execute that command. +For instance, a \fInewline\fP will terminate the search and accept +the line, thereby executing the command from the history list. +.PP +Readline remembers the last incremental search string. If two +Control-Rs are typed without any intervening characters defining a +new search string, any remembered search string is used. +.PP +Non-incremental searches read the entire search string before starting +to search for matching history lines. The search string may be +typed by the user or be part of the contents of the current line. +.SS "Readline Command Names" +.PP +The following is a list of the names of the commands and the default +key sequences to which they are bound. +Command names without an accompanying key sequence are unbound by default. +In the following descriptions, \fIpoint\fP refers to the current cursor +position, and \fImark\fP refers to a cursor position saved by the +\fBset\-mark\fP command. +The text between the point and mark is referred to as the \fIregion\fP. +.SS Commands for Moving +.PP +.PD 0 +.TP +.B beginning\-of\-line (C\-a) +Move to the start of the current line. +.TP +.B end\-of\-line (C\-e) +Move to the end of the line. +.TP +.B forward\-char (C\-f) +Move forward a character. +.TP +.B backward\-char (C\-b) +Move back a character. +.TP +.B forward\-word (M\-f) +Move forward to the end of the next word. Words are composed of +alphanumeric characters (letters and digits). +.TP +.B backward\-word (M\-b) +Move back to the start of the current or previous word. +Words are composed of alphanumeric characters (letters and digits). +.TP +.B shell\-forward\-word +Move forward to the end of the next word. +Words are delimited by non-quoted shell metacharacters. +.TP +.B shell\-backward\-word +Move back to the start of the current or previous word. +Words are delimited by non-quoted shell metacharacters. +.TP +.B clear\-screen (C\-l) +Clear the screen leaving the current line at the top of the screen. +With an argument, refresh the current line without clearing the +screen. +.TP +.B redraw\-current\-line +Refresh the current line. +.PD +.SS Commands for Manipulating the History +.PP +.PD 0 +.TP +.B accept\-line (Newline, Return) +Accept the line regardless of where the cursor is. If this line is +non-empty, add it to the history list according to the state of the +.SM +.B HISTCONTROL +variable. If the line is a modified history +line, then restore the history line to its original state. +.TP +.B previous\-history (C\-p) +Fetch the previous command from the history list, moving back in +the list. +.TP +.B next\-history (C\-n) +Fetch the next command from the history list, moving forward in the +list. +.TP +.B beginning\-of\-history (M\-<) +Move to the first line in the history. +.TP +.B end\-of\-history (M\->) +Move to the end of the input history, i.e., the line currently being +entered. +.TP +.B reverse\-search\-history (C\-r) +Search backward starting at the current line and moving `up' through +the history as necessary. This is an incremental search. +.TP +.B forward\-search\-history (C\-s) +Search forward starting at the current line and moving `down' through +the history as necessary. This is an incremental search. +.TP +.B non\-incremental\-reverse\-search\-history (M\-p) +Search backward through the history starting at the current line +using a non-incremental search for a string supplied by the user. +.TP +.B non\-incremental\-forward\-search\-history (M\-n) +Search forward through the history using a non-incremental search for +a string supplied by the user. +.TP +.B history\-search\-forward +Search forward through the history for the string of characters +between the start of the current line and the point. +This is a non-incremental search. +.TP +.B history\-search\-backward +Search backward through the history for the string of characters +between the start of the current line and the point. +This is a non-incremental search. +.TP +.B yank\-nth\-arg (M\-C\-y) +Insert the first argument to the previous command (usually +the second word on the previous line) at point. +With an argument +.IR n , +insert the \fIn\fPth word from the previous command (the words +in the previous command begin with word 0). A negative argument +inserts the \fIn\fPth word from the end of the previous command. +Once the argument \fIn\fP is computed, the argument is extracted +as if the "!\fIn\fP" history expansion had been specified. +.TP +.B +yank\-last\-arg (M\-.\^, M\-_\^) +Insert the last argument to the previous command (the last word of +the previous history entry). +With a numeric argument, behave exactly like \fByank\-nth\-arg\fP. +Successive calls to \fByank\-last\-arg\fP move back through the history +list, inserting the last word (or the word specified by the argument to +the first call) of each line in turn. +Any numeric argument supplied to these successive calls determines +the direction to move through the history. A negative argument switches +the direction through the history (back or forward). +The history expansion facilities are used to extract the last word, +as if the "!$" history expansion had been specified. +.TP +.B shell\-expand\-line (M\-C\-e) +Expand the line as the shell does. This +performs alias and history expansion as well as all of the shell +word expansions. See +.SM +.B HISTORY EXPANSION +below for a description of history expansion. +.TP +.B history\-expand\-line (M\-^) +Perform history expansion on the current line. +See +.SM +.B HISTORY EXPANSION +below for a description of history expansion. +.TP +.B magic\-space +Perform history expansion on the current line and insert a space. +See +.SM +.B HISTORY EXPANSION +below for a description of history expansion. +.TP +.B alias\-expand\-line +Perform alias expansion on the current line. +See +.SM +.B ALIASES +above for a description of alias expansion. +.TP +.B history\-and\-alias\-expand\-line +Perform history and alias expansion on the current line. +.TP +.B insert\-last\-argument (M\-.\^, M\-_\^) +A synonym for \fByank\-last\-arg\fP. +.TP +.B operate\-and\-get\-next (C\-o) +Accept the current line for execution and fetch the next line +relative to the current line from the history for editing. Any +argument is ignored. +.TP +.B edit\-and\-execute\-command (C\-xC\-e) +Invoke an editor on the current command line, and execute the result as shell +commands. +\fBBash\fP attempts to invoke +.SM +.BR $VISUAL , +.SM +.BR $EDITOR , +and \fIemacs\fP as the editor, in that order. +.PD +.SS Commands for Changing Text +.PP +.PD 0 +.TP +.B \fIend\-of\-file\fP (usually C\-d) +The character indicating end-of-file as set, for example, by +.if t \f(CWstty\fP. +.if n ``stty''. +If this character is read when there are no characters +on the line, and point is at the beginning of the line, Readline +interprets it as the end of input and returns +.SM +.BR EOF . +.TP +.B delete\-char (C\-d) +Delete the character at point. +If this function is bound to the +same character as the tty \fBEOF\fP character, as \fBC\-d\fP +commonly is, see above for the effects. +.TP +.B backward\-delete\-char (Rubout) +Delete the character behind the cursor. When given a numeric argument, +save the deleted text on the kill ring. +.TP +.B forward\-backward\-delete\-char +Delete the character under the cursor, unless the cursor is at the +end of the line, in which case the character behind the cursor is +deleted. +.TP +.B quoted\-insert (C\-q, C\-v) +Add the next character typed to the line verbatim. This is +how to insert characters like \fBC\-q\fP, for example. +.TP +.B tab\-insert (C\-v TAB) +Insert a tab character. +.TP +.B self\-insert (a,\ b,\ A,\ 1,\ !,\ ...) +Insert the character typed. +.TP +.B transpose\-chars (C\-t) +Drag the character before point forward over the character at point, +moving point forward as well. +If point is at the end of the line, then this transposes +the two characters before point. +Negative arguments have no effect. +.TP +.B transpose\-words (M\-t) +Drag the word before point past the word after point, +moving point over that word as well. +If point is at the end of the line, this transposes +the last two words on the line. +.TP +.B upcase\-word (M\-u) +Uppercase the current (or following) word. With a negative argument, +uppercase the previous word, but do not move point. +.TP +.B downcase\-word (M\-l) +Lowercase the current (or following) word. With a negative argument, +lowercase the previous word, but do not move point. +.TP +.B capitalize\-word (M\-c) +Capitalize the current (or following) word. With a negative argument, +capitalize the previous word, but do not move point. +.TP +.B overwrite\-mode +Toggle overwrite mode. With an explicit positive numeric argument, +switches to overwrite mode. With an explicit non-positive numeric +argument, switches to insert mode. This command affects only +\fBemacs\fP mode; \fBvi\fP mode does overwrite differently. +Each call to \fIreadline()\fP starts in insert mode. +In overwrite mode, characters bound to \fBself\-insert\fP replace +the text at point rather than pushing the text to the right. +Characters bound to \fBbackward\-delete\-char\fP replace the character +before point with a space. By default, this command is unbound. +.PD +.SS Killing and Yanking +.PP +.PD 0 +.TP +.B kill\-line (C\-k) +Kill the text from point to the end of the line. +.TP +.B backward\-kill\-line (C\-x Rubout) +Kill backward to the beginning of the line. +.TP +.B unix\-line\-discard (C\-u) +Kill backward from point to the beginning of the line. +The killed text is saved on the kill-ring. +.\" There is no real difference between this and backward-kill-line +.TP +.B kill\-whole\-line +Kill all characters on the current line, no matter where point is. +.TP +.B kill\-word (M\-d) +Kill from point to the end of the current word, or if between +words, to the end of the next word. +Word boundaries are the same as those used by \fBforward\-word\fP. +.TP +.B backward\-kill\-word (M\-Rubout) +Kill the word behind point. +Word boundaries are the same as those used by \fBbackward\-word\fP. +.TP +.B shell\-kill\-word +Kill from point to the end of the current word, or if between +words, to the end of the next word. +Word boundaries are the same as those used by \fBshell\-forward\-word\fP. +.TP +.B shell\-backward\-kill\-word +Kill the word behind point. +Word boundaries are the same as those used by \fBshell\-backward\-word\fP. +.TP +.B unix\-word\-rubout (C\-w) +Kill the word behind point, using white space as a word boundary. +The killed text is saved on the kill-ring. +.TP +.B unix\-filename\-rubout +Kill the word behind point, using white space and the slash character +as the word boundaries. +The killed text is saved on the kill-ring. +.TP +.B delete\-horizontal\-space (M\-\e) +Delete all spaces and tabs around point. +.TP +.B kill\-region +Kill the text in the current region. +.TP +.B copy\-region\-as\-kill +Copy the text in the region to the kill buffer. +.TP +.B copy\-backward\-word +Copy the word before point to the kill buffer. +The word boundaries are the same as \fBbackward\-word\fP. +.TP +.B copy\-forward\-word +Copy the word following point to the kill buffer. +The word boundaries are the same as \fBforward\-word\fP. +.TP +.B yank (C\-y) +Yank the top of the kill ring into the buffer at point. +.TP +.B yank\-pop (M\-y) +Rotate the kill ring, and yank the new top. Only works following +.B yank +or +.BR yank\-pop . +.PD +.SS Numeric Arguments +.PP +.PD 0 +.TP +.B digit\-argument (M\-0, M\-1, ..., M\-\-) +Add this digit to the argument already accumulating, or start a new +argument. M\-\- starts a negative argument. +.TP +.B universal\-argument +This is another way to specify an argument. +If this command is followed by one or more digits, optionally with a +leading minus sign, those digits define the argument. +If the command is followed by digits, executing +.B universal\-argument +again ends the numeric argument, but is otherwise ignored. +As a special case, if this command is immediately followed by a +character that is neither a digit nor minus sign, the argument count +for the next command is multiplied by four. +The argument count is initially one, so executing this function the +first time makes the argument count four, a second time makes the +argument count sixteen, and so on. +.PD +.SS Completing +.PP +.PD 0 +.TP +.B complete (TAB) +Attempt to perform completion on the text before point. +.B Bash +attempts completion treating the text as a variable (if the +text begins with \fB$\fP), username (if the text begins with +\fB~\fP), hostname (if the text begins with \fB@\fP), or +command (including aliases and functions) in turn. If none +of these produces a match, filename completion is attempted. +.TP +.B possible\-completions (M\-?) +List the possible completions of the text before point. +.TP +.B insert\-completions (M\-*) +Insert all completions of the text before point +that would have been generated by +\fBpossible\-completions\fP. +.TP +.B menu\-complete +Similar to \fBcomplete\fP, but replaces the word to be completed +with a single match from the list of possible completions. +Repeated execution of \fBmenu\-complete\fP steps through the list +of possible completions, inserting each match in turn. +At the end of the list of completions, the bell is rung +(subject to the setting of \fBbell\-style\fP) +and the original text is restored. +An argument of \fIn\fP moves \fIn\fP positions forward in the list +of matches; a negative argument may be used to move backward +through the list. +This command is intended to be bound to \fBTAB\fP, but is unbound +by default. +.TP +.B menu\-complete\-backward +Identical to \fBmenu\-complete\fP, but moves backward through the list +of possible completions, as if \fBmenu\-complete\fP had been given a +negative argument. This command is unbound by default. +.TP +.B delete\-char\-or\-list +Deletes the character under the cursor if not at the beginning or +end of the line (like \fBdelete\-char\fP). +If at the end of the line, behaves identically to +\fBpossible\-completions\fP. +This command is unbound by default. +.TP +.B complete\-filename (M\-/) +Attempt filename completion on the text before point. +.TP +.B possible\-filename\-completions (C\-x /) +List the possible completions of the text before point, +treating it as a filename. +.TP +.B complete\-username (M\-~) +Attempt completion on the text before point, treating +it as a username. +.TP +.B possible\-username\-completions (C\-x ~) +List the possible completions of the text before point, +treating it as a username. +.TP +.B complete\-variable (M\-$) +Attempt completion on the text before point, treating +it as a shell variable. +.TP +.B possible\-variable\-completions (C\-x $) +List the possible completions of the text before point, +treating it as a shell variable. +.TP +.B complete\-hostname (M\-@) +Attempt completion on the text before point, treating +it as a hostname. +.TP +.B possible\-hostname\-completions (C\-x @) +List the possible completions of the text before point, +treating it as a hostname. +.TP +.B complete\-command (M\-!) +Attempt completion on the text before point, treating +it as a command name. Command completion attempts to +match the text against aliases, reserved words, shell +functions, shell builtins, and finally executable filenames, +in that order. +.TP +.B possible\-command\-completions (C\-x !) +List the possible completions of the text before point, +treating it as a command name. +.TP +.B dynamic\-complete\-history (M\-TAB) +Attempt completion on the text before point, comparing +the text against lines from the history list for possible +completion matches. +.TP +.B dabbrev\-expand +Attempt menu completion on the text before point, comparing +the text against lines from the history list for possible +completion matches. +.TP +.B complete\-into\-braces (M\-{) +Perform filename completion and insert the list of possible completions +enclosed within braces so the list is available to the shell (see +.B Brace Expansion +above). +.PD +.SS Keyboard Macros +.PP +.PD 0 +.TP +.B start\-kbd\-macro (C\-x (\^) +Begin saving the characters typed into the current keyboard macro. +.TP +.B end\-kbd\-macro (C\-x )\^) +Stop saving the characters typed into the current keyboard macro +and store the definition. +.TP +.B call\-last\-kbd\-macro (C\-x e) +Re-execute the last keyboard macro defined, by making the characters +in the macro appear as if typed at the keyboard. +.TP +.B print\-last\-kbd\-macro () +Print the last keyboard macro defined in a format suitable for the +\fIinputrc\fP file. +.PD +.SS Miscellaneous +.PP +.PD 0 +.TP +.B re\-read\-init\-file (C\-x C\-r) +Read in the contents of the \fIinputrc\fP file, and incorporate +any bindings or variable assignments found there. +.TP +.B abort (C\-g) +Abort the current editing command and +ring the terminal's bell (subject to the setting of +.BR bell\-style ). +.TP +.B do\-uppercase\-version (M\-a, M\-b, M\-\fIx\fP, ...) +If the metafied character \fIx\fP is lowercase, run the command +that is bound to the corresponding uppercase character. +.TP +.B prefix\-meta (ESC) +Metafy the next character typed. +.SM +.B ESC +.B f +is equivalent to +.BR Meta\-f . +.TP +.B undo (C\-_, C\-x C\-u) +Incremental undo, separately remembered for each line. +.TP +.B revert\-line (M\-r) +Undo all changes made to this line. This is like executing the +.B undo +command enough times to return the line to its initial state. +.TP +.B tilde\-expand (M\-&) +Perform tilde expansion on the current word. +.TP +.B set\-mark (C\-@, M\-) +Set the mark to the point. If a +numeric argument is supplied, the mark is set to that position. +.TP +.B exchange\-point\-and\-mark (C\-x C\-x) +Swap the point with the mark. The current cursor position is set to +the saved position, and the old cursor position is saved as the mark. +.TP +.B character\-search (C\-]) +A character is read and point is moved to the next occurrence of that +character. A negative count searches for previous occurrences. +.TP +.B character\-search\-backward (M\-C\-]) +A character is read and point is moved to the previous occurrence of that +character. A negative count searches for subsequent occurrences. +.TP +.B skip\-csi\-sequence +Read enough characters to consume a multi-key sequence such as those +defined for keys like Home and End. Such sequences begin with a +Control Sequence Indicator (CSI), usually ESC\-[. If this sequence is +bound to "\e[", keys producing such sequences will have no effect +unless explicitly bound to a readline command, instead of inserting +stray characters into the editing buffer. This is unbound by default, +but usually bound to ESC\-[. +.TP +.B insert\-comment (M\-#) +Without a numeric argument, the value of the readline +.B comment\-begin +variable is inserted at the beginning of the current line. +If a numeric argument is supplied, this command acts as a toggle: if +the characters at the beginning of the line do not match the value +of \fBcomment\-begin\fP, the value is inserted, otherwise +the characters in \fBcomment\-begin\fP are deleted from the beginning of +the line. +In either case, the line is accepted as if a newline had been typed. +The default value of +\fBcomment\-begin\fP causes this command to make the current line +a shell comment. +If a numeric argument causes the comment character to be removed, the line +will be executed by the shell. +.TP +.B glob\-complete\-word (M\-g) +The word before point is treated as a pattern for pathname expansion, +with an asterisk implicitly appended. This pattern is used to +generate a list of matching filenames for possible completions. +.TP +.B glob\-expand\-word (C\-x *) +The word before point is treated as a pattern for pathname expansion, +and the list of matching filenames is inserted, replacing the word. +If a numeric argument is supplied, an asterisk is appended before +pathname expansion. +.TP +.B glob\-list\-expansions (C\-x g) +The list of expansions that would have been generated by +.B glob\-expand\-word +is displayed, and the line is redrawn. +If a numeric argument is supplied, an asterisk is appended before +pathname expansion. +.TP +.B dump\-functions +Print all of the functions and their key bindings to the +readline output stream. If a numeric argument is supplied, +the output is formatted in such a way that it can be made part +of an \fIinputrc\fP file. +.TP +.B dump\-variables +Print all of the settable readline variables and their values to the +readline output stream. If a numeric argument is supplied, +the output is formatted in such a way that it can be made part +of an \fIinputrc\fP file. +.TP +.B dump\-macros +Print all of the readline key sequences bound to macros and the +strings they output. If a numeric argument is supplied, +the output is formatted in such a way that it can be made part +of an \fIinputrc\fP file. +.TP +.B display\-shell\-version (C\-x C\-v) +Display version information about the current instance of +.BR bash . +.PD +.SS Programmable Completion +.PP +When word completion is attempted for an argument to a command for +which a completion specification (a \fIcompspec\fP) has been defined +using the \fBcomplete\fP builtin (see +.SM +.B "SHELL BUILTIN COMMANDS" +below), the programmable completion facilities are invoked. +.PP +First, the command name is identified. +If the command word is the empty string (completion attempted at the +beginning of an empty line), any compspec defined with +the \fB\-E\fP option to \fBcomplete\fP is used. +If a compspec has been defined for that command, the +compspec is used to generate the list of possible completions for the word. +If the command word is a full pathname, a compspec for the full +pathname is searched for first. +If no compspec is found for the full pathname, an attempt is made to +find a compspec for the portion following the final slash. +If those searches do not result in a compspec, any compspec defined with +the \fB\-D\fP option to \fBcomplete\fP is used as the default. +.PP +Once a compspec has been found, it is used to generate the list of +matching words. +If a compspec is not found, the default \fBbash\fP completion as +described above under \fBCompleting\fP is performed. +.PP +First, the actions specified by the compspec are used. +Only matches which are prefixed by the word being completed are +returned. +When the +.B \-f +or +.B \-d +option is used for filename or directory name completion, the shell +variable +.SM +.B FIGNORE +is used to filter the matches. +.PP +Any completions specified by a pathname expansion pattern to the +\fB\-G\fP option are generated next. +The words generated by the pattern need not match the word +being completed. +The +.SM +.B GLOBIGNORE +shell variable is not used to filter the matches, but the +.SM +.B FIGNORE +variable is used. +.PP +Next, the string specified as the argument to the \fB\-W\fP option +is considered. +The string is first split using the characters in the +.SM +.B IFS +special variable as delimiters. +Shell quoting is honored. +Each word is then expanded using +brace expansion, tilde expansion, parameter and variable expansion, +command substitution, and arithmetic expansion, +as described above under +.SM +.BR EXPANSION . +The results are split using the rules described above under +\fBWord Splitting\fP. +The results of the expansion are prefix-matched against the word being +completed, and the matching words become the possible completions. +.PP +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 +.BR COMP_LINE , +.SM +.BR COMP_POINT , +.SM +.BR COMP_KEY , +and +.SM +.B COMP_TYPE +variables are assigned values as described above under +\fBShell Variables\fP. +If a shell function is being invoked, the +.SM +.B COMP_WORDS +and +.SM +.B COMP_CWORD +variables are also set. +When the function or command is invoked, +the first argument (\fB$1\fP) is the name of the command whose arguments are +being completed, +the second argument (\fB$2\fP) is the word being completed, +and the third argument (\fB$3\fP) is the word preceding the word being +completed on the current command line. +No filtering of the generated completions against the word being completed +is performed; the function or command has complete freedom in generating +the matches. +.PP +Any function specified with \fB\-F\fP is invoked first. +The function may use any of the shell facilities, including the +\fBcompgen\fP builtin described below, to generate the matches. +It must put the possible completions in the +.SM +.B COMPREPLY +array variable, one per array element. +.PP +Next, any command specified with the \fB\-C\fP option is invoked +in an environment equivalent to command substitution. +It should print a list of completions, one per line, to the +standard output. +Backslash may be used to escape a newline, if necessary. +.PP +After all of the possible completions are generated, any filter +specified with the \fB\-X\fP option is applied to the list. +The filter is a pattern as used for pathname expansion; a \fB&\fP +in the pattern is replaced with the text of the word being completed. +A literal \fB&\fP may be escaped with a backslash; the backslash +is removed before attempting a match. +Any completion that matches the pattern will be removed from the list. +A leading \fB!\fP negates the pattern; in this case any completion +not matching the pattern will be removed. +If the +.B nocasematch +shell option is enabled, the match is performed without regard to the case +of alphabetic characters. +.PP +Finally, any prefix and suffix specified with the \fB\-P\fP and \fB\-S\fP +options are added to each member of the completion list, and the result is +returned to the readline completion code as the list of possible +completions. +.PP +If the previously-applied actions do not generate any matches, and the +\fB\-o dirnames\fP option was supplied to \fBcomplete\fP when the +compspec was defined, directory name completion is attempted. +.PP +If the \fB\-o plusdirs\fP option was supplied to \fBcomplete\fP when the +compspec was defined, directory name completion is attempted and any +matches are added to the results of the other actions. +.PP +By default, if a compspec is found, whatever it generates is returned +to the completion code as the full set of possible completions. +The default \fBbash\fP completions are not attempted, and the readline +default of filename completion is disabled. +If the \fB\-o bashdefault\fP option was supplied to \fBcomplete\fP when +the compspec was defined, the \fBbash\fP default completions are attempted +if the compspec generates no matches. +If the \fB\-o default\fP option was supplied to \fBcomplete\fP when the +compspec was defined, readline's default completion will be performed +if the compspec (and, if attempted, the default \fBbash\fP completions) +generate no matches. +.PP +When a compspec indicates that directory name completion is desired, +the programmable completion functions force readline to append a slash +to completed names which are symbolic links to directories, subject to +the value of the \fBmark\-directories\fP readline variable, regardless +of the setting of the \fBmark-symlinked\-directories\fP readline variable. +.PP +There is some support for dynamically modifying completions. This is +most useful when used in combination with a default completion specified +with \fBcomplete -D\fP. +It's possible for shell functions executed as completion +handlers to indicate that completion should be retried by returning an +exit status of 124. If a shell function returns 124, and changes +the compspec associated with the command on which completion is being +attempted (supplied as the first argument when the function is executed), +programmable completion restarts from the beginning, with an +attempt to find a new compspec for that command. This allows a set of +completions to be built dynamically as completion is attempted, rather than +being loaded all at once. +.PP +For instance, assuming that there is a library of compspecs, each kept in a +file corresponding to the name of the command, the following default +completion function would load completions dynamically: +.PP +\f(CW_completion_loader() +.br +{ +.br + . "/etc/bash_completion.d/$1.sh" >/dev/null 2>&1 && return 124 +.br +} +.br +complete -D -F _completion_loader -o bashdefault -o default +.br +\fP +.SH HISTORY +When the +.B \-o history +option to the +.B set +builtin is enabled, the shell provides access to the +\fIcommand history\fP, +the list of commands previously typed. +The value of the +.SM +.B HISTSIZE +variable is used as the +number of commands to save in a history list. +The text of the last +.SM +.B HISTSIZE +commands (default 500) is saved. The shell +stores each command in the history list prior to parameter and +variable expansion (see +.SM +.B EXPANSION +above) but after history expansion is performed, subject to the +values of the shell variables +.SM +.B HISTIGNORE +and +.SM +.BR HISTCONTROL . +.PP +On startup, the history is initialized from the file named by +the variable +.SM +.B HISTFILE +(default \fI~/.bash_history\fP). +The file named by the value of +.SM +.B HISTFILE +is truncated, if necessary, to contain no more than +the number of lines specified by the value of +.SM +.BR HISTFILESIZE . +If \fBHISTFILESIZE\fP is unset, or set to null, a non-numeric value, +or a numeric value less than zero, the history file is not truncated. +When the history file is read, +lines beginning with the history comment character followed immediately +by a digit are interpreted as timestamps for the preceding history line. +These timestamps are optionally displayed depending on the value of the +.SM +.B HISTTIMEFORMAT +variable. +When a shell with history enabled exits, the last +.SM +.B $HISTSIZE +lines are copied from the history list to +.SM +.BR $HISTFILE . +If the +.B histappend +shell option is enabled +(see the description of +.B shopt +under +.SM +.B "SHELL BUILTIN COMMANDS" +below), the lines are appended to the history file, +otherwise the history file is overwritten. +If +.SM +.B HISTFILE +is unset, or if the history file is unwritable, the history is +not saved. +If the +.SM +.B HISTTIMEFORMAT +variable is set, time stamps are written to the history file, marked +with the history comment character, so +they may be preserved across shell sessions. +This uses the history comment character to distinguish timestamps from +other history lines. +After saving the history, the history file is truncated +to contain no more than +.SM +.B HISTFILESIZE +lines. If +.SM +.B HISTFILESIZE +is unset, or set to null, a non-numeric value, +or a numeric value less than zero, the history file is not truncated. +.PP +The builtin command +.B fc +(see +.SM +.B SHELL BUILTIN COMMANDS +below) may be used to list or edit and re-execute a portion of +the history list. +The +.B history +builtin may be used to display or modify the history list and +manipulate the history file. +When using command-line editing, search commands +are available in each editing mode that provide access to the +history list. +.PP +The shell allows control over which commands are saved on the history +list. The +.SM +.B HISTCONTROL +and +.SM +.B HISTIGNORE +variables may be set to cause the shell to save only a subset of the +commands entered. +The +.B cmdhist +shell option, if enabled, causes the shell to attempt to save each +line of a multi-line command in the same history entry, adding +semicolons where necessary to preserve syntactic correctness. +The +.B lithist +shell option causes the shell to save the command with embedded newlines +instead of semicolons. See the description of the +.B shopt +builtin below under +.SM +.B "SHELL BUILTIN COMMANDS" +for information on setting and unsetting shell options. +.SH "HISTORY EXPANSION" +.PP +The shell supports a history expansion feature that +is similar to the history expansion in +.BR csh. +This section describes what syntax features are available. This +feature is enabled by default for interactive shells, and can be +disabled using the +.B +H +option to the +.B set +builtin command (see +.SM +.B SHELL BUILTIN COMMANDS +below). Non-interactive shells do not perform history expansion +by default. +.PP +History expansions introduce words from the history list into +the input stream, making it easy to repeat commands, insert the +arguments to a previous command into the current input line, or +fix errors in previous commands quickly. +.PP +History expansion is performed immediately after a complete line +is read, before the shell breaks it into words. +It takes place in two parts. +The first is to determine which line from the history list +to use during substitution. +The second is to select portions of that line for inclusion into +the current one. +The line selected from the history is the \fIevent\fP, +and the portions of that line that are acted upon are \fIwords\fP. +Various \fImodifiers\fP are available to manipulate the selected words. +The line is broken into words in the same fashion as when reading input, +so that several \fImetacharacter\fP-separated words surrounded by +quotes are considered one word. +History expansions are introduced by the appearance of the +history expansion character, which is \^\fB!\fP\^ by default. +Only backslash (\^\fB\e\fP\^) and single quotes can quote +the history expansion character, but the history expansion character is +also treated as quoted if it immediately precedes the closing double quote +in a double-quoted string. +.PP +Several characters inhibit history expansion if found immediately +following the history expansion character, even if it is unquoted: +space, tab, newline, carriage return, and \fB=\fP. +If the \fBextglob\fP shell option is enabled, \fB(\fP will also +inhibit expansion. +.PP +Several shell options settable with the +.B shopt +builtin may be used to tailor the behavior of history expansion. +If the +.B histverify +shell option is enabled (see the description of the +.B shopt +builtin below), and +.B readline +is being used, history substitutions are not immediately passed to +the shell parser. +Instead, the expanded line is reloaded into the +.B readline +editing buffer for further modification. +If +.B readline +is being used, and the +.B histreedit +shell option is enabled, a failed history substitution will be reloaded +into the +.B readline +editing buffer for correction. +The +.B \-p +option to the +.B history +builtin command may be used to see what a history expansion will +do before using it. +The +.B \-s +option to the +.B history +builtin may be used to add commands to the end of the history list +without actually executing them, so that they are available for +subsequent recall. +.PP +The shell allows control of the various characters used by the +history expansion mechanism (see the description of +.B histchars +above under +.BR "Shell Variables" ). +The shell uses +the history comment character to mark history timestamps when +writing the history file. +.SS Event Designators +.PP +An event designator is a reference to a command line entry in the +history list. +Unless the reference is absolute, events are relative to the current +position in the history list. +.PP +.PD 0 +.TP +.B ! +Start a history substitution, except when followed by a +.BR blank , +newline, carriage return, = +or ( (when the \fBextglob\fP shell option is enabled using +the \fBshopt\fP builtin). +.TP +.B !\fIn\fR +Refer to command line +.IR n . +.TP +.B !\-\fIn\fR +Refer to the current command minus +.IR n . +.TP +.B !! +Refer to the previous command. This is a synonym for `!\-1'. +.TP +.B !\fIstring\fR +Refer to the most recent command preceding the current position in the +history list starting with +.IR string . +.TP +.B !?\fIstring\fR\fB[?]\fR +Refer to the most recent command preceding the current position in the +history list containing +.IR string . +The trailing \fB?\fP may be omitted if +.I string +is followed immediately by a newline. +.TP +.B \d\s+2^\s-2\u\fIstring1\fP\d\s+2^\s-2\u\fIstring2\fP\d\s+2^\s-2\u +Quick substitution. Repeat the previous command, replacing +.I string1 +with +.IR string2 . +Equivalent to +``!!:s/\fIstring1\fP/\fIstring2\fP/'' +(see \fBModifiers\fP below). +.TP +.B !# +The entire command line typed so far. +.PD +.SS Word Designators +.PP +Word designators are used to select desired words from the event. +A +.B : +separates the event specification from the word designator. +It may be omitted if the word designator begins with a +.BR ^ , +.BR $ , +.BR * , +.BR \- , +or +.BR % . +Words are numbered from the beginning of the line, +with the first word being denoted by 0 (zero). +Words are inserted into the current line separated by single spaces. +.PP +.PD 0 +.TP +.B 0 (zero) +The zeroth word. For the shell, this is the command +word. +.TP +.I n +The \fIn\fRth word. +.TP +.B ^ +The first argument. That is, word 1. +.TP +.B $ +The last word. This is usually the last argument, but will expand to the +zeroth word if there is only one word in the line. +.TP +.B % +The word matched by the most recent `?\fIstring\fR?' search. +.TP +.I x\fB\-\fPy +A range of words; `\-\fIy\fR' abbreviates `0\-\fIy\fR'. +.TP +.B * +All of the words but the zeroth. This is a synonym +for `\fI1\-$\fP'. It is not an error to use +.B * +if there is just one +word in the event; the empty string is returned in that case. +.TP +.B x* +Abbreviates \fIx\-$\fP. +.TP +.B x\- +Abbreviates \fIx\-$\fP like \fBx*\fP, but omits the last word. +.PD +.PP +If a word designator is supplied without an event specification, the +previous command is used as the event. +.SS Modifiers +.PP +After the optional word designator, there may appear a sequence of +one or more of the following modifiers, each preceded by a `:'. +.PP +.PD 0 +.PP +.TP +.B h +Remove a trailing filename component, leaving only the head. +.TP +.B t +Remove all leading filename components, leaving the tail. +.TP +.B r +Remove a trailing suffix of the form \fI.xxx\fP, leaving the +basename. +.TP +.B e +Remove all but the trailing suffix. +.TP +.B p +Print the new command but do not execute it. +.TP +.B q +Quote the substituted words, escaping further substitutions. +.TP +.B x +Quote the substituted words as with +.BR q , +but break into words at +.B blanks +and newlines. +.TP +.B s/\fIold\fP/\fInew\fP/ +Substitute +.I new +for the first occurrence of +.I old +in the event line. Any delimiter can be used in place of /. The +final delimiter is optional if it is the last character of the +event line. The delimiter may be quoted in +.I old +and +.I new +with a single backslash. If & appears in +.IR new , +it is replaced by +.IR old . +A single backslash will quote the &. If +.I old +is null, it is set to the last +.I old +substituted, or, if no previous history substitutions took place, +the last +.I string +in a +.B !?\fIstring\fR\fB[?]\fR +search. +.TP +.B & +Repeat the previous substitution. +.TP +.B g +Cause changes to be applied over the entire event line. This is +used in conjunction with `\fB:s\fP' (e.g., `\fB:gs/\fIold\fP/\fInew\fP/\fR') +or `\fB:&\fP'. If used with +`\fB:s\fP', any delimiter can be used +in place of /, and the final delimiter is optional +if it is the last character of the event line. +An \fBa\fP may be used as a synonym for \fBg\fP. +.TP +.B G +Apply the following `\fBs\fP' modifier once to each word in the event line. +.PD +.SH "SHELL BUILTIN COMMANDS" +.\" start of bash_builtins +.zZ +.PP +Unless otherwise noted, each builtin command documented in this +section as accepting options preceded by +.B \- +accepts +.B \-\- +to signify the end of the options. +The \fB:\fP, \fBtrue\fP, \fBfalse\fP, and \fBtest\fP builtins +do not accept options and do not treat \fB\-\-\fP specially. +The \fBexit\fP, \fBlogout\fP, \fBreturn\fP, +\fBbreak\fP, \fBcontinue\fP, \fBlet\fP, +and \fBshift\fP builtins accept and process arguments beginning with +\fB\-\fP without requiring \fB\-\-\fP. +Other builtins that accept arguments but are not specified as accepting +options interpret arguments beginning with \fB\-\fP as invalid options and +require \fB\-\-\fP to prevent this interpretation. +.sp .5 +.PD 0 +.TP +\fB:\fP [\fIarguments\fP] +.PD +No effect; the command does nothing beyond expanding +.I arguments +and performing any specified +redirections. +The return status is zero. +.TP +\fB .\| \fP \fIfilename\fP [\fIarguments\fP] +.PD 0 +.TP +\fBsource\fP \fIfilename\fP [\fIarguments\fP] +.PD +Read and execute commands from +.I filename +in the current +shell environment and return the exit status of the last command +executed from +.IR filename . +If +.I filename +does not contain a slash, filenames in +.SM +.B PATH +are used to find the directory containing +.IR filename . +The file searched for in +.SM +.B PATH +need not be executable. +When \fBbash\fP is not in \fIposix mode\fP, the current directory is +searched if no file is found in +.SM +.BR PATH . +If the +.B sourcepath +option to the +.B shopt +builtin command is turned off, the +.SM +.B PATH +is not searched. +If any \fIarguments\fP are supplied, they become the positional +parameters when \fIfilename\fP is executed. Otherwise the positional +parameters are unchanged. +If the \fB\-T\fP option is enabled, \fBsource\fP inherits any trap on +\fBDEBUG\fP; if it is not, any \fBDEBUG\fP trap string is saved and +restored around the call to \fBsource\fP, and \fBsource\fP unsets the +\fBDEBUG\fP trap while it executes. +If \fB\-T\fP is not set, and the sourced file changes +the \fBDEBUG\fP trap, the new value is retained when \fBsource\fP completes. +The return status is the status of the last command exited within +the script (0 if no commands are executed), and false if +.I filename +is not found or cannot be read. +.TP +\fBalias\fP [\fB\-p\fP] [\fIname\fP[=\fIvalue\fP] ...] +\fBAlias\fP with no arguments or with the +.B \-p +option prints the list of aliases in the form +\fBalias\fP \fIname\fP=\fIvalue\fP on standard output. +When arguments are supplied, an alias is defined for +each \fIname\fP whose \fIvalue\fP is given. +A trailing space in \fIvalue\fP causes the next word to be +checked for alias substitution when the alias is expanded. +For each \fIname\fP in the argument list for which no \fIvalue\fP +is supplied, the name and value of the alias is printed. +\fBAlias\fP returns true unless a \fIname\fP is given for which +no alias has been defined. +.TP +\fBbg\fP [\fIjobspec\fP ...] +Resume each suspended job \fIjobspec\fP in the background, as if it +had been started with +.BR & . +If +.I jobspec +is not present, the shell's notion of the \fIcurrent job\fP is used. +.B bg +.I jobspec +returns 0 unless run when job control is disabled or, when run with +job control enabled, any specified \fIjobspec\fP was not found +or was started without job control. +.TP +\fBbind\fP [\fB\-m\fP \fIkeymap\fP] [\fB\-lpsvPSVX\fP] +.PD 0 +.TP +\fBbind\fP [\fB\-m\fP \fIkeymap\fP] [\fB\-q\fP \fIfunction\fP] [\fB\-u\fP \fIfunction\fP] [\fB\-r\fP \fIkeyseq\fP] +.TP +\fBbind\fP [\fB\-m\fP \fIkeymap\fP] \fB\-f\fP \fIfilename\fP +.TP +\fBbind\fP [\fB\-m\fP \fIkeymap\fP] \fB\-x\fP \fIkeyseq\fP:\fIshell\-command\fP +.TP +\fBbind\fP [\fB\-m\fP \fIkeymap\fP] \fIkeyseq\fP:\fIfunction\-name\fP +.TP +\fBbind\fP [\fB\-m\fP \fIkeymap\fP] \fIkeyseq\fP:\fIreadline\-command\fP +.PD +Display current +.B readline +key and function bindings, bind a key sequence to a +.B readline +function or macro, or set a +.B readline +variable. +Each non-option argument is a command as it would appear in +.IR .inputrc , +but each binding or command must be passed as a separate argument; +e.g., '"\eC\-x\eC\-r": re\-read\-init\-file'. +Options, if supplied, have the following meanings: +.RS +.PD 0 +.TP +.B \-m \fIkeymap\fP +Use +.I keymap +as the keymap to be affected by the subsequent bindings. +Acceptable +.I keymap +names are +\fIemacs, emacs\-standard, emacs\-meta, emacs\-ctlx, vi, +vi\-move, vi\-command\fP, and +.IR vi\-insert . +\fIvi\fP is equivalent to \fIvi\-command\fP (\fIvi\-move\fP is also +a synonym); \fIemacs\fP is +equivalent to \fIemacs\-standard\fP. +.TP +.B \-l +List the names of all \fBreadline\fP functions. +.TP +.B \-p +Display \fBreadline\fP function names and bindings in such a way +that they can be re-read. +.TP +.B \-P +List current \fBreadline\fP function names and bindings. +.TP +.B \-s +Display \fBreadline\fP key sequences bound to macros and the strings +they output in such a way that they can be re-read. +.TP +.B \-S +Display \fBreadline\fP key sequences bound to macros and the strings +they output. +.TP +.B \-v +Display \fBreadline\fP variable names and values in such a way that they +can be re-read. +.TP +.B \-V +List current \fBreadline\fP variable names and values. +.TP +.B \-f \fIfilename\fP +Read key bindings from \fIfilename\fP. +.TP +.B \-q \fIfunction\fP +Query about which keys invoke the named \fIfunction\fP. +.TP +.B \-u \fIfunction\fP +Unbind all keys bound to the named \fIfunction\fP. +.TP +.B \-r \fIkeyseq\fP +Remove any current binding for \fIkeyseq\fP. +.TP +.B \-x \fIkeyseq\fP:\fIshell\-command\fP +Cause \fIshell\-command\fP to be executed whenever \fIkeyseq\fP is +entered. +When \fIshell\-command\fP is executed, the shell sets the +.SM +.B READLINE_LINE +variable to the contents of the \fBreadline\fP line buffer and the +.SM +.B READLINE_POINT +variable to the current location of the insertion point. +If the executed command changes the value of +.SM +.B READLINE_LINE +or +.SM +.BR READLINE_POINT , +those new values will be reflected in the editing state. +.TP +.B \-X +List all key sequences bound to shell commands and the associated commands +in a format that can be reused as input. +.PD +.PP +The return value is 0 unless an unrecognized option is given or an +error occurred. +.RE +.TP +\fBbreak\fP [\fIn\fP] +Exit from within a +.BR for , +.BR while , +.BR until , +or +.B select +loop. If \fIn\fP is specified, break \fIn\fP levels. +.I n +must be \(>= 1. If +.I n +is greater than the number of enclosing loops, all enclosing loops +are exited. +The return value is 0 unless \fIn\fP is not greater than or equal to 1. +.TP +\fBbuiltin\fP \fIshell\-builtin\fP [\fIarguments\fP] +Execute the specified shell builtin, passing it +.IR arguments , +and return its exit status. +This is useful when defining a +function whose name is the same as a shell builtin, +retaining the functionality of the builtin within the function. +The \fBcd\fP builtin is commonly redefined this way. +The return status is false if +.I shell\-builtin +is not a shell builtin command. +.TP +\fBcaller\fP [\fIexpr\fP] +Returns the context of any active subroutine call (a shell function or +a script executed with the \fB.\fP or \fBsource\fP builtins). +Without \fIexpr\fP, \fBcaller\fP displays the line number and source +filename of the current subroutine call. +If a non-negative integer is supplied as \fIexpr\fP, \fBcaller\fP +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 \fIexpr\fP does not correspond to a valid position in the +call stack. +.TP +\fBcd\fP [\fB\-L\fP|[\fB\-P\fP [\fB\-e\fP]] [\-@]] [\fIdir\fP] +Change the current directory to \fIdir\fP. +if \fIdir\fP is not supplied, the value of the +.SM +.B HOME +shell variable is the default. +Any additional arguments following \fIdir\fP are ignored. +The variable +.SM +.B CDPATH +defines the search path for the directory containing +.IR dir : +each directory name in +.SM +.B CDPATH +is searched for \fIdir\fP. +Alternative directory names in +.SM +.B CDPATH +are separated by a colon (:). A null directory name in +.SM +.B CDPATH +is the same as the current directory, i.e., ``\fB.\fP''. If +.I dir +begins with a slash (/), +then +.SM +.B CDPATH +is not used. The +.B \-P +option causes \fBcd\fP to use the physical directory structure +by resolving symbolic links while traversing \fIdir\fP and +before processing instances of \fI..\fP in \fIdir\fP (see also the +.B \-P +option to the +.B set +builtin command); the +.B \-L +option forces symbolic links to be followed by resolving the link +after processing instances of \fI..\fP in \fIdir\fP. +If \fI..\fP appears in \fIdir\fP, it is processed by removing the +immediately previous pathname component from \fIdir\fP, back to a slash +or the beginning of \fIdir\fP. +If the +.B \-e +option is supplied with +.BR \-P , +and the current working directory cannot be successfully determined +after a successful directory change, \fBcd\fP will return an unsuccessful +status. +On systems that support it, the \fB\-@\fP option presents the extended +attributes associated with a file as a directory. +An argument of +.B \- +is converted to +.SM +.B $OLDPWD +before the directory change is attempted. +If a non-empty directory name from +.SM +.B CDPATH +is used, or if +\fB\-\fP 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 value is true if the directory was successfully changed; +false otherwise. +.TP +\fBcommand\fP [\fB\-pVv\fP] \fIcommand\fP [\fIarg\fP ...] +Run +.I command +with +.I args +suppressing the normal shell function lookup. +Only builtin commands or commands found in the +.SM +.B PATH +are executed. If the +.B \-p +option is given, the search for +.I command +is performed using a default value for +.SM +.B PATH +that is guaranteed to find all of the standard utilities. +If either the +.B \-V +or +.B \-v +option is supplied, a description of +.I command +is printed. The +.B \-v +option causes a single word indicating the command or filename +used to invoke +.I command +to be displayed; the +.B \-V +option produces a more verbose description. +If the +.B \-V +or +.B \-v +option is supplied, the exit status is 0 if +.I command +was found, and 1 if not. If neither option is supplied and +an error occurred or +.I command +cannot be found, the exit status is 127. Otherwise, the exit status of the +.B command +builtin is the exit status of +.IR command . +.TP +\fBcompgen\fP [\fIoption\fP] [\fIword\fP] +Generate possible completion matches for \fIword\fP according to +the \fIoption\fPs, which may be any option accepted by the +.B complete +builtin with the exception of \fB\-p\fP and \fB\-r\fP, and write +the matches to the standard output. +When using the \fB\-F\fP or \fB\-C\fP options, the various shell variables +set by the programmable completion facilities, while available, will not +have useful values. +.sp 1 +The matches will be generated in the same way as if the programmable +completion code had generated them directly from a completion specification +with the same flags. +If \fIword\fP is specified, only those completions matching \fIword\fP +will be displayed. +.sp 1 +The return value is true unless an invalid option is supplied, or no +matches were generated. +.TP +\fBcomplete\fP [\fB\-abcdefgjksuv\fP] [\fB\-o\fP \fIcomp-option\fP] [\fB\-DE\fP] [\fB\-A\fP \fIaction\fP] [\fB\-G\fP \fIglobpat\fP] [\fB\-W\fP \fIwordlist\fP] [\fB\-F\fP \fIfunction\fP] [\fB\-C\fP \fIcommand\fP] +.br +[\fB\-X\fP \fIfilterpat\fP] [\fB\-P\fP \fIprefix\fP] [\fB\-S\fP \fIsuffix\fP] \fIname\fP [\fIname ...\fP] +.PD 0 +.TP +\fBcomplete\fP \fB\-pr\fP [\fB\-DE\fP] [\fIname\fP ...] +.PD +Specify how arguments to each \fIname\fP should be completed. +If the \fB\-p\fP option is supplied, or if no options are supplied, +existing completion specifications are printed in a way that allows +them to be reused as input. +The \fB\-r\fP option removes a completion specification for +each \fIname\fP, or, if no \fIname\fPs are supplied, all +completion specifications. +The \fB\-D\fP option indicates that the remaining options and actions should +apply to the ``default'' command completion; that is, completion attempted +on a command for which no completion has previously been defined. +The \fB\-E\fP option indicates that the remaining options and actions should +apply to ``empty'' command completion; that is, completion attempted on a +blank line. +.sp 1 +The process of applying these completion specifications when word completion +is attempted is described above under \fBProgrammable Completion\fP. +.sp 1 +Other options, if specified, have the following meanings. +The arguments to the \fB\-G\fP, \fB\-W\fP, and \fB\-X\fP options +(and, if necessary, the \fB\-P\fP and \fB\-S\fP options) +should be quoted to protect them from expansion before the +.B complete +builtin is invoked. +.RS +.PD 0 +.TP 8 +\fB\-o\fP \fIcomp-option\fP +The \fIcomp-option\fP controls several aspects of the compspec's behavior +beyond the simple generation of completions. +\fIcomp-option\fP may be one of: +.RS +.TP 8 +.B bashdefault +Perform the rest of the default \fBbash\fP completions if the compspec +generates no matches. +.TP 8 +.B default +Use readline's default filename completion if the compspec generates +no matches. +.TP 8 +.B dirnames +Perform directory name completion if the compspec generates no matches. +.TP 8 +.B filenames +Tell readline that the compspec generates filenames, so it can perform any +filename\-specific processing (like adding a slash to directory names, +quoting special characters, or suppressing trailing spaces). +Intended to be used with shell functions. +.TP 8 +.B noquote +Tell readline not to quote the completed words if they are filenames +(quoting filenames is the default). +.TP 8 +.B nosort +Tell readline not to sort the list of possible completions alphabetically. +.TP 8 +.B nospace +Tell readline not to append a space (the default) to words completed at +the end of the line. +.TP 8 +.B plusdirs +After any matches defined by the compspec are generated, +directory name completion is attempted and any +matches are added to the results of the other actions. +.RE +.TP 8 +\fB\-A\fP \fIaction\fP +The \fIaction\fP may be one of the following to generate a list of possible +completions: +.RS +.TP 8 +.B alias +Alias names. May also be specified as \fB\-a\fP. +.TP 8 +.B arrayvar +Array variable names. +.TP 8 +.B binding +\fBReadline\fP key binding names. +.TP 8 +.B builtin +Names of shell builtin commands. May also be specified as \fB\-b\fP. +.TP 8 +.B command +Command names. May also be specified as \fB\-c\fP. +.TP 8 +.B directory +Directory names. May also be specified as \fB\-d\fP. +.TP 8 +.B disabled +Names of disabled shell builtins. +.TP 8 +.B enabled +Names of enabled shell builtins. +.TP 8 +.B export +Names of exported shell variables. May also be specified as \fB\-e\fP. +.TP 8 +.B file +File names. May also be specified as \fB\-f\fP. +.TP 8 +.B function +Names of shell functions. +.TP 8 +.B group +Group names. May also be specified as \fB\-g\fP. +.TP 8 +.B helptopic +Help topics as accepted by the \fBhelp\fP builtin. +.TP 8 +.B hostname +Hostnames, as taken from the file specified by the +.SM +.B HOSTFILE +shell variable. +.TP 8 +.B job +Job names, if job control is active. May also be specified as \fB\-j\fP. +.TP 8 +.B keyword +Shell reserved words. May also be specified as \fB\-k\fP. +.TP 8 +.B running +Names of running jobs, if job control is active. +.TP 8 +.B service +Service names. May also be specified as \fB\-s\fP. +.TP 8 +.B setopt +Valid arguments for the \fB\-o\fP option to the \fBset\fP builtin. +.TP 8 +.B shopt +Shell option names as accepted by the \fBshopt\fP builtin. +.TP 8 +.B signal +Signal names. +.TP 8 +.B stopped +Names of stopped jobs, if job control is active. +.TP 8 +.B user +User names. May also be specified as \fB\-u\fP. +.TP 8 +.B variable +Names of all shell variables. May also be specified as \fB\-v\fP. +.RE +.TP 8 +\fB\-C\fP \fIcommand\fP +\fIcommand\fP is executed in a subshell environment, and its output is +used as the possible completions. +.TP 8 +\fB\-F\fP \fIfunction\fP +The shell function \fIfunction\fP is executed in the current shell +environment. +When the function is executed, +the first argument (\fB$1\fP) is the name of the command whose arguments are +being completed, +the second argument (\fB$2\fP) is the word being completed, +and the third argument (\fB$3\fP) is the word preceding the word being +completed on the current command line. +When it finishes, the possible completions are retrieved from the value +of the +.SM +.B COMPREPLY +array variable. +.TP 8 +\fB\-G\fP \fIglobpat\fP +The pathname expansion pattern \fIglobpat\fP is expanded to generate +the possible completions. +.TP 8 +\fB\-P\fP \fIprefix\fP +\fIprefix\fP is added at the beginning of each possible completion +after all other options have been applied. +.TP 8 +\fB\-S\fP \fIsuffix\fP +\fIsuffix\fP is appended to each possible completion +after all other options have been applied. +.TP 8 +\fB\-W\fP \fIwordlist\fP +The \fIwordlist\fP is split using the characters in the +.SM +.B IFS +special variable as delimiters, and each resultant word is expanded. +The possible completions are the members of the resultant list which +match the word being completed. +.TP 8 +\fB\-X\fP \fIfilterpat\fP +\fIfilterpat\fP is a pattern as used for pathname expansion. +It is applied to the list of possible completions generated by the +preceding options and arguments, and each completion matching +\fIfilterpat\fP is removed from the list. +A leading \fB!\fP in \fIfilterpat\fP negates the pattern; in this +case, any completion not matching \fIfilterpat\fP is removed. +.PD +.PP +The return value is true unless an invalid option is supplied, an option +other than \fB\-p\fP or \fB\-r\fP is supplied without a \fIname\fP +argument, an attempt is made to remove a completion specification for +a \fIname\fP for which no specification exists, or +an error occurs adding a completion specification. +.RE +.TP +\fBcompopt\fP [\fB\-o\fP \fIoption\fP] [\fB\-DE\fP] [\fB+o\fP \fIoption\fP] [\fIname\fP] +Modify completion options for each \fIname\fP according to the +\fIoption\fPs, or for the +currently-executing completion if no \fIname\fPs are supplied. +If no \fIoption\fPs are given, display the completion options for each +\fIname\fP or the current completion. +The possible values of \fIoption\fP are those valid for the \fBcomplete\fP +builtin described above. +The \fB\-D\fP option indicates that the remaining options should +apply to the ``default'' command completion; that is, completion attempted +on a command for which no completion has previously been defined. +The \fB\-E\fP option indicates that the remaining options should +apply to ``empty'' command completion; that is, completion attempted on a +blank line. +.sp 1 +The return value is true unless an invalid option is supplied, an attempt +is made to modify the options for a \fIname\fP for which no completion +specification exists, or an output error occurs. +.TP +\fBcontinue\fP [\fIn\fP] +Resume the next iteration of the enclosing +.BR for , +.BR while , +.BR until , +or +.B select +loop. +If +.I n +is specified, resume at the \fIn\fPth enclosing loop. +.I n +must be \(>= 1. If +.I n +is greater than the number of enclosing loops, the last enclosing loop +(the ``top-level'' loop) is resumed. +The return value is 0 unless \fIn\fP is not greater than or equal to 1. +.TP +\fBdeclare\fP [\fB\-aAfFgilnrtux\fP] [\fB\-p\fP] [\fIname\fP[=\fIvalue\fP] ...] +.PD 0 +.TP +\fBtypeset\fP [\fB\-aAfFgilnrtux\fP] [\fB\-p\fP] [\fIname\fP[=\fIvalue\fP] ...] +.PD +Declare variables and/or give them attributes. +If no \fIname\fPs are given then display the values of variables. +The +.B \-p +option will display the attributes and values of each +.IR name . +When +.B \-p +is used with \fIname\fP arguments, additional options, +other than \fB\-f\fP and \fB\-F\fP, are ignored. +When +.B \-p +is supplied without \fIname\fP arguments, it will display the attributes +and values of all variables having the attributes specified by the +additional options. +If no other options are supplied with \fB\-p\fP, \fBdeclare\fP will display +the attributes and values of all shell variables. The \fB\-f\fP option +will restrict the display to shell functions. +The +.B \-F +option inhibits the display of function definitions; only the +function name and attributes are printed. +If the \fBextdebug\fP shell option is enabled using \fBshopt\fP, +the source file name and line number where each \fIname\fP +is defined are displayed as well. The +.B \-F +option implies +.BR \-f . +The +.B \-g +option forces variables to be created or modified at the global scope, +even when \fBdeclare\fP is executed in a shell function. +It is ignored in all other cases. +The following options can +be used to restrict output to variables with the specified attribute or +to give variables attributes: +.RS +.PD 0 +.TP +.B \-a +Each \fIname\fP is an indexed array variable (see +.B Arrays +above). +.TP +.B \-A +Each \fIname\fP is an associative array variable (see +.B Arrays +above). +.TP +.B \-f +Use function names only. +.TP +.B \-i +The variable is treated as an integer; arithmetic evaluation (see +.SM +.B "ARITHMETIC EVALUATION" +above) is performed when the variable is assigned a value. +.TP +.B \-l +When the variable is assigned a value, all upper-case characters are +converted to lower-case. +The upper-case attribute is disabled. +.TP +.B \-n +Give each \fIname\fP the \fInameref\fP attribute, making +it a name reference to another variable. +That other variable is defined by the value of \fIname\fP. +All references, assignments, and attribute modifications +to \fIname\fP, except those using or changing the +\fB\-n\fP attribute itself, are performed on the variable referenced by +\fIname\fP's value. +The nameref attribute cannot be applied to array variables. +.TP +.B \-r +Make \fIname\fPs readonly. These names cannot then be assigned values +by subsequent assignment statements or unset. +.TP +.B \-t +Give each \fIname\fP the \fItrace\fP attribute. +Traced functions inherit the \fBDEBUG\fP and \fBRETURN\fP traps from +the calling shell. +The trace attribute has no special meaning for variables. +.TP +.B \-u +When the variable is assigned a value, all lower-case characters are +converted to upper-case. +The lower-case attribute is disabled. +.TP +.B \-x +Mark \fIname\fPs for export to subsequent commands via the environment. +.PD +.PP +Using `+' instead of `\-' +turns off the attribute instead, +with the exceptions that \fB+a\fP +may not be used to destroy an array variable and \fB+r\fP will not +remove the readonly attribute. +When used in a function, +.B declare +and +.B typeset +make each +\fIname\fP local, as with the +.B local +command, +unless the \fB\-g\fP option is supplied. +If a variable name is followed by =\fIvalue\fP, the value of +the variable is set to \fIvalue\fP. +When using \fB\-a\fP or \fB\-A\fP and the compound assignment syntax to +create array variables, additional attributes do not take effect until +subsequent assignments. +The return value is 0 unless an invalid option is encountered, +an attempt is made to define a function using +.if n ``\-f foo=bar'', +.if t \f(CW\-f foo=bar\fP, +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 (see +.B Arrays +above), one of the \fInames\fP 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 \fB\-f\fP. +.RE +.TP +.B dirs [\fB\-clpv\fP] [+\fIn\fP] [\-\fIn\fP] +Without options, displays the list of currently remembered directories. +The default display is on a single line with directory names separated +by spaces. +Directories are added to the list with the +.B pushd +command; the +.B popd +command removes entries from the list. +The current directory is always the first directory in the stack. +.RS +.PD 0 +.TP +.B \-c +Clears the directory stack by deleting all of the entries. +.TP +.B \-l +Produces a listing using full pathnames; +the default listing format uses a tilde to denote the home directory. +.TP +.B \-p +Print the directory stack with one entry per line. +.TP +.B \-v +Print the directory stack with one entry per line, +prefixing each entry with its index in the stack. +.TP +\fB+\fP\fIn\fP +Displays the \fIn\fPth entry counting from the left of the list +shown by +.B dirs +when invoked without options, starting with zero. +.TP +\fB\-\fP\fIn\fP +Displays the \fIn\fPth entry counting from the right of the list +shown by +.B dirs +when invoked without options, starting with zero. +.PD +.PP +The return value is 0 unless an +invalid option is supplied or \fIn\fP indexes beyond the end +of the directory stack. +.RE +.TP +\fBdisown\fP [\fB\-ar\fP] [\fB\-h\fP] [\fIjobspec\fP ... | \fIpid\fP ... ] +Without options, remove each +.I jobspec +from the table of active jobs. +If +.I jobspec +is not present, and neither the \fB\-a\fP nor the \fB\-r\fP option +is supplied, the \fIcurrent job\fP is used. +If the \fB\-h\fP option is given, each +.I jobspec +is not removed from the table, but is marked so that +.SM +.B SIGHUP +is not sent to the job if the shell receives a +.SM +.BR SIGHUP . +If no +.I jobspec +is supplied, the +.B \-a +option means to remove or mark all jobs; the +.B \-r +option without a +.I jobspec +argument restricts operation to running jobs. +The return value is 0 unless a +.I jobspec +does not specify a valid job. +.TP +\fBecho\fP [\fB\-neE\fP] [\fIarg\fP ...] +Output the \fIarg\fPs, separated by spaces, followed by a newline. +The return status is 0 unless a write error occurs. +If \fB\-n\fP is specified, the trailing newline is +suppressed. If the \fB\-e\fP option is given, interpretation of +the following backslash-escaped characters is enabled. The +.B \-E +option disables the interpretation of these escape characters, +even on systems where they are interpreted by default. +The \fBxpg_echo\fP shell option may be used to +dynamically determine whether or not \fBecho\fP expands these +escape characters by default. +.B echo +does not interpret \fB\-\-\fP to mean the end of options. +.B echo +interprets the following escape sequences: +.RS +.PD 0 +.TP +.B \ea +alert (bell) +.TP +.B \eb +backspace +.TP +.B \ec +suppress further output +.TP +.B \ee +.TP +.B \eE +an escape character +.TP +.B \ef +form feed +.TP +.B \en +new line +.TP +.B \er +carriage return +.TP +.B \et +horizontal tab +.TP +.B \ev +vertical tab +.TP +.B \e\e +backslash +.TP +.B \e0\fInnn\fP +the eight-bit character whose value is the octal value \fInnn\fP +(zero to three octal digits) +.TP +.B \ex\fIHH\fP +the eight-bit character whose value is the hexadecimal value \fIHH\fP +(one or two hex digits) +.TP +.B \eu\fIHHHH\fP +the Unicode (ISO/IEC 10646) character whose value is the hexadecimal value +\fIHHHH\fP (one to four hex digits) +.TP +.B \eU\fIHHHHHHHH\fP +the Unicode (ISO/IEC 10646) character whose value is the hexadecimal value +\fIHHHHHHHH\fP (one to eight hex digits) +.PD +.RE +.TP +\fBenable\fP [\fB\-a\fP] [\fB\-dnps\fP] [\fB\-f\fP \fIfilename\fP] [\fIname\fP ...] +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 \fB\-n\fP is used, each \fIname\fP +is disabled; otherwise, +\fInames\fP are enabled. For example, to use the +.B test +binary found via the +.SM +.B PATH +instead of the shell builtin version, run +.if t \f(CWenable -n test\fP. +.if n ``enable -n test''. +The +.B \-f +option means to load the new builtin command +.I name +from shared object +.IR filename , +on systems that support dynamic loading. The +.B \-d +option will delete a builtin previously loaded with +.BR \-f . +If no \fIname\fP arguments are given, or if the +.B \-p +option is supplied, a list of shell builtins is printed. +With no other option arguments, the list consists of all enabled +shell builtins. +If \fB\-n\fP is supplied, only disabled builtins are printed. +If \fB\-a\fP is supplied, the list printed includes all builtins, with an +indication of whether or not each is enabled. +If \fB\-s\fP is supplied, the output is restricted to the POSIX +\fIspecial\fP builtins. +The return value is 0 unless a +.I name +is not a shell builtin or there is an error loading a new builtin +from a shared object. +.TP +\fBeval\fP [\fIarg\fP ...] +The \fIarg\fPs are read and concatenated together into a single +command. This command is then read and executed by the shell, and +its exit status is returned as the value of +.BR eval . +If there are no +.IR args , +or only null arguments, +.B eval +returns 0. +.TP +\fBexec\fP [\fB\-cl\fP] [\fB\-a\fP \fIname\fP] [\fIcommand\fP [\fIarguments\fP]] +If +.I command +is specified, it replaces the shell. +No new process is created. The +.I arguments +become the arguments to \fIcommand\fP. +If the +.B \-l +option is supplied, +the shell places a dash at the beginning of the zeroth argument passed to +.IR command . +This is what +.IR login (1) +does. The +.B \-c +option causes +.I command +to be executed with an empty environment. If +.B \-a +is supplied, the shell passes +.I name +as the zeroth argument to the executed command. +If +.I command +cannot be executed for some reason, a non-interactive shell exits, +unless the +.B execfail +shell option +is enabled. In that case, it returns failure. +An interactive shell returns failure if the file cannot be executed. +If +.I command +is not specified, any redirections take effect in the current shell, +and the return status is 0. If there is a redirection error, the +return status is 1. +.TP +\fBexit\fP [\fIn\fP] +Cause the shell to exit +with a status of \fIn\fP. If +.I n +is omitted, the exit status +is that of the last command executed. +A trap on +.SM +.B EXIT +is executed before the shell terminates. +.TP +\fBexport\fP [\fB\-fn\fP\^] [\fIname\fP[=\fIword\fP]] ... +.PD 0 +.TP +.B export \-p +.PD +The supplied +.I names +are marked for automatic export to the environment of +subsequently executed commands. If the +.B \-f +option is given, the +.I names +refer to functions. +If no +.I names +are given, or if the +.B \-p +option is supplied, a list +of names of all exported variables is printed. +The +.B \-n +option causes the export property to be removed from each +\fIname\fP. +If a variable name is followed by =\fIword\fP, the value of +the variable is set to \fIword\fP. +.B export +returns an exit status of 0 unless an invalid option is +encountered, +one of the \fInames\fP is not a valid shell variable name, or +.B \-f +is supplied with a +.I name +that is not a function. +.TP +\fBfc\fP [\fB\-e\fP \fIename\fP] [\fB\-lnr\fP] [\fIfirst\fP] [\fIlast\fP] +.PD 0 +.TP +\fBfc\fP \fB\-s\fP [\fIpat\fP=\fIrep\fP] [\fIcmd\fP] +.PD +The first form selects a range of commands from +.I first +to +.I last +from the history list and displays or edits and re-executes them. +.I First +and +.I last +may be specified as a string (to locate the last command beginning +with that string) or as a number (an index into the history list, +where a negative number is used as an offset from the current +command number). If +.I last +is not specified it is set to +the current command for listing (so that +.if n ``fc \-l \-10'' +.if t \f(CWfc \-l \-10\fP +prints the last 10 commands) and to +.I first +otherwise. +If +.I first +is not specified it is set to the previous +command for editing and \-16 for listing. +.sp 1 +The +.B \-n +option suppresses +the command numbers when listing. The +.B \-r +option reverses the order of +the commands. If the +.B \-l +option is given, +the commands are listed on +standard output. Otherwise, the editor given by +.I ename +is invoked +on a file containing those commands. If +.I ename +is not given, the +value of the +.SM +.B FCEDIT +variable is used, and +the value of +.SM +.B EDITOR +if +.SM +.B FCEDIT +is not set. If neither variable is set, +.FN vi +is used. When editing is complete, the edited commands are +echoed and executed. +.sp 1 +In the second form, \fIcommand\fP is re-executed after each instance +of \fIpat\fP is replaced by \fIrep\fP. +\fICommand\fP is intepreted the same as \fIfirst\fP above. +A useful alias to use with this is +.if n ``r="fc -s"'', +.if t \f(CWr='fc \-s'\fP, +so that typing +.if n ``r cc'' +.if t \f(CWr cc\fP +runs the last command beginning with +.if n ``cc'' +.if t \f(CWcc\fP +and typing +.if n ``r'' +.if t \f(CWr\fP +re-executes the last command. +.sp 1 +If the first form is used, the return value is 0 unless an invalid +option is encountered or +.I first +or +.I last +specify history lines out of range. +If the +.B \-e +option is supplied, the return value is the value of the last +command executed or failure if an error occurs with the temporary +file of commands. If the second form is used, the return status +is that of the command re-executed, unless +.I cmd +does not specify a valid history line, in which case +.B fc +returns failure. +.TP +\fBfg\fP [\fIjobspec\fP] +Resume +.I jobspec +in the foreground, and make it the current job. +If +.I jobspec +is not present, the shell's notion of the \fIcurrent job\fP is used. +The return value is that of the command placed into the foreground, +or failure if run when job control is disabled or, when run with +job control enabled, if +.I jobspec +does not specify a valid job or +.I jobspec +specifies a job that was started without job control. +.TP +\fBgetopts\fP \fIoptstring\fP \fIname\fP [\fIargs\fP] +.B getopts +is used by shell procedures to parse positional parameters. +.I 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 and question mark characters may not be used as +option characters. +Each time it is invoked, +.B getopts +places the next option in the shell variable +.IR name , +initializing +.I name +if it does not exist, +and the index of the next argument to be processed into the +variable +.SM +.BR OPTIND . +.SM +.B OPTIND +is initialized to 1 each time the shell or a shell script +is invoked. When an option requires an argument, +.B getopts +places that argument into the variable +.SM +.BR OPTARG . +The shell does not reset +.SM +.B OPTIND +automatically; it must be manually reset between multiple +calls to +.B getopts +within the same shell invocation if a new set of parameters +is to be used. +.sp 1 +When the end of options is encountered, \fBgetopts\fP exits with a +return value greater than zero. +.SM +.B OPTIND +is set to the index of the first non-option argument, +and \fIname\fP is set to ?. +.sp 1 +.B getopts +normally parses the positional parameters, but if more arguments are +given in +.IR args , +.B getopts +parses those instead. +.sp 1 +.B getopts +can report errors in two ways. If the first character of +.I optstring +is a colon, +.I silent +error reporting is used. In normal operation, diagnostic messages +are printed when invalid options or missing option arguments are +encountered. +If the variable +.SM +.B OPTERR +is set to 0, no error messages will be displayed, even if the first +character of +.I optstring +is not a colon. +.sp 1 +If an invalid option is seen, +.B getopts +places ? into +.I name +and, if not silent, +prints an error message and unsets +.SM +.BR OPTARG . +If +.B getopts +is silent, +the option character found is placed in +.SM +.B OPTARG +and no diagnostic message is printed. +.sp 1 +If a required argument is not found, and +.B getopts +is not silent, +a question mark (\^\fB?\fP\^) is placed in +.IR name , +.SM +.B OPTARG +is unset, and a diagnostic message is printed. +If +.B getopts +is silent, then a colon (\^\fB:\fP\^) is placed in +.I name +and +.SM +.B OPTARG +is set to the option character found. +.sp 1 +.B getopts +returns true if an option, specified or unspecified, is found. +It returns false if the end of options is encountered or an +error occurs. +.TP +\fBhash\fP [\fB\-lr\fP] [\fB\-p\fP \fIfilename\fP] [\fB\-dt\fP] [\fIname\fP] +Each time \fBhash\fP is invoked, +the full pathname of the command +.I name +is determined by searching +the directories in +.B $PATH +and remembered. Any previously-remembered pathname is discarded. +If the +.B \-p +option is supplied, no path search is performed, and +.I filename +is used as the full filename of the command. +The +.B \-r +option causes the shell to forget all +remembered locations. +The +.B \-d +option causes the shell to forget the remembered location of each \fIname\fP. +If the +.B \-t +option is supplied, the full pathname to which each \fIname\fP corresponds +is printed. If multiple \fIname\fP arguments are supplied with \fB\-t\fP, +the \fIname\fP is printed before the hashed full pathname. +The +.B \-l +option causes output to be displayed in a format that may be reused as input. +If no arguments are given, or if only \fB\-l\fP is supplied, +information about remembered commands is printed. +The return status is true unless a +.I name +is not found or an invalid option is supplied. +.TP +\fBhelp\fP [\fB\-dms\fP] [\fIpattern\fP] +Display helpful information about builtin commands. If +.I pattern +is specified, +.B help +gives detailed help on all commands matching +.IR pattern ; +otherwise help for all the builtins and shell control structures +is printed. +.RS +.PD 0 +.TP +.B \-d +Display a short description of each \fIpattern\fP +.TP +.B \-m +Display the description of each \fIpattern\fP in a manpage-like format +.TP +.B \-s +Display only a short usage synopsis for each \fIpattern\fP +.PD +.PP +The return status is 0 unless no command matches +.IR pattern . +.RE +.TP +\fBhistory [\fIn\fP] +.PD 0 +.TP +\fBhistory\fP \fB\-c\fP +.TP +\fBhistory \-d\fP \fIoffset\fP +.TP +\fBhistory\fP \fB\-anrw\fP [\fIfilename\fP] +.TP +\fBhistory\fP \fB\-p\fP \fIarg\fP [\fIarg ...\fP] +.TP +\fBhistory\fP \fB\-s\fP \fIarg\fP [\fIarg ...\fP] +.PD +With no options, display the command +history list with line numbers. Lines listed +with a +.B * +have been modified. An argument of +.I n +lists only the last +.I n +lines. +If the shell variable +.SM +.B HISTTIMEFORMAT +is set and not null, +it is used as a format string for \fIstrftime\fP(3) to display +the time stamp associated with each displayed history entry. +No intervening blank is printed between the formatted time stamp +and the history line. +If \fIfilename\fP is supplied, it is used as the +name of the history file; if not, the value of +.SM +.B HISTFILE +is used. Options, if supplied, have the following meanings: +.RS +.PD 0 +.TP +.B \-c +Clear the history list by deleting all the entries. +.TP +\fB\-d\fP \fIoffset\fP +Delete the history entry at position \fIoffset\fP. +.TP +.B \-a +Append the ``new'' history lines to the history file. +These are history lines entered since the beginning of the current +\fBbash\fP session, but not already appended to the history file. +.TP +.B \-n +Read the history lines not already read from the history +file into the current history list. These are lines +appended to the history file since the beginning of the +current \fBbash\fP session. +.TP +.B \-r +Read the contents of the history file +and append them to the current history list. +.TP +.B \-w +Write the current history list to the history file, overwriting the +history file's contents. +.TP +.B \-p +Perform history substitution on the following \fIargs\fP and display +the result on the standard output. +Does not store the results in the history list. +Each \fIarg\fP must be quoted to disable normal history expansion. +.TP +.B \-s +Store the +.I args +in the history list as a single entry. The last command in the +history list is removed before the +.I args +are added. +.PD +.PP +If the +.SM +.B HISTTIMEFORMAT +variable is set, the time stamp information +associated with each history entry is written to the history file, +marked with the history comment character. +When the history file is read, lines beginning with the history +comment character followed immediately by a digit are interpreted +as timestamps for the following history entry. +The return value is 0 unless an invalid option is encountered, an +error occurs while reading or writing the history file, an invalid +\fIoffset\fP is supplied as an argument to \fB\-d\fP, or the +history expansion supplied as an argument to \fB\-p\fP fails. +.RE +.TP +\fBjobs\fP [\fB\-lnprs\fP] [ \fIjobspec\fP ... ] +.PD 0 +.TP +\fBjobs\fP \fB\-x\fP \fIcommand\fP [ \fIargs\fP ... ] +.PD +The first form lists the active jobs. The options have the following +meanings: +.RS +.PD 0 +.TP +.B \-l +List process IDs +in addition to the normal information. +.TP +.B \-n +Display information only about jobs that have changed status since +the user was last notified of their status. +.TP +.B \-p +List only the process ID of the job's process group +leader. +.TP +.B \-r +Display only running jobs. +.TP +.B \-s +Display only stopped jobs. +.PD +.PP +If +.I jobspec +is given, output is restricted to information about that job. +The return status is 0 unless an invalid option is encountered +or an invalid +.I jobspec +is supplied. +.PP +If the +.B \-x +option is supplied, +.B jobs +replaces any +.I jobspec +found in +.I command +or +.I args +with the corresponding process group ID, and executes +.I command +passing it +.IR args , +returning its exit status. +.RE +.TP +\fBkill\fP [\fB\-s\fP \fIsigspec\fP | \fB\-n\fP \fIsignum\fP | \fB\-\fP\fIsigspec\fP] [\fIpid\fP | \fIjobspec\fP] ... +.PD 0 +.TP +\fBkill\fP \fB\-l\fP|\fB\-L\fP [\fIsigspec\fP | \fIexit_status\fP] +.PD +Send the signal named by +.I sigspec +or +.I signum +to the processes named by +.I pid +or +.IR jobspec . +.I sigspec +is either a case-insensitive signal name such as +.SM +.B SIGKILL +(with or without the +.SM +.B SIG +prefix) or a signal number; +.I signum +is a signal number. +If +.I sigspec +is not present, then +.SM +.B SIGTERM +is assumed. +An argument of +.B \-l +lists the signal names. +If any arguments are supplied when +.B \-l +is given, the names of the signals corresponding to the arguments are +listed, and the return status is 0. +The \fIexit_status\fP argument to +.B \-l +is a number specifying either a signal number or the exit status of +a process terminated by a signal. +The +.B \-L +option is equivalent to \fB\-l\fP. +.B kill +returns true if at least one signal was successfully sent, or false +if an error occurs or an invalid option is encountered. +.TP +\fBlet\fP \fIarg\fP [\fIarg\fP ...] +Each +.I arg +is an arithmetic expression to be evaluated (see +.SM +.B "ARITHMETIC EVALUATION" +above). +If the last +.I arg +evaluates to 0, +.B let +returns 1; 0 is returned otherwise. +.TP +\fBlocal\fP [\fIoption\fP] [\fIname\fP[=\fIvalue\fP] ... | \- ] +For each argument, a local variable named +.I name +is created, and assigned +.IR value . +The \fIoption\fP can be any of the options accepted by \fBdeclare\fP. +When +.B local +is used within a function, it causes the variable +.I name +to have a visible scope restricted to that function and its children. +If \fIname\fP is \-, the set of shell options is made local to the function +in which \fBlocal\fP is invoked: shell options changed using the +\fBset\fP builtin inside the function are restored to their original values +when the function returns. +With no operands, +.B local +writes a list of local variables to the standard output. It is +an error to use +.B local +when not within a function. The return status is 0 unless +.B local +is used outside a function, an invalid +.I name +is supplied, or +\fIname\fP is a readonly variable. +.TP +.B logout +Exit a login shell. +.TP +\fBmapfile\fP [\fB\-d\fP \fIdelim\fP] [\fB\-n\fP \fIcount\fP] [\fB\-O\fP \fIorigin\fP] [\fB\-s\fP \fIcount\fP] [\fB\-t\fP] [\fB\-u\fP \fIfd\fP] [\fB\-C\fP \fIcallback\fP] [\fB\-c\fP \fIquantum\fP] [\fIarray\fP] +.PD 0 +.TP +\fBreadarray\fP [\fB\-d\fP \fIdelim\fP] [\fB\-n\fP \fIcount\fP] [\fB\-O\fP \fIorigin\fP] [\fB\-s\fP \fIcount\fP] [\fB\-t\fP] [\fB\-u\fP \fIfd\fP] [\fB\-C\fP \fIcallback\fP] [\fB\-c\fP \fIquantum\fP] [\fIarray\fP] +.PD +Read lines from the standard input into the indexed array variable +.IR array , +or from file descriptor +.IR fd +if the +.B \-u +option is supplied. +The variable +.SM +.B MAPFILE +is the default \fIarray\fP. +Options, if supplied, have the following meanings: +.RS +.PD 0 +.TP +.B \-d +The first character of \fIdelim\fP is used to terminate each input line, +rather than newline. +.TP +.B \-n +Copy at most +.I count +lines. If \fIcount\fP is 0, all lines are copied. +.TP +.B \-O +Begin assigning to +.I array +at index +.IR origin . +The default index is 0. +.TP +.B \-s +Discard the first \fIcount\fP lines read. +.TP +.B \-t +Remove a trailing \fIdelim\fP (default newline) from each line read. +.TP +.B \-u +Read lines from file descriptor \fIfd\fP instead of the standard input. +.TP +.B \-C +Evaluate +.I callback +each time \fIquantum\fP lines are read. The \fB\-c\fP option specifies +.IR quantum . +.TP +.B \-c +Specify the number of lines read between each call to +.IR callback . +.PD +.PP +If +.B \-C +is specified without +.BR \-c , +the default quantum is 5000. +When \fIcallback\fP is evaluated, it is supplied the index of the next +array element to be assigned and the line to be assigned to that element +as additional arguments. +\fIcallback\fP is evaluated after the line is read but before the +array element is assigned. +.PP +If not supplied with an explicit origin, \fBmapfile\fP will clear \fIarray\fP +before assigning to it. +.PP +\fBmapfile\fP returns successfully unless an invalid option or option +argument is supplied, \fIarray\fP is invalid or unassignable, or if +\fIarray\fP is not an indexed array. +.RE +.TP +\fBpopd\fP [\-\fBn\fP] [+\fIn\fP] [\-\fIn\fP] +Removes entries from the directory stack. With no arguments, +removes the top directory from the stack, and performs a +.B cd +to the new top directory. +Arguments, if supplied, have the following meanings: +.RS +.PD 0 +.TP +.B \-n +Suppresses the normal change of directory when removing directories +from the stack, so that only the stack is manipulated. +.TP +\fB+\fP\fIn\fP +Removes the \fIn\fPth entry counting from the left of the list +shown by +.BR dirs , +starting with zero. For example: +.if n ``popd +0'' +.if t \f(CWpopd +0\fP +removes the first directory, +.if n ``popd +1'' +.if t \f(CWpopd +1\fP +the second. +.TP +\fB\-\fP\fIn\fP +Removes the \fIn\fPth entry counting from the right of the list +shown by +.BR dirs , +starting with zero. For example: +.if n ``popd -0'' +.if t \f(CWpopd -0\fP +removes the last directory, +.if n ``popd -1'' +.if t \f(CWpopd -1\fP +the next to last. +.PD +.PP +If the +.B popd +command is successful, a +.B dirs +is performed as well, and the return status is 0. +.B popd +returns false if an invalid option is encountered, the directory stack +is empty, a non-existent directory stack entry is specified, or the +directory change fails. +.RE +.TP +\fBprintf\fP [\fB\-v\fP \fIvar\fP] \fIformat\fP [\fIarguments\fP] +Write the formatted \fIarguments\fP to the standard output under the +control of the \fIformat\fP. +The \fB\-v\fP option causes the output to be assigned to the variable +\fIvar\fP rather than being printed to the standard output. +.sp 1 +The \fIformat\fP 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 +\fIargument\fP. +In addition to the standard \fIprintf\fP(1) format specifications, +\fBprintf\fP interprets the following extensions: +.RS +.PD 0 +.TP +.B %b +causes +\fBprintf\fP to expand backslash escape sequences in the corresponding +\fIargument\fP +in the same way as \fBecho \-e\fP. +.TP +.B %q +causes \fBprintf\fP to output the corresponding +\fIargument\fP in a format that can be reused as shell input. +.TP +.B %(\fIdatefmt\fP)T +causes \fBprintf\fP to output the date-time string resulting from using +\fIdatefmt\fP as a format string for \fIstrftime\fP(3). +The corresponding \fIargument\fP is an integer representing the number of +seconds since the epoch. +Two special argument values may be used: -1 represents the current +time, and -2 represents the time the shell was invoked. +If no argument is specified, conversion behaves as if -1 had been given. +This is an exception to the usual \fBprintf\fP behavior. +.PD +.PP +Arguments to non-string format specifiers are treated as C constants, +except that a leading plus or minus sign is allowed, and if the leading +character is a single or double quote, the value is the ASCII value of +the following character. +.PP +The \fIformat\fP is reused as necessary to consume all of the \fIarguments\fP. +If the \fIformat\fP requires more \fIarguments\fP 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. +.RE +.TP +\fBpushd\fP [\fB\-n\fP] [+\fIn\fP] [\-\fIn\fP] +.PD 0 +.TP +\fBpushd\fP [\fB\-n\fP] [\fIdir\fP] +.PD +Adds a directory to the top of the directory stack, or rotates +the stack, making the new top of the stack the current working +directory. With no arguments, \fBpushd\fP exchanges the top two directories +and returns 0, unless the directory stack is empty. +Arguments, if supplied, have the following meanings: +.RS +.PD 0 +.TP +.B \-n +Suppresses the normal change of directory when rotating or +adding directories to the stack, so that only the stack is manipulated. +.TP +\fB+\fP\fIn\fP +Rotates the stack so that the \fIn\fPth directory +(counting from the left of the list shown by +.BR dirs , +starting with zero) +is at the top. +.TP +\fB\-\fP\fIn\fP +Rotates the stack so that the \fIn\fPth directory +(counting from the right of the list shown by +.BR dirs , +starting with zero) is at the top. +.TP +.I dir +Adds +.I dir +to the directory stack at the top, making it the +new current working directory as if it had been supplied as the argument +to the \fBcd\fP builtin. +.PD +.PP +If the +.B pushd +command is successful, a +.B dirs +is performed as well. +If the first form is used, +.B pushd +returns 0 unless the cd to +.I dir +fails. With the second form, +.B pushd +returns 0 unless the directory stack is empty, +a non-existent directory stack element is specified, +or the directory change to the specified new current directory +fails. +.RE +.TP +\fBpwd\fP [\fB\-LP\fP] +Print the absolute pathname of the current working directory. +The pathname printed contains no symbolic links if the +.B \-P +option is supplied or the +.B \-o physical +option to the +.B set +builtin command is enabled. +If the +.B \-L +option is used, the pathname printed may contain symbolic links. +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\-a\fP \fIaname\fP] [\fB\-d\fP \fIdelim\fP] [\fB\-i\fP \fItext\fP] [\fB\-n\fP \fInchars\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, +split into words as described above under \fBWord Splitting\fP, +and the first word +is assigned to the first +.IR name , +the second word to the second +.IR name , +and so on. +If there are more words than names, the remaining words and their +intervening delimiters are assigned to the last +.IR name . +If there are fewer words read from the input stream than names, +the remaining names are assigned empty values. +The characters in +.SM +.B IFS +are used to split the line into words using the same rules the shell +uses for expansion (described above under \fBWord Splitting\fP). +The backslash character (\fB\e\fP) may be used to remove any special +meaning for the next character read and for line continuation. +Options, if supplied, have the following meanings: +.RS +.PD 0 +.TP +.B \-a \fIaname\fP +The words are assigned to sequential indices +of the array variable +.IR aname , +starting at 0. +.I aname +is unset before any new values are assigned. +Other \fIname\fP arguments are ignored. +.TP +.B \-d \fIdelim\fP +The first character of \fIdelim\fP is used to terminate the input line, +rather than newline. +.TP +.B \-e +If the standard input +is coming from a terminal, +.B readline +(see +.SM +.B READLINE +above) is used to obtain the line. +Readline uses the current (or default, if line editing was not previously +active) editing settings. +.TP +.B \-i \fItext\fP +If +.B readline +is being used to read the line, \fItext\fP is placed into the editing +buffer before editing begins. +.TP +.B \-n \fInchars\fP +\fBread\fP returns after reading \fInchars\fP characters rather than +waiting for a complete line of input, but honors a delimiter if fewer +than \fInchars\fP characters are read before the delimiter. +.TP +.B \-N \fInchars\fP +\fBread\fP returns after reading exactly \fInchars\fP characters rather +than waiting for a complete line of input, unless EOF is encountered or +\fBread\fP times out. +Delimiter characters encountered in the input are +not treated specially and do not cause \fBread\fP to return until +\fInchars\fP characters are read. +The result is not split on the characters in \fBIFS\fP; the intent is +that the variable is assigned exactly the characters read +(with the exception of backslash; see the \fB\-r\fP option below). +.TP +.B \-p \fIprompt\fP +Display \fIprompt\fP on standard error, without a +trailing newline, before attempting to read any input. The prompt +is displayed only if input is coming from a terminal. +.TP +.B \-r +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. +.TP +.B \-s +Silent mode. If input is coming from a terminal, characters are +not echoed. +.TP +.B \-t \fItimeout\fP +Cause \fBread\fP to time out and return failure if a complete line of +input (or a specified number of characters) +is not read within \fItimeout\fP seconds. +\fItimeout\fP may be a decimal number with a fractional portion following +the decimal point. +This option is only effective if \fBread\fP is reading input from a +terminal, pipe, or other special file; it has no effect when reading +from regular files. +If \fBread\fP times out, \fBread\fP saves any partial input read into +the specified variable \fIname\fP. +If \fItimeout\fP is 0, \fBread\fP returns immediately, without trying to +read any data. The exit status is 0 if input is available on +the specified file descriptor, non-zero otherwise. +The exit status is greater than 128 if the timeout is exceeded. +.TP +.B \-u \fIfd\fP +Read input from file descriptor \fIfd\fP. +.PD +.PP +If no +.I names +are supplied, the line read is assigned to the variable +.SM +.BR REPLY . +The exit status is zero, unless end-of-file is encountered, \fBread\fP +times out (in which case the status is greater than 128), +a variable assignment error (such as assigning to a readonly variable) occurs, +or an invalid file descriptor is supplied as the argument to \fB\-u\fP. +.RE +.TP +\fBreadonly\fP [\fB\-aAf\fP] [\fB\-p\fP] [\fIname\fP[=\fIword\fP] ...] +.PD +The given +\fInames\fP are marked readonly; the values of these +.I names +may not be changed by subsequent assignment. +If the +.B \-f +option is supplied, the functions corresponding to the +\fInames\fP are so +marked. +The +.B \-a +option restricts the variables to indexed arrays; the +.B \-A +option restricts the variables to associative arrays. +If both options are supplied, +.B \-A +takes precedence. +If no +.I name +arguments are given, or if the +.B \-p +option is supplied, a list of all readonly names is printed. +The other options may be used to restrict the output to a subset of +the set of readonly names. +The +.B \-p +option causes output to be displayed in a format that +may be reused as input. +If a variable name is followed by =\fIword\fP, the value of +the variable is set to \fIword\fP. +The return status is 0 unless an invalid option is encountered, +one of the +.I names +is not a valid shell variable name, or +.B \-f +is supplied with a +.I name +that is not a function. +.TP +\fBreturn\fP [\fIn\fP] +Causes a function to stop executing and return the value specified by +.I n +to its caller. +If +.I n +is omitted, the return status is that of the last command +executed in the function body. +If \fBreturn\fP is executed by a trap handler, the last command used to +determine the status is the last command executed before the trap handler. +if \fBreturn\fP is executed during a \fBDEBUG\fP trap, the last command +used to determine the status is the last command executed by the trap +handler before \fBreturn\fP was invoked. +If +.B return +is used outside a function, +but during execution of a script by the +.B . +(\fBsource\fP) command, it causes the shell to stop executing +that script and return either +.I n +or the exit status of the last command executed within the +script as the exit status of the script. +If \fIn\fP is supplied, the return value is its least significant +8 bits. +The return status is non-zero if +.B return +is supplied a non-numeric argument, or +is used outside a +function and not during execution of a script by \fB.\fP\^ or \fBsource\fP. +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\-name\fP] [\fIarg\fP ...] +.PD 0 +.TP +\fBset\fP [\fB+abefhkmnptuvxBCEHPT\fP] [\fB+o\fP \fIoption\-name\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. +Read-only variables cannot be reset. +In \fIposix\fP mode, only shell variables are listed. +The output is sorted according to the current locale. +When options are specified, they set or unset shell attributes. +Any arguments remaining after option processing are treated +as values for the positional parameters and are assigned, in order, to +.BR $1 , +.BR $2 , +.B ... +.BR $\fIn\fP . +Options, if specified, have the following meanings: +.RS +.PD 0 +.TP 8 +.B \-a +Each variable or function that is created or modified is given the +export attribute and marked for export to the environment of +subsequent commands. +.TP 8 +.B \-b +Report the status of terminated background jobs +immediately, rather than before the next primary prompt. This is +effective only when job control is enabled. +.TP 8 +.B \-e +Exit immediately if a +\fIpipeline\fP (which may consist of a single \fIsimple command\fP), +a \fIlist\fP, +or a \fIcompound command\fP +(see +.SM +.B SHELL GRAMMAR +above), exits with a non-zero status. +The shell does not exit if the +command that fails is part of the command list immediately following a +.B while +or +.B until +keyword, +part of the test following the +.B if +or +.B elif +reserved words, part of any command executed in a +.B && +or +.B || +list except the command following the final \fB&&\fP or \fB||\fP, +any command in a pipeline but the last, +or if the command's return value is +being inverted with +.BR ! . +If a compound command other than a subshell +returns a non-zero status because a command failed +while \fB\-e\fP was being ignored, the shell does not exit. +A trap on \fBERR\fP, if set, is executed before the shell exits. +This option applies to the shell environment and each subshell environment +separately (see +.SM +.B "COMMAND EXECUTION ENVIRONMENT" +above), and may cause +subshells to exit before executing all the commands in the subshell. +.if t .sp 0.5 +.if n .sp 1 +If a compound command or shell function executes in a context +where \fB\-e\fP is being ignored, +none of the commands executed within the compound command or function body +will be affected by the \fB\-e\fP setting, even if \fB\-e\fP is set +and a command returns a failure status. +If a compound command or shell function sets \fB\-e\fP while executing in +a context where \fB\-e\fP is ignored, that setting will not have any +effect until the compound command or the command containing the function +call completes. +.TP 8 +.B \-f +Disable pathname expansion. +.TP 8 +.B \-h +Remember the location of commands as they are looked up for execution. +This is enabled by default. +.TP 8 +.B \-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. +.TP 8 +.B \-m +Monitor mode. Job control is enabled. This option is on +by default for interactive shells on systems that support +it (see +.SM +.B JOB CONTROL +above). +All processes run in a separate process group. +When a background job completes, the shell prints a line +containing its exit status. +.TP 8 +.B \-n +Read commands but do not execute them. +This may be used to check a shell script for syntax errors. +This is ignored by interactive shells. +.TP 8 +.B \-o \fIoption\-name\fP +The \fIoption\-name\fP can be one of the following: +.RS +.TP 8 +.B allexport +Same as +.BR \-a . +.TP 8 +.B braceexpand +Same as +.BR \-B . +.TP 8 +.B emacs +Use an emacs-style command line editing interface. This is enabled +by default when the shell is interactive, unless the shell is started +with the +.B \-\-noediting +option. +This also affects the editing interface used for \fBread \-e\fP. +.TP 8 +.B errexit +Same as +.BR \-e . +.TP 8 +.B errtrace +Same as +.BR \-E . +.TP 8 +.B functrace +Same as +.BR \-T . +.TP 8 +.B hashall +Same as +.BR \-h . +.TP 8 +.B histexpand +Same as +.BR \-H . +.TP 8 +.B history +Enable command history, as described above under +.SM +.BR HISTORY . +This option is on by default in interactive shells. +.TP 8 +.B ignoreeof +The effect is as if the shell command +.if t \f(CWIGNOREEOF=10\fP +.if n ``IGNOREEOF=10'' +had been executed +(see +.B Shell Variables +above). +.TP 8 +.B keyword +Same as +.BR \-k . +.TP 8 +.B monitor +Same as +.BR \-m . +.TP 8 +.B noclobber +Same as +.BR \-C . +.TP 8 +.B noexec +Same as +.BR \-n . +.TP 8 +.B noglob +Same as +.BR \-f . +.TP 8 +.B nolog +Currently ignored. +.TP 8 +.B notify +Same as +.BR \-b . +.TP 8 +.B nounset +Same as +.BR \-u . +.TP 8 +.B onecmd +Same as +.BR \-t . +.TP 8 +.B physical +Same as +.BR \-P . +.TP 8 +.B 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. +.TP 8 +.B posix +Change the behavior of +.B bash +where the default operation differs +from the POSIX standard to match the standard (\fIposix mode\fP). +See +.SM +.B "SEE ALSO" +below for a reference to a document that details how posix mode affects +bash's behavior. +.TP 8 +.B privileged +Same as +.BR \-p . +.TP 8 +.B verbose +Same as +.BR \-v . +.TP 8 +.B vi +Use a vi-style command line editing interface. +This also affects the editing interface used for \fBread \-e\fP. +.TP 8 +.B xtrace +Same as +.BR \-x . +.sp .5 +.PP +If +.B \-o +is supplied with no \fIoption\-name\fP, the values of the current options are +printed. +If +.B +o +is supplied with no \fIoption\-name\fP, a series of +.B set +commands to recreate the current option settings is displayed on +the standard output. +.RE +.TP 8 +.B \-p +Turn on +.I privileged +mode. In this mode, the +.SM +.B $ENV +and +.SM +.B $BASH_ENV +files are not processed, shell functions are not inherited from the +environment, and the +.SM +.BR SHELLOPTS , +.SM +.BR BASHOPTS , +.SM +.BR CDPATH , +and +.SM +.B GLOBIGNORE +variables, if they appear in the environment, are ignored. +If the shell is started with the effective user (group) id not equal to the +real user (group) id, and the \fB\-p\fP option is not supplied, these actions +are taken and the effective user id is set to the real user id. +If the \fB\-p\fP option is supplied at startup, the effective user id is +not reset. +Turning this option off causes the effective user +and group ids to be set to the real user and group ids. +.TP 8 +.B \-t +Exit after reading and executing one command. +.TP 8 +.B \-u +Treat unset variables and parameters other than the special +parameters "@" and "*" as an error when performing +parameter expansion. If expansion is attempted on an +unset variable or parameter, the shell prints an error message, and, +if not interactive, exits with a non-zero status. +.TP 8 +.B \-v +Print shell input lines as they are read. +.TP 8 +.B \-x +After expanding each \fIsimple command\fP, +\fBfor\fP command, \fBcase\fP command, \fBselect\fP command, or +arithmetic \fBfor\fP command, display the expanded value of +.SM +.BR PS4 , +followed by the command and its expanded arguments +or associated word list. +.TP 8 +.B \-B +The shell performs brace expansion (see +.B Brace Expansion +above). This is on by default. +.TP 8 +.B \-C +If set, +.B bash +does not overwrite an existing file with the +.BR > , +.BR >& , +and +.B <> +redirection operators. This may be overridden when +creating output files by using the redirection operator +.B >| +instead of +.BR > . +.TP 8 +.B \-E +If set, any trap on \fBERR\fP is inherited by shell functions, command +substitutions, and commands executed in a subshell environment. +The \fBERR\fP trap is normally not inherited in such cases. +.TP 8 +.B \-H +Enable +.B ! +style history substitution. This option is on by +default when the shell is interactive. +.TP 8 +.B \-P +If set, the shell does not resolve symbolic links when executing +commands such as +.B cd +that change the current working directory. It uses the +physical directory structure instead. By default, +.B bash +follows the logical chain of directories when performing commands +which change the current directory. +.TP 8 +.B \-T +If set, any traps on \fBDEBUG\fP and \fBRETURN\fP are inherited by shell +functions, command substitutions, and commands executed in a +subshell environment. +The \fBDEBUG\fP and \fBRETURN\fP traps are normally not inherited +in such cases. +.TP 8 +.B \-\- +If no arguments follow this option, then the positional parameters are +unset. Otherwise, the positional parameters are set to the +\fIarg\fPs, even if some of them begin with a +.BR \- . +.TP 8 +.B \- +Signal the end of options, cause all remaining \fIarg\fPs to be +assigned to the positional parameters. The +.B \-x +and +.B \-v +options are turned off. +If there are no \fIarg\fPs, +the positional parameters remain unchanged. +.PD +.PP +The options are off by default unless otherwise noted. +Using + rather than \- causes these options to be turned off. +The options can also be specified as arguments to an invocation of +the shell. +The current set of options may be found in +.BR $\- . +The return status is always true unless an invalid option is encountered. +.RE +.TP +\fBshift\fP [\fIn\fP] +The positional parameters from \fIn\fP+1 ... are renamed to +.B $1 +.B .... +Parameters represented by the numbers \fB$#\fP +down to \fB$#\fP\-\fIn\fP+1 are unset. +.I n +must be a non-negative number less than or equal to \fB$#\fP. +If +.I n +is 0, no parameters are changed. +If +.I n +is not given, it is assumed to be 1. +If +.I n +is greater than \fB$#\fP, the positional parameters are not changed. +The return status is greater than zero if +.I n +is greater than +.B $# +or less than zero; otherwise 0. +.TP +\fBshopt\fP [\fB\-pqsu\fP] [\fB\-o\fP] [\fIoptname\fP ...] +Toggle the values of settings controlling optional shell behavior. +The settings can be either those listed below, or, if the +.B \-o +option is used, those available with the +.B \-o +option to the \fBset\fP builtin command. +With no options, or with the +.B \-p +option, a list of all settable options is displayed, with +an indication of whether or not each is set. +The \fB\-p\fP option causes output to be displayed in a form that +may be reused as input. +Other options have the following meanings: +.RS +.PD 0 +.TP +.B \-s +Enable (set) each \fIoptname\fP. +.TP +.B \-u +Disable (unset) each \fIoptname\fP. +.TP +.B \-q +Suppresses normal output (quiet mode); the return status indicates +whether the \fIoptname\fP is set or unset. +If multiple \fIoptname\fP arguments are given with +.BR \-q , +the return status is zero if all \fIoptnames\fP are enabled; non-zero +otherwise. +.TP +.B \-o +Restricts the values of \fIoptname\fP to be those defined for the +.B \-o +option to the +.B set +builtin. +.PD +.PP +If either +.B \-s +or +.B \-u +is used with no \fIoptname\fP arguments, +.B shopt +shows only those options which are set or unset, respectively. +Unless otherwise noted, the \fBshopt\fP options are disabled (unset) +by default. +.PP +The return status when listing options is zero if all \fIoptnames\fP +are enabled, non-zero otherwise. When setting or unsetting options, +the return status is zero unless an \fIoptname\fP is not a valid shell +option. +.PP +The list of \fBshopt\fP options is: +.if t .sp .5v +.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 +builtin command that +is not a directory is assumed to be the name of a variable whose +value is the directory to change to. +.TP 8 +.B cdspell +If set, minor errors in the spelling of a directory component in a +.B cd +command will be corrected. +The errors checked for are transposed characters, +a missing character, and one character too many. +If a correction is found, the corrected filename is printed, +and the command proceeds. +This option is only used by interactive shells. +.TP 8 +.B checkhash +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, \fBbash\fP 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 +.SM +.B "JOB CONTROL" +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 +.SM +.B LINES +and +.SM +.BR COLUMNS . +.TP 8 +.B cmdhist +If set, +.B 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. +.TP 8 +.B compat31 +If set, +.B bash +changes its behavior to that of version 3.1 with respect to quoted +arguments to the \fB[[\fP conditional command's \fB=~\fP operator +and locale-specific string comparison when using the \fB[[\fP +conditional command's \fB<\fP and \fB>\fP operators. +Bash versions prior to bash-4.1 use ASCII collation and +.IR strcmp (3); +bash-4.1 and later use the current locale's collation sequence and +.IR strcoll (3). +.TP 8 +.B compat32 +If set, +.B bash +changes its behavior to that of version 3.2 with respect to +locale-specific string comparison when using the \fB[[\fP +conditional command's \fB<\fP and \fB>\fP operators (see previous item) +and the effect of interrupting a command list. +Bash versions 3.2 and earlier continue with the next command in the list +after one terminates due to an interrupt. +.TP 8 +.B compat40 +If set, +.B bash +changes its behavior to that of version 4.0 with respect to locale-specific +string comparison when using the \fB[[\fP +conditional command's \fB<\fP and \fB>\fP operators (see description of +\fBcompat31\fP) +and the effect of interrupting a command list. +Bash versions 4.0 and later interrupt the list as if the shell received the +interrupt; previous versions continue with the next command in the list. +.TP 8 +.B compat41 +If set, +.BR bash , +when in \fIposix\fP mode, treats a single quote in a double-quoted +parameter expansion as a special character. The single quotes must match +(an even number) and the characters between the single quotes are considered +quoted. This is the behavior of posix mode through version 4.1. +The default bash behavior remains as in previous versions. +.TP 8 +.B compat42 +If set, +.B bash +does not process the replacement string in the pattern substitution word +expansion using quote removal. +.TP 8 +.B compat43 +If set, +.B bash +does not print a warning message if an attempt is made to use a quoted compound +array assignment as an argument to \fBdeclare\fP, +makes word expansion errors +non-fatal errors that cause the current command to fail (the default behavior is +to make them fatal errors that cause the shell to exit), +and does not reset the +loop state when a shell function is executed (this allows \fBbreak\fP or +\fBcontinue\fP in a shell function to affect loops in the caller's context). +.TP 8 +.B complete_fullquote +If set, +.B bash +quotes all shell metacharacters in filenames and directory names when +performing completion. +If not set, +.B bash +removes metacharacters such as the dollar sign from the set of +characters that will be quoted in completed filenames +when these metacharacters appear in shell variable references in words to be +completed. +This means that dollar signs in variable names that expand to directories +will not be quoted; +however, any dollar signs appearing in filenames will not be quoted, either. +This is active only when bash is using backslashes to quote completed +filenames. +This variable is set by default, which is the default bash behavior in +versions through 4.2. +.TP 8 +.B direxpand +If set, +.B bash +replaces directory names with the results of word expansion when performing +filename completion. This changes the contents of the readline editing +buffer. +If not set, +.B bash +attempts to preserve what the user typed. +.TP 8 +.B dirspell +If set, +.B bash +attempts spelling correction on directory names during word completion +if the directory name initially supplied does not exist. +.TP 8 +.B dotglob +If set, +.B bash +includes filenames beginning with a `.' in the results of pathname +expansion. +.TP 8 +.B execfail +If set, a non-interactive shell will not exit if +it cannot execute the file specified as an argument to the +.B exec +builtin command. An interactive shell does not exit if +.B exec +fails. +.TP 8 +.B expand_aliases +If set, aliases are expanded as described above under +.SM +.BR ALIASES . +This option is enabled by default for interactive shells. +.TP 8 +.B extdebug +If set at shell invocation, arrange to execute the debugger profile +before the shell starts, identical to the \fB\-\-debugger\fP option. +If set after invocation, behavior intended for use by debuggers is enabled: +.RS +.TP +.B 1. +The \fB\-F\fP option to the \fBdeclare\fP builtin displays the source +file name and line number corresponding to each function name supplied +as an argument. +.TP +.B 2. +If the command run by the \fBDEBUG\fP trap returns a non-zero value, the +next command is skipped and not executed. +.TP +.B 3. +If the command run by the \fBDEBUG\fP trap returns a value of 2, and the +shell is executing in a subroutine (a shell function or a shell script +executed by the \fB.\fP or \fBsource\fP builtins), the shell simulates +a call to \fBreturn\fP. +.TP +.B 4. +.SM +.B BASH_ARGC +and +.SM +.B BASH_ARGV +are updated as described in their descriptions above. +.TP +.B 5. +Function tracing is enabled: command substitution, shell functions, and +subshells invoked with \fB(\fP \fIcommand\fP \fB)\fP inherit the +\fBDEBUG\fP and \fBRETURN\fP traps. +.TP +.B 6. +Error tracing is enabled: command substitution, shell functions, and +subshells invoked with \fB(\fP \fIcommand\fP \fB)\fP inherit the +\fBERR\fP trap. +.RE +.TP 8 +.B extglob +If set, the extended pattern matching features described above under +\fBPathname Expansion\fP are enabled. +.TP 8 +.B extquote +If set, \fB$\fP\(aq\fIstring\fP\(aq and \fB$\fP"\fIstring\fP" quoting is +performed within \fB${\fP\fIparameter\fP\fB}\fP expansions +enclosed in double quotes. This option is enabled by default. +.TP 8 +.B failglob +If set, patterns which fail to match filenames during pathname expansion +result in an expansion error. +.TP 8 +.B force_fignore +If set, the suffixes specified by the +.SM +.B FIGNORE +shell variable +cause words to be ignored when performing word completion even if +the ignored words are the only possible completions. +See +.SM +\fBSHELL VARIABLES\fP +above for a description of +.SM +.BR FIGNORE . +This option is enabled by default. +.TP 8 +.B globasciiranges +If set, range expressions used in pattern matching bracket expressions (see +.SM +.B Pattern Matching +above) behave as if in the traditional C locale when performing +comparisons. That is, the current locale's collating sequence +is not taken into account, so +.B b +will not collate between +.B A +and +.BR B , +and upper-case and lower-case ASCII characters will collate together. +.TP 8 +.B globstar +If set, the pattern \fB**\fP used in a pathname expansion context will +match all files and zero or more directories and subdirectories. +If the pattern is followed by a \fB/\fP, only directories and +subdirectories match. +.TP 8 +.B gnu_errfmt +If set, shell error messages are written in the standard GNU error +message format. +.TP 8 +.B histappend +If set, the history list is appended to the file named by the value +of the +.SM +.B HISTFILE +variable when the shell exits, rather than overwriting the file. +.TP 8 +.B histreedit +If set, and +.B readline +is being used, a user is given the opportunity to re-edit a +failed history substitution. +.TP 8 +.B histverify +If set, and +.B 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 \fBreadline\fP editing buffer, allowing further modification. +.TP 8 +.B hostcomplete +If set, and +.B readline +is being used, \fBbash\fP will attempt to perform hostname completion when a +word containing a \fB@\fP is being completed (see +.B Completing +under +.SM +.B READLINE +above). +This is enabled by default. +.TP 8 +.B huponexit +If set, \fBbash\fP will send +.SM +.B SIGHUP +to all jobs when an interactive login shell exits. +.TP 8 +.B inherit_errexit +If set, command substitution inherits the value of the \fBerrexit\fP option, +instead of unsetting it in the subshell environment. +This option is enabled when \fIposix mode\fP is enabled. +.TP 8 +.B interactive_comments +If set, allow a word beginning with +.B # +to cause that word and all remaining characters on that +line to be ignored in an interactive shell (see +.SM +.B COMMENTS +above). This option is enabled by default. +.TP 8 +.B lastpipe +If set, and job control is not active, the shell runs the last command of +a pipeline not executed in the background in the current shell environment. +.TP 8 +.B lithist +If set, and the +.B cmdhist +option is enabled, multi-line commands are saved to the history with +embedded newlines rather than using semicolon separators where possible. +.TP 8 +.B login_shell +The shell sets this option if it is started as a login shell (see +.SM +.B "INVOCATION" +above). +The value may not be changed. +.TP 8 +.B mailwarn +If set, and a file that \fBbash\fP is checking for mail has been +accessed since the last time it was checked, the message ``The mail in +\fImailfile\fP has been read'' is displayed. +.TP 8 +.B no_empty_cmd_completion +If set, and +.B readline +is being used, +.B bash +will not attempt to search the +.SM +.B PATH +for possible completions when +completion is attempted on an empty line. +.TP 8 +.B nocaseglob +If set, +.B bash +matches filenames in a case\-insensitive fashion when performing pathname +expansion (see +.B Pathname Expansion +above). +.TP 8 +.B nocasematch +If set, +.B bash +matches patterns in a case\-insensitive fashion when performing matching +while executing \fBcase\fP or \fB[[\fP conditional commands, +when performing pattern substitution word expansions, +or when filtering possible completions as part of programmable completion. +.TP 8 +.B nullglob +If set, +.B bash +allows patterns which match no +files (see +.B Pathname Expansion +above) +to expand to a null string, rather than themselves. +.TP 8 +.B progcomp +If set, the programmable completion facilities (see +\fBProgrammable Completion\fP above) are enabled. +This option is enabled by default. +.TP 8 +.B promptvars +If set, prompt strings undergo +parameter expansion, command substitution, arithmetic +expansion, and quote removal after being expanded as described in +.SM +.B PROMPTING +above. This option is enabled by default. +.TP 8 +.B restricted_shell +The shell sets this option if it is started in restricted mode (see +.SM +.B "RESTRICTED SHELL" +below). +The value may not be changed. +This is not reset when the startup files are executed, allowing +the startup files to discover whether or not a shell is restricted. +.TP 8 +.B shift_verbose +If set, the +.B shift +builtin prints an error message when the shift count exceeds the +number of positional parameters. +.TP 8 +.B sourcepath +If set, the +\fBsource\fP (\fB.\fP) builtin uses the value of +.SM +.B PATH +to find the directory containing the file supplied as an argument. +This option is enabled by default. +.TP 8 +.B xpg_echo +If set, the \fBecho\fP builtin expands backslash-escape sequences +by default. +.RE +.PD +.TP +\fBsuspend\fP [\fB\-f\fP] +Suspend the execution of this shell until it receives a +.SM +.B SIGCONT +signal. A login shell cannot be suspended; the +.B \-f +option can be used to override this and force the suspension. +The return status is 0 unless the shell is a login shell and +.B \-f +is not supplied, or if job control is not enabled. +.TP +\fBtest\fP \fIexpr\fP +.PD 0 +.TP +\fB[\fP \fIexpr\fP \fB]\fP +Return a status of 0 (true) or 1 (false) depending on +the evaluation of the conditional expression +.IR expr . +Each operator and operand must be a separate argument. +Expressions are composed of the primaries described above under +.SM +.BR "CONDITIONAL EXPRESSIONS" . +\fBtest\fP does not accept any options, nor does it accept and ignore +an argument of \fB\-\-\fP as signifying the end of options. +.if t .sp 0.5 +.if n .sp 1 +Expressions may be combined using the following operators, listed +in decreasing order of precedence. +The evaluation depends on the number of arguments; see below. +Operator precedence is used when there are five or more arguments. +.RS +.PD 0 +.TP +.B ! \fIexpr\fP +True if +.I expr +is false. +.TP +.B ( \fIexpr\fP ) +Returns the value of \fIexpr\fP. +This may be used to override the normal precedence of operators. +.TP +\fIexpr1\fP \-\fBa\fP \fIexpr2\fP +True if both +.I expr1 +and +.I expr2 +are true. +.TP +\fIexpr1\fP \-\fBo\fP \fIexpr2\fP +True if either +.I expr1 +or +.I expr2 +is true. +.PD +.PP +\fBtest\fP and \fB[\fP evaluate conditional +expressions using a set of rules based on the number of arguments. +.if t .sp 0.5 +.if n .sp 1 +.PD 0 +.TP +0 arguments +The expression is false. +.TP +1 argument +The expression is true if and only if the argument is not null. +.TP +2 arguments +If the first argument is \fB!\fP, the expression is true if and +only if the second argument is null. +If the first argument is one of the unary conditional operators listed above +under +.SM +.BR "CONDITIONAL EXPRESSIONS" , +the expression is true if the unary test is true. +If the first argument is not a valid unary conditional operator, the expression +is false. +.TP +3 arguments +The following conditions are applied in the order listed. +If the second argument is one of the binary conditional operators listed above +under +.SM +.BR "CONDITIONAL EXPRESSIONS" , +the result of the expression is the result of the binary test using +the first and third arguments as operands. +The \fB\-a\fP and \fB\-o\fP operators are considered binary operators +when there are three arguments. +If the first argument is \fB!\fP, the value is the negation of +the two-argument test using the second and third arguments. +If the first argument is exactly \fB(\fP and the third argument is +exactly \fB)\fP, the result is the one-argument test of the second +argument. +Otherwise, the expression is false. +.TP +4 arguments +If the first argument is \fB!\fP, 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. +.TP +5 or more arguments +The expression is parsed and evaluated according to precedence +using the rules listed above. +.if t .sp 0.5 +.if n .sp 1 +.LP +When used with \fBtest\fP or \fB[\fP, the \fB<\fP and \fB>\fP operators +sort lexicographically using ASCII ordering. +.RE +.PD +.TP +.B times +Print the accumulated user and system times for the shell and +for processes run from the shell. The return status is 0. +.TP +\fBtrap\fP [\fB\-lp\fP] [[\fIarg\fP] \fIsigspec\fP ...] +The command +.I arg +is to be read and executed when the shell receives +signal(s) +.IR sigspec . +If +.I arg +is absent (and there is a single \fIsigspec\fP) or +.BR \- , +each specified signal is +reset to its original disposition (the value it had +upon entrance to the shell). +If +.I arg +is the null string the signal specified by each +.I sigspec +is ignored by the shell and by the commands it invokes. +If +.I arg +is not present and +.B \-p +has been supplied, then the trap commands associated with each +.I sigspec +are displayed. +If no arguments are supplied or if only +.B \-p +is given, +.B trap +prints the list of commands associated with each signal. +The +.B \-l +option causes the shell to print a list of signal names and +their corresponding numbers. +Each +.I sigspec +is either +a signal name defined in <\fIsignal.h\fP>, or a signal number. +Signal names are case insensitive and the +.SM +.B SIG +prefix is optional. +.if t .sp 0.5 +.if n .sp 1 +If a +.I sigspec +is +.SM +.B EXIT +(0) the command +.I arg +is executed on exit from the shell. +If a +.I sigspec +is +.SM +.BR DEBUG , +the command +.I arg +is executed before every \fIsimple command\fP, \fIfor\fP command, +\fIcase\fP command, \fIselect\fP command, every arithmetic \fIfor\fP +command, and before the first command executes in a shell function (see +.SM +.B SHELL GRAMMAR +above). +Refer to the description of the \fBextdebug\fP option to the +\fBshopt\fP builtin for details of its effect on the \fBDEBUG\fP trap. +If a +.I sigspec +is +.SM +.BR RETURN , +the command +.I arg +is executed each time a shell function or a script executed with +the \fB.\fP or \fBsource\fP builtins finishes executing. +.if t .sp 0.5 +.if n .sp 1 +If a +.I sigspec +is +.SM +.BR ERR , +the command +.I arg +is executed whenever +a pipeline (which may consist of a single simple +command), a list, or a compound command returns a +non\-zero exit status, +subject to the following conditions. +The +.SM +.B ERR +trap is not executed if the failed +command is part of the command list immediately following a +.B while +or +.B until +keyword, +part of the test in an +.I if +statement, part of a command executed in a +.B && +or +.B || +list except the command following the final \fB&&\fP or \fB||\fP, +any command in a pipeline but the last, +or if the command's return value is +being inverted using +.BR ! . +These are the same conditions obeyed by the \fBerrexit\fP (\fB\-e\fP) option. +.if t .sp 0.5 +.if n .sp 1 +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 subshell or subshell environment when one is created. +The return status is false if any +.I sigspec +is invalid; otherwise +.B trap +returns true. +.TP +\fBtype\fP [\fB\-aftpP\fP] \fIname\fP [\fIname\fP ...] +With no options, +indicate how each +.I name +would be interpreted if used as a command name. +If the +.B \-t +option is used, +.B type +prints a string which is one of +.IR alias , +.IR keyword , +.IR function , +.IR builtin , +or +.I file +if +.I name +is an alias, shell reserved word, function, builtin, or disk file, +respectively. +If the +.I name +is not found, then nothing is printed, and an exit status of false +is returned. +If the +.B \-p +option is used, +.B type +either returns the name of the disk file +that would be executed if +.I name +were specified as a command name, +or nothing if +.if t \f(CWtype -t name\fP +.if n ``type -t name'' +would not return +.IR file . +The +.B \-P +option forces a +.SM +.B PATH +search for each \fIname\fP, even if +.if t \f(CWtype -t name\fP +.if n ``type -t name'' +would not return +.IR file . +If a command is hashed, +.B \-p +and +.B \-P +print the hashed value, which is not necessarily the file that appears +first in +.SM +.BR PATH . +If the +.B \-a +option is used, +.B type +prints all of the places that contain +an executable named +.IR name . +This includes aliases and functions, +if and only if the +.B \-p +option is not also used. +The table of hashed commands is not consulted +when using +.BR \-a . +The +.B \-f +option suppresses shell function lookup, as with the \fBcommand\fP builtin. +.B type +returns true if all of the arguments are found, false if +any are not found. +.TP +\fBulimit\fP [\fB\-HSabcdefiklmnpqrstuvxPT\fP [\fIlimit\fP]] +Provides control over the resources available to the shell and to +processes started by it, on systems that allow such control. +The \fB\-H\fP and \fB\-S\fP options specify that the hard or soft limit is +set for the given resource. +A hard limit cannot be increased by a non-root user once it is set; +a soft limit may be increased up to the value of the hard limit. +If neither \fB\-H\fP nor \fB\-S\fP is specified, both the soft and hard +limits are set. +The value of +.I limit +can be a number in the unit specified for the resource +or one of the special values +.BR hard , +.BR soft , +or +.BR unlimited , +which stand for the current hard limit, the current soft limit, and +no limit, respectively. +If +.I limit +is omitted, the current value of the soft limit of the resource is +printed, unless the \fB\-H\fP option is given. When more than one +resource is specified, the limit name and unit are printed before the value. +Other options are interpreted as follows: +.RS +.PD 0 +.TP +.B \-a +All current limits are reported +.TP +.B \-b +The maximum socket buffer size +.TP +.B \-c +The maximum size of core files created +.TP +.B \-d +The maximum size of a process's data segment +.TP +.B \-e +The maximum scheduling priority ("nice") +.TP +.B \-f +The maximum size of files written by the shell and its children +.TP +.B \-i +The maximum number of pending signals +.TP +.B \-k +The maximum number of kqueues that may be allocated +.TP +.B \-l +The maximum size that may be locked into memory +.TP +.B \-m +The maximum resident set size (many systems do not honor this limit) +.TP +.B \-n +The maximum number of open file descriptors (most systems do not +allow this value to be set) +.TP +.B \-p +The pipe size in 512-byte blocks (this may not be set) +.TP +.B \-q +The maximum number of bytes in POSIX message queues +.TP +.B \-r +The maximum real-time scheduling priority +.TP +.B \-s +The maximum stack size +.TP +.B \-t +The maximum amount of cpu time in seconds +.TP +.B \-u +The maximum number of processes available to a single user +.TP +.B \-v +The maximum amount of virtual memory available to the shell and, on +some systems, to its children +.TP +.B \-x +The maximum number of file locks +.TP +.B \-P +The maximum number of pseudoterminals +.TP +.B \-T +The maximum number of threads +.PD +.PP +If +.I limit +is given, and the +.B \-a +option is not used, +\fIlimit\fP is the new value of the specified resource. +If no option is given, then +.B \-f +is assumed. Values are in 1024-byte increments, except for +.BR \-t , +which is in seconds; +.BR \-p , +which is in units of 512-byte blocks; +.BR \-P , +.BR \-T , +.BR \-b , +.BR \-k , +.BR \-n , +and +.BR \-u , +which are unscaled values; +and, when in Posix mode, +.B \-c +and +.BR \-f , +which are in 512-byte increments. +The return status is 0 unless an invalid option or argument is supplied, +or an error occurs while setting a new limit. +.RE +.TP +\fBumask\fP [\fB\-p\fP] [\fB\-S\fP] [\fImode\fP] +The user file-creation mask is set to +.IR mode . +If +.I mode +begins with a digit, it +is interpreted as an octal number; otherwise +it is interpreted as a symbolic mode mask similar +to that accepted by +.IR chmod (1). +If +.I mode +is omitted, the current value of the mask is printed. +The +.B \-S +option causes the mask to be printed in symbolic form; the +default output is an octal number. +If the +.B \-p +option is supplied, and +.I mode +is omitted, the output is in a form that may be reused as input. +The return status is 0 if the mode was successfully changed or if +no \fImode\fP argument was supplied, and false otherwise. +.TP +\fBunalias\fP [\-\fBa\fP] [\fIname\fP ...] +Remove each \fIname\fP from the list of defined aliases. If +.B \-a +is supplied, all alias definitions are removed. The return +value is true unless a supplied +.I name +is not a defined alias. +.TP +\fBunset\fP [\-\fBfv\fP] [\-\fBn\fP] [\fIname\fP ...] +For each +.IR name , +remove the corresponding variable or function. +If the +.B \-v +option is given, each +.I name +refers to a shell variable, and that variable is removed. +Read-only variables may not be unset. +If +.B \-f +is specified, each +.I name +refers to a shell function, and the function definition +is removed. +If the +.B \-n +option is supplied, and \fIname\fP is a variable with the \fInameref\fP +attribute, \fIname\fP will be unset rather than the variable it +references. +\fB\-n\fP has no effect if the \fB\-f\fP option is supplied. +If no options are supplied, each \fIname\fP refers to a variable; if +there is no variable by that name, any function with that name is +unset. +Each unset variable or function is removed from the environment +passed to subsequent commands. +If any of +.SM +.BR COMP_WORDBREAKS , +.SM +.BR RANDOM , +.SM +.BR SECONDS , +.SM +.BR LINENO , +.SM +.BR HISTCMD , +.SM +.BR FUNCNAME , +.SM +.BR GROUPS , +or +.SM +.B DIRSTACK +are unset, they lose their special properties, even if they are +subsequently reset. The exit status is true unless a +.I name +is readonly. +.TP +\fBwait\fP [\fB\-n\fP] [\fIn ...\fP] +Wait for each specified child process and return its termination status. +Each +.I n +may be a process +ID or a job specification; if a job spec is given, all processes +in that job's pipeline are waited for. If +.I n +is not given, all currently active child processes +are waited for, and the return status is zero. +If the \fB\-n\fP option is supplied, \fBwait\fP waits for any job to +terminate and returns its exit status. +If +.I n +specifies a non-existent process or job, the return status is +127. Otherwise, the return status is the exit status of the last +process or job waited for. +.\" bash_builtins +.if \n(zZ=1 .ig zZ +.SH "RESTRICTED SHELL" +.\" rbash.1 +.zY +.PP +If +.B bash +is started with the name +.BR rbash , +or the +.B \-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. +It behaves identically to +.B bash +with the exception that the following are disallowed or not performed: +.IP \(bu +changing directories with \fBcd\fP +.IP \(bu +setting or unsetting the values of +.SM +.BR SHELL , +.SM +.BR PATH , +.SM +.BR ENV , +or +.SM +.B BASH_ENV +.IP \(bu +specifying command names containing +.B / +.IP \(bu +specifying a filename containing a +.B / +as an argument to the +.B . +builtin command +.IP \(bu +specifying a filename containing a slash as an argument to the +.B \-p +option to the +.B hash +builtin command +.IP \(bu +importing function definitions from the shell environment at startup +.IP \(bu +parsing the value of +.SM +.B SHELLOPTS +from the shell environment at startup +.IP \(bu +redirecting output using the >, >|, <>, >&, &>, and >> redirection operators +.IP \(bu +using the +.B exec +builtin command to replace the shell with another command +.IP \(bu +adding or deleting builtin commands with the +.B \-f +and +.B \-d +options to the +.B enable +builtin command +.IP \(bu +using the \fBenable\fP builtin command to enable disabled shell builtins +.IP \(bu +specifying the +.B \-p +option to the +.B command +builtin command +.IP \(bu +turning off restricted mode with +\fBset +r\fP or \fBset +o restricted\fP. +.PP +These restrictions are enforced after any startup files are read. +.PP +.ie \n(zY=1 When a command that is found to be a shell script is executed, +.el \{ When a command that is found to be a shell script is executed +(see +.SM +.B "COMMAND EXECUTION" +above), +\} +.B rbash +turns off any restrictions in the shell spawned to execute the +script. +.\" end of rbash.1 +.if \n(zY=1 .ig zY +.SH "SEE ALSO" +.PD 0 +.TP +\fIBash Reference Manual\fP, Brian Fox and Chet Ramey +.TP +\fIThe Gnu Readline Library\fP, Brian Fox and Chet Ramey +.TP +\fIThe Gnu History Library\fP, Brian Fox and Chet Ramey +.TP +\fIPortable Operating System Interface (POSIX) Part 2: Shell and Utilities\fP, IEEE -- +http://pubs.opengroup.org/onlinepubs/9699919799/ +.TP +http://tiswww.case.edu/~chet/bash/POSIX -- a description of posix mode +.TP +\fIsh\fP(1), \fIksh\fP(1), \fIcsh\fP(1) +.TP +\fIemacs\fP(1), \fIvi\fP(1) +.TP +\fIreadline\fP(3) +.PD +.SH FILES +.PD 0 +.TP +.FN /bin/bash +The \fBbash\fP executable +.TP +.FN /etc/profile +The systemwide initialization file, executed for login shells +.TP +.FN ~/.bash_profile +The personal initialization file, executed for login shells +.TP +.FN ~/.bashrc +The individual per-interactive-shell startup file +.TP +.FN ~/.bash_logout +The individual login shell cleanup file, executed when a login shell exits +.TP +.FN ~/.inputrc +Individual \fIreadline\fP initialization file +.PD +.SH AUTHORS +Brian Fox, Free Software Foundation +.br +bfox@gnu.org +.PP +Chet Ramey, Case Western Reserve University +.br +chet.ramey@case.edu +.SH BUG REPORTS +If you find a bug in +.B bash, +you should report it. But first, you should +make sure that it really is a bug, and that it appears in the latest +version of +.BR bash . +The latest version is always available from +\fIftp://ftp.gnu.org/pub/gnu/bash/\fP. +.PP +Once you have determined that a bug actually exists, use the +.I bashbug +command to submit a bug report. +If you have a fix, you are encouraged to mail that as well! +Suggestions and `philosophical' bug reports may be mailed +to \fIbug-bash@gnu.org\fP or posted to the Usenet +newsgroup +.BR gnu.bash.bug . +.PP +ALL bug reports should include: +.PP +.PD 0 +.TP 20 +The version number of \fBbash\fR +.TP +The hardware and operating system +.TP +The compiler used to compile +.TP +A description of the bug behaviour +.TP +A short script or `recipe' which exercises the bug +.PD +.PP +.I bashbug +inserts the first three items automatically into the template +it provides for filing a bug report. +.PP +Comments and bug reports concerning +this manual page should be directed to +.IR chet.ramey@case.edu . +.SH BUGS +.PP +It's too big and too slow. +.PP +There are some subtle differences between +.B bash +and traditional versions of +.BR sh , +mostly because of the +.SM +.B POSIX +specification. +.PP +Aliases are confusing in some uses. +.PP +Shell builtin commands and functions are not stoppable/restartable. +.PP +Compound commands and command sequences of the form `a ; b ; c' +are not handled gracefully when process suspension is attempted. +When a process is stopped, the shell immediately executes the next +command in the sequence. +It suffices to place the sequence of commands between +parentheses to force it into a subshell, which may be stopped as +a unit. +.PP +Array variables may not (yet) be exported. +.PP +There may be only one active coprocess at a time. +.zZ +.zY diff --git a/doc/bash.html b/doc/bash.html new file mode 100644 index 0000000..983284e --- /dev/null +++ b/doc/bash.html @@ -0,0 +1,13640 @@ + +BASH(1) Manual Page + + + + +
BASH(1)2016 August 26BASH(1) +
+
Index +
+ + + + + + + + + + + + + + + + + + + +  +

NAME

+ +bash - GNU Bourne-Again SHell +  +

SYNOPSIS

+ +bash + +[options] +[command_string | file] +  +

COPYRIGHT

+ + +Bash is Copyright © 1989-2016 by the Free Software Foundation, Inc. +  +

DESCRIPTION

+ +Bash + +is an sh-compatible command language interpreter that +executes commands read from the standard input or from a file. +Bash + +also incorporates useful features from the Korn and C +shells (ksh and csh). +

+ +Bash + +is intended to be a conformant implementation of the +Shell and Utilities portion of the IEEE POSIX specification +(IEEE Standard 1003.1). +Bash + +can be configured to be POSIX-conformant by default. +  +

OPTIONS

+ +All of the single-character shell options documented in the +description of the set builtin command can be used as options +when the shell is invoked. +In addition, bash +interprets the following options when it is invoked: +

+ + +

+
-c + +
+If the +-c + +option is present, then commands are read from the first non-option argument +command_string. + +If there are arguments after the +command_string, + +the first argument is assigned to +$0 + +and any remaining arguments are assigned to the positional parameters. +The assignment to +$0 + +sets the name of the shell, which is used in warning and error messages. +
-i + +
+If the +-i + +option is present, the shell is +interactive. + +
-l + +
+Make +bash + +act as if it had been invoked as a login shell (see +INVOCATION + + +below). +
-r + +
+If the +-r + +option is present, the shell becomes +restricted + +(see +RESTRICTED SHELL + + +below). +
-s + +
+If the +-s + +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. +
-D + +
+A list of all double-quoted strings preceded by $ +is printed on the standard output. +These are the strings that +are subject to language translation when the current locale +is not C or POSIX. +This implies the -n option; no commands will be executed. +
[-+]O [shopt_option] + +
+shopt_option is one of the shell options accepted by the +shopt builtin (see +SHELL BUILTIN COMMANDS + + +below). +If shopt_option is present, -O sets the value of that option; ++O unsets it. +If shopt_option is not supplied, the names and values of the shell +options accepted by shopt are printed on the standard output. +If the invocation option is +O, the output is displayed in a format +that may be reused as input. +
-- + +
+A +-- + +signals the end of options and disables further option processing. +Any arguments after the +-- + +are treated as filenames and arguments. An argument of +- + +is equivalent to --. + +
+

+ +Bash + +also interprets a number of multi-character options. +These options must appear on the command line before the +single-character options to be recognized. +

+ + +

+
--debugger + +
+Arrange for the debugger profile to be executed before the shell +starts. +Turns on extended debugging mode (see the description of the +extdebug + +option to the +shopt + +builtin below). +
--dump-po-strings + +
+Equivalent to -D, but the output is in the GNU gettext +po (portable object) file format. +
--dump-strings + +
+Equivalent to -D. +
--help + +
+Display a usage message on standard output and exit successfully. +
--init-file file
+ +
--rcfile file
+ +Execute commands from +file + +instead of the standard personal initialization file +~/.bashrc + +if the shell is interactive (see +INVOCATION + + +below). +
--login + +
+Equivalent to -l. +
--noediting + +
+Do not use the GNU +readline + +library to read command lines when the shell is interactive. +
--noprofile + +
+Do not read either the system-wide startup file + +/etc/profile + +or any of the personal initialization files +~/.bash_profile, + +~/.bash_login, + +or +~/.profile. + +By default, +bash + +reads these files when it is invoked as a login shell (see +INVOCATION + + +below). +
--norc + +
+Do not read and execute the personal initialization file +~/.bashrc + +if the shell is interactive. +This option is on by default if the shell is invoked as +sh. + +
--posix + +
+Change the behavior of bash where the default operation differs +from the POSIX standard to match the standard (posix mode). +See +SEE ALSO + + +below for a reference to a document that details how posix mode affects +bash's behavior. +
--restricted + +
+The shell becomes restricted (see +RESTRICTED SHELL + + +below). +
--verbose + +
+Equivalent to -v. +
--version + +
+Show version information for this instance of +bash + +on the standard output and exit successfully. + +
+  +

ARGUMENTS

+ +If arguments remain after option processing, and neither the +-c + +nor the +-s + +option has been supplied, the first argument is assumed to +be the name of a file containing shell commands. +If +bash + +is invoked in this fashion, +$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. +An attempt is first made to open the file in the current directory, and, +if no file is found, then the shell searches the directories in +PATH + + +for the script. +  +

INVOCATION

+ +A login shell is one whose first character of argument zero is a +-, + +or one started with the +--login + +option. +

+ +An interactive shell is one started without non-option arguments +(unless -s is specified) +and without the +-c + +option +whose standard input and error are +both connected to terminals (as determined by +isatty(3)), + +or one started with the +-i + +option. +PS1 + + +is set and +$- + +includes +i + +if +bash + +is interactive, +allowing a shell script or a startup file to test this state. +

+ +The following paragraphs describe how +bash + +executes its startup files. +If any of the files exist but cannot be read, +bash + +reports an error. +Tildes are expanded in filenames as described below under +Tilde Expansion + +in the +EXPANSION + + +section. +

+ +When +bash + +is invoked as an interactive login shell, or as a non-interactive shell +with the --login option, it first reads and +executes commands from the file /etc/profile, if that +file exists. +After reading that file, it looks for ~/.bash_profile, +~/.bash_login, and ~/.profile, in that order, and reads +and executes commands from the first one that exists and is readable. +The +--noprofile + +option may be used when the shell is started to inhibit this behavior. +

+ +When an interactive login shell exits, +or a non-interactive login shell executes the exit builtin command, +bash + +reads and executes commands from the file ~/.bash_logout, if it +exists. +

+ +When an interactive shell that is not a login shell is started, +bash + +reads and executes commands from ~/.bashrc, if that file exists. +This may be inhibited by using the +--norc + +option. +The --rcfile file option will force +bash + +to read and execute commands from file instead of ~/.bashrc. +

+ +When +bash + +is started non-interactively, to run a shell script, for example, it +looks for the variable +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: +

+

+if [ -n "$BASH_ENV" ]; then . "$BASH_ENV"; fi + +
+ +

+but the value of the +PATH + + +variable is not used to search for the filename. +

+ +If +bash + +is invoked with the name +sh, + +it tries to mimic the startup behavior of historical versions of +sh + +as closely as possible, +while conforming to the POSIX standard as well. +When invoked as an interactive login shell, or a non-interactive +shell with the --login option, it first attempts to +read and execute commands from +/etc/profile + +and +~/.profile, + +in that order. +The +--noprofile + +option may be used to inhibit this behavior. +When invoked as an interactive shell with the name +sh, + +bash + +looks for the variable +ENV, + + +expands its value if it is defined, and uses the +expanded value as the name of a file to read and execute. +Since a shell invoked as +sh + +does not attempt to read and execute commands from any other startup +files, the +--rcfile + +option has no effect. +A non-interactive shell invoked with the name +sh + +does not attempt to read any other startup files. +When invoked as +sh, + +bash + +enters +posix + +mode after the startup files are read. +

+ +When +bash + +is started in +posix + +mode, as with the +--posix + +command line option, it follows the POSIX standard for startup files. +In this mode, interactive shells expand the +ENV + + +variable and commands are read and executed from the file +whose name is the expanded value. +No other startup files are read. +

+ +Bash + +attempts to determine when it is being run with its standard input +connected to a network connection, as when executed by the remote shell +daemon, usually rshd, or the secure shell daemon sshd. +If +bash + +determines it is being run in this fashion, it reads and executes +commands from ~/.bashrc, if that file exists and is readable. +It will not do this if invoked as sh. +The +--norc + +option may be used to inhibit this behavior, and the +--rcfile + +option may be used to force another file to be read, but neither +rshd nor sshd generally invoke the shell with those options +or allow them to be specified. +

+ +If the shell is started with the effective user (group) id not equal to the +real user (group) id, and the -p option is not supplied, no startup +files are read, shell functions are not inherited from the environment, the +SHELLOPTS, + + +BASHOPTS, + + +CDPATH, + + +and +GLOBIGNORE + + +variables, if they appear in the environment, are ignored, +and the effective user id is set to the real user id. +If the -p option is supplied at invocation, the startup behavior is +the same, but the effective user id is not reset. +  +

DEFINITIONS

+ +

+ +The following definitions are used throughout the rest of this +document. + +

+
blank + +
+A space or tab. +
word + +
+A sequence of characters considered as a single unit by the shell. +Also known as a +token. + +
name + +
+A +word + +consisting only of alphanumeric characters and underscores, and +beginning with an alphabetic character or an underscore. Also +referred to as an +identifier. + +
metacharacter + +
+A character that, when unquoted, separates words. One of the following: +
+ +
+

+ +| & ; ( ) < > space tab newline + +

+ +
+

+ +

+
control operator + +
+A token that performs a control function. It is one of the following +symbols: +
+

+ +|| & && ; ;; ;& ;;& ( ) | |& <newline> + +

+ + +
+  +

RESERVED WORDS

+ +Reserved words are words that have a special meaning to the shell. +The following words are recognized as reserved when unquoted and either +the first word of a simple command (see +SHELL GRAMMAR + + +below) or the third word of a +case + +or +for + +command: +
+ +

+ + + + +! case coproc do done elif else esac fi for function if in select then until while { } time [[ ]] +

+ + +  +

SHELL GRAMMAR

+ +  +

Simple Commands

+ +

+ +A simple command is a sequence of optional variable assignments +followed by blank-separated words and redirections, and +terminated by a control operator. The first word +specifies the command to be executed, and is passed as argument zero. +The remaining words are passed as arguments to the invoked command. +

+ +The return value of a simple command is its exit status, or +128+n if the command is terminated by signal +n. + +  +

Pipelines

+ +

+ +A pipeline is a sequence of one or more commands separated by +one of the control operators +| + +or |&. +The format for a pipeline is: +

+

+ +[time [-p]] [ ! ] command [ [|||&] command2 ... ] +

+ +

+ +The standard output of +command + +is connected via a pipe to the standard input of +command2. + +This connection is performed before any redirections specified by the +command (see +REDIRECTION + + +below). +If |& is used, command's standard error, in addition to its +standard output, is connected to +command2's standard input through the pipe; +it is shorthand for 2>&1 |. +This implicit redirection of the standard error to the standard output is +performed after any redirections specified by the command. +

+ +The return status of a pipeline is the exit status of the last +command, unless the pipefail option is enabled. +If 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 +! + +precedes a pipeline, the exit status of that pipeline 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. +

+ +If the +time + +reserved word precedes a pipeline, the elapsed as well as user and +system time consumed by its execution are reported when the pipeline +terminates. +The -p option changes the output format to that specified by POSIX. +When the shell is in posix mode, it does not recognize +time as a reserved word if the next token begins with a `-'. +The +TIMEFORMAT + + +variable may be set to a format string that specifies how the timing +information should be displayed; see the description of +TIMEFORMAT + + +under +Shell Variables + +below. +

+ +When the shell is in posix mode, time +may be followed by a newline. In this case, the shell displays the +total user and system time consumed by the shell and its children. +The +TIMEFORMAT + + +variable may be used to specify the format of +the time information. +

+ +Each command in a pipeline is executed as a separate process (i.e., in a +subshell). +  +

Lists

+ +

+ +A list is a sequence of one or more pipelines separated by one +of the operators +;, + +&, + +&&, + +or +||, + +and optionally terminated by one of +;, + +&, + +or +<newline>. + +

+ +Of these list operators, +&& + +and +|| + +have equal precedence, followed by +; + +and +&, + +which have equal precedence. +

+ +A sequence of one or more newlines may appear in a list instead +of a semicolon to delimit commands. +

+ +If a command is terminated by the control operator +&, + +the shell executes the command in the background +in a subshell. The shell does not wait for the command to +finish, and the return status is 0. Commands separated by a +; + +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. +

+ +AND and OR lists are sequences of one or more pipelines separated by the +&& and || control operators, respectively. +AND and OR lists are executed with left associativity. +An AND list has the form +

+

+ +command1 && command2 +

+ +

+ +command2 + +is executed if, and only if, +command1 + +returns an exit status of zero. +

+ +An OR list has the form +

+

+ +command1 || command2 +

+ +

+ +

+ +command2 + +is executed if and only if +command1 + +returns a non-zero exit status. +The return status of +AND and OR lists is the exit status of the last command +executed in the list. +  +

Compound Commands

+ +

+ +A compound command is one of the following. +In most cases a list in a command's description may be separated from +the rest of the command by one or more newlines, and may be followed by a +newline in place of a semicolon. +

+
(list)
+list is executed in a subshell environment (see +COMMAND EXECUTION ENVIRONMENT +below). +Variable assignments and builtin +commands that affect the shell's environment do not remain in effect +after the command completes. The return status is the exit status of +list. +
{ list; }
+list is simply executed in the current shell environment. +list must be terminated with a newline or semicolon. +This is known as a group command. +The return status is the exit status of +list. +Note that unlike the metacharacters ( and ), { and +} are reserved words and must occur where a reserved +word is permitted to be recognized. Since they do not cause a word +break, they must be separated from list by whitespace or another +shell metacharacter. +
((expression))
+The expression is evaluated according to the rules described +below under +ARITHMETIC EVALUATION. + + +If the value of the expression is non-zero, the return status is 0; +otherwise the return status is 1. This is exactly equivalent to +let "expression". +
[[ expression ]]
+Return a status of 0 or 1 depending on the evaluation of +the conditional expression expression. +Expressions are composed of the primaries described below under +CONDITIONAL EXPRESSIONS. + + +Word splitting and pathname expansion are not performed on the words +between the [[ and ]]; tilde expansion, +parameter and variable expansion, +arithmetic expansion, command substitution, process +substitution, and quote removal are performed. +Conditional operators such as -f must be unquoted to be recognized +as primaries. +

+ + +When used with [[, the < and > operators sort +lexicographically using the current locale. +

+ + +When the == and != operators are used, the string to the +right of the operator is considered a pattern and matched according +to the rules described below under Pattern Matching, +as if the extglob shell option were enabled. +The = operator is equivalent to ==. +If the +nocasematch + +shell option is enabled, the match is performed without regard to the case +of alphabetic characters. +The return value is 0 if the string matches (==) or does not match +(!=) the pattern, and 1 otherwise. +Any part of the pattern may be quoted to force the quoted portion +to be matched as a string. +

+ + +An additional binary operator, =~, is available, with the same +precedence as == and !=. +When it is used, the string to the right of the operator is considered +an extended regular expression and matched accordingly (as in 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 +nocasematch + +shell option is enabled, the match is performed without regard to the case +of alphabetic characters. +Any part of the pattern may be quoted to force the quoted portion +to be matched as a string. +Bracket expressions in regular expressions must be treated carefully, +since normal quoting characters lose their meanings between brackets. +If the pattern is stored in a shell variable, quoting the variable +expansion forces the entire pattern to be matched as a string. +Substrings matched by parenthesized subexpressions within the regular +expression are saved in the array variable +BASH_REMATCH. + + +The element of +BASH_REMATCH + + +with index 0 is the portion of the string +matching the entire regular expression. +The element of +BASH_REMATCH + + +with index n is the portion of the +string matching the nth parenthesized subexpression. +

+ + +Expressions may be combined using the following operators, listed +in decreasing order of precedence: +

+ + +

+ +
+
( expression ) + +
+Returns the value of expression. +This may be used to override the normal precedence of operators. +
! expression + +
+True if +expression + +is false. +
expression1 && expression2
+True if both +expression1 + +and +expression2 + +are true. +
expression1 || expression2
+True if either +expression1 + +or +expression2 + +is true. + +
+

+ +The && and || +operators do not evaluate expression2 if the value of +expression1 is sufficient to determine the return value of +the entire conditional expression. +

+ +
for name [ [ in [ word ... ] ] ; ] do list ; done
+The list of words following in is expanded, generating a list +of items. +The variable name is set to each element of this list +in turn, and list is executed each time. +If the in word is omitted, the for command executes +list once for each positional parameter that is set (see +PARAMETERS + + +below). +The return status is the exit status of the last command that executes. +If the expansion of the items following in results in an empty +list, no commands are executed, and the return status is 0. +
for (( expr1 ; expr2 ; expr3 )) ; do list ; done
+First, the arithmetic expression expr1 is evaluated according +to the rules described below under +ARITHMETIC EVALUATION. + + +The arithmetic expression expr2 is then evaluated repeatedly +until it evaluates to zero. +Each time expr2 evaluates to a non-zero value, list is +executed and the arithmetic expression 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 list +that is executed, or false if any of the expressions is invalid. +
select name [ in word ] ; do list ; done
+The list of words following in is expanded, generating a list +of items. The set of expanded words is printed on the standard +error, each preceded by a number. If the in +word is omitted, the positional parameters are printed (see +PARAMETERS + + +below). The +PS3 + + +prompt is then displayed and a line read from the standard input. +If the line consists of a number corresponding to one of +the displayed words, then the value of +name + +is set to that word. If the line is empty, the words and prompt +are displayed again. If EOF is read, the command completes. Any +other value read causes +name + +to be set to null. The line read is saved in the variable +REPLY. + + +The +list + +is executed after each selection until a +break + +command is executed. +The exit status of +select + +is the exit status of the last command executed in +list, + +or zero if no commands were executed. +
case word in [ [(] pattern [ | pattern ] +
+A case command first expands word, and tries to match +it against each pattern in turn, using the same matching rules +as for pathname expansion (see +Pathname Expansion + +below). +The word is expanded using tilde +expansion, parameter and variable expansion, arithmetic expansion, +command substitution, process substitution and quote removal. +Each pattern examined is expanded using tilde +expansion, parameter and variable expansion, arithmetic expansion, +command substitution, and process substitution. +If the +nocasematch + +shell option is enabled, the match is performed without regard to the case +of alphabetic characters. +When a match is found, the corresponding list is executed. +If the ;; operator is used, no subsequent matches are attempted after +the first pattern match. +Using ;& in place of ;; causes execution to continue with +the list associated with the next set of patterns. +Using ;;& in place of ;; causes the shell to test the next +pattern list in the statement, if any, and execute any associated list +on a successful match. +The exit status is zero if no +pattern matches. Otherwise, it is the exit status of the +last command executed in list. +
if list; then list; [ elif list; then list; ] ... [ else list; ] fi
+The +if + +list + +is executed. If its exit status is zero, the +then list is executed. Otherwise, each elif +list is executed in turn, and if its exit status is zero, +the corresponding then list is executed and the +command completes. Otherwise, the else list is +executed, if present. The exit status is the exit status of the +last command executed, or zero if no condition tested true. +
while list-1; do list-2; done
+ +
until list-1; do list-2; done
+ +The while command continuously executes the list +list-2 as long as the last command in the list list-1 returns +an exit status of zero. The until command is identical +to the while command, except that the test is negated: +list-2 + +is executed as long as the last command in +list-1 + +returns a non-zero exit status. +The exit status of the while and until commands +is the exit status +of the last command executed in list-2, or zero if +none was executed. +
+  +

Coprocesses

+ +

+ +A coprocess is a shell command preceded by the coproc reserved +word. +A coprocess is executed asynchronously in a subshell, as if the command +had been terminated with the & control operator, with a two-way pipe +established between the executing shell and the coprocess. +

+ +The format for a coprocess is: +

+

+ +coproc [NAME] command [redirections] +

+ +

+ +This creates a coprocess named NAME. +If NAME is not supplied, the default name is COPROC. +NAME must not be supplied if command is a simple +command (see above); otherwise, it is interpreted as the first word +of the simple command. +When the coprocess is executed, the shell creates an array variable (see +Arrays + +below) named NAME in the context of the executing shell. +The standard output of +command + +is connected via a pipe to a file descriptor in the executing shell, +and that file descriptor is assigned to NAME[0]. +The standard input of +command + +is connected via a pipe to a file descriptor in the executing shell, +and that file descriptor is assigned to NAME[1]. +This pipe is established before any redirections specified by the +command (see +REDIRECTION + + +below). +The file descriptors can be utilized as arguments to shell commands +and redirections using standard word expansions. +The file descriptors are not available in subshells. +The process ID of the shell spawned to execute the coprocess is +available as the value of the variable NAME_PID. +The wait +builtin command may be used to wait for the coprocess to terminate. +

+ +Since the coprocess is created as an asynchronous command, +the coproc command always returns success. +The return status of a coprocess is the exit status of command. +  +

Shell Function Definitions

+ +

+ +A shell function is an object that is called like a simple command and +executes a compound command with a new set of positional parameters. +Shell functions are declared as follows: +

+
name () compound-command [redirection]
+ +
function name [()] compound-command [redirection]
+ +This defines a function named name. +The reserved word function is optional. +If the function reserved word is supplied, the parentheses are optional. +The body of the function is the compound command +compound-command + +(see Compound Commands above). +That command is usually a list of commands between { and }, but +may be any command listed under Compound Commands above, +with one exception: If the function reserved word is used, but the +parentheses are not supplied, the braces are required. +compound-command is executed whenever name is specified as the +name of a simple command. +When in posix mode, name may not be the name of one of the +POSIX special builtins. +Any redirections (see +REDIRECTION + + +below) specified when a function is defined are performed +when the function is executed. +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. (See +FUNCTIONS + + +below.) +
+  +

COMMENTS

+ +In a non-interactive shell, or an interactive shell in which the +interactive_comments + +option to the +shopt + +builtin is enabled (see +SHELL BUILTIN COMMANDS + + +below), a word beginning with +# + +causes that word and all remaining characters on that line to +be ignored. An interactive shell without the +interactive_comments + +option enabled does not allow comments. The +interactive_comments + +option is on by default in interactive shells. +  +

QUOTING

+ +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 metacharacters listed above under +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 +(see +HISTORY EXPANSION + + +below), the +history expansion character, usually !, must be quoted +to prevent history expansion. +

+ +There are three quoting mechanisms: the +escape character, + +single quotes, and double quotes. +

+ +A non-quoted backslash (\) is the +escape character. + +It preserves the literal value of the next character that follows, +with the exception of <newline>. If a \<newline> pair +appears, and the backslash is not itself quoted, the \<newline> +is treated as a line continuation (that is, it is removed from the +input stream and effectively ignored). +

+ +Enclosing characters in single quotes 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. +

+ +Enclosing characters in double quotes preserves the literal value +of all characters within the quotes, with the exception of +$, + +`, + +\, + +and, when history expansion is enabled, +!. + +When the shell is in posix mode, the ! has no special meaning +within double quotes, even when history expansion is enabled. +The characters +$ + +and +` + +retain their special meaning within double quotes. The backslash +retains its special meaning only when followed by one of the following +characters: +$, + +`, + +", +\, + +or +<newline>. + +A double quote may be quoted within double quotes by preceding it with +a backslash. +If enabled, history expansion will be performed unless an +! + +appearing in double quotes is escaped using a backslash. +The backslash preceding the +! + +is not removed. +

+ +The special parameters +* + +and +@ + +have special meaning when in double +quotes (see +PARAMETERS + + +below). +

+ +Words of the form $aqstringaq are treated specially. The +word expands to string, with backslash-escaped characters replaced +as specified by the ANSI C standard. Backslash escape sequences, if +present, are decoded as follows: +

+ +
+
\a + +
+alert (bell) +
\b + +
+backspace +
\e + +
+
\E + +
+an escape character +
\f + +
+form feed +
\n + +
+new line +
\r + +
+carriage return +
\t + +
+horizontal tab +
\v + +
+vertical tab +
\\ + +
+backslash +
\aq + +
+single quote +
\dq + +
+double quote +
\? + +
+question mark +
\nnn + +
+the eight-bit character whose value is the octal value nnn +(one to three digits) +
\xHH + +
+the eight-bit character whose value is the hexadecimal value HH +(one or two hex digits) +
\uHHHH + +
+the Unicode (ISO/IEC 10646) character whose value is the hexadecimal value +HHHH (one to four hex digits) +
\UHHHHHHHH + +
+the Unicode (ISO/IEC 10646) character whose value is the hexadecimal value +HHHHHHHH (one to eight hex digits) +
\cx + +
+a control-x character + +
+ +

+ +The expanded result is single-quoted, as if the dollar sign had +not been present. +

+ +A double-quoted string preceded by a dollar sign ($dqstringdq) +will cause the string to be translated according to the current locale. +If the current locale is C or POSIX, the dollar sign +is ignored. +If the string is translated and replaced, the replacement is +double-quoted. +  +

PARAMETERS

+ +A +parameter + +is an entity that stores values. +It can be a +name, + +a number, or one of the special characters listed below under +Special Parameters. + +A +variable + +is a parameter denoted by a +name. + +A variable has a value and zero or more attributes. +Attributes are assigned using the +declare + +builtin command (see +declare + +below in +SHELL BUILTIN COMMANDS). + + +

+ +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 +unset + +builtin command (see +SHELL BUILTIN COMMANDS + + +below). +

+ +A +variable + +may be assigned to by a statement of the form +

+

+ +name=[value] +

+ +

+ +If +value + +is not given, the variable is assigned the null string. All +values + +undergo tilde expansion, parameter and variable expansion, +command substitution, arithmetic expansion, and quote +removal (see +EXPANSION + + +below). If the variable has its +integer + +attribute set, then +value + +is evaluated as an arithmetic expression even if the $((...)) expansion is +not used (see +Arithmetic Expansion + +below). +Word splitting is not performed, with the exception +of "$@" as explained below under +Special Parameters. + +Pathname expansion is not performed. +Assignment statements may also appear as arguments to the +alias, + +declare, + +typeset, + +export, + +readonly, + +and +local + +builtin commands (declaration commands). +When in posix mode, these builtins may appear in a command after +one or more instances of the command builtin and retain these +assignment statement properties. +

+ +In the context where an assignment statement is assigning a value +to a shell variable or array index, the += operator can be used to +append to or add to the variable's previous value. +This includes arguments to builtin commands such as declare that +accept assignment statements (declaration commands). +When += is applied to a variable for which the integer attribute has been +set, value is evaluated as an arithmetic expression and added to the +variable's current value, which is also evaluated. +When += is applied to an array variable using compound assignment (see +Arrays + +below), the +variable's value is not unset (as it is when using =), and new values are +appended to the array beginning at one greater than the array's maximum index +(for indexed arrays) or added as additional key-value pairs in an +associative array. +When applied to a string-valued variable, value is expanded and +appended to the variable's value. +

+ +A variable can be assigned the nameref attribute using the +-n option to the declare or local builtin commands +(see the descriptions of declare and local below) +to create a nameref, or a reference to another variable. +This allows variables to be manipulated indirectly. +Whenever the nameref variable is referenced, assigned to, unset, or has +its attributes modified (other than using or changing the nameref +attribute itself), the +operation is actually performed on the variable specified by the nameref +variable's value. +A nameref is commonly used within shell functions to refer to a variable +whose name is passed as an argument to the function. +For instance, if a variable name is passed to a shell function as its first +argument, running +

+

+declare -n ref=$1 + +
+ +

+inside the function creates a nameref variable ref whose value is +the variable name passed as the first argument. +References and assignments to ref, and changes to its attributes, +are treated as references, assignments, and attribute modifications +to the variable whose name was passed as $1. +If the control variable in a for loop has the nameref attribute, +the list of words can be a list of shell variables, and a name reference +will be established for each word in the list, in turn, when the loop is +executed. +Array variables cannot be given the nameref attribute. +However, nameref variables can reference array variables and subscripted +array variables. +Namerefs can be unset using the -n option to the unset builtin. +Otherwise, if unset is executed with the name of a nameref variable +as an argument, the variable referenced by the nameref variable will be unset. +  +

Positional Parameters

+ +

+ +A +positional parameter + +is a parameter denoted by one or more +digits, other than the single digit 0. Positional parameters are +assigned from the shell's arguments when it is invoked, +and may be reassigned using the +set + +builtin command. Positional parameters may not be assigned to +with assignment statements. The positional parameters are +temporarily replaced when a shell function is executed (see +FUNCTIONS + + +below). +

+ +When a positional parameter consisting of more than a single +digit is expanded, it must be enclosed in braces (see +EXPANSION + + +below). +  +

Special Parameters

+ +

+ +The shell treats several parameters specially. These parameters may +only be referenced; assignment to them is not allowed. + +

+
* + +
+Expands to the positional parameters, starting from one. +When the expansion is not within double quotes, each positional parameter +expands to a separate word. +In contexts where it is performed, those words +are subject to further word splitting and pathname expansion. +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 +IFS + + +special variable. That is, "$*" is equivalent +to "$1c$2c...", where +c + +is the first character of the value of the +IFS + + +variable. If +IFS + + +is unset, the parameters are separated by spaces. +If +IFS + + +is null, the parameters are joined without intervening separators. +
@ + +
+Expands to the positional parameters, starting from one. When the +expansion occurs within double quotes, each parameter expands to a +separate word. That is, "$@" is equivalent to +"$1" "$2" ... +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, "$@" and +$@ + +expand to nothing (i.e., they are removed). +
# + +
+Expands to the number of positional parameters in decimal. +
? + +
+Expands to the exit status of the most recently executed foreground +pipeline. +
- + +
+Expands to the current option flags as specified upon invocation, +by the +set + +builtin command, or those set by the shell itself +(such as the +-i + +option). +
$ + +
+Expands to the process ID of the shell. In a () subshell, it +expands to the process ID of the current shell, not the +subshell. +
! + +
+Expands to the process ID of the job most recently placed into the +background, whether executed as an asynchronous command or using +the bg builtin (see +JOB CONTROL + + +below). +
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, +$0 + +is set to the name of that file. If +bash + +is started with the +-c + +option, then +$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. +
_ + +
+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 +currently being checked. + +
+  +

Shell Variables

+ +

+ +The following variables are set by the shell: +

+ + +

+
BASH + +
+Expands to the full filename used to invoke this instance of +bash. + +
BASHOPTS + +
+A colon-separated list of enabled shell options. Each word in +the list is a valid argument for the +-s + +option to the +shopt + +builtin command (see +SHELL BUILTIN COMMANDS + + +below). The options appearing in +BASHOPTS + + +are those reported as +on + +by shopt. +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 read-only. +
BASHPID + +
+Expands to the process ID of the current bash process. +This differs from $$ under certain circumstances, such as subshells +that do not require bash to be re-initialized. +
BASH_ALIASES + +
+An associative array variable whose members correspond to the internal +list of aliases as maintained by the alias builtin. +Elements added to this array appear in the alias list; however, +unsetting array elements currently does not cause aliases to be removed +from the alias list. +If +BASH_ALIASES + +is unset, it loses its special properties, even if it is +subsequently reset. +
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 . or source) is at the top of the stack. +When a subroutine is executed, the number of parameters passed is pushed onto +BASH_ARGC. + + +The shell sets +BASH_ARGC + + +only when in extended debugging mode (see the description of the +extdebug + +option to the +shopt + +builtin below) +
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 +BASH_ARGV. + + +The shell sets +BASH_ARGV + + +only when in extended debugging mode +(see the description of the +extdebug + +option to the +shopt + +builtin below) +
BASH_CMDS + +
+An associative array variable whose members correspond to the internal +hash table of commands as maintained by the hash builtin. +Elements added to this array appear in the hash table; however, +unsetting array elements currently does not cause command names to be removed +from the hash table. +If +BASH_CMDS + +is unset, it loses its special properties, even if it is +subsequently reset. +
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. +
BASH_EXECUTION_STRING + +
+The command argument to the -c invocation option. +
BASH_LINENO + +
+An array variable whose members are the line numbers in source files +where each corresponding member of +FUNCNAME + + +was invoked. +${BASH_LINENO[$i]} is the line number in the source +file (${BASH_SOURCE[$i+1]}) where +${FUNCNAME[$i]} was called +(or ${BASH_LINENO[$i-1]} if referenced within another +shell function). +Use +LINENO + + +to obtain the current line number. +
BASH_LOADABLES_PATH + +
+A colon-separated list of directories in which the shell looks for +dynamically loadable builtins specified by the +enable + +command. +
BASH_REMATCH + +
+An array variable whose members are assigned by the =~ binary +operator to the [[ conditional command. +The element with index 0 is the portion of the string +matching the entire regular expression. +The element with index n is the portion of the +string matching the nth parenthesized subexpression. +This variable is read-only. +
BASH_SOURCE + +
+An array variable whose members are the source filenames +where the corresponding shell function names in the +FUNCNAME + + +array variable are defined. +The shell function +${FUNCNAME[$i]} is defined in the file +${BASH_SOURCE[$i]} and called from +${BASH_SOURCE[$i+1]}. +
BASH_SUBSHELL + +
+Incremented by one within each subshell or subshell environment when +the shell begins executing in that environment. +The initial value is 0. +
BASH_VERSINFO + +
+A readonly array variable whose members hold version information for +this instance of +bash. + +The values assigned to the array members are as follows: +

+

+
+
BASH_VERSINFO[0] + +
+The major version number (the release). +
BASH_VERSINFO[1] + +
+The minor version number (the version). +
BASH_VERSINFO[2] + +
+The patch level. +
BASH_VERSINFO[3] + +
+The build version. +
BASH_VERSINFO[4] + +
+The release status (e.g., beta1). +
BASH_VERSINFO[5] + +
+The value of +MACHTYPE. + + +
+ +
BASH_VERSION + +
+Expands to a string describing the version of this instance of +bash. + +
COMP_CWORD + +
+An index into ${COMP_WORDS} of the word containing the current +cursor position. +This variable is available only in shell functions invoked by the +programmable completion facilities (see Programmable Completion +below). +
COMP_KEY + +
+The key (or final key of a key sequence) used to invoke the current +completion function. +
COMP_LINE + +
+The current command line. +This variable is available only in shell functions and external +commands invoked by the +programmable completion facilities (see Programmable Completion +below). +
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 ${#COMP_LINE}. +This variable is available only in shell functions and external +commands invoked by the +programmable completion facilities (see Programmable Completion +below). +
COMP_TYPE + +
+Set to an integer value corresponding to the type of completion attempted +that caused a completion function to be called: +TAB, for normal completion, +?, for listing completions after successive tabs, +!, for listing alternatives on partial word completion, +@, to list completions if the word is not unmodified, +or +%, for menu completion. +This variable is available only in shell functions and external +commands invoked by the +programmable completion facilities (see Programmable Completion +below). +
COMP_WORDBREAKS + +
+The set of characters that the readline library treats as word +separators when performing word completion. +If +COMP_WORDBREAKS + + +is unset, it loses its special properties, even if it is +subsequently reset. +
COMP_WORDS + +
+An array variable (see Arrays below) consisting of the individual +words in the current command line. +The line is split into words as readline would split it, using +COMP_WORDBREAKS + + +as described above. +This variable is available only in shell functions invoked by the +programmable completion facilities (see Programmable Completion +below). +
COPROC + +
+An array variable (see Arrays below) created to hold the file descriptors +for output from and input to an unnamed coprocess (see Coprocesses +above). +
DIRSTACK + +
+An array variable (see +Arrays + +below) containing the current contents of the directory stack. +Directories appear in the stack in the order they are displayed by the +dirs + +builtin. +Assigning to members of this array variable may be used to modify +directories already in the stack, but the +pushd + +and +popd + +builtins must be used to add and remove directories. +Assignment to this variable will not change the current directory. +If +DIRSTACK + + +is unset, it loses its special properties, even if it is +subsequently reset. +
EUID + +
+Expands to the effective user ID of the current user, initialized at +shell startup. This variable is readonly. +
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 (the one with the highest index) is +"main". + +This variable exists only when a shell function is executing. +Assignments to +FUNCNAME + + +have no effect. +If +FUNCNAME + + +is unset, it loses its special properties, even if it is +subsequently reset. +

+ + +This variable can be used with BASH_LINENO and BASH_SOURCE. +Each element of FUNCNAME has corresponding elements in +BASH_LINENO and BASH_SOURCE to describe the call stack. +For instance, ${FUNCNAME[$i]} was called from the file +${BASH_SOURCE[$i+1]} at line number +${BASH_LINENO[$i]}. +The caller builtin displays the current call stack using this +information. +

GROUPS + +
+An array variable containing the list of groups of which the current +user is a member. +Assignments to +GROUPS + + +have no effect. +If +GROUPS + + +is unset, it loses its special properties, even if it is +subsequently reset. +
HISTCMD + +
+The history number, or index in the history list, of the current +command. +If +HISTCMD + + +is unset, it loses its special properties, even if it is +subsequently reset. +
HOSTNAME + +
+Automatically set to the name of the current host. +
HOSTTYPE + +
+Automatically set to a string that uniquely +describes the type of machine on which +bash + +is executing. +The default is system-dependent. +
LINENO + +
+Each time this parameter is referenced, the shell substitutes +a decimal number representing the current sequential line number +(starting with 1) within a script or function. When not in a +script or function, the value substituted is not guaranteed to +be meaningful. +If +LINENO + + +is unset, it loses its special properties, even if it is +subsequently reset. +
MACHTYPE + +
+Automatically set to a string that fully describes the system +type on which +bash + +is executing, in the standard GNU cpu-company-system format. +The default is system-dependent. +
MAPFILE + +
+An array variable (see Arrays below) created to hold the text +read by the mapfile builtin when no variable name is supplied. +
OLDPWD + +
+The previous working directory as set by the +cd + +command. +
OPTARG + +
+The value of the last option argument processed by the +getopts + +builtin command (see +SHELL BUILTIN COMMANDS + + +below). +
OPTIND + +
+The index of the next argument to be processed by the +getopts + +builtin command (see +SHELL BUILTIN COMMANDS + + +below). +
OSTYPE + +
+Automatically set to a string that +describes the operating system on which +bash + +is executing. +The default is system-dependent. +
PIPESTATUS + +
+An array variable (see +Arrays + +below) containing a list of exit status values from the processes +in the most-recently-executed foreground pipeline (which may +contain only a single command). +
PPID + +
+The process ID of the shell's parent. This variable is readonly. +
PWD + +
+The current working directory as set by the +cd + +command. +
RANDOM + +
+Each time this parameter is referenced, a random integer between +0 and 32767 is +generated. The sequence of random numbers may be initialized by assigning +a value to +RANDOM. + + +If +RANDOM + + +is unset, it loses its special properties, even if it is +subsequently reset. +
READLINE_LINE + +
+The contents of the +readline + +line buffer, for use with +bind -x + +(see +SHELL BUILTIN COMMANDS + + +below). +
READLINE_POINT + +
+The position of the insertion point in the +readline + +line buffer, for use with +bind -x + +(see +SHELL BUILTIN COMMANDS + + +below). +
REPLY + +
+Set to the line of input read by the +read + +builtin command when no arguments are supplied. +
SECONDS + +
+Each time this parameter is +referenced, the number of seconds since shell invocation is returned. If a +value is assigned to +SECONDS, + + +the value returned upon subsequent +references is +the number of seconds since the assignment plus the value assigned. +If +SECONDS + + +is unset, it loses its special properties, even if it is +subsequently reset. +
SHELLOPTS + +
+A colon-separated list of enabled shell options. Each word in +the list is a valid argument for the +-o + +option to the +set + +builtin command (see +SHELL BUILTIN COMMANDS + + +below). The options appearing in +SHELLOPTS + + +are those reported as +on + +by 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 read-only. +
SHLVL + +
+Incremented by one each time an instance of +bash + +is started. +
UID + +
+Expands to the user ID of the current user, initialized at shell startup. +This variable is readonly. + +
+

+ +The following variables are used by the shell. In some cases, +bash + +assigns a default value to a variable; these cases are noted +below. +

+ + +

+
BASH_COMPAT + +
+The value is used to set the shell's compatibility level. +See the description of the shopt builtin below under +SHELL BUILTIN COMMANDS +for a description of the various compatibility +levels and their effects. +The value may be a decimal number (e.g., 4.2) or an integer (e.g., 42) +corresponding to the desired compatibility level. +If BASH_COMPAT is unset or set to the empty string, the compatibility +level is set to the default for the current version. +If BASH_COMPAT is set to a value that is not one of the valid +compatibility levels, the shell prints an error message and sets the +compatibility level to the default for the current version. +The valid compatibility levels correspond to the compatibility options +accepted by the shopt builtin described below (for example, +compat42 means that 4.2 and 42 are valid values). +The current version is also a valid value. +
BASH_ENV + +
+If this parameter is set when bash is executing a shell script, +its value is interpreted as a filename containing commands to +initialize the shell, as in +~/.bashrc. + +The value of +BASH_ENV + + +is subjected to parameter expansion, command substitution, and arithmetic +expansion before being interpreted as a filename. +PATH + + +is not used to search for the resultant filename. +
BASH_XTRACEFD + +
+If set to an integer corresponding to a valid file descriptor, bash +will write the trace output generated when +set -x + +is enabled to that file descriptor. +The file descriptor is closed when +BASH_XTRACEFD + + +is unset or assigned a new value. +Unsetting +BASH_XTRACEFD + + +or assigning it the empty string causes the +trace output to be sent to the standard error. +Note that setting +BASH_XTRACEFD + + +to 2 (the standard error file +descriptor) and then unsetting it will result in the standard error +being closed. +
CDPATH + +
+The search path for the +cd + +command. +This is a colon-separated list of directories in which the shell looks +for destination directories specified by the +cd + +command. +A sample value is +".:~:/usr". + +
CHILD_MAX + +
+Set the number of exited child status values for the shell to remember. +Bash will not allow this value to be decreased below a POSIX-mandated +minimum, and there is a maximum value (currently 8192) that this may +not exceed. +The minimum value is system-dependent. +
COLUMNS + +
+Used by the select compound command to determine the terminal width +when printing selection lists. +Automatically set if the +checkwinsize + +option is enabled or in an interactive shell upon receipt of a +SIGWINCH. + + +
COMPREPLY + +
+An array variable from which bash reads the possible completions +generated by a shell function invoked by the programmable completion +facility (see Programmable Completion below). +Each array element contains one possible completion. +
EMACS + +
+If bash finds this variable in the environment when the shell starts +with value +t, + +it assumes that the shell is running in an Emacs shell buffer and disables +line editing. +
ENV + +
+Similar to +BASH_ENV; + + +used when the shell is invoked in POSIX mode. +
EXECIGNORE + +
+A colon-separated list of shell patterns (see Pattern Matching) +defining the list of filenames to be ignored by command search using +PATH. +Files whose full pathnames match one of these patterns are not considered +executable files for the purposes of completion and command execution +via PATH lookup. +This does not affect the behavior of the [, test, and [[ +commands. +Full pathnames in the command hash table are not subject to EXECIGNORE. +Use this variable to ignore shared library files that have the executable +bit set, but are not executable files. +The pattern matching honors the setting of the extglob shell +option. +
FCEDIT + +
+The default editor for the +fc + +builtin command. +
FIGNORE + +
+A colon-separated list of suffixes to ignore when performing +filename completion (see +READLINE + + +below). +A filename whose suffix matches one of the entries in +FIGNORE + + +is excluded from the list of matched filenames. +A sample value is +".o:~". + +
FUNCNEST + +
+If set to a numeric value greater than 0, defines a maximum function +nesting level. Function invocations that exceed this nesting level +will cause the current command to abort. +
GLOBIGNORE + +
+A colon-separated list of patterns defining the set of filenames to +be ignored by pathname expansion. +If a filename matched by a pathname expansion pattern also matches one +of the patterns in +GLOBIGNORE, + + +it is removed from the list of matches. +
HISTCONTROL + +
+A colon-separated list of values controlling how commands are saved on +the history list. +If the list of values includes +ignorespace, + +lines which begin with a +space + +character are not saved in the history list. +A value of +ignoredups + +causes lines matching the previous history entry to not be saved. +A value of +ignoreboth + +is shorthand for ignorespace and ignoredups. +A value of +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 +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 +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 +HISTCONTROL. + + +
HISTFILE + +
+The name of the file in which command history is saved (see +HISTORY + + +below). The default value is ~/.bash_history. If unset, the +command history is not saved when a shell exits. +
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 by removing the oldest entries. +The history file is also truncated to this size after +writing it when a shell exits. +If the value is 0, the history file is truncated to zero size. +Non-numeric values and numeric values less than zero inhibit truncation. +The shell sets the default value to the value of HISTSIZE +after reading any startup files. +
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 +`*' is appended). Each pattern is tested against the line +after the checks specified by +HISTCONTROL + + +are applied. +In addition to the normal shell pattern matching characters, `&' +matches the previous history line. `&' 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 +HISTIGNORE. + + +The pattern matching honors the setting of the extglob shell +option. +
HISTSIZE + +
+The number of commands to remember in the command history (see +HISTORY + + +below). +If the value is 0, commands are not saved in the history list. +Numeric values less than zero result in every command being saved +on the history list (there is no limit). +The shell sets the default value to 500 after reading any startup files. +
HISTTIMEFORMAT + +
+If this variable is set and not null, its value is used as a format string +for strftime(3) to print the time stamp associated with each history +entry displayed by the history builtin. +If this variable is set, time stamps are written to the history file so +they may be preserved across shell sessions. +This uses the history comment character to distinguish timestamps from +other history lines. +
HOME + +
+The home directory of the current user; the default argument for the +cd builtin command. +The value of this variable is also used when performing tilde expansion. +
HOSTFILE + +
+Contains the name of a file in the same format as + +/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 +HOSTFILE + + +is set, but has no value, or does not name a readable file, +bash attempts to read + +/etc/hosts + +to obtain the list of possible hostname completions. +When +HOSTFILE + + +is unset, the hostname list is cleared. +
IFS + +
+The +Internal Field Separator + +that is used +for word splitting after expansion and to +split lines into words with the +read + +builtin command. The default value is +``<space><tab><newline>''. +
IGNOREEOF + +
+Controls the +action of an interactive shell on receipt of an +EOF + + +character as the sole input. If set, the value is the number of +consecutive +EOF + + +characters which must be +typed as the first characters on an input line before +bash + +exits. If the variable exists but does not have a numeric value, or +has no value, the default value is 10. If it does not exist, +EOF + + +signifies the end of input to the shell. +
INPUTRC + +
+The filename for the +readline + +startup file, overriding the default of + +~/.inputrc + +(see +READLINE + + +below). +
LANG + +
+Used to determine the locale category for any category not specifically +selected with a variable starting with LC_. +
LC_ALL + +
+This variable overrides the value of +LANG + + +and any other +LC_ variable specifying a locale category. +
LC_COLLATE + +
+This variable determines the collation order used when sorting the +results of pathname expansion, and determines the behavior of range +expressions, equivalence classes, and collating sequences within +pathname expansion and pattern matching. +
LC_CTYPE + +
+This variable determines the interpretation of characters and the +behavior of character classes within pathname expansion and pattern +matching. +
LC_MESSAGES + +
+This variable determines the locale used to translate double-quoted +strings preceded by a $. +
LC_NUMERIC + +
+This variable determines the locale category used for number formatting. +
LC_TIME + +
+This variable determines the locale category used for data and time +formatting. +
LINES + +
+Used by the select compound command to determine the column length +for printing selection lists. +Automatically set if the +checkwinsize + +option is enabled or in an interactive shell upon receipt of a +SIGWINCH. + + +
MAIL + +
+If this parameter is set to a file or directory name and the +MAILPATH + + +variable is not set, +bash + +informs the user of the arrival of mail in the specified file or +Maildir-format directory. +
MAILCHECK + +
+Specifies how +often (in seconds) +bash + +checks for mail. The default is 60 seconds. When it is time to check +for mail, the shell does so before displaying the primary prompt. +If this variable is unset, or set to a value that is not a number +greater than or equal to zero, the shell disables mail checking. +
MAILPATH + +
+A colon-separated list of filenames to be checked for mail. +The message to be printed when mail arrives in a particular file +may be specified by separating the filename from the message with a `?'. +When used in the text of the message, $_ expands to the name of +the current mailfile. +Example: +
+

+ +MAILPATH=aq/var/mail/bfox?"You have mail":~/shell-mail?"$_ has mail!"aq +

+ +Bash + +can be configured to supply +a default value for this variable (there is no value by default), +but the location of the user +mail files that it uses is system dependent (e.g., /var/mail/$USER). +

+ +
OPTERR + +
+If set to the value 1, +bash + +displays error messages generated by the +getopts + +builtin command (see +SHELL BUILTIN COMMANDS + + +below). +OPTERR + + +is initialized to 1 each time the shell is invoked or a shell +script is executed. +
PATH + +
+The search path for commands. It +is a colon-separated list of directories in which +the shell looks for commands (see +COMMAND EXECUTION + + +below). +A zero-length (null) directory name in the value of +PATH + + +indicates the current directory. +A null directory name may appear as two adjacent colons, or as an initial +or trailing colon. +The default path is system-dependent, +and is set by the administrator who installs +bash. + +A common value is + +/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin. + + +
POSIXLY_CORRECT + +
+If this variable is in the environment when bash starts, the shell +enters posix mode before reading the startup files, as if the +--posix + +invocation option had been supplied. If it is set while the shell is +running, bash enables posix mode, as if the command +set -o posix + +had been executed. +
PROMPT_COMMAND + +
+If set, the value is executed as a command prior to issuing each primary +prompt. +
PROMPT_DIRTRIM + +
+If set to a number greater than zero, the value is used as the number of +trailing directory components to retain when expanding the \w and +\W prompt string escapes (see +PROMPTING + + +below). Characters removed are replaced with an ellipsis. +
PS0 + +
+The value of this parameter is expanded (see +PROMPTING + + +below) and displayed by interactive shells after reading a command +and before the command is executed. +
PS1 + +
+The value of this parameter is expanded (see +PROMPTING + + +below) and used as the primary prompt string. The default value is +``\s-\v\$ ''. +
PS2 + +
+The value of this parameter is expanded as with +PS1 + + +and used as the secondary prompt string. The default is +``> ''. +
PS3 + +
+The value of this parameter is used as the prompt for the +select + +command (see +SHELL GRAMMAR + + +above). +
PS4 + +
+The value of this parameter is expanded as with +PS1 + + +and the value is printed before each command +bash + +displays during an execution trace. The first character of +PS4 + + +is replicated multiple times, as necessary, to indicate multiple +levels of indirection. The default is ``+ ''. +
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. +
TIMEFORMAT + +
+The value of this parameter is used as a format string specifying +how the timing information for pipelines prefixed with the +time + +reserved word should be displayed. +The % 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. +

+

+ +
+
%% + +
+A literal %. +
%[p][l]R + +
+The elapsed time in seconds. +
%[p][l]U + +
+The number of CPU seconds spent in user mode. +
%[p][l]S + +
+The number of CPU seconds spent in system mode. +
%P + +
+The CPU percentage, computed as (%U + %S) / %R. + +
+ +
+The optional 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 p greater than 3 are changed to 3. +If p is not specified, the value 3 is used. +
+The optional l specifies a longer format, including +minutes, of the form MMmSS.FFs. +The value of p determines whether or not the fraction is +included. +
+If this variable is not set, bash acts as if it had the +value $aq\nreal\t%3lR\nuser\t%3lU\nsys\t%3lSaq. +If the value is null, no timing information is displayed. +A trailing newline is added when the format string is displayed. + +
TMOUT + +
+If set to a value greater than zero, +TMOUT + + +is treated as the +default timeout for the read builtin. +The select command terminates if input does not arrive +after +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 a line of input after issuing the +primary prompt. +Bash + +terminates after waiting for that number of seconds if a complete +line of input does not arrive. +
TMPDIR + +
+If set, bash uses its value as the name of a directory in which +bash creates temporary files for the shell's use. +
auto_resume + +
+This variable controls how the shell interacts with the user and +job control. If this variable is set, single word simple +commands without redirections are treated as candidates for resumption +of an existing stopped job. There is no ambiguity allowed; if there is +more than one job beginning with the string typed, the job most recently +accessed is selected. The +name + +of a stopped job, in this context, is the command line used to +start it. +If set to the value +exact, + +the string supplied must match the name of a stopped job exactly; +if set to +substring, + +the string supplied needs to match a substring of the name of a +stopped job. The +substring + +value provides functionality analogous to the +%? + +job identifier (see +JOB CONTROL + + +below). 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 %string job identifier. +
histchars + +
+The two or three characters which control history expansion +and tokenization (see +HISTORY EXPANSION + + +below). The first character is the history expansion character, +the character which signals the start of a history +expansion, normally `!'. +The second character is the quick substitution +character, which is used as shorthand for re-running the previous +command entered, substituting one string for another in the command. +The default is `^'. +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, normally `#'. 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. + +
+  +

Arrays

+ +Bash + +provides one-dimensional indexed and associative array variables. +Any variable may be used as an indexed array; the +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. +Indexed arrays are referenced using integers (including arithmetic +expressions) and are zero-based; associative arrays are referenced +using arbitrary strings. +Unless otherwise noted, indexed array indices must be non-negative integers. +

+ +An indexed array is created automatically if any variable is assigned to +using the syntax name[subscript]=value. The +subscript + +is treated as an arithmetic expression that must evaluate to a number. +To explicitly declare an indexed array, use +declare -a name + +(see +SHELL BUILTIN COMMANDS + + +below). +declare -a name[subscript] + +is also accepted; the subscript is ignored. +

+ +Associative arrays are created using +declare -A name. + +

+ +Attributes may be +specified for an array variable using the +declare + +and +readonly + +builtins. Each attribute applies to all members of an array. +

+ +Arrays are assigned to using compound assignments of the form +name=(value1 ... valuen), where each +value is of the form [subscript]=string. +Indexed array assignments do not require anything but string. +When assigning to indexed arrays, if the optional brackets and subscript +are 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. +

+ +When assigning to an associative array, the subscript is required. +

+ +This syntax is also accepted by the +declare + +builtin. Individual array elements may be assigned to using the +name[subscript]=value syntax introduced above. +When assigning to an indexed array, if +name + +is subscripted by a negative number, that number is +interpreted as relative to one greater than the maximum index of +name, so negative indices count back from the end of the +array, and an index of -1 references the last element. +

+ +Any element of an array may be referenced using +${name[subscript]}. The braces are required to avoid +conflicts with pathname expansion. If +subscript is @ or *, the word expands to +all members of name. These subscripts differ only when the +word appears within double quotes. If the word is double-quoted, +${name[*]} expands to a single +word with the value of each array member separated by the first +character of the +IFS + + +special variable, and ${name[@]} expands each element of +name to a separate word. When there are no array members, +${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 * and @ (see +Special Parameters + +above). ${#name[subscript]} expands to the length of +${name[subscript]}. If subscript is * or +@, the expansion is the number of elements in the array. +If the +subscript + +used to reference an element of an indexed array +evaluates to a number less than zero, it is +interpreted as relative to one greater than the maximum index of the array, +so negative indices count back from the end of the +array, and an index of -1 references the last element. +

+ +Referencing an array variable without a subscript is equivalent to +referencing the array with a subscript of 0. +Any reference to a variable using a valid subscript is legal, and +bash + +will create an array if necessary. +

+ +An array variable is considered set if a subscript has been assigned a +value. The null string is a valid value. +

+ +It is possible to obtain the keys (indices) of an array as well as the values. +${!name[@]} and ${!name[*]} +expand to the indices assigned in array variable name. +The treatment when in double quotes is similar to the expansion of the +special parameters @ and * within double quotes. +

+ +The +unset + +builtin is used to destroy arrays. unset name[subscript] +destroys the array element at index subscript. +Negative subscripts to indexed arrays are interpreted as described above. +Care must be taken to avoid unwanted side effects caused by pathname +expansion. +unset name, where name is an array, or +unset name[subscript], where +subscript is * or @, removes the entire array. +

+ +The +declare, + +local, + +and +readonly + +builtins each accept a +-a + +option to specify an indexed array and a +-A + +option to specify an associative array. +If both options are supplied, +-A + +takes precedence. +The +read + +builtin accepts a +-a + +option to assign a list of words read from the standard input +to an array. The +set + +and +declare + +builtins display array values in a way that allows them to be +reused as assignments. +  +

EXPANSION

+ +Expansion is performed on the command line after it has been split into +words. There are seven kinds of expansion performed: +brace expansion, + +tilde expansion, + +parameter and variable expansion, + +command substitution, + +arithmetic expansion, + +word splitting, + +and +pathname expansion. + +

+ +The order of expansions is: +brace expansion; +tilde expansion, parameter and variable expansion, arithmetic expansion, +and command substitution (done in a left-to-right fashion); +word splitting; +and pathname expansion. +

+ +On systems that can support it, there is an additional expansion +available: process substitution. +This is performed at the +same time as tilde, parameter, variable, and arithmetic expansion and +command substitution. +

+ +After these expansions are performed, quote characters present in the +original word are removed unless they have been quoted themselves +(quote removal). +

+ +Only brace expansion, word splitting, and pathname 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 +"$@" and "${name[@]}" +as explained above (see +PARAMETERS). + + +  +

Brace Expansion

+ +

+ +Brace expansion + +is a mechanism by which arbitrary strings +may be generated. This mechanism is similar to +pathname expansion, but the filenames generated +need not exist. Patterns to be brace expanded take +the form of an optional +preamble, + +followed by either a series of comma-separated strings or +a sequence expression between a pair of braces, followed by +an optional +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, a{d,c,b}e expands into `ade ace abe'. +

+ +A sequence expression takes the form +{x..y[..incr]}, +where x and y are either integers or single characters, +and incr, an optional increment, is an integer. +When integers are supplied, the expression expands to each number between +x and y, inclusive. +Supplied integers may be prefixed with 0 to force each term to have the +same width. +When either x or y begins with a zero, the shell +attempts to force all generated terms to contain the same number of digits, +zero-padding where necessary. +When characters are supplied, the expression expands to each character +lexicographically between x and y, inclusive, +using the default C locale. +Note that both x and y must be of the same type. +When the increment is supplied, it is used as the difference between +each term. The default increment is 1 or -1 as appropriate. +

+ +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. +

+ +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 , may be quoted with a backslash to prevent its +being considered part of a brace expression. +To avoid conflicts with parameter expansion, the string ${ +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: +

+

+ +mkdir /usr/local/src/bash/{old,new,dist,bugs} +

+ +or +
+chown root /usr/{ucb/{ex,edit},lib/{ex?.?*,how_ex}} +
+ +

+ +Brace expansion introduces a slight incompatibility with +historical versions of +sh. + +sh + +does not treat opening or closing braces specially when they +appear as part of a word, and preserves them in the output. +Bash + +removes braces from words as a consequence of brace +expansion. For example, a word entered to +sh + +as file{1,2} +appears identically in the output. The same word is +output as +file1 file2 + +after expansion by +bash. + +If strict compatibility with +sh + +is desired, start +bash + +with the ++B + +option or disable brace expansion with the ++B + +option to the +set + +command (see +SHELL BUILTIN COMMANDS + + +below). +  +

Tilde Expansion

+ +

+ +If a word begins with an unquoted tilde character (`~'), all of +the characters preceding the first unquoted slash (or all characters, +if there is no unquoted slash) are considered a 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 login name. +If this login name is the null string, the tilde is replaced with the +value of the shell parameter +HOME. + + +If +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 a `~+', the value of the shell variable +PWD + + +replaces the tilde-prefix. +If the tilde-prefix is a `~-', the value of the shell variable +OLDPWD, + + +if it is set, is substituted. +If the characters following the tilde in the tilde-prefix consist +of a number N, optionally prefixed +by a `+' or a `-', the tilde-prefix is replaced with the corresponding +element from the directory stack, as it would be displayed by the +dirs + +builtin invoked with the tilde-prefix as an argument. +If the characters following the tilde in the tilde-prefix consist of a +number without a leading `+' or `-', `+' is assumed. +

+ +If the login name is invalid, or the tilde expansion fails, the word +is unchanged. +

+ +Each variable assignment is checked for unquoted tilde-prefixes immediately +following a +: + +or the first +=. + +In these cases, tilde expansion is also performed. +Consequently, one may use filenames with tildes in assignments to +PATH, + + +MAILPATH, + + +and +CDPATH, + + +and the shell assigns the expanded value. +  +

Parameter Expansion

+ +

+ +The `$' 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 `}' +not escaped by a backslash or within a quoted string, and not within an +embedded arithmetic expansion, command substitution, or parameter +expansion. +

+ + +

+
${parameter}
+The value of parameter is substituted. The braces are required +when +parameter + +is a positional parameter with more than one digit, +or when +parameter + +is followed by a character which is not to be +interpreted as part of its name. +The parameter is a shell parameter as described above +PARAMETERS) or an array reference (Arrays). + +
+

+ +If the first character of parameter is an exclamation point (!), +and parameter is not a nameref, +it introduces a level of variable indirection. +Bash uses the value of the variable formed from the rest of +parameter as the name of the variable; this variable is then +expanded and that value is used in the rest of the substitution, rather +than the value of parameter itself. +This is known as indirect expansion. +If parameter is a nameref, this expands to the name of the +variable referenced by parameter instead of performing the +complete indirect expansion. +The exceptions to this are the expansions of ${!prefix*} and +${!name[@]} described below. +The exclamation point must immediately follow the left brace in order to +introduce indirection. +

+ +In each of the cases below, word is subject to tilde expansion, +parameter expansion, command substitution, and arithmetic expansion. +

+ +When not performing substring expansion, using the forms documented below +(e.g., :-), +bash tests for a parameter that is unset or null. Omitting the colon +results in a test only for a parameter that is unset. +

+ + +

+
${parameter:-word}
+Use Default Values. If +parameter + +is unset or null, the expansion of +word + +is substituted. Otherwise, the value of +parameter + +is substituted. +
${parameter:=word}
+Assign Default Values. +If +parameter + +is unset or null, the expansion of +word + +is assigned to +parameter. + +The value of +parameter + +is then substituted. Positional parameters and special parameters may +not be assigned to in this way. +
${parameter:?word}
+Display Error if Null or Unset. +If +parameter + +is null or unset, the expansion of word (or a message to that effect +if +word + +is not present) is written to the standard error and the shell, if it +is not interactive, exits. Otherwise, the value of parameter is +substituted. +
${parameter:+word}
+Use Alternate Value. +If +parameter + +is null or unset, nothing is substituted, otherwise the expansion of +word + +is substituted. +
${parameter:offset}
+ +
${parameter:offset:length}
+ +Substring Expansion. +Expands to up to length characters of the value of parameter +starting at the character specified by offset. +If parameter is @, an indexed array subscripted by +@ or *, or an associative array name, the results differ as +described below. +If length is omitted, expands to the substring of the value of +parameter starting at the character specified by offset +and extending to the end of the value. +length and offset are arithmetic expressions (see +ARITHMETIC EVALUATION + + +below). +

+If offset evaluates to a number less than zero, the value +is used as an offset in characters +from the end of the value of parameter. +If length evaluates to a number less than zero, +it is interpreted as an offset in characters +from the end of the value of parameter rather than +a number of characters, and the expansion is the characters between +offset and that result. +Note that a negative offset must be separated from the colon by at least +one space to avoid being confused with the :- expansion. +

+If parameter is @, the result is length positional +parameters beginning at offset. +A negative offset is taken relative to one greater than the greatest +positional parameter, so an offset of -1 evaluates to the last positional +parameter. +It is an expansion error if length evaluates to a number less than +zero. +

+If parameter is an indexed array name subscripted by @ or *, +the result is the length +members of the array beginning with ${parameter[offset]}. +A negative offset is taken relative to one greater than the maximum +index of the specified array. +It is an expansion error if length evaluates to a number less than +zero. +

+Substring expansion applied to an associative array produces undefined +results. +

+Substring indexing is zero-based unless the positional parameters +are used, in which case the indexing starts at 1 by default. +If offset is 0, and the positional parameters are used, $0 is +prefixed to the list. +

${!prefix*}
+ +
${!prefix@}
+ +Names matching prefix. +Expands to the names of variables whose names begin with prefix, +separated by the first character of the +IFS + + +special variable. +When @ is used and the expansion appears within double quotes, each +variable name expands to a separate word. +
${!name[@]}
+ +
${!name[*]}
+ +List of array keys. +If name is an array variable, expands to the list of array indices +(keys) assigned in name. +If name is not an array, expands to 0 if name is set and null +otherwise. +When @ is used and the expansion appears within double quotes, each +key expands to a separate word. +
${#parameter}
+Parameter length. +The length in characters of the value of parameter is substituted. +If +parameter + +is +* + +or +@, + +the value substituted is the number of positional parameters. +If +parameter + +is an array name subscripted by +* + +or +@, + +the value substituted is the number of elements in the array. +If +parameter + +is an indexed array name subscripted by a negative number, that number is +interpreted as relative to one greater than the maximum index of +parameter, so negative indices count back from the end of the +array, and an index of -1 references the last element. +
${parameter#word}
+ +
${parameter##word}
+ +Remove matching prefix pattern. +The +word + +is expanded to produce a pattern just as in pathname +expansion. If the pattern matches the beginning of +the value of +parameter, + +then the result of the expansion is the expanded value of +parameter + +with the shortest matching pattern (the ``#'' case) or the +longest matching pattern (the ``##'' case) deleted. +If +parameter + +is +@ + +or +*, + +the pattern removal operation is applied to each positional +parameter in turn, and the expansion is the resultant list. +If +parameter + +is an array variable subscripted with +@ + +or +*, + +the pattern removal operation is applied to each member of the +array in turn, and the expansion is the resultant list. +
${parameter%word}
+ +
${parameter%%word}
+ +Remove matching suffix pattern. +The word is expanded to produce a pattern just as in +pathname expansion. +If the pattern matches a trailing portion of the expanded value of +parameter, + +then the result of the expansion is the expanded value of +parameter + +with the shortest matching pattern (the ``%'' case) or the +longest matching pattern (the ``%%'' case) deleted. +If +parameter + +is +@ + +or +*, + +the pattern removal operation is applied to each positional +parameter in turn, and the expansion is the resultant list. +If +parameter + +is an array variable subscripted with +@ + +or +*, + +the pattern removal operation is applied to each member of the +array in turn, and the expansion is the resultant list. +
${parameter/pattern/string}
+Pattern substitution. +The pattern is expanded to produce a pattern just as in +pathname expansion. +Parameter is expanded and the longest match of pattern +against its value is replaced with string. +If pattern begins with /, all matches of pattern are +replaced with string. Normally only the first match is replaced. +If pattern begins with #, it must match at the beginning +of the expanded value of parameter. +If pattern begins with %, it must match at the end +of the expanded value of parameter. +If string is null, matches of pattern are deleted +and the / following pattern may be omitted. +If the +nocasematch + +shell option is enabled, the match is performed without regard to the case +of alphabetic characters. +If +parameter + +is +@ + +or +*, + +the substitution operation is applied to each positional +parameter in turn, and the expansion is the resultant list. +If +parameter + +is an array variable subscripted with +@ + +or +*, + +the substitution operation is applied to each member of the +array in turn, and the expansion is the resultant list. +
${parameter^pattern}
+ +
${parameter^^pattern}
+
${parameter,pattern}
+
${parameter,,pattern}
+ +Case modification. +This expansion modifies the case of alphabetic characters in parameter. +The pattern is expanded to produce a pattern just as in +pathname expansion. +Each character in the expanded value of parameter is tested against +pattern, and, if it matches the pattern, its case is converted. +The pattern should not attempt to match more than one character. +The ^ operator converts lowercase letters matching pattern +to uppercase; the , operator converts matching uppercase letters +to lowercase. +The ^^ and ,, expansions convert each matched character in the +expanded value; the ^ and , expansions match and convert only +the first character in the expanded value. +If pattern is omitted, it is treated like a ?, which matches +every character. +If +parameter + +is +@ + +or +*, + +the case modification operation is applied to each positional +parameter in turn, and the expansion is the resultant list. +If +parameter + +is an array variable subscripted with +@ + +or +*, + +the case modification operation is applied to each member of the +array in turn, and the expansion is the resultant list. +
${parameter@operator}
+Parameter transformation. +The expansion is either a transformation of the value of parameter +or information about parameter itself, depending on the value of +operator. Each operator is a single letter: +

+

+ +
+
Q + +
+The expansion is a string that is the value of parameter quoted in a +format that can be reused as input. +
E + +
+The expansion is a string that is the value of parameter with backslash +escape sequences expanded as with the $'...' quoting mechansim. +
P + +
+The expansion is a string that is the result of expanding the value of +parameter as if it were a prompt string (see PROMPTING below). +
A + +
+The expansion is a string in the form of +an assignment statement or declare command that, if +evaluated, will recreate parameter with its attributes and value. +
a + +
+The expansion is a string consisting of flag values representing +parameter's attributes. + +
+

+ +If +parameter + +is +@ + +or +*, + +the operation is applied to each positional +parameter in turn, and the expansion is the resultant list. +If +parameter + +is an array variable subscripted with +@ + +or +*, + +the case modification operation is applied to each member of the +array in turn, and the expansion is the resultant list. +

+The result of the expansion is subject to word splitting and pathname +expansion as described below. +

+ +
+  +

Command Substitution

+ +

+ +Command substitution allows the output of a command to replace +the command name. There are two forms: +

+

+ +$(command) +

+ +or +
+`command` +
+ +

+ +Bash + +performs the expansion by executing command in a subshell environment +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 $(cat file) can be replaced by +the equivalent but faster $(< file). +

+ +When the old-style backquote form of substitution is used, +backslash retains its literal meaning except when followed by +$, + +`, + +or +\. + +The first backquote not preceded by a backslash terminates the +command substitution. +When using the $(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 +pathname expansion are not performed on the results. +  +

Arithmetic Expansion

+ +

+ +Arithmetic expansion allows the evaluation of an arithmetic expression +and the substitution of the result. The format for arithmetic expansion is: +

+

+ +$((expression)) +

+ +

+ +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 and variable expansion, +command substitution, and quote removal. +The result is treated as the arithmetic expression to be evaluated. +Arithmetic expansions may be nested. +

+ +The evaluation is performed according to the rules listed below under +ARITHMETIC EVALUATION. + + +If +expression + +is invalid, +bash + +prints a message indicating failure and no substitution occurs. +  +

Process Substitution

+ +

+ +Process substitution allows a process's input or output to be +referred to using a filename. +It takes the form of +<(list) +or +>(list). +The process list is run asynchronously, and its input or output +appears as a filename. +This filename is +passed as an argument to the current command as the result of the +expansion. +If the >(list) form is used, writing to +the file will provide input for list. If the +<(list) form is used, the file passed as an +argument should be read to obtain the output of list. +Process substitution is supported on systems that support named +pipes (FIFOs) or the /dev/fd method of naming open files. +

+ +When available, process substitution is performed +simultaneously with parameter and variable expansion, +command substitution, +and arithmetic expansion. +  +

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 +IFS + + +as a delimiter, and splits the results of the other +expansions into words using these characters as field terminators. +If +IFS + + +is unset, or its +value is exactly +<space><tab><newline>, + +the default, then +sequences of +<space>, + +<tab>, + +and +<newline> + +at the beginning and end of the results of the previous +expansions are ignored, and +any sequence of +IFS + + +characters not at the beginning or end serves to delimit words. +If +IFS + + +has a value other than the default, then sequences of +the whitespace characters +space, + +tab, + +and +newline + +are ignored at the beginning and end of the +word, as long as the whitespace character is in the +value of +IFS + + +(an +IFS + + +whitespace character). +Any character in +IFS + + +that is not +IFS + + +whitespace, along with any adjacent +IFS + + +whitespace characters, delimits a field. +A sequence of +IFS + + +whitespace characters is also treated as a delimiter. +If the value of +IFS + + +is null, no word splitting occurs. +

+ +Explicit null arguments ("" or aqaq) are retained +and passed to commands as empty strings. +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 +and passed to a command as an empty string. +When a quoted null argument appears as part of a word whose expansion is +non-null, the null argument is removed. +That is, the word +-daqaq becomes -d after word splitting and +null argument removal. +

+ +Note that if no expansion occurs, no splitting +is performed. +  +

Pathname Expansion

+ +

+ +After word splitting, +unless the +-f + +option has been set, +bash + +scans each word for the characters +*, + +?, + +and +[. + +If one of these characters appears, then the word is +regarded as a +pattern, + +and replaced with an alphabetically sorted list of +filenames matching the pattern +(see +Pattern Matching + + +below). +If no matching filenames are found, +and the shell option +nullglob + +is not enabled, the word is left unchanged. +If the +nullglob + +option is set, and no matches are found, +the word is removed. +If the +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 +nocaseglob + +is enabled, the match is performed without regard to the case +of alphabetic characters. +When a pattern is used for pathname expansion, +the character +``.'' + +at the start of a name or immediately following a slash +must be matched explicitly, unless the shell option +dotglob + +is set. +When matching a pathname, the slash character must always be +matched explicitly. +In other cases, the +``.'' + +character is not treated specially. +See the description of +shopt + +below under +SHELL BUILTIN COMMANDS + + +for a description of the +nocaseglob, + +nullglob, + +failglob, + +and +dotglob + +shell options. +

+ +The +GLOBIGNORE + + +shell variable may be used to restrict the set of filenames matching a +pattern. + +If +GLOBIGNORE + + +is set, each matching filename that also matches one of the patterns in +GLOBIGNORE + + +is removed from the list of matches. +If the nocaseglob option is set, the matching against the patterns in +GLOBIGNORE + + +is performed without regard to case. +The filenames +``.'' + +and +``..'' + +are always ignored when +GLOBIGNORE + + +is set and not null. However, setting +GLOBIGNORE + + +to a non-null value has the effect of enabling the +dotglob + +shell option, so all other filenames beginning with a +``.'' + +will match. +To get the old behavior of ignoring filenames beginning with a +``.'', + +make +``.*'' + +one of the patterns in +GLOBIGNORE. + + +The +dotglob + +option is disabled when +GLOBIGNORE + + +is unset. +The pattern matching honors the setting of the extglob shell +option. +

+ +Pattern Matching +

+ +Any character that appears in a pattern, other than the special pattern +characters described below, matches itself. The 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: +

+ + +

+
+
* + +
+Matches any string, including the null string. +When the globstar shell option is enabled, and * is used in +a pathname expansion context, two adjacent *s used as a single +pattern will match all files and zero or more directories and +subdirectories. +If followed by a /, two adjacent *s will match only directories +and subdirectories. +
? + +
+Matches any single character. +
[...] + +
+Matches any one of the enclosed characters. A pair of characters +separated by a hyphen denotes a +range expression; +any character that falls between those two characters, inclusive, +using the current locale's collating sequence and character set, +is matched. If the first character following the +[ + +is a +! + +or a +^ + +then any character not enclosed is matched. +The sorting order of characters in range expressions is determined by +the current locale and the values of the +LC_COLLATE + + +or +LC_ALL + + +shell variables, if set. +To obtain the traditional interpretation of range expressions, where +[a-d] + +is equivalent to +[abcd], + +set value of the +LC_ALL + +shell variable to +C, + +or enable the +globasciiranges + +shell option. +A +- + +may be matched by including it as the first or last character +in the set. +A +] + +may be matched by including it as the first character +in the set. +
+ +

+ + +Within +[ + +and +], + +character classes can be specified using the syntax +[:class:], where class is one of the +following classes defined in the POSIX standard: +

+

+ +

+ + + +alnum alpha ascii blank cntrl digit graph lower print punct space upper word xdigit +
+ +A character class matches any character belonging to that class. +The word character class matches letters, digits, and the character _. +
+ +

+ + +Within +[ + +and +], + +an equivalence class can be specified using the syntax +[=c=], which matches all characters with the +same collation weight (as defined by the current locale) as +the character c. +
+ +

+ + +Within +[ + +and +], + +the syntax [.symbol.] matches the collating symbol +symbol. +

+ +
+ + +

+ +If the extglob shell option is enabled using the shopt +builtin, several extended pattern matching operators are recognized. +In the following description, a pattern-list is a list of one +or more patterns separated by a |. +Composite patterns may be formed using one or more of the following +sub-patterns: +

+ +

+
+
?(pattern-list)
+Matches zero or one occurrence of the given patterns +
*(pattern-list)
+Matches zero or more occurrences of the given patterns +
+(pattern-list)
+Matches one or more occurrences of the given patterns +
@(pattern-list)
+Matches one of the given patterns +
!(pattern-list)
+Matches anything except one of the given patterns +
+ + +  +

Quote Removal

+ +

+ +After the preceding expansions, all unquoted occurrences of the +characters +\, + +aq, + +and " that did not result from one of the above +expansions are removed. +  +

REDIRECTION

+ +Before a command is executed, its input and output +may be +redirected + +using a special notation interpreted by the shell. +Redirection allows commands' file handles to be +duplicated, opened, closed, +made to refer to different files, +and can change the files the command reads from and writes to. +Redirection may also be used to modify file handles in 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. +

+ +Each redirection that may be preceded by a file descriptor number +may instead be preceded by a word of the form {varname}. +In this case, for each redirection operator except +>&- and <&-, the shell will allocate a file descriptor greater +than or equal to 10 and assign it to varname. +If >&- or <&- is preceded +by {varname}, the value of varname defines the file +descriptor to close. +

+ +In the following descriptions, if the file descriptor number is +omitted, and the first character of the redirection operator is +<, + +the redirection refers to the standard input (file descriptor +0). If the first character of the redirection operator is +>, + +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 and variable expansion, +command substitution, arithmetic expansion, quote removal, +pathname 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 +

+

+ +ls > dirlist 2>&1 +

+ +

+ +directs both standard output and standard error to the file +dirlist, + +while the command +

+

+ +ls 2>&1 > dirlist +

+ +

+ +directs only the standard output to file +dirlist, + +because the standard error was duplicated from the standard output +before the standard output was redirected to +dirlist. + +

+ +Bash handles several filenames specially when they are used in +redirections, as described in the following table. +If the operating system on which bash is running provides these +special files, bash will use them; otherwise it will emulate them +internally with the behavior described below. +

+

+ + +

+
/dev/fd/fd + +
+If fd is a valid integer, file descriptor fd is duplicated. +
/dev/stdin + +
+File descriptor 0 is duplicated. +
/dev/stdout + +
+File descriptor 1 is duplicated. +
/dev/stderr + +
+File descriptor 2 is duplicated. +
/dev/tcp/host/port + +
+If host is a valid hostname or Internet address, and port +is an integer port number or service name, bash attempts to open +the corresponding TCP socket. +
/dev/udp/host/port + +
+If host is a valid hostname or Internet address, and port +is an integer port number or service name, bash attempts to open +the corresponding UDP 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. +  +

Redirecting Input

+ +

+ +Redirection of input causes the file whose name results from +the expansion of +word + +to be opened for reading on file descriptor +n, + +or the standard input (file descriptor 0) if +n + +is not specified. +

+ +The general format for redirecting input is: +

+

+ +[n]<word +

+ +  +

Redirecting Output

+ +

+ +Redirection of output causes the file whose name results from +the expansion of +word + +to be opened for writing on file descriptor +n, + +or the standard output (file descriptor 1) if +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: +

+

+ +[n]>word +

+ +

+ +If the redirection operator is +>, + +and the +noclobber + +option to the +set + +builtin has been enabled, the redirection will fail if the file +whose name results from the expansion of word exists and is +a regular file. +If the redirection operator is +>|, + +or the redirection operator is +> + +and the +noclobber + +option to the +set + +builtin command is not enabled, the redirection is attempted even +if the file named by word exists. +  +

Appending Redirected Output

+ +

+ +Redirection of output in this fashion +causes the file whose name results from +the expansion of +word + +to be opened for appending on file descriptor +n, + +or the standard output (file descriptor 1) if +n + +is not specified. If the file does not exist it is created. +

+ +The general format for appending output is: +

+

+ +[n]>>word +

+ +

+ +  +

Redirecting Standard Output and Standard Error

+ +

+ +This construct 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 +word. + +

+ +There are two formats for redirecting standard output and +standard error: +

+

+ +&>word +

+ +and +
+>&word +
+ +

+ +Of the two forms, the first is preferred. +This is semantically equivalent to +

+

+ +>word 2>&1 +

+ +

+ +When using the second form, word may not expand to a number or +-. If it does, other redirection operators apply +(see Duplicating File Descriptors below) for compatibility +reasons. +  +

Appending Standard Output and Standard Error

+ +

+ +This construct allows both the +standard output (file descriptor 1) and +the standard error output (file descriptor 2) +to be appended to the file whose name is the +expansion of +word. + +

+ +The format for appending standard output and standard error is: +

+

+ +&>>word +

+ +

+ +This is semantically equivalent to +

+

+ +>>word 2>&1 +

+ +

+ +(see Duplicating File Descriptors below). +  +

Here Documents

+ +

+ +This type of redirection instructs the shell to read input from the +current source until a line containing only +delimiter + +(with no trailing blanks) +is seen. All of +the lines read up to that point are then used as the standard +input (or file descriptor n if n is specified) for a command. +

+ +The format of here-documents is: +

+

+ +

+[n]<<[-]word
+        here-document
+delimiter
+
+ +
+ +

+ +No parameter and variable expansion, command substitution, +arithmetic expansion, or pathname expansion is performed on +word. + +If any part of +word + +is quoted, the +delimiter + +is the result of quote removal on +word, + +and the lines in the here-document are not expanded. +If word is unquoted, +all lines of the here-document are subjected to +parameter expansion, command substitution, and arithmetic expansion, +the character sequence +\<newline> + +is ignored, and +\ + +must be used to quote the characters +\, + +$, + +and +`. + +

+ +If the redirection operator is +<<-, + +then all leading tab characters are stripped from input lines and the +line containing +delimiter. + +This allows +here-documents within shell scripts to be indented in a +natural fashion. +  +

Here Strings

+ +A variant of here documents, the format is: +
+

+ +

+[n]<<<word
+
+ +
+ +

+ +The word undergoes +brace expansion, tilde expansion, parameter and variable expansion, +command substitution, arithmetic expansion, and quote removal. +Pathname expansion and word splitting are not performed. +The result is supplied as a single string, with a newline appended, +to the command on its +standard input (or file descriptor n if n is specified). +  +

Duplicating File Descriptors

+ +

+ +The redirection operator +

+

+ +[n]<&word +

+ +

+ +is used to duplicate input file descriptors. +If +word + +expands to one or more digits, the file descriptor denoted by +n + +is made to be a copy of that file descriptor. +If the digits in +word + +do not specify a file descriptor open for input, a redirection error occurs. +If +word + +evaluates to +-, + +file descriptor +n + +is closed. If +n + +is not specified, the standard input (file descriptor 0) is used. +

+ +The operator +

+

+ +[n]>&word +

+ +

+ +is used similarly to duplicate output file descriptors. If +n + +is not specified, the standard output (file descriptor 1) is used. +If the digits in +word + +do not specify a file descriptor open for output, a redirection error occurs. +If +word + +evaluates to +-, + +file descriptor +n + +is closed. +As a special case, if n is omitted, and word does not +expand to one or more digits or -, the standard output and standard +error are redirected as described previously. +  +

Moving File Descriptors

+ +

+ +The redirection operator +

+

+ +[n]<&digit- +

+ +

+ +moves the file descriptor digit to file descriptor +n, + +or the standard input (file descriptor 0) if n is not specified. +digit is closed after being duplicated to n. +

+ +Similarly, the redirection operator +

+

+ +[n]>&digit- +

+ +

+ +moves the file descriptor digit to file descriptor +n, + +or the standard output (file descriptor 1) if n is not specified. +  +

Opening File Descriptors for Reading and Writing

+ +

+ +The redirection operator +

+

+ +[n]<>word +

+ +

+ +causes the file whose name is the expansion of +word + +to be opened for both reading and writing on file descriptor +n, + +or on file descriptor 0 if +n + +is not specified. If the file does not exist, it is created. +  +

ALIASES

+ +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 +alias + +and +unalias + +builtin commands (see +SHELL BUILTIN COMMANDS + + +below). +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 /, $, `, and = 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 +ls + +to +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 +blank, + +then the next command +word following the alias is also checked for alias expansion. +

+ +Aliases are created and listed with the +alias + +command, and removed with the +unalias + +command. +

+ +There is no mechanism for using arguments in the replacement text. +If arguments are needed, a shell function should be used (see +FUNCTIONS + + +below). +

+ +Aliases are not expanded when the shell is not interactive, unless +the +expand_aliases + +shell option is set using +shopt + +(see the description of +shopt + +under +SHELL BUILTIN COMMANDS +below). +

+ +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 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 +alias + +in compound commands. +

+ +For almost every purpose, aliases are superseded by +shell functions. +  +

FUNCTIONS

+ +A shell function, defined as described above under +SHELL GRAMMAR, + + +stores a series of commands for later execution. +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. +Functions are executed in the context of the +current shell; no new process is created to interpret +them (contrast this with the execution of a shell script). +When a function is executed, the arguments to the +function become the positional parameters +during its execution. +The special parameter +# + +is updated to reflect the change. Special parameter 0 +is unchanged. +The first element of the +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 these exceptions: the +DEBUG + + +and +RETURN + +traps (see the description of the +trap + +builtin under +SHELL BUILTIN COMMANDS + + +below) are not inherited unless the function has been given the +trace attribute (see the description of the +declare + + +builtin below) or the +-o functrace shell option has been enabled with +the set builtin +(in which case all functions inherit the DEBUG and RETURN traps), +and the +ERR + + +trap is not inherited unless the -o errtrace shell option has +been enabled. +

+ +Variables local to the function may be declared with the +local + +builtin command. Ordinarily, variables and their values +are shared between the function and its caller. +

+ +The FUNCNEST variable, if set to a numeric value greater +than 0, defines a maximum function nesting level. Function +invocations that exceed the limit cause the entire command to +abort. +

+ +If the builtin command +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 RETURN trap is executed +before execution resumes. +When a function completes, the values of the +positional parameters and the special parameter +# + +are restored to the values they had prior to the function's +execution. +

+ +Function names and definitions may be listed with the +-f + +option to the +declare + +or +typeset + +builtin commands. The +-F + +option to +declare + +or +typeset + +will list the function names only +(and optionally the source file and line number, if the extdebug +shell option is enabled). +Functions may be exported so that subshells +automatically have them defined with the +-f + +option to the +export + +builtin. +A function definition may be deleted using the -f option to +the +unset + +builtin. +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. +The FUNCNEST variable may be used to limit the depth of the +function call stack and restrict the number of function invocations. +By default, no limit is imposed on the number of recursive calls. +  +

ARITHMETIC EVALUATION

+ +The shell allows arithmetic expressions to be evaluated, under +certain circumstances (see the let and declare builtin +commands, the (( compound command, and Arithmetic Expansion). +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. +

+ + +

+
id++ id-- + +
+variable post-increment and post-decrement +
++id --id + +
+variable pre-increment and pre-decrement +
- + + +
+unary minus and plus +
! ~ + +
+logical and bitwise negation +
** + +
+exponentiation +
* / % + +
+multiplication, division, remainder +
+ - + +
+addition, subtraction +
<< >> + +
+left and right bitwise shifts +
<= >= < > + +
+comparison +
== != + +
+equality and inequality +
& + +
+bitwise AND +
^ + +
+bitwise exclusive OR +
| + +
+bitwise OR +
&& + +
+logical AND +
|| + +
+logical OR +
expr?expr:expr + +
+conditional operator +
= *= /= %= += -= <<= >>= &= ^= |= + +
+assignment +
expr1 , expr2 + +
+comma + +
+

+ +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 +integer attribute using 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 0x or 0X denotes hexadecimal. +Otherwise, numbers take the form [base#]n, where the optional base +is a decimal number between 2 and 64 representing the arithmetic +base, and n is a number in that base. +If base# is omitted, then base 10 is used. +When specifying n, +the digits greater than 9 are represented by the lowercase letters, +the uppercase letters, @, and _, in that order. +If 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. +  +

CONDITIONAL EXPRESSIONS

+ +Conditional expressions are used by the [[ compound command and +the test and [ builtin commands to test file attributes +and perform string and arithmetic comparisons. +Expressions are formed from the following unary or binary primaries. +Bash handles several filenames specially when they are used in +expressions. +If the operating system on which bash is running provides these +special files, bash will use them; otherwise it will emulate them +internally with this behavior: +If any file argument to one of the primaries is of the form +/dev/fd/n, then file descriptor n is checked. +If the file argument to one of the primaries is one of +/dev/stdin, /dev/stdout, or /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. +

+ + +When used with [[, the < and > operators sort +lexicographically using the current locale. +The test command sorts using ASCII ordering. +

+ +

+
-a file + +
+True if file exists. +
-b file + +
+True if file exists and is a block special file. +
-c file + +
+True if file exists and is a character special file. +
-d file + +
+True if file exists and is a directory. +
-e file + +
+True if file exists. +
-f file + +
+True if file exists and is a regular file. +
-g file + +
+True if file exists and is set-group-id. +
-h file + +
+True if file exists and is a symbolic link. +
-k file + +
+True if file exists and its ``sticky'' bit is set. +
-p file + +
+True if file exists and is a named pipe (FIFO). +
-r file + +
+True if file exists and is readable. +
-s file + +
+True if file exists and has a size greater than zero. +
-t fd + +
+True if file descriptor +fd + +is open and refers to a terminal. +
-u file + +
+True if file exists and its set-user-id bit is set. +
-w file + +
+True if file exists and is writable. +
-x file + +
+True if file exists and is executable. +
-G file + +
+True if file exists and is owned by the effective group id. +
-L file + +
+True if file exists and is a symbolic link. +
-N file + +
+True if file exists and has been modified since it was last read. +
-O file + +
+True if file exists and is owned by the effective user id. +
-S file + +
+True if file exists and is a socket. +
file1 -ef file2
+True if file1 and file2 refer to the same device and +inode numbers. +
file1 -nt file2
+True if file1 is newer (according to modification date) than file2, +or if file1 exists and file2 does not. +
file1 -ot file2
+True if file1 is older than file2, or if file2 exists +and file1 does not. +
-o optname + +
+True if the shell option +optname + +is enabled. +See the list of options under the description of the +-o + +option to the +set + +builtin below. +
-v varname + +
+True if the shell variable +varname + +is set (has been assigned a value). +
-R varname + +
+True if the shell variable +varname + +is set and is a name reference. +
-z string + +
+True if the length of string is zero. +
string
+ +
-n string + +
+ +True if the length of +string + +is non-zero. +
string1 == string2
+ +
string1 = string2
+ +True if the strings are equal. = should be used +with the test command for POSIX conformance. +When used with the [[ command, this performs pattern matching as +described above (Compound Commands). +
string1 != string2
+True if the strings are not equal. +
string1 < string2
+True if string1 sorts before string2 lexicographically. +
string1 > string2
+True if string1 sorts after string2 lexicographically. +
arg1 OP arg2 + +
+OP + + +is one of +-eq, + +-ne, + +-lt, + +-le, + +-gt, + +or +-ge. + +These arithmetic binary operators return true if arg1 +is equal to, not equal to, less than, less than or equal to, +greater than, or greater than or equal to arg2, respectively. +Arg1 + +and +arg2 + +may be positive or negative integers. + +
+  +

SIMPLE COMMAND EXPANSION

+ +When a simple command is executed, the shell performs the following +expansions, assignments, and redirections, from left to right. +
+
1.
+The words that the parser has marked as variable assignments (those +preceding the command name) and redirections are saved for later +processing. +
2.
+The words that are not variable assignments or redirections are +expanded. 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. +
3.
+Redirections are performed as described above under +REDIRECTION. + + +
4.
+The text after the = in each variable assignment undergoes tilde +expansion, parameter expansion, command substitution, arithmetic expansion, +and quote removal before being assigned to the variable. +
+

+ +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. +  +

COMMAND EXECUTION

+ +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. +

+ +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 above in +FUNCTIONS. + + +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. +

+ +If the name is neither a shell function nor a builtin, +and contains no slashes, +bash + +searches each element of the +PATH + + +for a directory containing an executable file by that name. +Bash + +uses a hash table to remember the full pathnames of executable +files (see +hash + +under +SHELL BUILTIN COMMANDS + + +below). +A full search of the directories in +PATH + + +is performed only if the command is not found in the hash table. +If the search is unsuccessful, the shell searches for a defined shell +function named command_not_found_handle. +If that function exists, it is invoked with the original command and +the original command's arguments as its arguments, and the function's +exit status becomes the exit status of the shell. +If that function is not defined, the shell prints an error +message and returns an exit status of 127. +

+ +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 given, if any. +

+ +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 shell script, a file +containing shell commands. A subshell is spawned to execute +it. This subshell reinitializes itself, so +that the effect is as if a new shell had been invoked +to handle the script, with the exception that the locations of +commands remembered by the parent (see +hash + +below under +SHELL BUILTIN COMMANDS) +are retained by the child. +

+ +If the program is a file beginning with +#!, + +the remainder of the first line specifies an interpreter +for the program. The shell executes the +specified interpreter on operating systems that do not +handle this executable format themselves. The arguments to the +interpreter consist of a single optional argument following the +interpreter name on the first line of the program, followed +by the name of the program, followed by the command +arguments, if any. +  +

COMMAND EXECUTION ENVIRONMENT

+ +The shell has an execution environment, which consists of the +following: +
+
*
+open files inherited by the shell at invocation, as modified by +redirections supplied to the exec builtin +
*
+the current working directory as set by cd, pushd, or +popd, or inherited by the shell at invocation +
*
+the file creation mode mask as set by umask or inherited from +the shell's parent +
*
+current traps set by trap +
*
+shell parameters that are set by variable assignment or with set +or inherited from the shell's parent in the environment +
*
+shell functions defined during execution or inherited from the shell's +parent in the environment +
*
+options enabled at invocation (either by default or with command-line +arguments) or by set +
*
+options enabled by shopt +
*
+shell aliases defined with alias +
*
+various process IDs, including those of background jobs, the value +of $$, and the value of +PPID + + +
+

+ +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. + +

+
*
+the shell's open files, plus any modifications and additions specified +by redirections to the command +
*
+the current working directory +
*
+the file creation mode mask +
*
+shell variables and functions marked for export, along with variables +exported for the command, passed in the environment +
*
+traps caught by the shell are reset to the values inherited from the +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, 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. +

+ +Subshells spawned to execute command substitutions inherit the value of +the -e option from the parent shell. When not in posix mode, +bash clears the -e option in such subshells. +

+ +If a command is followed by a & and job control is not active, the +default standard input for the command is the empty file /dev/null. +Otherwise, the invoked command inherits the file descriptors of the calling +shell as modified by redirections. +  +

ENVIRONMENT

+ +When a program is invoked it is given an array of strings +called the +environment. + +This is a list of +name-value pairs, of the form +name=value. + +

+ +The shell 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 +export + +to child processes. Executed commands inherit the environment. +The +export + +and +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 +unset + +command, plus any additions via the +export + +and +declare -x + +commands. +

+ +The environment for any +simple command + +or function may be augmented temporarily by prefixing it with +parameter assignments, as described above in +PARAMETERS. + + +These assignment statements affect only the environment seen +by that command. +

+ +If the +-k + +option is set (see the +set + +builtin command below), 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 +_ + +is set to the full filename of the command and passed to that +command in its environment. +  +

EXIT STATUS

+ +

+ +The exit status of an executed command is the value returned by the +waitpid system call or equivalent function. Exit statuses +fall between 0 and 255, though, as explained below, the shell may +use values above 125 specially. Exit statuses from shell builtins and +compound commands are also limited to this range. Under certain +circumstances, the shell will use special values to indicate specific +failure modes. +

+ +For the shell's purposes, a command which exits with a +zero exit status has succeeded. An exit status of zero +indicates success. A non-zero exit status indicates failure. +When a command terminates on a fatal signal N, bash uses +the value of 128+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. +

+ +Shell builtin commands return a status of 0 (true) if +successful, and non-zero (false) if an error occurs +while they execute. +All builtins return an exit status of 2 to indicate incorrect usage, +generally invalid options or missing arguments. +

+ +Bash itself returns the exit status of the last command +executed, unless a syntax error occurs, in which case it exits +with a non-zero value. See also the exit builtin +command below. +  +

SIGNALS

+ +When bash is interactive, in the absence of any traps, it ignores +SIGTERM + + +(so that kill 0 does not kill an interactive shell), +and +SIGINT + + +is caught and handled (so that the wait builtin is interruptible). +In all cases, bash ignores +SIGQUIT. + + +If job control is in effect, +bash + +ignores +SIGTTIN, + + +SIGTTOU, + + +and +SIGTSTP. + + +

+ +Non-builtin commands run 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 +SIGINT + + +and +SIGQUIT + + +in addition to these inherited handlers. +Commands run as a result of command substitution ignore the +keyboard-generated job control signals +SIGTTIN, + + +SIGTTOU, + + +and +SIGTSTP. + + +

+ +The shell exits by default upon receipt of a +SIGHUP. + + +Before exiting, an interactive shell resends the +SIGHUP + + +to all jobs, running or stopped. +Stopped jobs are sent +SIGCONT + + +to ensure that they receive the +SIGHUP. + + +To prevent the shell from +sending the signal to a particular job, it should be removed from the +jobs table with the +disown + +builtin (see +SHELL BUILTIN COMMANDS + + +below) or marked +to not receive +SIGHUP + + +using +disown -h. + +

+ +If the +huponexit + +shell option has been set with +shopt, + +bash + +sends a +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 wait +builtin, the reception of a signal for which a trap has been set will +cause the wait builtin to return immediately with an exit status +greater than 128, immediately after which the trap is executed. +  +

JOB CONTROL

+ +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 operating system kernel's terminal driver and +bash. + +

+ +The shell associates a +job + +with each pipeline. It keeps a table of currently executing +jobs, which may be listed with the +jobs + +command. When +bash + +starts a job asynchronously (in the +background), + +it prints a line that looks like: +

+

+ +[1] 25647 +

+ +

+ +indicating that this job is job number 1 and that the process 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 +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 ID. Members of this process group (processes whose +process group ID is equal to the current terminal process group ID) +receive keyboard-generated signals such as +SIGINT. + + +These processes are said to be in the +foreground. + +Background + +processes are those whose process group ID differs from the terminal's; +such processes are immune to keyboard-generated signals. +Only foreground processes are allowed to read from or, if the +user so specifies with stty tostop, write to the +terminal. +Background processes which attempt to read from (write to when +stty tostop is in effect) the +terminal are sent a +SIGTTIN (SIGTTOU) + + +signal by the kernel's 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 +suspend + +character (typically +^Z, + +Control-Z) while a process is running +causes that process to be stopped and returns control to +bash. + +Typing the +delayed suspend + +character (typically +^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 may then manipulate the state of this job, using the +bg + +command to continue it in the background, the +fg + +command to continue it in the foreground, or +the +kill + +command to kill it. A ^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 +% + +introduces a job specification (jobspec). Job number +n + +may be referred to as +%n. + +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, +%ce + +refers to a stopped +ce + +job. If a prefix matches more than one job, +bash + +reports an error. Using +%?ce, + +on the other hand, refers to any job containing the string +ce + +in its command line. If the substring matches more than one job, +bash + +reports an error. The symbols +%% + +and +%+ + +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 +%-. + +If there is only a single job, %+ and %- can both be used +to refer to that job. +In output pertaining to jobs (e.g., the output of the +jobs + +command), the current job is always flagged with a ++, + +and the previous job with a +-. + +A single % (with no accompanying job specification) also refers to the +current job. +

+ +Simply naming a job can be used to bring it into the +foreground: +%1 + +is a synonym for +``fg %1'', +bringing job 1 from the background into the foreground. +Similarly, +``%1 &'' + +resumes job 1 in the background, equivalent to +``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 +-b + +option to the +set + +builtin command +is enabled, +bash + +reports such changes immediately. +Any trap on +SIGCHLD + + +is executed for each child that exits. +

+ +If an attempt to exit +bash + +is made while jobs are stopped (or, if the checkjobs shell option has +been enabled using the shopt builtin, running), the shell prints a +warning message, and, if the checkjobs option is enabled, lists the +jobs and their statuses. +The +jobs + +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 any stopped +jobs are terminated. +  +

PROMPTING

+ +When executing interactively, +bash + +displays the primary prompt +PS1 + + +when it is ready to read a command, and the secondary prompt +PS2 + + +when it needs more input to complete a command. +Bash + +displays +PS0 + +after it reads a command but before executing it. +Bash + +allows these prompt strings to be customized by inserting a number of +backslash-escaped special characters that are decoded as follows: +
+ +
+
\a + +
+an ASCII bell character (07) +
\d + +
+the date in "Weekday Month Date" format (e.g., "Tue May 26") +
\D{format} + +
+the format is passed to strftime(3) and the result is inserted +into the prompt string; an empty format results in a locale-specific +time representation. The braces are required +
\e + +
+an ASCII escape character (033) +
\h + +
+the hostname up to the first `.' +
\H + +
+the hostname +
\j + +
+the number of jobs currently managed by the shell +
\l + +
+the basename of the shell's terminal device name +
\n + +
+newline +
\r + +
+carriage return +
\s + +
+the name of the shell, the basename of +$0 + +(the portion following the final slash) +
\t + +
+the current time in 24-hour HH:MM:SS format +
\T + +
+the current time in 12-hour HH:MM:SS format +
\@ + +
+the current time in 12-hour am/pm format +
\A + +
+the current time in 24-hour HH:MM format +
\u + +
+the username of the current user +
\v + +
+the version of bash (e.g., 2.00) +
\V + +
+the release of bash, version + patch level (e.g., 2.00.0) +
\w + +
+the current working directory, with +$HOME + + +abbreviated with a tilde +(uses the value of the +PROMPT_DIRTRIM + + +variable) +
\W + +
+the basename of the current working directory, with +$HOME + + +abbreviated with a tilde +
\! + +
+the history number of this command +
\# + +
+the command number of this command +
\$ + +
+if the effective UID is 0, a +#, + +otherwise a +$ + +
\nnn + +
+the character corresponding to the octal number nnn +
\\ + +
+a backslash +
\[ + +
+begin a sequence of non-printing characters, which could be used to +embed a terminal control sequence into the prompt +
\] + +
+end a sequence of non-printing characters + +
+ +

+ +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 +(see +HISTORY + + +below), 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 +promptvars + +shell option (see the description of the +shopt + +command under +SHELL BUILTIN COMMANDS + + +below). +  +

READLINE

+ +This is the library that handles reading input when using an interactive +shell, unless the +--noediting + +option is given at shell invocation. +Line editing is also used when using the -e option to the +read builtin. +By default, the line editing commands are similar to those of Emacs. +A vi-style line editing interface is also available. +Line editing can be enabled at any time using the +-o emacs + +or +-o vi + +options to the +set + +builtin (see +SHELL BUILTIN COMMANDS + + +below). +To turn off line editing after the shell is running, use the ++o emacs + +or ++o vi + +options to the +set + +builtin. +  +

Readline Notation

+ +

+ +In this section, the Emacs-style notation is used to denote +keystrokes. Control keys are denoted by C-key, e.g., C-n +means Control-N. Similarly, +meta + +keys are denoted by M-key, so M-x means Meta-X. (On keyboards +without a +meta + +key, M-x means ESC x, i.e., press the Escape key +then the +x + +key. This makes ESC the meta prefix. +The combination M-C-x means ESC-Control-x, +or press the Escape key +then hold the Control key while pressing the +x + +key.) +

+ +Readline commands may be given numeric +arguments, + +which normally act as a repeat count. +Sometimes, however, it is the sign of the argument that is significant. +Passing a negative argument to a command that acts in the forward +direction (e.g., kill-line) causes that command to act in a +backward direction. +Commands whose behavior with arguments deviates from this are noted +below. +

+ +When a command is described as killing text, the text +deleted is saved for possible future retrieval +(yanking). The killed text is saved in a +kill ring. Consecutive kills cause the text to be +accumulated into one unit, which can be yanked all at once. +Commands which do not kill text separate the chunks of text +on the kill ring. +  +

Readline Initialization

+ +

+ +Readline is customized by putting commands in an initialization +file (the inputrc file). +The name of this file is taken from the value of the +INPUTRC + + +variable. If that variable is unset, the default is +~/.inputrc. + +When a program which uses the readline library starts up, the +initialization file is read, and the key bindings and variables +are set. +There are only a few basic constructs allowed in the +readline initialization file. +Blank lines are ignored. +Lines beginning with a # are comments. +Lines beginning with a $ indicate conditional constructs. +Other lines denote key bindings and variable settings. +

+ +The default key-bindings may be changed with an +inputrc + +file. +Other programs that use this library may add their own commands +and bindings. +

+ +For example, placing +

+

+ +M-Control-u: universal-argument +

+ +or +
+C-Meta-u: universal-argument +
+ +into the +inputrc + +would make M-C-u execute the readline command +universal-argument. + +

+ +The following symbolic character names are recognized: +RUBOUT, + +DEL, + +ESC, + +LFD, + +NEWLINE, + +RET, + +RETURN, + +SPC, + +SPACE, + +and +TAB. + +

+ +In addition to command names, readline allows keys to be bound +to a string that is inserted when the key is pressed (a macro). +  +

Readline Key Bindings

+ +

+ +The syntax for controlling key bindings in the +inputrc + +file is simple. All that is required is the name of the +command or the text of a macro and a key sequence to which +it should be bound. The name may be specified in one of two ways: +as a symbolic key name, possibly with Meta- or Control- +prefixes, or as a key sequence. +

+ +When using the form keyname:function-name or macro, +keyname + +is the name of a key spelled out in English. For example: +

+

+Control-u: universal-argument +
+ +Meta-Rubout: backward-kill-word +
+ +Control-o: "> output" +
+ +

+ +In the above example, +C-u + +is bound to the function +universal-argument, + +M-DEL + +is bound to the function +backward-kill-word, + +and +C-o + +is bound to run the macro +expressed on the right hand side (that is, to insert the text +> output + +into the line). +

+ +In the second form, "keyseq":function-name or macro, +keyseq + +differs from +keyname + +above in that strings denoting +an entire key sequence may be specified by placing the sequence +within double quotes. Some GNU Emacs style key escapes can be +used, as in the following example, but the symbolic character names +are not recognized. +

+

+"\C-u": universal-argument +
+ +"\C-x\C-r": re-read-init-file +
+ +"\e[11~": "Function Key 1" +
+ +

+ +In this example, +C-u + +is again bound to the function +universal-argument. + +C-x C-r + +is bound to the function +re-read-init-file, + +and +ESC [ 1 1 ~ + +is bound to insert the text +Function Key 1. + +

+ +The full set of GNU Emacs style escape sequences is +

+ +
+
\C- + +
+control prefix +
\M- + +
+meta prefix +
\e + +
+an escape character +
\\ + +
+backslash +
\ + +
+literal " +
\aq + +
+literal aq +
+ + +

+ +In addition to the GNU Emacs style escape sequences, a second +set of backslash escapes is available: +

+ +
+
\a + +
+alert (bell) +
\b + +
+backspace +
\d + +
+delete +
\f + +
+form feed +
\n + +
+newline +
\r + +
+carriage return +
\t + +
+horizontal tab +
\v + +
+vertical tab +
\nnn + +
+the eight-bit character whose value is the octal value nnn +(one to three digits) +
\xHH + +
+the eight-bit character whose value is the hexadecimal value HH +(one or two hex digits) +
+ + +

+ +When entering the text of a macro, single or double quotes must +be used to indicate a macro definition. +Unquoted text is assumed to be a function name. +In the macro body, the backslash escapes described above are expanded. +Backslash will quote any other character in the macro text, +including " and aq. +

+ +Bash + +allows the current readline key bindings to be displayed or modified +with the +bind + +builtin command. The editing mode may be switched during interactive +use by using the +-o + +option to the +set + +builtin command (see +SHELL BUILTIN COMMANDS + + +below). +  +

Readline Variables

+ +

+ +Readline has variables that can be used to further customize its +behavior. A variable may be set in the +inputrc + +file with a statement of the form +

+

+ +set variable-name value +

+ +

+ +Except where noted, readline variables can take the values +On + +or +Off + +(without regard to case). +Unrecognized variable names are ignored. +When a variable value is read, empty or null values, "on" (case-insensitive), +and "1" are equivalent to On. All other values are equivalent to +Off. +The variables and their default values are: +

+ + +

+
bell-style (audible) + +
+Controls what happens when readline wants to ring the terminal bell. +If set to none, readline never rings the bell. If set to +visible, readline uses a visible bell if one is available. +If set to audible, readline attempts to ring the terminal's bell. +
bind-tty-special-chars (On) + +
+If set to On, readline attempts to bind the control characters +treated specially by the kernel's terminal driver to their readline +equivalents. +
blink-matching-paren (Off) + +
+If set to On, readline attempts to briefly move the cursor to an +opening parenthesis when a closing parenthesis is inserted. +
colored-completion-prefix (Off) + +
+If set to On, when listing completions, readline displays the +common prefix of the set of possible completions using a different color. +The color definitions are taken from the value of the LS_COLORS +environment variable. +
colored-stats (Off) + +
+If set to On, readline displays possible completions using different +colors to indicate their file type. +The color definitions are taken from the value of the LS_COLORS +environment variable. +
comment-begin (``#'') + +
+The string that is inserted when the readline +insert-comment + +command is executed. +This command is bound to +M-# + +in emacs mode and to +# + +in vi command mode. +
completion-display-width (-1) + +
+The number of screen columns used to display possible matches +when performing completion. +The value is ignored if it is less than 0 or greater than the terminal +screen width. +A value of 0 will cause matches to be displayed one per line. +The default value is -1. +
completion-ignore-case (Off) + +
+If set to On, readline performs filename matching and completion +in a case-insensitive fashion. +
completion-map-case (Off) + +
+If set to On, and completion-ignore-case is enabled, readline +treats hyphens (-) and underscores (_) as equivalent when +performing case-insensitive filename matching and completion. +
completion-prefix-display-length (0) + +
+The length in characters of the common prefix of a list of possible +completions that is displayed without modification. When set to a +value greater than zero, common prefixes longer than this value are +replaced with an ellipsis when displaying possible completions. +
completion-query-items (100) + +
+This determines when the user is queried about viewing +the number of possible completions +generated by the possible-completions command. +It may be set to any integer value greater than or equal to +zero. If the number of possible completions is greater than +or equal to the value of this variable, the user is asked whether +or not he wishes to view them; otherwise they are simply listed +on the terminal. +
convert-meta (On) + +
+If set to On, readline will convert characters with the +eighth bit set to an ASCII key sequence +by stripping the eighth bit and prefixing an +escape character (in effect, using escape as the meta prefix). +The default is On, but readline will set it to Off if the +locale contains eight-bit characters. +
disable-completion (Off) + +
+If set to On, readline will inhibit word completion. Completion +characters will be inserted into the line as if they had been +mapped to self-insert. +
echo-control-characters (On) + +
+When set to On, on operating systems that indicate they support it, +readline echoes a character corresponding to a signal generated from the +keyboard. +
editing-mode (emacs) + +
+Controls whether readline begins with a set of key bindings similar +to Emacs or vi. +editing-mode + +can be set to either +emacs + +or +vi. + +
enable-bracketed-paste (Off) + +
+When set to On, readline will configure the terminal in a way +that will enable it to insert each paste into the editing buffer as a +single string of characters, instead of treating each character as if +it had been read from the keyboard. This can prevent pasted characters +from being interpreted as editing commands. +
enable-keypad (Off) + +
+When set to On, readline will try to enable the application +keypad when it is called. Some systems need this to enable the +arrow keys. +
enable-meta-key (On) + +
+When set to On, readline will try to enable any meta modifier +key the terminal claims to support when it is called. On many terminals, +the meta key is used to send eight-bit characters. +
expand-tilde (Off) + +
+If set to On, tilde expansion is performed when readline +attempts word completion. +
history-preserve-point (Off) + +
+If set to On, the history code attempts to place point at the +same location on each history line retrieved with previous-history +or next-history. +
history-size (unset) + +
+Set the maximum number of history entries saved in the history list. +If set to zero, any existing history entries are deleted and no new entries +are saved. +If set to a value less than zero, the number of history entries is not +limited. +By default, the number of history entries is set to the value of the +HISTSIZE shell variable. +If an attempt is made to set history-size to a non-numeric value, +the maximum number of history entries will be set to 500. +
horizontal-scroll-mode (Off) + +
+When set to On, makes readline use a single line for display, +scrolling the input horizontally on a single screen line when it +becomes longer than the screen width rather than wrapping to a new line. +
input-meta (Off) + +
+If set to On, readline will enable eight-bit input (that is, +it will not strip the eighth bit from the characters it reads), +regardless of what the terminal claims it can support. The name +meta-flag + +is a synonym for this variable. +The default is Off, but readline will set it to On if the +locale contains eight-bit characters. +
isearch-terminators (``C-[C-J'') + +
+The string of characters that should terminate an incremental +search without subsequently executing the character as a command. +If this variable has not been given a value, the characters +ESC and C-J will terminate an incremental search. +
keymap (emacs) + +
+Set the current readline keymap. The set of valid keymap names is +emacs, emacs-standard, emacs-meta, emacs-ctlx, vi, +vi-command, and +vi-insert. + +vi is equivalent to vi-command; emacs is +equivalent to emacs-standard. The default value is +emacs; + +the value of +editing-mode + +also affects the default keymap. +
emacs-mode-string (@) + +
+This string is displayed immediately before the last line of the primary +prompt when emacs editing mode is active. The value is expanded like a +key binding, so the standard set of meta- and control prefixes and +backslash escape sequences is available. +Use the \1 and \2 escapes to begin and end sequences of +non-printing characters, which can be used to embed a terminal control +sequence into the mode string. +
keyseq-timeout (500) + +
+Specifies the duration readline will wait for a character when reading an +ambiguous key sequence (one that can form a complete key sequence using +the input read so far, or can take additional input to complete a longer +key sequence). +If no input is received within the timeout, readline will use the shorter +but complete key sequence. +The value is specified in milliseconds, so a value of 1000 means that +readline will wait one second for additional input. +If this variable is set to a value less than or equal to zero, or to a +non-numeric value, readline will wait until another key is pressed to +decide which key sequence to complete. +
mark-directories (On) + +
+If set to On, completed directory names have a slash +appended. +
mark-modified-lines (Off) + +
+If set to On, history lines that have been modified are displayed +with a preceding asterisk (*). +
mark-symlinked-directories (Off) + +
+If set to On, completed names which are symbolic links to directories +have a slash appended (subject to the value of +mark-directories). +
match-hidden-files (On) + +
+This variable, when set to On, causes readline to match files whose +names begin with a `.' (hidden files) when performing filename +completion. +If set to Off, the leading `.' must be +supplied by the user in the filename to be completed. +
menu-complete-display-prefix (Off) + +
+If set to On, menu completion displays the common prefix of the +list of possible completions (which may be empty) before cycling through +the list. +
output-meta (Off) + +
+If set to On, readline will display characters with the +eighth bit set directly rather than as a meta-prefixed escape +sequence. +The default is Off, but readline will set it to On if the +locale contains eight-bit characters. +
page-completions (On) + +
+If set to On, readline uses an internal more-like pager +to display a screenful of possible completions at a time. +
print-completions-horizontally (Off) + +
+If set to On, readline will display completions with matches +sorted horizontally in alphabetical order, rather than down the screen. +
revert-all-at-newline (Off) + +
+If set to On, readline will undo all changes to history lines +before returning when accept-line is executed. By default, +history lines may be modified and retain individual undo lists across +calls to readline. +
show-all-if-ambiguous (Off) + +
+This alters the default behavior of the completion functions. If +set to +On, + +words which have more than one possible completion cause the +matches to be listed immediately instead of ringing the bell. +
show-all-if-unmodified (Off) + +
+This alters the default behavior of the completion functions in +a fashion similar to show-all-if-ambiguous. +If set to +On, + +words which have more than one possible completion without any +possible partial completion (the possible completions don't share +a common prefix) cause the matches to be listed immediately instead +of ringing the bell. +
show-mode-in-prompt (Off) + +
+If set to On, add a character to the beginning of the prompt +indicating the editing mode: emacs (@), vi command (:) or vi +insertion (+). +
skip-completed-text (Off) + +
+If set to On, this alters the default completion behavior when +inserting a single match into the line. It's only active when +performing completion in the middle of a word. If enabled, readline +does not insert characters from the completion that match characters +after point in the word being completed, so portions of the word +following the cursor are not duplicated. +
vi-cmd-mode-string ((cmd)) + +
+This string is displayed immediately before the last line of the primary +prompt when vi editing mode is active and in command mode. +The value is expanded like a +key binding, so the standard set of meta- and control prefixes and +backslash escape sequences is available. +Use the \1 and \2 escapes to begin and end sequences of +non-printing characters, which can be used to embed a terminal control +sequence into the mode string. +
vi-ins-mode-string ((ins)) + +
+This string is displayed immediately before the last line of the primary +prompt when vi editing mode is active and in insertion mode. +The value is expanded like a +key binding, so the standard set of meta- and control prefixes and +backslash escape sequences is available. +Use the \1 and \2 escapes to begin and end sequences of +non-printing characters, which can be used to embed a terminal control +sequence into the mode string. +
visible-stats (Off) + +
+If set to On, a character denoting a file's type as reported +by stat(2) is appended to the filename when listing possible +completions. + +
+  +

Readline Conditional Constructs

+ +

+ +Readline implements a facility similar in spirit to the conditional +compilation features of the C preprocessor which allows key +bindings and variable settings to be performed as the result +of tests. There are four parser directives used. +

+
$if
+The +$if + +construct allows bindings to be made based on the +editing mode, the terminal being used, or the application using +readline. The text of the test extends to the end of the line; +no characters are required to isolate it. +
+
+
mode
+The mode= form of the $if directive is used to test +whether readline is in emacs or vi mode. +This may be used in conjunction +with the set keymap command, for instance, to set bindings in +the emacs-standard and emacs-ctlx keymaps only if +readline is starting out in emacs mode. +
term
+The term= form may be used to include terminal-specific +key bindings, perhaps to bind the key sequences output by the +terminal's function keys. The word on the right side of the += + +is tested against both the full name of the terminal and the portion +of the terminal name before the first -. This allows +sun + +to match both +sun + +and +sun-cmd, + +for instance. +
application
+The application construct is used to include +application-specific settings. Each program using the readline +library sets the application name, and an initialization +file can test for a particular value. +This could be used to bind key sequences to functions useful for +a specific program. For instance, the following command adds a +key sequence that quotes the current or previous word in bash: +

+

+
+$if Bash
+# Quote the current or previous word
+"\C-xq": "\eb\"\ef\""
+$endif
+
+ +
+ +
+ +
$endif
+This command, as seen in the previous example, terminates an +$if command. +
$else
+Commands in this branch of the $if directive are executed if +the test fails. +
$include
+This directive takes a single filename as an argument and reads commands +and bindings from that file. For example, the following directive +would read /etc/inputrc: +

+

+
+$include  /etc/inputrc
+
+ +
+ +
+  +

Searching

+ +

+ +Readline provides commands for searching through the command history +(see +HISTORY + + +below) for lines containing a specified string. +There are two search modes: +incremental + +and +non-incremental. + +

+ +Incremental searches begin before the user has finished typing the +search string. +As each character of the search string is typed, readline displays +the next entry from the history matching the string typed so far. +An incremental search requires only as many characters as needed to +find the desired history entry. +The characters present in the value of the isearch-terminators +variable are used to terminate an incremental search. +If that variable has not been assigned a value the Escape and +Control-J characters will terminate an incremental search. +Control-G will abort an incremental search and restore the original +line. +When the search is terminated, the history entry containing the +search string becomes the current line. +

+ +To find other matching entries in the history list, type Control-S or +Control-R as appropriate. +This will search backward or forward in the history for the next +entry matching the search string typed so far. +Any other key sequence bound to a readline command will terminate +the search and execute that command. +For instance, a newline will terminate the search and accept +the line, thereby executing the command from the history list. +

+ +Readline remembers the last incremental search string. If two +Control-Rs are typed without any intervening characters defining a +new search string, any remembered search string is used. +

+ +Non-incremental searches read the entire search string before starting +to search for matching history lines. The search string may be +typed by the user or be part of the contents of the current line. +  +

Readline Command Names

+ +

+ +The following is a list of the names of the commands and the default +key sequences to which they are bound. +Command names without an accompanying key sequence are unbound by default. +In the following descriptions, point refers to the current cursor +position, and mark refers to a cursor position saved by the +set-mark command. +The text between the point and mark is referred to as the region. +  +

Commands for Moving

+ +

+ + +

+
beginning-of-line (C-a) + +
+Move to the start of the current line. +
end-of-line (C-e) + +
+Move to the end of the line. +
forward-char (C-f) + +
+Move forward a character. +
backward-char (C-b) + +
+Move back a character. +
forward-word (M-f) + +
+Move forward to the end of the next word. Words are composed of +alphanumeric characters (letters and digits). +
backward-word (M-b) + +
+Move back to the start of the current or previous word. +Words are composed of alphanumeric characters (letters and digits). +
shell-forward-word + +
+Move forward to the end of the next word. +Words are delimited by non-quoted shell metacharacters. +
shell-backward-word + +
+Move back to the start of the current or previous word. +Words are delimited by non-quoted shell metacharacters. +
clear-screen (C-l) + +
+Clear the screen leaving the current line at the top of the screen. +With an argument, refresh the current line without clearing the +screen. +
redraw-current-line + +
+Refresh the current line. + +
+  +

Commands for Manipulating the History

+ +

+ + +

+
accept-line (Newline, Return) + +
+Accept the line regardless of where the cursor is. If this line is +non-empty, add it to the history list according to the state of the +HISTCONTROL + + +variable. If the line is a modified history +line, then restore the history line to its original state. +
previous-history (C-p) + +
+Fetch the previous command from the history list, moving back in +the list. +
next-history (C-n) + +
+Fetch the next command from the history list, moving forward in the +list. +
beginning-of-history (M-<) + +
+Move to the first line in the history. +
end-of-history (M->) + +
+Move to the end of the input history, i.e., the line currently being +entered. +
reverse-search-history (C-r) + +
+Search backward starting at the current line and moving `up' through +the history as necessary. This is an incremental search. +
forward-search-history (C-s) + +
+Search forward starting at the current line and moving `down' through +the history as necessary. This is an incremental search. +
non-incremental-reverse-search-history (M-p) + +
+Search backward through the history starting at the current line +using a non-incremental search for a string supplied by the user. +
non-incremental-forward-search-history (M-n) + +
+Search forward through the history using a non-incremental search for +a string supplied by the user. +
history-search-forward + +
+Search forward through the history for the string of characters +between the start of the current line and the point. +This is a non-incremental search. +
history-search-backward + +
+Search backward through the history for the string of characters +between the start of the current line and the point. +This is a non-incremental search. +
yank-nth-arg (M-C-y) + +
+Insert the first argument to the previous command (usually +the second word on the previous line) at point. +With an argument +n, + +insert the nth word from the previous command (the words +in the previous command begin with word 0). A negative argument +inserts the nth word from the end of the previous command. +Once the argument n is computed, the argument is extracted +as if the "!n" history expansion had been specified. +
yank-last-arg (M-., M-_) + +
+Insert the last argument to the previous command (the last word of +the previous history entry). +With a numeric argument, behave exactly like yank-nth-arg. +Successive calls to yank-last-arg move back through the history +list, inserting the last word (or the word specified by the argument to +the first call) of each line in turn. +Any numeric argument supplied to these successive calls determines +the direction to move through the history. A negative argument switches +the direction through the history (back or forward). +The history expansion facilities are used to extract the last word, +as if the "!$" history expansion had been specified. +
shell-expand-line (M-C-e) + +
+Expand the line as the shell does. This +performs alias and history expansion as well as all of the shell +word expansions. See +HISTORY EXPANSION + + +below for a description of history expansion. +
history-expand-line (M-^) + +
+Perform history expansion on the current line. +See +HISTORY EXPANSION + + +below for a description of history expansion. +
magic-space + +
+Perform history expansion on the current line and insert a space. +See +HISTORY EXPANSION + + +below for a description of history expansion. +
alias-expand-line + +
+Perform alias expansion on the current line. +See +ALIASES + + +above for a description of alias expansion. +
history-and-alias-expand-line + +
+Perform history and alias expansion on the current line. +
insert-last-argument (M-., M-_) + +
+A synonym for yank-last-arg. +
operate-and-get-next (C-o) + +
+Accept the current line for execution and fetch the next line +relative to the current line from the history for editing. Any +argument is ignored. +
edit-and-execute-command (C-xC-e) + +
+Invoke an editor on the current command line, and execute the result as shell +commands. +Bash attempts to invoke +$VISUAL, + + +$EDITOR, + + +and emacs as the editor, in that order. + +
+  +

Commands for Changing Text

+ +

+ + +

+
end-of-file (usually C-d) + +
+The character indicating end-of-file as set, for example, by +stty. + +If this character is read when there are no characters +on the line, and point is at the beginning of the line, Readline +interprets it as the end of input and returns +EOF. + + +
delete-char (C-d) + +
+Delete the character at point. +If this function is bound to the +same character as the tty EOF character, as C-d +commonly is, see above for the effects. +
backward-delete-char (Rubout) + +
+Delete the character behind the cursor. When given a numeric argument, +save the deleted text on the kill ring. +
forward-backward-delete-char + +
+Delete the character under the cursor, unless the cursor is at the +end of the line, in which case the character behind the cursor is +deleted. +
quoted-insert (C-q, C-v) + +
+Add the next character typed to the line verbatim. This is +how to insert characters like C-q, for example. +
tab-insert (C-v TAB) + +
+Insert a tab character. +
self-insert (a, b, A, 1, !, ...) + +
+Insert the character typed. +
transpose-chars (C-t) + +
+Drag the character before point forward over the character at point, +moving point forward as well. +If point is at the end of the line, then this transposes +the two characters before point. +Negative arguments have no effect. +
transpose-words (M-t) + +
+Drag the word before point past the word after point, +moving point over that word as well. +If point is at the end of the line, this transposes +the last two words on the line. +
upcase-word (M-u) + +
+Uppercase the current (or following) word. With a negative argument, +uppercase the previous word, but do not move point. +
downcase-word (M-l) + +
+Lowercase the current (or following) word. With a negative argument, +lowercase the previous word, but do not move point. +
capitalize-word (M-c) + +
+Capitalize the current (or following) word. With a negative argument, +capitalize the previous word, but do not move point. +
overwrite-mode + +
+Toggle overwrite mode. With an explicit positive numeric argument, +switches to overwrite mode. With an explicit non-positive numeric +argument, switches to insert mode. This command affects only +emacs mode; vi mode does overwrite differently. +Each call to readline() starts in insert mode. +In overwrite mode, characters bound to self-insert replace +the text at point rather than pushing the text to the right. +Characters bound to backward-delete-char replace the character +before point with a space. By default, this command is unbound. + +
+  +

Killing and Yanking

+ +

+ + +

+
kill-line (C-k) + +
+Kill the text from point to the end of the line. +
backward-kill-line (C-x Rubout) + +
+Kill backward to the beginning of the line. +
unix-line-discard (C-u) + +
+Kill backward from point to the beginning of the line. +The killed text is saved on the kill-ring. + +
kill-whole-line + +
+Kill all characters on the current line, no matter where point is. +
kill-word (M-d) + +
+Kill from point to the end of the current word, or if between +words, to the end of the next word. +Word boundaries are the same as those used by forward-word. +
backward-kill-word (M-Rubout) + +
+Kill the word behind point. +Word boundaries are the same as those used by backward-word. +
shell-kill-word + +
+Kill from point to the end of the current word, or if between +words, to the end of the next word. +Word boundaries are the same as those used by shell-forward-word. +
shell-backward-kill-word + +
+Kill the word behind point. +Word boundaries are the same as those used by shell-backward-word. +
unix-word-rubout (C-w) + +
+Kill the word behind point, using white space as a word boundary. +The killed text is saved on the kill-ring. +
unix-filename-rubout + +
+Kill the word behind point, using white space and the slash character +as the word boundaries. +The killed text is saved on the kill-ring. +
delete-horizontal-space (M-\) + +
+Delete all spaces and tabs around point. +
kill-region + +
+Kill the text in the current region. +
copy-region-as-kill + +
+Copy the text in the region to the kill buffer. +
copy-backward-word + +
+Copy the word before point to the kill buffer. +The word boundaries are the same as backward-word. +
copy-forward-word + +
+Copy the word following point to the kill buffer. +The word boundaries are the same as forward-word. +
yank (C-y) + +
+Yank the top of the kill ring into the buffer at point. +
yank-pop (M-y) + +
+Rotate the kill ring, and yank the new top. Only works following +yank + +or +yank-pop. + + +
+  +

Numeric Arguments

+ +

+ + +

+
digit-argument (M-0, M-1, ..., M--) + +
+Add this digit to the argument already accumulating, or start a new +argument. M-- starts a negative argument. +
universal-argument + +
+This is another way to specify an argument. +If this command is followed by one or more digits, optionally with a +leading minus sign, those digits define the argument. +If the command is followed by digits, executing +universal-argument + +again ends the numeric argument, but is otherwise ignored. +As a special case, if this command is immediately followed by a +character that is neither a digit nor minus sign, the argument count +for the next command is multiplied by four. +The argument count is initially one, so executing this function the +first time makes the argument count four, a second time makes the +argument count sixteen, and so on. + +
+  +

Completing

+ +

+ + +

+
complete (TAB) + +
+Attempt to perform completion on the text before point. +Bash + +attempts completion treating the text as a variable (if the +text begins with $), username (if the text begins with +~), hostname (if the text begins with @), or +command (including aliases and functions) in turn. If none +of these produces a match, filename completion is attempted. +
possible-completions (M-?) + +
+List the possible completions of the text before point. +
insert-completions (M-*) + +
+Insert all completions of the text before point +that would have been generated by +possible-completions. +
menu-complete + +
+Similar to complete, but replaces the word to be completed +with a single match from the list of possible completions. +Repeated execution of menu-complete steps through the list +of possible completions, inserting each match in turn. +At the end of the list of completions, the bell is rung +(subject to the setting of bell-style) +and the original text is restored. +An argument of n moves n positions forward in the list +of matches; a negative argument may be used to move backward +through the list. +This command is intended to be bound to TAB, but is unbound +by default. +
menu-complete-backward + +
+Identical to menu-complete, but moves backward through the list +of possible completions, as if menu-complete had been given a +negative argument. This command is unbound by default. +
delete-char-or-list + +
+Deletes the character under the cursor if not at the beginning or +end of the line (like delete-char). +If at the end of the line, behaves identically to +possible-completions. +This command is unbound by default. +
complete-filename (M-/) + +
+Attempt filename completion on the text before point. +
possible-filename-completions (C-x /) + +
+List the possible completions of the text before point, +treating it as a filename. +
complete-username (M-~) + +
+Attempt completion on the text before point, treating +it as a username. +
possible-username-completions (C-x ~) + +
+List the possible completions of the text before point, +treating it as a username. +
complete-variable (M-$) + +
+Attempt completion on the text before point, treating +it as a shell variable. +
possible-variable-completions (C-x $) + +
+List the possible completions of the text before point, +treating it as a shell variable. +
complete-hostname (M-@) + +
+Attempt completion on the text before point, treating +it as a hostname. +
possible-hostname-completions (C-x @) + +
+List the possible completions of the text before point, +treating it as a hostname. +
complete-command (M-!) + +
+Attempt completion on the text before point, treating +it as a command name. Command completion attempts to +match the text against aliases, reserved words, shell +functions, shell builtins, and finally executable filenames, +in that order. +
possible-command-completions (C-x !) + +
+List the possible completions of the text before point, +treating it as a command name. +
dynamic-complete-history (M-TAB) + +
+Attempt completion on the text before point, comparing +the text against lines from the history list for possible +completion matches. +
dabbrev-expand + +
+Attempt menu completion on the text before point, comparing +the text against lines from the history list for possible +completion matches. +
complete-into-braces (M-{) + +
+Perform filename completion and insert the list of possible completions +enclosed within braces so the list is available to the shell (see +Brace Expansion + +above). + +
+  +

Keyboard Macros

+ +

+ + +

+
start-kbd-macro (C-x () + +
+Begin saving the characters typed into the current keyboard macro. +
end-kbd-macro (C-x )) + +
+Stop saving the characters typed into the current keyboard macro +and store the definition. +
call-last-kbd-macro (C-x e) + +
+Re-execute the last keyboard macro defined, by making the characters +in the macro appear as if typed at the keyboard. +
print-last-kbd-macro () + +
+Print the last keyboard macro defined in a format suitable for the +inputrc file. + +
+  +

Miscellaneous

+ +

+ + +

+
re-read-init-file (C-x C-r) + +
+Read in the contents of the inputrc file, and incorporate +any bindings or variable assignments found there. +
abort (C-g) + +
+Abort the current editing command and +ring the terminal's bell (subject to the setting of +bell-style). + +
do-uppercase-version (M-a, M-b, M-x, ...) + +
+If the metafied character x is lowercase, run the command +that is bound to the corresponding uppercase character. +
prefix-meta (ESC) + +
+Metafy the next character typed. +ESC + + +f + +is equivalent to +Meta-f. + +
undo (C-_, C-x C-u) + +
+Incremental undo, separately remembered for each line. +
revert-line (M-r) + +
+Undo all changes made to this line. This is like executing the +undo + +command enough times to return the line to its initial state. +
tilde-expand (M-&) + +
+Perform tilde expansion on the current word. +
set-mark (C-@, M-<space>) + +
+Set the mark to the point. If a +numeric argument is supplied, the mark is set to that position. +
exchange-point-and-mark (C-x C-x) + +
+Swap the point with the mark. The current cursor position is set to +the saved position, and the old cursor position is saved as the mark. +
character-search (C-]) + +
+A character is read and point is moved to the next occurrence of that +character. A negative count searches for previous occurrences. +
character-search-backward (M-C-]) + +
+A character is read and point is moved to the previous occurrence of that +character. A negative count searches for subsequent occurrences. +
skip-csi-sequence + +
+Read enough characters to consume a multi-key sequence such as those +defined for keys like Home and End. Such sequences begin with a +Control Sequence Indicator (CSI), usually ESC-[. If this sequence is +bound to "\[", keys producing such sequences will have no effect +unless explicitly bound to a readline command, instead of inserting +stray characters into the editing buffer. This is unbound by default, +but usually bound to ESC-[. +
insert-comment (M-#) + +
+Without a numeric argument, the value of the readline +comment-begin + +variable is inserted at the beginning of the current line. +If a numeric argument is supplied, this command acts as a toggle: if +the characters at the beginning of the line do not match the value +of comment-begin, the value is inserted, otherwise +the characters in comment-begin are deleted from the beginning of +the line. +In either case, the line is accepted as if a newline had been typed. +The default value of +comment-begin causes this command to make the current line +a shell comment. +If a numeric argument causes the comment character to be removed, the line +will be executed by the shell. +
glob-complete-word (M-g) + +
+The word before point is treated as a pattern for pathname expansion, +with an asterisk implicitly appended. This pattern is used to +generate a list of matching filenames for possible completions. +
glob-expand-word (C-x *) + +
+The word before point is treated as a pattern for pathname expansion, +and the list of matching filenames is inserted, replacing the word. +If a numeric argument is supplied, an asterisk is appended before +pathname expansion. +
glob-list-expansions (C-x g) + +
+The list of expansions that would have been generated by +glob-expand-word + +is displayed, and the line is redrawn. +If a numeric argument is supplied, an asterisk is appended before +pathname expansion. +
dump-functions + +
+Print all of the functions and their key bindings to the +readline output stream. If a numeric argument is supplied, +the output is formatted in such a way that it can be made part +of an inputrc file. +
dump-variables + +
+Print all of the settable readline variables and their values to the +readline output stream. If a numeric argument is supplied, +the output is formatted in such a way that it can be made part +of an inputrc file. +
dump-macros + +
+Print all of the readline key sequences bound to macros and the +strings they output. If a numeric argument is supplied, +the output is formatted in such a way that it can be made part +of an inputrc file. +
display-shell-version (C-x C-v) + +
+Display version information about the current instance of +bash. + + +
+  +

Programmable Completion

+ +

+ +When word completion is attempted for an argument to a command for +which a completion specification (a compspec) has been defined +using the complete builtin (see +SHELL BUILTIN COMMANDS + + +below), the programmable completion facilities are invoked. +

+ +First, the command name is identified. +If the command word is the empty string (completion attempted at the +beginning of an empty line), any compspec defined with +the -E option to complete is used. +If a compspec has been defined for that command, the +compspec is used to generate the list of possible completions for the word. +If the command word is a full pathname, a compspec for the full +pathname is searched for first. +If no compspec is found for the full pathname, an attempt is made to +find a compspec for the portion following the final slash. +If those searches do not result in a compspec, any compspec defined with +the -D option to complete is used as the default. +

+ +Once a compspec has been found, it is used to generate the list of +matching words. +If a compspec is not found, the default bash completion as +described above under Completing is performed. +

+ +First, the actions specified by the compspec are used. +Only matches which are prefixed by the word being completed are +returned. +When the +-f + +or +-d + +option is used for filename or directory name completion, the shell +variable +FIGNORE + + +is used to filter the matches. +

+ +Any completions specified by a pathname expansion pattern to the +-G option are generated next. +The words generated by the pattern need not match the word +being completed. +The +GLOBIGNORE + + +shell variable is not used to filter the matches, but the +FIGNORE + + +variable is used. +

+ +Next, the string specified as the argument to the -W option +is considered. +The string is first split using the characters in the +IFS + + +special variable as delimiters. +Shell quoting is honored. +Each word is then expanded using +brace expansion, tilde expansion, parameter and variable expansion, +command substitution, and arithmetic expansion, +as described above under +EXPANSION. + + +The results are split using the rules described above under +Word Splitting. +The results of the expansion are prefix-matched against the word being +completed, and the matching words become the possible completions. +

+ +After these matches have been generated, any shell function or command +specified with the -F and -C options is invoked. +When the command or function is invoked, the +COMP_LINE, + + +COMP_POINT, + + +COMP_KEY, + + +and +COMP_TYPE + + +variables are assigned values as described above under +Shell Variables. +If a shell function is being invoked, the +COMP_WORDS + + +and +COMP_CWORD + + +variables are also set. +When the function or command is invoked, +the first argument ($1) is the name of the command whose arguments are +being completed, +the second argument ($2) is the word being completed, +and the third argument ($3) is the word preceding the word being +completed on the current command line. +No filtering of the generated completions against the word being completed +is performed; the function or command has complete freedom in generating +the matches. +

+ +Any function specified with -F is invoked first. +The function may use any of the shell facilities, including the +compgen builtin described below, to generate the matches. +It must put the possible completions in the +COMPREPLY + + +array variable, one per array element. +

+ +Next, any command specified with the -C option is invoked +in an environment equivalent to command substitution. +It should print a list of completions, one per line, to the +standard output. +Backslash may be used to escape a newline, if necessary. +

+ +After all of the possible completions are generated, any filter +specified with the -X option is applied to the list. +The filter is a pattern as used for pathname expansion; a & +in the pattern is replaced with the text of the word being completed. +A literal & may be escaped with a backslash; the backslash +is removed before attempting a match. +Any completion that matches the pattern will be removed from the list. +A leading ! negates the pattern; in this case any completion +not matching the pattern will be removed. +If the +nocasematch + +shell option is enabled, the match is performed without regard to the case +of alphabetic characters. +

+ +Finally, any prefix and suffix specified with the -P and -S +options are added to each member of the completion list, and the result is +returned to the readline completion code as the list of possible +completions. +

+ +If the previously-applied actions do not generate any matches, and the +-o dirnames option was supplied to complete when the +compspec was defined, directory name completion is attempted. +

+ +If the -o plusdirs option was supplied to complete when the +compspec was defined, directory name completion is attempted and any +matches are added to the results of the other actions. +

+ +By default, if a compspec is found, whatever it generates is returned +to the completion code as the full set of possible completions. +The default bash completions are not attempted, and the readline +default of filename completion is disabled. +If the -o bashdefault option was supplied to complete when +the compspec was defined, the bash default completions are attempted +if the compspec generates no matches. +If the -o default option was supplied to complete when the +compspec was defined, readline's default completion will be performed +if the compspec (and, if attempted, the default bash completions) +generate no matches. +

+ +When a compspec indicates that directory name completion is desired, +the programmable completion functions force readline to append a slash +to completed names which are symbolic links to directories, subject to +the value of the mark-directories readline variable, regardless +of the setting of the mark-symlinked-directories readline variable. +

+ +There is some support for dynamically modifying completions. This is +most useful when used in combination with a default completion specified +with complete -D. +It's possible for shell functions executed as completion +handlers to indicate that completion should be retried by returning an +exit status of 124. If a shell function returns 124, and changes +the compspec associated with the command on which completion is being +attempted (supplied as the first argument when the function is executed), +programmable completion restarts from the beginning, with an +attempt to find a new compspec for that command. This allows a set of +completions to be built dynamically as completion is attempted, rather than +being loaded all at once. +

+ +For instance, assuming that there is a library of compspecs, each kept in a +file corresponding to the name of the command, the following default +completion function would load completions dynamically: +

+ +_completion_loader() +
+ +{ +
+ +       . "/etc/bash_completion.d/$1.sh" >/dev/null 2>&1 && return 124
+
+ +} +
+ +complete -D -F _completion_loader -o bashdefault -o default +
+ +
+  +

HISTORY

+ +When the +-o history + +option to the +set + +builtin is enabled, the shell provides access to the +command history, +the list of commands previously typed. +The value of the +HISTSIZE + + +variable is used as the +number of commands to save in a history list. +The text of the last +HISTSIZE + + +commands (default 500) is saved. The shell +stores each command in the history list prior to parameter and +variable expansion (see +EXPANSION + + +above) but after history expansion is performed, subject to the +values of the shell variables +HISTIGNORE + + +and +HISTCONTROL. + + +

+ +On startup, the history is initialized from the file named by +the variable +HISTFILE + + +(default ~/.bash_history). +The file named by the value of +HISTFILE + + +is truncated, if necessary, to contain no more than +the number of lines specified by the value of +HISTFILESIZE. + + +If HISTFILESIZE is unset, or set to null, a non-numeric value, +or a numeric value less than zero, the history file is not truncated. +When the history file is read, +lines beginning with the history comment character followed immediately +by a digit are interpreted as timestamps for the preceding history line. +These timestamps are optionally displayed depending on the value of the +HISTTIMEFORMAT + + +variable. +When a shell with history enabled exits, the last +$HISTSIZE + + +lines are copied from the history list to +$HISTFILE. + + +If the +histappend + +shell option is enabled +(see the description of +shopt + +under +SHELL BUILTIN COMMANDS + + +below), the lines are appended to the history file, +otherwise the history file is overwritten. +If +HISTFILE + + +is unset, or if the history file is unwritable, the history is +not saved. +If the +HISTTIMEFORMAT + + +variable is set, time stamps are written to the history file, marked +with the history comment character, so +they may be preserved across shell sessions. +This uses the history comment character to distinguish timestamps from +other history lines. +After saving the history, the history file is truncated +to contain no more than +HISTFILESIZE + + +lines. If +HISTFILESIZE + + +is unset, or set to null, a non-numeric value, +or a numeric value less than zero, the history file is not truncated. +

+ +The builtin command +fc + +(see +SHELL BUILTIN COMMANDS + + +below) may be used to list or edit and re-execute a portion of +the history list. +The +history + +builtin may be used to display or modify the history list and +manipulate the history file. +When using command-line editing, search commands +are available in each editing mode that provide access to the +history list. +

+ +The shell allows control over which commands are saved on the history +list. The +HISTCONTROL + + +and +HISTIGNORE + + +variables may be set to cause the shell to save only a subset of the +commands entered. +The +cmdhist + +shell option, if enabled, causes the shell to attempt to save each +line of a multi-line command in the same history entry, adding +semicolons where necessary to preserve syntactic correctness. +The +lithist + +shell option causes the shell to save the command with embedded newlines +instead of semicolons. See the description of the +shopt + +builtin below under +SHELL BUILTIN COMMANDS + + +for information on setting and unsetting shell options. +  +

HISTORY EXPANSION

+ +

+ +The shell supports a history expansion feature that +is similar to the history expansion in +csh. + +This section describes what syntax features are available. This +feature is enabled by default for interactive shells, and can be +disabled using the ++H + +option to the +set + +builtin command (see +SHELL BUILTIN COMMANDS + + +below). Non-interactive shells do not perform history expansion +by default. +

+ +History expansions introduce words from the history list into +the input stream, making it easy to repeat commands, insert the +arguments to a previous command into the current input line, or +fix errors in previous commands quickly. +

+ +History expansion is performed immediately after a complete line +is read, before the shell breaks it into words. +It takes place in two parts. +The first is to determine which line from the history list +to use during substitution. +The second is to select portions of that line for inclusion into +the current one. +The line selected from the history is the event, +and the portions of that line that are acted upon are words. +Various modifiers are available to manipulate the selected words. +The line is broken into words in the same fashion as when reading input, +so that several metacharacter-separated words surrounded by +quotes are considered one word. +History expansions are introduced by the appearance of the +history expansion character, which is ! by default. +Only backslash (\) and single quotes can quote +the history expansion character, but the history expansion character is +also treated as quoted if it immediately precedes the closing double quote +in a double-quoted string. +

+ +Several characters inhibit history expansion if found immediately +following the history expansion character, even if it is unquoted: +space, tab, newline, carriage return, and =. +If the extglob shell option is enabled, ( will also +inhibit expansion. +

+ +Several shell options settable with the +shopt + +builtin may be used to tailor the behavior of history expansion. +If the +histverify + +shell option is enabled (see the description of the +shopt + +builtin below), and +readline + +is being used, history substitutions are not immediately passed to +the shell parser. +Instead, the expanded line is reloaded into the +readline + +editing buffer for further modification. +If +readline + +is being used, and the +histreedit + +shell option is enabled, a failed history substitution will be reloaded +into the +readline + +editing buffer for correction. +The +-p + +option to the +history + +builtin command may be used to see what a history expansion will +do before using it. +The +-s + +option to the +history + +builtin may be used to add commands to the end of the history list +without actually executing them, so that they are available for +subsequent recall. +

+ +The shell allows control of the various characters used by the +history expansion mechanism (see the description of +histchars + +above under +Shell Variables). + +The shell uses +the history comment character to mark history timestamps when +writing the history file. +  +

Event Designators

+ +

+ +An event designator is a reference to a command line entry in the +history list. +Unless the reference is absolute, events are relative to the current +position in the history list. +

+ + +

+
! + +
+Start a history substitution, except when followed by a +blank, + +newline, carriage return, = +or ( (when the extglob shell option is enabled using +the shopt builtin). +
!n + +
+Refer to command line +n. + +
!-n + +
+Refer to the current command minus +n. + +
!! + +
+Refer to the previous command. This is a synonym for `!-1'. +
!string + +
+Refer to the most recent command preceding the current position in the +history list starting with +string. + +
!?string[?] + +
+Refer to the most recent command preceding the current position in the +history list containing +string. + +The trailing ? may be omitted if +string + +is followed immediately by a newline. +
^string1^string2^ + +
+Quick substitution. Repeat the previous command, replacing +string1 + +with +string2. + +Equivalent to +``!!:s/string1/string2/'' +(see Modifiers below). +
!# + +
+The entire command line typed so far. + +
+  +

Word Designators

+ +

+ +Word designators are used to select desired words from the event. +A +: + +separates the event specification from the word designator. +It may be omitted if the word designator begins with a +^, + +$, + +*, + +-, + +or +%. + +Words are numbered from the beginning of the line, +with the first word being denoted by 0 (zero). +Words are inserted into the current line separated by single spaces. +

+ + +

+
0 (zero) + +
+The zeroth word. For the shell, this is the command +word. +
n + +
+The nth word. +
^ + +
+The first argument. That is, word 1. +
$ + +
+The last word. This is usually the last argument, but will expand to the +zeroth word if there is only one word in the line. +
% + +
+The word matched by the most recent `?string?' search. +
x-y + +
+A range of words; `-y' abbreviates `0-y'. +
* + +
+All of the words but the zeroth. This is a synonym +for `1-$'. It is not an error to use +* + +if there is just one +word in the event; the empty string is returned in that case. +
x* + +
+Abbreviates x-$. +
x- + +
+Abbreviates x-$ like x*, but omits the last word. + +
+

+ +If a word designator is supplied without an event specification, the +previous command is used as the event. +  +

Modifiers

+ +

+ +After the optional word designator, there may appear a sequence of +one or more of the following modifiers, each preceded by a `:'. +

+ + +

+ +

+
h + +
+Remove a trailing filename component, leaving only the head. +
t + +
+Remove all leading filename components, leaving the tail. +
r + +
+Remove a trailing suffix of the form .xxx, leaving the +basename. +
e + +
+Remove all but the trailing suffix. +
p + +
+Print the new command but do not execute it. +
q + +
+Quote the substituted words, escaping further substitutions. +
x + +
+Quote the substituted words as with +q, + +but break into words at +blanks + +and newlines. +
s/old/new/ + +
+Substitute +new + +for the first occurrence of +old + +in the event line. Any delimiter can be used in place of /. The +final delimiter is optional if it is the last character of the +event line. The delimiter may be quoted in +old + +and +new + +with a single backslash. If & appears in +new, + +it is replaced by +old. + +A single backslash will quote the &. If +old + +is null, it is set to the last +old + +substituted, or, if no previous history substitutions took place, +the last +string + +in a +!?string[?] + +search. +
& + +
+Repeat the previous substitution. +
g + +
+Cause changes to be applied over the entire event line. This is +used in conjunction with `:s' (e.g., `:gs/old/new/') +or `:&'. If used with +`:s', any delimiter can be used +in place of /, and the final delimiter is optional +if it is the last character of the event line. +An a may be used as a synonym for g. +
G + +
+Apply the following `s' modifier once to each word in the event line. + +
+  +

SHELL BUILTIN COMMANDS

+ + + +

+ +Unless otherwise noted, each builtin command documented in this +section as accepting options preceded by +- + +accepts +-- + +to signify the end of the options. +The :, true, false, and test builtins +do not accept options and do not treat -- specially. +The exit, logout, return, +break, continue, let, +and shift builtins accept and process arguments beginning with +- without requiring --. +Other builtins that accept arguments but are not specified as accepting +options interpret arguments beginning with - as invalid options and +require -- to prevent this interpretation. +

+ +

+
: [arguments]
+ +No effect; the command does nothing beyond expanding +arguments + +and performing any specified +redirections. +The return status is zero. +
. filename [arguments]
+ +
source filename [arguments]
+ +Read and execute commands from +filename + +in the current +shell environment and return the exit status of the last command +executed from +filename. + +If +filename + +does not contain a slash, filenames in +PATH + + +are used to find the directory containing +filename. + +The file searched for in +PATH + + +need not be executable. +When bash is not in posix mode, the current directory is +searched if no file is found in +PATH. + + +If the +sourcepath + +option to the +shopt + +builtin command is turned off, the +PATH + + +is not searched. +If any arguments are supplied, they become the positional +parameters when filename is executed. Otherwise the positional +parameters are unchanged. +If the -T option is enabled, source inherits any trap on +DEBUG; if it is not, any DEBUG trap string is saved and +restored around the call to source, and source unsets the +DEBUG trap while it executes. +If -T is not set, and the sourced file changes +the DEBUG trap, the new value is retained when source completes. +The return status is the status of the last command exited within +the script (0 if no commands are executed), and false if +filename + +is not found or cannot be read. +
alias [-p] [name[=value] ...]
+Alias with no arguments or with the +-p + +option prints the list of aliases in the form +alias name=value on standard output. +When arguments are supplied, an alias is defined for +each name whose value is given. +A trailing space in value causes the next word to be +checked for alias substitution when the alias is expanded. +For each name in the argument list for which no value +is supplied, the name and value of the alias is printed. +Alias returns true unless a name is given for which +no alias has been defined. +
bg [jobspec ...]
+Resume each suspended job jobspec in the background, as if it +had been started with +&. + +If +jobspec + +is not present, the shell's notion of the current job is used. +bg + +jobspec + +returns 0 unless run when job control is disabled or, when run with +job control enabled, any specified jobspec was not found +or was started without job control. +
bind [-m keymap] [-lpsvPSVX]
+ +
bind [-m keymap] [-q function] [-u function] [-r keyseq]
+
bind [-m keymap] -f filename
+
bind [-m keymap] -x keyseq:shell-command
+
bind [-m keymap] keyseq:function-name
+
bind [-m keymap] keyseq:readline-command
+ +Display current +readline + +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 +.inputrc, + +but each binding or command must be passed as a separate argument; +e.g., '"\C-x\C-r": re-read-init-file'. +Options, if supplied, have the following meanings: +
+ +
+
-m keymap + +
+Use +keymap + +as the keymap to be affected by the subsequent bindings. +Acceptable +keymap + +names are +emacs, emacs-standard, emacs-meta, emacs-ctlx, vi, +vi-move, vi-command, and +vi-insert. + +vi is equivalent to vi-command (vi-move is also +a synonym); emacs is +equivalent to emacs-standard. +
-l + +
+List the names of all readline functions. +
-p + +
+Display readline function names and bindings in such a way +that they can be re-read. +
-P + +
+List current readline function names and bindings. +
-s + +
+Display readline key sequences bound to macros and the strings +they output in such a way that they can be re-read. +
-S + +
+Display readline key sequences bound to macros and the strings +they output. +
-v + +
+Display readline variable names and values in such a way that they +can be re-read. +
-V + +
+List current readline variable names and values. +
-f filename + +
+Read key bindings from filename. +
-q function + +
+Query about which keys invoke the named function. +
-u function + +
+Unbind all keys bound to the named function. +
-r keyseq + +
+Remove any current binding for keyseq. +
-x keyseq:shell-command + +
+Cause shell-command to be executed whenever keyseq is +entered. +When shell-command is executed, the shell sets the +READLINE_LINE + + +variable to the contents of the readline line buffer and the +READLINE_POINT + + +variable to the current location of the insertion point. +If the executed command changes the value of +READLINE_LINE + + +or +READLINE_POINT, + + +those new values will be reflected in the editing state. +
-X + +
+List all key sequences bound to shell commands and the associated commands +in a format that can be reused as input. + +
+

+ +The return value is 0 unless an unrecognized option is given or an +error occurred. +

+ +
break [n]
+Exit from within a +for, + +while, + +until, + +or +select + +loop. If n is specified, break n levels. +n + +must be >= 1. If +n + +is greater than the number of enclosing loops, all enclosing loops +are exited. +The return value is 0 unless n is not greater than or equal to 1. +
builtin shell-builtin [arguments]
+Execute the specified shell builtin, passing it +arguments, + +and return its exit status. +This is useful when defining a +function whose name is the same as a shell builtin, +retaining the functionality of the builtin within the function. +The cd builtin is commonly redefined this way. +The return status is false if +shell-builtin + +is not a shell builtin command. +
caller [expr]
+Returns the context of any active subroutine call (a shell function or +a script executed with the . or source builtins). +Without expr, caller displays the line number and source +filename of the current subroutine call. +If a non-negative integer is supplied as expr, 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 expr does not correspond to a valid position in the +call stack. +
cd [-L|[-P [-e]] [-@]] [dir]
+Change the current directory to dir. +if dir is not supplied, the value of the +HOME + + +shell variable is the default. +Any additional arguments following dir are ignored. +The variable +CDPATH + + +defines the search path for the directory containing +dir: + +each directory name in +CDPATH + + +is searched for dir. +Alternative directory names in +CDPATH + + +are separated by a colon (:). A null directory name in +CDPATH + + +is the same as the current directory, i.e., ``.''. If +dir + +begins with a slash (/), +then +CDPATH + + +is not used. The +-P + +option causes cd to use the physical directory structure +by resolving symbolic links while traversing dir and +before processing instances of .. in dir (see also the +-P + +option to the +set + +builtin command); the +-L + +option forces symbolic links to be followed by resolving the link +after processing instances of .. in dir. +If .. appears in dir, it is processed by removing the +immediately previous pathname component from dir, back to a slash +or the beginning of dir. +If the +-e + +option is supplied with +-P, + +and the current working directory cannot be successfully determined +after a successful directory change, cd will return an unsuccessful +status. +On systems that support it, the -@ option presents the extended +attributes associated with a file as a directory. +An argument of +- + +is converted to +$OLDPWD + + +before the directory change is attempted. +If a non-empty directory name from +CDPATH + + +is used, or if +- 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 value is true if the directory was successfully changed; +false otherwise. +
command [-pVv] command [arg ...]
+Run +command + +with +args + +suppressing the normal shell function lookup. +Only builtin commands or commands found in the +PATH + + +are executed. If the +-p + +option is given, the search for +command + +is performed using a default value for +PATH + + +that is guaranteed to find all of the standard utilities. +If either the +-V + +or +-v + +option is supplied, a description of +command + +is printed. The +-v + +option causes a single word indicating the command or filename +used to invoke +command + +to be displayed; the +-V + +option produces a more verbose description. +If the +-V + +or +-v + +option is supplied, the exit status is 0 if +command + +was found, and 1 if not. If neither option is supplied and +an error occurred or +command + +cannot be found, the exit status is 127. Otherwise, the exit status of the +command + +builtin is the exit status of +command. + +
compgen [option] [word]
+Generate possible completion matches for word according to +the options, which may be any option accepted by the +complete + +builtin with the exception of -p and -r, and write +the matches to the standard output. +When using the -F or -C options, the various shell variables +set by the programmable completion facilities, while available, will not +have useful values. +

+The matches will be generated in the same way as if the programmable +completion code had generated them directly from a completion specification +with the same flags. +If word is specified, only those completions matching word +will be displayed. +

+The return value is true unless an invalid option is supplied, or no +matches were generated. +

complete [-abcdefgjksuv] [-o comp-option] [-DE] [-A action] [-G globpat] [-W wordlist] [-F function] [-C command]
+
+ +[-X filterpat] [-P prefix] [-S suffix] name [name ...] + +
complete -pr [-DE] [name ...]
+ +Specify how arguments to each name should be completed. +If the -p option is supplied, or if no options are supplied, +existing completion specifications are printed in a way that allows +them to be reused as input. +The -r option removes a completion specification for +each name, or, if no names are supplied, all +completion specifications. +The -D option indicates that the remaining options and actions should +apply to the ``default'' command completion; that is, completion attempted +on a command for which no completion has previously been defined. +The -E option indicates that the remaining options and actions should +apply to ``empty'' command completion; that is, completion attempted on a +blank line. +

+The process of applying these completion specifications when word completion +is attempted is described above under Programmable Completion. +

+Other options, if specified, have the following meanings. +The arguments to the -G, -W, and -X options +(and, if necessary, the -P and -S options) +should be quoted to protect them from expansion before the +complete + +builtin is invoked. +

+ +
+
-o comp-option
+The comp-option controls several aspects of the compspec's behavior +beyond the simple generation of completions. +comp-option may be one of: +
+
+
bashdefault + +
+Perform the rest of the default bash completions if the compspec +generates no matches. +
default + +
+Use readline's default filename completion if the compspec generates +no matches. +
dirnames + +
+Perform directory name completion if the compspec generates no matches. +
filenames + +
+Tell readline that the compspec generates filenames, so it can perform any +filename-specific processing (like adding a slash to directory names, +quoting special characters, or suppressing trailing spaces). +Intended to be used with shell functions. +
noquote + +
+Tell readline not to quote the completed words if they are filenames +(quoting filenames is the default). +
nosort + +
+Tell readline not to sort the list of possible completions alphabetically. +
nospace + +
+Tell readline not to append a space (the default) to words completed at +the end of the line. +
plusdirs + +
+After any matches defined by the compspec are generated, +directory name completion is attempted and any +matches are added to the results of the other actions. +
+ +
-A action
+The action may be one of the following to generate a list of possible +completions: +
+
+
alias + +
+Alias names. May also be specified as -a. +
arrayvar + +
+Array variable names. +
binding + +
+Readline key binding names. +
builtin + +
+Names of shell builtin commands. May also be specified as -b. +
command + +
+Command names. May also be specified as -c. +
directory + +
+Directory names. May also be specified as -d. +
disabled + +
+Names of disabled shell builtins. +
enabled + +
+Names of enabled shell builtins. +
export + +
+Names of exported shell variables. May also be specified as -e. +
file + +
+File names. May also be specified as -f. +
function + +
+Names of shell functions. +
group + +
+Group names. May also be specified as -g. +
helptopic + +
+Help topics as accepted by the help builtin. +
hostname + +
+Hostnames, as taken from the file specified by the +HOSTFILE + + +shell variable. +
job + +
+Job names, if job control is active. May also be specified as -j. +
keyword + +
+Shell reserved words. May also be specified as -k. +
running + +
+Names of running jobs, if job control is active. +
service + +
+Service names. May also be specified as -s. +
setopt + +
+Valid arguments for the -o option to the set builtin. +
shopt + +
+Shell option names as accepted by the shopt builtin. +
signal + +
+Signal names. +
stopped + +
+Names of stopped jobs, if job control is active. +
user + +
+User names. May also be specified as -u. +
variable + +
+Names of all shell variables. May also be specified as -v. +
+ +
-C command
+command is executed in a subshell environment, and its output is +used as the possible completions. +
-F function
+The shell function function is executed in the current shell +environment. +When the function is executed, +the first argument ($1) is the name of the command whose arguments are +being completed, +the second argument ($2) is the word being completed, +and the third argument ($3) is the word preceding the word being +completed on the current command line. +When it finishes, the possible completions are retrieved from the value +of the +COMPREPLY + + +array variable. +
-G globpat
+The pathname expansion pattern globpat is expanded to generate +the possible completions. +
-P prefix
+prefix is added at the beginning of each possible completion +after all other options have been applied. +
-S suffix
+suffix is appended to each possible completion +after all other options have been applied. +
-W wordlist
+The wordlist is split using the characters in the +IFS + + +special variable as delimiters, and each resultant word is expanded. +The possible completions are the members of the resultant list which +match the word being completed. +
-X filterpat
+filterpat is a pattern as used for pathname expansion. +It is applied to the list of possible completions generated by the +preceding options and arguments, and each completion matching +filterpat is removed from the list. +A leading ! in filterpat negates the pattern; in this +case, any completion not matching filterpat is removed. + +
+

+ +The return value is true unless an invalid option is supplied, an option +other than -p or -r is supplied without a name +argument, an attempt is made to remove a completion specification for +a name for which no specification exists, or +an error occurs adding a completion specification. +

+ +
compopt [-o option] [-DE] [+o option] [name]
+Modify completion options for each name according to the +options, or for the +currently-executing completion if no names are supplied. +If no options are given, display the completion options for each +name or the current completion. +The possible values of option are those valid for the complete +builtin described above. +The -D option indicates that the remaining options should +apply to the ``default'' command completion; that is, completion attempted +on a command for which no completion has previously been defined. +The -E option indicates that the remaining options should +apply to ``empty'' command completion; that is, completion attempted on a +blank line. +

+The return value is true unless an invalid option is supplied, an attempt +is made to modify the options for a name for which no completion +specification exists, or an output error occurs. +

continue [n]
+Resume the next iteration of the enclosing +for, + +while, + +until, + +or +select + +loop. +If +n + +is specified, resume at the nth enclosing loop. +n + +must be >= 1. If +n + +is greater than the number of enclosing loops, the last enclosing loop +(the ``top-level'' loop) is resumed. +The return value is 0 unless n is not greater than or equal to 1. +
declare [-aAfFgilnrtux] [-p] [name[=value] ...]
+ +
typeset [-aAfFgilnrtux] [-p] [name[=value] ...]
+ +Declare variables and/or give them attributes. +If no names are given then display the values of variables. +The +-p + +option will display the attributes and values of each +name. + +When +-p + +is used with name arguments, additional options, +other than -f and -F, are ignored. +When +-p + +is supplied without name arguments, it will display the attributes +and values of all variables having the attributes specified by the +additional options. +If no other options are supplied with -p, declare will display +the attributes and values of all shell variables. The -f option +will restrict the display to shell functions. +The +-F + +option inhibits the display of function definitions; only the +function name and attributes are printed. +If the extdebug shell option is enabled using shopt, +the source file name and line number where each name +is defined are displayed as well. The +-F + +option implies +-f. + +The +-g + +option forces variables to be created or modified at the global scope, +even when declare is executed in a shell function. +It is ignored in all other cases. +The following options can +be used to restrict output to variables with the specified attribute or +to give variables attributes: +
+ +
+
-a + +
+Each name is an indexed array variable (see +Arrays + +above). +
-A + +
+Each name is an associative array variable (see +Arrays + +above). +
-f + +
+Use function names only. +
-i + +
+The variable is treated as an integer; arithmetic evaluation (see +ARITHMETIC EVALUATION + + +above) is performed when the variable is assigned a value. +
-l + +
+When the variable is assigned a value, all upper-case characters are +converted to lower-case. +The upper-case attribute is disabled. +
-n + +
+Give each name the nameref attribute, making +it a name reference to another variable. +That other variable is defined by the value of name. +All references, assignments, and attribute modifications +to name, except those using or changing the +-n attribute itself, are performed on the variable referenced by +name's value. +The nameref attribute cannot be applied to array variables. +
-r + +
+Make names readonly. These names cannot then be assigned values +by subsequent assignment statements or unset. +
-t + +
+Give each name the trace attribute. +Traced functions inherit the DEBUG and RETURN traps from +the calling shell. +The trace attribute has no special meaning for variables. +
-u + +
+When the variable is assigned a value, all lower-case characters are +converted to upper-case. +The lower-case attribute is disabled. +
-x + +
+Mark names for export to subsequent commands via the environment. + +
+

+ +Using `+' instead of `-' +turns off the attribute instead, +with the exceptions that +a +may not be used to destroy an array variable and +r will not +remove the readonly attribute. +When used in a function, +declare + +and +typeset + +make each +name local, as with the +local + +command, +unless the -g option is supplied. +If a variable name is followed by =value, the value of +the variable is set to value. +When using -a or -A and the compound assignment syntax to +create array variables, additional attributes do not take effect until +subsequent assignments. +The return value is 0 unless an invalid option is encountered, +an attempt is made to define a function using + +-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 (see +Arrays + +above), one of the 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 -f. +

+ +
dirs [-clpv] [+n] [-n] + +
+Without options, displays the list of currently remembered directories. +The default display is on a single line with directory names separated +by spaces. +Directories are added to the list with the +pushd + +command; the +popd + +command removes entries from the list. +The current directory is always the first directory in the stack. +
+ +
+
-c + +
+Clears the directory stack by deleting all of the entries. +
-l + +
+Produces a listing using full pathnames; +the default listing format uses a tilde to denote the home directory. +
-p + +
+Print the directory stack with one entry per line. +
-v + +
+Print the directory stack with one entry per line, +prefixing each entry with its index in the stack. +
+n
+Displays the nth entry counting from the left of the list +shown by +dirs + +when invoked without options, starting with zero. +
-n
+Displays the nth entry counting from the right of the list +shown by +dirs + +when invoked without options, starting with zero. + +
+

+ +The return value is 0 unless an +invalid option is supplied or n indexes beyond the end +of the directory stack. +

+ +
disown [-ar] [-h] [jobspec ... | pid ... ]
+Without options, remove each +jobspec + +from the table of active jobs. +If +jobspec + +is not present, and neither the -a nor the -r option +is supplied, the current job is used. +If the -h option is given, each +jobspec + +is not removed from the table, but is marked so that +SIGHUP + + +is not sent to the job if the shell receives a +SIGHUP. + + +If no +jobspec + +is supplied, the +-a + +option means to remove or mark all jobs; the +-r + +option without a +jobspec + +argument restricts operation to running jobs. +The return value is 0 unless a +jobspec + +does not specify a valid job. +
echo [-neE] [arg ...]
+Output the args, separated by spaces, followed by a newline. +The return status is 0 unless a write error occurs. +If -n is specified, the trailing newline is +suppressed. If the -e option is given, interpretation of +the following backslash-escaped characters is enabled. The +-E + +option disables the interpretation of these escape characters, +even on systems where they are interpreted by default. +The xpg_echo shell option may be used to +dynamically determine whether or not echo expands these +escape characters by default. +echo + +does not interpret -- to mean the end of options. +echo + +interprets the following escape sequences: +
+ +
+
\a + +
+alert (bell) +
\b + +
+backspace +
\c + +
+suppress further output +
\e + +
+
\E + +
+an escape character +
\f + +
+form feed +
\n + +
+new line +
\r + +
+carriage return +
\t + +
+horizontal tab +
\v + +
+vertical tab +
\\ + +
+backslash +
\0nnn + +
+the eight-bit character whose value is the octal value nnn +(zero to three octal digits) +
\xHH + +
+the eight-bit character whose value is the hexadecimal value HH +(one or two hex digits) +
\uHHHH + +
+the Unicode (ISO/IEC 10646) character whose value is the hexadecimal value +HHHH (one to four hex digits) +
\UHHHHHHHH + +
+the Unicode (ISO/IEC 10646) character whose value is the hexadecimal value +HHHHHHHH (one to eight hex digits) + +
+ +
enable [-a] [-dnps] [-f filename] [name ...]
+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 -n is used, each name +is disabled; otherwise, +names are enabled. For example, to use the +test + +binary found via the +PATH + + +instead of the shell builtin version, run +enable -n test. + +The +-f + +option means to load the new builtin command +name + +from shared object +filename, + +on systems that support dynamic loading. The +-d + +option will delete a builtin previously loaded with +-f. + +If no name arguments are given, or if the +-p + +option is supplied, a list of shell builtins is printed. +With no other option arguments, the list consists of all enabled +shell builtins. +If -n is supplied, only disabled builtins are printed. +If -a is supplied, the list printed includes all builtins, with an +indication of whether or not each is enabled. +If -s is supplied, the output is restricted to the POSIX +special builtins. +The return value is 0 unless a +name + +is not a shell builtin or there is an error loading a new builtin +from a shared object. +
eval [arg ...]
+The args are read and concatenated together into a single +command. This command is then read and executed by the shell, and +its exit status is returned as the value of +eval. + +If there are no +args, + +or only null arguments, +eval + +returns 0. +
exec [-cl] [-a name] [command [arguments]]
+If +command + +is specified, it replaces the shell. +No new process is created. The +arguments + +become the arguments to command. +If the +-l + +option is supplied, +the shell places a dash at the beginning of the zeroth argument passed to +command. + +This is what +login(1) + +does. The +-c + +option causes +command + +to be executed with an empty environment. If +-a + +is supplied, the shell passes +name + +as the zeroth argument to the executed command. +If +command + +cannot be executed for some reason, a non-interactive shell exits, +unless the +execfail + +shell option +is enabled. In that case, it returns failure. +An interactive shell returns failure if the file cannot be executed. +If +command + +is not specified, any redirections take effect in the current shell, +and the return status is 0. If there is a redirection error, the +return status is 1. +
exit [n]
+Cause the shell to exit +with a status of n. If +n + +is omitted, the exit status +is that of the last command executed. +A trap on +EXIT + + +is executed before the shell terminates. +
export [-fn] [name[=word]] ...
+ +
export -p + +
+ +The supplied +names + +are marked for automatic export to the environment of +subsequently executed commands. If the +-f + +option is given, the +names + +refer to functions. +If no +names + +are given, or if the +-p + +option is supplied, a list +of names of all exported variables is printed. +The +-n + +option causes the export property to be removed from each +name. +If a variable name is followed by =word, the value of +the variable is set to word. +export + +returns an exit status of 0 unless an invalid option is +encountered, +one of the names is not a valid shell variable name, or +-f + +is supplied with a +name + +that is not a function. +
fc [-e ename] [-lnr] [first] [last]
+ +
fc -s [pat=rep] [cmd]
+ +The first form selects a range of commands from +first + +to +last + +from the history list and displays or edits and re-executes them. +First + +and +last + +may be specified as a string (to locate the last command beginning +with that string) or as a number (an index into the history list, +where a negative number is used as an offset from the current +command number). If +last + +is not specified it is set to +the current command for listing (so that + +fc -l -10 +prints the last 10 commands) and to +first + +otherwise. +If +first + +is not specified it is set to the previous +command for editing and -16 for listing. +

+The +-n + +option suppresses +the command numbers when listing. The +-r + +option reverses the order of +the commands. If the +-l + +option is given, +the commands are listed on +standard output. Otherwise, the editor given by +ename + +is invoked +on a file containing those commands. If +ename + +is not given, the +value of the +FCEDIT + + +variable is used, and +the value of +EDITOR + + +if +FCEDIT + + +is not set. If neither variable is set, + +vi + +is used. When editing is complete, the edited commands are +echoed and executed. +

+In the second form, command is re-executed after each instance +of pat is replaced by rep. +Command is intepreted the same as first above. +A useful alias to use with this is + +r='fc -s', +so that typing + +r cc +runs the last command beginning with + +cc +and typing + +r +re-executes the last command. +

+If the first form is used, the return value is 0 unless an invalid +option is encountered or +first + +or +last + +specify history lines out of range. +If the +-e + +option is supplied, the return value is the value of the last +command executed or failure if an error occurs with the temporary +file of commands. If the second form is used, the return status +is that of the command re-executed, unless +cmd + +does not specify a valid history line, in which case +fc + +returns failure. +

fg [jobspec]
+Resume +jobspec + +in the foreground, and make it the current job. +If +jobspec + +is not present, the shell's notion of the current job is used. +The return value is that of the command placed into the foreground, +or failure if run when job control is disabled or, when run with +job control enabled, if +jobspec + +does not specify a valid job or +jobspec + +specifies a job that was started without job control. +
getopts optstring name [args]
+getopts + +is used by shell procedures to parse positional parameters. +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 and question mark characters may not be used as +option characters. +Each time it is invoked, +getopts + +places the next option in the shell variable +name, + +initializing +name + +if it does not exist, +and the index of the next argument to be processed into the +variable +OPTIND. + + +OPTIND + + +is initialized to 1 each time the shell or a shell script +is invoked. When an option requires an argument, +getopts + +places that argument into the variable +OPTARG. + + +The shell does not reset +OPTIND + + +automatically; it must be manually reset between multiple +calls to +getopts + +within the same shell invocation if a new set of parameters +is to be used. +

+When the end of options is encountered, getopts exits with a +return value greater than zero. +OPTIND + + +is set to the index of the first non-option argument, +and name is set to ?. +

+getopts + +normally parses the positional parameters, but if more arguments are +given in +args, + +getopts + +parses those instead. +

+getopts + +can report errors in two ways. If the first character of +optstring + +is a colon, +silent + +error reporting is used. In normal operation, diagnostic messages +are printed when invalid options or missing option arguments are +encountered. +If the variable +OPTERR + + +is set to 0, no error messages will be displayed, even if the first +character of +optstring + +is not a colon. +

+If an invalid option is seen, +getopts + +places ? into +name + +and, if not silent, +prints an error message and unsets +OPTARG. + + +If +getopts + +is silent, +the option character found is placed in +OPTARG + + +and no diagnostic message is printed. +

+If a required argument is not found, and +getopts + +is not silent, +a question mark (?) is placed in +name, + +OPTARG + + +is unset, and a diagnostic message is printed. +If +getopts + +is silent, then a colon (:) is placed in +name + +and +OPTARG + + +is set to the option character found. +

+getopts + +returns true if an option, specified or unspecified, is found. +It returns false if the end of options is encountered or an +error occurs. +

hash [-lr] [-p filename] [-dt] [name]
+Each time hash is invoked, +the full pathname of the command +name + +is determined by searching +the directories in +$PATH + +and remembered. Any previously-remembered pathname is discarded. +If the +-p + +option is supplied, no path search is performed, and +filename + +is used as the full filename of the command. +The +-r + +option causes the shell to forget all +remembered locations. +The +-d + +option causes the shell to forget the remembered location of each name. +If the +-t + +option is supplied, the full pathname to which each name corresponds +is printed. If multiple name arguments are supplied with -t, +the name is printed before the hashed full pathname. +The +-l + +option causes output to be displayed in a format that may be reused as input. +If no arguments are given, or if only -l is supplied, +information about remembered commands is printed. +The return status is true unless a +name + +is not found or an invalid option is supplied. +
help [-dms] [pattern]
+Display helpful information about builtin commands. If +pattern + +is specified, +help + +gives detailed help on all commands matching +pattern; + +otherwise help for all the builtins and shell control structures +is printed. +
+ +
+
-d + +
+Display a short description of each pattern +
-m + +
+Display the description of each pattern in a manpage-like format +
-s + +
+Display only a short usage synopsis for each pattern + +
+

+ +The return status is 0 unless no command matches +pattern. + +

+ +
history [n]
+ +
history -c
+
history -d offset
+
history -anrw [filename]
+
history -p arg [arg ...]
+
history -s arg [arg ...]
+ +With no options, display the command +history list with line numbers. Lines listed +with a +* + +have been modified. An argument of +n + +lists only the last +n + +lines. +If the shell variable +HISTTIMEFORMAT + + +is set and not null, +it is used as a format string for strftime(3) to display +the time stamp associated with each displayed history entry. +No intervening blank is printed between the formatted time stamp +and the history line. +If filename is supplied, it is used as the +name of the history file; if not, the value of +HISTFILE + + +is used. Options, if supplied, have the following meanings: +
+ +
+
-c + +
+Clear the history list by deleting all the entries. +
-d offset
+Delete the history entry at position offset. +
-a + +
+Append the ``new'' history lines to the history file. +These are history lines entered since the beginning of the current +bash session, but not already appended to the history file. +
-n + +
+Read the history lines not already read from the history +file into the current history list. These are lines +appended to the history file since the beginning of the +current bash session. +
-r + +
+Read the contents of the history file +and append them to the current history list. +
-w + +
+Write the current history list to the history file, overwriting the +history file's contents. +
-p + +
+Perform history substitution on the following args and display +the result on the standard output. +Does not store the results in the history list. +Each arg must be quoted to disable normal history expansion. +
-s + +
+Store the +args + +in the history list as a single entry. The last command in the +history list is removed before the +args + +are added. + +
+

+ +If the +HISTTIMEFORMAT + + +variable is set, the time stamp information +associated with each history entry is written to the history file, +marked with the history comment character. +When the history file is read, lines beginning with the history +comment character followed immediately by a digit are interpreted +as timestamps for the following history entry. +The return value is 0 unless an invalid option is encountered, an +error occurs while reading or writing the history file, an invalid +offset is supplied as an argument to -d, or the +history expansion supplied as an argument to -p fails. +

+ +
jobs [-lnprs] [ jobspec ... ]
+ +
jobs -x command [ args ... ]
+ +The first form lists the active jobs. The options have the following +meanings: +
+ +
+
-l + +
+List process IDs +in addition to the normal information. +
-n + +
+Display information only about jobs that have changed status since +the user was last notified of their status. +
-p + +
+List only the process ID of the job's process group +leader. +
-r + +
+Display only running jobs. +
-s + +
+Display only stopped jobs. + +
+

+ +If +jobspec + +is given, output is restricted to information about that job. +The return status is 0 unless an invalid option is encountered +or an invalid +jobspec + +is supplied. +

+ +If the +-x + +option is supplied, +jobs + +replaces any +jobspec + +found in +command + +or +args + +with the corresponding process group ID, and executes +command + +passing it +args, + +returning its exit status. +

+ +
kill [-s sigspec | -n signum | -sigspec] [pid | jobspec] ...
+ +
kill -l|-L [sigspec | exit_status]
+ +Send the signal named by +sigspec + +or +signum + +to the processes named by +pid + +or +jobspec. + +sigspec + +is either a case-insensitive signal name such as +SIGKILL + + +(with or without the +SIG + + +prefix) or a signal number; +signum + +is a signal number. +If +sigspec + +is not present, then +SIGTERM + + +is assumed. +An argument of +-l + +lists the signal names. +If any arguments are supplied when +-l + +is given, the names of the signals corresponding to the arguments are +listed, and the return status is 0. +The exit_status argument to +-l + +is a number specifying either a signal number or the exit status of +a process terminated by a signal. +The +-L + +option is equivalent to -l. +kill + +returns true if at least one signal was successfully sent, or false +if an error occurs or an invalid option is encountered. +
let arg [arg ...]
+Each +arg + +is an arithmetic expression to be evaluated (see +ARITHMETIC EVALUATION + + +above). +If the last +arg + +evaluates to 0, +let + +returns 1; 0 is returned otherwise. +
local [option] [name[=value] ... | - ]
+For each argument, a local variable named +name + +is created, and assigned +value. + +The option can be any of the options accepted by declare. +When +local + +is used within a function, it causes the variable +name + +to have a visible scope restricted to that function and its children. +If name is -, the set of shell options is made local to the function +in which local is invoked: shell options changed using the +set builtin inside the function are restored to their original values +when the function returns. +With no operands, +local + +writes a list of local variables to the standard output. It is +an error to use +local + +when not within a function. The return status is 0 unless +local + +is used outside a function, an invalid +name + +is supplied, or +name is a readonly variable. +
logout + +
+Exit a login shell. +
mapfile [-d delim] [-n count] [-O origin] [-s count] [-t] [-u fd] [-C callback] [-c quantum] [array]
+ +
readarray [-d delim] [-n count] [-O origin] [-s count] [-t] [-u fd] [-C callback] [-c quantum] [array]
+ +Read lines from the standard input into the indexed array variable +array, + +or from file descriptor +fd + +if the +-u + +option is supplied. +The variable +MAPFILE + + +is the default array. +Options, if supplied, have the following meanings: +
+ +
+
-d + +
+The first character of delim is used to terminate each input line, +rather than newline. +
-n + +
+Copy at most +count + +lines. If count is 0, all lines are copied. +
-O + +
+Begin assigning to +array + +at index +origin. + +The default index is 0. +
-s + +
+Discard the first count lines read. +
-t + +
+Remove a trailing delim (default newline) from each line read. +
-u + +
+Read lines from file descriptor fd instead of the standard input. +
-C + +
+Evaluate +callback + +each time quantum lines are read. The -c option specifies +quantum. + +
-c + +
+Specify the number of lines read between each call to +callback. + + +
+

+ +If +-C + +is specified without +-c, + +the default quantum is 5000. +When callback is evaluated, it is supplied the index of the next +array element to be assigned and the line to be assigned to that element +as additional arguments. +callback is evaluated after the line is read but before the +array element is assigned. +

+ +If not supplied with an explicit origin, mapfile will clear array +before assigning to it. +

+ +mapfile returns successfully unless an invalid option or option +argument is supplied, array is invalid or unassignable, or if +array is not an indexed array. +

+ +
popd [-n] [+n] [-n]
+Removes entries from the directory stack. With no arguments, +removes the top directory from the stack, and performs a +cd + +to the new top directory. +Arguments, if supplied, have the following meanings: +
+ +
+
-n + +
+Suppresses the normal change of directory when removing directories +from the stack, so that only the stack is manipulated. +
+n
+Removes the nth entry counting from the left of the list +shown by +dirs, + +starting with zero. For example: + +popd +0 +removes the first directory, + +popd +1 +the second. +
-n
+Removes the nth entry counting from the right of the list +shown by +dirs, + +starting with zero. For example: + +popd -0 +removes the last directory, + +popd -1 +the next to last. + +
+

+ +If the +popd + +command is successful, a +dirs + +is performed as well, and the return status is 0. +popd + +returns false if an invalid option is encountered, the directory stack +is empty, a non-existent directory stack entry is specified, or the +directory change fails. +

+ +
printf [-v var] format [arguments]
+Write the formatted arguments to the standard output under the +control of the format. +The -v option causes the output to be assigned to the variable +var rather than being printed to the standard output. +

+The 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 +argument. +In addition to the standard printf(1) format specifications, +printf interprets the following extensions: +

+ +
+
%b + +
+causes +printf to expand backslash escape sequences in the corresponding +argument +in the same way as echo -e. +
%q + +
+causes printf to output the corresponding +argument in a format that can be reused as shell input. +
%(datefmt)T + +
+causes printf to output the date-time string resulting from using +datefmt as a format string for strftime(3). +The corresponding argument is an integer representing the number of +seconds since the epoch. +Two special argument values may be used: -1 represents the current +time, and -2 represents the time the shell was invoked. +If no argument is specified, conversion behaves as if -1 had been given. +This is an exception to the usual printf behavior. + +
+

+ +Arguments to non-string format specifiers are treated as C constants, +except that a leading plus or minus sign is allowed, and if the leading +character is a single or double quote, the value is the ASCII value of +the following character. +

+ +The format is reused as necessary to consume all of the arguments. +If the format requires more 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. +

+ +
pushd [-n] [+n] [-n]
+ +
pushd [-n] [dir]
+ +Adds a directory to the top of the directory stack, or rotates +the stack, making the new top of the stack the current working +directory. With no arguments, pushd exchanges the top two directories +and returns 0, unless the directory stack is empty. +Arguments, if supplied, have the following meanings: +
+ +
+
-n + +
+Suppresses the normal change of directory when rotating or +adding directories to the stack, so that only the stack is manipulated. +
+n
+Rotates the stack so that the nth directory +(counting from the left of the list shown by +dirs, + +starting with zero) +is at the top. +
-n
+Rotates the stack so that the nth directory +(counting from the right of the list shown by +dirs, + +starting with zero) is at the top. +
dir + +
+Adds +dir + +to the directory stack at the top, making it the +new current working directory as if it had been supplied as the argument +to the cd builtin. + +
+

+ +If the +pushd + +command is successful, a +dirs + +is performed as well. +If the first form is used, +pushd + +returns 0 unless the cd to +dir + +fails. With the second form, +pushd + +returns 0 unless the directory stack is empty, +a non-existent directory stack element is specified, +or the directory change to the specified new current directory +fails. +

+ +
pwd [-LP]
+Print the absolute pathname of the current working directory. +The pathname printed contains no symbolic links if the +-P + +option is supplied or the +-o physical + +option to the +set + +builtin command is enabled. +If the +-L + +option is used, the pathname printed may contain symbolic links. +The return status is 0 unless an error occurs while +reading the name of the current directory or an +invalid option is supplied. +
read [-ers] [-a aname] [-d delim] [-i text] [-n nchars] [-N nchars] [-p prompt] [-t timeout] [-u fd] [name ...]
+One line is read from the standard input, or from the file descriptor +fd supplied as an argument to the -u option, +split into words as described above under Word Splitting, +and the first word +is assigned to the first +name, + +the second word to the second +name, + +and so on. +If there are more words than names, the remaining words and their +intervening delimiters are assigned to the last +name. + +If there are fewer words read from the input stream than names, +the remaining names are assigned empty values. +The characters in +IFS + + +are used to split the line into words using the same rules the shell +uses for expansion (described above under Word Splitting). +The backslash character (\) may be used to remove any special +meaning for the next character read and for line continuation. +Options, if supplied, have the following meanings: +
+ +
+
-a aname + +
+The words are assigned to sequential indices +of the array variable +aname, + +starting at 0. +aname + +is unset before any new values are assigned. +Other name arguments are ignored. +
-d delim + +
+The first character of delim is used to terminate the input line, +rather than newline. +
-e + +
+If the standard input +is coming from a terminal, +readline + +(see +READLINE + + +above) is used to obtain the line. +Readline uses the current (or default, if line editing was not previously +active) editing settings. +
-i text + +
+If +readline + +is being used to read the line, text is placed into the editing +buffer before editing begins. +
-n nchars + +
+read returns after reading nchars characters rather than +waiting for a complete line of input, but honors a delimiter if fewer +than nchars characters are read before the delimiter. +
-N nchars + +
+read returns after reading exactly nchars characters rather +than waiting for a complete line of input, unless EOF is encountered or +read times out. +Delimiter characters encountered in the input are +not treated specially and do not cause read to return until +nchars characters are read. +The result is not split on the characters in IFS; the intent is +that the variable is assigned exactly the characters read +(with the exception of backslash; see the -r option below). +
-p prompt + +
+Display prompt on standard error, without a +trailing newline, before attempting to read any input. The prompt +is displayed only if input is coming from a terminal. +
-r + +
+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. +
-s + +
+Silent mode. If input is coming from a terminal, characters are +not echoed. +
-t timeout + +
+Cause read to time out and return failure if a complete line of +input (or a specified number of characters) +is not read within timeout seconds. +timeout may be a decimal number with a fractional portion following +the decimal point. +This option is only effective if read is reading input from a +terminal, pipe, or other special file; it has no effect when reading +from regular files. +If read times out, read saves any partial input read into +the specified variable name. +If timeout is 0, read returns immediately, without trying to +read any data. The exit status is 0 if input is available on +the specified file descriptor, non-zero otherwise. +The exit status is greater than 128 if the timeout is exceeded. +
-u fd + +
+Read input from file descriptor fd. + +
+

+ +If no +names + +are supplied, the line read is assigned to the variable +REPLY. + + +The exit status is zero, unless end-of-file is encountered, read +times out (in which case the status is greater than 128), +a variable assignment error (such as assigning to a readonly variable) occurs, +or an invalid file descriptor is supplied as the argument to -u. +

+ +
readonly [-aAf] [-p] [name[=word] ...]
+ +The given +names are marked readonly; the values of these +names + +may not be changed by subsequent assignment. +If the +-f + +option is supplied, the functions corresponding to the +names are so +marked. +The +-a + +option restricts the variables to indexed arrays; the +-A + +option restricts the variables to associative arrays. +If both options are supplied, +-A + +takes precedence. +If no +name + +arguments are given, or if the +-p + +option is supplied, a list of all readonly names is printed. +The other options may be used to restrict the output to a subset of +the set of readonly names. +The +-p + +option causes output to be displayed in a format that +may be reused as input. +If a variable name is followed by =word, the value of +the variable is set to word. +The return status is 0 unless an invalid option is encountered, +one of the +names + +is not a valid shell variable name, or +-f + +is supplied with a +name + +that is not a function. +
return [n]
+Causes a function to stop executing and return the value specified by +n + +to its caller. +If +n + +is omitted, the return status is that of the last command +executed in the function body. +If return is executed by a trap handler, the last command used to +determine the status is the last command executed before the trap handler. +if return is executed during a DEBUG trap, the last command +used to determine the status is the last command executed by the trap +handler before return was invoked. +If +return + +is used outside a function, +but during execution of a script by the +. + +(source) command, it causes the shell to stop executing +that script and return either +n + +or the exit status of the last command executed within the +script as the exit status of the script. +If n is supplied, the return value is its least significant +8 bits. +The return status is non-zero if +return + +is supplied a non-numeric argument, or +is used outside a +function and not during execution of a script by . or source. +Any command associated with the RETURN trap is executed +before execution resumes after the function or script. +
set [--abefhkmnptuvxBCEHPT] [-o option-name] [arg ...]
+ +
set [+abefhkmnptuvxBCEHPT] [+o option-name] [arg ...]
+ +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. +Read-only variables cannot be reset. +In posix mode, only shell variables are listed. +The output is sorted according to the current locale. +When options are specified, they set or unset shell attributes. +Any arguments remaining after option processing are treated +as values for the positional parameters and are assigned, in order, to +$1, + +$2, + +... + +$n. + +Options, if specified, have the following meanings: +
+ +
+
-a + +
+Each variable or function that is created or modified is given the +export attribute and marked for export to the environment of +subsequent commands. +
-b + +
+Report the status of terminated background jobs +immediately, rather than before the next primary prompt. This is +effective only when job control is enabled. +
-e + +
+Exit immediately if a +pipeline (which may consist of a single simple command), +a list, +or a compound command +(see +SHELL GRAMMAR + + +above), exits with a non-zero status. +The shell does not exit if the +command that fails is part of the command list immediately following a +while + +or +until + +keyword, +part of the test following the +if + +or +elif + +reserved words, part of any command executed in a +&& + +or +|| + +list except the command following the final && or ||, +any command in a pipeline but the last, +or if the command's return value is +being inverted with +!. + +If a compound command other than a subshell +returns a non-zero status because a command failed +while -e was being ignored, the shell does not exit. +A trap on ERR, if set, is executed before the shell exits. +This option applies to the shell environment and each subshell environment +separately (see +COMMAND EXECUTION ENVIRONMENT + + +above), and may cause +subshells to exit before executing all the commands in the subshell. +

+ + +If a compound command or shell function executes in a context +where -e is being ignored, +none of the commands executed within the compound command or function body +will be affected by the -e setting, even if -e is set +and a command returns a failure status. +If a compound command or shell function sets -e while executing in +a context where -e is ignored, that setting will not have any +effect until the compound command or the command containing the function +call completes. +

-f + +
+Disable pathname expansion. +
-h + +
+Remember the location of commands as they are looked up for execution. +This is enabled by default. +
-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. +
-m + +
+Monitor mode. Job control is enabled. This option is on +by default for interactive shells on systems that support +it (see +JOB CONTROL + + +above). +All processes run in a separate process group. +When a background job completes, the shell prints a line +containing its exit status. +
-n + +
+Read commands but do not execute them. +This may be used to check a shell script for syntax errors. +This is ignored by interactive shells. +
-o option-name + +
+The option-name can be one of the following: +
+
+
allexport + +
+Same as +-a. + +
braceexpand + +
+Same as +-B. + +
emacs + +
+Use an emacs-style command line editing interface. This is enabled +by default when the shell is interactive, unless the shell is started +with the +--noediting + +option. +This also affects the editing interface used for read -e. +
errexit + +
+Same as +-e. + +
errtrace + +
+Same as +-E. + +
functrace + +
+Same as +-T. + +
hashall + +
+Same as +-h. + +
histexpand + +
+Same as +-H. + +
history + +
+Enable command history, as described above under +HISTORY. + + +This option is on by default in interactive shells. +
ignoreeof + +
+The effect is as if the shell command +IGNOREEOF=10 + +had been executed +(see +Shell Variables + +above). +
keyword + +
+Same as +-k. + +
monitor + +
+Same as +-m. + +
noclobber + +
+Same as +-C. + +
noexec + +
+Same as +-n. + +
noglob + +
+Same as +-f. + +
nolog + +
+Currently ignored. +
notify + +
+Same as +-b. + +
nounset + +
+Same as +-u. + +
onecmd + +
+Same as +-t. + +
physical + +
+Same as +-P. + +
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. +
posix + +
+Change the behavior of +bash + +where the default operation differs +from the POSIX standard to match the standard (posix mode). +See +SEE ALSO + + +below for a reference to a document that details how posix mode affects +bash's behavior. +
privileged + +
+Same as +-p. + +
verbose + +
+Same as +-v. + +
vi + +
+Use a vi-style command line editing interface. +This also affects the editing interface used for read -e. +
xtrace + +
+Same as +-x. + +

+

+

+ +If +-o + +is supplied with no option-name, the values of the current options are +printed. +If ++o + +is supplied with no option-name, a series of +set + +commands to recreate the current option settings is displayed on +the standard output. +

+ +
-p + +
+Turn on +privileged + +mode. In this mode, the +$ENV + + +and +$BASH_ENV + + +files are not processed, shell functions are not inherited from the +environment, and the +SHELLOPTS, + + +BASHOPTS, + + +CDPATH, + + +and +GLOBIGNORE + + +variables, if they appear in the environment, are ignored. +If the shell is started with the effective user (group) id not equal to the +real user (group) id, and the -p option is not supplied, these actions +are taken and the effective user id is set to the real user id. +If the -p option is supplied at startup, the effective user id is +not reset. +Turning this option off causes the effective user +and group ids to be set to the real user and group ids. +
-t + +
+Exit after reading and executing one command. +
-u + +
+Treat unset variables and parameters other than the special +parameters "@" and "*" as an error when performing +parameter expansion. If expansion is attempted on an +unset variable or parameter, the shell prints an error message, and, +if not interactive, exits with a non-zero status. +
-v + +
+Print shell input lines as they are read. +
-x + +
+After expanding each simple command, +for command, case command, select command, or +arithmetic for command, display the expanded value of +PS4, + + +followed by the command and its expanded arguments +or associated word list. +
-B + +
+The shell performs brace expansion (see +Brace Expansion + +above). This is on by default. +
-C + +
+If set, +bash + +does not overwrite an existing file with the +>, + +>&, + +and +<> + +redirection operators. This may be overridden when +creating output files by using the redirection operator +>| + +instead of +>. + +
-E + +
+If set, any trap on ERR is inherited by shell functions, command +substitutions, and commands executed in a subshell environment. +The ERR trap is normally not inherited in such cases. +
-H + +
+Enable +! + +style history substitution. This option is on by +default when the shell is interactive. +
-P + +
+If set, the shell does not resolve symbolic links when executing +commands such as +cd + +that change the current working directory. It uses the +physical directory structure instead. By default, +bash + +follows the logical chain of directories when performing commands +which change the current directory. +
-T + +
+If set, any traps on DEBUG and RETURN are inherited by shell +functions, command substitutions, and commands executed in a +subshell environment. +The DEBUG and RETURN traps are normally not inherited +in such cases. +
-- + +
+If no arguments follow this option, then the positional parameters are +unset. Otherwise, the positional parameters are set to the +args, even if some of them begin with a +-. + +
- + +
+Signal the end of options, cause all remaining args to be +assigned to the positional parameters. The +-x + +and +-v + +options are turned off. +If there are no args, +the positional parameters remain unchanged. + +
+

+ +The options are off by default unless otherwise noted. +Using + rather than - causes these options to be turned off. +The options can also be specified as arguments to an invocation of +the shell. +The current set of options may be found in +$-. + +The return status is always true unless an invalid option is encountered. +

+ +
shift [n]
+The positional parameters from n+1 ... are renamed to +$1 + +.... + +Parameters represented by the numbers $# +down to $#-n+1 are unset. +n + +must be a non-negative number less than or equal to $#. +If +n + +is 0, no parameters are changed. +If +n + +is not given, it is assumed to be 1. +If +n + +is greater than $#, the positional parameters are not changed. +The return status is greater than zero if +n + +is greater than +$# + +or less than zero; otherwise 0. +
shopt [-pqsu] [-o] [optname ...]
+Toggle the values of settings controlling optional shell behavior. +The settings can be either those listed below, or, if the +-o + +option is used, those available with the +-o + +option to the set builtin command. +With no options, or with the +-p + +option, a list of all settable options is displayed, with +an indication of whether or not each is set. +The -p option causes output to be displayed in a form that +may be reused as input. +Other options have the following meanings: +
+ +
+
-s + +
+Enable (set) each optname. +
-u + +
+Disable (unset) each optname. +
-q + +
+Suppresses normal output (quiet mode); the return status indicates +whether the optname is set or unset. +If multiple optname arguments are given with +-q, + +the return status is zero if all optnames are enabled; non-zero +otherwise. +
-o + +
+Restricts the values of optname to be those defined for the +-o + +option to the +set + +builtin. + +
+

+ +If either +-s + +or +-u + +is used with no optname arguments, +shopt + +shows only those options which are set or unset, respectively. +Unless otherwise noted, the shopt options are disabled (unset) +by default. +

+ +The return status when listing options is zero if all optnames +are enabled, non-zero otherwise. When setting or unsetting options, +the return status is zero unless an optname is not a valid shell +option. +

+ +The list of shopt options is: +

+ + + +

+
autocd + +
+If set, a command name that is the name of a directory is executed as if +it were the argument to the cd command. +This option is only used by interactive shells. +
cdable_vars + +
+If set, an argument to the +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. +
cdspell + +
+If set, minor errors in the spelling of a directory component in a +cd + +command will be corrected. +The errors checked for are transposed characters, +a missing character, and one character too many. +If a correction is found, the corrected filename is printed, +and the command proceeds. +This option is only used by interactive shells. +
checkhash + +
+If 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. +
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 +JOB CONTROL + + +above). The shell always +postpones exiting if any jobs are stopped. +
checkwinsize + +
+If set, bash checks the window size after each command +and, if necessary, updates the values of +LINES + + +and +COLUMNS. + + +
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. +
compat31 + +
+If set, +bash + +changes its behavior to that of version 3.1 with respect to quoted +arguments to the [[ conditional command's =~ operator +and locale-specific string comparison when using the [[ +conditional command's < and > operators. +Bash versions prior to bash-4.1 use ASCII collation and +strcmp(3); + +bash-4.1 and later use the current locale's collation sequence and +strcoll(3). + +
compat32 + +
+If set, +bash + +changes its behavior to that of version 3.2 with respect to +locale-specific string comparison when using the [[ +conditional command's < and > operators (see previous item) +and the effect of interrupting a command list. +Bash versions 3.2 and earlier continue with the next command in the list +after one terminates due to an interrupt. +
compat40 + +
+If set, +bash + +changes its behavior to that of version 4.0 with respect to locale-specific +string comparison when using the [[ +conditional command's < and > operators (see description of +compat31) +and the effect of interrupting a command list. +Bash versions 4.0 and later interrupt the list as if the shell received the +interrupt; previous versions continue with the next command in the list. +
compat41 + +
+If set, +bash, + +when in posix mode, treats a single quote in a double-quoted +parameter expansion as a special character. The single quotes must match +(an even number) and the characters between the single quotes are considered +quoted. This is the behavior of posix mode through version 4.1. +The default bash behavior remains as in previous versions. +
compat42 + +
+If set, +bash + +does not process the replacement string in the pattern substitution word +expansion using quote removal. +
compat43 + +
+If set, +bash + +does not print a warning message if an attempt is made to use a quoted compound +array assignment as an argument to declare, +makes word expansion errors +non-fatal errors that cause the current command to fail (the default behavior is +to make them fatal errors that cause the shell to exit), +and does not reset the +loop state when a shell function is executed (this allows break or +continue in a shell function to affect loops in the caller's context). +
complete_fullquote + +
+If set, +bash + +quotes all shell metacharacters in filenames and directory names when +performing completion. +If not set, +bash + +removes metacharacters such as the dollar sign from the set of +characters that will be quoted in completed filenames +when these metacharacters appear in shell variable references in words to be +completed. +This means that dollar signs in variable names that expand to directories +will not be quoted; +however, any dollar signs appearing in filenames will not be quoted, either. +This is active only when bash is using backslashes to quote completed +filenames. +This variable is set by default, which is the default bash behavior in +versions through 4.2. +
direxpand + +
+If set, +bash + +replaces directory names with the results of word expansion when performing +filename completion. This changes the contents of the readline editing +buffer. +If not set, +bash + +attempts to preserve what the user typed. +
dirspell + +
+If set, +bash + +attempts spelling correction on directory names during word completion +if the directory name initially supplied does not exist. +
dotglob + +
+If set, +bash + +includes filenames beginning with a `.' in the results of pathname +expansion. +
execfail + +
+If set, a non-interactive shell will not exit if +it cannot execute the file specified as an argument to the +exec + +builtin command. An interactive shell does not exit if +exec + +fails. +
expand_aliases + +
+If set, aliases are expanded as described above under +ALIASES. + + +This option is enabled by default for interactive shells. +
extdebug + +
+If set at shell invocation, arrange to execute the debugger profile +before the shell starts, identical to the --debugger option. +If set after invocation, behavior intended for use by debuggers is enabled: +
+
+
1. + +
+The -F option to the declare builtin displays the source +file name and line number corresponding to each function name supplied +as an argument. +
2. + +
+If the command run by the DEBUG trap returns a non-zero value, the +next command is skipped and not executed. +
3. + +
+If the command run by the 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 . or source builtins), the shell simulates +a call to return. +
4. + +
+BASH_ARGC + + +and +BASH_ARGV + + +are updated as described in their descriptions above. +
5. + +
+Function tracing is enabled: command substitution, shell functions, and +subshells invoked with ( command ) inherit the +DEBUG and RETURN traps. +
6. + +
+Error tracing is enabled: command substitution, shell functions, and +subshells invoked with ( command ) inherit the +ERR trap. +
+ +
extglob + +
+If set, the extended pattern matching features described above under +Pathname Expansion are enabled. +
extquote + +
+If set, $aqstringaq and $"string" quoting is +performed within ${parameter} expansions +enclosed in double quotes. This option is enabled by default. +
failglob + +
+If set, patterns which fail to match filenames during pathname expansion +result in an expansion error. +
force_fignore + +
+If set, the suffixes specified by the +FIGNORE + + +shell variable +cause words to be ignored when performing word completion even if +the ignored words are the only possible completions. +See +SHELL VARIABLES +above for a description of +FIGNORE. + + +This option is enabled by default. +
globasciiranges + +
+If set, range expressions used in pattern matching bracket expressions (see +Pattern Matching + + +above) behave as if in the traditional C locale when performing +comparisons. That is, the current locale's collating sequence +is not taken into account, so +b + +will not collate between +A + +and +B, + +and upper-case and lower-case ASCII characters will collate together. +
globstar + +
+If set, the pattern ** used in a pathname expansion context will +match all files and zero or more directories and subdirectories. +If the pattern is followed by a /, only directories and +subdirectories match. +
gnu_errfmt + +
+If set, shell error messages are written in the standard GNU error +message format. +
histappend + +
+If set, the history list is appended to the file named by the value +of the +HISTFILE + + +variable when the shell exits, rather than overwriting the file. +
histreedit + +
+If set, and +readline + +is being used, a user is given the opportunity to re-edit a +failed history substitution. +
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. +
hostcomplete + +
+If set, and +readline + +is being used, bash will attempt to perform hostname completion when a +word containing a @ is being completed (see +Completing + +under +READLINE + + +above). +This is enabled by default. +
huponexit + +
+If set, bash will send +SIGHUP + + +to all jobs when an interactive login shell exits. +
inherit_errexit + +
+If set, command substitution inherits the value of the errexit option, +instead of unsetting it in the subshell environment. +This option is enabled when posix mode is enabled. +
interactive_comments + +
+If set, allow a word beginning with +# + +to cause that word and all remaining characters on that +line to be ignored in an interactive shell (see +COMMENTS + + +above). This option is enabled by default. +
lastpipe + +
+If set, and job control is not active, the shell runs the last command of +a pipeline not executed in the background in the current shell environment. +
lithist + +
+If set, and the +cmdhist + +option is enabled, multi-line commands are saved to the history with +embedded newlines rather than using semicolon separators where possible. +
login_shell + +
+The shell sets this option if it is started as a login shell (see +INVOCATION + + +above). +The value may not be changed. +
mailwarn + +
+If set, and a file that bash is checking for mail has been +accessed since the last time it was checked, the message ``The mail in +mailfile has been read'' is displayed. +
no_empty_cmd_completion + +
+If set, and +readline + +is being used, +bash + +will not attempt to search the +PATH + + +for possible completions when +completion is attempted on an empty line. +
nocaseglob + +
+If set, +bash + +matches filenames in a case-insensitive fashion when performing pathname +expansion (see +Pathname Expansion + +above). +
nocasematch + +
+If set, +bash + +matches patterns in a case-insensitive fashion when performing matching +while executing case or [[ conditional commands, +when performing pattern substitution word expansions, +or when filtering possible completions as part of programmable completion. +
nullglob + +
+If set, +bash + +allows patterns which match no +files (see +Pathname Expansion + +above) +to expand to a null string, rather than themselves. +
progcomp + +
+If set, the programmable completion facilities (see +Programmable Completion above) are enabled. +This option is enabled by default. +
promptvars + +
+If set, prompt strings undergo +parameter expansion, command substitution, arithmetic +expansion, and quote removal after being expanded as described in +PROMPTING + + +above. This option is enabled by default. +
restricted_shell + +
+The shell sets this option if it is started in restricted mode (see +RESTRICTED SHELL + + +below). +The value may not be changed. +This is not reset when the startup files are executed, allowing +the startup files to discover whether or not a shell is restricted. +
shift_verbose + +
+If set, the +shift + +builtin prints an error message when the shift count exceeds the +number of positional parameters. +
sourcepath + +
+If set, the +source (.) builtin uses the value of +PATH + + +to find the directory containing the file supplied as an argument. +This option is enabled by default. +
xpg_echo + +
+If set, the echo builtin expands backslash-escape sequences +by default. +
+ + +
suspend [-f]
+Suspend the execution of this shell until it receives a +SIGCONT + + +signal. A login shell cannot be suspended; the +-f + +option can be used to override this and force the suspension. +The return status is 0 unless the shell is a login shell and +-f + +is not supplied, or if job control is not enabled. +
test expr
+ +
[ expr ]
+Return a status of 0 (true) or 1 (false) depending on +the evaluation of the conditional expression +expr. + +Each operator and operand must be a separate argument. +Expressions are composed of the primaries described above under +CONDITIONAL EXPRESSIONS. + + +test does not accept any options, nor does it accept and ignore +an argument of -- as signifying the end of options. +

+ + +Expressions may be combined using the following operators, listed +in decreasing order of precedence. +The evaluation depends on the number of arguments; see below. +Operator precedence is used when there are five or more arguments. +

+ +
+
! expr + +
+True if +expr + +is false. +
( expr ) + +
+Returns the value of expr. +This may be used to override the normal precedence of operators. +
expr1 -a expr2
+True if both +expr1 + +and +expr2 + +are true. +
expr1 -o expr2
+True if either +expr1 + +or +expr2 + +is true. + +
+

+ +test and [ evaluate conditional +expressions using a set of rules based on the number of arguments. +

+ + + +

+
0 arguments
+The expression is false. +
1 argument
+The expression is true if and only if the argument is not null. +
2 arguments
+If the first argument is !, the expression is true if and +only if the second argument is null. +If the first argument is one of the unary conditional operators listed above +under +CONDITIONAL EXPRESSIONS, + + +the expression is true if the unary test is true. +If the first argument is not a valid unary conditional operator, the expression +is false. +
3 arguments
+The following conditions are applied in the order listed. +If the second argument is one of the binary conditional operators listed above +under +CONDITIONAL EXPRESSIONS, + + +the result of the expression is the result of the binary test using +the first and third arguments as operands. +The -a and -o operators are considered binary operators +when there are three arguments. +If the first argument is !, the value is the negation of +the two-argument test using the second and third arguments. +If the first argument is exactly ( and the third argument is +exactly ), the result is the one-argument test of the second +argument. +Otherwise, the expression is false. +
4 arguments
+If the first argument is !, 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. +
5 or more arguments
+The expression is parsed and evaluated according to precedence +using the rules listed above. +

+ + +

+

+ +When used with test or [, the < and > operators +sort lexicographically using ASCII ordering. +

+ + +
times + +
+Print the accumulated user and system times for the shell and +for processes run from the shell. The return status is 0. +
trap [-lp] [[arg] sigspec ...]
+The command +arg + +is to be read and executed when the shell receives +signal(s) +sigspec. + +If +arg + +is absent (and there is a single sigspec) or +-, + +each specified signal is +reset to its original disposition (the value it had +upon entrance to the shell). +If +arg + +is the null string the signal specified by each +sigspec + +is ignored by the shell and by the commands it invokes. +If +arg + +is not present and +-p + +has been supplied, then the trap commands associated with each +sigspec + +are displayed. +If no arguments are supplied or if only +-p + +is given, +trap + +prints the list of commands associated with each signal. +The +-l + +option causes the shell to print a list of signal names and +their corresponding numbers. +Each +sigspec + +is either +a signal name defined in <signal.h>, or a signal number. +Signal names are case insensitive and the +SIG + + +prefix is optional. +

+ + +If a +sigspec + +is +EXIT + + +(0) the command +arg + +is executed on exit from the shell. +If a +sigspec + +is +DEBUG, + + +the command +arg + +is executed before every simple command, for command, +case command, select command, every arithmetic for +command, and before the first command executes in a shell function (see +SHELL GRAMMAR + + +above). +Refer to the description of the extdebug option to the +shopt builtin for details of its effect on the DEBUG trap. +If a +sigspec + +is +RETURN, + + +the command +arg + +is executed each time a shell function or a script executed with +the . or source builtins finishes executing. +

+ + +If a +sigspec + +is +ERR, + + +the command +arg + +is executed whenever +a pipeline (which may consist of a single simple +command), a list, or a compound command returns a +non-zero exit status, +subject to the following conditions. +The +ERR + + +trap is not executed if the failed +command is part of the command list immediately following a +while + +or +until + +keyword, +part of the test in an +if + +statement, part of a command executed in a +&& + +or +|| + +list except the command following the final && or ||, +any command in a pipeline but the last, +or if the command's return value is +being inverted using +!. + +These are the same conditions obeyed by the errexit (-e) option. +

+ + +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 subshell or subshell environment when one is created. +The return status is false if any +sigspec + +is invalid; otherwise +trap + +returns true. +

type [-aftpP] name [name ...]
+With no options, +indicate how each +name + +would be interpreted if used as a command name. +If the +-t + +option is used, +type + +prints a string which is one of +alias, + +keyword, + +function, + +builtin, + +or +file + +if +name + +is an alias, shell reserved word, function, builtin, or disk file, +respectively. +If the +name + +is not found, then nothing is printed, and an exit status of false +is returned. +If the +-p + +option is used, +type + +either returns the name of the disk file +that would be executed if +name + +were specified as a command name, +or nothing if +type -t name + +would not return +file. + +The +-P + +option forces a +PATH + + +search for each name, even if +type -t name + +would not return +file. + +If a command is hashed, +-p + +and +-P + +print the hashed value, which is not necessarily the file that appears +first in +PATH. + + +If the +-a + +option is used, +type + +prints all of the places that contain +an executable named +name. + +This includes aliases and functions, +if and only if the +-p + +option is not also used. +The table of hashed commands is not consulted +when using +-a. + +The +-f + +option suppresses shell function lookup, as with the command builtin. +type + +returns true if all of the arguments are found, false if +any are not found. +
ulimit [-HSabcdefiklmnpqrstuvxPT [limit]]
+Provides control over the resources available to the shell and to +processes started by it, on systems that allow such control. +The -H and -S options specify that the hard or soft limit is +set for the given resource. +A hard limit cannot be increased by a non-root user once it is set; +a soft limit may be increased up to the value of the hard limit. +If neither -H nor -S is specified, both the soft and hard +limits are set. +The value of +limit + +can be a number in the unit specified for the resource +or one of the special values +hard, + +soft, + +or +unlimited, + +which stand for the current hard limit, the current soft limit, and +no limit, respectively. +If +limit + +is omitted, the current value of the soft limit of the resource is +printed, unless the -H option is given. When more than one +resource is specified, the limit name and unit are printed before the value. +Other options are interpreted as follows: +
+ +
+
-a + +
+All current limits are reported +
-b + +
+The maximum socket buffer size +
-c + +
+The maximum size of core files created +
-d + +
+The maximum size of a process's data segment +
-e + +
+The maximum scheduling priority ("nice") +
-f + +
+The maximum size of files written by the shell and its children +
-i + +
+The maximum number of pending signals +
-k + +
+The maximum number of kqueues that may be allocated +
-l + +
+The maximum size that may be locked into memory +
-m + +
+The maximum resident set size (many systems do not honor this limit) +
-n + +
+The maximum number of open file descriptors (most systems do not +allow this value to be set) +
-p + +
+The pipe size in 512-byte blocks (this may not be set) +
-q + +
+The maximum number of bytes in POSIX message queues +
-r + +
+The maximum real-time scheduling priority +
-s + +
+The maximum stack size +
-t + +
+The maximum amount of cpu time in seconds +
-u + +
+The maximum number of processes available to a single user +
-v + +
+The maximum amount of virtual memory available to the shell and, on +some systems, to its children +
-x + +
+The maximum number of file locks +
-P + +
+The maximum number of pseudoterminals +
-T + +
+The maximum number of threads + +
+

+ +If +limit + +is given, and the +-a + +option is not used, +limit is the new value of the specified resource. +If no option is given, then +-f + +is assumed. Values are in 1024-byte increments, except for +-t, + +which is in seconds; +-p, + +which is in units of 512-byte blocks; +-P, + +-T, + +-b, + +-k, + +-n, + +and +-u, + +which are unscaled values; +and, when in Posix mode, +-c + +and +-f, + +which are in 512-byte increments. +The return status is 0 unless an invalid option or argument is supplied, +or an error occurs while setting a new limit. +

+ +
umask [-p] [-S] [mode]
+The user file-creation mask is set to +mode. + +If +mode + +begins with a digit, it +is interpreted as an octal number; otherwise +it is interpreted as a symbolic mode mask similar +to that accepted by +chmod(1). + +If +mode + +is omitted, the current value of the mask is printed. +The +-S + +option causes the mask to be printed in symbolic form; the +default output is an octal number. +If the +-p + +option is supplied, and +mode + +is omitted, the output is in a form that may be reused as input. +The return status is 0 if the mode was successfully changed or if +no mode argument was supplied, and false otherwise. +
unalias [-a] [name ...]
+Remove each name from the list of defined aliases. If +-a + +is supplied, all alias definitions are removed. The return +value is true unless a supplied +name + +is not a defined alias. +
unset [-fv] [-n] [name ...]
+For each +name, + +remove the corresponding variable or function. +If the +-v + +option is given, each +name + +refers to a shell variable, and that variable is removed. +Read-only variables may not be unset. +If +-f + +is specified, each +name + +refers to a shell function, and the function definition +is removed. +If the +-n + +option is supplied, and name is a variable with the nameref +attribute, name will be unset rather than the variable it +references. +-n has no effect if the -f option is supplied. +If no options are supplied, each name refers to a variable; if +there is no variable by that name, any function with that name is +unset. +Each unset variable or function is removed from the environment +passed to subsequent commands. +If any of +COMP_WORDBREAKS, + + +RANDOM, + + +SECONDS, + + +LINENO, + + +HISTCMD, + + +FUNCNAME, + + +GROUPS, + + +or +DIRSTACK + + +are unset, they lose their special properties, even if they are +subsequently reset. The exit status is true unless a +name + +is readonly. +
wait [-n] [n ...]
+Wait for each specified child process and return its termination status. +Each +n + +may be a process +ID or a job specification; if a job spec is given, all processes +in that job's pipeline are waited for. If +n + +is not given, all currently active child processes +are waited for, and the return status is zero. +If the -n option is supplied, wait waits for any job to +terminate and returns its exit status. +If +n + +specifies a non-existent process or job, the return status is +127. Otherwise, the return status is the exit status of the last +process or job waited for. + + +
+  +

RESTRICTED SHELL

+ + + +

+ +If +bash + +is started with the name +rbash, + +or the +-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. +It behaves identically to +bash + +with the exception that the following are disallowed or not performed: +

+
*
+changing directories with cd +
*
+setting or unsetting the values of +SHELL, + + +PATH, + + +ENV, + + +or +BASH_ENV + + +
*
+specifying command names containing +/ + +
*
+specifying a filename containing a +/ + +as an argument to the +. + +builtin command +
*
+specifying a filename containing a slash as an argument to the +-p + +option to the +hash + +builtin command +
*
+importing function definitions from the shell environment at startup +
*
+parsing the value of +SHELLOPTS + + +from the shell environment at startup +
*
+redirecting output using the >, >|, <>, >&, &>, and >> redirection operators +
*
+using the +exec + +builtin command to replace the shell with another command +
*
+adding or deleting builtin commands with the +-f + +and +-d + +options to the +enable + +builtin command +
*
+using the enable builtin command to enable disabled shell builtins +
*
+specifying the +-p + +option to the +command + +builtin command +
*
+turning off restricted mode with +set +r or set +o restricted. +
+

+ +These restrictions are enforced after any startup files are read. +

+ + + When a command that is found to be a shell script is executed +(see +COMMAND EXECUTION + + + +above), + +rbash + +turns off any restrictions in the shell spawned to execute the +script. + + +  +

SEE ALSO

+ + +
+
Bash Reference Manual, Brian Fox and Chet Ramey
+
The Gnu Readline Library, Brian Fox and Chet Ramey
+
The Gnu History Library, Brian Fox and Chet Ramey
+
Portable Operating System Interface (POSIX) Part 2: Shell and Utilities, IEEE --
+http://pubs.opengroup.org/onlinepubs/9699919799/ +
http://tiswww.case.edu/~chet/bash/POSIX -- a description of posix mode
+
sh(1), ksh(1), csh(1)
+
emacs(1), vi(1)
+
readline(3)
+ +
+  +

FILES

+ + +
+
+/bin/bash + +
+The bash executable +
+/etc/profile + +
+The systemwide initialization file, executed for login shells +
+~/.bash_profile + +
+The personal initialization file, executed for login shells +
+~/.bashrc + +
+The individual per-interactive-shell startup file +
+~/.bash_logout + +
+The individual login shell cleanup file, executed when a login shell exits +
+~/.inputrc + +
+Individual readline initialization file + +
+  +

AUTHORS

+ +Brian Fox, Free Software Foundation +
+ +bfox@gnu.org +

+ +Chet Ramey, Case Western Reserve University +
+ +chet.ramey@case.edu +  +

BUG REPORTS

+ +If you find a bug in +bash, + +you should report it. 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 is always available from +ftp://ftp.gnu.org/pub/gnu/bash/. +

+ +Once you have determined that a bug actually exists, use the +bashbug + +command to submit a bug report. +If you have a fix, you are encouraged to mail that as well! +Suggestions and `philosophical' bug reports may be mailed +to bug-bash@gnu.org or posted to the Usenet +newsgroup +gnu.bash.bug. + +

+ +ALL bug reports should include: +

+ + +

+
The version number of bash
+
The hardware and operating system
+
The compiler used to compile
+
A description of the bug behaviour
+
A short script or `recipe' which exercises the bug
+ +
+

+ +bashbug + +inserts the first three items automatically into the template +it provides for filing a bug report. +

+ +Comments and bug reports concerning +this manual page should be directed to +chet.ramey@case.edu. + +  +

BUGS

+ +

+ +It's too big and too slow. +

+ +There are some subtle differences between +bash + +and traditional versions of +sh, + +mostly because of the +POSIX + + +specification. +

+ +Aliases are confusing in some uses. +

+ +Shell builtin commands and functions are not stoppable/restartable. +

+ +Compound commands and command sequences of the form `a ; b ; c' +are not handled gracefully when process suspension is attempted. +When a process is stopped, the shell immediately executes the next +command in the sequence. +It suffices to place the sequence of commands between +parentheses to force it into a subshell, which may be stopped as +a unit. +

+ +Array variables may not (yet) be exported. +

+ +There may be only one active coprocess at a time. + + + +


+ + + +
GNU Bash 4.42016 August 26BASH(1) +
+
+ 

Index

+
+
NAME
+
SYNOPSIS
+
COPYRIGHT
+
DESCRIPTION
+
OPTIONS
+
ARGUMENTS
+
INVOCATION
+
DEFINITIONS
+
RESERVED WORDS
+
SHELL GRAMMAR
+
+
Simple Commands
+
Pipelines
+
Lists
+
Compound Commands
+
Coprocesses
+
Shell Function Definitions
+
+
COMMENTS
+
QUOTING
+
PARAMETERS
+
+
Positional Parameters
+
Special Parameters
+
Shell Variables
+
Arrays
+
+
EXPANSION
+
+
Brace Expansion
+
Tilde Expansion
+
Parameter Expansion
+
Command Substitution
+
Arithmetic Expansion
+
Process Substitution
+
Word Splitting
+
Pathname Expansion
+
Quote Removal
+
+
REDIRECTION
+
+
Redirecting Input
+
Redirecting Output
+
Appending Redirected Output
+
Redirecting Standard Output and Standard Error
+
Appending Standard Output and Standard Error
+
Here Documents
+
Here Strings
+
Duplicating File Descriptors
+
Moving File Descriptors
+
Opening File Descriptors for Reading and Writing
+
+
ALIASES
+
FUNCTIONS
+
ARITHMETIC EVALUATION
+
CONDITIONAL EXPRESSIONS
+
SIMPLE COMMAND EXPANSION
+
COMMAND EXECUTION
+
COMMAND EXECUTION ENVIRONMENT
+
ENVIRONMENT
+
EXIT STATUS
+
SIGNALS
+
JOB CONTROL
+
PROMPTING
+
READLINE
+
+
Readline Notation
+
Readline Initialization
+
Readline Key Bindings
+
Readline Variables
+
Readline Conditional Constructs
+
Searching
+
Readline Command Names
+
Commands for Moving
+
Commands for Manipulating the History
+
Commands for Changing Text
+
Killing and Yanking
+
Numeric Arguments
+
Completing
+
Keyboard Macros
+
Miscellaneous
+
Programmable Completion
+
+
HISTORY
+
HISTORY EXPANSION
+
+
Event Designators
+
Word Designators
+
Modifiers
+
+
SHELL BUILTIN COMMANDS
+
RESTRICTED SHELL
+
SEE ALSO
+
FILES
+
AUTHORS
+
BUG REPORTS
+
BUGS
+
+
+This document was created by man2html from bash.1.
+Time: 31 August 2016 10:24:30 EDT + + diff --git a/doc/bash.info b/doc/bash.info new file mode 100644 index 0000000..fac6786 --- /dev/null +++ b/doc/bash.info @@ -0,0 +1,11484 @@ +This is bash.info, produced by makeinfo version 6.1 from +bashref.texi. + +This text is a brief description of the features that are present in the +Bash shell (version 4.4, 7 September 2016). + + This is Edition 4.4, last updated 7 September 2016, of 'The GNU Bash +Reference Manual', for 'Bash', Version 4.4. + + Copyright (C) 1988-2016 Free Software Foundation, Inc. + + Permission is granted to copy, distribute and/or modify this + document under the terms of the GNU Free Documentation License, + Version 1.3 or any later version published by the Free Software + Foundation; with no Invariant Sections, no Front-Cover Texts, and + no Back-Cover Texts. A copy of the license is included in the + section entitled "GNU Free Documentation License". +INFO-DIR-SECTION Basics +START-INFO-DIR-ENTRY +* Bash: (bash). The GNU Bourne-Again SHell. +END-INFO-DIR-ENTRY + + +File: bash.info, Node: Top, Next: Introduction, Prev: (dir), Up: (dir) + +Bash Features +************* + +This text is a brief description of the features that are present in the +Bash shell (version 4.4, 7 September 2016). The Bash home page is +. + + This is Edition 4.4, last updated 7 September 2016, of 'The GNU Bash +Reference Manual', for 'Bash', Version 4.4. + + 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 ('sh'), the Korn Shell +('ksh'), and the C-shell ('csh' and its successor, 'tcsh'). The +following menu breaks the features up into categories, noting which +features were inspired by other shells and which are specific to Bash. + + 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. +* Command Line Editing:: Chapter describing the command line + editing features. +* Using History Interactively:: Command History Expansion +* 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. +* GNU Free Documentation License:: Copying and sharing this documentation. +* Indexes:: Various indexes for this manual. + + +File: bash.info, Node: Introduction, Next: Definitions, Up: Top + +1 Introduction +************** + +* Menu: + +* What is Bash?:: A short description of Bash. +* What is a shell?:: A brief introduction to shells. + + +File: bash.info, Node: What is Bash?, Next: What is a shell?, Up: Introduction + +1.1 What is Bash? +================= + +Bash is the shell, or command language interpreter, for the GNU +operating system. The name is an acronym for the 'Bourne-Again SHell', +a pun on Stephen Bourne, the author of the direct ancestor of the +current Unix shell 'sh', which appeared in the Seventh Edition Bell Labs +Research version of Unix. + + Bash is largely compatible with 'sh' and incorporates useful features +from the Korn shell 'ksh' and the C shell 'csh'. It is intended to be a +conformant implementation of the IEEE POSIX Shell and Tools portion of +the IEEE POSIX specification (IEEE Standard 1003.1). It offers +functional improvements over 'sh' for both interactive and programming +use. + + While the GNU operating system provides other shells, including a +version of 'csh', Bash is the default shell. Like other GNU software, +Bash is quite portable. It currently runs on nearly every version of +Unix and a few other operating systems - independently-supported ports +exist for MS-DOS, OS/2, and Windows platforms. + + +File: bash.info, Node: What is a shell?, Prev: What is Bash?, Up: Introduction + +1.2 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 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 +'/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 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 "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 ("builtins") +implementing functionality impossible or inconvenient to obtain via +separate utilities. For example, 'cd', 'break', 'continue', and 'exec' +cannot be implemented outside of the shell because they directly +manipulate the shell itself. The 'history', 'getopts', 'kill', or '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. + + +File: bash.info, Node: Definitions, Next: Basic Shell Features, Prev: Introduction, Up: Top + +2 Definitions +************* + +These definitions are used throughout the remainder of this manual. + +'POSIX' + A family of open system standards based on Unix. Bash is primarily + concerned with the Shell and Utilities portion of the POSIX 1003.1 + standard. + +'blank' + A space or tab character. + +'builtin' + A command that is implemented internally by the shell itself, + rather than by an executable program somewhere in the file system. + +'control operator' + A 'token' that performs a control function. It is a 'newline' or + one of the following: '||', '&&', '&', ';', ';;', ';&', ';;&', '|', + '|&', '(', or ')'. + +'exit status' + The value returned by a command to its caller. The value is + restricted to eight bits, so the maximum value is 255. + +'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. + +'filename' + A string of characters used to identify a file. + +'job' + A set of processes comprising a pipeline, and any processes + descended from it, that are all in the same process group. + +'job control' + A mechanism by which users can selectively stop (suspend) and + restart (resume) execution of processes. + +'metacharacter' + A character that, when unquoted, separates words. A metacharacter + is a 'space', 'tab', 'newline', or one of the following characters: + '|', '&', ';', '(', ')', '<', or '>'. + +'name' + A 'word' consisting solely of letters, numbers, and underscores, + and beginning with a letter or underscore. 'Name's are used as + shell variable and function names. Also referred to as an + 'identifier'. + +'operator' + A 'control operator' or a 'redirection operator'. *Note + Redirections::, for a list of redirection operators. Operators + contain at least one unquoted 'metacharacter'. + +'process group' + A collection of related processes each having the same process + group ID. + +'process group ID' + A unique identifier that represents a 'process group' during its + lifetime. + +'reserved word' + A 'word' that has a special meaning to the shell. Most reserved + words introduce shell flow control constructs, such as 'for' and + 'while'. + +'return status' + A synonym for 'exit status'. + +'signal' + A mechanism by which a process may be notified by the kernel of an + event occurring in the system. + +'special builtin' + A shell builtin command that has been classified as special by the + POSIX standard. + +'token' + A sequence of characters considered a single unit by the shell. It + is either a 'word' or an 'operator'. + +'word' + A sequence of characters treated as a unit by the shell. Words may + not include unquoted 'metacharacters'. + + +File: bash.info, Node: Basic Shell Features, Next: Shell Builtin Commands, Prev: Definitions, Up: Top + +3 Basic Shell Features +********************** + +Bash is an acronym for '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 POSIX specification for the +'standard' Unix shell. + + This chapter briefly summarizes the shell's 'building blocks': +commands, control structures, shell functions, shell parameters, shell +expansions, 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. + + +File: bash.info, Node: Shell Syntax, Next: Shell Commands, Up: Basic Shell Features + +3.1 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. + +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 ('#'), 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. + + +File: bash.info, Node: Shell Operation, Next: Quoting, Up: Shell Syntax + +3.1.1 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: + + 1. Reads its input from a file (*note Shell Scripts::), from a string + supplied as an argument to the '-c' invocation option (*note + Invoking Bash::), or from the user's terminal. + + 2. Breaks the input into words and operators, obeying the quoting + rules described in *note Quoting::. These tokens are separated by + 'metacharacters'. Alias expansion is performed by this step (*note + Aliases::). + + 3. Parses the tokens into simple and compound commands (*note Shell + Commands::). + + 4. Performs the various shell expansions (*note Shell Expansions::), + breaking the expanded tokens into lists of filenames (*note + Filename Expansion::) and commands and arguments. + + 5. Performs any necessary redirections (*note Redirections::) and + removes the redirection operators and their operands from the + argument list. + + 6. Executes the command (*note Executing Commands::). + + 7. Optionally waits for the command to complete and collects its exit + status (*note Exit Status::). + + +File: bash.info, Node: Quoting, Next: Comments, Prev: Shell Operation, Up: Shell Syntax + +3.1.2 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. + +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 (*note 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 (*note +History Interaction::), the HISTORY EXPANSION character, usually '!', +must be quoted to prevent history expansion. *Note Bash History +Facilities::, for more details concerning history expansion. + + There are three quoting mechanisms: the ESCAPE CHARACTER, single +quotes, and double quotes. + + +File: bash.info, Node: Escape Character, Next: Single Quotes, Up: Quoting + +3.1.2.1 Escape Character +........................ + +A non-quoted backslash '\' is the Bash escape character. It preserves +the literal value of the next character that follows, with the exception +of 'newline'. If a '\newline' pair appears, and the backslash itself is +not quoted, the '\newline' is treated as a line continuation (that is, +it is removed from the input stream and effectively ignored). + + +File: bash.info, Node: Single Quotes, Next: Double Quotes, Prev: Escape Character, Up: Quoting + +3.1.2.2 Single Quotes +..................... + +Enclosing characters in single quotes (''') 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. + + +File: bash.info, Node: Double Quotes, Next: ANSI-C Quoting, Prev: Single Quotes, Up: Quoting + +3.1.2.3 Double Quotes +..................... + +Enclosing characters in double quotes ('"') preserves the literal value +of all characters within the quotes, with the exception of '$', '`', +'\', and, when history expansion is enabled, '!'. When the shell is in +POSIX mode (*note Bash POSIX Mode::), the '!' has no special meaning +within double quotes, even when history expansion is enabled. The +characters '$' and '`' retain their special meaning within double quotes +(*note Shell Expansions::). The backslash retains its special meaning +only when followed by one of the following characters: '$', '`', '"', +'\', or '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 +'!' appearing in double quotes is escaped using a backslash. The +backslash preceding the '!' is not removed. + + The special parameters '*' and '@' have special meaning when in +double quotes (*note Shell Parameter Expansion::). + + +File: bash.info, Node: ANSI-C Quoting, Next: Locale Translation, Prev: Double Quotes, Up: Quoting + +3.1.2.4 ANSI-C Quoting +...................... + +Words of the form '$'STRING'' are treated specially. The word expands +to STRING, with backslash-escaped characters replaced as specified by +the ANSI C standard. Backslash escape sequences, if present, are +decoded as follows: + +'\a' + alert (bell) +'\b' + backspace +'\e' +'\E' + an escape character (not ANSI C) +'\f' + form feed +'\n' + newline +'\r' + carriage return +'\t' + horizontal tab +'\v' + vertical tab +'\\' + backslash +'\'' + single quote +'\"' + double quote +'\?' + question mark +'\NNN' + the eight-bit character whose value is the octal value NNN (one to + three digits) +'\xHH' + the eight-bit character whose value is the hexadecimal value HH + (one or two hex digits) +'\uHHHH' + the Unicode (ISO/IEC 10646) character whose value is the + hexadecimal value HHHH (one to four hex digits) +'\UHHHHHHHH' + the Unicode (ISO/IEC 10646) character whose value is the + hexadecimal value HHHHHHHH (one to eight hex digits) +'\cX' + a control-X character + +The expanded result is single-quoted, as if the dollar sign had not been +present. + + +File: bash.info, Node: Locale Translation, Prev: ANSI-C Quoting, Up: Quoting + +3.1.2.5 Locale-Specific Translation +................................... + +A double-quoted string preceded by a dollar sign ('$') will cause the +string to be translated according to the current locale. If the current +locale is 'C' or 'POSIX', the dollar sign is ignored. If the string is +translated and replaced, the replacement is double-quoted. + + Some systems use the message catalog selected by the 'LC_MESSAGES' +shell variable. Others create the name of the message catalog from the +value of the 'TEXTDOMAIN' shell variable, possibly adding a suffix of +'.mo'. If you use the 'TEXTDOMAIN' variable, you may need to set the +'TEXTDOMAINDIR' variable to the location of the message catalog files. +Still others use both variables in this fashion: +'TEXTDOMAINDIR'/'LC_MESSAGES'/LC_MESSAGES/'TEXTDOMAIN'.mo. + + +File: bash.info, Node: Comments, Prev: Quoting, Up: Shell Syntax + +3.1.3 Comments +-------------- + +In a non-interactive shell, or an interactive shell in which the +'interactive_comments' option to the 'shopt' builtin is enabled (*note +The Shopt Builtin::), a word beginning with '#' causes that word and all +remaining characters on that line to be ignored. An interactive shell +without the 'interactive_comments' option enabled does not allow +comments. The 'interactive_comments' option is on by default in +interactive shells. *Note Interactive Shells::, for a description of +what makes a shell interactive. + + +File: bash.info, Node: Shell Commands, Next: Shell Functions, Prev: Shell Syntax, Up: Basic Shell Features + +3.2 Shell Commands +================== + +A simple shell command such as '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. +* Coprocesses:: Two-way communication between commands. +* GNU Parallel:: Running commands in parallel. + + +File: bash.info, Node: Simple Commands, Next: Pipelines, Up: Shell Commands + +3.2.1 Simple Commands +--------------------- + +A simple command is the kind of command encountered most often. It's +just a sequence of words separated by 'blank's, terminated by one of the +shell's control operators (*note 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 (*note Exit Status::) of a simple command is its +exit status as provided by the POSIX 1003.1 'waitpid' function, or 128+N +if the command was terminated by signal N. + + +File: bash.info, Node: Pipelines, Next: Lists, Prev: Simple Commands, Up: Shell Commands + +3.2.2 Pipelines +--------------- + +A 'pipeline' is a sequence of one or more commands separated by one of +the control operators '|' or '|&'. + + The format for a pipeline is + [time [-p]] [!] COMMAND1 [ | or |& COMMAND2 ] ... + +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. This connection is performed before any redirections +specified by the command. + + If '|&' is used, COMMAND1's standard error, in addition to its +standard output, is connected to COMMAND2's standard input through the +pipe; it is shorthand for '2>&1 |'. This implicit redirection of the +standard error to the standard output is performed after any +redirections specified by the command. + + The reserved word '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 '-p' option changes the output format to that +specified by POSIX. When the shell is in POSIX mode (*note Bash POSIX +Mode::), it does not recognize 'time' as a reserved word if the next +token begins with a '-'. The 'TIMEFORMAT' variable may be set to a +format string that specifies how the timing information should be +displayed. *Note Bash Variables::, for a description of the available +formats. The use of 'time' as a reserved word permits the timing of +shell builtins, shell functions, and pipelines. An external 'time' +command cannot time these easily. + + When the shell is in POSIX mode (*note Bash POSIX Mode::), 'time' may +be followed by a newline. In this case, the shell displays the total +user and system time consumed by the shell and its children. The +'TIMEFORMAT' variable may be used to specify the format of the time +information. + + If the pipeline is not executed asynchronously (*note Lists::), the +shell waits for all commands in the pipeline to complete. + + Each command in a pipeline is executed in its own subshell (*note +Command Execution Environment::). The exit status of a pipeline is the +exit status of the last command in the pipeline, unless the 'pipefail' +option is enabled (*note The Set Builtin::). If '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 '!' 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. + + +File: bash.info, Node: Lists, Next: Compound Commands, Prev: Pipelines, Up: Shell Commands + +3.2.3 Lists of Commands +----------------------- + +A 'list' is a sequence of one or more pipelines separated by one of the +operators ';', '&', '&&', or '||', and optionally terminated by one of +';', '&', or a 'newline'. + + Of these list operators, '&&' and '||' have equal precedence, +followed by ';' and '&', which have equal precedence. + + A sequence of one or more newlines may appear in a 'list' to delimit +commands, equivalent to a semicolon. + + If a command is terminated by the control operator '&', the shell +executes the command asynchronously in a subshell. This is known as +executing the command in the BACKGROUND. The shell does not wait for +the command to finish, and the return status is 0 (true). When job +control is not active (*note Job Control::), the standard input for +asynchronous commands, in the absence of any explicit redirections, is +redirected from '/dev/null'. + + Commands separated by a ';' 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. + + AND and OR lists are sequences of one or more pipelines separated by +the control operators '&&' and '||', respectively. AND and OR lists are +executed with left associativity. + + An AND list has the form + COMMAND1 && COMMAND2 + +COMMAND2 is executed if, and only if, COMMAND1 returns an exit status of +zero. + + An OR list has the form + COMMAND1 || COMMAND2 + +COMMAND2 is executed if, and only if, COMMAND1 returns a non-zero exit +status. + + The return status of AND and OR lists is the exit status of the last +command executed in the list. + + +File: bash.info, Node: Compound Commands, Next: Coprocesses, Prev: Lists, Up: Shell Commands + +3.2.4 Compound Commands +----------------------- + +* Menu: + +* Looping Constructs:: Shell commands for iterative action. +* Conditional Constructs:: Shell commands for conditional execution. +* Command Grouping:: Ways to group commands. + +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 (*note +Redirections::) associated with a compound command apply to all commands +within that compound command unless explicitly overridden. + + In most cases a list of commands in a compound command's description +may be separated from the rest of the command by one or more newlines, +and may be followed by a newline in place of a semicolon. + + Bash provides looping constructs, conditional commands, and +mechanisms to group commands and execute them as a unit. + + +File: bash.info, Node: Looping Constructs, Next: Conditional Constructs, Up: Compound Commands + +3.2.4.1 Looping Constructs +.......................... + +Bash supports the following looping constructs. + + Note that wherever a ';' appears in the description of a command's +syntax, it may be replaced with one or more newlines. + +'until' + The syntax of the 'until' command is: + + until TEST-COMMANDS; do CONSEQUENT-COMMANDS; done + + Execute CONSEQUENT-COMMANDS as long as TEST-COMMANDS has an exit + status which is not zero. The return status is the exit status of + the last command executed in CONSEQUENT-COMMANDS, or zero if none + was executed. + +'while' + The syntax of the 'while' command is: + + while TEST-COMMANDS; do CONSEQUENT-COMMANDS; done + + Execute CONSEQUENT-COMMANDS as long as TEST-COMMANDS has an exit + status of zero. The return status is the exit status of the last + command executed in CONSEQUENT-COMMANDS, or zero if none was + executed. + +'for' + The syntax of the 'for' command is: + + for NAME [ [in [WORDS ...] ] ; ] do COMMANDS; done + + Expand WORDS, and execute COMMANDS once for each member in the + resultant list, with NAME bound to the current member. If 'in + WORDS' is not present, the 'for' command executes the COMMANDS once + for each positional parameter that is set, as if 'in "$@"' had been + specified (*note Special Parameters::). The return status is the + exit status of the last command that executes. If there are no + items in the expansion of WORDS, no commands are executed, and the + return status is zero. + + An alternate form of the 'for' command is also supported: + + for (( EXPR1 ; EXPR2 ; EXPR3 )) ; do COMMANDS ; done + + First, the arithmetic expression EXPR1 is evaluated according to + the rules described below (*note Shell Arithmetic::). The + arithmetic expression EXPR2 is then evaluated repeatedly until it + evaluates to zero. Each time EXPR2 evaluates to a non-zero value, + COMMANDS are executed and the arithmetic expression 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 COMMANDS that is executed, or false if any of the + expressions is invalid. + + The 'break' and 'continue' builtins (*note Bourne Shell Builtins::) +may be used to control loop execution. + + +File: bash.info, Node: Conditional Constructs, Next: Command Grouping, Prev: Looping Constructs, Up: Compound Commands + +3.2.4.2 Conditional Constructs +.............................. + +'if' + The syntax of the 'if' command is: + + if TEST-COMMANDS; then + CONSEQUENT-COMMANDS; + [elif MORE-TEST-COMMANDS; then + MORE-CONSEQUENTS;] + [else ALTERNATE-CONSEQUENTS;] + fi + + The TEST-COMMANDS list is executed, and if its return status is + zero, the CONSEQUENT-COMMANDS list is executed. If TEST-COMMANDS + returns a non-zero status, each 'elif' list is executed in turn, + and if its exit status is zero, the corresponding MORE-CONSEQUENTS + is executed and the command completes. If 'else + ALTERNATE-CONSEQUENTS' is present, and the final command in the + final 'if' or 'elif' clause has a non-zero exit status, then + ALTERNATE-CONSEQUENTS is executed. The return status is the exit + status of the last command executed, or zero if no condition tested + true. + +'case' + The syntax of the 'case' command is: + + case WORD in [ [(] PATTERN [| PATTERN]...) COMMAND-LIST ;;]... esac + + 'case' will selectively execute the COMMAND-LIST corresponding to + the first PATTERN that matches WORD. If the 'nocasematch' shell + option (see the description of 'shopt' in *note The Shopt + Builtin::) is enabled, the match is performed without regard to the + case of alphabetic characters. The '|' is used to separate + multiple patterns, and the ')' operator terminates a pattern list. + A list of patterns and an associated command-list is known as a + CLAUSE. + + Each clause must be terminated with ';;', ';&', or ';;&'. The WORD + undergoes tilde expansion, parameter expansion, command + substitution, arithmetic expansion, and quote removal before + matching is attempted. Each PATTERN undergoes tilde expansion, + parameter expansion, command substitution, and arithmetic + expansion. + + There may be an arbitrary number of 'case' clauses, each terminated + by a ';;', ';&', or ';;&'. The first pattern that matches + determines the command-list that is executed. It's a common idiom + to use '*' as the final pattern to define the default case, since + that pattern will always match. + + Here is an example using 'case' in a script that could be used to + describe one interesting feature of an animal: + + 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." + + + If the ';;' operator is used, no subsequent matches are attempted + after the first pattern match. Using ';&' in place of ';;' causes + execution to continue with the COMMAND-LIST associated with the + next clause, if any. Using ';;&' in place of ';;' causes the shell + to test the patterns in the next clause, if any, and execute any + associated COMMAND-LIST on a successful match. + + The return status is zero if no PATTERN is matched. Otherwise, the + return status is the exit status of the COMMAND-LIST executed. + +'select' + + The 'select' construct allows the easy generation of menus. It has + almost the same syntax as the 'for' command: + + select NAME [in WORDS ...]; do COMMANDS; done + + The list of words following '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 'in WORDS' is + omitted, the positional parameters are printed, as if 'in "$@"' had + been specified. The '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 NAME + is set to that word. If the line is empty, the words and prompt + are displayed again. If 'EOF' is read, the 'select' command + completes. Any other value read causes NAME to be set to null. + The line read is saved in the variable 'REPLY'. + + The COMMANDS are executed after each selection until a 'break' + command is executed, at which point the '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. + + select fname in *; + do + echo you picked $fname \($REPLY\) + break; + done + +'((...))' + (( EXPRESSION )) + + The arithmetic EXPRESSION is evaluated according to the rules + described below (*note 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 + let "EXPRESSION" + *Note Bash Builtins::, for a full description of the 'let' builtin. + +'[[...]]' + [[ EXPRESSION ]] + + Return a status of 0 or 1 depending on the evaluation of the + conditional expression EXPRESSION. Expressions are composed of the + primaries described below in *note Bash Conditional Expressions::. + Word splitting and filename expansion are not performed on the + words between the '[[' and ']]'; tilde expansion, parameter and + variable expansion, arithmetic expansion, command substitution, + process substitution, and quote removal are performed. Conditional + operators such as '-f' must be unquoted to be recognized as + primaries. + + When used with '[[', the '<' and '>' operators sort + lexicographically using the current locale. + + When the '==' and '!=' operators are used, the string to the right + of the operator is considered a pattern and matched according to + the rules described below in *note Pattern Matching::, as if the + 'extglob' shell option were enabled. The '=' operator is identical + to '=='. If the 'nocasematch' shell option (see the description of + 'shopt' in *note 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 ('==') or does not match + ('!=')the pattern, and 1 otherwise. Any part of the pattern may be + quoted to force the quoted portion to be matched as a string. + + An additional binary operator, '=~', is available, with the same + precedence as '==' and '!='. When it is used, the string to the + right of the operator is considered an extended regular expression + and matched accordingly (as in regex3)). 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 'nocasematch' shell option (see the + description of 'shopt' in *note The Shopt Builtin::) is enabled, + the match is performed without regard to the case of alphabetic + characters. Any part of the pattern may be quoted to force the + quoted portion to be matched as a string. Bracket expressions in + regular expressions must be treated carefully, since normal quoting + characters lose their meanings between brackets. If the pattern is + stored in a shell variable, quoting the variable expansion forces + the entire pattern to be matched as a string. Substrings matched + by parenthesized subexpressions within the regular expression are + saved in the array variable 'BASH_REMATCH'. The element of + 'BASH_REMATCH' with index 0 is the portion of the string matching + the entire regular expression. The element of 'BASH_REMATCH' with + index N is the portion of the string matching the Nth parenthesized + subexpression. + + For example, the following will match a line (stored in the shell + variable LINE) if there is a sequence of characters in the value + consisting of any number, including zero, of space characters, zero + or one instances of 'a', then a 'b': + [[ $line =~ [[:space:]]*(a)?b ]] + + That means values like 'aab' and ' aaaaaab' will match, as will a + line containing a 'b' anywhere in its value. + + Storing the regular expression in a shell variable is often a + useful way to avoid problems with quoting characters that are + special to the shell. It is sometimes difficult to specify a + regular expression literally without using quotes, or to keep track + of the quoting used by regular expressions while paying attention + to the shell's quote removal. Using a shell variable to store the + pattern decreases these problems. For example, the following is + equivalent to the above: + pattern='[[:space:]]*(a)?b' + [[ $line =~ $pattern ]] + + If you want to match a character that's special to the regular + expression grammar, it has to be quoted to remove its special + meaning. This means that in the pattern 'xxx.txt', the '.' matches + any character in the string (its usual regular expression meaning), + but in the pattern '"xxx.txt"' it can only match a literal '.'. + Shell programmers should take special care with backslashes, since + backslashes are used both by the shell and regular expressions to + remove the special meaning from the following character. The + following two sets of commands are _not_ equivalent: + pattern='\.' + + [[ . =~ $pattern ]] + [[ . =~ \. ]] + + [[ . =~ "$pattern" ]] + [[ . =~ '\.' ]] + + The first two matches will succeed, but the second two will not, + because in the second two the backslash will be part of the pattern + to be matched. In the first two examples, the backslash removes + the special meaning from '.', so the literal '.' matches. If the + string in the first examples were anything other than '.', say 'a', + the pattern would not match, because the quoted '.' in the pattern + loses its special meaning of matching any single character. + + Expressions may be combined using the following operators, listed + in decreasing order of precedence: + + '( EXPRESSION )' + Returns the value of EXPRESSION. This may be used to override + the normal precedence of operators. + + '! EXPRESSION' + True if EXPRESSION is false. + + 'EXPRESSION1 && EXPRESSION2' + True if both EXPRESSION1 and EXPRESSION2 are true. + + 'EXPRESSION1 || EXPRESSION2' + True if either EXPRESSION1 or EXPRESSION2 is true. + + The '&&' and '||' operators do not evaluate EXPRESSION2 if the + value of EXPRESSION1 is sufficient to determine the return value of + the entire conditional expression. + + +File: bash.info, Node: Command Grouping, Prev: Conditional Constructs, Up: Compound Commands + +3.2.4.3 Grouping Commands +......................... + +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. + +'()' + ( LIST ) + + Placing a list of commands between parentheses causes a subshell + environment to be created (*note Command Execution Environment::), + and each of the commands in LIST to be executed in that subshell. + Since the LIST is executed in a subshell, variable assignments do + not remain in effect after the subshell completes. + +'{}' + { LIST; } + + 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 LIST is required. + + In addition to the creation of a subshell, there is a subtle +difference between these two constructs due to historical reasons. The +braces are 'reserved words', so they must be separated from the LIST by +'blank's or other shell metacharacters. The parentheses are +'operators', and are recognized as separate tokens by the shell even if +they are not separated from the LIST by whitespace. + + The exit status of both of these constructs is the exit status of +LIST. + + +File: bash.info, Node: Coprocesses, Next: GNU Parallel, Prev: Compound Commands, Up: Shell Commands + +3.2.5 Coprocesses +----------------- + +A 'coprocess' is a shell command preceded by the 'coproc' reserved word. +A coprocess is executed asynchronously in a subshell, as if the command +had been terminated with the '&' control operator, with a two-way pipe +established between the executing shell and the coprocess. + + The format for a coprocess is: + coproc [NAME] COMMAND [REDIRECTIONS] + +This creates a coprocess named NAME. If NAME is not supplied, the +default name is COPROC. NAME must not be supplied if COMMAND is a +simple command (*note Simple Commands::); otherwise, it is interpreted +as the first word of the simple command. + + When the coprocess is executed, the shell creates an array variable +(*note Arrays::) named 'NAME' in the context of the executing shell. +The standard output of COMMAND is connected via a pipe to a file +descriptor in the executing shell, and that file descriptor is assigned +to 'NAME'[0]. The standard input of COMMAND is connected via a pipe to +a file descriptor in the executing shell, and that file descriptor is +assigned to 'NAME'[1]. This pipe is established before any redirections +specified by the command (*note Redirections::). The file descriptors +can be utilized as arguments to shell commands and redirections using +standard word expansions. The file descriptors are not available in +subshells. + + The process ID of the shell spawned to execute the coprocess is +available as the value of the variable 'NAME'_PID. The 'wait' builtin +command may be used to wait for the coprocess to terminate. + + Since the coprocess is created as an asynchronous command, the +'coproc' command always returns success. The return status of a +coprocess is the exit status of COMMAND. + + +File: bash.info, Node: GNU Parallel, Prev: Coprocesses, Up: Shell Commands + +3.2.6 GNU Parallel +------------------ + +There are ways to run commands in parallel that are not built into Bash. +GNU Parallel is a tool to do just that. + + GNU Parallel, as its name suggests, can be used to build and run +commands in parallel. You may run the same command with different +arguments, whether they are filenames, usernames, hostnames, or lines +read from files. GNU Parallel provides shorthand references to many of +the most common operations (input lines, various portions of the input +line, different ways to specify the input source, and so on). Parallel +can replace 'xargs' or feed commands from its input sources to several +different instances of Bash. + + For a complete description, refer to the GNU Parallel documentation. +A few examples should provide a brief introduction to its use. + + For example, it is easy to replace 'xargs' to gzip all html files in +the current directory and its subdirectories: + find . -type f -name '*.html' -print | parallel gzip +If you need to protect special characters such as newlines in file +names, use find's '-print0' option and parallel's '-0' option. + + You can use Parallel to move files from the current directory when +the number of files is too large to process with one 'mv' invocation: + ls | parallel mv {} destdir + + As you can see, the {} is replaced with each line read from standard +input. While using 'ls' will work in most instances, it is not +sufficient to deal with all filenames. If you need to accommodate +special characters in filenames, you can use + + find . -depth 1 \! -name '.*' -print0 | parallel -0 mv {} destdir + +as alluded to above. + + This will run as many 'mv' commands as there are files in the current +directory. You can emulate a parallel 'xargs' by adding the '-X' +option: + find . -depth 1 \! -name '.*' -print0 | parallel -0 -X mv {} destdir + + GNU Parallel can replace certain common idioms that operate on lines +read from a file (in this case, filenames listed one per line): + while IFS= read -r x; do + do-something1 "$x" "config-$x" + do-something2 < "$x" + done < file | process-output + +with a more compact syntax reminiscent of lambdas: + cat list | parallel "do-something1 {} config-{} ; do-something2 < {}" | process-output + + Parallel provides a built-in mechanism to remove filename extensions, +which lends itself to batch file transformations or renaming: + ls *.gz | parallel -j+0 "zcat {} | bzip2 >{.}.bz2 && rm {}" +This will recompress all files in the current directory with names +ending in .gz using bzip2, running one job per CPU (-j+0) in parallel. +(We use 'ls' for brevity here; using 'find' as above is more robust in +the face of filenames containing unexpected characters.) Parallel can +take arguments from the command line; the above can also be written as + + parallel "zcat {} | bzip2 >{.}.bz2 && rm {}" ::: *.gz + + If a command generates output, you may want to preserve the input +order in the output. For instance, the following command + { echo foss.org.my ; echo debian.org; echo freenetproject.org; } | parallel traceroute +will display as output the traceroute invocation that finishes first. +Adding the '-k' option + { echo foss.org.my ; echo debian.org; echo freenetproject.org; } | parallel -k traceroute +will ensure that the output of 'traceroute foss.org.my' is displayed +first. + + Finally, Parallel can be used to run a sequence of shell commands in +parallel, similar to 'cat file | bash'. It is not uncommon to take a +list of filenames, create a series of shell commands to operate on them, +and feed that list of commnds to a shell. Parallel can speed this up. +Assuming that 'file' contains a list of shell commands, one per line, + + parallel -j 10 < file + +will evaluate the commands using the shell (since no explicit command is +supplied as an argument), in blocks of ten shell jobs at a time. + + +File: bash.info, Node: Shell Functions, Next: Shell Parameters, Prev: Shell Commands, Up: Basic Shell Features + +3.3 Shell Functions +=================== + +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: + NAME () COMPOUND-COMMAND [ REDIRECTIONS ] + + or + + function NAME [()] COMPOUND-COMMAND [ REDIRECTIONS ] + + This defines a shell function named NAME. The reserved word +'function' is optional. If the 'function' reserved word is supplied, +the parentheses are optional. The BODY of the function is the compound +command COMPOUND-COMMAND (*note Compound Commands::). That command is +usually a LIST enclosed between { and }, but may be any compound command +listed above, with one exception: If the 'function' reserved word is +used, but the parentheses are not supplied, the braces are required. +COMPOUND-COMMAND is executed whenever NAME is specified as the name of a +command. When the shell is in POSIX mode (*note Bash POSIX Mode::), +NAME may not be the same as one of the special builtins (*note Special +Builtins::). Any redirections (*note Redirections::) associated with +the shell function are performed when the function is executed. + + A function definition may be deleted using the '-f' option to the +'unset' builtin (*note 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 'blank's or newlines. This is because the braces are reserved +words and are only recognized as such when they are separated from the +command list by whitespace or another shell metacharacter. Also, when +using the braces, the LIST must be terminated by a semicolon, a '&', or +a newline. + + When a function is executed, the arguments to the function become the +positional parameters during its execution (*note Positional +Parameters::). The special parameter '#' that expands to the number of +positional parameters is updated to reflect the change. Special +parameter '0' is unchanged. The first element of the '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 these exceptions: the 'DEBUG' and +'RETURN' traps are not inherited unless the function has been given the +'trace' attribute using the 'declare' builtin or the '-o functrace' +option has been enabled with the 'set' builtin, (in which case all +functions inherit the 'DEBUG' and 'RETURN' traps), and the 'ERR' trap is +not inherited unless the '-o errtrace' shell option has been enabled. +*Note Bourne Shell Builtins::, for the description of the 'trap' +builtin. + + The 'FUNCNEST' variable, if set to a numeric value greater than 0, +defines a maximum function nesting level. Function invocations that +exceed the limit cause the entire command to abort. + + If the builtin command '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 'RETURN' trap is +executed before execution resumes. When a function completes, the +values of the positional parameters and the special parameter '#' are +restored to the values they had prior to the function's execution. If a +numeric argument is given to '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 'return'. + + Variables local to the function may be declared with the 'local' +builtin. These variables are visible only to the function and the +commands it invokes. + + Function names and definitions may be listed with the '-f' option to +the 'declare' ('typeset') builtin command (*note Bash Builtins::). The +'-F' option to 'declare' or 'typeset' will list the function names only +(and optionally the source file and line number, if the 'extdebug' shell +option is enabled). Functions may be exported so that subshells +automatically have them defined with the '-f' option to the 'export' +builtin (*note 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. The 'FUNCNEST' variable may be used to +limit the depth of the function call stack and restrict the number of +function invocations. By default, no limit is placed on the number of +recursive calls. + + +File: bash.info, Node: Shell Parameters, Next: Shell Expansions, Prev: Shell Functions, Up: Basic Shell Features + +3.4 Shell Parameters +==================== + +* Menu: + +* Positional Parameters:: The shell's command-line arguments. +* Special Parameters:: Parameters denoted by special characters. + +A PARAMETER is an entity that stores values. It can be a 'name', a +number, or one of the special characters listed below. A VARIABLE is a +parameter denoted by a 'name'. A variable has a VALUE and zero or more +ATTRIBUTES. Attributes are assigned using the 'declare' builtin command +(see the description of the 'declare' builtin in *note 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 'unset' builtin command. + + A variable may be assigned to by a statement of the form + NAME=[VALUE] +If VALUE is not given, the variable is assigned the null string. All +VALUEs undergo tilde expansion, parameter and variable expansion, +command substitution, arithmetic expansion, and quote removal (detailed +below). If the variable has its 'integer' attribute set, then VALUE is +evaluated as an arithmetic expression even if the '$((...))' expansion +is not used (*note Arithmetic Expansion::). Word splitting is not +performed, with the exception of '"$@"' as explained below. Filename +expansion is not performed. Assignment statements may also appear as +arguments to the 'alias', 'declare', 'typeset', 'export', 'readonly', +and 'local' builtin commands (DECLARATION commands). When in POSIX mode +(*note Bash POSIX Mode::), these builtins may appear in a command after +one or more instances of the 'command' builtin and retain these +assignment statement properties. + + In the context where an assignment statement is assigning a value to +a shell variable or array index (*note Arrays::), the '+=' operator can +be used to append to or add to the variable's previous value. This +includes arguments to builtin commands such as 'declare' that accept +assignment statements (DECLARATION commands). When '+=' is applied to a +variable for which the INTEGER attribute has been set, VALUE is +evaluated as an arithmetic expression and added to the variable's +current value, which is also evaluated. When '+=' is applied to an +array variable using compound assignment (*note Arrays::), the +variable's value is not unset (as it is when using '='), and new values +are appended to the array beginning at one greater than the array's +maximum index (for indexed arrays), or added as additional key-value +pairs in an associative array. When applied to a string-valued +variable, VALUE is expanded and appended to the variable's value. + + A variable can be assigned the NAMEREF attribute using the '-n' +option to the 'declare' or 'local' builtin commands (*note Bash +Builtins::) to create a NAMEREF, or a reference to another variable. +This allows variables to be manipulated indirectly. Whenever the +nameref variable is referenced, assigned to, unset, or has its +attributes modified (other than using or changing the nameref attribute +itself), the operation is actually performed on the variable specified +by the nameref variable's value. A nameref is commonly used within +shell functions to refer to a variable whose name is passed as an +argument to the function. For instance, if a variable name is passed to +a shell function as its first argument, running + declare -n ref=$1 +inside the function creates a nameref variable REF whose value is the +variable name passed as the first argument. References and assignments +to REF, and changes to its attributes, are treated as references, +assignments, and attribute modifications to the variable whose name was +passed as '$1'. + + If the control variable in a 'for' loop has the nameref attribute, +the list of words can be a list of shell variables, and a name reference +will be established for each word in the list, in turn, when the loop is +executed. Array variables cannot be given the nameref attribute. +However, nameref variables can reference array variables and subscripted +array variables. Namerefs can be unset using the '-n' option to the +'unset' builtin (*note Bourne Shell Builtins::). Otherwise, if 'unset' +is executed with the name of a nameref variable as an argument, the +variable referenced by the nameref variable will be unset. + + +File: bash.info, Node: Positional Parameters, Next: Special Parameters, Up: Shell Parameters + +3.4.1 Positional Parameters +--------------------------- + +A POSITIONAL PARAMETER is a parameter denoted by one or more digits, +other than the single digit '0'. Positional parameters are assigned +from the shell's arguments when it is invoked, and may be reassigned +using the 'set' builtin command. Positional parameter 'N' may be +referenced as '${N}', or as '$N' when 'N' consists of a single digit. +Positional parameters may not be assigned to with assignment statements. +The 'set' and 'shift' builtins are used to set and unset them (*note +Shell Builtin Commands::). The positional parameters are temporarily +replaced when a shell function is executed (*note Shell Functions::). + + When a positional parameter consisting of more than a single digit is +expanded, it must be enclosed in braces. + + +File: bash.info, Node: Special Parameters, Prev: Positional Parameters, Up: Shell Parameters + +3.4.2 Special Parameters +------------------------ + +The shell treats several parameters specially. These parameters may +only be referenced; assignment to them is not allowed. + +'*' + ($*) Expands to the positional parameters, starting from one. When + the expansion is not within double quotes, each positional + parameter expands to a separate word. In contexts where it is + performed, those words are subject to further word splitting and + pathname expansion. 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 'IFS' special + variable. That is, '"$*"' is equivalent to '"$1C$2C..."', where C + is the first character of the value of the 'IFS' variable. If + 'IFS' is unset, the parameters are separated by spaces. If 'IFS' + is null, the parameters are joined without intervening separators. + +'@' + ($@) Expands to the positional parameters, starting from one. When + the expansion occurs within double quotes, each parameter expands + to a separate word. That is, '"$@"' is equivalent to '"$1" "$2" + ...'. 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, '"$@"' and '$@' expand to nothing (i.e., + they are removed). + +'#' + ($#) Expands to the number of positional parameters in decimal. + +'?' + ($?) Expands to the exit status of the most recently executed + foreground pipeline. + +'-' + ($-, a hyphen.) Expands to the current option flags as specified + upon invocation, by the 'set' builtin command, or those set by the + shell itself (such as the '-i' option). + +'$' + ($$) Expands to the process ID of the shell. In a '()' subshell, + it expands to the process ID of the invoking shell, not the + subshell. + +'!' + ($!) Expands to the process ID of the job most recently placed + into the background, whether executed as an asynchronous command or + using the 'bg' builtin (*note Job Control Builtins::). + +'0' + ($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 (*note Shell Scripts::), '$0' is set to the name of that + file. If Bash is started with the '-c' option (*note Invoking + Bash::), then '$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. + +'_' + ($_, 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. + + +File: bash.info, Node: Shell Expansions, Next: Redirections, Prev: Shell Parameters, Up: Basic Shell Features + +3.5 Shell Expansions +==================== + +Expansion is performed on the command line after it has been split into +'token's. There are seven kinds of expansion performed: + + * brace expansion + * tilde expansion + * parameter and variable expansion + * command substitution + * arithmetic expansion + * word splitting + * filename expansion + +* 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. + + The order of expansions is: brace expansion; tilde expansion, +parameter and variable expansion, 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: PROCESS SUBSTITUTION. This is performed at the same time as +tilde, parameter, variable, and arithmetic expansion and command +substitution. + + After these expansions are performed, quote characters present in the +original word are removed unless they have been quoted themselves (QUOTE +REMOVAL). + + Only brace expansion, word splitting, and filename expansion can +change the number of words of the expansion; other expansions expand a +single word to a single word. The only exceptions to this are the +expansions of '"$@"' (*note Special Parameters::) and '"${NAME[@]}"' +(*note Arrays::). + + After all expansions, 'quote removal' (*note Quote Removal::) is +performed. + + +File: bash.info, Node: Brace Expansion, Next: Tilde Expansion, Up: Shell Expansions + +3.5.1 Brace Expansion +--------------------- + +Brace expansion is a mechanism by which arbitrary strings may be +generated. This mechanism is similar to FILENAME EXPANSION (*note +Filename Expansion::), but the filenames generated need not exist. +Patterns to be brace expanded take the form of an optional PREAMBLE, +followed by either a series of comma-separated strings or a sequence +expression between a pair of braces, followed by an optional 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, + bash$ echo a{d,c,b}e + ade ace abe + + A sequence expression takes the form '{X..Y[..INCR]}', where X and Y +are either integers or single characters, and INCR, an optional +increment, is an integer. When integers are supplied, the expression +expands to each number between X and Y, inclusive. Supplied integers +may be prefixed with '0' to force each term to have the same width. +When either X or Y begins with a zero, the shell attempts to force all +generated terms to contain the same number of digits, zero-padding where +necessary. When characters are supplied, the expression expands to each +character lexicographically between X and Y, inclusive, using the +default C locale. Note that both X and Y must be of the same type. +When the increment is supplied, it is used as the difference between +each term. The default increment is 1 or -1 as appropriate. + + 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 '${' 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 ',' may be quoted with a backslash to prevent its being +considered part of a brace expression. To avoid conflicts with +parameter expansion, the string '${' 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: + mkdir /usr/local/src/bash/{old,new,dist,bugs} + or + chown root /usr/{ucb/{ex,edit},lib/{ex?.?*,how_ex}} + + +File: bash.info, Node: Tilde Expansion, Next: Shell Parameter Expansion, Prev: Brace Expansion, Up: Shell Expansions + +3.5.2 Tilde Expansion +--------------------- + +If a word begins with an unquoted tilde character ('~'), all of the +characters up to the first unquoted slash (or all characters, if there +is no unquoted slash) are considered a 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 LOGIN NAME. +If this login name is the null string, the tilde is replaced with the +value of the 'HOME' shell variable. If '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 '~+', the value of the shell variable 'PWD' +replaces the tilde-prefix. If the tilde-prefix is '~-', the value of +the shell variable 'OLDPWD', if it is set, is substituted. + + If the characters following the tilde in the tilde-prefix consist of +a number N, optionally prefixed by a '+' or a '-', the tilde-prefix is +replaced with the corresponding element from the directory stack, as it +would be displayed by the 'dirs' builtin invoked with the characters +following tilde in the tilde-prefix as an argument (*note The Directory +Stack::). If the tilde-prefix, sans the tilde, consists of a number +without a leading '+' or '-', '+' 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 ':' or the first '='. In these cases, tilde +expansion is also performed. Consequently, one may use filenames with +tildes in assignments to 'PATH', 'MAILPATH', and 'CDPATH', and the shell +assigns the expanded value. + + The following table shows how Bash treats unquoted tilde-prefixes: + +'~' + The value of '$HOME' +'~/foo' + '$HOME/foo' + +'~fred/foo' + The subdirectory 'foo' of the home directory of the user 'fred' + +'~+/foo' + '$PWD/foo' + +'~-/foo' + '${OLDPWD-'~-'}/foo' + +'~N' + The string that would be displayed by 'dirs +N' + +'~+N' + The string that would be displayed by 'dirs +N' + +'~-N' + The string that would be displayed by 'dirs -N' + + +File: bash.info, Node: Shell Parameter Expansion, Next: Command Substitution, Prev: Tilde Expansion, Up: Shell Expansions + +3.5.3 Shell Parameter Expansion +------------------------------- + +The '$' 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 '}' 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 ${PARAMETER}. The value of +PARAMETER is substituted. The PARAMETER is a shell parameter as +described above (*note Shell Parameters::) or an array reference (*note +Arrays::). The braces are required when PARAMETER is a positional +parameter with more than one digit, or when PARAMETER is followed by a +character that is not to be interpreted as part of its name. + + If the first character of PARAMETER is an exclamation point (!), and +PARAMETER is not a NAMEREF, it introduces a level of variable +indirection. Bash uses the value of the variable formed from the rest +of PARAMETER as the name of the variable; this variable is then expanded +and that value is used in the rest of the substitution, rather than the +value of PARAMETER itself. This is known as 'indirect expansion'. If +PARAMETER is a nameref, this expands to the name of the variable +referenced by PARAMETER instead of performing the complete indirect +expansion. The exceptions to this are the expansions of ${!PREFIX*} and +${!NAME[@]} described below. The exclamation point must immediately +follow the left brace in order to introduce indirection. + + In each of the cases below, WORD is subject to tilde expansion, +parameter expansion, command substitution, and arithmetic expansion. + + When not performing substring expansion, using the form described +below (e.g., ':-'), 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 +PARAMETER's existence and that its value is not null; if the colon is +omitted, the operator tests only for existence. + +'${PARAMETER:-WORD}' + If PARAMETER is unset or null, the expansion of WORD is + substituted. Otherwise, the value of PARAMETER is substituted. + +'${PARAMETER:=WORD}' + If PARAMETER is unset or null, the expansion of WORD is assigned to + PARAMETER. The value of PARAMETER is then substituted. Positional + parameters and special parameters may not be assigned to in this + way. + +'${PARAMETER:?WORD}' + If PARAMETER is null or unset, the expansion of WORD (or a message + to that effect if WORD is not present) is written to the standard + error and the shell, if it is not interactive, exits. Otherwise, + the value of PARAMETER is substituted. + +'${PARAMETER:+WORD}' + If PARAMETER is null or unset, nothing is substituted, otherwise + the expansion of WORD is substituted. + +'${PARAMETER:OFFSET}' +'${PARAMETER:OFFSET:LENGTH}' + This is referred to as Substring Expansion. It expands to up to + LENGTH characters of the value of PARAMETER starting at the + character specified by OFFSET. If PARAMETER is '@', an indexed + array subscripted by '@' or '*', or an associative array name, the + results differ as described below. If LENGTH is omitted, it + expands to the substring of the value of PARAMETER starting at the + character specified by OFFSET and extending to the end of the + value. LENGTH and OFFSET are arithmetic expressions (*note Shell + Arithmetic::). + + If OFFSET evaluates to a number less than zero, the value is used + as an offset in characters from the end of the value of PARAMETER. + If LENGTH evaluates to a number less than zero, it is interpreted + as an offset in characters from the end of the value of PARAMETER + rather than a number of characters, and the expansion is the + characters between OFFSET and that result. Note that a negative + offset must be separated from the colon by at least one space to + avoid being confused with the ':-' expansion. + + Here are some examples illustrating substring expansion on + parameters and subscripted arrays: + + $ string=01234567890abcdefgh + $ echo ${string:7} + 7890abcdefgh + $ echo ${string:7:0} + + $ echo ${string:7:2} + 78 + $ echo ${string:7:-2} + 7890abcdef + $ echo ${string: -7} + bcdefgh + $ echo ${string: -7:0} + + $ echo ${string: -7:2} + bc + $ echo ${string: -7:-2} + bcdef + $ set -- 01234567890abcdefgh + $ echo ${1:7} + 7890abcdefgh + $ echo ${1:7:0} + + $ echo ${1:7:2} + 78 + $ echo ${1:7:-2} + 7890abcdef + $ echo ${1: -7} + bcdefgh + $ echo ${1: -7:0} + + $ echo ${1: -7:2} + bc + $ echo ${1: -7:-2} + bcdef + $ array[0]=01234567890abcdefgh + $ echo ${array[0]:7} + 7890abcdefgh + $ echo ${array[0]:7:0} + + $ echo ${array[0]:7:2} + 78 + $ echo ${array[0]:7:-2} + 7890abcdef + $ echo ${array[0]: -7} + bcdefgh + $ echo ${array[0]: -7:0} + + $ echo ${array[0]: -7:2} + bc + $ echo ${array[0]: -7:-2} + bcdef + + If PARAMETER is '@', the result is LENGTH positional parameters + beginning at OFFSET. A negative OFFSET is taken relative to one + greater than the greatest positional parameter, so an offset of -1 + evaluates to the last positional parameter. It is an expansion + error if LENGTH evaluates to a number less than zero. + + The following examples illustrate substring expansion using + positional parameters: + + $ set -- 1 2 3 4 5 6 7 8 9 0 a b c d e f g h + $ echo ${@:7} + 7 8 9 0 a b c d e f g h + $ echo ${@:7:0} + + $ echo ${@:7:2} + 7 8 + $ echo ${@:7:-2} + bash: -2: substring expression < 0 + $ echo ${@: -7:2} + b c + $ echo ${@:0} + ./bash 1 2 3 4 5 6 7 8 9 0 a b c d e f g h + $ echo ${@:0:2} + ./bash 1 + $ echo ${@: -7:0} + + + If PARAMETER is an indexed array name subscripted by '@' or '*', + the result is the LENGTH members of the array beginning with + '${PARAMETER[OFFSET]}'. A negative OFFSET is taken relative to one + greater than the maximum index of the specified array. It is an + expansion error if LENGTH evaluates to a number less than zero. + + These examples show how you can use substring expansion with + indexed arrays: + + $ array=(0 1 2 3 4 5 6 7 8 9 0 a b c d e f g h) + $ echo ${array[@]:7} + 7 8 9 0 a b c d e f g h + $ echo ${array[@]:7:2} + 7 8 + $ echo ${array[@]: -7:2} + b c + $ echo ${array[@]: -7:-2} + bash: -2: substring expression < 0 + $ echo ${array[@]:0} + 0 1 2 3 4 5 6 7 8 9 0 a b c d e f g h + $ echo ${array[@]:0:2} + 0 1 + $ echo ${array[@]: -7:0} + + + Substring expansion applied to an associative array produces + undefined results. + + Substring indexing is zero-based unless the positional parameters + are used, in which case the indexing starts at 1 by default. If + OFFSET is 0, and the positional parameters are used, '$@' is + prefixed to the list. + +'${!PREFIX*}' +'${!PREFIX@}' + Expands to the names of variables whose names begin with PREFIX, + separated by the first character of the 'IFS' special variable. + When '@' is used and the expansion appears within double quotes, + each variable name expands to a separate word. + +'${!NAME[@]}' +'${!NAME[*]}' + If NAME is an array variable, expands to the list of array indices + (keys) assigned in NAME. If NAME is not an array, expands to 0 if + NAME is set and null otherwise. When '@' is used and the expansion + appears within double quotes, each key expands to a separate word. + +'${#PARAMETER}' + The length in characters of the expanded value of PARAMETER is + substituted. If PARAMETER is '*' or '@', the value substituted is + the number of positional parameters. If PARAMETER is an array name + subscripted by '*' or '@', the value substituted is the number of + elements in the array. If PARAMETER is an indexed array name + subscripted by a negative number, that number is interpreted as + relative to one greater than the maximum index of PARAMETER, so + negative indices count back from the end of the array, and an index + of -1 references the last element. + +'${PARAMETER#WORD}' +'${PARAMETER##WORD}' + The WORD is expanded to produce a pattern just as in filename + expansion (*note Filename Expansion::). If the pattern matches the + beginning of the expanded value of PARAMETER, then the result of + the expansion is the expanded value of PARAMETER with the shortest + matching pattern (the '#' case) or the longest matching pattern + (the '##' case) deleted. If PARAMETER is '@' or '*', the pattern + removal operation is applied to each positional parameter in turn, + and the expansion is the resultant list. If PARAMETER is an array + variable subscripted with '@' or '*', the pattern removal operation + is applied to each member of the array in turn, and the expansion + is the resultant list. + +'${PARAMETER%WORD}' +'${PARAMETER%%WORD}' + The WORD is expanded to produce a pattern just as in filename + expansion. If the pattern matches a trailing portion of the + expanded value of PARAMETER, then the result of the expansion is + the value of PARAMETER with the shortest matching pattern (the '%' + case) or the longest matching pattern (the '%%' case) deleted. If + PARAMETER is '@' or '*', the pattern removal operation is applied + to each positional parameter in turn, and the expansion is the + resultant list. If PARAMETER is an array variable subscripted with + '@' or '*', the pattern removal operation is applied to each member + of the array in turn, and the expansion is the resultant list. + +'${PARAMETER/PATTERN/STRING}' + + The PATTERN is expanded to produce a pattern just as in filename + expansion. PARAMETER is expanded and the longest match of PATTERN + against its value is replaced with STRING. If PATTERN begins with + '/', all matches of PATTERN are replaced with STRING. Normally + only the first match is replaced. If PATTERN begins with '#', it + must match at the beginning of the expanded value of PARAMETER. If + PATTERN begins with '%', it must match at the end of the expanded + value of PARAMETER. If STRING is null, matches of PATTERN are + deleted and the '/' following PATTERN may be omitted. If the + 'nocasematch' shell option (see the description of 'shopt' in *note + The Shopt Builtin::) is enabled, the match is performed without + regard to the case of alphabetic characters. If PARAMETER is '@' + or '*', the substitution operation is applied to each positional + parameter in turn, and the expansion is the resultant list. If + PARAMETER is an array variable subscripted with '@' or '*', the + substitution operation is applied to each member of the array in + turn, and the expansion is the resultant list. + +'${PARAMETER^PATTERN}' +'${PARAMETER^^PATTERN}' +'${PARAMETER,PATTERN}' +'${PARAMETER,,PATTERN}' + This expansion modifies the case of alphabetic characters in + PARAMETER. The PATTERN is expanded to produce a pattern just as in + filename expansion. Each character in the expanded value of + PARAMETER is tested against PATTERN, and, if it matches the + pattern, its case is converted. The pattern should not attempt to + match more than one character. The '^' operator converts lowercase + letters matching PATTERN to uppercase; the ',' operator converts + matching uppercase letters to lowercase. The '^^' and ',,' + expansions convert each matched character in the expanded value; + the '^' and ',' expansions match and convert only the first + character in the expanded value. If PATTERN is omitted, it is + treated like a '?', which matches every character. If PARAMETER is + '@' or '*', the case modification operation is applied to each + positional parameter in turn, and the expansion is the resultant + list. If PARAMETER is an array variable subscripted with '@' or + '*', the case modification operation is applied to each member of + the array in turn, and the expansion is the resultant list. + +'${PARAMETER@OPERATOR}' + The expansion is either a transformation of the value of PARAMETER + or information about PARAMETER itself, depending on the value of + OPERATOR. Each OPERATOR is a single letter: + + 'Q' + The expansion is a string that is the value of PARAMETER + quoted in a format that can be reused as input. + 'E' + The expansion is a string that is the value of PARAMETER with + backslash escape sequences expanded as with the '$'...'' + quoting mechansim. + 'P' + The expansion is a string that is the result of expanding the + value of PARAMETER as if it were a prompt string (*note + Controlling the Prompt::). + 'A' + The expansion is a string in the form of an assignment + statement or 'declare' command that, if evaluated, will + recreate PARAMETER with its attributes and value. + 'a' + The expansion is a string consisting of flag values + representing PARAMETER's attributes. + + If PARAMETER is '@' or '*', the operation is applied to each + positional parameter in turn, and the expansion is the resultant + list. If PARAMETER is an array variable subscripted with '@' or + '*', the operation is applied to each member of the array in turn, + and the expansion is the resultant list. + + The result of the expansion is subject to word splitting and + pathname expansion as described below. + + +File: bash.info, Node: Command Substitution, Next: Arithmetic Expansion, Prev: Shell Parameter Expansion, Up: Shell Expansions + +3.5.4 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: + $(COMMAND) +or + `COMMAND` + +Bash performs the expansion by executing COMMAND in a subshell +environment 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 '$(cat FILE)' can be replaced by the equivalent +but faster '$(< FILE)'. + + When the old-style backquote form of substitution is used, backslash +retains its literal meaning except when followed by '$', '`', or '\'. +The first backquote not preceded by a backslash terminates the command +substitution. When using the '$(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. + + +File: bash.info, Node: Arithmetic Expansion, Next: Process Substitution, Prev: Command Substitution, Up: Shell Expansions + +3.5.5 Arithmetic Expansion +-------------------------- + +Arithmetic expansion allows the evaluation of an arithmetic expression +and the substitution of the result. The format for arithmetic expansion +is: + + $(( EXPRESSION )) + + 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 and variable expansion, +command substitution, and quote removal. The result is treated as the +arithmetic expression to be evaluated. Arithmetic expansions may be +nested. + + The evaluation is performed according to the rules listed below +(*note Shell Arithmetic::). If the expression is invalid, Bash prints a +message indicating failure to the standard error and no substitution +occurs. + + +File: bash.info, Node: Process Substitution, Next: Word Splitting, Prev: Arithmetic Expansion, Up: Shell Expansions + +3.5.6 Process Substitution +-------------------------- + +Process substitution allows a process's input or output to be referred +to using a filename. It takes the form of + <(LIST) +or + >(LIST) +The process LIST is run asynchronously, and its input or output appears +as a filename. This filename is passed as an argument to the current +command as the result of the expansion. If the '>(LIST)' form is used, +writing to the file will provide input for LIST. If the '<(LIST)' form +is used, the file passed as an argument should be read to obtain the +output of LIST. Note that no space may appear between the '<' or '>' +and the left parenthesis, otherwise the construct would be interpreted +as a redirection. Process substitution is supported on systems that +support named pipes (FIFOs) or the '/dev/fd' method of naming open +files. + + When available, process substitution is performed simultaneously with +parameter and variable expansion, command substitution, and arithmetic +expansion. + + +File: bash.info, Node: Word Splitting, Next: Filename Expansion, Prev: Process Substitution, Up: Shell Expansions + +3.5.7 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 '$IFS' as a delimiter, and splits +the results of the other expansions into words using these characters as +field terminators. If 'IFS' is unset, or its value is exactly +'', the default, then sequences of ' ', +'', and '' at the beginning and end of the results of the +previous expansions are ignored, and any sequence of 'IFS' characters +not at the beginning or end serves to delimit words. If 'IFS' has a +value other than the default, then sequences of the whitespace +characters 'space', 'tab', and 'newline' are ignored at the beginning +and end of the word, as long as the whitespace character is in the value +of 'IFS' (an 'IFS' whitespace character). Any character in 'IFS' that +is not 'IFS' whitespace, along with any adjacent 'IFS' whitespace +characters, delimits a field. A sequence of 'IFS' whitespace characters +is also treated as a delimiter. If the value of 'IFS' is null, no word +splitting occurs. + + Explicit null arguments ('""' or '''') are retained and passed to +commands as empty strings. 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 and passed to a command as an empty +string. When a quoted null argument appears as part of a word whose +expansion is non-null, the null argument is removed. That is, the word +'-d''' becomes '-d' after word splitting and null argument removal. + + Note that if no expansion occurs, no splitting is performed. + + +File: bash.info, Node: Filename Expansion, Next: Quote Removal, Prev: Word Splitting, Up: Shell Expansions + +3.5.8 Filename Expansion +------------------------ + +* Menu: + +* Pattern Matching:: How the shell matches patterns. + +After word splitting, unless the '-f' option has been set (*note The Set +Builtin::), Bash scans each word for the characters '*', '?', and '['. +If one of these characters appears, then the word is regarded as a +PATTERN, and replaced with an alphabetically sorted list of filenames +matching the pattern (*note Pattern Matching::). If no matching +filenames are found, and the shell option 'nullglob' is disabled, the +word is left unchanged. If the 'nullglob' option is set, and no matches +are found, the word is removed. If the '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 'nocaseglob' is enabled, the match is +performed without regard to the case of alphabetic characters. + + When a pattern is used for filename expansion, the character '.' at +the start of a filename or immediately following a slash must be matched +explicitly, unless the shell option 'dotglob' is set. When matching a +filename, the slash character must always be matched explicitly. In +other cases, the '.' character is not treated specially. + + See the description of 'shopt' in *note The Shopt Builtin::, for a +description of the 'nocaseglob', 'nullglob', 'failglob', and 'dotglob' +options. + + The 'GLOBIGNORE' shell variable may be used to restrict the set of +filenames matching a pattern. If 'GLOBIGNORE' is set, each matching +filename that also matches one of the patterns in 'GLOBIGNORE' is +removed from the list of matches. If the 'nocaseglob' option is set, +the matching against the patterns in 'GLOBIGNORE' is performed without +regard to case. The filenames '.' and '..' are always ignored when +'GLOBIGNORE' is set and not null. However, setting 'GLOBIGNORE' to a +non-null value has the effect of enabling the 'dotglob' shell option, so +all other filenames beginning with a '.' will match. To get the old +behavior of ignoring filenames beginning with a '.', make '.*' one of +the patterns in 'GLOBIGNORE'. The 'dotglob' option is disabled when +'GLOBIGNORE' is unset. + + +File: bash.info, Node: Pattern Matching, Up: Filename Expansion + +3.5.8.1 Pattern Matching +........................ + +Any character that appears in a pattern, other than the special pattern +characters described below, matches itself. The 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: +'*' + Matches any string, including the null string. When the 'globstar' + shell option is enabled, and '*' is used in a filename expansion + context, two adjacent '*'s used as a single pattern will match all + files and zero or more directories and subdirectories. If followed + by a '/', two adjacent '*'s will match only directories and + subdirectories. +'?' + Matches any single character. +'[...]' + Matches any one of the enclosed characters. A pair of characters + separated by a hyphen denotes a RANGE EXPRESSION; any character + that falls between those two characters, inclusive, using the + current locale's collating sequence and character set, is matched. + If the first character following the '[' is a '!' or a '^' then any + character not enclosed is matched. A '-' may be matched by + including it as the first or last character in the set. A ']' 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 values of the 'LC_COLLATE' and 'LC_ALL' + shell variables, if set. + + For example, in the default C locale, '[a-dx-z]' is equivalent to + '[abcdxyz]'. Many locales sort characters in dictionary order, and + in these locales '[a-dx-z]' is typically not equivalent to + '[abcdxyz]'; it might be equivalent to '[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 'LC_COLLATE' or 'LC_ALL' environment variable to the + value 'C', or enable the 'globasciiranges' shell option. + + Within '[' and ']', CHARACTER CLASSES can be specified using the + syntax '[:'CLASS':]', where CLASS is one of the following classes + defined in the POSIX standard: + alnum alpha ascii blank cntrl digit graph lower + print punct space upper word xdigit + A character class matches any character belonging to that class. + The 'word' character class matches letters, digits, and the + character '_'. + + Within '[' and ']', an EQUIVALENCE CLASS can be specified using the + syntax '[='C'=]', which matches all characters with the same + collation weight (as defined by the current locale) as the + character C. + + Within '[' and ']', the syntax '[.'SYMBOL'.]' matches the collating + symbol SYMBOL. + + If the 'extglob' shell option is enabled using the 'shopt' builtin, +several extended pattern matching operators are recognized. In the +following description, a PATTERN-LIST is a list of one or more patterns +separated by a '|'. Composite patterns may be formed using one or more +of the following sub-patterns: + +'?(PATTERN-LIST)' + Matches zero or one occurrence of the given patterns. + +'*(PATTERN-LIST)' + Matches zero or more occurrences of the given patterns. + +'+(PATTERN-LIST)' + Matches one or more occurrences of the given patterns. + +'@(PATTERN-LIST)' + Matches one of the given patterns. + +'!(PATTERN-LIST)' + Matches anything except one of the given patterns. + + +File: bash.info, Node: Quote Removal, Prev: Filename Expansion, Up: Shell Expansions + +3.5.9 Quote Removal +------------------- + +After the preceding expansions, all unquoted occurrences of the +characters '\', ''', and '"' that did not result from one of the above +expansions are removed. + + +File: bash.info, Node: Redirections, Next: Executing Commands, Prev: Shell Expansions, Up: Basic Shell Features + +3.6 Redirections +================ + +Before a command is executed, its input and output may be REDIRECTED +using a special notation interpreted by the shell. Redirection allows +commands' file handles to be duplicated, opened, closed, made to refer +to different files, and can change the files the command reads from and +writes to. Redirection may also be used to modify file handles in 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. + + Each redirection that may be preceded by a file descriptor number may +instead be preceded by a word of the form {VARNAME}. In this case, for +each redirection operator except >&- and <&-, the shell will allocate a +file descriptor greater than 10 and assign it to {VARNAME}. If >&- or +<&- is preceded by {VARNAME}, the value of VARNAME defines the file +descriptor to close. + + In the following descriptions, if the file descriptor number is +omitted, and the first character of the redirection operator is '<', the +redirection refers to the standard input (file descriptor 0). If the +first character of the redirection operator is '>', 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 + ls > DIRLIST 2>&1 +directs both standard output (file descriptor 1) and standard error +(file descriptor 2) to the file DIRLIST, while the command + ls 2>&1 > DIRLIST +directs only the standard output to file DIRLIST, because the standard +error was made a copy of the standard output before the standard output +was redirected to DIRLIST. + + Bash handles several filenames specially when they are used in +redirections, as described in the following table. If the operating +system on which Bash is running provides these special files, bash will +use them; otherwise it will emulate them internally with the behavior +described below. + +'/dev/fd/FD' + If FD is a valid integer, file descriptor FD is duplicated. + +'/dev/stdin' + File descriptor 0 is duplicated. + +'/dev/stdout' + File descriptor 1 is duplicated. + +'/dev/stderr' + File descriptor 2 is duplicated. + +'/dev/tcp/HOST/PORT' + If HOST is a valid hostname or Internet address, and PORT is an + integer port number or service name, Bash attempts to open the + corresponding TCP socket. + +'/dev/udp/HOST/PORT' + If HOST is a valid hostname or Internet address, and PORT is an + integer port number or service name, Bash attempts to open the + corresponding UDP 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. + +3.6.1 Redirecting Input +----------------------- + +Redirection of input causes the file whose name results from the +expansion of WORD to be opened for reading on file descriptor 'n', or +the standard input (file descriptor 0) if 'n' is not specified. + + The general format for redirecting input is: + [N][|]WORD + + If the redirection operator is '>', and the 'noclobber' option to the +'set' builtin has been enabled, the redirection will fail if the file +whose name results from the expansion of WORD exists and is a regular +file. If the redirection operator is '>|', or the redirection operator +is '>' and the 'noclobber' option is not enabled, the redirection is +attempted even if the file named by WORD exists. + +3.6.3 Appending Redirected Output +--------------------------------- + +Redirection of output in this fashion causes the file whose name results +from the expansion of WORD to be opened for appending on file descriptor +N, or the standard output (file descriptor 1) if N is not specified. If +the file does not exist it is created. + + The general format for appending output is: + [N]>>WORD + +3.6.4 Redirecting Standard Output and Standard Error +---------------------------------------------------- + +This construct 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 WORD. + + There are two formats for redirecting standard output and standard +error: + &>WORD +and + >&WORD +Of the two forms, the first is preferred. This is semantically +equivalent to + >WORD 2>&1 + When using the second form, WORD may not expand to a number or '-'. +If it does, other redirection operators apply (see Duplicating File +Descriptors below) for compatibility reasons. + +3.6.5 Appending Standard Output and Standard Error +-------------------------------------------------- + +This construct allows both the standard output (file descriptor 1) and +the standard error output (file descriptor 2) to be appended to the file +whose name is the expansion of WORD. + + The format for appending standard output and standard error is: + &>>WORD +This is semantically equivalent to + >>WORD 2>&1 + (see Duplicating File Descriptors below). + +3.6.6 Here Documents +-------------------- + +This type of redirection instructs the shell to read input from the +current source until a line containing only WORD (with no trailing +blanks) is seen. All of the lines read up to that point are then used +as the standard input (or file descriptor N if N is specified) for a +command. + + The format of here-documents is: + [N]<<[-]WORD + HERE-DOCUMENT + DELIMITER + + No parameter and variable expansion, command substitution, arithmetic +expansion, or filename expansion is performed on WORD. If any part of +WORD is quoted, the DELIMITER is the result of quote removal on WORD, +and the lines in the here-document are not expanded. If WORD is +unquoted, all lines of the here-document are subjected to parameter +expansion, command substitution, and arithmetic expansion, the character +sequence '\newline' is ignored, and '\' must be used to quote the +characters '\', '$', and '`'. + + If the redirection operator is '<<-', then all leading tab characters +are stripped from input lines and the line containing DELIMITER. This +allows here-documents within shell scripts to be indented in a natural +fashion. + +3.6.7 Here Strings +------------------ + +A variant of here documents, the format is: + [N]<<< WORD + + The WORD undergoes brace expansion, tilde expansion, parameter and +variable expansion, command substitution, arithmetic expansion, and +quote removal. Pathname expansion and word splitting are not performed. +The result is supplied as a single string, with a newline appended, to +the command on its standard input (or file descriptor N if N is +specified). + +3.6.8 Duplicating File Descriptors +---------------------------------- + +The redirection operator + [N]<&WORD +is used to duplicate input file descriptors. If WORD expands to one or +more digits, the file descriptor denoted by N is made to be a copy of +that file descriptor. If the digits in WORD do not specify a file +descriptor open for input, a redirection error occurs. If WORD +evaluates to '-', file descriptor N is closed. If N is not specified, +the standard input (file descriptor 0) is used. + + The operator + [N]>&WORD +is used similarly to duplicate output file descriptors. If N is not +specified, the standard output (file descriptor 1) is used. If the +digits in WORD do not specify a file descriptor open for output, a +redirection error occurs. If WORD evaluates to '-', file descriptor N +is closed. As a special case, if N is omitted, and WORD does not expand +to one or more digits or '-', the standard output and standard error are +redirected as described previously. + +3.6.9 Moving File Descriptors +----------------------------- + +The redirection operator + [N]<&DIGIT- +moves the file descriptor DIGIT to file descriptor N, or the standard +input (file descriptor 0) if N is not specified. DIGIT is closed after +being duplicated to N. + + Similarly, the redirection operator + [N]>&DIGIT- +moves the file descriptor DIGIT to file descriptor N, or the standard +output (file descriptor 1) if N is not specified. + +3.6.10 Opening File Descriptors for Reading and Writing +------------------------------------------------------- + +The redirection operator + [N]<>WORD +causes the file whose name is the expansion of WORD to be opened for +both reading and writing on file descriptor N, or on file descriptor 0 +if N is not specified. If the file does not exist, it is created. + + +File: bash.info, Node: Executing Commands, Next: Shell Scripts, Prev: Redirections, Up: Basic Shell Features + +3.7 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. + + +File: bash.info, Node: Simple Command Expansion, Next: Command Search and Execution, Up: Executing Commands + +3.7.1 Simple Command Expansion +------------------------------ + +When a simple command is executed, the shell performs the following +expansions, assignments, and redirections, from left to right. + + 1. The words that the parser has marked as variable assignments (those + preceding the command name) and redirections are saved for later + processing. + + 2. The words that are not variable assignments or redirections are + expanded (*note 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. + + 3. Redirections are performed as described above (*note + Redirections::). + + 4. The text after the '=' in each variable assignment undergoes tilde + expansion, parameter expansion, command substitution, arithmetic + expansion, and quote removal before being assigned to the variable. + + 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. + + +File: bash.info, Node: Command Search and Execution, Next: Command Execution Environment, Prev: Simple Command Expansion, Up: Executing Commands + +3.7.2 Command Search and Execution +---------------------------------- + +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. + + 1. 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 *note Shell Functions::. + + 2. 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. + + 3. If the name is neither a shell function nor a builtin, and contains + no slashes, Bash searches each element of '$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 'PATH' searches (see the description of 'hash' in *note + Bourne Shell Builtins::). A full search of the directories in + '$PATH' is performed only if the command is not found in the hash + table. If the search is unsuccessful, the shell searches for a + defined shell function named 'command_not_found_handle'. If that + function exists, it is invoked with the original command and the + original command's arguments as its arguments, and the function's + exit status becomes the exit status of the shell. If that function + is not defined, the shell prints an error message and returns an + exit status of 127. + + 4. 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. + + 5. 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 + SHELL SCRIPT and the shell executes it as described in *note Shell + Scripts::. + + 6. If the command was not begun asynchronously, the shell waits for + the command to complete and collects its exit status. + + +File: bash.info, Node: Command Execution Environment, Next: Environment, Prev: Command Search and Execution, Up: Executing Commands + +3.7.3 Command Execution Environment +----------------------------------- + +The shell has an EXECUTION ENVIRONMENT, which consists of the following: + + * open files inherited by the shell at invocation, as modified by + redirections supplied to the 'exec' builtin + + * the current working directory as set by 'cd', 'pushd', or 'popd', + or inherited by the shell at invocation + + * the file creation mode mask as set by 'umask' or inherited from the + shell's parent + + * current traps set by 'trap' + + * shell parameters that are set by variable assignment or with 'set' + or inherited from the shell's parent in the environment + + * shell functions defined during execution or inherited from the + shell's parent in the environment + + * options enabled at invocation (either by default or with + command-line arguments) or by 'set' + + * options enabled by 'shopt' (*note The Shopt Builtin::) + + * shell aliases defined with 'alias' (*note Aliases::) + + * various process IDs, including those of background jobs (*note + Lists::), the value of '$$', and the value of '$PPID' + + 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. + + * the shell's open files, plus any modifications and additions + specified by redirections to the command + + * the current working directory + + * the file creation mode mask + + * shell variables and functions marked for export, along with + variables exported for the command, passed in the environment + (*note Environment::) + + * traps caught by the shell are reset to the values inherited from + the 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, 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. + + Subshells spawned to execute command substitutions inherit the value +of the '-e' option from the parent shell. When not in POSIX mode, Bash +clears the '-e' option in such subshells. + + If a command is followed by a '&' and job control is not active, the +default standard input for the command is the empty file '/dev/null'. +Otherwise, the invoked command inherits the file descriptors of the +calling shell as modified by redirections. + + +File: bash.info, Node: Environment, Next: Exit Status, Prev: Command Execution Environment, Up: Executing Commands + +3.7.4 Environment +----------------- + +When a program is invoked it is given an array of strings called the +ENVIRONMENT. This is a list of name-value pairs, of the form +'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 EXPORT to child +processes. Executed commands inherit the environment. The 'export' and +'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 'unset' and 'export +-n' commands, plus any additions via the 'export' and 'declare -x' +commands. + + The environment for any simple command or function may be augmented +temporarily by prefixing it with parameter assignments, as described in +*note Shell Parameters::. These assignment statements affect only the +environment seen by that command. + + If the '-k' option is set (*note 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 '$_' is set to +the full pathname of the command and passed to that command in its +environment. + + +File: bash.info, Node: Exit Status, Next: Signals, Prev: Environment, Up: Executing Commands + +3.7.5 Exit Status +----------------- + +The exit status of an executed command is the value returned by the +WAITPID system call or equivalent function. Exit statuses fall between +0 and 255, though, as explained below, the shell may use values above +125 specially. Exit statuses from shell builtins and compound commands +are also limited to this range. Under certain circumstances, the shell +will use special values to indicate specific failure modes. + + 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 N, Bash uses the value 128+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 (*note +Conditional Constructs::) and some of the list constructs (*note +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, generally invalid options or missing +arguments. + + +File: bash.info, Node: Signals, Prev: Exit Status, Up: Executing Commands + +3.7.6 Signals +------------- + +When Bash is interactive, in the absence of any traps, it ignores +'SIGTERM' (so that 'kill 0' does not kill an interactive shell), and +'SIGINT' is caught and handled (so that the 'wait' builtin is +interruptible). When Bash receives a 'SIGINT', it breaks out of any +executing loops. In all cases, Bash ignores 'SIGQUIT'. If job control +is in effect (*note Job Control::), Bash ignores 'SIGTTIN', 'SIGTTOU', +and '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 'SIGINT' and 'SIGQUIT' in +addition to these inherited handlers. Commands run as a result of +command substitution ignore the keyboard-generated job control signals +'SIGTTIN', 'SIGTTOU', and 'SIGTSTP'. + + The shell exits by default upon receipt of a 'SIGHUP'. Before +exiting, an interactive shell resends the 'SIGHUP' to all jobs, running +or stopped. Stopped jobs are sent 'SIGCONT' to ensure that they receive +the 'SIGHUP'. To prevent the shell from sending the 'SIGHUP' signal to +a particular job, it should be removed from the jobs table with the +'disown' builtin (*note Job Control Builtins::) or marked to not receive +'SIGHUP' using 'disown -h'. + + If the 'huponexit' shell option has been set with 'shopt' (*note The +Shopt Builtin::), Bash sends a '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 'wait' builtin, the reception of a signal for which a trap has been +set will cause the 'wait' builtin to return immediately with an exit +status greater than 128, immediately after which the trap is executed. + + +File: bash.info, Node: Shell Scripts, Prev: Executing Commands, Up: Basic Shell Features + +3.8 Shell Scripts +================= + +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 '-c' nor '-s' option is supplied (*note 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 +'$PATH' if not found there. + + When Bash runs a shell script, it sets the special parameter '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 'chmod' command to +turn on the execute bit. When Bash finds such a file while searching +the '$PATH' for a command, it spawns a subshell to execute it. In other +words, executing + filename ARGUMENTS +is equivalent to executing + bash filename ARGUMENTS + +if '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 'hash' in +*note 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 '#!', the remainder of the line specifies an +interpreter for the program. Thus, you can specify Bash, '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 '#! /bin/bash' (assuming that Bash has +been installed in '/bin'), since this ensures that Bash will be used to +interpret the script, even if it is executed under another shell. + + +File: bash.info, Node: Shell Builtin Commands, Next: Shell Variables, Prev: Basic Shell Features, Up: Top + +4 Shell Builtin Commands +************************ + +* Menu: + +* Bourne Shell Builtins:: Builtin commands inherited from the Bourne + Shell. +* Bash Builtins:: Table of builtins specific to Bash. +* Modifying Shell Behavior:: Builtins to modify shell attributes and + optional behavior. +* Special Builtins:: Builtin commands classified specially by + POSIX. + +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 +(*note 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 +(*note Job Control Builtins::), the directory stack (*note Directory +Stack Builtins::), the command history (*note Bash History Builtins::), +and the programmable completion facilities (*note Programmable +Completion Builtins::). + + Many of the builtins have been extended by POSIX or Bash. + + Unless otherwise noted, each builtin command documented as accepting +options preceded by '-' accepts '--' to signify the end of the options. +The ':', 'true', 'false', and 'test' builtins do not accept options and +do not treat '--' specially. The 'exit', 'logout', 'return', 'break', +'continue', 'let', and 'shift' builtins accept and process arguments +beginning with '-' without requiring '--'. Other builtins that accept +arguments but are not specified as accepting options interpret arguments +beginning with '-' as invalid options and require '--' to prevent this +interpretation. + + +File: bash.info, Node: Bourne Shell Builtins, Next: Bash Builtins, Up: Shell Builtin Commands + +4.1 Bourne Shell Builtins +========================= + +The following shell builtin commands are inherited from the Bourne +Shell. These commands are implemented as specified by the POSIX +standard. + +': (a colon)' + : [ARGUMENTS] + + Do nothing beyond expanding ARGUMENTS and performing redirections. + The return status is zero. + +'. (a period)' + . FILENAME [ARGUMENTS] + + Read and execute commands from the FILENAME argument in the current + shell context. If FILENAME does not contain a slash, the 'PATH' + variable is used to find FILENAME. When Bash is not in POSIX mode, + the current directory is searched if FILENAME is not found in + '$PATH'. If any ARGUMENTS are supplied, they become the positional + parameters when FILENAME is executed. Otherwise the positional + parameters are unchanged. If the '-T' option is enabled, 'source' + inherits any trap on 'DEBUG'; if it is not, any 'DEBUG' trap string + is saved and restored around the call to 'source', and 'source' + unsets the 'DEBUG' trap while it executes. If '-T' is not set, and + the sourced file changes the 'DEBUG' trap, the new value is + retained when 'source' completes. The return status is the exit + status of the last command executed, or zero if no commands are + executed. If FILENAME is not found, or cannot be read, the return + status is non-zero. This builtin is equivalent to 'source'. + +'break' + break [N] + + Exit from a 'for', 'while', 'until', or 'select' loop. If N is + supplied, the Nth enclosing loop is exited. N must be greater than + or equal to 1. The return status is zero unless N is not greater + than or equal to 1. + +'cd' + cd [-L|[-P [-e]] [-@] [DIRECTORY] + + Change the current working directory to DIRECTORY. If DIRECTORY is + not supplied, the value of the 'HOME' shell variable is used. Any + additional arguments following DIRECTORY are ignored. If the shell + variable 'CDPATH' exists, it is used as a search path: each + directory name in 'CDPATH' is searched for DIRECTORY, with + alternative directory names in 'CDPATH' separated by a colon (':'). + If DIRECTORY begins with a slash, 'CDPATH' is not used. + + The '-P' option means to not follow symbolic links: symbolic links + are resolved while 'cd' is traversing DIRECTORY and before + processing an instance of '..' in DIRECTORY. + + By default, or when the '-L' option is supplied, symbolic links in + DIRECTORY are resolved after 'cd' processes an instance of '..' in + DIRECTORY. + + If '..' appears in DIRECTORY, it is processed by removing the + immediately preceding pathname component, back to a slash or the + beginning of DIRECTORY. + + If the '-e' option is supplied with '-P' and the current working + directory cannot be successfully determined after a successful + directory change, 'cd' will return an unsuccessful status. + + On systems that support it, the '-@' option presents the extended + attributes associated with a file as a directory. + + If DIRECTORY is '-', it is converted to '$OLDPWD' before the + directory change is attempted. + + If a non-empty directory name from 'CDPATH' is used, or if '-' 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. + +'continue' + continue [N] + + Resume the next iteration of an enclosing 'for', 'while', 'until', + or 'select' loop. If N is supplied, the execution of the Nth + enclosing loop is resumed. N must be greater than or equal to 1. + The return status is zero unless N is not greater than or equal to + 1. + +'eval' + eval [ARGUMENTS] + + 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 'eval'. If there are no arguments or only empty + arguments, the return status is zero. + +'exec' + exec [-cl] [-a NAME] [COMMAND [ARGUMENTS]] + + If COMMAND is supplied, it replaces the shell without creating a + new process. If the '-l' option is supplied, the shell places a + dash at the beginning of the zeroth argument passed to COMMAND. + This is what the 'login' program does. The '-c' option causes + COMMAND to be executed with an empty environment. If '-a' is + supplied, the shell passes NAME as the zeroth argument to COMMAND. + If COMMAND cannot be executed for some reason, a non-interactive + shell exits, unless the 'execfail' shell option is enabled. In + that case, it returns failure. An interactive shell returns + failure if the file cannot be executed. If no 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. + +'exit' + exit [N] + + Exit the shell, returning a status of N to the shell's parent. If + N is omitted, the exit status is that of the last command executed. + Any trap on 'EXIT' is executed before the shell terminates. + +'export' + export [-fn] [-p] [NAME[=VALUE]] + + Mark each NAME to be passed to child processes in the environment. + If the '-f' option is supplied, the NAMEs refer to shell functions; + otherwise the names refer to shell variables. The '-n' option + means to no longer mark each NAME for export. If no NAMES are + supplied, or if the '-p' option is given, a list of names of all + exported variables is displayed. The '-p' option displays output + in a form that may be reused as input. If a variable name is + followed by =VALUE, the value of the variable is set to VALUE. + + The return status is zero unless an invalid option is supplied, one + of the names is not a valid shell variable name, or '-f' is + supplied with a name that is not a shell function. + +'getopts' + getopts OPTSTRING NAME [ARGS] + + 'getopts' is used by shell scripts to parse positional parameters. + 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 whitespace. The + colon (':') and question mark ('?') may not be used as option + characters. Each time it is invoked, 'getopts' places the next + option in the shell variable NAME, initializing NAME if it does not + exist, and the index of the next argument to be processed into the + variable 'OPTIND'. 'OPTIND' is initialized to 1 each time the + shell or a shell script is invoked. When an option requires an + argument, 'getopts' places that argument into the variable + 'OPTARG'. The shell does not reset 'OPTIND' automatically; it must + be manually reset between multiple calls to 'getopts' within the + same shell invocation if a new set of parameters is to be used. + + When the end of options is encountered, 'getopts' exits with a + return value greater than zero. 'OPTIND' is set to the index of + the first non-option argument, and NAME is set to '?'. + + 'getopts' normally parses the positional parameters, but if more + arguments are given in ARGS, 'getopts' parses those instead. + + 'getopts' can report errors in two ways. If the first character of + OPTSTRING is a colon, SILENT error reporting is used. In normal + operation, diagnostic messages are printed when invalid options or + missing option arguments are encountered. If the variable 'OPTERR' + is set to 0, no error messages will be displayed, even if the first + character of 'optstring' is not a colon. + + If an invalid option is seen, 'getopts' places '?' into NAME and, + if not silent, prints an error message and unsets 'OPTARG'. If + 'getopts' is silent, the option character found is placed in + 'OPTARG' and no diagnostic message is printed. + + If a required argument is not found, and 'getopts' is not silent, a + question mark ('?') is placed in NAME, 'OPTARG' is unset, and a + diagnostic message is printed. If 'getopts' is silent, then a + colon (':') is placed in NAME and 'OPTARG' is set to the option + character found. + +'hash' + hash [-r] [-p FILENAME] [-dt] [NAME] + + Each time 'hash' is invoked, it remembers the full pathnames of the + commands specified as NAME arguments, so they need not be searched + for on subsequent invocations. The commands are found by searching + through the directories listed in '$PATH'. Any + previously-remembered pathname is discarded. The '-p' option + inhibits the path search, and FILENAME is used as the location of + NAME. The '-r' option causes the shell to forget all remembered + locations. The '-d' option causes the shell to forget the + remembered location of each NAME. If the '-t' option is supplied, + the full pathname to which each NAME corresponds is printed. If + multiple NAME arguments are supplied with '-t' the NAME is printed + before the hashed full pathname. The '-l' option causes output to + be displayed in a format that may be reused as input. If no + arguments are given, or if only '-l' is supplied, information about + remembered commands is printed. The return status is zero unless a + NAME is not found or an invalid option is supplied. + +'pwd' + pwd [-LP] + + Print the absolute pathname of the current working directory. If + the '-P' option is supplied, the pathname printed will not contain + symbolic links. If the '-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. + +'readonly' + readonly [-aAf] [-p] [NAME[=VALUE]] ... + + Mark each NAME as readonly. The values of these names may not be + changed by subsequent assignment. If the '-f' option is supplied, + each NAME refers to a shell function. The '-a' option means each + NAME refers to an indexed array variable; the '-A' option means + each NAME refers to an associative array variable. If both options + are supplied, '-A' takes precedence. If no NAME arguments are + given, or if the '-p' option is supplied, a list of all readonly + names is printed. The other options may be used to restrict the + output to a subset of the set of readonly names. The '-p' option + causes output to be displayed in a format that may be reused as + input. If a variable name is followed by =VALUE, the value of the + variable is set to VALUE. The return status is zero unless an + invalid option is supplied, one of the NAME arguments is not a + valid shell variable or function name, or the '-f' option is + supplied with a name that is not a shell function. + +'return' + return [N] + + Cause a shell function to stop executing and return the value N to + its caller. If N is not supplied, the return value is the exit + status of the last command executed in the function. If 'return' + is executed by a trap handler, the last command used to determine + the status is the last command executed before the trap handler. + if 'return' is executed during a 'DEBUG' trap, the last command + used to determine the status is the last command executed by the + trap handler before 'return' was invoked. 'return' may also be + used to terminate execution of a script being executed with the '.' + ('source') builtin, returning either N or the exit status of the + last command executed within the script as the exit status of the + script. If N is supplied, the return value is its least + significant 8 bits. Any command associated with the 'RETURN' trap + is executed before execution resumes after the function or script. + The return status is non-zero if 'return' is supplied a non-numeric + argument or is used outside a function and not during the execution + of a script by '.' or 'source'. + +'shift' + shift [N] + + Shift the positional parameters to the left by N. The positional + parameters from N+1 ... '$#' are renamed to '$1' ... '$#'-N. + Parameters represented by the numbers '$#' to '$#'-N+1 are unset. + N must be a non-negative number less than or equal to '$#'. If N + is zero or greater than '$#', the positional parameters are not + changed. If N is not supplied, it is assumed to be 1. The return + status is zero unless N is greater than '$#' or less than zero, + non-zero otherwise. + +'test' +'[' + test EXPR + + Evaluate a conditional expression EXPR and return a status of 0 + (true) or 1 (false). Each operator and operand must be a separate + argument. Expressions are composed of the primaries described + below in *note Bash Conditional Expressions::. 'test' does not + accept any options, nor does it accept and ignore an argument of + '--' as signifying the end of options. + + When the '[' form is used, the last argument to the command must be + a ']'. + + Expressions may be combined using the following operators, listed + in decreasing order of precedence. The evaluation depends on the + number of arguments; see below. Operator precedence is used when + there are five or more arguments. + + '! EXPR' + True if EXPR is false. + + '( EXPR )' + Returns the value of EXPR. This may be used to override the + normal precedence of operators. + + 'EXPR1 -a EXPR2' + True if both EXPR1 and EXPR2 are true. + + 'EXPR1 -o EXPR2' + True if either EXPR1 or EXPR2 is true. + + The 'test' and '[' builtins evaluate conditional expressions using + a set of rules based on the number of arguments. + + 0 arguments + The expression is false. + + 1 argument + The expression is true if and only if the argument is not + null. + + 2 arguments + If the first argument is '!', the expression is true if and + only if the second argument is null. If the first argument is + one of the unary conditional operators (*note 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. + + 3 arguments + The following conditions are applied in the order listed. If + the second argument is one of the binary conditional operators + (*note Bash Conditional Expressions::), the result of the + expression is the result of the binary test using the first + and third arguments as operands. The '-a' and '-o' operators + are considered binary operators when there are three + arguments. If the first argument is '!', the value is the + negation of the two-argument test using the second and third + arguments. If the first argument is exactly '(' and the third + argument is exactly ')', the result is the one-argument test + of the second argument. Otherwise, the expression is false. + + 4 arguments + If the first argument is '!', 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. + + 5 or more arguments + The expression is parsed and evaluated according to precedence + using the rules listed above. + + When used with 'test' or '[', the '<' and '>' operators sort + lexicographically using ASCII ordering. + +'times' + times + + Print out the user and system times used by the shell and its + children. The return status is zero. + +'trap' + trap [-lp] [ARG] [SIGSPEC ...] + + The commands in ARG are to be read and executed when the shell + receives signal SIGSPEC. If ARG is absent (and there is a single + SIGSPEC) or equal to '-', each specified signal's disposition is + reset to the value it had when the shell was started. If ARG is + the null string, then the signal specified by each SIGSPEC is + ignored by the shell and commands it invokes. If ARG is not + present and '-p' has been supplied, the shell displays the trap + commands associated with each SIGSPEC. If no arguments are + supplied, or only '-p' is given, 'trap' prints the list of commands + associated with each signal number in a form that may be reused as + shell input. The '-l' option causes the shell to print a list of + signal names and their corresponding numbers. Each SIGSPEC is + either a signal name or a signal number. Signal names are case + insensitive and the 'SIG' prefix is optional. + + If a SIGSPEC is '0' or 'EXIT', ARG is executed when the shell + exits. If a SIGSPEC is 'DEBUG', the command ARG is executed before + every simple command, 'for' command, 'case' command, 'select' + command, every arithmetic 'for' command, and before the first + command executes in a shell function. Refer to the description of + the 'extdebug' option to the 'shopt' builtin (*note The Shopt + Builtin::) for details of its effect on the 'DEBUG' trap. If a + SIGSPEC is 'RETURN', the command ARG is executed each time a shell + function or a script executed with the '.' or 'source' builtins + finishes executing. + + If a SIGSPEC is 'ERR', the command ARG is executed whenever a + pipeline (which may consist of a single simple command), a list, or + a compound command returns a non-zero exit status, subject to the + following conditions. The 'ERR' trap is not executed if the failed + command is part of the command list immediately following an + 'until' or 'while' keyword, part of the test following the 'if' or + 'elif' reserved words, part of a command executed in a '&&' or '||' + list except the command following the final '&&' or '||', any + command in a pipeline but the last, or if the command's return + status is being inverted using '!'. These are the same conditions + obeyed by the 'errexit' ('-e') option. + + 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 subshell or subshell environment when one is + created. + + The return status is zero unless a SIGSPEC does not specify a valid + signal. + +'umask' + umask [-p] [-S] [MODE] + + Set the shell process's file creation mask to MODE. If 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 + 'chmod' command. If MODE is omitted, the current value of the mask + is printed. If the '-S' option is supplied without a MODE + argument, the mask is printed in a symbolic format. If the '-p' + option is supplied, and 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 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 '7'. Thus, a umask of '022' + results in permissions of '755'. + +'unset' + unset [-fnv] [NAME] + + Remove each variable or function NAME. If the '-v' option is + given, each NAME refers to a shell variable and that variable is + removed. If the '-f' option is given, the NAMEs refer to shell + functions, and the function definition is removed. If the '-n' + option is supplied, and NAME is a variable with the NAMEREF + attribute, NAME will be unset rather than the variable it + references. '-n' has no effect if the '-f' option is supplied. If + no options are supplied, each NAME refers to a variable; if there + is no variable by that name, any function with that name is unset. + Readonly variables and functions may not be unset. The return + status is zero unless a NAME is readonly. + + +File: bash.info, Node: Bash Builtins, Next: Modifying Shell Behavior, Prev: Bourne Shell Builtins, Up: Shell Builtin Commands + +4.2 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 POSIX +standard. + +'alias' + alias [-p] [NAME[=VALUE] ...] + + Without arguments or with the '-p' option, '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 NAME whose VALUE is given. If no VALUE is given, the name + and value of the alias is printed. Aliases are described in *note + Aliases::. + +'bind' + bind [-m KEYMAP] [-lpsvPSVX] + bind [-m KEYMAP] [-q FUNCTION] [-u FUNCTION] [-r KEYSEQ] + bind [-m KEYMAP] -f FILENAME + bind [-m KEYMAP] -x KEYSEQ:SHELL-COMMAND + bind [-m KEYMAP] KEYSEQ:FUNCTION-NAME + bind [-m KEYMAP] KEYSEQ:READLINE-COMMAND + + Display current Readline (*note 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 (*note + Readline Init File::), but each binding or command must be passed + as a separate argument; e.g., '"\C-x\C-r":re-read-init-file'. + + Options, if supplied, have the following meanings: + + '-m KEYMAP' + Use KEYMAP as the keymap to be affected by the subsequent + bindings. Acceptable KEYMAP names are 'emacs', + 'emacs-standard', 'emacs-meta', 'emacs-ctlx', 'vi', 'vi-move', + 'vi-command', and 'vi-insert'. 'vi' is equivalent to + 'vi-command' ('vi-move' is also a synonym); 'emacs' is + equivalent to 'emacs-standard'. + + '-l' + List the names of all Readline functions. + + '-p' + Display Readline function names and bindings in such a way + that they can be used as input or in a Readline initialization + file. + + '-P' + List current Readline function names and bindings. + + '-v' + Display Readline variable names and values in such a way that + they can be used as input or in a Readline initialization + file. + + '-V' + List current Readline variable names and values. + + '-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. + + '-S' + Display Readline key sequences bound to macros and the strings + they output. + + '-f FILENAME' + Read key bindings from FILENAME. + + '-q FUNCTION' + Query about which keys invoke the named FUNCTION. + + '-u FUNCTION' + Unbind all keys bound to the named FUNCTION. + + '-r KEYSEQ' + Remove any current binding for KEYSEQ. + + '-x KEYSEQ:SHELL-COMMAND' + Cause SHELL-COMMAND to be executed whenever KEYSEQ is entered. + When SHELL-COMMAND is executed, the shell sets the + 'READLINE_LINE' variable to the contents of the Readline line + buffer and the 'READLINE_POINT' variable to the current + location of the insertion point. If the executed command + changes the value of 'READLINE_LINE' or 'READLINE_POINT', + those new values will be reflected in the editing state. + + '-X' + List all key sequences bound to shell commands and the + associated commands in a format that can be reused as input. + + The return status is zero unless an invalid option is supplied or + an error occurs. + +'builtin' + builtin [SHELL-BUILTIN [ARGS]] + + Run a shell builtin, passing it 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 SHELL-BUILTIN is + not a shell builtin command. + +'caller' + caller [EXPR] + + Returns the context of any active subroutine call (a shell function + or a script executed with the '.' or 'source' builtins). + + Without EXPR, 'caller' displays the line number and source filename + of the current subroutine call. If a non-negative integer is + supplied as EXPR, '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 EXPR does not correspond to a valid position in + the call stack. + +'command' + command [-pVv] COMMAND [ARGUMENTS ...] + + Runs COMMAND with ARGUMENTS ignoring any shell function named + COMMAND. Only shell builtin commands or commands found by + searching the 'PATH' are executed. If there is a shell function + named 'ls', running 'command ls' within the function will execute + the external command 'ls' instead of calling the function + recursively. The '-p' option means to use a default value for + 'PATH' that is guaranteed to find all of the standard utilities. + The return status in this case is 127 if COMMAND cannot be found or + an error occurred, and the exit status of COMMAND otherwise. + + If either the '-V' or '-v' option is supplied, a description of + COMMAND is printed. The '-v' option causes a single word + indicating the command or file name used to invoke COMMAND to be + displayed; the '-V' option produces a more verbose description. In + this case, the return status is zero if COMMAND is found, and + non-zero if not. + +'declare' + declare [-aAfFgilnrtux] [-p] [NAME[=VALUE] ...] + + Declare variables and give them attributes. If no NAMEs are given, + then display the values of variables instead. + + The '-p' option will display the attributes and values of each + NAME. When '-p' is used with NAME arguments, additional options, + other than '-f' and '-F', are ignored. + + When '-p' is supplied without NAME arguments, 'declare' will + display the attributes and values of all variables having the + attributes specified by the additional options. If no other + options are supplied with '-p', 'declare' will display the + attributes and values of all shell variables. The '-f' option will + restrict the display to shell functions. + + The '-F' option inhibits the display of function definitions; only + the function name and attributes are printed. If the 'extdebug' + shell option is enabled using 'shopt' (*note The Shopt Builtin::), + the source file name and line number where each NAME is defined are + displayed as well. '-F' implies '-f'. + + The '-g' option forces variables to be created or modified at the + global scope, even when 'declare' is executed in a shell function. + It is ignored in all other cases. + + The following options can be used to restrict output to variables + with the specified attributes or to give variables attributes: + + '-a' + Each NAME is an indexed array variable (*note Arrays::). + + '-A' + Each NAME is an associative array variable (*note Arrays::). + + '-f' + Use function names only. + + '-i' + The variable is to be treated as an integer; arithmetic + evaluation (*note Shell Arithmetic::) is performed when the + variable is assigned a value. + + '-l' + When the variable is assigned a value, all upper-case + characters are converted to lower-case. The upper-case + attribute is disabled. + + '-n' + Give each NAME the NAMEREF attribute, making it a name + reference to another variable. That other variable is defined + by the value of NAME. All references, assignments, and + attribute modifications to NAME, except for those using or + changing the '-n' attribute itself, are performed on the + variable referenced by NAME's value. The nameref attribute + cannot be applied to array variables. + + '-r' + Make NAMEs readonly. These names cannot then be assigned + values by subsequent assignment statements or unset. + + '-t' + Give each NAME the 'trace' attribute. Traced functions + inherit the 'DEBUG' and 'RETURN' traps from the calling shell. + The trace attribute has no special meaning for variables. + + '-u' + When the variable is assigned a value, all lower-case + characters are converted to upper-case. The lower-case + attribute is disabled. + + '-x' + Mark each NAME for export to subsequent commands via the + environment. + + Using '+' instead of '-' turns off the attribute instead, with the + exceptions that '+a' may not be used to destroy an array variable + and '+r' will not remove the readonly attribute. When used in a + function, 'declare' makes each NAME local, as with the 'local' + command, unless the '-g' option is used. If a variable name is + followed by =VALUE, the value of the variable is set to VALUE. + + When using '-a' or '-A' and the compound assignment syntax to + create array variables, additional attributes do not take effect + until subsequent assignments. + + The return status is zero unless an invalid option is encountered, + an attempt is made to define a function using '-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 (*note Arrays::), one of the + 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 '-f'. + +'echo' + echo [-neE] [ARG ...] + + Output the ARGs, separated by spaces, terminated with a newline. + The return status is 0 unless a write error occurs. If '-n' is + specified, the trailing newline is suppressed. If the '-e' option + is given, interpretation of the following backslash-escaped + characters is enabled. The '-E' option disables the interpretation + of these escape characters, even on systems where they are + interpreted by default. The 'xpg_echo' shell option may be used to + dynamically determine whether or not 'echo' expands these escape + characters by default. 'echo' does not interpret '--' to mean the + end of options. + + 'echo' interprets the following escape sequences: + '\a' + alert (bell) + '\b' + backspace + '\c' + suppress further output + '\e' + '\E' + escape + '\f' + form feed + '\n' + new line + '\r' + carriage return + '\t' + horizontal tab + '\v' + vertical tab + '\\' + backslash + '\0NNN' + the eight-bit character whose value is the octal value NNN + (zero to three octal digits) + '\xHH' + the eight-bit character whose value is the hexadecimal value + HH (one or two hex digits) + '\uHHHH' + the Unicode (ISO/IEC 10646) character whose value is the + hexadecimal value HHHH (one to four hex digits) + '\UHHHHHHHH' + the Unicode (ISO/IEC 10646) character whose value is the + hexadecimal value HHHHHHHH (one to eight hex digits) + +'enable' + enable [-a] [-dnps] [-f FILENAME] [NAME ...] + + 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 '-n' + is used, the NAMEs become disabled. Otherwise NAMEs are enabled. + For example, to use the 'test' binary found via '$PATH' instead of + the shell builtin version, type 'enable -n test'. + + If the '-p' option is supplied, or no NAME arguments appear, a list + of shell builtins is printed. With no other arguments, the list + consists of all enabled shell builtins. The '-a' option means to + list each builtin with an indication of whether or not it is + enabled. + + The '-f' option means to load the new builtin command NAME from + shared object FILENAME, on systems that support dynamic loading. + The '-d' option will delete a builtin loaded with '-f'. + + If there are no options, a list of the shell builtins is displayed. + The '-s' option restricts 'enable' to the POSIX special builtins. + If '-s' is used with '-f', the new builtin becomes a special + builtin (*note Special Builtins::). + + The return status is zero unless a NAME is not a shell builtin or + there is an error loading a new builtin from a shared object. + +'help' + help [-dms] [PATTERN] + + Display helpful information about builtin commands. If PATTERN is + specified, 'help' gives detailed help on all commands matching + PATTERN, otherwise a list of the builtins is printed. + + Options, if supplied, have the following meanings: + + '-d' + Display a short description of each PATTERN + '-m' + Display the description of each PATTERN in a manpage-like + format + '-s' + Display only a short usage synopsis for each PATTERN + + The return status is zero unless no command matches PATTERN. + +'let' + let EXPRESSION [EXPRESSION ...] + + The 'let' builtin allows arithmetic to be performed on shell + variables. Each EXPRESSION is evaluated according to the rules + given below in *note Shell Arithmetic::. If the last EXPRESSION + evaluates to 0, 'let' returns 1; otherwise 0 is returned. + +'local' + local [OPTION] NAME[=VALUE] ... + + For each argument, a local variable named NAME is created, and + assigned VALUE. The OPTION can be any of the options accepted by + 'declare'. 'local' can only be used within a function; it makes + the variable NAME have a visible scope restricted to that function + and its children. If NAME is '-', the set of shell options is made + local to the function in which 'local' is invoked: shell options + changed using the 'set' builtin inside the function are restored to + their original values when the function returns. The return status + is zero unless 'local' is used outside a function, an invalid NAME + is supplied, or NAME is a readonly variable. + +'logout' + logout [N] + + Exit a login shell, returning a status of N to the shell's parent. + +'mapfile' + mapfile [-d DELIM] [-n COUNT] [-O ORIGIN] [-s COUNT] [-t] [-u FD] + [-C CALLBACK] [-c QUANTUM] [ARRAY] + + Read lines from the standard input into the indexed array variable + ARRAY, or from file descriptor FD if the '-u' option is supplied. + The variable 'MAPFILE' is the default ARRAY. Options, if supplied, + have the following meanings: + + '-d' + The first character of DELIM is used to terminate each input + line, rather than newline. + '-n' + Copy at most COUNT lines. If COUNT is 0, all lines are + copied. + '-O' + Begin assigning to ARRAY at index ORIGIN. The default index + is 0. + '-s' + Discard the first COUNT lines read. + '-t' + Remove a trailing DELIM (default newline) from each line read. + '-u' + Read lines from file descriptor FD instead of the standard + input. + '-C' + Evaluate CALLBACK each time QUANTUMP lines are read. The '-c' + option specifies QUANTUM. + '-c' + Specify the number of lines read between each call to + CALLBACK. + + If '-C' is specified without '-c', the default quantum is 5000. + When CALLBACK is evaluated, it is supplied the index of the next + array element to be assigned and the line to be assigned to that + element as additional arguments. CALLBACK is evaluated after the + line is read but before the array element is assigned. + + If not supplied with an explicit origin, 'mapfile' will clear ARRAY + before assigning to it. + + 'mapfile' returns successfully unless an invalid option or option + argument is supplied, ARRAY is invalid or unassignable, or ARRAY is + not an indexed array. + +'printf' + printf [-v VAR] FORMAT [ARGUMENTS] + + Write the formatted ARGUMENTS to the standard output under the + control of the FORMAT. The '-v' option causes the output to be + assigned to the variable VAR rather than being printed to the + standard output. + + The 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 ARGUMENT. In addition to + the standard 'printf(1)' formats, 'printf' interprets the following + extensions: + + '%b' + Causes 'printf' to expand backslash escape sequences in the + corresponding ARGUMENT in the same way as 'echo -e' (*note + Bash Builtins::). + '%q' + Causes 'printf' to output the corresponding ARGUMENT in a + format that can be reused as shell input. + '%(DATEFMT)T' + Causes 'printf' to output the date-time string resulting from + using DATEFMT as a format string for 'strftime'(3). The + corresponding ARGUMENT is an integer representing the number + of seconds since the epoch. Two special argument values may + be used: -1 represents the current time, and -2 represents the + time the shell was invoked. If no argument is specified, + conversion behaves as if -1 had been given. This is an + exception to the usual 'printf' behavior. + + Arguments to non-string format specifiers are treated as C language + constants, except that a leading plus or minus sign is allowed, and + if the leading character is a single or double quote, the value is + the ASCII value of the following character. + + The FORMAT is reused as necessary to consume all of the ARGUMENTS. + If the FORMAT requires more 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. + +'read' + read [-ers] [-a ANAME] [-d DELIM] [-i TEXT] [-n NCHARS] + [-N NCHARS] [-p PROMPT] [-t TIMEOUT] [-u FD] [NAME ...] + + One line is read from the standard input, or from the file + descriptor FD supplied as an argument to the '-u' option, split + into words as described above in *note Word Splitting::, and the + first word is assigned to the first NAME, the second word to the + second NAME, and so on. If there are more words than names, the + remaining words and their intervening delimiters are assigned to + the last 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 'IFS' variable are used to split the + line into words using the same rules the shell uses for expansion + (described above in *note Word Splitting::). The backslash + character '\' may be used to remove any special meaning for the + next character read and for line continuation. If no names are + supplied, the line read is assigned to the variable 'REPLY'. The + exit status is zero, unless end-of-file is encountered, 'read' + times out (in which case the status is greater than 128), a + variable assignment error (such as assigning to a readonly + variable) occurs, or an invalid file descriptor is supplied as the + argument to '-u'. + + Options, if supplied, have the following meanings: + + '-a ANAME' + The words are assigned to sequential indices of the array + variable ANAME, starting at 0. All elements are removed from + ANAME before the assignment. Other NAME arguments are + ignored. + + '-d DELIM' + The first character of DELIM is used to terminate the input + line, rather than newline. + + '-e' + Readline (*note Command Line Editing::) is used to obtain the + line. Readline uses the current (or default, if line editing + was not previously active) editing settings. + + '-i TEXT' + If Readline is being used to read the line, TEXT is placed + into the editing buffer before editing begins. + + '-n NCHARS' + 'read' returns after reading NCHARS characters rather than + waiting for a complete line of input, but honors a delimiter + if fewer than NCHARS characters are read before the delimiter. + + '-N NCHARS' + 'read' returns after reading exactly NCHARS characters rather + than waiting for a complete line of input, unless EOF is + encountered or 'read' times out. Delimiter characters + encountered in the input are not treated specially and do not + cause 'read' to return until NCHARS characters are read. The + result is not split on the characters in 'IFS'; the intent is + that the variable is assigned exactly the characters read + (with the exception of backslash; see the '-r' option below). + + '-p PROMPT' + Display PROMPT, without a trailing newline, before attempting + to read any input. The prompt is displayed only if input is + coming from a terminal. + + '-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. + + '-s' + Silent mode. If input is coming from a terminal, characters + are not echoed. + + '-t TIMEOUT' + Cause 'read' to time out and return failure if a complete line + of input (or a specified number of characters) is not read + within TIMEOUT seconds. TIMEOUT may be a decimal number with + a fractional portion following the decimal point. This option + is only effective if 'read' is reading input from a terminal, + pipe, or other special file; it has no effect when reading + from regular files. If 'read' times out, 'read' saves any + partial input read into the specified variable NAME. If + TIMEOUT is 0, 'read' returns immediately, without trying to + read and data. The exit status is 0 if input is available on + the specified file descriptor, non-zero otherwise. The exit + status is greater than 128 if the timeout is exceeded. + + '-u FD' + Read input from file descriptor FD. + +'readarray' + readarray [-d DELIM] [-n COUNT] [-O ORIGIN] [-s COUNT] [-t] [-u FD] + [-C CALLBACK] [-c QUANTUM] [ARRAY] + + Read lines from the standard input into the indexed array variable + ARRAY, or from file descriptor FD if the '-u' option is supplied. + + A synonym for 'mapfile'. + +'source' + source FILENAME + + A synonym for '.' (*note Bourne Shell Builtins::). + +'type' + type [-afptP] [NAME ...] + + For each NAME, indicate how it would be interpreted if used as a + command name. + + If the '-t' option is used, 'type' prints a single word which is + one of 'alias', 'function', 'builtin', 'file' or 'keyword', if NAME + is an alias, shell function, shell builtin, disk file, or shell + reserved word, respectively. If the NAME is not found, then + nothing is printed, and 'type' returns a failure status. + + If the '-p' option is used, 'type' either returns the name of the + disk file that would be executed, or nothing if '-t' would not + return 'file'. + + The '-P' option forces a path search for each NAME, even if '-t' + would not return 'file'. + + If a command is hashed, '-p' and '-P' print the hashed value, which + is not necessarily the file that appears first in '$PATH'. + + If the '-a' option is used, 'type' returns all of the places that + contain an executable named FILE. This includes aliases and + functions, if and only if the '-p' option is not also used. + + If the '-f' option is used, 'type' does not attempt to find shell + functions, as with the 'command' builtin. + + The return status is zero if all of the NAMES are found, non-zero + if any are not found. + +'typeset' + typeset [-afFgrxilnrtux] [-p] [NAME[=VALUE] ...] + + The 'typeset' command is supplied for compatibility with the Korn + shell. It is a synonym for the 'declare' builtin command. + +'ulimit' + ulimit [-HSabcdefiklmnpqrstuvxPT] [LIMIT] + + '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: + + '-S' + Change and report the soft limit associated with a resource. + + '-H' + Change and report the hard limit associated with a resource. + + '-a' + All current limits are reported. + + '-b' + The maximum socket buffer size. + + '-c' + The maximum size of core files created. + + '-d' + The maximum size of a process's data segment. + + '-e' + The maximum scheduling priority ("nice"). + + '-f' + The maximum size of files written by the shell and its + children. + + '-i' + The maximum number of pending signals. + + '-k' + The maximum number of kqueues that may be allocated. + + '-l' + The maximum size that may be locked into memory. + + '-m' + The maximum resident set size (many systems do not honor this + limit). + + '-n' + The maximum number of open file descriptors (most systems do + not allow this value to be set). + + '-p' + The pipe buffer size. + + '-q' + The maximum number of bytes in POSIX message queues. + + '-r' + The maximum real-time scheduling priority. + + '-s' + The maximum stack size. + + '-t' + The maximum amount of cpu time in seconds. + + '-u' + The maximum number of processes available to a single user. + + '-v' + The maximum amount of virtual memory available to the shell, + and, on some systems, to its children. + + '-x' + The maximum number of file locks. + + '-P' + The maximum number of pseudoterminals. + + '-T' + The maximum number of threads. + + If LIMIT is given, and the '-a' option is not used, LIMIT is the + new value of the specified resource. The special LIMIT values + 'hard', 'soft', and 'unlimited' stand for the current hard limit, + the current soft limit, and no limit, respectively. A hard limit + cannot be increased by a non-root user once it is set; a soft limit + may be increased up to the value of the hard limit. Otherwise, the + current value of the soft limit for the specified resource is + printed, unless the '-H' option is supplied. When setting new + limits, if neither '-H' nor '-S' is supplied, both the hard and + soft limits are set. If no option is given, then '-f' is assumed. + Values are in 1024-byte increments, except for '-t', which is in + seconds; '-p', which is in units of 512-byte blocks; '-P', '-T', + '-b', '-k', '-n' and '-u', which are unscaled values; and, when in + POSIX Mode (*note Bash POSIX Mode::), '-c' and '-f', which are in + 512-byte increments. + + The return status is zero unless an invalid option or argument is + supplied, or an error occurs while setting a new limit. + +'unalias' + unalias [-a] [NAME ... ] + + Remove each NAME from the list of aliases. If '-a' is supplied, + all aliases are removed. Aliases are described in *note Aliases::. + + +File: bash.info, Node: Modifying Shell Behavior, Next: Special Builtins, Prev: Bash Builtins, Up: Shell Builtin Commands + +4.3 Modifying Shell Behavior +============================ + +* Menu: + +* The Set Builtin:: Change the values of shell attributes and + positional parameters. +* The Shopt Builtin:: Modify shell optional behavior. + + +File: bash.info, Node: The Set Builtin, Next: The Shopt Builtin, Up: Modifying Shell Behavior + +4.3.1 The Set Builtin +--------------------- + +This builtin is so complicated that it deserves its own section. '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. + +'set' + set [--abefhkmnptuvxBCEHPT] [-o OPTION-NAME] [ARGUMENT ...] + set [+abefhkmnptuvxBCEHPT] [+o OPTION-NAME] [ARGUMENT ...] + + If no options or arguments are supplied, '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 POSIX mode, only shell variables are + listed. + + When options are supplied, they set or unset shell attributes. + Options, if specified, have the following meanings: + + '-a' + Each variable or function that is created or modified is given + the export attribute and marked for export to the environment + of subsequent commands. + + '-b' + Cause the status of terminated background jobs to be reported + immediately, rather than before printing the next primary + prompt. + + '-e' + Exit immediately if a pipeline (*note Pipelines::), which may + consist of a single simple command (*note Simple Commands::), + a list (*note Lists::), or a compound command (*note Compound + Commands::) returns a non-zero status. The shell does not + exit if the command that fails is part of the command list + immediately following a 'while' or 'until' keyword, part of + the test in an 'if' statement, part of any command executed in + a '&&' or '||' list except the command following the final + '&&' or '||', any command in a pipeline but the last, or if + the command's return status is being inverted with '!'. If a + compound command other than a subshell returns a non-zero + status because a command failed while '-e' was being ignored, + the shell does not exit. A trap on 'ERR', if set, is executed + before the shell exits. + + This option applies to the shell environment and each subshell + environment separately (*note Command Execution + Environment::), and may cause subshells to exit before + executing all the commands in the subshell. + + If a compound command or shell function executes in a context + where '-e' is being ignored, none of the commands executed + within the compound command or function body will be affected + by the '-e' setting, even if '-e' is set and a command returns + a failure status. If a compound command or shell function + sets '-e' while executing in a context where '-e' is ignored, + that setting will not have any effect until the compound + command or the command containing the function call completes. + + '-f' + Disable filename expansion (globbing). + + '-h' + Locate and remember (hash) commands as they are looked up for + execution. This option is enabled by default. + + '-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. + + '-m' + Job control is enabled (*note Job Control::). All processes + run in a separate process group. When a background job + completes, the shell prints a line containing its exit status. + + '-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. + + '-o OPTION-NAME' + + Set the option corresponding to OPTION-NAME: + + 'allexport' + Same as '-a'. + + 'braceexpand' + Same as '-B'. + + 'emacs' + Use an 'emacs'-style line editing interface (*note + Command Line Editing::). This also affects the editing + interface used for 'read -e'. + + 'errexit' + Same as '-e'. + + 'errtrace' + Same as '-E'. + + 'functrace' + Same as '-T'. + + 'hashall' + Same as '-h'. + + 'histexpand' + Same as '-H'. + + 'history' + Enable command history, as described in *note Bash + History Facilities::. This option is on by default in + interactive shells. + + 'ignoreeof' + An interactive shell will not exit upon reading EOF. + + 'keyword' + Same as '-k'. + + 'monitor' + Same as '-m'. + + 'noclobber' + Same as '-C'. + + 'noexec' + Same as '-n'. + + 'noglob' + Same as '-f'. + + 'nolog' + Currently ignored. + + 'notify' + Same as '-b'. + + 'nounset' + Same as '-u'. + + 'onecmd' + Same as '-t'. + + 'physical' + Same as '-P'. + + '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. + + 'posix' + Change the behavior of Bash where the default operation + differs from the POSIX standard to match the standard + (*note Bash POSIX Mode::). This is intended to make Bash + behave as a strict superset of that standard. + + 'privileged' + Same as '-p'. + + 'verbose' + Same as '-v'. + + 'vi' + Use a 'vi'-style line editing interface. This also + affects the editing interface used for 'read -e'. + + 'xtrace' + Same as '-x'. + + '-p' + Turn on privileged mode. In this mode, the '$BASH_ENV' and + '$ENV' files are not processed, shell functions are not + inherited from the environment, and the 'SHELLOPTS', + 'BASHOPTS', 'CDPATH' and 'GLOBIGNORE' variables, if they + appear in the environment, are ignored. If the shell is + started with the effective user (group) id not equal to the + real user (group) id, and the '-p' option is not supplied, + these actions are taken and the effective user id is set to + the real user id. If the '-p' option is supplied at startup, + the effective user id is not reset. Turning this option off + causes the effective user and group ids to be set to the real + user and group ids. + + '-t' + Exit after reading and executing one command. + + '-u' + Treat unset variables and parameters other than the special + parameters '@' or '*' as an error when performing parameter + expansion. An error message will be written to the standard + error, and a non-interactive shell will exit. + + '-v' + Print shell input lines as they are read. + + '-x' + Print a trace of simple commands, 'for' commands, 'case' + commands, 'select' commands, and arithmetic 'for' commands and + their arguments or associated word lists after they are + expanded and before they are executed. The value of the 'PS4' + variable is expanded and the resultant value is printed before + the command and its expanded arguments. + + '-B' + The shell will perform brace expansion (*note Brace + Expansion::). This option is on by default. + + '-C' + Prevent output redirection using '>', '>&', and '<>' from + overwriting existing files. + + '-E' + If set, any trap on 'ERR' is inherited by shell functions, + command substitutions, and commands executed in a subshell + environment. The 'ERR' trap is normally not inherited in such + cases. + + '-H' + Enable '!' style history substitution (*note History + Interaction::). This option is on by default for interactive + shells. + + '-P' + If set, do not resolve symbolic links when performing commands + such as '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 '/usr/sys' is a symbolic link to + '/usr/local/sys' then: + $ cd /usr/sys; echo $PWD + /usr/sys + $ cd ..; pwd + /usr + + If 'set -P' is on, then: + $ cd /usr/sys; echo $PWD + /usr/local/sys + $ cd ..; pwd + /usr/local + + '-T' + If set, any trap on 'DEBUG' and 'RETURN' are inherited by + shell functions, command substitutions, and commands executed + in a subshell environment. The 'DEBUG' and 'RETURN' traps are + normally not inherited in such cases. + + '--' + If no arguments follow this option, then the positional + parameters are unset. Otherwise, the positional parameters + are set to the ARGUMENTS, even if some of them begin with a + '-'. + + '-' + Signal the end of options, cause all remaining ARGUMENTS to be + assigned to the positional parameters. The '-x' and '-v' + options are turned off. If there are no arguments, the + positional parameters remain unchanged. + + Using '+' rather than '-' 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 '$-'. + + The remaining N ARGUMENTS are positional parameters and are + assigned, in order, to '$1', '$2', ... '$N'. The special parameter + '#' is set to N. + + The return status is always zero unless an invalid option is + supplied. + + +File: bash.info, Node: The Shopt Builtin, Prev: The Set Builtin, Up: Modifying Shell Behavior + +4.3.2 The Shopt Builtin +----------------------- + +This builtin allows you to change additional shell optional behavior. + +'shopt' + shopt [-pqsu] [-o] [OPTNAME ...] + + Toggle the values of settings controlling optional shell behavior. + The settings can be either those listed below, or, if the '-o' + option is used, those available with the '-o' option to the 'set' + builtin command (*note The Set Builtin::). With no options, or + with the '-p' option, a list of all settable options is displayed, + with an indication of whether or not each is set. The '-p' option + causes output to be displayed in a form that may be reused as + input. Other options have the following meanings: + + '-s' + Enable (set) each OPTNAME. + + '-u' + Disable (unset) each OPTNAME. + + '-q' + Suppresses normal output; the return status indicates whether + the OPTNAME is set or unset. If multiple OPTNAME arguments + are given with '-q', the return status is zero if all OPTNAMES + are enabled; non-zero otherwise. + + '-o' + Restricts the values of OPTNAME to be those defined for the + '-o' option to the 'set' builtin (*note The Set Builtin::). + + If either '-s' or '-u' is used with no OPTNAME arguments, 'shopt' + shows only those options which are set or unset, respectively. + + Unless otherwise noted, the 'shopt' options are disabled (off) by + default. + + The return status when listing options is zero if all OPTNAMES are + enabled, non-zero otherwise. When setting or unsetting options, + the return status is zero unless an OPTNAME is not a valid shell + option. + + The list of 'shopt' options is: + + 'autocd' + If set, a command name that is the name of a directory is + executed as if it were the argument to the 'cd' command. This + option is only used by interactive shells. + + 'cdable_vars' + If this is set, an argument to the '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. + + 'cdspell' + If set, minor errors in the spelling of a directory component + in a '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. + + '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. + + '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 (*note Job + Control::). The shell always postpones exiting if any jobs + are stopped. + + 'checkwinsize' + If set, Bash checks the window size after each command and, if + necessary, updates the values of 'LINES' and 'COLUMNS'. + + '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. + + 'compat31' + If set, Bash changes its behavior to that of version 3.1 with + respect to quoted arguments to the conditional command's '=~' + operator and with respect to locale-specific string comparison + when using the '[[' conditional command's '<' and '>' + operators. Bash versions prior to bash-4.1 use ASCII + collation and strcmp(3); bash-4.1 and later use the current + locale's collation sequence and strcoll(3). + + 'compat32' + If set, Bash changes its behavior to that of version 3.2 with + respect to locale-specific string comparison when using the + '[[' conditional command's '<' and '>' operators (see previous + item) and the effect of interrupting a command list. Bash + versions 3.2 and earlier continue with the next command in the + list after one terminates due to an interrupt. + + 'compat40' + If set, Bash changes its behavior to that of version 4.0 with + respect to locale-specific string comparison when using the + '[[' conditional command's '<' and '>' operators (see + description of 'compat31') and the effect of interrupting a + command list. Bash versions 4.0 and later interrupt the list + as if the shell received the interrupt; previous versions + continue with the next command in the list. + + 'compat41' + If set, Bash, when in POSIX mode, treats a single quote in a + double-quoted parameter expansion as a special character. The + single quotes must match (an even number) and the characters + between the single quotes are considered quoted. This is the + behavior of POSIX mode through version 4.1. The default Bash + behavior remains as in previous versions. + + 'compat42' + If set, Bash does not process the replacement string in the + pattern substitution word expansion using quote removal. + + 'compat43' + If set, Bash does not print a warning message if an attempt is + made to use a quoted compound array assignment as an argument + to 'declare', makes word expansion errors non-fatal errors + that cause the current command to fail (the default behavior + is to make them fatal errors that cause the shell to exit), + and does not reset the loop state when a shell function is + executed (this allows 'break' or 'continue' in a shell + function to affect loops in the caller's context). + + 'complete_fullquote' + If set, Bash quotes all shell metacharacters in filenames and + directory names when performing completion. If not set, Bash + removes metacharacters such as the dollar sign from the set of + characters that will be quoted in completed filenames when + these metacharacters appear in shell variable references in + words to be completed. This means that dollar signs in + variable names that expand to directories will not be quoted; + however, any dollar signs appearing in filenames will not be + quoted, either. This is active only when bash is using + backslashes to quote completed filenames. This variable is + set by default, which is the default Bash behavior in versions + through 4.2. + + 'direxpand' + If set, Bash replaces directory names with the results of word + expansion when performing filename completion. This changes + the contents of the readline editing buffer. If not set, Bash + attempts to preserve what the user typed. + + 'dirspell' + If set, Bash attempts spelling correction on directory names + during word completion if the directory name initially + supplied does not exist. + + 'dotglob' + If set, Bash includes filenames beginning with a '.' in the + results of filename expansion. + + 'execfail' + If this is set, a non-interactive shell will not exit if it + cannot execute the file specified as an argument to the 'exec' + builtin command. An interactive shell does not exit if 'exec' + fails. + + 'expand_aliases' + If set, aliases are expanded as described below under Aliases, + *note Aliases::. This option is enabled by default for + interactive shells. + + 'extdebug' + If set at shell invocation, arrange to execute the debugger + profile before the shell starts, identical to the '--debugger' + option. If set after invocation, behavior intended for use by + debuggers is enabled: + + 1. The '-F' option to the 'declare' builtin (*note Bash + Builtins::) displays the source file name and line number + corresponding to each function name supplied as an + argument. + + 2. If the command run by the 'DEBUG' trap returns a non-zero + value, the next command is skipped and not executed. + + 3. If the command run by the '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 '.' or + 'source' builtins), the shell simulates a call to + 'return'. + + 4. 'BASH_ARGC' and 'BASH_ARGV' are updated as described in + their descriptions (*note Bash Variables::). + + 5. Function tracing is enabled: command substitution, shell + functions, and subshells invoked with '( COMMAND )' + inherit the 'DEBUG' and 'RETURN' traps. + + 6. Error tracing is enabled: command substitution, shell + functions, and subshells invoked with '( COMMAND )' + inherit the 'ERR' trap. + + 'extglob' + If set, the extended pattern matching features described above + (*note Pattern Matching::) are enabled. + + 'extquote' + If set, '$'STRING'' and '$"STRING"' quoting is performed + within '${PARAMETER}' expansions enclosed in double quotes. + This option is enabled by default. + + 'failglob' + If set, patterns which fail to match filenames during filename + expansion result in an expansion error. + + 'force_fignore' + If set, the suffixes specified by the 'FIGNORE' shell variable + cause words to be ignored when performing word completion even + if the ignored words are the only possible completions. *Note + Bash Variables::, for a description of 'FIGNORE'. This option + is enabled by default. + + 'globasciiranges' + If set, range expressions used in pattern matching bracket + expressions (*note Pattern Matching::) behave as if in the + traditional C locale when performing comparisons. That is, + the current locale's collating sequence is not taken into + account, so 'b' will not collate between 'A' and 'B', and + upper-case and lower-case ASCII characters will collate + together. + + 'globstar' + If set, the pattern '**' used in a filename expansion context + will match all files and zero or more directories and + subdirectories. If the pattern is followed by a '/', only + directories and subdirectories match. + + 'gnu_errfmt' + If set, shell error messages are written in the standard GNU + error message format. + + 'histappend' + If set, the history list is appended to the file named by the + value of the 'HISTFILE' variable when the shell exits, rather + than overwriting the file. + + 'histreedit' + If set, and Readline is being used, a user is given the + opportunity to re-edit a failed history substitution. + + '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. + + 'hostcomplete' + If set, and Readline is being used, Bash will attempt to + perform hostname completion when a word containing a '@' is + being completed (*note Commands For Completion::). This + option is enabled by default. + + 'huponexit' + If set, Bash will send 'SIGHUP' to all jobs when an + interactive login shell exits (*note Signals::). + + 'inherit_errexit' + If set, command substitution inherits the value of the + 'errexit' option, instead of unsetting it in the subshell + environment. This option is enabled when POSIX mode is + enabled. + + 'interactive_comments' + Allow a word beginning with '#' to cause that word and all + remaining characters on that line to be ignored in an + interactive shell. This option is enabled by default. + + 'lastpipe' + If set, and job control is not active, the shell runs the last + command of a pipeline not executed in the background in the + current shell environment. + + 'lithist' + If enabled, and the 'cmdhist' option is enabled, multi-line + commands are saved to the history with embedded newlines + rather than using semicolon separators where possible. + + 'login_shell' + The shell sets this option if it is started as a login shell + (*note Invoking Bash::). The value may not be changed. + + 'mailwarn' + If set, and a file that Bash is checking for mail has been + accessed since the last time it was checked, the message '"The + mail in MAILFILE has been read"' is displayed. + + 'no_empty_cmd_completion' + If set, and Readline is being used, Bash will not attempt to + search the 'PATH' for possible completions when completion is + attempted on an empty line. + + 'nocaseglob' + If set, Bash matches filenames in a case-insensitive fashion + when performing filename expansion. + + 'nocasematch' + If set, Bash matches patterns in a case-insensitive fashion + when performing matching while executing 'case' or '[[' + conditional commands, when performing pattern substitution + word expansions, or when filtering possible completions as + part of programmable completion. + + 'nullglob' + If set, Bash allows filename patterns which match no files to + expand to a null string, rather than themselves. + + 'progcomp' + If set, the programmable completion facilities (*note + Programmable Completion::) are enabled. This option is + enabled by default. + + 'promptvars' + If set, prompt strings undergo parameter expansion, command + substitution, arithmetic expansion, and quote removal after + being expanded as described below (*note Controlling the + Prompt::). This option is enabled by default. + + 'restricted_shell' + The shell sets this option if it is started in restricted mode + (*note The Restricted Shell::). The value may not be changed. + This is not reset when the startup files are executed, + allowing the startup files to discover whether or not a shell + is restricted. + + 'shift_verbose' + If this is set, the 'shift' builtin prints an error message + when the shift count exceeds the number of positional + parameters. + + 'sourcepath' + If set, the 'source' builtin uses the value of 'PATH' to find + the directory containing the file supplied as an argument. + This option is enabled by default. + + 'xpg_echo' + If set, the 'echo' builtin expands backslash-escape sequences + by default. + + The return status when listing options is zero if all OPTNAMES are + enabled, non-zero otherwise. When setting or unsetting options, + the return status is zero unless an OPTNAME is not a valid shell + option. + + +File: bash.info, Node: Special Builtins, Prev: Modifying Shell Behavior, Up: Shell Builtin Commands + +4.4 Special Builtins +==================== + +For historical reasons, the POSIX standard has classified several +builtin commands as _special_. When Bash is executing in POSIX mode, +the special builtins differ from other builtin commands in three +respects: + + 1. Special builtins are found before shell functions during command + lookup. + + 2. If a special builtin returns an error status, a non-interactive + shell exits. + + 3. Assignment statements preceding the command stay in effect in the + shell environment after the command completes. + + When Bash is not executing in POSIX mode, these builtins behave no +differently than the rest of the Bash builtin commands. The Bash POSIX +mode is described in *note Bash POSIX Mode::. + + These are the POSIX special builtins: + break : . continue eval exec exit export readonly return set + shift trap unset + + +File: bash.info, Node: Shell Variables, Next: Bash Features, Prev: Shell Builtin Commands, Up: Top + +5 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. + +This chapter describes the shell variables that Bash uses. Bash +automatically assigns default values to a number of variables. + + +File: bash.info, Node: Bourne Shell Variables, Next: Bash Variables, Up: Shell Variables + +5.1 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. + +'CDPATH' + A colon-separated list of directories used as a search path for the + 'cd' builtin command. + +'HOME' + The current user's home directory; the default for the 'cd' builtin + command. The value of this variable is also used by tilde + expansion (*note Tilde Expansion::). + +'IFS' + A list of characters that separate fields; used when the shell + splits words as part of expansion. + +'MAIL' + If this parameter is set to a filename or directory name and the + 'MAILPATH' variable is not set, Bash informs the user of the + arrival of mail in the specified file or Maildir-format directory. + +'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 + filename from the message with a '?'. When used in the text of the + message, '$_' expands to the name of the current mail file. + +'OPTARG' + The value of the last option argument processed by the 'getopts' + builtin. + +'OPTIND' + The index of the last option argument processed by the 'getopts' + builtin. + +'PATH' + A colon-separated list of directories in which the shell looks for + commands. A zero-length (null) directory name in the value of + 'PATH' indicates the current directory. A null directory name may + appear as two adjacent colons, or as an initial or trailing colon. + +'PS1' + The primary prompt string. The default value is '\s-\v\$ '. *Note + Controlling the Prompt::, for the complete list of escape sequences + that are expanded before 'PS1' is displayed. + +'PS2' + The secondary prompt string. The default value is '> '. + + +File: bash.info, Node: Bash Variables, Prev: Bourne Shell Variables, Up: Shell Variables + +5.2 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 (*note Job Control +Variables::). + +'BASH' + The full pathname used to execute the current instance of Bash. + +'BASHOPTS' + A colon-separated list of enabled shell options. Each word in the + list is a valid argument for the '-s' option to the 'shopt' builtin + command (*note The Shopt Builtin::). The options appearing in + 'BASHOPTS' are those reported as 'on' by 'shopt'. 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. + +'BASHPID' + Expands to the process ID of the current Bash process. This + differs from '$$' under certain circumstances, such as subshells + that do not require Bash to be re-initialized. + +'BASH_ALIASES' + An associative array variable whose members correspond to the + internal list of aliases as maintained by the 'alias' builtin. + (*note Bourne Shell Builtins::). Elements added to this array + appear in the alias list; however, unsetting array elements + currently does not cause aliases to be removed from the alias list. + If 'BASH_ALIASES' is unset, it loses its special properties, even + if it is subsequently reset. + +'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 '.' or 'source') is at the top of the stack. When a + subroutine is executed, the number of parameters passed is pushed + onto 'BASH_ARGC'. The shell sets 'BASH_ARGC' only when in extended + debugging mode (see *note The Shopt Builtin:: for a description of + the 'extdebug' option to the 'shopt' builtin). + +'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 'BASH_ARGV'. The shell + sets 'BASH_ARGV' only when in extended debugging mode (see *note + The Shopt Builtin:: for a description of the 'extdebug' option to + the 'shopt' builtin). + +'BASH_CMDS' + An associative array variable whose members correspond to the + internal hash table of commands as maintained by the 'hash' builtin + (*note Bourne Shell Builtins::). Elements added to this array + appear in the hash table; however, unsetting array elements + currently does not cause command names to be removed from the hash + table. If 'BASH_CMDS' is unset, it loses its special properties, + even if it is subsequently reset. + +'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. + +'BASH_COMPAT' + The value is used to set the shell's compatibility level. *Note + The Shopt Builtin::, for a description of the various compatibility + levels and their effects. The value may be a decimal number (e.g., + 4.2) or an integer (e.g., 42) corresponding to the desired + compatibility level. If 'BASH_COMPAT' is unset or set to the empty + string, the compatibility level is set to the default for the + current version. If 'BASH_COMPAT' is set to a value that is not + one of the valid compatibility levels, the shell prints an error + message and sets the compatibility level to the default for the + current version. The valid compatibility levels correspond to the + compatibility options accepted by the 'shopt' builtin described + above (for example, COMPAT42 means that 4.2 and 42 are valid + values). The current version is also a valid value. + +'BASH_ENV' + If this variable is set when Bash is invoked to execute a shell + script, its value is expanded and used as the name of a startup + file to read before executing the script. *Note Bash Startup + Files::. + +'BASH_EXECUTION_STRING' + The command argument to the '-c' invocation option. + +'BASH_LINENO' + An array variable whose members are the line numbers in source + files where each corresponding member of FUNCNAME was invoked. + '${BASH_LINENO[$i]}' is the line number in the source file + ('${BASH_SOURCE[$i+1]}') where '${FUNCNAME[$i]}' was called (or + '${BASH_LINENO[$i-1]}' if referenced within another shell + function). Use 'LINENO' to obtain the current line number. + +'BASH_LOADABLES_PATH' + A colon-separated list of directories in which the shell looks for + dynamically loadable builtins specified by the 'enable' command. + +'BASH_REMATCH' + An array variable whose members are assigned by the '=~' binary + operator to the '[[' conditional command (*note Conditional + Constructs::). The element with index 0 is the portion of the + string matching the entire regular expression. The element with + index N is the portion of the string matching the Nth parenthesized + subexpression. This variable is read-only. + +'BASH_SOURCE' + An array variable whose members are the source filenames where the + corresponding shell function names in the 'FUNCNAME' array variable + are defined. The shell function '${FUNCNAME[$i]}' is defined in + the file '${BASH_SOURCE[$i]}' and called from + '${BASH_SOURCE[$i+1]}' + +'BASH_SUBSHELL' + Incremented by one within each subshell or subshell environment + when the shell begins executing in that environment. The initial + value is 0. + +'BASH_VERSINFO' + A readonly array variable (*note Arrays::) whose members hold + version information for this instance of Bash. The values assigned + to the array members are as follows: + + 'BASH_VERSINFO[0]' + The major version number (the RELEASE). + + 'BASH_VERSINFO[1]' + The minor version number (the VERSION). + + 'BASH_VERSINFO[2]' + The patch level. + + 'BASH_VERSINFO[3]' + The build version. + + 'BASH_VERSINFO[4]' + The release status (e.g., BETA1). + + 'BASH_VERSINFO[5]' + The value of 'MACHTYPE'. + +'BASH_VERSION' + The version number of the current instance of Bash. + +'BASH_XTRACEFD' + If set to an integer corresponding to a valid file descriptor, Bash + will write the trace output generated when 'set -x' is enabled to + that file descriptor. This allows tracing output to be separated + from diagnostic and error messages. The file descriptor is closed + when 'BASH_XTRACEFD' is unset or assigned a new value. Unsetting + 'BASH_XTRACEFD' or assigning it the empty string causes the trace + output to be sent to the standard error. Note that setting + 'BASH_XTRACEFD' to 2 (the standard error file descriptor) and then + unsetting it will result in the standard error being closed. + +'CHILD_MAX' + Set the number of exited child status values for the shell to + remember. Bash will not allow this value to be decreased below a + POSIX-mandated minimum, and there is a maximum value (currently + 8192) that this may not exceed. The minimum value is + system-dependent. + +'COLUMNS' + Used by the 'select' command to determine the terminal width when + printing selection lists. Automatically set if the 'checkwinsize' + option is enabled (*note The Shopt Builtin::), or in an interactive + shell upon receipt of a 'SIGWINCH'. + +'COMP_CWORD' + An index into '${COMP_WORDS}' of the word containing the current + cursor position. This variable is available only in shell + functions invoked by the programmable completion facilities (*note + Programmable Completion::). + +'COMP_LINE' + The current command line. This variable is available only in shell + functions and external commands invoked by the programmable + completion facilities (*note Programmable Completion::). + +'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 + '${#COMP_LINE}'. This variable is available only in shell + functions and external commands invoked by the programmable + completion facilities (*note Programmable Completion::). + +'COMP_TYPE' + Set to an integer value corresponding to the type of completion + attempted that caused a completion function to be called: TAB, for + normal completion, '?', for listing completions after successive + tabs, '!', for listing alternatives on partial word completion, + '@', to list completions if the word is not unmodified, or '%', for + menu completion. This variable is available only in shell + functions and external commands invoked by the programmable + completion facilities (*note Programmable Completion::). + +'COMP_KEY' + The key (or final key of a key sequence) used to invoke the current + completion function. + +'COMP_WORDBREAKS' + The set of characters that the Readline library treats as word + separators when performing word completion. If 'COMP_WORDBREAKS' + is unset, it loses its special properties, even if it is + subsequently reset. + +'COMP_WORDS' + An array variable consisting of the individual words in the current + command line. The line is split into words as Readline would split + it, using 'COMP_WORDBREAKS' as described above. This variable is + available only in shell functions invoked by the programmable + completion facilities (*note Programmable Completion::). + +'COMPREPLY' + An array variable from which Bash reads the possible completions + generated by a shell function invoked by the programmable + completion facility (*note Programmable Completion::). Each array + element contains one possible completion. + +'COPROC' + An array variable created to hold the file descriptors for output + from and input to an unnamed coprocess (*note Coprocesses::). + +'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 'dirs' builtin. Assigning to members of this + array variable may be used to modify directories already in the + stack, but the 'pushd' and 'popd' builtins must be used to add and + remove directories. Assignment to this variable will not change + the current directory. If 'DIRSTACK' is unset, it loses its + special properties, even if it is subsequently reset. + +'EMACS' + If Bash finds this variable in the environment when the shell + starts with value 't', it assumes that the shell is running in an + Emacs shell buffer and disables line editing. + +'ENV' + Similar to 'BASH_ENV'; used when the shell is invoked in POSIX Mode + (*note Bash POSIX Mode::). + +'EUID' + The numeric effective user id of the current user. This variable + is readonly. + +'EXECIGNORE' + A colon-separated list of shell patterns (*note Pattern Matching::) + defining the list of filenames to be ignored by command search + using 'PATH'. Files whose full pathnames match one of these + patterns are not considered executable files for the purposes of + completion and command execution via 'PATH' lookup. This does not + affect the behavior of the '[', 'test', and '[[' commands. Full + pathnames in the command hash table are not subject to + 'EXECIGNORE'. Use this variable to ignore shared library files + that have the executable bit set, but are not executable files. + The pattern matching honors the setting of the 'extglob' shell + option. + +'FCEDIT' + The editor used as a default by the '-e' option to the 'fc' builtin + command. + +'FIGNORE' + A colon-separated list of suffixes to ignore when performing + filename completion. A filename whose suffix matches one of the + entries in 'FIGNORE' is excluded from the list of matched + filenames. A sample value is '.o:~' + +'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 (the one with the highest index) is '"main"'. + This variable exists only when a shell function is executing. + Assignments to 'FUNCNAME' have no effect. If 'FUNCNAME' is unset, + it loses its special properties, even if it is subsequently reset. + + This variable can be used with 'BASH_LINENO' and 'BASH_SOURCE'. + Each element of 'FUNCNAME' has corresponding elements in + 'BASH_LINENO' and 'BASH_SOURCE' to describe the call stack. For + instance, '${FUNCNAME[$i]}' was called from the file + '${BASH_SOURCE[$i+1]}' at line number '${BASH_LINENO[$i]}'. The + 'caller' builtin displays the current call stack using this + information. + +'FUNCNEST' + If set to a numeric value greater than 0, defines a maximum + function nesting level. Function invocations that exceed this + nesting level will cause the current command to abort. + +'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 + 'GLOBIGNORE', it is removed from the list of matches. The pattern + matching honors the setting of the 'extglob' shell option. + +'GROUPS' + An array variable containing the list of groups of which the + current user is a member. Assignments to 'GROUPS' have no effect. + If 'GROUPS' is unset, it loses its special properties, even if it + is subsequently reset. + +'histchars' + Up to three characters which control history expansion, quick + substitution, and tokenization (*note History Interaction::). The + first character is the HISTORY EXPANSION character, that is, the + character which signifies the start of a history expansion, + normally '!'. The second character is the character which + signifies 'quick substitution' when seen as the first character on + a line, normally '^'. 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 '#'. + 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. + +'HISTCMD' + The history number, or index in the history list, of the current + command. If 'HISTCMD' is unset, it loses its special properties, + even if it is subsequently reset. + +'HISTCONTROL' + A colon-separated list of values controlling how commands are saved + on the history list. If the list of values includes 'ignorespace', + lines which begin with a space character are not saved in the + history list. A value of 'ignoredups' causes lines which match the + previous history entry to not be saved. A value of 'ignoreboth' is + shorthand for 'ignorespace' and 'ignoredups'. A value of + '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 '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 + '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 'HISTCONTROL'. + +'HISTFILE' + The name of the file to which the command history is saved. The + default value is '~/.bash_history'. + +'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 by + removing the oldest entries. The history file is also truncated to + this size after writing it when a shell exits. If the value is 0, + the history file is truncated to zero size. Non-numeric values and + numeric values less than zero inhibit truncation. The shell sets + the default value to the value of 'HISTSIZE' after reading any + startup files. + +'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 '*' is appended). Each pattern is tested against + the line after the checks specified by 'HISTCONTROL' are applied. + In addition to the normal shell pattern matching characters, '&' + matches the previous history line. '&' 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 + 'HISTIGNORE'. The pattern matching honors the setting of the + 'extglob' shell option. + + 'HISTIGNORE' subsumes the function of 'HISTCONTROL'. A pattern of + '&' is identical to 'ignoredups', and a pattern of '[ ]*' is + identical to 'ignorespace'. Combining these two patterns, + separating them with a colon, provides the functionality of + 'ignoreboth'. + +'HISTSIZE' + The maximum number of commands to remember on the history list. If + the value is 0, commands are not saved in the history list. + Numeric values less than zero result in every command being saved + on the history list (there is no limit). The shell sets the + default value to 500 after reading any startup files. + +'HISTTIMEFORMAT' + If this variable is set and not null, its value is used as a format + string for STRFTIME to print the time stamp associated with each + history entry displayed by the 'history' builtin. If this variable + is set, time stamps are written to the history file so they may be + preserved across shell sessions. This uses the history comment + character to distinguish timestamps from other history lines. + +'HOSTFILE' + Contains the name of a file in the same format as '/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 'HOSTFILE' is set, but has no value, or + does not name a readable file, Bash attempts to read '/etc/hosts' + to obtain the list of possible hostname completions. When + 'HOSTFILE' is unset, the hostname list is cleared. + +'HOSTNAME' + The name of the current host. + +'HOSTTYPE' + A string describing the machine Bash is running on. + +'IGNOREEOF' + Controls the action of the shell on receipt of an 'EOF' character + as the sole input. If set, the value denotes the number of + consecutive '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 'EOF' + signifies the end of input to the shell. This is only in effect + for interactive shells. + +'INPUTRC' + The name of the Readline initialization file, overriding the + default of '~/.inputrc'. + +'LANG' + Used to determine the locale category for any category not + specifically selected with a variable starting with 'LC_'. + +'LC_ALL' + This variable overrides the value of 'LANG' and any other 'LC_' + variable specifying a locale category. + +'LC_COLLATE' + This variable determines the collation order used when sorting the + results of filename expansion, and determines the behavior of range + expressions, equivalence classes, and collating sequences within + filename expansion and pattern matching (*note Filename + Expansion::). + +'LC_CTYPE' + This variable determines the interpretation of characters and the + behavior of character classes within filename expansion and pattern + matching (*note Filename Expansion::). + +'LC_MESSAGES' + This variable determines the locale used to translate double-quoted + strings preceded by a '$' (*note Locale Translation::). + +'LC_NUMERIC' + This variable determines the locale category used for number + formatting. + +'LC_TIME' + This variable determines the locale category used for data and time + formatting. + +'LINENO' + The line number in the script or shell function currently + executing. + +'LINES' + Used by the 'select' command to determine the column length for + printing selection lists. Automatically set if the 'checkwinsize' + option is enabled (*note The Shopt Builtin::), or in an interactive + shell upon receipt of a 'SIGWINCH'. + +'MACHTYPE' + A string that fully describes the system type on which Bash is + executing, in the standard GNU CPU-COMPANY-SYSTEM format. + +'MAILCHECK' + How often (in seconds) that the shell should check for mail in the + files specified in the 'MAILPATH' or '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. + +'MAPFILE' + An array variable created to hold the text read by the 'mapfile' + builtin when no variable name is supplied. + +'OLDPWD' + The previous working directory as set by the 'cd' builtin. + +'OPTERR' + If set to the value 1, Bash displays error messages generated by + the 'getopts' builtin command. + +'OSTYPE' + A string describing the operating system Bash is running on. + +'PIPESTATUS' + An array variable (*note 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). + +'POSIXLY_CORRECT' + If this variable is in the environment when Bash starts, the shell + enters POSIX mode (*note Bash POSIX Mode::) before reading the + startup files, as if the '--posix' invocation option had been + supplied. If it is set while the shell is running, Bash enables + POSIX mode, as if the command + set -o posix + had been executed. + +'PPID' + The process ID of the shell's parent process. This variable is + readonly. + +'PROMPT_COMMAND' + If set, the value is interpreted as a command to execute before the + printing of each primary prompt ('$PS1'). + +'PROMPT_DIRTRIM' + If set to a number greater than zero, the value is used as the + number of trailing directory components to retain when expanding + the '\w' and '\W' prompt string escapes (*note Controlling the + Prompt::). Characters removed are replaced with an ellipsis. + +'PS0' + The value of this parameter is expanded like PS1 and displayed by + interactive shells after reading a command and before the command + is executed. + +'PS3' + The value of this variable is used as the prompt for the 'select' + command. If this variable is not set, the 'select' command prompts + with '#? ' + +'PS4' + The value is the prompt printed before the command line is echoed + when the '-x' option is set (*note The Set Builtin::). The first + character of 'PS4' is replicated multiple times, as necessary, to + indicate multiple levels of indirection. The default is '+ '. + +'PWD' + The current working directory as set by the 'cd' builtin. + +'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. + +'READLINE_LINE' + The contents of the Readline line buffer, for use with 'bind -x' + (*note Bash Builtins::). + +'READLINE_POINT' + The position of the insertion point in the Readline line buffer, + for use with 'bind -x' (*note Bash Builtins::). + +'REPLY' + The default variable for the 'read' builtin. + +'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. + +'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. + +'SHELLOPTS' + A colon-separated list of enabled shell options. Each word in the + list is a valid argument for the '-o' option to the 'set' builtin + command (*note The Set Builtin::). The options appearing in + 'SHELLOPTS' are those reported as 'on' by '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. + +'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. + +'TIMEFORMAT' + The value of this parameter is used as a format string specifying + how the timing information for pipelines prefixed with the 'time' + reserved word should be displayed. The '%' 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. + + '%%' + A literal '%'. + + '%[P][l]R' + The elapsed time in seconds. + + '%[P][l]U' + The number of CPU seconds spent in user mode. + + '%[P][l]S' + The number of CPU seconds spent in system mode. + + '%P' + The CPU percentage, computed as (%U + %S) / %R. + + The optional 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 P greater than 3 are + changed to 3. If P is not specified, the value 3 is used. + + The optional 'l' specifies a longer format, including minutes, of + the form MMmSS.FFs. The value of P determines whether or not the + fraction is included. + + If this variable is not set, Bash acts as if it had the value + $'\nreal\t%3lR\nuser\t%3lU\nsys\t%3lS' + If the value is null, no timing information is displayed. A + trailing newline is added when the format string is displayed. + +'TMOUT' + If set to a value greater than zero, 'TMOUT' is treated as the + default timeout for the 'read' builtin (*note Bash Builtins::). + The 'select' command (*note Conditional Constructs::) terminates if + input does not arrive after '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 a line of input after issuing the primary + prompt. Bash terminates after waiting for that number of seconds + if a complete line of input does not arrive. + +'TMPDIR' + If set, Bash uses its value as the name of a directory in which + Bash creates temporary files for the shell's use. + +'UID' + The numeric real user id of the current user. This variable is + readonly. + + +File: bash.info, Node: Bash Features, Next: Job Control, Prev: Shell Variables, Up: Top + +6 Bash Features +*************** + +This chapter 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 'test' builtin. +* Shell Arithmetic:: Arithmetic on shell variables. +* Aliases:: Substituting one command for another. +* Arrays:: Array Variables. +* The Directory Stack:: History of visited directories. +* Controlling the Prompt:: Customizing the various prompt strings. +* The Restricted Shell:: A more controlled mode of shell execution. +* Bash POSIX Mode:: Making Bash behave more closely to what + the POSIX standard specifies. + + +File: bash.info, Node: Invoking Bash, Next: Bash Startup Files, Up: Bash Features + +6.1 Invoking Bash +================= + + bash [long-opt] [-ir] [-abefhkmnptuvxdBCDHP] [-o OPTION] [-O SHOPT_OPTION] [ARGUMENT ...] + bash [long-opt] [-abefhkmnptuvxdBCDHP] [-o OPTION] [-O SHOPT_OPTION] -c STRING [ARGUMENT ...] + bash [long-opt] -s [-abefhkmnptuvxdBCDHP] [-o OPTION] [-O SHOPT_OPTION] [ARGUMENT ...] + + All of the single-character options used with the 'set' builtin +(*note The Set Builtin::) can be used as options when the shell is +invoked. In addition, 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. + +'--debugger' + Arrange for the debugger profile to be executed before the shell + starts. Turns on extended debugging mode (see *note The Shopt + Builtin:: for a description of the 'extdebug' option to the 'shopt' + builtin). + +'--dump-po-strings' + A list of all double-quoted strings preceded by '$' is printed on + the standard output in the GNU 'gettext' PO (portable object) file + format. Equivalent to '-D' except for the output format. + +'--dump-strings' + Equivalent to '-D'. + +'--help' + Display a usage message on standard output and exit successfully. + +'--init-file FILENAME' +'--rcfile FILENAME' + Execute commands from FILENAME (instead of '~/.bashrc') in an + interactive shell. + +'--login' + Equivalent to '-l'. + +'--noediting' + Do not use the GNU Readline library (*note Command Line Editing::) + to read command lines when the shell is interactive. + +'--noprofile' + Don't load the system-wide startup file '/etc/profile' or any of + the personal initialization files '~/.bash_profile', + '~/.bash_login', or '~/.profile' when Bash is invoked as a login + shell. + +'--norc' + Don't read the '~/.bashrc' initialization file in an interactive + shell. This is on by default if the shell is invoked as 'sh'. + +'--posix' + Change the behavior of Bash where the default operation differs + from the POSIX standard to match the standard. This is intended to + make Bash behave as a strict superset of that standard. *Note Bash + POSIX Mode::, for a description of the Bash POSIX mode. + +'--restricted' + Make the shell a restricted shell (*note The Restricted Shell::). + +'--verbose' + Equivalent to '-v'. Print shell input lines as they're read. + +'--version' + Show version information for this instance of Bash on the standard + output and exit successfully. + + There are several single-character options that may be supplied at +invocation which are not available with the 'set' builtin. + +'-c' + Read and execute commands from the first non-option argument + COMMAND_STRING, then exit. If there are arguments after the + COMMAND_STRING, the first argument is assigned to '$0' and any + remaining arguments are assigned to the positional parameters. The + assignment to '$0' sets the name of the shell, which is used in + warning and error messages. + +'-i' + Force the shell to run interactively. Interactive shells are + described in *note Interactive Shells::. + +'-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 'exec -l bash'. When the shell is not + interactive, the login shell startup files will be executed. 'exec + bash -l' or 'exec bash --login' will replace the current shell with + a Bash login shell. *Note Bash Startup Files::, for a description + of the special behavior of a login shell. + +'-r' + Make the shell a restricted shell (*note The Restricted Shell::). + +'-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. + +'-D' + A list of all double-quoted strings preceded by '$' is printed on + the standard output. These are the strings that are subject to + language translation when the current locale is not 'C' or 'POSIX' + (*note Locale Translation::). This implies the '-n' option; no + commands will be executed. + +'[-+]O [SHOPT_OPTION]' + SHOPT_OPTION is one of the shell options accepted by the 'shopt' + builtin (*note The Shopt Builtin::). If SHOPT_OPTION is present, + '-O' sets the value of that option; '+O' unsets it. If + SHOPT_OPTION is not supplied, the names and values of the shell + options accepted by 'shopt' are printed on the standard output. If + the invocation option is '+O', the output is displayed in a format + that may be reused as input. + +'--' + A '--' signals the end of options and disables further option + processing. Any arguments after the '--' are treated as filenames + and arguments. + + A _login_ shell is one whose first character of argument zero is '-', +or one invoked with the '--login' option. + + An _interactive_ shell is one started without non-option arguments, +unless '-s' is specified, without specifying the '-c' option, and whose +input and output are both connected to terminals (as determined by +'isatty(3)'), or one started with the '-i' option. *Note Interactive +Shells::, for more information. + + If arguments remain after option processing, and neither the '-c' nor +the '-s' option has been supplied, the first argument is assumed to be +the name of a file containing shell commands (*note Shell Scripts::). +When Bash is invoked in this fashion, '$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. + + +File: bash.info, Node: Bash Startup Files, Next: Interactive Shells, Prev: Invoking Bash, Up: Bash Features + +6.2 Bash 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 filenames as described above under Tilde Expansion (*note +Tilde Expansion::). + + Interactive shells are described in *note Interactive Shells::. + +Invoked as an interactive login shell, or with '--login' +........................................................ + +When Bash is invoked as an interactive login shell, or as a +non-interactive shell with the '--login' option, it first reads and +executes commands from the file '/etc/profile', if that file exists. +After reading that file, it looks for '~/.bash_profile', +'~/.bash_login', and '~/.profile', in that order, and reads and executes +commands from the first one that exists and is readable. The +'--noprofile' option may be used when the shell is started to inhibit +this behavior. + + When an interactive login shell exits, or a non-interactive login +shell executes the 'exit' builtin command, Bash reads and executes +commands from the file '~/.bash_logout', if it exists. + +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 '~/.bashrc', if that file exists. This +may be inhibited by using the '--norc' option. The '--rcfile FILE' +option will force Bash to read and execute commands from FILE instead of +'~/.bashrc'. + + So, typically, your '~/.bash_profile' contains the line + if [ -f ~/.bashrc ]; then . ~/.bashrc; fi +after (or before) any login-specific initializations. + +Invoked non-interactively +......................... + +When Bash is started non-interactively, to run a shell script, for +example, it looks for the variable '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: + if [ -n "$BASH_ENV" ]; then . "$BASH_ENV"; fi +but the value of the 'PATH' variable is not used to search for the +filename. + + As noted above, if a non-interactive shell is invoked with the +'--login' option, Bash attempts to read and execute commands from the +login shell startup files. + +Invoked with name 'sh' +...................... + +If Bash is invoked with the name 'sh', it tries to mimic the startup +behavior of historical versions of 'sh' as closely as possible, while +conforming to the POSIX standard as well. + + When invoked as an interactive login shell, or as a non-interactive +shell with the '--login' option, it first attempts to read and execute +commands from '/etc/profile' and '~/.profile', in that order. The +'--noprofile' option may be used to inhibit this behavior. When invoked +as an interactive shell with the name 'sh', Bash looks for the variable +'ENV', expands its value if it is defined, and uses the expanded value +as the name of a file to read and execute. Since a shell invoked as +'sh' does not attempt to read and execute commands from any other +startup files, the '--rcfile' option has no effect. A non-interactive +shell invoked with the name 'sh' does not attempt to read any other +startup files. + + When invoked as 'sh', Bash enters POSIX mode after the startup files +are read. + +Invoked in POSIX mode +..................... + +When Bash is started in POSIX mode, as with the '--posix' command line +option, it follows the POSIX standard for startup files. In this mode, +interactive shells expand the 'ENV' variable and commands are read and +executed from the file whose name is the expanded value. No other +startup files are read. + +Invoked by remote shell daemon +.............................. + +Bash attempts to determine when it is being run with its standard input +connected to a network connection, as when executed by the remote shell +daemon, usually 'rshd', or the secure shell daemon 'sshd'. If Bash +determines it is being run in this fashion, it reads and executes +commands from '~/.bashrc', if that file exists and is readable. It will +not do this if invoked as 'sh'. The '--norc' option may be used to +inhibit this behavior, and the '--rcfile' option may be used to force +another file to be read, but neither 'rshd' nor 'sshd' generally invoke +the shell with those options or allow them to be specified. + +Invoked with unequal effective and real UID/GIDs +................................................ + +If Bash is started with the effective user (group) id not equal to the +real user (group) id, and the '-p' option is not supplied, no startup +files are read, shell functions are not inherited from the environment, +the 'SHELLOPTS', 'BASHOPTS', 'CDPATH', and 'GLOBIGNORE' variables, if +they appear in the environment, are ignored, and the effective user id +is set to the real user id. If the '-p' option is supplied at +invocation, the startup behavior is the same, but the effective user id +is not reset. + + +File: bash.info, Node: Interactive Shells, Next: Bash Conditional Expressions, Prev: Bash Startup Files, Up: Bash Features + +6.3 Interactive Shells +====================== + +* 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? + + +File: bash.info, Node: What is an Interactive Shell?, Next: Is this Shell Interactive?, Up: Interactive Shells + +6.3.1 What is an Interactive Shell? +----------------------------------- + +An interactive shell is one started without non-option arguments, unless +'-s' is specified, without specifying the '-c' option, and whose input +and error output are both connected to terminals (as determined by +'isatty(3)'), or one started with the '-i' option. + + An interactive shell generally reads from and writes to a user's +terminal. + + The '-s' invocation option may be used to set the positional +parameters when an interactive shell is started. + + +File: bash.info, Node: Is this Shell Interactive?, Next: Interactive Shell Behavior, Prev: What is an Interactive Shell?, Up: Interactive Shells + +6.3.2 Is this Shell Interactive? +-------------------------------- + +To determine within a startup script whether or not Bash is running +interactively, test the value of the '-' special parameter. It contains +'i' when the shell is interactive. For example: + + case "$-" in + *i*) echo This shell is interactive ;; + *) echo This shell is not interactive ;; + esac + + Alternatively, startup scripts may examine the variable 'PS1'; it is +unset in non-interactive shells, and set in interactive shells. Thus: + + if [ -z "$PS1" ]; then + echo This shell is not interactive + else + echo This shell is interactive + fi + + +File: bash.info, Node: Interactive Shell Behavior, Prev: Is this Shell Interactive?, Up: Interactive Shells + +6.3.3 Interactive Shell Behavior +-------------------------------- + +When the shell is running interactively, it changes its behavior in +several ways. + + 1. Startup files are read and executed as described in *note Bash + Startup Files::. + + 2. Job Control (*note Job Control::) is enabled by default. When job + control is in effect, Bash ignores the keyboard-generated job + control signals 'SIGTTIN', 'SIGTTOU', and 'SIGTSTP'. + + 3. Bash expands and displays 'PS1' before reading the first line of a + command, and expands and displays 'PS2' before reading the second + and subsequent lines of a multi-line command. Bash displays 'PS0' + after it reads a command but before executing it. + + 4. Bash executes the value of the 'PROMPT_COMMAND' variable as a + command before printing the primary prompt, '$PS1' (*note Bash + Variables::). + + 5. Readline (*note Command Line Editing::) is used to read commands + from the user's terminal. + + 6. Bash inspects the value of the 'ignoreeof' option to 'set -o' + instead of exiting immediately when it receives an 'EOF' on its + standard input when reading a command (*note The Set Builtin::). + + 7. Command history (*note Bash History Facilities::) and history + expansion (*note History Interaction::) are enabled by default. + Bash will save the command history to the file named by '$HISTFILE' + when a shell with history enabled exits. + + 8. Alias expansion (*note Aliases::) is performed by default. + + 9. In the absence of any traps, Bash ignores 'SIGTERM' (*note + Signals::). + + 10. In the absence of any traps, 'SIGINT' is caught and handled + ((*note Signals::). 'SIGINT' will interrupt some shell builtins. + + 11. An interactive login shell sends a 'SIGHUP' to all jobs on exit if + the 'huponexit' shell option has been enabled (*note Signals::). + + 12. The '-n' invocation option is ignored, and 'set -n' has no effect + (*note The Set Builtin::). + + 13. Bash will check for mail periodically, depending on the values of + the 'MAIL', 'MAILPATH', and 'MAILCHECK' shell variables (*note Bash + Variables::). + + 14. Expansion errors due to references to unbound shell variables + after 'set -u' has been enabled will not cause the shell to exit + (*note The Set Builtin::). + + 15. The shell will not exit on expansion errors caused by VAR being + unset or null in '${VAR:?WORD}' expansions (*note Shell Parameter + Expansion::). + + 16. Redirection errors encountered by shell builtins will not cause + the shell to exit. + + 17. When running in POSIX mode, a special builtin returning an error + status will not cause the shell to exit (*note Bash POSIX Mode::). + + 18. A failed 'exec' will not cause the shell to exit (*note Bourne + Shell Builtins::). + + 19. Parser syntax errors will not cause the shell to exit. + + 20. Simple spelling correction for directory arguments to the 'cd' + builtin is enabled by default (see the description of the 'cdspell' + option to the 'shopt' builtin in *note The Shopt Builtin::). + + 21. The shell will check the value of the 'TMOUT' variable and exit if + a command is not read within the specified number of seconds after + printing '$PS1' (*note Bash Variables::). + + +File: bash.info, Node: Bash Conditional Expressions, Next: Shell Arithmetic, Prev: Interactive Shells, Up: Bash Features + +6.4 Bash Conditional Expressions +================================ + +Conditional expressions are used by the '[[' compound command and the +'test' and '[' 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. Bash handles several filenames specially +when they are used in expressions. If the operating system on which +Bash is running provides these special files, Bash will use them; +otherwise it will emulate them internally with this behavior: If the +FILE argument to one of the primaries is of the form '/dev/fd/N', then +file descriptor N is checked. If the FILE argument to one of the +primaries is one of '/dev/stdin', '/dev/stdout', or '/dev/stderr', file +descriptor 0, 1, or 2, respectively, is checked. + + When used with '[[', the '<' and '>' operators sort lexicographically +using the current locale. The 'test' command uses ASCII ordering. + + Unless otherwise specified, primaries that operate on files follow +symbolic links and operate on the target of the link, rather than the +link itself. + +'-a FILE' + True if FILE exists. + +'-b FILE' + True if FILE exists and is a block special file. + +'-c FILE' + True if FILE exists and is a character special file. + +'-d FILE' + True if FILE exists and is a directory. + +'-e FILE' + True if FILE exists. + +'-f FILE' + True if FILE exists and is a regular file. + +'-g FILE' + True if FILE exists and its set-group-id bit is set. + +'-h FILE' + True if FILE exists and is a symbolic link. + +'-k FILE' + True if FILE exists and its "sticky" bit is set. + +'-p FILE' + True if FILE exists and is a named pipe (FIFO). + +'-r FILE' + True if FILE exists and is readable. + +'-s FILE' + True if FILE exists and has a size greater than zero. + +'-t FD' + True if file descriptor FD is open and refers to a terminal. + +'-u FILE' + True if FILE exists and its set-user-id bit is set. + +'-w FILE' + True if FILE exists and is writable. + +'-x FILE' + True if FILE exists and is executable. + +'-G FILE' + True if FILE exists and is owned by the effective group id. + +'-L FILE' + True if FILE exists and is a symbolic link. + +'-N FILE' + True if FILE exists and has been modified since it was last read. + +'-O FILE' + True if FILE exists and is owned by the effective user id. + +'-S FILE' + True if FILE exists and is a socket. + +'FILE1 -ef FILE2' + True if FILE1 and FILE2 refer to the same device and inode numbers. + +'FILE1 -nt FILE2' + True if FILE1 is newer (according to modification date) than FILE2, + or if FILE1 exists and FILE2 does not. + +'FILE1 -ot FILE2' + True if FILE1 is older than FILE2, or if FILE2 exists and FILE1 + does not. + +'-o OPTNAME' + True if the shell option OPTNAME is enabled. The list of options + appears in the description of the '-o' option to the 'set' builtin + (*note The Set Builtin::). + +'-v VARNAME' + True if the shell variable VARNAME is set (has been assigned a + value). + +'-R VARNAME' + True if the shell variable VARNAME is set and is a name reference. + +'-z STRING' + True if the length of STRING is zero. + +'-n STRING' +'STRING' + True if the length of STRING is non-zero. + +'STRING1 == STRING2' +'STRING1 = STRING2' + True if the strings are equal. When used with the '[[' command, + this performs pattern matching as described above (*note + Conditional Constructs::). + + '=' should be used with the 'test' command for POSIX conformance. + +'STRING1 != STRING2' + True if the strings are not equal. + +'STRING1 < STRING2' + True if STRING1 sorts before STRING2 lexicographically. + +'STRING1 > STRING2' + True if STRING1 sorts after STRING2 lexicographically. + +'ARG1 OP ARG2' + 'OP' is one of '-eq', '-ne', '-lt', '-le', '-gt', or '-ge'. These + arithmetic binary operators return true if ARG1 is equal to, not + equal to, less than, less than or equal to, greater than, or + greater than or equal to ARG2, respectively. ARG1 and ARG2 may be + positive or negative integers. + + +File: bash.info, Node: Shell Arithmetic, Next: Aliases, Prev: Bash Conditional Expressions, Up: Bash Features + +6.5 Shell Arithmetic +==================== + +The shell allows arithmetic expressions to be evaluated, as one of the +shell expansions or by using the '((' compound command, the 'let' +builtin, or the '-i' option to the 'declare' builtin. + + 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. + +'ID++ ID--' + variable post-increment and post-decrement + +'++ID --ID' + variable pre-increment and pre-decrement + +'- +' + unary minus and plus + +'! ~' + logical and bitwise negation + +'**' + exponentiation + +'* / %' + multiplication, division, remainder + +'+ -' + addition, subtraction + +'<< >>' + left and right bitwise shifts + +'<= >= < >' + comparison + +'== !=' + equality and inequality + +'&' + bitwise AND + +'^' + bitwise exclusive OR + +'|' + bitwise OR + +'&&' + logical AND + +'||' + logical OR + +'expr ? expr : expr' + conditional operator + +'= *= /= %= += -= <<= >>= &= ^= |=' + assignment + +'expr1 , expr2' + comma + + 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 INTEGER attribute using '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 '0x' or '0X' denotes hexadecimal. Otherwise, numbers take the +form [BASE'#']N, where the optional BASE is a decimal number between 2 +and 64 representing the arithmetic base, and N is a number in that base. +If BASE'#' is omitted, then base 10 is used. When specifying N, the +digits greater than 9 are represented by the lowercase letters, the +uppercase letters, '@', and '_', in that order. If 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. + + +File: bash.info, Node: Aliases, Next: Arrays, Prev: Shell Arithmetic, Up: Bash Features + +6.6 Aliases +=========== + +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 'alias' and '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 '/', '$', '`', '=' 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 +'ls' to '"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 BLANK, then the next command word following the alias is also +checked for alias expansion. + + Aliases are created and listed with the 'alias' command, and removed +with the 'unalias' command. + + There is no mechanism for using arguments in the replacement text, as +in 'csh'. If arguments are needed, a shell function should be used +(*note Shell Functions::). + + Aliases are not expanded when the shell is not interactive, unless +the 'expand_aliases' shell option is set using 'shopt' (*note 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 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 'alias' in compound commands. + + For almost every purpose, shell functions are preferred over aliases. + + +File: bash.info, Node: Arrays, Next: The Directory Stack, Prev: Aliases, Up: Bash Features + +6.7 Arrays +========== + +Bash provides one-dimensional indexed and associative array variables. +Any variable may be used as an indexed array; the '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. Indexed arrays are referenced using integers (including +arithmetic expressions (*note Shell Arithmetic::)) and are zero-based; +associative arrays use arbitrary strings. Unless otherwise noted, +indexed array indices must be non-negative integers. + + An indexed array is created automatically if any variable is assigned +to using the syntax + NAME[SUBSCRIPT]=VALUE + +The SUBSCRIPT is treated as an arithmetic expression that must evaluate +to a number. To explicitly declare an array, use + declare -a NAME +The syntax + declare -a NAME[SUBSCRIPT] +is also accepted; the SUBSCRIPT is ignored. + +Associative arrays are created using + declare -A NAME. + + Attributes may be specified for an array variable using the 'declare' +and 'readonly' builtins. Each attribute applies to all members of an +array. + + Arrays are assigned to using compound assignments of the form + NAME=(VALUE1 VALUE2 ... ) +where each VALUE is of the form '[SUBSCRIPT]='STRING. Indexed array +assignments do not require anything but STRING. When assigning to +indexed arrays, 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. + + When assigning to an associative array, the subscript is required. + + This syntax is also accepted by the 'declare' builtin. Individual +array elements may be assigned to using the 'NAME[SUBSCRIPT]=VALUE' +syntax introduced above. + + When assigning to an indexed array, if NAME is subscripted by a +negative number, that number is interpreted as relative to one greater +than the maximum index of NAME, so negative indices count back from the +end of the array, and an index of -1 references the last element. + + Any element of an array may be referenced using '${NAME[SUBSCRIPT]}'. +The braces are required to avoid conflicts with the shell's filename +expansion operators. If the SUBSCRIPT is '@' or '*', the word expands +to all members of the array NAME. These subscripts differ only when the +word appears within double quotes. If the word is double-quoted, +'${NAME[*]}' expands to a single word with the value of each array +member separated by the first character of the 'IFS' variable, and +'${NAME[@]}' expands each element of NAME to a separate word. When +there are no array members, '${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 '@' and '*'. '${#NAME[SUBSCRIPT]}' expands to the length of +'${NAME[SUBSCRIPT]}'. If SUBSCRIPT is '@' or '*', the expansion is the +number of elements in the array. If the SUBSCRIPT used to reference an +element of an indexed array evaluates to a number less than zero, it is +interpreted as relative to one greater than the maximum index of the +array, so negative indices count back from the end of the array, and an +index of -1 refers to the last element. + + Referencing an array variable without a subscript is equivalent to +referencing with a subscript of 0. Any reference to a variable using a +valid subscript is legal, and 'bash' will create an array if necessary. + + An array variable is considered set if a subscript has been assigned +a value. The null string is a valid value. + + It is possible to obtain the keys (indices) of an array as well as +the values. ${!NAME[@]} and ${!NAME[*]} expand to the indices assigned +in array variable NAME. The treatment when in double quotes is similar +to the expansion of the special parameters '@' and '*' within double +quotes. + + The 'unset' builtin is used to destroy arrays. 'unset +NAME[SUBSCRIPT]' destroys the array element at index SUBSCRIPT. +Negative subscripts to indexed arrays are interpreted as described +above. Care must be taken to avoid unwanted side effects caused by +filename expansion. 'unset NAME', where NAME is an array, removes the +entire array. A subscript of '*' or '@' also removes the entire array. + + The 'declare', 'local', and 'readonly' builtins each accept a '-a' +option to specify an indexed array and a '-A' option to specify an +associative array. If both options are supplied, '-A' takes precedence. +The 'read' builtin accepts a '-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 'set' and 'declare' +builtins display array values in a way that allows them to be reused as +input. + + +File: bash.info, Node: The Directory Stack, Next: Controlling the Prompt, Prev: Arrays, Up: Bash Features + +6.8 The Directory Stack +======================= + +* Menu: + +* Directory Stack Builtins:: Bash builtin commands to manipulate + the directory stack. + +The directory stack is a list of recently-visited directories. The +'pushd' builtin adds directories to the stack as it changes the current +directory, and the 'popd' builtin removes specified directories from the +stack and changes the current directory to the directory removed. The +'dirs' builtin displays the contents of the directory stack. The +current directory is always the "top" of the directory stack. + + The contents of the directory stack are also visible as the value of +the 'DIRSTACK' shell variable. + + +File: bash.info, Node: Directory Stack Builtins, Up: The Directory Stack + +6.8.1 Directory Stack Builtins +------------------------------ + +'dirs' + dirs [-clpv] [+N | -N] + + Display the list of currently remembered directories. Directories + are added to the list with the 'pushd' command; the 'popd' command + removes directories from the list. The current directory is always + the first directory in the stack. + + '-c' + Clears the directory stack by deleting all of the elements. + '-l' + Produces a listing using full pathnames; the default listing + format uses a tilde to denote the home directory. + '-p' + Causes 'dirs' to print the directory stack with one entry per + line. + '-v' + Causes 'dirs' to print the directory stack with one entry per + line, prefixing each entry with its index in the stack. + '+N' + Displays the Nth directory (counting from the left of the list + printed by 'dirs' when invoked without options), starting with + zero. + '-N' + Displays the Nth directory (counting from the right of the + list printed by 'dirs' when invoked without options), starting + with zero. + +'popd' + popd [-n] [+N | -N] + + When no arguments are given, 'popd' removes the top directory from + the stack and performs a 'cd' to the new top directory. The + elements are numbered from 0 starting at the first directory listed + with 'dirs'; that is, 'popd' is equivalent to 'popd +0'. + + '-n' + Suppresses the normal change of directory when removing + directories from the stack, so that only the stack is + manipulated. + '+N' + Removes the Nth directory (counting from the left of the list + printed by 'dirs'), starting with zero. + '-N' + Removes the Nth directory (counting from the right of the list + printed by 'dirs'), starting with zero. + +'pushd' + pushd [-n] [+N | -N | DIR] + + Save the current directory on the top of the directory stack and + then 'cd' to DIR. With no arguments, 'pushd' exchanges the top two + directories and makes the new top the current directory. + + '-n' + Suppresses the normal change of directory when rotating or + adding directories to the stack, so that only the stack is + manipulated. + '+N' + Brings the Nth directory (counting from the left of the list + printed by 'dirs', starting with zero) to the top of the list + by rotating the stack. + '-N' + Brings the Nth directory (counting from the right of the list + printed by 'dirs', starting with zero) to the top of the list + by rotating the stack. + 'DIR' + Makes DIR be the top of the stack, making it the new current + directory as if it had been supplied as an argument to the + 'cd' builtin. + + +File: bash.info, Node: Controlling the Prompt, Next: The Restricted Shell, Prev: The Directory Stack, Up: Bash Features + +6.9 Controlling the Prompt +========================== + +The value of the variable 'PROMPT_COMMAND' is examined just before Bash +prints each primary prompt. If '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 'PS1' to 'PS4': + +'\a' + A bell character. +'\d' + The date, in "Weekday Month Date" format (e.g., "Tue May 26"). +'\D{FORMAT}' + The FORMAT is passed to 'strftime'(3) and the result is inserted + into the prompt string; an empty FORMAT results in a + locale-specific time representation. The braces are required. +'\e' + An escape character. +'\h' + The hostname, up to the first '.'. +'\H' + The hostname. +'\j' + The number of jobs currently managed by the shell. +'\l' + The basename of the shell's terminal device name. +'\n' + A newline. +'\r' + A carriage return. +'\s' + The name of the shell, the basename of '$0' (the portion following + the final slash). +'\t' + The time, in 24-hour HH:MM:SS format. +'\T' + The time, in 12-hour HH:MM:SS format. +'\@' + The time, in 12-hour am/pm format. +'\A' + The time, in 24-hour HH:MM format. +'\u' + The username of the current user. +'\v' + The version of Bash (e.g., 2.00) +'\V' + The release of Bash, version + patchlevel (e.g., 2.00.0) +'\w' + The current working directory, with '$HOME' abbreviated with a + tilde (uses the '$PROMPT_DIRTRIM' variable). +'\W' + The basename of '$PWD', with '$HOME' abbreviated with a tilde. +'\!' + The history number of this command. +'\#' + The command number of this command. +'\$' + If the effective uid is 0, '#', otherwise '$'. +'\NNN' + The character whose ASCII code is the octal value NNN. +'\\' + A backslash. +'\[' + Begin a sequence of non-printing characters. This could be used to + embed a terminal control sequence into the prompt. +'\]' + End a sequence of non-printing characters. + + 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 (*note 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 'promptvars' shell option (*note Bash Builtins::). + + +File: bash.info, Node: The Restricted Shell, Next: Bash POSIX Mode, Prev: Controlling the Prompt, Up: Bash Features + +6.10 The Restricted Shell +========================= + +If Bash is started with the name 'rbash', or the '--restricted' or '-r' +option is supplied at invocation, the shell becomes restricted. A +restricted shell is used to set up an environment more controlled than +the standard shell. A restricted shell behaves identically to 'bash' +with the exception that the following are disallowed or not performed: + + * Changing directories with the 'cd' builtin. + * Setting or unsetting the values of the 'SHELL', 'PATH', 'ENV', or + 'BASH_ENV' variables. + * Specifying command names containing slashes. + * Specifying a filename containing a slash as an argument to the '.' + builtin command. + * Specifying a filename containing a slash as an argument to the '-p' + option to the 'hash' builtin command. + * Importing function definitions from the shell environment at + startup. + * Parsing the value of 'SHELLOPTS' from the shell environment at + startup. + * Redirecting output using the '>', '>|', '<>', '>&', '&>', and '>>' + redirection operators. + * Using the 'exec' builtin to replace the shell with another command. + * Adding or deleting builtin commands with the '-f' and '-d' options + to the 'enable' builtin. + * Using the 'enable' builtin command to enable disabled shell + builtins. + * Specifying the '-p' option to the 'command' builtin. + * Turning off restricted mode with 'set +r' or 'set +o restricted'. + + These restrictions are enforced after any startup files are read. + + When a command that is found to be a shell script is executed (*note +Shell Scripts::), 'rbash' turns off any restrictions in the shell +spawned to execute the script. + + +File: bash.info, Node: Bash POSIX Mode, Prev: The Restricted Shell, Up: Bash Features + +6.11 Bash POSIX Mode +==================== + +Starting Bash with the '--posix' command-line option or executing 'set +-o posix' while Bash is running will cause Bash to conform more closely +to the POSIX standard by changing the behavior to match that specified +by POSIX in areas where the Bash default differs. + + When invoked as 'sh', Bash enters POSIX mode after reading the +startup files. + + The following list is what's changed when 'POSIX mode' is in effect: + + 1. When a command in the hash table no longer exists, Bash will + re-search '$PATH' to find the new location. This is also available + with 'shopt -s checkhash'. + + 2. The message printed by the job control code and builtins when a job + exits with a non-zero status is 'Done(status)'. + + 3. The message printed by the job control code and builtins when a job + is stopped is 'Stopped(SIGNAME)', where SIGNAME is, for example, + 'SIGTSTP'. + + 4. Alias expansion is always enabled, even in non-interactive shells. + + 5. Reserved words appearing in a context where reserved words are + recognized do not undergo alias expansion. + + 6. The POSIX 'PS1' and 'PS2' expansions of '!' to the history number + and '!!' to '!' are enabled, and parameter expansion is performed + on the values of 'PS1' and 'PS2' regardless of the setting of the + 'promptvars' option. + + 7. The POSIX startup files are executed ('$ENV') rather than the + normal Bash files. + + 8. Tilde expansion is only performed on assignments preceding a + command name, rather than on all assignment statements on the line. + + 9. The default history file is '~/.sh_history' (this is the default + value of '$HISTFILE'). + + 10. Redirection operators do not perform filename expansion on the + word in the redirection unless the shell is interactive. + + 11. Redirection operators do not perform word splitting on the word in + the redirection. + + 12. Function names must be valid shell '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. + + 13. Function names may not be the same as one of the POSIX special + builtins. + + 14. POSIX special builtins are found before shell functions during + command lookup. + + 15. When printing shell function definitions (e.g., by 'type'), Bash + does not print the 'function' keyword. + + 16. Literal tildes that appear as the first character in elements of + the 'PATH' variable are not expanded as described above under *note + Tilde Expansion::. + + 17. The 'time' reserved word may be used by itself as a command. When + used in this way, it displays timing statistics for the shell and + its completed children. The 'TIMEFORMAT' variable controls the + format of the timing information. + + 18. When parsing and expanding a ${...} expansion that appears within + double quotes, single quotes are no longer special and cannot be + used to quote a closing brace or other special character, unless + the operator is one of those defined to perform pattern removal. + In this case, they do not have to appear as matched pairs. + + 19. The parser does not recognize 'time' as a reserved word if the + next token begins with a '-'. + + 20. The '!' character does not introduce history expansion within a + double-quoted string, even if the 'histexpand' option is enabled. + + 21. If a 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. + + 22. 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. + + 23. A non-interactive shell exits with an error status if a variable + assignment error occurs in an assignment statement preceding a + special builtin, but not with any other simple command. + + 24. A non-interactive shell exits with an error status if the + iteration variable in a 'for' statement or the selection variable + in a 'select' statement is a readonly variable. + + 25. Non-interactive shells exit if FILENAME in '.' FILENAME is not + found. + + 26. Non-interactive shells exit if a syntax error in an arithmetic + expansion results in an invalid expression. + + 27. Non-interactive shells exit if a parameter expansion error occurs. + + 28. Non-interactive shells exit if there is a syntax error in a script + read with the '.' or 'source' builtins, or in a string processed by + the 'eval' builtin. + + 29. Process substitution is not available. + + 30. While variable indirection is available, it may not be applied to + the '#' and '?' special parameters. + + 31. When expanding the '*' special parameter in a pattern context + where the expansion is double-quoted does not treat the '$*' as if + it were double-quoted. + + 32. Assignment statements preceding POSIX special builtins persist in + the shell environment after the builtin completes. + + 33. Assignment statements preceding shell function calls persist in + the shell environment after the function returns, as if a POSIX + special builtin command had been executed. + + 34. The 'command' builtin does not prevent builtins that take + assignment statements as arguments from expanding them as + assignment statements; when not in POSIX mode, assignment builtins + lose their assignment statement expansion properties when preceded + by 'command'. + + 35. The '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. + + 36. The output of 'kill -l' prints all the signal names on a single + line, separated by spaces, without the 'SIG' prefix. + + 37. The 'kill' builtin does not accept signal names with a 'SIG' + prefix. + + 38. The 'export' and 'readonly' builtin commands display their output + in the format required by POSIX. + + 39. The 'trap' builtin displays signal names without the leading + 'SIG'. + + 40. The '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 '-' as the first argument. + + 41. The '.' and 'source' builtins do not search the current directory + for the filename argument if it is not found by searching 'PATH'. + + 42. Enabling POSIX mode has the effect of setting the + 'inherit_errexit' option, so subshells spawned to execute command + substitutions inherit the value of the '-e' option from the parent + shell. When the 'inherit_errexit' option is not enabled, Bash + clears the '-e' option in such subshells. + + 43. When the 'alias' builtin displays alias definitions, it does not + display them with a leading 'alias ' unless the '-p' option is + supplied. + + 44. When the 'set' builtin is invoked without options, it does not + display shell function names and definitions. + + 45. When the 'set' builtin is invoked without options, it displays + variable values without quotes, unless they contain shell + metacharacters, even if the result contains nonprinting characters. + + 46. When the 'cd' builtin is invoked in LOGICAL mode, and the pathname + constructed from '$PWD' and the directory name supplied as an + argument does not refer to an existing directory, 'cd' will fail + instead of falling back to PHYSICAL mode. + + 47. The '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 '-P' option. + + 48. When listing the history, the 'fc' builtin does not include an + indication of whether or not a history entry has been modified. + + 49. The default editor used by 'fc' is 'ed'. + + 50. The 'type' and '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 '$PATH'. + + 51. The 'vi' editing mode will invoke the 'vi' editor directly when + the 'v' command is run, instead of checking '$VISUAL' and + '$EDITOR'. + + 52. When the 'xpg_echo' option is enabled, Bash does not attempt to + interpret any arguments to 'echo' as options. Each argument is + displayed, after escape characters are converted. + + 53. The 'ulimit' builtin uses a block size of 512 bytes for the '-c' + and '-f' options. + + 54. The arrival of 'SIGCHLD' when a trap is set on 'SIGCHLD' does not + interrupt the 'wait' builtin and cause it to return immediately. + The trap command is run once for each child that exits. + + 55. The 'read' builtin may be interrupted by a signal for which a trap + has been set. If Bash receives a trapped signal while executing + 'read', the trap handler executes and 'read' returns an exit status + greater than 128. + + 56. Bash removes an exited background process's status from the list + of such statuses after the 'wait' builtin is used to obtain it. + + There is other POSIX behavior that Bash does not implement by default +even when in POSIX mode. Specifically: + + 1. The 'fc' builtin checks '$EDITOR' as a program to edit history + entries if 'FCEDIT' is unset, rather than defaulting directly to + 'ed'. 'fc' uses 'ed' if 'EDITOR' is unset. + + 2. As noted above, Bash requires the 'xpg_echo' option to be enabled + for the 'echo' builtin to be fully conformant. + + Bash can be configured to be POSIX-conformant by default, by +specifying the '--enable-strict-posix-default' to 'configure' when +building (*note Optional Features::). + + +File: bash.info, Node: Job Control, Next: Command Line Editing, Prev: Bash Features, Up: Top + +7 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. + + +File: bash.info, Node: Job Control Basics, Next: Job Control Builtins, Up: Job Control + +7.1 Job Control Basics +====================== + +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 operating system kernel's terminal +driver and Bash. + + The shell associates a JOB with each pipeline. It keeps a table of +currently executing jobs, which may be listed with the 'jobs' command. +When Bash starts a job asynchronously, it prints a line that looks like: + [1] 25647 +indicating that this job is job number 1 and that the process 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 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 ID. Members of this process group (processes whose +process group ID is equal to the current terminal process group ID) +receive keyboard-generated signals such as 'SIGINT'. These processes +are said to be in the foreground. Background processes are those whose +process group ID differs from the terminal's; such processes are immune +to keyboard-generated signals. Only foreground processes are allowed to +read from or, if the user so specifies with 'stty tostop', write to the +terminal. Background processes which attempt to read from (write to +when 'stty tostop' is in effect) the terminal are sent a 'SIGTTIN' +('SIGTTOU') signal by the kernel's 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 SUSPEND +character (typically '^Z', Control-Z) while a process is running causes +that process to be stopped and returns control to Bash. Typing the +DELAYED SUSPEND character (typically '^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 'bg' command to continue it in the background, the +'fg' command to continue it in the foreground, or the 'kill' command to +kill it. A '^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 '%' introduces a job specification (JOBSPEC). + + Job number 'n' may be referred to as '%n'. The symbols '%%' and '%+' +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 '%' (with no accompanying job specification) also refers to the +current job. The previous job may be referenced using '%-'. If there +is only a single job, '%+' and '%-' can both be used to refer to that +job. In output pertaining to jobs (e.g., the output of the 'jobs' +command), the current job is always flagged with a '+', and the previous +job with a '-'. + + 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, '%ce' refers to a stopped 'ce' job. Using '%?ce', on the other +hand, refers to any job containing the string '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: '%1' +is a synonym for 'fg %1', bringing job 1 from the background into the +foreground. Similarly, '%1 &' resumes job 1 in the background, +equivalent to '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 '-b' +option to the 'set' builtin is enabled, Bash reports such changes +immediately (*note The Set Builtin::). Any trap on 'SIGCHLD' is +executed for each child process that exits. + + If an attempt to exit Bash is made while jobs are stopped, (or +running, if the 'checkjobs' option is enabled - see *note The Shopt +Builtin::), the shell prints a warning message, and if the 'checkjobs' +option is enabled, lists the jobs and their statuses. The '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 any stopped jobs are terminated. + + +File: bash.info, Node: Job Control Builtins, Next: Job Control Variables, Prev: Job Control Basics, Up: Job Control + +7.2 Job Control Builtins +======================== + +'bg' + bg [JOBSPEC ...] + + Resume each suspended job JOBSPEC in the background, as if it had + been started with '&'. If 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 + JOBSPEC was not found or specifies a job that was started without + job control. + +'fg' + fg [JOBSPEC] + + Resume the job JOBSPEC in the foreground and make it the current + job. If 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, JOBSPEC does not specify a valid job or JOBSPEC + specifies a job that was started without job control. + +'jobs' + jobs [-lnprs] [JOBSPEC] + jobs -x COMMAND [ARGUMENTS] + + The first form lists the active jobs. The options have the + following meanings: + + '-l' + List process IDs in addition to the normal information. + + '-n' + Display information only about jobs that have changed status + since the user was last notified of their status. + + '-p' + List only the process ID of the job's process group leader. + + '-r' + Display only running jobs. + + '-s' + Display only stopped jobs. + + If JOBSPEC is given, output is restricted to information about that + job. If JOBSPEC is not supplied, the status of all jobs is listed. + + If the '-x' option is supplied, 'jobs' replaces any JOBSPEC found + in COMMAND or ARGUMENTS with the corresponding process group ID, + and executes COMMAND, passing it ARGUMENTs, returning its exit + status. + +'kill' + kill [-s SIGSPEC] [-n SIGNUM] [-SIGSPEC] JOBSPEC or PID + kill -l|-L [EXIT_STATUS] + + Send a signal specified by SIGSPEC or SIGNUM to the process named + by job specification JOBSPEC or process ID PID. SIGSPEC is either + a case-insensitive signal name such as 'SIGINT' (with or without + the 'SIG' prefix) or a signal number; SIGNUM is a signal number. + If SIGSPEC and SIGNUM are not present, 'SIGTERM' is used. The '-l' + option lists the signal names. If any arguments are supplied when + '-l' is given, the names of the signals corresponding to the + arguments are listed, and the return status is zero. EXIT_STATUS + is a number specifying a signal number or the exit status of a + process terminated by a signal. The '-L' option is equivalent to + '-l'. 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. + +'wait' + wait [-n] [JOBSPEC or PID ...] + + Wait until the child process specified by each process ID PID or + job specification 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 the '-n' option is supplied, 'wait' waits for any job to + terminate and returns its exit status. If neither JOBSPEC nor PID + specifies an active child process of the shell, the return status + is 127. + +'disown' + disown [-ar] [-h] [JOBSPEC ... | PID ... ] + + Without options, remove each JOBSPEC from the table of active jobs. + If the '-h' option is given, the job is not removed from the table, + but is marked so that 'SIGHUP' is not sent to the job if the shell + receives a 'SIGHUP'. If JOBSPEC is not present, and neither the + '-a' nor the '-r' option is supplied, the current job is used. If + no JOBSPEC is supplied, the '-a' option means to remove or mark all + jobs; the '-r' option without a JOBSPEC argument restricts + operation to running jobs. + +'suspend' + suspend [-f] + + Suspend the execution of this shell until it receives a 'SIGCONT' + signal. A login shell cannot be suspended; the '-f' option can be + used to override this and force the suspension. + + When job control is not active, the 'kill' and 'wait' builtins do not +accept JOBSPEC arguments. They must be supplied process IDs. + + +File: bash.info, Node: Job Control Variables, Prev: Job Control Builtins, Up: Job Control + +7.3 Job Control Variables +========================= + +'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 'exact', the string supplied + must match the name of a stopped job exactly; if set to + 'substring', the string supplied needs to match a substring of the + name of a stopped job. The 'substring' value provides + functionality analogous to the '%?' job ID (*note Job Control + 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 '%' job ID. + + +File: bash.info, Node: Command Line Editing, Next: Using History Interactively, Prev: Job Control, Up: Top + +8 Command Line Editing +********************** + +This chapter describes the basic features of the GNU command line +editing interface. Command line editing is provided by the Readline +library, which is used by several different programs, including Bash. +Command line editing is enabled by default when using an interactive +shell, unless the '--noediting' option is supplied at shell invocation. +Line editing is also used when using the '-e' option to the 'read' +builtin command (*note Bash Builtins::). By default, the line editing +commands are similar to those of Emacs. A vi-style line editing +interface is also available. Line editing can be enabled at any time +using the '-o emacs' or '-o vi' options to the 'set' builtin command +(*note The Set Builtin::), or disabled using the '+o emacs' or '+o vi' +options to 'set'. + +* Menu: + +* Introduction and Notation:: Notation used in this text. +* Readline Interaction:: The minimum set of commands for editing a line. +* Readline Init File:: Customizing Readline from a user's view. +* Bindable Readline Commands:: A description of most of the Readline commands + available for binding +* Readline vi Mode:: A short description of how to make Readline + behave like the vi editor. +* Programmable Completion:: How to specify the possible completions for + a specific command. +* Programmable Completion Builtins:: Builtin commands to specify how to + complete arguments for a particular command. +* A Programmable Completion Example:: An example shell function for + generating possible completions. + + +File: bash.info, Node: Introduction and Notation, Next: Readline Interaction, Up: Command Line Editing + +8.1 Introduction to Line Editing +================================ + +The following paragraphs describe the notation used to represent +keystrokes. + + The text 'C-k' is read as 'Control-K' and describes the character +produced when the key is pressed while the Control key is depressed. + + The text 'M-k' is read as 'Meta-K' and describes the character +produced when the Meta key (if you have one) is depressed, and the +key is pressed. The Meta key is labeled on many keyboards. On +keyboards with two keys labeled (usually to either side of the +space bar), the on the left side is generally set to work as a +Meta key. The key on the right may also be configured to work as +a Meta key or may be configured as some other modifier, such as a +Compose key for typing accented characters. + + If you do not have a Meta or key, or another key working as a +Meta key, the identical keystroke can be generated by typing +_first_, and then typing . Either process is known as "metafying" +the key. + + The text 'M-C-k' is read as 'Meta-Control-k' and describes the +character produced by "metafying" 'C-k'. + + In addition, several keys have their own names. Specifically, , +, , , , and all stand for themselves when seen +in this text, or in an init file (*note Readline Init File::). If your +keyboard lacks a key, typing will produce the desired +character. The key may be labeled or on some +keyboards. + + +File: bash.info, Node: Readline Interaction, Next: Readline Init File, Prev: Introduction and Notation, Up: Command Line Editing + +8.2 Readline Interaction +======================== + +Often during an interactive session you type in a long line of text, +only to notice that the first word on the line is misspelled. The +Readline library gives you a set of commands for manipulating the text +as you type it in, allowing you to just fix your typo, and not forcing +you to retype the majority of the line. Using these editing commands, +you move the cursor to the place that needs correction, and delete or +insert the text of the corrections. Then, when you are satisfied with +the line, you simply press . You do not have to be at the end of +the line to press ; the entire line is accepted regardless of the +location of the cursor within the line. + +* Menu: + +* Readline Bare Essentials:: The least you need to know about Readline. +* Readline Movement Commands:: Moving about the input line. +* Readline Killing Commands:: How to delete text, and how to get it back! +* Readline Arguments:: Giving numeric arguments to commands. +* Searching:: Searching through previous lines. + + +File: bash.info, Node: Readline Bare Essentials, Next: Readline Movement Commands, Up: Readline Interaction + +8.2.1 Readline Bare Essentials +------------------------------ + +In order to enter characters into the line, simply type them. The typed +character appears where the cursor was, and then the cursor moves one +space to the right. If you mistype a character, you can use your erase +character to back up and delete the mistyped character. + + Sometimes you may mistype a character, and not notice the error until +you have typed several other characters. In that case, you can type +'C-b' to move the cursor to the left, and then correct your mistake. +Afterwards, you can move the cursor to the right with 'C-f'. + + When you add text in the middle of a line, you will notice that +characters to the right of the cursor are 'pushed over' to make room for +the text that you have inserted. Likewise, when you delete text behind +the cursor, characters to the right of the cursor are 'pulled back' to +fill in the blank space created by the removal of the text. A list of +the bare essentials for editing the text of an input line follows. + +'C-b' + Move back one character. +'C-f' + Move forward one character. + or + Delete the character to the left of the cursor. +'C-d' + Delete the character underneath the cursor. +Printing characters + Insert the character into the line at the cursor. +'C-_' or 'C-x C-u' + Undo the last editing command. You can undo all the way back to an + empty line. + +(Depending on your configuration, the key be set to delete +the character to the left of the cursor and the key set to delete +the character underneath the cursor, like 'C-d', rather than the +character to the left of the cursor.) + + +File: bash.info, Node: Readline Movement Commands, Next: Readline Killing Commands, Prev: Readline Bare Essentials, Up: Readline Interaction + +8.2.2 Readline Movement Commands +-------------------------------- + +The above table describes the most basic keystrokes that you need in +order to do editing of the input line. For your convenience, many other +commands have been added in addition to 'C-b', 'C-f', 'C-d', and . +Here are some commands for moving more rapidly about the line. + +'C-a' + Move to the start of the line. +'C-e' + Move to the end of the line. +'M-f' + Move forward a word, where a word is composed of letters and + digits. +'M-b' + Move backward a word. +'C-l' + Clear the screen, reprinting the current line at the top. + + Notice how 'C-f' moves forward a character, while 'M-f' moves forward +a word. It is a loose convention that control keystrokes operate on +characters while meta keystrokes operate on words. + + +File: bash.info, Node: Readline Killing Commands, Next: Readline Arguments, Prev: Readline Movement Commands, Up: Readline Interaction + +8.2.3 Readline Killing Commands +------------------------------- + +"Killing" text means to delete the text from the line, but to save it +away for later use, usually by "yanking" (re-inserting) it back into the +line. ('Cut' and 'paste' are more recent jargon for 'kill' and 'yank'.) + + If the description for a command says that it 'kills' text, then you +can be sure that you can get the text back in a different (or the same) +place later. + + When you use a kill command, the text is saved in a "kill-ring". Any +number of consecutive kills save all of the killed text together, so +that when you yank it back, you get it all. The kill ring is not line +specific; the text that you killed on a previously typed line is +available to be yanked back later, when you are typing another line. + + Here is the list of commands for killing text. + +'C-k' + Kill the text from the current cursor position to the end of the + line. + +'M-d' + Kill from the cursor to the end of the current word, or, if between + words, to the end of the next word. Word boundaries are the same + as those used by 'M-f'. + +'M-' + Kill from the cursor the start of the current word, or, if between + words, to the start of the previous word. Word boundaries are the + same as those used by 'M-b'. + +'C-w' + Kill from the cursor to the previous whitespace. This is different + than 'M-' because the word boundaries differ. + + Here is how to "yank" the text back into the line. Yanking means to +copy the most-recently-killed text from the kill buffer. + +'C-y' + Yank the most recently killed text back into the buffer at the + cursor. + +'M-y' + Rotate the kill-ring, and yank the new top. You can only do this + if the prior command is 'C-y' or 'M-y'. + + +File: bash.info, Node: Readline Arguments, Next: Searching, Prev: Readline Killing Commands, Up: Readline Interaction + +8.2.4 Readline Arguments +------------------------ + +You can pass numeric arguments to Readline commands. Sometimes the +argument acts as a repeat count, other times it is the sign of the +argument that is significant. If you pass a negative argument to a +command which normally acts in a forward direction, that command will +act in a backward direction. For example, to kill text back to the +start of the line, you might type 'M-- C-k'. + + The general way to pass numeric arguments to a command is to type +meta digits before the command. If the first 'digit' typed is a minus +sign ('-'), then the sign of the argument will be negative. Once you +have typed one meta digit to get the argument started, you can type the +remainder of the digits, and then the command. For example, to give the +'C-d' command an argument of 10, you could type 'M-1 0 C-d', which will +delete the next ten characters on the input line. + + +File: bash.info, Node: Searching, Prev: Readline Arguments, Up: Readline Interaction + +8.2.5 Searching for Commands in the History +------------------------------------------- + +Readline provides commands for searching through the command history +(*note Bash History Facilities::) for lines containing a specified +string. There are two search modes: "incremental" and +"non-incremental". + + Incremental searches begin before the user has finished typing the +search string. As each character of the search string is typed, +Readline displays the next entry from the history matching the string +typed so far. An incremental search requires only as many characters as +needed to find the desired history entry. To search backward in the +history for a particular string, type 'C-r'. Typing 'C-s' searches +forward through the history. The characters present in the value of the +'isearch-terminators' variable are used to terminate an incremental +search. If that variable has not been assigned a value, the and +'C-J' characters will terminate an incremental search. 'C-g' will abort +an incremental search and restore the original line. When the search is +terminated, the history entry containing the search string becomes the +current line. + + To find other matching entries in the history list, type 'C-r' or +'C-s' as appropriate. This will search backward or forward in the +history for the next entry matching the search string typed so far. Any +other key sequence bound to a Readline command will terminate the search +and execute that command. For instance, a will terminate the +search and accept the line, thereby executing the command from the +history list. A movement command will terminate the search, make the +last line found the current line, and begin editing. + + Readline remembers the last incremental search string. If two 'C-r's +are typed without any intervening characters defining a new search +string, any remembered search string is used. + + Non-incremental searches read the entire search string before +starting to search for matching history lines. The search string may be +typed by the user or be part of the contents of the current line. + + +File: bash.info, Node: Readline Init File, Next: Bindable Readline Commands, Prev: Readline Interaction, Up: Command Line Editing + +8.3 Readline Init File +====================== + +Although the Readline library comes with a set of Emacs-like keybindings +installed by default, it is possible to use a different set of +keybindings. Any user can customize programs that use Readline by +putting commands in an "inputrc" file, conventionally in his home +directory. The name of this file is taken from the value of the shell +variable 'INPUTRC'. If that variable is unset, the default is +'~/.inputrc'. If that file does not exist or cannot be read, the +ultimate default is '/etc/inputrc'. + + When a program which uses the Readline library starts up, the init +file is read, and the key bindings are set. + + In addition, the 'C-x C-r' command re-reads this init file, thus +incorporating any changes that you might have made to it. + +* Menu: + +* Readline Init File Syntax:: Syntax for the commands in the inputrc file. + +* Conditional Init Constructs:: Conditional key bindings in the inputrc file. + +* Sample Init File:: An example inputrc file. + + +File: bash.info, Node: Readline Init File Syntax, Next: Conditional Init Constructs, Up: Readline Init File + +8.3.1 Readline Init File Syntax +------------------------------- + +There are only a few basic constructs allowed in the Readline init file. +Blank lines are ignored. Lines beginning with a '#' are comments. +Lines beginning with a '$' indicate conditional constructs (*note +Conditional Init Constructs::). Other lines denote variable settings +and key bindings. + +Variable Settings + You can modify the run-time behavior of Readline by altering the + values of variables in Readline using the 'set' command within the + init file. The syntax is simple: + + set VARIABLE VALUE + + Here, for example, is how to change from the default Emacs-like key + binding to use 'vi' line editing commands: + + set editing-mode vi + + Variable names and values, where appropriate, are recognized + without regard to case. Unrecognized variable names are ignored. + + Boolean variables (those that can be set to on or off) are set to + on if the value is null or empty, ON (case-insensitive), or 1. Any + other value results in the variable being set to off. + + The 'bind -V' command lists the current Readline variable names and + values. *Note Bash Builtins::. + + A great deal of run-time behavior is changeable with the following + variables. + + 'bell-style' + Controls what happens when Readline wants to ring the terminal + bell. If set to 'none', Readline never rings the bell. If + set to 'visible', Readline uses a visible bell if one is + available. If set to 'audible' (the default), Readline + attempts to ring the terminal's bell. + + 'bind-tty-special-chars' + If set to 'on' (the default), Readline attempts to bind the + control characters treated specially by the kernel's terminal + driver to their Readline equivalents. + + 'blink-matching-paren' + If set to 'on', Readline attempts to briefly move the cursor + to an opening parenthesis when a closing parenthesis is + inserted. The default is 'off'. + + 'colored-completion-prefix' + If set to 'on', when listing completions, Readline displays + the common prefix of the set of possible completions using a + different color. The color definitions are taken from the + value of the 'LS_COLORS' environment variable. The default is + 'off'. + + 'colored-stats' + If set to 'on', Readline displays possible completions using + different colors to indicate their file type. The color + definitions are taken from the value of the 'LS_COLORS' + environment variable. The default is 'off'. + + 'comment-begin' + The string to insert at the beginning of the line when the + 'insert-comment' command is executed. The default value is + '"#"'. + + 'completion-display-width' + The number of screen columns used to display possible matches + when performing completion. The value is ignored if it is + less than 0 or greater than the terminal screen width. A + value of 0 will cause matches to be displayed one per line. + The default value is -1. + + 'completion-ignore-case' + If set to 'on', Readline performs filename matching and + completion in a case-insensitive fashion. The default value + is 'off'. + + 'completion-map-case' + If set to 'on', and COMPLETION-IGNORE-CASE is enabled, + Readline treats hyphens ('-') and underscores ('_') as + equivalent when performing case-insensitive filename matching + and completion. + + 'completion-prefix-display-length' + The length in characters of the common prefix of a list of + possible completions that is displayed without modification. + When set to a value greater than zero, common prefixes longer + than this value are replaced with an ellipsis when displaying + possible completions. + + 'completion-query-items' + The number of possible completions that determines when the + user is asked whether the list of possibilities should be + displayed. If the number of possible completions is greater + than this value, Readline will ask the user whether or not he + wishes to view them; otherwise, they are simply listed. This + variable must be set to an integer value greater than or equal + to 0. A negative value means Readline should never ask. The + default limit is '100'. + + 'convert-meta' + If set to 'on', Readline will convert characters with the + eighth bit set to an ASCII key sequence by stripping the + eighth bit and prefixing an character, converting them + to a meta-prefixed key sequence. The default value is 'on', + but will be set to 'off' if the locale is one that contains + eight-bit characters. + + 'disable-completion' + If set to 'On', Readline will inhibit word completion. + Completion characters will be inserted into the line as if + they had been mapped to 'self-insert'. The default is 'off'. + + 'echo-control-characters' + When set to 'on', on operating systems that indicate they + support it, readline echoes a character corresponding to a + signal generated from the keyboard. The default is 'on'. + + 'editing-mode' + The 'editing-mode' variable controls which default set of key + bindings is used. By default, Readline starts up in Emacs + editing mode, where the keystrokes are most similar to Emacs. + This variable can be set to either 'emacs' or 'vi'. + + 'emacs-mode-string' + This string is displayed immediately before the last line of + the primary prompt when emacs editing mode is active. The + value is expanded like a key binding, so the standard set of + meta- and control prefixes and backslash escape sequences is + available. Use the '\1' and '\2' escapes to begin and end + sequences of non-printing characters, which can be used to + embed a terminal control sequence into the mode string. The + default is '@'. + + 'enable-bracketed-paste' + When set to 'On', Readline will configure the terminal in a + way that will enable it to insert each paste into the editing + buffer as a single string of characters, instead of treating + each character as if it had been read from the keyboard. This + can prevent pasted characters from being interpreted as + editing commands. The default is 'off'. + + 'enable-keypad' + When set to 'on', Readline will try to enable the application + keypad when it is called. Some systems need this to enable + the arrow keys. The default is 'off'. + + 'enable-meta-key' + When set to 'on', Readline will try to enable any meta + modifier key the terminal claims to support when it is called. + On many terminals, the meta key is used to send eight-bit + characters. The default is 'on'. + + 'expand-tilde' + If set to 'on', tilde expansion is performed when Readline + attempts word completion. The default is 'off'. + + 'history-preserve-point' + If set to 'on', the history code attempts to place the point + (the current cursor position) at the same location on each + history line retrieved with 'previous-history' or + 'next-history'. The default is 'off'. + + 'history-size' + Set the maximum number of history entries saved in the history + list. If set to zero, any existing history entries are + deleted and no new entries are saved. If set to a value less + than zero, the number of history entries is not limited. By + default, the number of history entries is not limited. If an + attempt is made to set HISTORY-SIZE to a non-numeric value, + the maximum number of history entries will be set to 500. + + 'horizontal-scroll-mode' + This variable can be set to either 'on' or 'off'. Setting it + to 'on' means that the text of the lines being edited will + scroll horizontally on a single screen line when they are + longer than the width of the screen, instead of wrapping onto + a new screen line. By default, this variable is set to 'off'. + + 'input-meta' + If set to 'on', Readline will enable eight-bit input (it will + not clear the eighth bit in the characters it reads), + regardless of what the terminal claims it can support. The + default value is 'off', but Readline will set it to 'on' if + the locale contains eight-bit characters. The name + 'meta-flag' is a synonym for this variable. + + 'isearch-terminators' + The string of characters that should terminate an incremental + search without subsequently executing the character as a + command (*note Searching::). If this variable has not been + given a value, the characters and 'C-J' will terminate + an incremental search. + + 'keymap' + Sets Readline's idea of the current keymap for key binding + commands. Acceptable 'keymap' names are 'emacs', + 'emacs-standard', 'emacs-meta', 'emacs-ctlx', 'vi', 'vi-move', + 'vi-command', and 'vi-insert'. 'vi' is equivalent to + 'vi-command' ('vi-move' is also a synonym); 'emacs' is + equivalent to 'emacs-standard'. The default value is 'emacs'. + The value of the 'editing-mode' variable also affects the + default keymap. + + 'keyseq-timeout' + Specifies the duration Readline will wait for a character when + reading an ambiguous key sequence (one that can form a + complete key sequence using the input read so far, or can take + additional input to complete a longer key sequence). If no + input is received within the timeout, Readline will use the + shorter but complete key sequence. Readline uses this value + to determine whether or not input is available on the current + input source ('rl_instream' by default). The value is + specified in milliseconds, so a value of 1000 means that + Readline will wait one second for additional input. If this + variable is set to a value less than or equal to zero, or to a + non-numeric value, Readline will wait until another key is + pressed to decide which key sequence to complete. The default + value is '500'. + + 'mark-directories' + If set to 'on', completed directory names have a slash + appended. The default is 'on'. + + 'mark-modified-lines' + This variable, when set to 'on', causes Readline to display an + asterisk ('*') at the start of history lines which have been + modified. This variable is 'off' by default. + + 'mark-symlinked-directories' + If set to 'on', completed names which are symbolic links to + directories have a slash appended (subject to the value of + 'mark-directories'). The default is 'off'. + + 'match-hidden-files' + This variable, when set to 'on', causes Readline to match + files whose names begin with a '.' (hidden files) when + performing filename completion. If set to 'off', the leading + '.' must be supplied by the user in the filename to be + completed. This variable is 'on' by default. + + 'menu-complete-display-prefix' + If set to 'on', menu completion displays the common prefix of + the list of possible completions (which may be empty) before + cycling through the list. The default is 'off'. + + 'output-meta' + If set to 'on', Readline will display characters with the + eighth bit set directly rather than as a meta-prefixed escape + sequence. The default is 'off', but Readline will set it to + 'on' if the locale contains eight-bit characters. + + 'page-completions' + If set to 'on', Readline uses an internal 'more'-like pager to + display a screenful of possible completions at a time. This + variable is 'on' by default. + + 'print-completions-horizontally' + If set to 'on', Readline will display completions with matches + sorted horizontally in alphabetical order, rather than down + the screen. The default is 'off'. + + 'revert-all-at-newline' + If set to 'on', Readline will undo all changes to history + lines before returning when 'accept-line' is executed. By + default, history lines may be modified and retain individual + undo lists across calls to 'readline'. The default is 'off'. + + 'show-all-if-ambiguous' + This alters the default behavior of the completion functions. + If set to 'on', words which have more than one possible + completion cause the matches to be listed immediately instead + of ringing the bell. The default value is 'off'. + + 'show-all-if-unmodified' + This alters the default behavior of the completion functions + in a fashion similar to SHOW-ALL-IF-AMBIGUOUS. If set to + 'on', words which have more than one possible completion + without any possible partial completion (the possible + completions don't share a common prefix) cause the matches to + be listed immediately instead of ringing the bell. The + default value is 'off'. + + 'show-mode-in-prompt' + If set to 'on', add a character to the beginning of the prompt + indicating the editing mode: emacs, vi command, or vi + insertion. The mode strings are user-settable. The default + value is 'off'. + + 'skip-completed-text' + If set to 'on', this alters the default completion behavior + when inserting a single match into the line. It's only active + when performing completion in the middle of a word. If + enabled, readline does not insert characters from the + completion that match characters after point in the word being + completed, so portions of the word following the cursor are + not duplicated. For instance, if this is enabled, attempting + completion when the cursor is after the 'e' in 'Makefile' will + result in 'Makefile' rather than 'Makefilefile', assuming + there is a single possible completion. The default value is + 'off'. + + 'vi-cmd-mode-string' + This string is displayed immediately before the last line of + the primary prompt when vi editing mode is active and in + command mode. The value is expanded like a key binding, so + the standard set of meta- and control prefixes and backslash + escape sequences is available. Use the '\1' and '\2' escapes + to begin and end sequences of non-printing characters, which + can be used to embed a terminal control sequence into the mode + string. The default is '(cmd)'. + + 'vi-ins-mode-string' + This string is displayed immediately before the last line of + the primary prompt when vi editing mode is active and in + insertion mode. The value is expanded like a key binding, so + the standard set of meta- and control prefixes and backslash + escape sequences is available. Use the '\1' and '\2' escapes + to begin and end sequences of non-printing characters, which + can be used to embed a terminal control sequence into the mode + string. The default is '(ins)'. + + 'visible-stats' + If set to 'on', a character denoting a file's type is appended + to the filename when listing possible completions. The + default is 'off'. + +Key Bindings + The syntax for controlling key bindings in the init file is simple. + First you need to find the name of the command that you want to + change. The following sections contain tables of the command name, + the default keybinding, if any, and a short description of what the + command does. + + Once you know the name of the command, simply place on a line in + the init file the name of the key you wish to bind the command to, + a colon, and then the name of the command. There can be no space + between the key name and the colon - that will be interpreted as + part of the key name. The name of the key can be expressed in + different ways, depending on what you find most comfortable. + + In addition to command names, readline allows keys to be bound to a + string that is inserted when the key is pressed (a MACRO). + + The 'bind -p' command displays Readline function names and bindings + in a format that can put directly into an initialization file. + *Note Bash Builtins::. + + KEYNAME: FUNCTION-NAME or MACRO + KEYNAME is the name of a key spelled out in English. For + example: + Control-u: universal-argument + Meta-Rubout: backward-kill-word + Control-o: "> output" + + In the above example, 'C-u' is bound to the function + 'universal-argument', 'M-DEL' is bound to the function + 'backward-kill-word', and 'C-o' is bound to run the macro + expressed on the right hand side (that is, to insert the text + '> output' into the line). + + A number of symbolic character names are recognized while + processing this key binding syntax: DEL, ESC, ESCAPE, LFD, + NEWLINE, RET, RETURN, RUBOUT, SPACE, SPC, and TAB. + + "KEYSEQ": FUNCTION-NAME or MACRO + KEYSEQ differs from KEYNAME above in that strings denoting an + entire key sequence can be specified, by placing the key + sequence in double quotes. Some GNU Emacs style key escapes + can be used, as in the following example, but the special + character names are not recognized. + + "\C-u": universal-argument + "\C-x\C-r": re-read-init-file + "\e[11~": "Function Key 1" + + In the above example, 'C-u' is again bound to the function + 'universal-argument' (just as it was in the first example), + ''C-x' 'C-r'' is bound to the function 're-read-init-file', + and ' <[> <1> <1> <~>' is bound to insert the text + 'Function Key 1'. + + The following GNU Emacs style escape sequences are available when + specifying key sequences: + + '\C-' + control prefix + '\M-' + meta prefix + '\e' + an escape character + '\\' + backslash + '\"' + <">, a double quotation mark + '\'' + <'>, a single quote or apostrophe + + In addition to the GNU Emacs style escape sequences, a second set + of backslash escapes is available: + + '\a' + alert (bell) + '\b' + backspace + '\d' + delete + '\f' + form feed + '\n' + newline + '\r' + carriage return + '\t' + horizontal tab + '\v' + vertical tab + '\NNN' + the eight-bit character whose value is the octal value NNN + (one to three digits) + '\xHH' + the eight-bit character whose value is the hexadecimal value + HH (one or two hex digits) + + When entering the text of a macro, single or double quotes must be + used to indicate a macro definition. Unquoted text is assumed to + be a function name. In the macro body, the backslash escapes + described above are expanded. Backslash will quote any other + character in the macro text, including '"' and '''. For example, + the following binding will make ''C-x' \' insert a single '\' into + the line: + "\C-x\\": "\\" + + +File: bash.info, Node: Conditional Init Constructs, Next: Sample Init File, Prev: Readline Init File Syntax, Up: Readline Init File + +8.3.2 Conditional Init Constructs +--------------------------------- + +Readline implements a facility similar in spirit to the conditional +compilation features of the C preprocessor which allows key bindings and +variable settings to be performed as the result of tests. There are +four parser directives used. + +'$if' + The '$if' construct allows bindings to be made based on the editing + mode, the terminal being used, or the application using Readline. + The text of the test extends to the end of the line; no characters + are required to isolate it. + + 'mode' + The 'mode=' form of the '$if' directive is used to test + whether Readline is in 'emacs' or 'vi' mode. This may be used + in conjunction with the 'set keymap' command, for instance, to + set bindings in the 'emacs-standard' and 'emacs-ctlx' keymaps + only if Readline is starting out in 'emacs' mode. + + 'term' + The 'term=' form may be used to include terminal-specific key + bindings, perhaps to bind the key sequences output by the + terminal's function keys. The word on the right side of the + '=' is tested against both the full name of the terminal and + the portion of the terminal name before the first '-'. This + allows 'sun' to match both 'sun' and 'sun-cmd', for instance. + + 'application' + The APPLICATION construct is used to include + application-specific settings. Each program using the + Readline library sets the APPLICATION NAME, and you can test + for a particular value. This could be used to bind key + sequences to functions useful for a specific program. For + instance, the following command adds a key sequence that + quotes the current or previous word in Bash: + $if Bash + # Quote the current or previous word + "\C-xq": "\eb\"\ef\"" + $endif + +'$endif' + This command, as seen in the previous example, terminates an '$if' + command. + +'$else' + Commands in this branch of the '$if' directive are executed if the + test fails. + +'$include' + This directive takes a single filename as an argument and reads + commands and bindings from that file. For example, the following + directive reads from '/etc/inputrc': + $include /etc/inputrc + + +File: bash.info, Node: Sample Init File, Prev: Conditional Init Constructs, Up: Readline Init File + +8.3.3 Sample Init File +---------------------- + +Here is an example of an INPUTRC file. This illustrates key binding, +variable assignment, and conditional syntax. + + # This file controls the behaviour of line input editing for + # programs that use the GNU Readline library. Existing + # programs include FTP, Bash, and GDB. + # + # You can re-read the inputrc file with C-x C-r. + # Lines beginning with '#' are comments. + # + # First, include any system-wide bindings and variable + # assignments from /etc/Inputrc + $include /etc/Inputrc + + # + # Set various bindings for emacs mode. + + set editing-mode emacs + + $if mode=emacs + + Meta-Control-h: backward-kill-word Text after the function name is ignored + + # + # Arrow keys in keypad mode + # + #"\M-OD": backward-char + #"\M-OC": forward-char + #"\M-OA": previous-history + #"\M-OB": next-history + # + # Arrow keys in ANSI mode + # + "\M-[D": backward-char + "\M-[C": forward-char + "\M-[A": previous-history + "\M-[B": next-history + # + # Arrow keys in 8 bit keypad mode + # + #"\M-\C-OD": backward-char + #"\M-\C-OC": forward-char + #"\M-\C-OA": previous-history + #"\M-\C-OB": next-history + # + # Arrow keys in 8 bit ANSI mode + # + #"\M-\C-[D": backward-char + #"\M-\C-[C": forward-char + #"\M-\C-[A": previous-history + #"\M-\C-[B": next-history + + C-q: quoted-insert + + $endif + + # An old-style binding. This happens to be the default. + TAB: complete + + # Macros that are convenient for shell interaction + $if Bash + # edit the path + "\C-xp": "PATH=${PATH}\e\C-e\C-a\ef\C-f" + # prepare to type a quoted word -- + # insert open and close double quotes + # and move to just after the open quote + "\C-x\"": "\"\"\C-b" + # insert a backslash (testing backslash escapes + # in sequences and macros) + "\C-x\\": "\\" + # Quote the current or previous word + "\C-xq": "\eb\"\ef\"" + # Add a binding to refresh the line, which is unbound + "\C-xr": redraw-current-line + # Edit variable on current line. + "\M-\C-v": "\C-a\C-k$\C-y\M-\C-e\C-a\C-y=" + $endif + + # use a visible bell if one is available + set bell-style visible + + # don't strip characters to 7 bits when reading + set input-meta on + + # allow iso-latin1 characters to be inserted rather + # than converted to prefix-meta sequences + set convert-meta off + + # display characters with the eighth bit set directly + # rather than as meta-prefixed characters + set output-meta on + + # if there are more than 150 possible completions for + # a word, ask the user if he wants to see all of them + set completion-query-items 150 + + # For FTP + $if Ftp + "\C-xg": "get \M-?" + "\C-xt": "put \M-?" + "\M-.": yank-last-arg + $endif + + +File: bash.info, Node: Bindable Readline Commands, Next: Readline vi Mode, Prev: Readline Init File, Up: Command Line Editing + +8.4 Bindable Readline Commands +============================== + +* Menu: + +* Commands For Moving:: Moving about the line. +* Commands For History:: Getting at previous lines. +* Commands For Text:: Commands for changing text. +* Commands For Killing:: Commands for killing and yanking. +* Numeric Arguments:: Specifying numeric arguments, repeat counts. +* Commands For Completion:: Getting Readline to do the typing for you. +* Keyboard Macros:: Saving and re-executing typed characters +* Miscellaneous Commands:: Other miscellaneous commands. + +This section describes Readline commands that may be bound to key +sequences. You can list your key bindings by executing 'bind -P' or, +for a more terse format, suitable for an INPUTRC file, 'bind -p'. +(*Note Bash Builtins::.) Command names without an accompanying key +sequence are unbound by default. + + In the following descriptions, "point" refers to the current cursor +position, and "mark" refers to a cursor position saved by the 'set-mark' +command. The text between the point and mark is referred to as the +"region". + + +File: bash.info, Node: Commands For Moving, Next: Commands For History, Up: Bindable Readline Commands + +8.4.1 Commands For Moving +------------------------- + +'beginning-of-line (C-a)' + Move to the start of the current line. + +'end-of-line (C-e)' + Move to the end of the line. + +'forward-char (C-f)' + Move forward a character. + +'backward-char (C-b)' + Move back a character. + +'forward-word (M-f)' + Move forward to the end of the next word. Words are composed of + letters and digits. + +'backward-word (M-b)' + Move back to the start of the current or previous word. Words are + composed of letters and digits. + +'shell-forward-word ()' + Move forward to the end of the next word. Words are delimited by + non-quoted shell metacharacters. + +'shell-backward-word ()' + Move back to the start of the current or previous word. Words are + delimited by non-quoted shell metacharacters. + +'clear-screen (C-l)' + Clear the screen and redraw the current line, leaving the current + line at the top of the screen. + +'redraw-current-line ()' + Refresh the current line. By default, this is unbound. + + +File: bash.info, Node: Commands For History, Next: Commands For Text, Prev: Commands For Moving, Up: Bindable Readline Commands + +8.4.2 Commands For Manipulating The History +------------------------------------------- + +'accept-line (Newline or Return)' + Accept the line regardless of where the cursor is. If this line is + non-empty, add it to the history list according to the setting of + the 'HISTCONTROL' and 'HISTIGNORE' variables. If this line is a + modified history line, then restore the history line to its + original state. + +'previous-history (C-p)' + Move 'back' through the history list, fetching the previous + command. + +'next-history (C-n)' + Move 'forward' through the history list, fetching the next command. + +'beginning-of-history (M-<)' + Move to the first line in the history. + +'end-of-history (M->)' + Move to the end of the input history, i.e., the line currently + being entered. + +'reverse-search-history (C-r)' + Search backward starting at the current line and moving 'up' + through the history as necessary. This is an incremental search. + +'forward-search-history (C-s)' + Search forward starting at the current line and moving 'down' + through the history as necessary. This is an incremental search. + +'non-incremental-reverse-search-history (M-p)' + Search backward starting at the current line and moving 'up' + through the history as necessary using a non-incremental search for + a string supplied by the user. The search string may match + anywhere in a history line. + +'non-incremental-forward-search-history (M-n)' + Search forward starting at the current line and moving 'down' + through the history as necessary using a non-incremental search for + a string supplied by the user. The search string may match + anywhere in a history line. + +'history-search-forward ()' + Search forward through the history for the string of characters + between the start of the current line and the point. The search + string must match at the beginning of a history line. This is a + non-incremental search. By default, this command is unbound. + +'history-search-backward ()' + Search backward through the history for the string of characters + between the start of the current line and the point. The search + string must match at the beginning of a history line. This is a + non-incremental search. By default, this command is unbound. + +'history-substr-search-forward ()' + Search forward through the history for the string of characters + between the start of the current line and the point. The search + string may match anywhere in a history line. This is a + non-incremental search. By default, this command is unbound. + +'history-substr-search-backward ()' + Search backward through the history for the string of characters + between the start of the current line and the point. The search + string may match anywhere in a history line. This is a + non-incremental search. By default, this command is unbound. + +'yank-nth-arg (M-C-y)' + Insert the first argument to the previous command (usually the + second word on the previous line) at point. With an argument N, + insert the Nth word from the previous command (the words in the + previous command begin with word 0). A negative argument inserts + the Nth word from the end of the previous command. Once the + argument N is computed, the argument is extracted as if the '!N' + history expansion had been specified. + +'yank-last-arg (M-. or M-_)' + Insert last argument to the previous command (the last word of the + previous history entry). With a numeric argument, behave exactly + like 'yank-nth-arg'. Successive calls to 'yank-last-arg' move back + through the history list, inserting the last word (or the word + specified by the argument to the first call) of each line in turn. + Any numeric argument supplied to these successive calls determines + the direction to move through the history. A negative argument + switches the direction through the history (back or forward). The + history expansion facilities are used to extract the last argument, + as if the '!$' history expansion had been specified. + + +File: bash.info, Node: Commands For Text, Next: Commands For Killing, Prev: Commands For History, Up: Bindable Readline Commands + +8.4.3 Commands For Changing Text +-------------------------------- + +'end-of-file (usually C-d)' + The character indicating end-of-file as set, for example, by + 'stty'. If this character is read when there are no characters on + the line, and point is at the beginning of the line, Readline + interprets it as the end of input and returns EOF. + +'delete-char (C-d)' + Delete the character at point. If this function is bound to the + same character as the tty EOF character, as 'C-d' commonly is, see + above for the effects. + +'backward-delete-char (Rubout)' + Delete the character behind the cursor. A numeric argument means + to kill the characters instead of deleting them. + +'forward-backward-delete-char ()' + Delete the character under the cursor, unless the cursor is at the + end of the line, in which case the character behind the cursor is + deleted. By default, this is not bound to a key. + +'quoted-insert (C-q or C-v)' + Add the next character typed to the line verbatim. This is how to + insert key sequences like 'C-q', for example. + +'self-insert (a, b, A, 1, !, ...)' + Insert yourself. + +'bracketed-paste-begin ()' + This function is intended to be bound to the "bracketed paste" + escape sequence sent by some terminals, and such a binding is + assigned by default. It allows Readline to insert the pasted text + as a single unit without treating each character as if it had been + read from the keyboard. The characters are inserted as if each one + was bound to 'self-insert') instead of executing any editing + commands. + +'transpose-chars (C-t)' + Drag the character before the cursor forward over the character at + the cursor, moving the cursor forward as well. If the insertion + point is at the end of the line, then this transposes the last two + characters of the line. Negative arguments have no effect. + +'transpose-words (M-t)' + Drag the word before point past the word after point, moving point + past that word as well. If the insertion point is at the end of + the line, this transposes the last two words on the line. + +'upcase-word (M-u)' + Uppercase the current (or following) word. With a negative + argument, uppercase the previous word, but do not move the cursor. + +'downcase-word (M-l)' + Lowercase the current (or following) word. With a negative + argument, lowercase the previous word, but do not move the cursor. + +'capitalize-word (M-c)' + Capitalize the current (or following) word. With a negative + argument, capitalize the previous word, but do not move the cursor. + +'overwrite-mode ()' + Toggle overwrite mode. With an explicit positive numeric argument, + switches to overwrite mode. With an explicit non-positive numeric + argument, switches to insert mode. This command affects only + 'emacs' mode; 'vi' mode does overwrite differently. Each call to + 'readline()' starts in insert mode. + + In overwrite mode, characters bound to 'self-insert' replace the + text at point rather than pushing the text to the right. + Characters bound to 'backward-delete-char' replace the character + before point with a space. + + By default, this command is unbound. + + +File: bash.info, Node: Commands For Killing, Next: Numeric Arguments, Prev: Commands For Text, Up: Bindable Readline Commands + +8.4.4 Killing And Yanking +------------------------- + +'kill-line (C-k)' + Kill the text from point to the end of the line. + +'backward-kill-line (C-x Rubout)' + Kill backward from the cursor to the beginning of the current line. + +'unix-line-discard (C-u)' + Kill backward from the cursor to the beginning of the current line. + +'kill-whole-line ()' + Kill all characters on the current line, no matter where point is. + By default, this is unbound. + +'kill-word (M-d)' + Kill from point to the end of the current word, or if between + words, to the end of the next word. Word boundaries are the same + as 'forward-word'. + +'backward-kill-word (M-)' + Kill the word behind point. Word boundaries are the same as + 'backward-word'. + +'shell-kill-word ()' + Kill from point to the end of the current word, or if between + words, to the end of the next word. Word boundaries are the same + as 'shell-forward-word'. + +'shell-backward-kill-word ()' + Kill the word behind point. Word boundaries are the same as + 'shell-backward-word'. + +'unix-word-rubout (C-w)' + Kill the word behind point, using white space as a word boundary. + The killed text is saved on the kill-ring. + +'unix-filename-rubout ()' + Kill the word behind point, using white space and the slash + character as the word boundaries. The killed text is saved on the + kill-ring. + +'delete-horizontal-space ()' + Delete all spaces and tabs around point. By default, this is + unbound. + +'kill-region ()' + Kill the text in the current region. By default, this command is + unbound. + +'copy-region-as-kill ()' + Copy the text in the region to the kill buffer, so it can be yanked + right away. By default, this command is unbound. + +'copy-backward-word ()' + Copy the word before point to the kill buffer. The word boundaries + are the same as 'backward-word'. By default, this command is + unbound. + +'copy-forward-word ()' + Copy the word following point to the kill buffer. The word + boundaries are the same as 'forward-word'. By default, this + command is unbound. + +'yank (C-y)' + Yank the top of the kill ring into the buffer at point. + +'yank-pop (M-y)' + Rotate the kill-ring, and yank the new top. You can only do this + if the prior command is 'yank' or 'yank-pop'. + + +File: bash.info, Node: Numeric Arguments, Next: Commands For Completion, Prev: Commands For Killing, Up: Bindable Readline Commands + +8.4.5 Specifying Numeric Arguments +---------------------------------- + +'digit-argument (M-0, M-1, ... M--)' + Add this digit to the argument already accumulating, or start a new + argument. 'M--' starts a negative argument. + +'universal-argument ()' + This is another way to specify an argument. If this command is + followed by one or more digits, optionally with a leading minus + sign, those digits define the argument. If the command is followed + by digits, executing 'universal-argument' again ends the numeric + argument, but is otherwise ignored. As a special case, if this + command is immediately followed by a character that is neither a + digit nor minus sign, the argument count for the next command is + multiplied by four. The argument count is initially one, so + executing this function the first time makes the argument count + four, a second time makes the argument count sixteen, and so on. + By default, this is not bound to a key. + + +File: bash.info, Node: Commands For Completion, Next: Keyboard Macros, Prev: Numeric Arguments, Up: Bindable Readline Commands + +8.4.6 Letting Readline Type For You +----------------------------------- + +'complete ()' + Attempt to perform completion on the text before point. The actual + completion performed is application-specific. Bash attempts + completion treating the text as a variable (if the text begins with + '$'), username (if the text begins with '~'), hostname (if the text + begins with '@'), or command (including aliases and functions) in + turn. If none of these produces a match, filename completion is + attempted. + +'possible-completions (M-?)' + List the possible completions of the text before point. When + displaying completions, Readline sets the number of columns used + for display to the value of 'completion-display-width', the value + of the environment variable 'COLUMNS', or the screen width, in that + order. + +'insert-completions (M-*)' + Insert all completions of the text before point that would have + been generated by 'possible-completions'. + +'menu-complete ()' + Similar to 'complete', but replaces the word to be completed with a + single match from the list of possible completions. Repeated + execution of 'menu-complete' steps through the list of possible + completions, inserting each match in turn. At the end of the list + of completions, the bell is rung (subject to the setting of + 'bell-style') and the original text is restored. An argument of N + moves N positions forward in the list of matches; a negative + argument may be used to move backward through the list. This + command is intended to be bound to , but is unbound by + default. + +'menu-complete-backward ()' + Identical to 'menu-complete', but moves backward through the list + of possible completions, as if 'menu-complete' had been given a + negative argument. + +'delete-char-or-list ()' + Deletes the character under the cursor if not at the beginning or + end of the line (like 'delete-char'). If at the end of the line, + behaves identically to 'possible-completions'. This command is + unbound by default. + +'complete-filename (M-/)' + Attempt filename completion on the text before point. + +'possible-filename-completions (C-x /)' + List the possible completions of the text before point, treating it + as a filename. + +'complete-username (M-~)' + Attempt completion on the text before point, treating it as a + username. + +'possible-username-completions (C-x ~)' + List the possible completions of the text before point, treating it + as a username. + +'complete-variable (M-$)' + Attempt completion on the text before point, treating it as a shell + variable. + +'possible-variable-completions (C-x $)' + List the possible completions of the text before point, treating it + as a shell variable. + +'complete-hostname (M-@)' + Attempt completion on the text before point, treating it as a + hostname. + +'possible-hostname-completions (C-x @)' + List the possible completions of the text before point, treating it + as a hostname. + +'complete-command (M-!)' + Attempt completion on the text before point, treating it as a + command name. Command completion attempts to match the text + against aliases, reserved words, shell functions, shell builtins, + and finally executable filenames, in that order. + +'possible-command-completions (C-x !)' + List the possible completions of the text before point, treating it + as a command name. + +'dynamic-complete-history (M-)' + Attempt completion on the text before point, comparing the text + against lines from the history list for possible completion + matches. + +'dabbrev-expand ()' + Attempt menu completion on the text before point, comparing the + text against lines from the history list for possible completion + matches. + +'complete-into-braces (M-{)' + Perform filename completion and insert the list of possible + completions enclosed within braces so the list is available to the + shell (*note Brace Expansion::). + + +File: bash.info, Node: Keyboard Macros, Next: Miscellaneous Commands, Prev: Commands For Completion, Up: Bindable Readline Commands + +8.4.7 Keyboard Macros +--------------------- + +'start-kbd-macro (C-x ()' + Begin saving the characters typed into the current keyboard macro. + +'end-kbd-macro (C-x ))' + Stop saving the characters typed into the current keyboard macro + and save the definition. + +'call-last-kbd-macro (C-x e)' + Re-execute the last keyboard macro defined, by making the + characters in the macro appear as if typed at the keyboard. + +'print-last-kbd-macro ()' + Print the last keboard macro defined in a format suitable for the + INPUTRC file. + + +File: bash.info, Node: Miscellaneous Commands, Prev: Keyboard Macros, Up: Bindable Readline Commands + +8.4.8 Some Miscellaneous Commands +--------------------------------- + +'re-read-init-file (C-x C-r)' + Read in the contents of the INPUTRC file, and incorporate any + bindings or variable assignments found there. + +'abort (C-g)' + Abort the current editing command and ring the terminal's bell + (subject to the setting of 'bell-style'). + +'do-uppercase-version (M-a, M-b, M-X, ...)' + If the metafied character X is lowercase, run the command that is + bound to the corresponding uppercase character. + +'prefix-meta ()' + Metafy the next character typed. This is for keyboards without a + meta key. Typing ' f' is equivalent to typing 'M-f'. + +'undo (C-_ or C-x C-u)' + Incremental undo, separately remembered for each line. + +'revert-line (M-r)' + Undo all changes made to this line. This is like executing the + 'undo' command enough times to get back to the beginning. + +'tilde-expand (M-&)' + Perform tilde expansion on the current word. + +'set-mark (C-@)' + Set the mark to the point. If a numeric argument is supplied, the + mark is set to that position. + +'exchange-point-and-mark (C-x C-x)' + Swap the point with the mark. The current cursor position is set + to the saved position, and the old cursor position is saved as the + mark. + +'character-search (C-])' + A character is read and point is moved to the next occurrence of + that character. A negative count searches for previous + occurrences. + +'character-search-backward (M-C-])' + A character is read and point is moved to the previous occurrence + of that character. A negative count searches for subsequent + occurrences. + +'skip-csi-sequence ()' + Read enough characters to consume a multi-key sequence such as + those defined for keys like Home and End. Such sequences begin + with a Control Sequence Indicator (CSI), usually ESC-[. If this + sequence is bound to "\e[", keys producing such sequences will have + no effect unless explicitly bound to a readline command, instead of + inserting stray characters into the editing buffer. This is + unbound by default, but usually bound to ESC-[. + +'insert-comment (M-#)' + Without a numeric argument, the value of the 'comment-begin' + variable is inserted at the beginning of the current line. If a + numeric argument is supplied, this command acts as a toggle: if the + characters at the beginning of the line do not match the value of + 'comment-begin', the value is inserted, otherwise the characters in + 'comment-begin' are deleted from the beginning of the line. In + either case, the line is accepted as if a newline had been typed. + The default value of 'comment-begin' causes this command to make + the current line a shell comment. If a numeric argument causes the + comment character to be removed, the line will be executed by the + shell. + +'dump-functions ()' + Print all of the functions and their key bindings to the Readline + output stream. If a numeric argument is supplied, the output is + formatted in such a way that it can be made part of an INPUTRC + file. This command is unbound by default. + +'dump-variables ()' + Print all of the settable variables and their values to the + Readline output stream. If a numeric argument is supplied, the + output is formatted in such a way that it can be made part of an + INPUTRC file. This command is unbound by default. + +'dump-macros ()' + Print all of the Readline key sequences bound to macros and the + strings they output. If a numeric argument is supplied, the output + is formatted in such a way that it can be made part of an INPUTRC + file. This command is unbound by default. + +'glob-complete-word (M-g)' + The word before point is treated as a pattern for pathname + expansion, with an asterisk implicitly appended. This pattern is + used to generate a list of matching file names for possible + completions. + +'glob-expand-word (C-x *)' + The word before point is treated as a pattern for pathname + expansion, and the list of matching file names is inserted, + replacing the word. If a numeric argument is supplied, a '*' is + appended before pathname expansion. + +'glob-list-expansions (C-x g)' + The list of expansions that would have been generated by + 'glob-expand-word' is displayed, and the line is redrawn. If a + numeric argument is supplied, a '*' is appended before pathname + expansion. + +'display-shell-version (C-x C-v)' + Display version information about the current instance of Bash. + +'shell-expand-line (M-C-e)' + Expand the line as the shell does. This performs alias and history + expansion as well as all of the shell word expansions (*note Shell + Expansions::). + +'history-expand-line (M-^)' + Perform history expansion on the current line. + +'magic-space ()' + Perform history expansion on the current line and insert a space + (*note History Interaction::). + +'alias-expand-line ()' + Perform alias expansion on the current line (*note Aliases::). + +'history-and-alias-expand-line ()' + Perform history and alias expansion on the current line. + +'insert-last-argument (M-. or M-_)' + A synonym for 'yank-last-arg'. + +'operate-and-get-next (C-o)' + Accept the current line for execution and fetch the next line + relative to the current line from the history for editing. Any + argument is ignored. + +'edit-and-execute-command (C-xC-e)' + Invoke an editor on the current command line, and execute the + result as shell commands. Bash attempts to invoke '$VISUAL', + '$EDITOR', and 'emacs' as the editor, in that order. + + +File: bash.info, Node: Readline vi Mode, Next: Programmable Completion, Prev: Bindable Readline Commands, Up: Command Line Editing + +8.5 Readline vi Mode +==================== + +While the Readline library does not have a full set of 'vi' editing +functions, it does contain enough to allow simple editing of the line. +The Readline 'vi' mode behaves as specified in the POSIX standard. + + In order to switch interactively between 'emacs' and 'vi' editing +modes, use the 'set -o emacs' and 'set -o vi' commands (*note The Set +Builtin::). The Readline default is 'emacs' mode. + + When you enter a line in 'vi' mode, you are already placed in +'insertion' mode, as if you had typed an 'i'. Pressing switches +you into 'command' mode, where you can edit the text of the line with +the standard 'vi' movement keys, move to previous history lines with 'k' +and subsequent lines with 'j', and so forth. + + +File: bash.info, Node: Programmable Completion, Next: Programmable Completion Builtins, Prev: Readline vi Mode, Up: Command Line Editing + +8.6 Programmable Completion +=========================== + +When word completion is attempted for an argument to a command for which +a completion specification (a COMPSPEC) has been defined using the +'complete' builtin (*note Programmable Completion Builtins::), the +programmable completion facilities are invoked. + + First, the command name is identified. If a compspec has been +defined for that command, the compspec is used to generate the list of +possible completions for the word. If the command word is the empty +string (completion attempted at the beginning of an empty line), any +compspec defined with the '-E' option to 'complete' is used. If the +command word is a full pathname, a compspec for the full pathname is +searched for first. If no compspec is found for the full pathname, an +attempt is made to find a compspec for the portion following the final +slash. If those searches do not result in a compspec, any compspec +defined with the '-D' option to 'complete' is used as the default. + + Once a compspec has been found, it is used to generate the list of +matching words. If a compspec is not found, the default Bash completion +described above (*note Commands For Completion::) is performed. + + First, the actions specified by the compspec are used. Only matches +which are prefixed by the word being completed are returned. When the +'-f' or '-d' option is used for filename or directory name completion, +the shell variable 'FIGNORE' is used to filter the matches. *Note Bash +Variables::, for a description of 'FIGNORE'. + + Any completions specified by a filename expansion pattern to the '-G' +option are generated next. The words generated by the pattern need not +match the word being completed. The 'GLOBIGNORE' shell variable is not +used to filter the matches, but the 'FIGNORE' shell variable is used. + + Next, the string specified as the argument to the '-W' option is +considered. The string is first split using the characters in the 'IFS' +special variable as delimiters. Shell quoting is honored. Each word is +then expanded using brace expansion, tilde expansion, parameter and +variable expansion, command substitution, and arithmetic expansion, as +described above (*note Shell Expansions::). The results are split using +the rules described above (*note Word Splitting::). The results of the +expansion are prefix-matched against the word being completed, and the +matching words become the possible completions. + + After these matches have been generated, any shell function or +command specified with the '-F' and '-C' options is invoked. When the +command or function is invoked, the 'COMP_LINE', 'COMP_POINT', +'COMP_KEY', and 'COMP_TYPE' variables are assigned values as described +above (*note Bash Variables::). If a shell function is being invoked, +the 'COMP_WORDS' and 'COMP_CWORD' variables are also set. When the +function or command is invoked, the first argument ($1) is the name of +the command whose arguments are being completed, the second argument +($2) is the word being completed, and the third argument ($3) is the +word preceding the word being completed on the current command line. No +filtering of the generated completions against the word being completed +is performed; the function or command has complete freedom in generating +the matches. + + Any function specified with '-F' is invoked first. The function may +use any of the shell facilities, including the 'compgen' and 'compopt' +builtins described below (*note Programmable Completion Builtins::), to +generate the matches. It must put the possible completions in the +'COMPREPLY' array variable, one per array element. + + Next, any command specified with the '-C' option is invoked in an +environment equivalent to command substitution. It should print a list +of completions, one per line, to the standard output. Backslash may be +used to escape a newline, if necessary. + + After all of the possible completions are generated, any filter +specified with the '-X' option is applied to the list. The filter is a +pattern as used for pathname expansion; a '&' in the pattern is replaced +with the text of the word being completed. A literal '&' may be escaped +with a backslash; the backslash is removed before attempting a match. +Any completion that matches the pattern will be removed from the list. +A leading '!' negates the pattern; in this case any completion not +matching the pattern will be removed. If the 'nocasematch' shell option +(see the description of 'shopt' in *note The Shopt Builtin::) is +enabled, the match is performed without regard to the case of alphabetic +characters. + + Finally, any prefix and suffix specified with the '-P' and '-S' +options are added to each member of the completion list, and the result +is returned to the Readline completion code as the list of possible +completions. + + If the previously-applied actions do not generate any matches, and +the '-o dirnames' option was supplied to 'complete' when the compspec +was defined, directory name completion is attempted. + + If the '-o plusdirs' option was supplied to 'complete' when the +compspec was defined, directory name completion is attempted and any +matches are added to the results of the other actions. + + By default, if a compspec is found, whatever it generates is returned +to the completion code as the full set of possible completions. The +default Bash completions are not attempted, and the Readline default of +filename completion is disabled. If the '-o bashdefault' option was +supplied to 'complete' when the compspec was defined, the default Bash +completions are attempted if the compspec generates no matches. If the +'-o default' option was supplied to 'complete' when the compspec was +defined, Readline's default completion will be performed if the compspec +(and, if attempted, the default Bash completions) generate no matches. + + When a compspec indicates that directory name completion is desired, +the programmable completion functions force Readline to append a slash +to completed names which are symbolic links to directories, subject to +the value of the MARK-DIRECTORIES Readline variable, regardless of the +setting of the MARK-SYMLINKED-DIRECTORIES Readline variable. + + There is some support for dynamically modifying completions. This is +most useful when used in combination with a default completion specified +with '-D'. It's possible for shell functions executed as completion +handlers to indicate that completion should be retried by returning an +exit status of 124. If a shell function returns 124, and changes the +compspec associated with the command on which completion is being +attempted (supplied as the first argument when the function is +executed), programmable completion restarts from the beginning, with an +attempt to find a new compspec for that command. This allows a set of +completions to be built dynamically as completion is attempted, rather +than being loaded all at once. + + For instance, assuming that there is a library of compspecs, each +kept in a file corresponding to the name of the command, the following +default completion function would load completions dynamically: + + _completion_loader() + { + . "/etc/bash_completion.d/$1.sh" >/dev/null 2>&1 && return 124 + } + complete -D -F _completion_loader -o bashdefault -o default + + +File: bash.info, Node: Programmable Completion Builtins, Next: A Programmable Completion Example, Prev: Programmable Completion, Up: Command Line Editing + +8.7 Programmable Completion Builtins +==================================== + +Three builtin commands are available to manipulate the programmable +completion facilities: one to specify how the arguments to a particular +command are to be completed, and two to modify the completion as it is +happening. + +'compgen' + compgen [OPTION] [WORD] + + Generate possible completion matches for WORD according to the + OPTIONs, which may be any option accepted by the 'complete' builtin + with the exception of '-p' and '-r', and write the matches to the + standard output. When using the '-F' or '-C' options, the various + shell variables set by the programmable completion facilities, + while available, will not have useful values. + + The matches will be generated in the same way as if the + programmable completion code had generated them directly from a + completion specification with the same flags. If WORD is + specified, only those completions matching WORD will be displayed. + + The return value is true unless an invalid option is supplied, or + no matches were generated. + +'complete' + complete [-abcdefgjksuv] [-o COMP-OPTION] [-DE] [-A ACTION] [-G GLOBPAT] [-W WORDLIST] + [-F FUNCTION] [-C COMMAND] [-X FILTERPAT] + [-P PREFIX] [-S SUFFIX] NAME [NAME ...] + complete -pr [-DE] [NAME ...] + + Specify how arguments to each NAME should be completed. If the + '-p' option is supplied, or if no options are supplied, existing + completion specifications are printed in a way that allows them to + be reused as input. The '-r' option removes a completion + specification for each NAME, or, if no NAMEs are supplied, all + completion specifications. The '-D' option indicates that the + remaining options and actions should apply to the "default" command + completion; that is, completion attempted on a command for which no + completion has previously been defined. The '-E' option indicates + that the remaining options and actions should apply to "empty" + command completion; that is, completion attempted on a blank line. + + The process of applying these completion specifications when word + completion is attempted is described above (*note Programmable + Completion::). The '-D' option takes precedence over '-E'. + + Other options, if specified, have the following meanings. The + arguments to the '-G', '-W', and '-X' options (and, if necessary, + the '-P' and '-S' options) should be quoted to protect them from + expansion before the 'complete' builtin is invoked. + + '-o COMP-OPTION' + The COMP-OPTION controls several aspects of the compspec's + behavior beyond the simple generation of completions. + COMP-OPTION may be one of: + + 'bashdefault' + Perform the rest of the default Bash completions if the + compspec generates no matches. + + 'default' + Use Readline's default filename completion if the + compspec generates no matches. + + 'dirnames' + Perform directory name completion if the compspec + generates no matches. + + 'filenames' + Tell Readline that the compspec generates filenames, so + it can perform any filename-specific processing (like + adding a slash to directory names quoting special + characters, or suppressing trailing spaces). This option + is intended to be used with shell functions specified + with '-F'. + + 'noquote' + Tell Readline not to quote the completed words if they + are filenames (quoting filenames is the default). + + 'nosort' + Tell Readline not to sort the list of possible + completions alphabetically. + + 'nospace' + Tell Readline not to append a space (the default) to + words completed at the end of the line. + + 'plusdirs' + After any matches defined by the compspec are generated, + directory name completion is attempted and any matches + are added to the results of the other actions. + + '-A ACTION' + The ACTION may be one of the following to generate a list of + possible completions: + + 'alias' + Alias names. May also be specified as '-a'. + + 'arrayvar' + Array variable names. + + 'binding' + Readline key binding names (*note Bindable Readline + Commands::). + + 'builtin' + Names of shell builtin commands. May also be specified + as '-b'. + + 'command' + Command names. May also be specified as '-c'. + + 'directory' + Directory names. May also be specified as '-d'. + + 'disabled' + Names of disabled shell builtins. + + 'enabled' + Names of enabled shell builtins. + + 'export' + Names of exported shell variables. May also be specified + as '-e'. + + 'file' + File names. May also be specified as '-f'. + + 'function' + Names of shell functions. + + 'group' + Group names. May also be specified as '-g'. + + 'helptopic' + Help topics as accepted by the 'help' builtin (*note Bash + Builtins::). + + 'hostname' + Hostnames, as taken from the file specified by the + 'HOSTFILE' shell variable (*note Bash Variables::). + + 'job' + Job names, if job control is active. May also be + specified as '-j'. + + 'keyword' + Shell reserved words. May also be specified as '-k'. + + 'running' + Names of running jobs, if job control is active. + + 'service' + Service names. May also be specified as '-s'. + + 'setopt' + Valid arguments for the '-o' option to the 'set' builtin + (*note The Set Builtin::). + + 'shopt' + Shell option names as accepted by the 'shopt' builtin + (*note Bash Builtins::). + + 'signal' + Signal names. + + 'stopped' + Names of stopped jobs, if job control is active. + + 'user' + User names. May also be specified as '-u'. + + 'variable' + Names of all shell variables. May also be specified as + '-v'. + + '-C COMMAND' + COMMAND is executed in a subshell environment, and its output + is used as the possible completions. + + '-F FUNCTION' + The shell function FUNCTION is executed in the current shell + environment. When it is executed, $1 is the name of the + command whose arguments are being completed, $2 is the word + being completed, and $3 is the word preceding the word being + completed, as described above (*note Programmable + Completion::). When it finishes, the possible completions are + retrieved from the value of the 'COMPREPLY' array variable. + + '-G GLOBPAT' + The filename expansion pattern GLOBPAT is expanded to generate + the possible completions. + + '-P PREFIX' + PREFIX is added at the beginning of each possible completion + after all other options have been applied. + + '-S SUFFIX' + SUFFIX is appended to each possible completion after all other + options have been applied. + + '-W WORDLIST' + The WORDLIST is split using the characters in the 'IFS' + special variable as delimiters, and each resultant word is + expanded. The possible completions are the members of the + resultant list which match the word being completed. + + '-X FILTERPAT' + FILTERPAT is a pattern as used for filename expansion. It is + applied to the list of possible completions generated by the + preceding options and arguments, and each completion matching + FILTERPAT is removed from the list. A leading '!' in + FILTERPAT negates the pattern; in this case, any completion + not matching FILTERPAT is removed. + + The return value is true unless an invalid option is supplied, an + option other than '-p' or '-r' is supplied without a NAME argument, + an attempt is made to remove a completion specification for a NAME + for which no specification exists, or an error occurs adding a + completion specification. + +'compopt' + compopt [-o OPTION] [-DE] [+o OPTION] [NAME] + Modify completion options for each NAME according to the OPTIONs, + or for the currently-executing completion if no NAMEs are supplied. + If no OPTIONs are given, display the completion options for each + NAME or the current completion. The possible values of OPTION are + those valid for the 'complete' builtin described above. The '-D' + option indicates that the remaining options should apply to the + "default" command completion; that is, completion attempted on a + command for which no completion has previously been defined. The + '-E' option indicates that the remaining options should apply to + "empty" command completion; that is, completion attempted on a + blank line. + + The '-D' option takes precedence over '-E'. + + The return value is true unless an invalid option is supplied, an + attempt is made to modify the options for a NAME for which no + completion specification exists, or an output error occurs. + + +File: bash.info, Node: A Programmable Completion Example, Prev: Programmable Completion Builtins, Up: Command Line Editing + +8.8 A Programmable Completion Example +===================================== + +The most common way to obtain additional completion functionality beyond +the default actions 'complete' and 'compgen' provide is to use a shell +function and bind it to a particular command using 'complete -F'. + + The following function provides completions for the 'cd' builtin. It +is a reasonably good example of what shell functions must do when used +for completion. This function uses the word passsed as '$2' to +determine the directory name to complete. You can also use the +'COMP_WORDS' array variable; the current word is indexed by the +'COMP_CWORD' variable. + + The function relies on the 'complete' and 'compgen' builtins to do +much of the work, adding only the things that the Bash 'cd' does beyond +accepting basic directory names: tilde expansion (*note Tilde +Expansion::), searching directories in $CDPATH, which is described above +(*note Bourne Shell Builtins::), and basic support for the 'cdable_vars' +shell option (*note The Shopt Builtin::). '_comp_cd' modifies the value +of IFS so that it contains only a newline to accommodate file names +containing spaces and tabs - 'compgen' prints the possible completions +it generates one per line. + + Possible completions go into the COMPREPLY array variable, one +completion per array element. The programmable completion system +retrieves the completions from there when the function returns. + + # A completion function for the cd builtin + # based on the cd completion function from the bash_completion package + _comp_cd() + { + local IFS=$' \t\n' # normalize IFS + local cur _skipdot _cdpath + local i j k + + # Tilde expansion, with side effect of expanding tilde to full pathname + case "$2" in + \~*) eval cur="$2" ;; + *) cur=$2 ;; + esac + + # no cdpath or absolute pathname -- straight directory completion + if [[ -z "${CDPATH:-}" ]] || [[ "$cur" == @(./*|../*|/*) ]]; then + # compgen prints paths one per line; could also use while loop + IFS=$'\n' + COMPREPLY=( $(compgen -d -- "$cur") ) + IFS=$' \t\n' + # CDPATH+directories in the current directory if not in CDPATH + else + IFS=$'\n' + _skipdot=false + # preprocess CDPATH to convert null directory names to . + _cdpath=${CDPATH/#:/.:} + _cdpath=${_cdpath//::/:.:} + _cdpath=${_cdpath/%:/:.} + for i in ${_cdpath//:/$'\n'}; do + if [[ $i -ef . ]]; then _skipdot=true; fi + k="${#COMPREPLY[@]}" + for j in $( compgen -d -- "$i/$cur" ); do + COMPREPLY[k++]=${j#$i/} # cut off directory + done + done + $_skipdot || COMPREPLY+=( $(compgen -d -- "$cur") ) + IFS=$' \t\n' + fi + + # variable names if appropriate shell option set and no completions + if shopt -q cdable_vars && [[ ${#COMPREPLY[@]} -eq 0 ]]; then + COMPREPLY=( $(compgen -v -- "$cur") ) + fi + + return 0 + } + + We install the completion function using the '-F' option to +'complete': + + # Tell readline to quote appropriate and append slashes to directories; + # use the bash default completion for other arguments + complete -o filenames -o nospace -o bashdefault -F _comp_cd cd + +Since we'd like Bash and Readline to take care of some of the other +details for us, we use several other options to tell Bash and Readline +what to do. The '-o filenames' option tells Readline that the possible +completions should be treated as filenames, and quoted appropriately. +That option will also cause Readline to append a slash to filenames it +can determine are directories (which is why we might want to extend +'_comp_cd' to append a slash if we're using directories found via +CDPATH: Readline can't tell those completions are directories). The '-o +nospace' option tells Readline to not append a space character to the +directory name, in case we want to append to it. The '-o bashdefault' +option brings in the rest of the "Bash default" completions - possible +completion that Bash adds to the default Readline set. These include +things like command name completion, variable completion for words +beginning with '{', completions containing pathname expansion patterns +(*note Filename Expansion::), and so on. + + Once installed using 'complete', '_comp_cd' will be called every time +we attempt word completion for a 'cd' command. + + Many more examples - an extensive collection of completions for most +of the common GNU, Unix, and Linux commands - are available as part of +the bash_completion project. This is installed by default on many +GNU/Linux distributions. Originally written by Ian Macdonald, the +project now lives at . There +are ports for other systems such as Solaris and Mac OS X. + + An older version of the bash_completion package is distributed with +bash in the 'examples/complete' subdirectory. + + +File: bash.info, Node: Using History Interactively, Next: Installing Bash, Prev: Command Line Editing, Up: Top + +9 Using History Interactively +***************************** + +This chapter describes how to use the GNU History Library interactively, +from a user's standpoint. It should be considered a user's guide. For +information on using the GNU History Library in other programs, see the +GNU Readline Library Manual. + +* Menu: + +* Bash History Facilities:: How Bash lets you manipulate your command + history. +* Bash History Builtins:: The Bash builtin commands that manipulate + the command history. +* History Interaction:: What it feels like using History as a user. + + +File: bash.info, Node: Bash History Facilities, Next: Bash History Builtins, Up: Using History Interactively + +9.1 Bash History Facilities +=========================== + +When the '-o history' option to the 'set' builtin is enabled (*note The +Set Builtin::), the shell provides access to the "command history", the +list of commands previously typed. The value of the 'HISTSIZE' shell +variable is used as the number of commands to save in a history list. +The text of the last '$HISTSIZE' commands (default 500) is saved. The +shell stores each command in the history list prior to parameter and +variable expansion but after history expansion is performed, subject to +the values of the shell variables 'HISTIGNORE' and 'HISTCONTROL'. + + When the shell starts up, the history is initialized from the file +named by the 'HISTFILE' variable (default '~/.bash_history'). The file +named by the value of 'HISTFILE' is truncated, if necessary, to contain +no more than the number of lines specified by the value of the +'HISTFILESIZE' variable. When a shell with history enabled exits, the +last '$HISTSIZE' lines are copied from the history list to the file +named by '$HISTFILE'. If the 'histappend' shell option is set (*note +Bash Builtins::), the lines are appended to the history file, otherwise +the history file is overwritten. If 'HISTFILE' is unset, or if the +history file is unwritable, the history is not saved. After saving the +history, the history file is truncated to contain no more than +'$HISTFILESIZE' lines. If 'HISTFILESIZE' is unset, or set to null, a +non-numeric value, or a numeric value less than zero, the history file +is not truncated. + + If the 'HISTTIMEFORMAT' is set, the time stamp information associated +with each history entry is written to the history file, marked with the +history comment character. When the history file is read, lines +beginning with the history comment character followed immediately by a +digit are interpreted as timestamps for the following history entry. + + The builtin command 'fc' may be used to list or edit and re-execute a +portion of the history list. The 'history' builtin may be used to +display or modify the history list and manipulate the history file. +When using command-line editing, search commands are available in each +editing mode that provide access to the history list (*note Commands For +History::). + + The shell allows control over which commands are saved on the history +list. The 'HISTCONTROL' and 'HISTIGNORE' variables may be set to cause +the shell to save only a subset of the commands entered. The 'cmdhist' +shell option, if enabled, causes the shell to attempt to save each line +of a multi-line command in the same history entry, adding semicolons +where necessary to preserve syntactic correctness. The 'lithist' shell +option causes the shell to save the command with embedded newlines +instead of semicolons. The 'shopt' builtin is used to set these +options. *Note Bash Builtins::, for a description of 'shopt'. + + +File: bash.info, Node: Bash History Builtins, Next: History Interaction, Prev: Bash History Facilities, Up: Using History Interactively + +9.2 Bash History Builtins +========================= + +Bash provides two builtin commands which manipulate the history list and +history file. + +'fc' + fc [-e ENAME] [-lnr] [FIRST] [LAST] + fc -s [PAT=REP] [COMMAND] + + The first form selects a range of commands from FIRST to LAST from + the history list and displays or edits and re-executes them. Both + FIRST and LAST may be specified as a string (to locate the most + recent command beginning with that string) or as a number (an index + into the history list, where a negative number is used as an offset + from the current command number). If LAST is not specified it is + set to FIRST. If FIRST is not specified it is set to the previous + command for editing and -16 for listing. If the '-l' flag is + given, the commands are listed on standard output. The '-n' flag + suppresses the command numbers when listing. The '-r' flag + reverses the order of the listing. Otherwise, the editor given by + ENAME is invoked on a file containing those commands. If ENAME is + not given, the value of the following variable expansion is used: + '${FCEDIT:-${EDITOR:-vi}}'. This says to use the value of the + 'FCEDIT' variable if set, or the value of the 'EDITOR' variable if + that is set, or 'vi' if neither is set. When editing is complete, + the edited commands are echoed and executed. + + In the second form, COMMAND is re-executed after each instance of + PAT in the selected command is replaced by REP. COMMAND is + intepreted the same as FIRST above. + + A useful alias to use with the 'fc' command is 'r='fc -s'', so that + typing 'r cc' runs the last command beginning with 'cc' and typing + 'r' re-executes the last command (*note Aliases::). + +'history' + history [N] + history -c + history -d OFFSET + history [-anrw] [FILENAME] + history -ps ARG + + With no options, display the history list with line numbers. Lines + prefixed with a '*' have been modified. An argument of N lists + only the last N lines. If the shell variable 'HISTTIMEFORMAT' is + set and not null, it is used as a format string for STRFTIME to + display the time stamp associated with each displayed history + entry. No intervening blank is printed between the formatted time + stamp and the history line. + + Options, if supplied, have the following meanings: + + '-c' + Clear the history list. This may be combined with the other + options to replace the history list completely. + + '-d OFFSET' + Delete the history entry at position OFFSET. OFFSET should be + specified as it appears when the history is displayed. + + '-a' + Append the new history lines to the history file. These are + history lines entered since the beginning of the current Bash + session, but not already appended to the history file. + + '-n' + Append the history lines not already read from the history + file to the current history list. These are lines appended to + the history file since the beginning of the current Bash + session. + + '-r' + Read the history file and append its contents to the history + list. + + '-w' + Write out the current history list to the history file. + + '-p' + Perform history substitution on the ARGs and display the + result on the standard output, without storing the results in + the history list. + + '-s' + The ARGs are added to the end of the history list as a single + entry. + + When any of the '-w', '-r', '-a', or '-n' options is used, if + FILENAME is given, then it is used as the history file. If not, + then the value of the 'HISTFILE' variable is used. + + +File: bash.info, Node: History Interaction, Prev: Bash History Builtins, Up: Using History Interactively + +9.3 History Expansion +===================== + +The History library provides a history expansion feature that is similar +to the history expansion provided by 'csh'. This section describes the +syntax used to manipulate the history information. + + History expansions introduce words from the history list into the +input stream, making it easy to repeat commands, insert the arguments to +a previous command into the current input line, or fix errors in +previous commands quickly. + + History expansion is performed immediately after a complete line is +read, before the shell breaks it into words. + + History expansion takes place in two parts. The first is to +determine which line from the history list should be used during +substitution. The second is to select portions of that line for +inclusion into the current one. The line selected from the history is +called the "event", and the portions of that line that are acted upon +are called "words". Various "modifiers" are available to manipulate the +selected words. The line is broken into words in the same fashion that +Bash does, so that several words surrounded by quotes are considered one +word. History expansions are introduced by the appearance of the +history expansion character, which is '!' by default. Only '\' and ''' +may be used to escape the history expansion character, but the history +expansion character is also treated as quoted if it immediately precedes +the closing double quote in a double-quoted string. + + Several shell options settable with the 'shopt' builtin (*note Bash +Builtins::) may be used to tailor the behavior of history expansion. If +the 'histverify' shell option is enabled, and Readline is being used, +history substitutions are not immediately passed to the shell parser. +Instead, the expanded line is reloaded into the Readline editing buffer +for further modification. If Readline is being used, and the +'histreedit' shell option is enabled, a failed history expansion will be +reloaded into the Readline editing buffer for correction. The '-p' +option to the 'history' builtin command may be used to see what a +history expansion will do before using it. The '-s' option to the +'history' builtin may be used to add commands to the end of the history +list without actually executing them, so that they are available for +subsequent recall. This is most useful in conjunction with Readline. + + The shell allows control of the various characters used by the +history expansion mechanism with the 'histchars' variable, as explained +above (*note Bash Variables::). The shell uses the history comment +character to mark history timestamps when writing the history file. + +* Menu: + +* Event Designators:: How to specify which history line to use. +* Word Designators:: Specifying which words are of interest. +* Modifiers:: Modifying the results of substitution. + + +File: bash.info, Node: Event Designators, Next: Word Designators, Up: History Interaction + +9.3.1 Event Designators +----------------------- + +An event designator is a reference to a command line entry in the +history list. Unless the reference is absolute, events are relative to +the current position in the history list. + +'!' + Start a history substitution, except when followed by a space, tab, + the end of the line, '=' or '(' (when the 'extglob' shell option is + enabled using the 'shopt' builtin). + +'!N' + Refer to command line N. + +'!-N' + Refer to the command N lines back. + +'!!' + Refer to the previous command. This is a synonym for '!-1'. + +'!STRING' + Refer to the most recent command preceding the current position in + the history list starting with STRING. + +'!?STRING[?]' + Refer to the most recent command preceding the current position in + the history list containing STRING. The trailing '?' may be + omitted if the STRING is followed immediately by a newline. + +'^STRING1^STRING2^' + Quick Substitution. Repeat the last command, replacing STRING1 + with STRING2. Equivalent to '!!:s/STRING1/STRING2/'. + +'!#' + The entire command line typed so far. + + +File: bash.info, Node: Word Designators, Next: Modifiers, Prev: Event Designators, Up: History Interaction + +9.3.2 Word Designators +---------------------- + +Word designators are used to select desired words from the event. A ':' +separates the event specification from the word designator. It may be +omitted if the word designator begins with a '^', '$', '*', '-', or '%'. +Words are numbered from the beginning of the line, with the first word +being denoted by 0 (zero). Words are inserted into the current line +separated by single spaces. + + For example, + +'!!' + designates the preceding command. When you type this, the + preceding command is repeated in toto. + +'!!:$' + designates the last argument of the preceding command. This may be + shortened to '!$'. + +'!fi:2' + designates the second argument of the most recent command starting + with the letters 'fi'. + + Here are the word designators: + +'0 (zero)' + The '0'th word. For many applications, this is the command word. + +'N' + The Nth word. + +'^' + The first argument; that is, word 1. + +'$' + The last argument. + +'%' + The word matched by the most recent '?STRING?' search. + +'X-Y' + A range of words; '-Y' abbreviates '0-Y'. + +'*' + All of the words, except the '0'th. This is a synonym for '1-$'. + It is not an error to use '*' if there is just one word in the + event; the empty string is returned in that case. + +'X*' + Abbreviates 'X-$' + +'X-' + Abbreviates 'X-$' like 'X*', but omits the last word. + + If a word designator is supplied without an event specification, the +previous command is used as the event. + + +File: bash.info, Node: Modifiers, Prev: Word Designators, Up: History Interaction + +9.3.3 Modifiers +--------------- + +After the optional word designator, you can add a sequence of one or +more of the following modifiers, each preceded by a ':'. + +'h' + Remove a trailing pathname component, leaving only the head. + +'t' + Remove all leading pathname components, leaving the tail. + +'r' + Remove a trailing suffix of the form '.SUFFIX', leaving the + basename. + +'e' + Remove all but the trailing suffix. + +'p' + Print the new command but do not execute it. + +'q' + Quote the substituted words, escaping further substitutions. + +'x' + Quote the substituted words as with 'q', but break into words at + spaces, tabs, and newlines. + +'s/OLD/NEW/' + Substitute NEW for the first occurrence of OLD in the event line. + Any delimiter may be used in place of '/'. The delimiter may be + quoted in OLD and NEW with a single backslash. If '&' appears in + NEW, it is replaced by OLD. A single backslash will quote the '&'. + The final delimiter is optional if it is the last character on the + input line. + +'&' + Repeat the previous substitution. + +'g' +'a' + Cause changes to be applied over the entire event line. Used in + conjunction with 's', as in 'gs/OLD/NEW/', or with '&'. + +'G' + Apply the following 's' modifier once to each word in the event. + + +File: bash.info, Node: Installing Bash, Next: Reporting Bugs, Prev: Using History Interactively, Up: Top + +10 Installing Bash +****************** + +This chapter provides basic instructions for installing Bash on the +various supported platforms. The distribution supports the GNU +operating systems, nearly every version of Unix, and several non-Unix +systems such as BeOS and Interix. Other independent ports exist for +MS-DOS, 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. + + +File: bash.info, Node: Basic Installation, Next: Compilers and Options, Up: Installing Bash + +10.1 Basic Installation +======================= + +These are installation instructions for Bash. + + The simplest way to compile Bash is: + + 1. 'cd' to the directory containing the source code and type + './configure' to configure Bash for your system. If you're using + 'csh' on an old version of System V, you might need to type 'sh + ./configure' instead to prevent 'csh' from trying to execute + 'configure' itself. + + Running 'configure' takes some time. While running, it prints + messages telling which features it is checking for. + + 2. Type 'make' to compile Bash and build the 'bashbug' bug reporting + script. + + 3. Optionally, type 'make tests' to run the Bash test suite. + + 4. Type 'make install' to install 'bash' and 'bashbug'. This will + also install the manual pages and Info file. + + The 'configure' shell script attempts to guess correct values for +various system-dependent variables used during compilation. It uses +those values to create a 'Makefile' in each directory of the package +(the top directory, the 'builtins', 'doc', and 'support' directories, +each directory under 'lib', and several others). It also creates a +'config.h' file containing system-dependent definitions. Finally, it +creates a shell script named 'config.status' that you can run in the +future to recreate the current configuration, a file 'config.cache' that +saves the results of its tests to speed up reconfiguring, and a file +'config.log' containing compiler output (useful mainly for debugging +'configure'). If at some point '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 'configure' +script understands, type + + bash-2.04$ ./configure --help + +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 'configure' could check whether or not to do them, and +mail diffs or instructions to so they can be +considered for the next release. + + The file 'configure.ac' is used to create 'configure' by a program +called Autoconf. You only need 'configure.ac' if you want to change it +or regenerate 'configure' using a newer version of Autoconf. If you do +this, make sure you are using Autoconf version 2.50 or newer. + + You can remove the program binaries and object files from the source +code directory by typing 'make clean'. To also remove the files that +'configure' created (so you can compile Bash for a different kind of +computer), type 'make distclean'. + + +File: bash.info, Node: Compilers and Options, Next: Compiling For Multiple Architectures, Prev: Basic Installation, Up: Installing Bash + +10.2 Compilers and Options +========================== + +Some systems require unusual options for compilation or linking that the +'configure' script does not know about. You can give '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: + + CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure + + On systems that have the 'env' program, you can do it like this: + + env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure + + The configuration process uses GCC to build Bash if it is available. + + +File: bash.info, Node: Compiling For Multiple Architectures, Next: Installation Names, Prev: Compilers and Options, Up: Installing Bash + +10.3 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 'make' that supports +the 'VPATH' variable, such as GNU 'make'. 'cd' to the directory where +you want the object files and executables to go and run the 'configure' +script from the source directory. You may need to supply the +'--srcdir=PATH' argument to tell 'configure' where the source files are. +'configure' automatically checks for the source code in the directory +that 'configure' is in and in '..'. + + If you have to use a 'make' that does not supports the '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 'make distclean' before reconfiguring for another +architecture. + + Alternatively, if your system supports symbolic links, you can use +the '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 '/usr/gnu/src/bash-2.0': + + bash /usr/gnu/src/bash-2.0/support/mkclone -s /usr/gnu/src/bash-2.0 . + +The '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. + + +File: bash.info, Node: Installation Names, Next: Specifying the System Type, Prev: Compiling For Multiple Architectures, Up: Installing Bash + +10.4 Installation Names +======================= + +By default, 'make install' will install into '/usr/local/bin', +'/usr/local/man', etc. You can specify an installation prefix other +than '/usr/local' by giving 'configure' the option '--prefix=PATH', or +by specifying a value for the 'DESTDIR' 'make' variable when running +'make install'. + + You can specify separate installation prefixes for +architecture-specific files and architecture-independent files. If you +give 'configure' the option '--exec-prefix=PATH', 'make install' will +use PATH as the prefix for installing programs and libraries. +Documentation and other data files will still use the regular prefix. + + +File: bash.info, Node: Specifying the System Type, Next: Sharing Defaults, Prev: Installation Names, Up: Installing Bash + +10.5 Specifying the System Type +=============================== + +There may be some features 'configure' can not figure out automatically, +but need to determine by the type of host Bash will run on. Usually +'configure' can figure that out, but if it prints a message saying it +can not guess the host type, give it the '--host=TYPE' option. 'TYPE' +can either be a short name for the system type, such as 'sun4', or a +canonical name with three fields: 'CPU-COMPANY-SYSTEM' (e.g., +'i386-unknown-freebsd4.2'). + + See the file 'support/config.sub' for the possible values of each +field. + + +File: bash.info, Node: Sharing Defaults, Next: Operation Controls, Prev: Specifying the System Type, Up: Installing Bash + +10.6 Sharing Defaults +===================== + +If you want to set default values for 'configure' scripts to share, you +can create a site shell script called 'config.site' that gives default +values for variables like 'CC', 'cache_file', and 'prefix'. 'configure' +looks for 'PREFIX/share/config.site' if it exists, then +'PREFIX/etc/config.site' if it exists. Or, you can set the +'CONFIG_SITE' environment variable to the location of the site script. +A warning: the Bash 'configure' looks for a site script, but not all +'configure' scripts do. + + +File: bash.info, Node: Operation Controls, Next: Optional Features, Prev: Sharing Defaults, Up: Installing Bash + +10.7 Operation Controls +======================= + +'configure' recognizes the following options to control how it operates. + +'--cache-file=FILE' + Use and save the results of the tests in FILE instead of + './config.cache'. Set FILE to '/dev/null' to disable caching, for + debugging 'configure'. + +'--help' + Print a summary of the options to 'configure', and exit. + +'--quiet' +'--silent' +'-q' + Do not print messages saying which checks are being made. + +'--srcdir=DIR' + Look for the Bash source code in directory DIR. Usually + 'configure' can determine that directory automatically. + +'--version' + Print the version of Autoconf used to generate the 'configure' + script, and exit. + + 'configure' also accepts some other, not widely used, boilerplate +options. 'configure --help' prints the complete list. + + +File: bash.info, Node: Optional Features, Prev: Operation Controls, Up: Installing Bash + +10.8 Optional Features +====================== + +The Bash 'configure' has a number of '--enable-FEATURE' options, where +FEATURE indicates an optional part of Bash. There are also several +'--with-PACKAGE' options, where PACKAGE is something like 'bash-malloc' +or 'purify'. To turn off the default use of a package, use +'--without-PACKAGE'. To configure Bash without a feature that is +enabled by default, use '--disable-FEATURE'. + + Here is a complete list of the '--enable-' and '--with-' options that +the Bash 'configure' recognizes. + +'--with-afs' + Define if you are using the Andrew File System from Transarc. + +'--with-bash-malloc' + Use the Bash version of 'malloc' in the directory 'lib/malloc'. + This is not the same 'malloc' that appears in GNU libc, but an + older version originally derived from the 4.2 BSD 'malloc'. This + 'malloc' is very fast, but wastes some space on each allocation. + This option is enabled by default. The 'NOTES' file contains a + list of systems for which this should be turned off, and + 'configure' disables this option automatically for a number of + systems. + +'--with-curses' + Use the curses library instead of the termcap library. This should + be supplied if your system has an inadequate or incomplete termcap + database. + +'--with-gnu-malloc' + A synonym for '--with-bash-malloc'. + +'--with-installed-readline[=PREFIX]' + Define this to make Bash link with a locally-installed version of + Readline rather than the version in 'lib/readline'. This works + only with Readline 5.0 and later versions. If PREFIX is 'yes' or + not supplied, 'configure' uses the values of the make variables + 'includedir' and 'libdir', which are subdirectories of 'prefix' by + default, to find the installed version of Readline if it is not in + the standard system include and library directories. If PREFIX is + 'no', Bash links with the version in 'lib/readline'. If PREFIX is + set to any other value, 'configure' treats it as a directory + pathname and looks for the installed version of Readline in + subdirectories of that directory (include files in PREFIX/'include' + and the library in PREFIX/'lib'). + +'--with-purify' + Define this to use the Purify memory allocation checker from + Rational Software. + +'--enable-minimal-config' + This produces a shell with minimal features, close to the + historical Bourne shell. + + There are several '--enable-' options that alter how Bash is compiled +and linked, rather than changing run-time features. + +'--enable-largefile' + Enable support for large files + (http://www.sas.com/standards/large_file/x_open.20Mar96.html) if + the operating system requires special compiler options to build + programs which can access large files. This is enabled by default, + if the operating system provides large file support. + +'--enable-profiling' + This builds a Bash binary that produces profiling information to be + processed by 'gprof' each time it is executed. + +'--enable-static-link' + This causes Bash to be linked statically, if 'gcc' is being used. + This could be used to build a version to use as root's shell. + + The '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 'enable-FEATURE'. + + All of the following options except for 'disabled-builtins', +'direxpand-default', and 'xpg-echo-default' are enabled by default, +unless the operating system does not provide the necessary support. + +'--enable-alias' + Allow alias expansion and include the 'alias' and 'unalias' + builtins (*note Aliases::). + +'--enable-arith-for-command' + Include support for the alternate form of the 'for' command that + behaves like the C language 'for' statement (*note Looping + Constructs::). + +'--enable-array-variables' + Include support for one-dimensional array shell variables (*note + Arrays::). + +'--enable-bang-history' + Include support for 'csh'-like history substitution (*note History + Interaction::). + +'--enable-brace-expansion' + Include 'csh'-like brace expansion ( 'b{a,b}c' ==> 'bac bbc' ). + See *note Brace Expansion::, for a complete description. + +'--enable-casemod-attributes' + Include support for case-modifying attributes in the 'declare' + builtin and assignment statements. Variables with the UPPERCASE + attribute, for example, will have their values converted to + uppercase upon assignment. + +'--enable-casemod-expansion' + Include support for case-modifying word expansions. + +'--enable-command-timing' + Include support for recognizing 'time' as a reserved word and for + displaying timing statistics for the pipeline following 'time' + (*note Pipelines::). This allows pipelines as well as shell + builtins and functions to be timed. + +'--enable-cond-command' + Include support for the '[[' conditional command. (*note + Conditional Constructs::). + +'--enable-cond-regexp' + Include support for matching POSIX regular expressions using the + '=~' binary operator in the '[[' conditional command. (*note + Conditional Constructs::). + +'--enable-coprocesses' + Include support for coprocesses and the 'coproc' reserved word + (*note Pipelines::). + +'--enable-debugger' + Include support for the bash debugger (distributed separately). + +'--enable-direxpand-default' + Cause the 'direxpand' shell option (*note The Shopt Builtin::) to + be enabled by default when the shell starts. It is normally + disabled by default. + +'--enable-directory-stack' + Include support for a 'csh'-like directory stack and the 'pushd', + 'popd', and 'dirs' builtins (*note The Directory Stack::). + +'--enable-disabled-builtins' + Allow builtin commands to be invoked via 'builtin xxx' even after + 'xxx' has been disabled using 'enable -n xxx'. See *note Bash + Builtins::, for details of the 'builtin' and 'enable' builtin + commands. + +'--enable-dparen-arithmetic' + Include support for the '((...))' command (*note Conditional + Constructs::). + +'--enable-extended-glob' + Include support for the extended pattern matching features + described above under *note Pattern Matching::. + +'--enable-extended-glob-default' + Set the default value of the EXTGLOB shell option described above + under *note The Shopt Builtin:: to be enabled. + +'--enable-function-import' + Include support for importing function definitions exported by + another instance of the shell from the environment. This option is + enabled by default. + +'--enable-glob-asciirange-default' + Set the default value of the GLOBASCIIRANGES shell option described + above under *note The Shopt Builtin:: to be enabled. This controls + the behavior of character ranges when used in pattern matching + bracket expressions. + +'--enable-help-builtin' + Include the 'help' builtin, which displays help on shell builtins + and variables (*note Bash Builtins::). + +'--enable-history' + Include command history and the 'fc' and 'history' builtin commands + (*note Bash History Facilities::). + +'--enable-job-control' + This enables the job control features (*note Job Control::), if the + operating system supports them. + +'--enable-multibyte' + This enables support for multibyte characters if the operating + system provides the necessary support. + +'--enable-net-redirections' + This enables the special handling of filenames of the form + '/dev/tcp/HOST/PORT' and '/dev/udp/HOST/PORT' when used in + redirections (*note Redirections::). + +'--enable-process-substitution' + This enables process substitution (*note Process Substitution::) if + the operating system provides the necessary support. + +'--enable-progcomp' + Enable the programmable completion facilities (*note Programmable + Completion::). If Readline is not enabled, this option has no + effect. + +'--enable-prompt-string-decoding' + Turn on the interpretation of a number of backslash-escaped + characters in the '$PS1', '$PS2', '$PS3', and '$PS4' prompt + strings. See *note Controlling the Prompt::, for a complete list + of prompt string escape sequences. + +'--enable-readline' + Include support for command-line editing and history with the Bash + version of the Readline library (*note Command Line Editing::). + +'--enable-restricted' + Include support for a "restricted shell". If this is enabled, + Bash, when called as 'rbash', enters a restricted mode. See *note + The Restricted Shell::, for a description of restricted mode. + +'--enable-select' + Include the 'select' compound command, which allows the generation + of simple menus (*note Conditional Constructs::). + +'--enable-separate-helpfiles' + Use external files for the documentation displayed by the 'help' + builtin instead of storing the text internally. + +'--enable-single-help-strings' + Store the text displayed by the '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. + +'--enable-strict-posix-default' + Make Bash POSIX-conformant by default (*note Bash POSIX Mode::). + +'--enable-usg-echo-default' + A synonym for '--enable-xpg-echo-default'. + +'--enable-xpg-echo-default' + Make the 'echo' builtin expand backslash-escaped characters by + default, without requiring the '-e' option. This sets the default + value of the 'xpg_echo' shell option to 'on', which makes the Bash + 'echo' behave more like the version specified in the Single Unix + Specification, version 3. *Note Bash Builtins::, for a description + of the escape sequences that 'echo' recognizes. + + The file 'config-top.h' contains C Preprocessor '#define' statements +for options which are not settable from '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. + + +File: bash.info, Node: Reporting Bugs, Next: Major Differences From The Bourne Shell, Prev: Installing Bash, Up: Top + +Appendix A 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 +. + + Once you have determined that a bug actually exists, use the +'bashbug' command to submit a bug report. If you have a fix, you are +encouraged to mail that as well! Suggestions and 'philosophical' bug +reports may be mailed to or posted to the Usenet +newsgroup 'gnu.bash.bug'. + + All bug reports should include: + * The version number of Bash. + * The hardware and operating system. + * The compiler used to compile Bash. + * A description of the bug behaviour. + * A short script or 'recipe' which exercises the bug and may be used + to reproduce it. + +'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 . + + +File: bash.info, Node: Major Differences From The Bourne Shell, Next: GNU Free Documentation License, Prev: Reporting Bugs, Up: Top + +Appendix B 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 +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 'sh' +included in SVR4.2 (the last version of the historical Bourne shell) as +the baseline reference. + + * Bash is POSIX-conformant, even where the POSIX specification + differs from traditional 'sh' behavior (*note Bash POSIX Mode::). + + * Bash has multi-character invocation options (*note Invoking + Bash::). + + * Bash has command-line editing (*note Command Line Editing::) and + the 'bind' builtin. + + * Bash provides a programmable word completion mechanism (*note + Programmable Completion::), and builtin commands 'complete', + 'compgen', and 'compopt', to manipulate it. + + * Bash has command history (*note Bash History Facilities::) and the + 'history' and 'fc' builtins to manipulate it. The Bash history + list maintains timestamp information and uses the value of the + 'HISTTIMEFORMAT' variable to display it. + + * Bash implements 'csh'-like history expansion (*note History + Interaction::). + + * Bash has one-dimensional array variables (*note 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. + + * The '$'...'' quoting syntax, which expands ANSI-C backslash-escaped + characters in the text between the single quotes, is supported + (*note ANSI-C Quoting::). + + * Bash supports the '$"..."' quoting syntax to do locale-specific + translation of the characters between the double quotes. The '-D', + '--dump-strings', and '--dump-po-strings' invocation options list + the translatable strings found in a script (*note Locale + Translation::). + + * Bash implements the '!' keyword to negate the return value of a + pipeline (*note Pipelines::). Very useful when an 'if' statement + needs to act only if a test fails. The Bash '-o pipefail' option + to 'set' will cause a pipeline to return a failure status if any + command fails. + + * Bash has the 'time' reserved word and command timing (*note + Pipelines::). The display of the timing statistics may be + controlled with the 'TIMEFORMAT' variable. + + * Bash implements the 'for (( EXPR1 ; EXPR2 ; EXPR3 ))' arithmetic + for command, similar to the C language (*note Looping + Constructs::). + + * Bash includes the 'select' compound command, which allows the + generation of simple menus (*note Conditional Constructs::). + + * Bash includes the '[[' compound command, which makes conditional + testing part of the shell grammar (*note Conditional Constructs::), + including optional regular expression matching. + + * Bash provides optional case-insensitive matching for the 'case' and + '[[' constructs. + + * Bash includes brace expansion (*note Brace Expansion::) and tilde + expansion (*note Tilde Expansion::). + + * Bash implements command aliases and the 'alias' and 'unalias' + builtins (*note Aliases::). + + * Bash provides shell arithmetic, the '((' compound command (*note + Conditional Constructs::), and arithmetic expansion (*note Shell + Arithmetic::). + + * 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 'export' command. + + * Bash supports the '+=' assignment operator, which appends to the + value of the variable named on the left hand side. + + * Bash includes the POSIX pattern removal '%', '#', '%%' and '##' + expansions to remove leading or trailing substrings from variable + values (*note Shell Parameter Expansion::). + + * The expansion '${#xx}', which returns the length of '${xx}', is + supported (*note Shell Parameter Expansion::). + + * The expansion '${var:'OFFSET'[:'LENGTH']}', which expands to the + substring of 'var''s value of length LENGTH, beginning at OFFSET, + is present (*note Shell Parameter Expansion::). + + * The expansion '${var/[/]'PATTERN'[/'REPLACEMENT']}', which matches + PATTERN and replaces it with REPLACEMENT in the value of 'var', is + available (*note Shell Parameter Expansion::). + + * The expansion '${!PREFIX*}' expansion, which expands to the names + of all shell variables whose names begin with PREFIX, is available + (*note Shell Parameter Expansion::). + + * Bash has INDIRECT variable expansion using '${!word}' (*note Shell + Parameter Expansion::). + + * Bash can expand positional parameters beyond '$9' using '${NUM}'. + + * The POSIX '$()' form of command substitution is implemented (*note + Command Substitution::), and preferred to the Bourne shell's '``' + (which is also implemented for backwards compatibility). + + * Bash has process substitution (*note Process Substitution::). + + * Bash automatically assigns variables that provide information about + the current user ('UID', 'EUID', and 'GROUPS'), the current host + ('HOSTTYPE', 'OSTYPE', 'MACHTYPE', and 'HOSTNAME'), and the + instance of Bash that is running ('BASH', 'BASH_VERSION', and + 'BASH_VERSINFO'). *Note Bash Variables::, for details. + + * The 'IFS' variable is used to split only the results of expansion, + not all words (*note Word Splitting::). This closes a longstanding + shell security hole. + + * The filename expansion bracket expression code uses '!' and '^' to + negate the set of characters between the brackets. The Bourne + shell uses only '!'. + + * Bash implements the full set of POSIX filename expansion operators, + including CHARACTER CLASSES, EQUIVALENCE CLASSES, and COLLATING + SYMBOLS (*note Filename Expansion::). + + * Bash implements extended pattern matching features when the + 'extglob' shell option is enabled (*note Pattern Matching::). + + * It is possible to have a variable and a function with the same + name; 'sh' does not separate the two name spaces. + + * Bash functions are permitted to have local variables using the + 'local' builtin, and thus useful recursive functions may be written + (*note Bash Builtins::). + + * Variable assignments preceding commands affect only that command, + even builtins and functions (*note Environment::). In 'sh', all + variable assignments preceding commands are global unless the + command is executed from the file system. + + * Bash performs filename expansion on filenames specified as operands + to input and output redirection operators (*note Redirections::). + + * Bash contains the '<>' redirection operator, allowing a file to be + opened for both reading and writing, and the '&>' redirection + operator, for directing standard output and standard error to the + same file (*note Redirections::). + + * Bash includes the '<<<' redirection operator, allowing a string to + be used as the standard input to a command. + + * Bash implements the '[n]<&WORD' and '[n]>&WORD' redirection + operators, which move one file descriptor to another. + + * Bash treats a number of filenames specially when they are used in + redirection operators (*note Redirections::). + + * Bash can open network connections to arbitrary machines and + services with the redirection operators (*note Redirections::). + + * The 'noclobber' option is available to avoid overwriting existing + files with output redirection (*note The Set Builtin::). The '>|' + redirection operator may be used to override 'noclobber'. + + * The Bash 'cd' and 'pwd' builtins (*note Bourne Shell Builtins::) + each take '-L' and '-P' options to switch between logical and + physical modes. + + * 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 'builtin' and 'command' builtins (*note Bash + Builtins::). + + * The 'command' builtin allows selective disabling of functions when + command lookup is performed (*note Bash Builtins::). + + * Individual builtins may be enabled or disabled using the 'enable' + builtin (*note Bash Builtins::). + + * The Bash '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 + (*note Bourne Shell Builtins::). + + * Shell functions may be exported to children via the environment + using 'export -f' (*note Shell Functions::). + + * The Bash 'export', 'readonly', and 'declare' builtins can take a + '-f' option to act on shell functions, a '-p' option to display + variables with various attributes set in a format that can be used + as shell input, a '-n' option to remove various variable + attributes, and 'name=value' arguments to set variable attributes + and values simultaneously. + + * The Bash 'hash' builtin allows a name to be associated with an + arbitrary filename, even when that filename cannot be found by + searching the '$PATH', using 'hash -p' (*note Bourne Shell + Builtins::). + + * Bash includes a 'help' builtin for quick reference to shell + facilities (*note Bash Builtins::). + + * The 'printf' builtin is available to display formatted output + (*note Bash Builtins::). + + * The Bash 'read' builtin (*note Bash Builtins::) will read a line + ending in '\' with the '-r' option, and will use the 'REPLY' + variable as a default if no non-option arguments are supplied. The + Bash 'read' builtin also accepts a prompt string with the '-p' + option and will use Readline to obtain the line when given the '-e' + option. The 'read' builtin also has additional options to control + input: the '-s' option will turn off echoing of input characters as + they are read, the '-t' option will allow 'read' to time out if + input does not arrive within a specified number of seconds, the + '-n' option will allow reading only a specified number of + characters rather than a full line, and the '-d' option will read + until a particular character rather than newline. + + * The 'return' builtin may be used to abort execution of scripts + executed with the '.' or 'source' builtins (*note Bourne Shell + Builtins::). + + * Bash includes the 'shopt' builtin, for finer control of shell + optional capabilities (*note The Shopt Builtin::), and allows these + options to be set and unset at shell invocation (*note Invoking + Bash::). + + * Bash has much more optional behavior controllable with the 'set' + builtin (*note The Set Builtin::). + + * The '-x' ('xtrace') option displays commands other than simple + commands when performing an execution trace (*note The Set + Builtin::). + + * The 'test' builtin (*note Bourne Shell Builtins::) is slightly + different, as it implements the POSIX algorithm, which specifies + the behavior based on the number of arguments. + + * Bash includes the 'caller' builtin, which displays the context of + any active subroutine call (a shell function or a script executed + with the '.' or 'source' builtins). This supports the bash + debugger. + + * The 'trap' builtin (*note Bourne Shell Builtins::) allows a 'DEBUG' + pseudo-signal specification, similar to 'EXIT'. Commands specified + with a 'DEBUG' trap are executed before every simple command, 'for' + command, 'case' command, 'select' command, every arithmetic 'for' + command, and before the first command executes in a shell function. + The 'DEBUG' trap is not inherited by shell functions unless the + function has been given the 'trace' attribute or the 'functrace' + option has been enabled using the 'shopt' builtin. The 'extdebug' + shell option has additional effects on the 'DEBUG' trap. + + The 'trap' builtin (*note Bourne Shell Builtins::) allows an 'ERR' + pseudo-signal specification, similar to 'EXIT' and 'DEBUG'. + Commands specified with an 'ERR' trap are executed after a simple + command fails, with a few exceptions. The 'ERR' trap is not + inherited by shell functions unless the '-o errtrace' option to the + 'set' builtin is enabled. + + The 'trap' builtin (*note Bourne Shell Builtins::) allows a + 'RETURN' pseudo-signal specification, similar to 'EXIT' and + 'DEBUG'. Commands specified with an 'RETURN' trap are executed + before execution resumes after a shell function or a shell script + executed with '.' or 'source' returns. The 'RETURN' trap is not + inherited by shell functions unless the function has been given the + 'trace' attribute or the 'functrace' option has been enabled using + the 'shopt' builtin. + + * The Bash 'type' builtin is more extensive and gives more + information about the names it finds (*note Bash Builtins::). + + * The Bash 'umask' builtin permits a '-p' option to cause the output + to be displayed in the form of a 'umask' command that may be reused + as input (*note Bourne Shell Builtins::). + + * Bash implements a 'csh'-like directory stack, and provides the + 'pushd', 'popd', and 'dirs' builtins to manipulate it (*note The + Directory Stack::). Bash also makes the directory stack visible as + the value of the 'DIRSTACK' shell variable. + + * Bash interprets special backslash-escaped characters in the prompt + strings when interactive (*note Controlling the Prompt::). + + * The Bash restricted mode is more useful (*note The Restricted + Shell::); the SVR4.2 shell restricted mode is too limited. + + * The 'disown' builtin can remove a job from the internal shell job + table (*note Job Control Builtins::) or suppress the sending of + 'SIGHUP' to a job when the shell exits as the result of a 'SIGHUP'. + + * Bash includes a number of features to support a separate debugger + for shell scripts. + + * The SVR4.2 shell has two privilege-related builtins ('mldmode' and + 'priv') not present in Bash. + + * Bash does not have the 'stop' or 'newgrp' builtins. + + * Bash does not use the 'SHACCT' variable or perform shell + accounting. + + * The SVR4.2 'sh' uses a 'TIMEOUT' variable like Bash uses 'TMOUT'. + +More features unique to Bash may be found in *note Bash Features::. + +B.1 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: + + * Bash does not fork a subshell when redirecting into or out of a + shell control structure such as an 'if' or 'while' statement. + + * Bash does not allow unbalanced quotes. The SVR4.2 shell will + silently insert a needed closing quote at 'EOF' under certain + circumstances. This can be the cause of some hard-to-find errors. + + * The SVR4.2 shell uses a baroque memory management scheme based on + trapping 'SIGSEGV'. If the shell is started from a process with + 'SIGSEGV' blocked (e.g., by using the 'system()' C library function + call), it misbehaves badly. + + * In a questionable attempt at security, the SVR4.2 shell, when + invoked without the '-p' option, will alter its real and effective + UID and GID if they are less than some magic threshold value, + commonly 100. This can lead to unexpected results. + + * The SVR4.2 shell does not allow users to trap 'SIGSEGV', 'SIGALRM', + or 'SIGCHLD'. + + * The SVR4.2 shell does not allow the 'IFS', 'MAILCHECK', 'PATH', + 'PS1', or 'PS2' variables to be unset. + + * The SVR4.2 shell treats '^' as the undocumented equivalent of '|'. + + * Bash allows multiple option arguments when it is invoked ('-x -v'); + the SVR4.2 shell allows only one option argument ('-xv'). In fact, + some versions of the shell dump core if the second argument begins + with a '-'. + + * The SVR4.2 shell exits a script if any builtin fails; Bash exits a + script only if one of the POSIX special builtins fails, and only + for certain failures, as enumerated in the POSIX standard. + + * The SVR4.2 shell behaves differently when invoked as 'jsh' (it + turns on job control). + + +File: bash.info, Node: GNU Free Documentation License, Next: Indexes, Prev: Major Differences From The Bourne Shell, Up: Top + +Appendix C GNU Free Documentation License +***************************************** + + Version 1.3, 3 November 2008 + + Copyright (C) 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc. + + + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + 0. PREAMBLE + + The purpose of this License is to make a manual, textbook, or other + functional and useful document "free" in the sense of freedom: to + assure everyone the effective freedom to copy and redistribute it, + with or without modifying it, either commercially or + noncommercially. Secondarily, this License preserves for the + author and publisher a way to get credit for their work, while not + being considered responsible for modifications made by others. + + This License is a kind of "copyleft", which means that derivative + works of the document must themselves be free in the same sense. + It complements the GNU General Public License, which is a copyleft + license designed for free software. + + We have designed this License in order to use it for manuals for + free software, because free software needs free documentation: a + free program should come with manuals providing the same freedoms + that the software does. But this License is not limited to + software manuals; it can be used for any textual work, regardless + of subject matter or whether it is published as a printed book. We + recommend this License principally for works whose purpose is + instruction or reference. + + 1. APPLICABILITY AND DEFINITIONS + + This License applies to any manual or other work, in any medium, + that contains a notice placed by the copyright holder saying it can + be distributed under the terms of this License. Such a notice + grants a world-wide, royalty-free license, unlimited in duration, + to use that work under the conditions stated herein. The + "Document", below, refers to any such manual or work. Any member + of the public is a licensee, and is addressed as "you". You accept + the license if you copy, modify or distribute the work in a way + requiring permission under copyright law. + + A "Modified Version" of the Document means any work containing the + Document or a portion of it, either copied verbatim, or with + modifications and/or translated into another language. + + A "Secondary Section" is a named appendix or a front-matter section + of the Document that deals exclusively with the relationship of the + publishers or authors of the Document to the Document's overall + subject (or to related matters) and contains nothing that could + fall directly within that overall subject. (Thus, if the Document + is in part a textbook of mathematics, a Secondary Section may not + explain any mathematics.) The relationship could be a matter of + historical connection with the subject or with related matters, or + of legal, commercial, philosophical, ethical or political position + regarding them. + + The "Invariant Sections" are certain Secondary Sections whose + titles are designated, as being those of Invariant Sections, in the + notice that says that the Document is released under this License. + If a section does not fit the above definition of Secondary then it + is not allowed to be designated as Invariant. The Document may + contain zero Invariant Sections. If the Document does not identify + any Invariant Sections then there are none. + + The "Cover Texts" are certain short passages of text that are + listed, as Front-Cover Texts or Back-Cover Texts, in the notice + that says that the Document is released under this License. A + Front-Cover Text may be at most 5 words, and a Back-Cover Text may + be at most 25 words. + + A "Transparent" copy of the Document means a machine-readable copy, + represented in a format whose specification is available to the + general public, that is suitable for revising the document + straightforwardly with generic text editors or (for images composed + of pixels) generic paint programs or (for drawings) some widely + available drawing editor, and that is suitable for input to text + formatters or for automatic translation to a variety of formats + suitable for input to text formatters. A copy made in an otherwise + Transparent file format whose markup, or absence of markup, has + been arranged to thwart or discourage subsequent modification by + readers is not Transparent. An image format is not Transparent if + used for any substantial amount of text. A copy that is not + "Transparent" is called "Opaque". + + Examples of suitable formats for Transparent copies include plain + ASCII without markup, Texinfo input format, LaTeX input format, + SGML or XML using a publicly available DTD, and standard-conforming + simple HTML, PostScript or PDF designed for human modification. + Examples of transparent image formats include PNG, XCF and JPG. + Opaque formats include proprietary formats that can be read and + edited only by proprietary word processors, SGML or XML for which + the DTD and/or processing tools are not generally available, and + the machine-generated HTML, PostScript or PDF produced by some word + processors for output purposes only. + + The "Title Page" means, for a printed book, the title page itself, + plus such following pages as are needed to hold, legibly, the + material this License requires to appear in the title page. For + works in formats which do not have any title page as such, "Title + Page" means the text near the most prominent appearance of the + work's title, preceding the beginning of the body of the text. + + The "publisher" means any person or entity that distributes copies + of the Document to the public. + + A section "Entitled XYZ" means a named subunit of the Document + whose title either is precisely XYZ or contains XYZ in parentheses + following text that translates XYZ in another language. (Here XYZ + stands for a specific section name mentioned below, such as + "Acknowledgements", "Dedications", "Endorsements", or "History".) + To "Preserve the Title" of such a section when you modify the + Document means that it remains a section "Entitled XYZ" according + to this definition. + + The Document may include Warranty Disclaimers next to the notice + which states that this License applies to the Document. These + Warranty Disclaimers are considered to be included by reference in + this License, but only as regards disclaiming warranties: any other + implication that these Warranty Disclaimers may have is void and + has no effect on the meaning of this License. + + 2. VERBATIM COPYING + + You may copy and distribute the Document in any medium, either + commercially or noncommercially, provided that this License, the + copyright notices, and the license notice saying this License + applies to the Document are reproduced in all copies, and that you + add no other conditions whatsoever to those of this License. You + may not use technical measures to obstruct or control the reading + or further copying of the copies you make or distribute. However, + you may accept compensation in exchange for copies. If you + distribute a large enough number of copies you must also follow the + conditions in section 3. + + You may also lend copies, under the same conditions stated above, + and you may publicly display copies. + + 3. COPYING IN QUANTITY + + If you publish printed copies (or copies in media that commonly + have printed covers) of the Document, numbering more than 100, and + the Document's license notice requires Cover Texts, you must + enclose the copies in covers that carry, clearly and legibly, all + these Cover Texts: Front-Cover Texts on the front cover, and + Back-Cover Texts on the back cover. Both covers must also clearly + and legibly identify you as the publisher of these copies. The + front cover must present the full title with all words of the title + equally prominent and visible. You may add other material on the + covers in addition. Copying with changes limited to the covers, as + long as they preserve the title of the Document and satisfy these + conditions, can be treated as verbatim copying in other respects. + + If the required texts for either cover are too voluminous to fit + legibly, you should put the first ones listed (as many as fit + reasonably) on the actual cover, and continue the rest onto + adjacent pages. + + If you publish or distribute Opaque copies of the Document + numbering more than 100, you must either include a machine-readable + Transparent copy along with each Opaque copy, or state in or with + each Opaque copy a computer-network location from which the general + network-using public has access to download using public-standard + network protocols a complete Transparent copy of the Document, free + of added material. If you use the latter option, you must take + reasonably prudent steps, when you begin distribution of Opaque + copies in quantity, to ensure that this Transparent copy will + remain thus accessible at the stated location until at least one + year after the last time you distribute an Opaque copy (directly or + through your agents or retailers) of that edition to the public. + + It is requested, but not required, that you contact the authors of + the Document well before redistributing any large number of copies, + to give them a chance to provide you with an updated version of the + Document. + + 4. MODIFICATIONS + + You may copy and distribute a Modified Version of the Document + under the conditions of sections 2 and 3 above, provided that you + release the Modified Version under precisely this License, with the + Modified Version filling the role of the Document, thus licensing + distribution and modification of the Modified Version to whoever + possesses a copy of it. In addition, you must do these things in + the Modified Version: + + A. Use in the Title Page (and on the covers, if any) a title + distinct from that of the Document, and from those of previous + versions (which should, if there were any, be listed in the + History section of the Document). You may use the same title + as a previous version if the original publisher of that + version gives permission. + + B. List on the Title Page, as authors, one or more persons or + entities responsible for authorship of the modifications in + the Modified Version, together with at least five of the + principal authors of the Document (all of its principal + authors, if it has fewer than five), unless they release you + from this requirement. + + C. State on the Title page the name of the publisher of the + Modified Version, as the publisher. + + D. Preserve all the copyright notices of the Document. + + E. Add an appropriate copyright notice for your modifications + adjacent to the other copyright notices. + + F. Include, immediately after the copyright notices, a license + notice giving the public permission to use the Modified + Version under the terms of this License, in the form shown in + the Addendum below. + + G. Preserve in that license notice the full lists of Invariant + Sections and required Cover Texts given in the Document's + license notice. + + H. Include an unaltered copy of this License. + + I. Preserve the section Entitled "History", Preserve its Title, + and add to it an item stating at least the title, year, new + authors, and publisher of the Modified Version as given on the + Title Page. If there is no section Entitled "History" in the + Document, create one stating the title, year, authors, and + publisher of the Document as given on its Title Page, then add + an item describing the Modified Version as stated in the + previous sentence. + + J. Preserve the network location, if any, given in the Document + for public access to a Transparent copy of the Document, and + likewise the network locations given in the Document for + previous versions it was based on. These may be placed in the + "History" section. You may omit a network location for a work + that was published at least four years before the Document + itself, or if the original publisher of the version it refers + to gives permission. + + K. For any section Entitled "Acknowledgements" or "Dedications", + Preserve the Title of the section, and preserve in the section + all the substance and tone of each of the contributor + acknowledgements and/or dedications given therein. + + L. Preserve all the Invariant Sections of the Document, unaltered + in their text and in their titles. Section numbers or the + equivalent are not considered part of the section titles. + + M. Delete any section Entitled "Endorsements". Such a section + may not be included in the Modified Version. + + N. Do not retitle any existing section to be Entitled + "Endorsements" or to conflict in title with any Invariant + Section. + + O. Preserve any Warranty Disclaimers. + + If the Modified Version includes new front-matter sections or + appendices that qualify as Secondary Sections and contain no + material copied from the Document, you may at your option designate + some or all of these sections as invariant. To do this, add their + titles to the list of Invariant Sections in the Modified Version's + license notice. These titles must be distinct from any other + section titles. + + You may add a section Entitled "Endorsements", provided it contains + nothing but endorsements of your Modified Version by various + parties--for example, statements of peer review or that the text + has been approved by an organization as the authoritative + definition of a standard. + + You may add a passage of up to five words as a Front-Cover Text, + and a passage of up to 25 words as a Back-Cover Text, to the end of + the list of Cover Texts in the Modified Version. Only one passage + of Front-Cover Text and one of Back-Cover Text may be added by (or + through arrangements made by) any one entity. If the Document + already includes a cover text for the same cover, previously added + by you or by arrangement made by the same entity you are acting on + behalf of, you may not add another; but you may replace the old + one, on explicit permission from the previous publisher that added + the old one. + + The author(s) and publisher(s) of the Document do not by this + License give permission to use their names for publicity for or to + assert or imply endorsement of any Modified Version. + + 5. COMBINING DOCUMENTS + + You may combine the Document with other documents released under + this License, under the terms defined in section 4 above for + modified versions, provided that you include in the combination all + of the Invariant Sections of all of the original documents, + unmodified, and list them all as Invariant Sections of your + combined work in its license notice, and that you preserve all + their Warranty Disclaimers. + + The combined work need only contain one copy of this License, and + multiple identical Invariant Sections may be replaced with a single + copy. If there are multiple Invariant Sections with the same name + but different contents, make the title of each such section unique + by adding at the end of it, in parentheses, the name of the + original author or publisher of that section if known, or else a + unique number. Make the same adjustment to the section titles in + the list of Invariant Sections in the license notice of the + combined work. + + In the combination, you must combine any sections Entitled + "History" in the various original documents, forming one section + Entitled "History"; likewise combine any sections Entitled + "Acknowledgements", and any sections Entitled "Dedications". You + must delete all sections Entitled "Endorsements." + + 6. COLLECTIONS OF DOCUMENTS + + You may make a collection consisting of the Document and other + documents released under this License, and replace the individual + copies of this License in the various documents with a single copy + that is included in the collection, provided that you follow the + rules of this License for verbatim copying of each of the documents + in all other respects. + + You may extract a single document from such a collection, and + distribute it individually under this License, provided you insert + a copy of this License into the extracted document, and follow this + License in all other respects regarding verbatim copying of that + document. + + 7. AGGREGATION WITH INDEPENDENT WORKS + + A compilation of the Document or its derivatives with other + separate and independent documents or works, in or on a volume of a + storage or distribution medium, is called an "aggregate" if the + copyright resulting from the compilation is not used to limit the + legal rights of the compilation's users beyond what the individual + works permit. When the Document is included in an aggregate, this + License does not apply to the other works in the aggregate which + are not themselves derivative works of the Document. + + If the Cover Text requirement of section 3 is applicable to these + copies of the Document, then if the Document is less than one half + of the entire aggregate, the Document's Cover Texts may be placed + on covers that bracket the Document within the aggregate, or the + electronic equivalent of covers if the Document is in electronic + form. Otherwise they must appear on printed covers that bracket + the whole aggregate. + + 8. TRANSLATION + + Translation is considered a kind of modification, so you may + distribute translations of the Document under the terms of section + 4. Replacing Invariant Sections with translations requires special + permission from their copyright holders, but you may include + translations of some or all Invariant Sections in addition to the + original versions of these Invariant Sections. You may include a + translation of this License, and all the license notices in the + Document, and any Warranty Disclaimers, provided that you also + include the original English version of this License and the + original versions of those notices and disclaimers. In case of a + disagreement between the translation and the original version of + this License or a notice or disclaimer, the original version will + prevail. + + If a section in the Document is Entitled "Acknowledgements", + "Dedications", or "History", the requirement (section 4) to + Preserve its Title (section 1) will typically require changing the + actual title. + + 9. TERMINATION + + You may not copy, modify, sublicense, or distribute the Document + except as expressly provided under this License. Any attempt + otherwise to copy, modify, sublicense, or distribute it is void, + and will automatically terminate your rights under this License. + + However, if you cease all violation of this License, then your + license from a particular copyright holder is reinstated (a) + provisionally, unless and until the copyright holder explicitly and + finally terminates your license, and (b) permanently, if the + copyright holder fails to notify you of the violation by some + reasonable means prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is + reinstated permanently if the copyright holder notifies you of the + violation by some reasonable means, this is the first time you have + received notice of violation of this License (for any work) from + that copyright holder, and you cure the violation prior to 30 days + after your receipt of the notice. + + Termination of your rights under this section does not terminate + the licenses of parties who have received copies or rights from you + under this License. If your rights have been terminated and not + permanently reinstated, receipt of a copy of some or all of the + same material does not give you any rights to use it. + + 10. FUTURE REVISIONS OF THIS LICENSE + + The Free Software Foundation may publish new, revised versions of + the GNU Free Documentation License from time to time. Such new + versions will be similar in spirit to the present version, but may + differ in detail to address new problems or concerns. See + . + + Each version of the License is given a distinguishing version + number. If the Document specifies that a particular numbered + version of this License "or any later version" applies to it, you + have the option of following the terms and conditions either of + that specified version or of any later version that has been + published (not as a draft) by the Free Software Foundation. If the + Document does not specify a version number of this License, you may + choose any version ever published (not as a draft) by the Free + Software Foundation. If the Document specifies that a proxy can + decide which future versions of this License can be used, that + proxy's public statement of acceptance of a version permanently + authorizes you to choose that version for the Document. + + 11. RELICENSING + + "Massive Multiauthor Collaboration Site" (or "MMC Site") means any + World Wide Web server that publishes copyrightable works and also + provides prominent facilities for anybody to edit those works. A + public wiki that anybody can edit is an example of such a server. + A "Massive Multiauthor Collaboration" (or "MMC") contained in the + site means any set of copyrightable works thus published on the MMC + site. + + "CC-BY-SA" means the Creative Commons Attribution-Share Alike 3.0 + license published by Creative Commons Corporation, a not-for-profit + corporation with a principal place of business in San Francisco, + California, as well as future copyleft versions of that license + published by that same organization. + + "Incorporate" means to publish or republish a Document, in whole or + in part, as part of another Document. + + An MMC is "eligible for relicensing" if it is licensed under this + License, and if all works that were first published under this + License somewhere other than this MMC, and subsequently + incorporated in whole or in part into the MMC, (1) had no cover + texts or invariant sections, and (2) were thus incorporated prior + to November 1, 2008. + + The operator of an MMC Site may republish an MMC contained in the + site under CC-BY-SA on the same site at any time before August 1, + 2009, provided the MMC is eligible for relicensing. + +ADDENDUM: How to use this License for your documents +==================================================== + +To use this License in a document you have written, include a copy of +the License in the document and put the following copyright and license +notices just after the title page: + + Copyright (C) YEAR YOUR NAME. + Permission is granted to copy, distribute and/or modify this document + under the terms of the GNU Free Documentation License, Version 1.3 + or any later version published by the Free Software Foundation; + with no Invariant Sections, no Front-Cover Texts, and no Back-Cover + Texts. A copy of the license is included in the section entitled ``GNU + Free Documentation License''. + + If you have Invariant Sections, Front-Cover Texts and Back-Cover +Texts, replace the "with...Texts." line with this: + + with the Invariant Sections being LIST THEIR TITLES, with + the Front-Cover Texts being LIST, and with the Back-Cover Texts + being LIST. + + If you have Invariant Sections without Cover Texts, or some other +combination of the three, merge those two alternatives to suit the +situation. + + If your document contains nontrivial examples of program code, we +recommend releasing these examples in parallel under your choice of free +software license, such as the GNU General Public License, to permit +their use in free software. + + +File: bash.info, Node: Indexes, Prev: GNU Free Documentation License, Up: Top + +Appendix D Indexes +****************** + +* Menu: + +* 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. + + +File: bash.info, Node: Builtin Index, Next: Reserved Word Index, Up: Indexes + +D.1 Index of Shell Builtin Commands +=================================== + +