summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJari Aalto <jari.aalto@cante.net>2000-03-17 21:46:59 +0000
committerJari Aalto <jari.aalto@cante.net>2009-09-12 16:46:53 +0000
commitbb70624e964126b7ac4ff085ba163a9c35ffa18f (patch)
treeba2dd4add13ada94b1899c6d4aca80195b80b74b
parentb72432fdcc59300c6fe7c9d6c8a31ad3447933f5 (diff)
downloadbash-bb70624e964126b7ac4ff085ba163a9c35ffa18f.tar.gz
Imported from ../bash-2.04.tar.gz.
-rw-r--r--CHANGES606
-rw-r--r--COMPAT9
-rw-r--r--CWRU/POSIX.NOTES41
-rw-r--r--CWRU/changelog2528
-rw-r--r--INSTALL137
-rw-r--r--MANIFEST105
-rw-r--r--Makefile.in606
-rw-r--r--NEWS108
-rw-r--r--NOTES12
-rw-r--r--README17
-rw-r--r--aclocal.m4172
-rw-r--r--alias.c32
-rw-r--r--alias.h2
-rw-r--r--array.c39
-rw-r--r--array.h21
-rw-r--r--bashansi.h2
-rw-r--r--bashhist.c75
-rw-r--r--bashhist.h2
-rw-r--r--bashintl.h2
-rw-r--r--bashjmp.h18
-rw-r--r--bashline.c500
-rw-r--r--bashline.h12
-rw-r--r--bashtty.h34
-rw-r--r--bashtypes.h2
-rw-r--r--bracecomp.c2
-rw-r--r--braces.c12
-rw-r--r--builtins.h4
-rw-r--r--builtins/Makefile.in241
-rw-r--r--builtins/alias.def4
-rw-r--r--builtins/bashgetopt.c4
-rw-r--r--builtins/bashgetopt.h2
-rw-r--r--builtins/bind.def20
-rw-r--r--builtins/break.def4
-rw-r--r--builtins/builtin.def4
-rw-r--r--builtins/cd.def51
-rw-r--r--builtins/colon.def4
-rw-r--r--builtins/command.def4
-rw-r--r--builtins/common.c90
-rw-r--r--builtins/common.h8
-rw-r--r--builtins/complete.def512
-rw-r--r--builtins/declare.def31
-rw-r--r--builtins/echo.def32
-rw-r--r--builtins/enable.def19
-rw-r--r--builtins/eval.def4
-rw-r--r--builtins/evalfile.c8
-rw-r--r--builtins/evalstring.c50
-rw-r--r--builtins/exec.def6
-rw-r--r--builtins/exit.def4
-rw-r--r--builtins/fc.def8
-rw-r--r--builtins/fg_bg.def4
-rw-r--r--builtins/getopt.c4
-rw-r--r--builtins/getopt.h2
-rw-r--r--builtins/getopts.def6
-rw-r--r--builtins/hash.def12
-rw-r--r--builtins/help.def24
-rw-r--r--builtins/history.def74
-rw-r--r--builtins/inlib.def4
-rw-r--r--builtins/jobs.def4
-rw-r--r--builtins/kill.def4
-rw-r--r--builtins/let.def4
-rw-r--r--builtins/mkbuiltins.c12
-rw-r--r--builtins/printf.def220
-rw-r--r--builtins/psize.c4
-rwxr-xr-xbuiltins/psize.sh2
-rw-r--r--builtins/pushd.def6
-rw-r--r--builtins/read.def268
-rw-r--r--builtins/reserved.def4
-rw-r--r--builtins/return.def5
-rw-r--r--builtins/set.def27
-rw-r--r--builtins/setattr.def8
-rw-r--r--builtins/shift.def4
-rw-r--r--builtins/shopt.def31
-rw-r--r--builtins/source.def8
-rw-r--r--builtins/suspend.def4
-rw-r--r--builtins/test.def4
-rw-r--r--builtins/times.def29
-rw-r--r--builtins/trap.def4
-rw-r--r--builtins/type.def33
-rw-r--r--builtins/ulimit.def8
-rw-r--r--builtins/umask.def10
-rw-r--r--builtins/wait.def23
-rw-r--r--command.h24
-rw-r--r--config-bot.h11
-rw-r--r--config-top.h4
-rw-r--r--config.h.in71
-rwxr-xr-xconfigure2123
-rw-r--r--configure.in157
-rw-r--r--copy_cmd.c44
-rw-r--r--dispose_cmd.c26
-rw-r--r--dispose_cmd.h2
-rw-r--r--doc/FAQ622
-rw-r--r--doc/Makefile.in76
-rw-r--r--doc/bash.1890
-rw-r--r--doc/bashref.info4132
-rw-r--r--doc/bashref.texi2881
-rw-r--r--doc/builtins.12
-rwxr-xr-xdoc/htmlpost.sh22
-rw-r--r--doc/rbash.18
-rw-r--r--doc/readline.311
-rw-r--r--error.c14
-rw-r--r--error.h2
-rw-r--r--eval.c89
-rw-r--r--examples/complete/complete-examples485
-rw-r--r--examples/functions/array-stuff103
-rw-r--r--examples/functions/isnum.bash31
-rw-r--r--examples/functions/ksh-compat-test40
-rw-r--r--examples/functions/kshenv88
-rw-r--r--examples/functions/lowercase1
-rw-r--r--examples/functions/pathfuncs3
-rw-r--r--examples/functions/which2
-rw-r--r--examples/functions/xfind.bash52
-rw-r--r--examples/loadables/Makefile.in23
-rw-r--r--examples/loadables/getconf.c51
-rw-r--r--examples/loadables/perl/Makefile.in97
-rw-r--r--examples/loadables/perl/README6
-rw-r--r--examples/loadables/perl/bperl.c46
-rw-r--r--examples/loadables/perl/iperl.c24
-rw-r--r--examples/loadables/print.c9
-rw-r--r--examples/scripts.v2/rename6
-rwxr-xr-xexamples/scripts/adventure.sh32
-rw-r--r--examples/scripts/center24
-rw-r--r--examples/scripts/line-input.bash185
-rw-r--r--examples/scripts/vtree3a100
-rw-r--r--examples/scripts/websrv.sh230
-rwxr-xr-xexamples/scripts/xterm_title27
-rw-r--r--examples/startup-files/apple/README24
-rw-r--r--examples/startup-files/apple/aliases34
-rw-r--r--examples/startup-files/apple/bash.defaults22
-rw-r--r--examples/startup-files/apple/environment24
-rw-r--r--examples/startup-files/apple/login15
-rw-r--r--examples/startup-files/apple/logout10
-rw-r--r--examples/startup-files/apple/rc63
-rw-r--r--execute_cmd.c638
-rw-r--r--execute_cmd.h4
-rw-r--r--expr.c188
-rw-r--r--externs.h47
-rw-r--r--filecntl.h45
-rw-r--r--findcmd.c28
-rw-r--r--findcmd.h2
-rw-r--r--flags.c18
-rw-r--r--flags.h2
-rw-r--r--general.c198
-rw-r--r--general.h14
-rw-r--r--hashcmd.c4
-rw-r--r--hashcmd.h13
-rw-r--r--hashlib.c8
-rw-r--r--hashlib.h21
-rw-r--r--include/ansi_stdlib.h (renamed from ansi_stdlib.h)2
-rw-r--r--include/filecntl.h (renamed from lib/posixheaders/filecntl.h)2
-rw-r--r--include/maxpath.h (renamed from maxpath.h)2
-rw-r--r--include/memalloc.h (renamed from memalloc.h)2
-rw-r--r--include/posixdir.h (renamed from posixdir.h)4
-rw-r--r--include/posixjmp.h40
-rw-r--r--include/posixstat.h (renamed from lib/posixheaders/posixstat.h)4
-rw-r--r--include/posixtime.h49
-rw-r--r--include/posixwait.h (renamed from posixwait.h)2
-rw-r--r--include/shtty.h101
-rw-r--r--include/stdc.h (renamed from stdc.h)18
-rw-r--r--include/systimes.h55
-rw-r--r--include/unionwait.h (renamed from unionwait.h)2
-rw-r--r--input.c16
-rw-r--r--input.h5
-rw-r--r--jobs.c211
-rw-r--r--jobs.h7
-rw-r--r--lib/glob/Makefile.in24
-rw-r--r--lib/glob/collsyms.h2
-rw-r--r--lib/glob/fnmatch.c56
-rw-r--r--lib/glob/fnmatch.h4
-rw-r--r--lib/glob/glob.c6
-rw-r--r--lib/glob/glob.h4
-rw-r--r--lib/malloc/Makefile.in22
-rw-r--r--lib/malloc/getpagesize.h2
-rw-r--r--lib/malloc/gmalloc.c6
-rw-r--r--lib/malloc/malloc.c164
-rw-r--r--lib/malloc/ogmalloc.c26
-rw-r--r--lib/malloc/omalloc.c4
-rw-r--r--lib/malloc/xmalloc.c4
-rw-r--r--lib/posixheaders/ansi_stdlib.h41
-rw-r--r--lib/posixheaders/memalloc.h58
-rw-r--r--lib/posixheaders/posixdir.h49
-rw-r--r--lib/posixheaders/posixjmp.h22
-rw-r--r--lib/posixheaders/stdc.h79
-rw-r--r--lib/readline/COPYING2
-rw-r--r--lib/readline/Makefile.in71
-rw-r--r--lib/readline/ansi_stdlib.h2
-rw-r--r--lib/readline/bind.c427
-rw-r--r--lib/readline/callback.c14
-rw-r--r--lib/readline/chardefs.h4
-rw-r--r--lib/readline/complete.c135
-rw-r--r--lib/readline/display.c358
-rw-r--r--lib/readline/doc/Makefile91
-rw-r--r--lib/readline/doc/hist.texinfo4
-rw-r--r--lib/readline/doc/hstech.texinfo9
-rw-r--r--lib/readline/doc/hsuser.texinfo109
-rw-r--r--lib/readline/doc/manvers.texinfo10
-rw-r--r--lib/readline/doc/rlman.texinfo4
-rw-r--r--lib/readline/doc/rltech.texinfo51
-rw-r--r--lib/readline/doc/rluser.texinfo448
-rw-r--r--lib/readline/doc/rluserman.texinfo94
-rw-r--r--lib/readline/emacs_keymap.c16
-rw-r--r--lib/readline/examples/Makefile18
-rw-r--r--lib/readline/examples/excallback.c186
-rw-r--r--lib/readline/examples/fileman.c26
-rw-r--r--lib/readline/examples/rl.c39
-rw-r--r--lib/readline/examples/rltest.c16
-rw-r--r--lib/readline/funmap.c16
-rw-r--r--lib/readline/histexpand.c18
-rw-r--r--lib/readline/histfile.c54
-rw-r--r--lib/readline/histlib.h12
-rw-r--r--lib/readline/history.c6
-rw-r--r--lib/readline/history.h10
-rw-r--r--lib/readline/histsearch.c7
-rw-r--r--lib/readline/input.c92
-rw-r--r--lib/readline/isearch.c21
-rw-r--r--lib/readline/keymaps.c14
-rw-r--r--lib/readline/keymaps.h12
-rw-r--r--lib/readline/kill.c39
-rw-r--r--lib/readline/macro.c19
-rw-r--r--lib/readline/nls.c21
-rw-r--r--lib/readline/parens.c41
-rw-r--r--lib/readline/posixdir.h4
-rw-r--r--lib/readline/posixjmp.h18
-rw-r--r--lib/readline/posixstat.h4
-rw-r--r--lib/readline/readline.c205
-rw-r--r--lib/readline/readline.h23
-rw-r--r--lib/readline/rlconf.h8
-rw-r--r--lib/readline/rldefs.h7
-rw-r--r--lib/readline/rlprivate.h271
-rw-r--r--lib/readline/rlshell.h34
-rw-r--r--lib/readline/rlstdc.h58
-rw-r--r--lib/readline/rltty.c202
-rw-r--r--lib/readline/rltty.h25
-rw-r--r--lib/readline/rlwinsize.h5
-rw-r--r--lib/readline/savestring.c4
-rw-r--r--lib/readline/search.c182
-rw-r--r--lib/readline/shell.c50
-rw-r--r--lib/readline/signals.c54
-rw-r--r--lib/readline/tcap.h4
-rw-r--r--lib/readline/terminal.c210
-rw-r--r--lib/readline/tilde.c55
-rw-r--r--lib/readline/tilde.h28
-rw-r--r--lib/readline/undo.c6
-rw-r--r--lib/readline/util.c24
-rw-r--r--lib/readline/vi_keymap.c4
-rw-r--r--lib/readline/vi_mode.c33
-rw-r--r--lib/readline/xmalloc.c27
-rw-r--r--lib/readline/xmalloc.h46
-rw-r--r--lib/sh/Makefile.in109
-rw-r--r--lib/sh/clock.c78
-rw-r--r--lib/sh/getcwd.c16
-rw-r--r--lib/sh/getenv.c2
-rw-r--r--lib/sh/inet_aton.c205
-rw-r--r--lib/sh/itos.c2
-rw-r--r--lib/sh/makepath.c116
-rw-r--r--lib/sh/netopen.c228
-rw-r--r--lib/sh/rename.c18
-rw-r--r--lib/sh/setlinebuf.c38
-rw-r--r--lib/sh/shquote.c217
-rw-r--r--lib/sh/shtty.c284
-rw-r--r--lib/sh/strpbrk.c44
-rw-r--r--lib/sh/times.c77
-rw-r--r--lib/sh/timeval.c144
-rw-r--r--lib/sh/vprint.c4
-rw-r--r--lib/sh/zread.c127
-rw-r--r--lib/sh/zwrite.c61
-rw-r--r--lib/termcap/Makefile.in23
-rw-r--r--lib/termcap/grot/COPYING12
-rw-r--r--lib/termcap/grot/Makefile.in2
-rw-r--r--lib/termcap/grot/termcap.texi3
-rw-r--r--lib/termcap/ltcap.h29
-rw-r--r--lib/termcap/termcap.c30
-rw-r--r--lib/termcap/termcap.h2
-rw-r--r--lib/termcap/tparam.c20
-rw-r--r--lib/termcap/version.c2
-rw-r--r--lib/tilde/Makefile.in22
-rw-r--r--lib/tilde/shell.c4
-rw-r--r--lib/tilde/tilde.c55
-rw-r--r--lib/tilde/tilde.h28
-rw-r--r--list.c2
-rw-r--r--locale.c23
-rw-r--r--mailcheck.c4
-rw-r--r--mailcheck.h4
-rw-r--r--make_cmd.c112
-rw-r--r--make_cmd.h6
-rw-r--r--nojobs.c283
-rw-r--r--parse.y384
-rw-r--r--parser-built27
-rw-r--r--parser.h19
-rw-r--r--pathexp.c21
-rw-r--r--pathexp.h2
-rw-r--r--pathnames.h4
-rw-r--r--pcomplete.c1461
-rw-r--r--pcomplete.h146
-rw-r--r--pcomplib.c231
-rw-r--r--posixjmp.h22
-rw-r--r--posixstat.h142
-rw-r--r--print_cmd.c110
-rw-r--r--quit.h2
-rw-r--r--redir.c252
-rw-r--r--redir.h4
-rw-r--r--shell.c94
-rw-r--r--shell.h2
-rw-r--r--sig.c6
-rw-r--r--sig.h2
-rw-r--r--siglist.c4
-rw-r--r--siglist.h2
-rw-r--r--stringlib.c109
-rw-r--r--subst.c560
-rw-r--r--subst.h16
-rw-r--r--support/Makefile.in22
-rw-r--r--support/SYMLINKS21
-rw-r--r--support/bashbug.sh78
-rwxr-xr-xsupport/config.guess382
-rwxr-xr-xsupport/config.sub397
-rw-r--r--support/mksignames.c63
-rwxr-xr-xsupport/mkversion.sh25
-rwxr-xr-xsupport/rlvers.sh22
-rwxr-xr-xsupport/shobj-conf50
-rw-r--r--test.c15
-rw-r--r--tests/arith-for.right72
-rw-r--r--tests/arith-for.tests87
-rw-r--r--tests/arith.right24
-rw-r--r--tests/arith.tests47
-rw-r--r--tests/array.right17
-rw-r--r--tests/array.tests40
-rw-r--r--tests/builtins.right5
-rw-r--r--tests/builtins.tests5
-rw-r--r--tests/builtins1.sub (renamed from tests/builtins.sub1)0
-rw-r--r--tests/builtins2.sub10
-rw-r--r--tests/cprint.right4
-rw-r--r--tests/errors.right4
-rw-r--r--tests/errors.tests10
-rw-r--r--tests/execscript3
-rw-r--r--tests/extglob.tests1
-rw-r--r--tests/extglob2.right70
-rwxr-xr-xtests/extglob2.tests90
-rw-r--r--tests/func.right92
-rw-r--r--tests/func.tests34
-rw-r--r--tests/func1.sub55
-rw-r--r--tests/history.right2
-rw-r--r--tests/invert.right10
-rw-r--r--tests/invert.tests19
-rw-r--r--tests/jobs.right16
-rw-r--r--tests/jobs.tests4
-rw-r--r--tests/jobs3.sub26
-rw-r--r--tests/misc/dev-tcp.tests16
-rw-r--r--tests/misc/read-nchars.tests11
-rw-r--r--tests/misc/wait-bg.tests25
-rw-r--r--tests/more-exp.right4
-rw-r--r--tests/more-exp.tests22
-rw-r--r--tests/new-exp.right44
-rw-r--r--tests/new-exp.tests40
-rw-r--r--tests/new-exp3.sub26
-rw-r--r--tests/nquote.right5
-rw-r--r--tests/nquote.tests17
-rw-r--r--tests/printf.rightbin1182 -> 1241 bytes
-rw-r--r--tests/printf.tests29
-rw-r--r--tests/read.right16
-rw-r--r--tests/read.tests9
-rw-r--r--tests/read1.sub23
-rw-r--r--tests/read2.sub22
-rw-r--r--tests/read3.sub19
-rw-r--r--tests/redir.tests5
-rw-r--r--tests/run-all4
-rw-r--r--tests/run-arith-for2
-rw-r--r--tests/run-extglob24
-rw-r--r--tests/run-invert2
-rw-r--r--tests/run-minimal6
-rw-r--r--tests/run-new-exp3
-rw-r--r--tests/run-read2
-rw-r--r--tests/run-test2
-rw-r--r--tests/shopt.right8
-rw-r--r--tests/shopt.tests1
-rw-r--r--tests/test.right40
-rw-r--r--tests/test.tests (renamed from tests/test-tests)7
-rw-r--r--tests/varenv.right1
-rw-r--r--tests/varenv.sh14
-rw-r--r--trap.c75
-rw-r--r--trap.h2
-rw-r--r--unwind_prot.c4
-rw-r--r--unwind_prot.h2
-rw-r--r--variables.c543
-rw-r--r--variables.h99
-rw-r--r--version.c6
-rw-r--r--xmalloc.c6
-rw-r--r--y.tab.c1339
-rw-r--r--y.tab.h27
387 files changed, 28083 insertions, 8895 deletions
diff --git a/CHANGES b/CHANGES
index d510f6fb..9c571313 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,609 @@
+This document details the changes between this version, bash-2.04-release,
+and the previous version, bash-2.04-beta5.
+
+1. Changes to Bash
+
+a. Better compile-time and configure-time checks for the necessity of
+ inet_aton().
+
+b. A bug was fixed in the expansion of "${@:-}" when there are positional
+ parameters.
+
+c. A typo was fixed in the output of `complete'.
+
+d. The matches generated for a word by the `-W' argument to complete and
+ compgen are now matched against the word being completed, and only
+ matches are returned as the result.
+
+e. Some fixes were made for systems which do not restart read(2) when a
+ signal caught by bash is received.
+
+f. A bug was fixed which caused the umask to be set to 0 when an invalid
+ symbolic mode mask was parsed.
+
+g. Fixed a bug that could cause a core dump if a SIGCHLD was received while
+ performing an assignment statement using command substitution.
+
+h. Changed the word splitting function for programmable completion so cases
+ in which the cursor is between words are handled a bit better.
+
+2. Changes to Readline
+
+a. rl_funmap_names() is now documented.
+
+3. New Features in Bash
+
+a. 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.
+
+------------------------------------------------------------------------------
+This document details the changes between this version, bash-2.04-beta5,
+and the previous version, bash-2.04-beta4.
+
+1. Changes to Bash
+
+a. A couple of changes were made to the Makefiles for easier building on
+ non-Unix systems.
+
+b. Fixed a bug where the current prompt would be set to $PS2 at startup.
+
+c. The shell script that tests an already-installed version was changed to
+ remove the directory it created its test programs in at exit.
+
+d. Several changes were made to the code that tokenizes an input line for
+ the programmable completion code. Shell metacharacters will now appear
+ as individual words in the word list passed to the completion functions.
+ Some of the example completion shell functions were changed to understand
+ redirection operators.
+
+e. A bug was fixed that, under obscure circumstances, could confuse the
+ parser when a shell function was run by the programmable completion code.
+
+f. A bug was fixed in the ulimit builtin for systems not using getrlimit().
+
+g. The execution code now propagates the correct exit status back to the rest
+ of the code if the return value of a subshell command was being inverted.
+ Some new test cases for inverting return values with the `!' reserved
+ word have been added.
+
+h. Negative exponents in the arithmetic evaluation of v**e now return an
+ evaluation error.
+
+i. A bug that caused bash to check the wrong process in a pipeline for
+ abnormal termination (and consequently resetting the terminal attributes)
+ was fixed.
+
+j. Fixed a bug that caused $PS2 to be displayed after PROMPT_COMMAND was
+ executed.
+
+2. Changes to Readline
+
+1. Fixed a bug in a C preprocessor define that caused the keypad control
+ functions to be compiled out for all platforms except DJGPP.
+
+------------------------------------------------------------------------------
+This document details the changes between this version, bash-2.04-beta4,
+and the previous version, bash-2.04-beta3.
+
+1. Changes to Bash
+
+a. A couple of changes were made to the redirection to attempt to avoid
+ race conditions and malicious file replacement.
+
+2. A change was made to the string evaluation code (used for command
+ substitution, `eval', and the `.' builtin) to fix an obscure core
+ dump on alpha machines.
+
+3. A bug that caused $LINENO to be wrong when executing arithmetic for
+ commands was fixed.
+
+4. A couple of memory leaks in the programmable completion code were fixed.
+
+5. A bug that could cause a core dump by freeing memory twice during a call
+ to `eval' if `set -u' had been enabled and an undefined variable was
+ referenced was fixed.
+
+------------------------------------------------------------------------------
+This document details the changes between this version, bash-2.04-beta3,
+and the previous version, bash-2.04-beta2.
+
+1. Changes to Bash
+
+a. Bash should run the appropriate startup files when invoked by ssh2.
+
+b. Fixed a bug in the parsing of conditional commands that could cause a
+ core dump.
+
+c. Fixed a bug in parsing job specifications that occasionally caused
+ core dumps when an out-of-range job was referenced.
+
+d. Fixed the `type' and `command' builtins to do better reporting of
+ commands that are not found in $PATH or the hash table.
+
+e. Fixed a POSIX.2 compliance problem in the command builtin -- commands
+ are supposed to be reported as full pathnames.
+
+f. The `echo' builtin now returns failure if a write error occurs.
+
+g. Fixed a bug which caused the locale to not be reset correctly when
+ LC_ALL was unset.
+
+h. Changed description of `getopts' in man page and reference manual to make
+ it clear that option characters may be characters other than letters.
+
+i. If the shell exits while in a function, make sure that any trap on EXIT
+ doesn't think the function is still executing.
+
+j. Bashbug now tries harder to find a usable editor if $EDITOR is not set,
+ rather than simply defaulting to `emacs'.
+
+k. Changes to the scripts that guess and canonicalize the system type, from
+ the latest `automake' distribution via Debian.
+
+l. When using named pipes for process substitution, make sure the file
+ descriptors opened for reading are set to non-blocking mode.
+
+m. Fixed a bug that caused termination of pipelines that are killed by a
+ signal to not be reported in some cases.
+
+n. When not in literal-history mode, shell comment lines are not added to
+ the history list.
+
+o. When running in POSIX.2 mode, bash no longer performs word splitting on
+ the expanded value of the word supplied as the filename argument to
+ redirection operators.
+
+p. The prompt string decoding code now backslash-quotes only characters that
+ are special within double quotes when expanding the \w and \W escape
+ sequences.
+
+q. Fixed a bug in the prompt decoding code that could cause a non-interactive
+ shell to seg fault if `\u' was used in PS4 and the shell was in xtrace
+ mode.
+
+r. Fixed a bug that caused function definitions to be printed with any
+ redirections that should be attached to the entire function before the
+ closing brace.
+
+s. Changed the tilde expansion code for Cygwin systems to avoid creating
+ pathnames beginning with `//' if $HOME == `/'.
+
+t. Fixed a couple of autoconf tests to avoid creating files with fixed names
+ in /tmp.
+
+u. The `trap' and `kill' builtins now know the names of the POSIX.1b real-
+ time signals on systems which support them.
+
+2. Changes to Readline
+
+a. Fixed a problem with the single-quote quoting function that could cause
+ buffer overflows.
+
+b. Fixed a bug that caused incorrect `stat characters' to be printed if
+ the files being completed were in the root directory and visible-stats
+ was enabled.
+
+3. New Features in Bash
+
+a. There is a new `rbash.1' manual page, from the Debian release.
+
+b. The `--enable-usg-echo-default' option to `configure' has been renamed to
+ `--enable-xpg-echo-default'. The old option is still there for backwards
+ compatibility.
+
+------------------------------------------------------------------------------
+This document details the changes between this version, bash-2.04-beta2,
+and the previous version, bash-2.04-beta1.
+
+1. Changes to Bash
+
+a. Fixed a bug that could cause pipes to be closed inappropriately in
+ some obscure cases.
+
+b. Fixed a bug that caused creation of the exported environment to clobber
+ the current command string if there were any exported shell functions.
+
+c. Some changes were made to reduce bash's memory usage.
+
+d. Fixed a problem with programmable completion and filenames to be
+ completed containing quote characters.
+
+e. Changed the code the removes named pipes created for the <(...) and >(...)
+ 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 \<newline>
+ 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 inaapropriate 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.
diff --git a/COMPAT b/COMPAT
index 79bc8cca..a01035a2 100644
--- a/COMPAT
+++ b/COMPAT
@@ -1,5 +1,5 @@
This document details the incompatibilites between this version of bash,
-bash-2.03, and the previous widely-available version, bash-1.14 (which
+bash-2.04, and the previous widely-available version, bash-1.14 (which
is still the `standard' version for many Linux distributions). These
were discovered by users of bash-2.x, so this list is not comprehensive.
@@ -124,3 +124,10 @@ were discovered by users of bash-2.x, so this list is not comprehensive.
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'
diff --git a/CWRU/POSIX.NOTES b/CWRU/POSIX.NOTES
index 03c61566..f692adb8 100644
--- a/CWRU/POSIX.NOTES
+++ b/CWRU/POSIX.NOTES
@@ -3,8 +3,8 @@ 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.2 standard by changing the behavior to match that
-specified by POSIX.2 in areas where the Bash default differs.
+to the POSIX 1003.2 standard by changing the behavior to match that
+specified by POSIX in areas where the Bash default differs.
The following list is what's changed when `POSIX mode' is in effect:
@@ -19,7 +19,7 @@ The following list is what's changed when `POSIX mode' is in effect:
4. Reserved words may not be aliased.
- 5. The POSIX.2 `PS1' and `PS2' expansions of `!' to the history
+ 5. The POSIX 1003.2 `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.
@@ -27,8 +27,8 @@ The following list is what's changed when `POSIX mode' is in effect:
6. Interactive comments are enabled by default. (Bash has them on by
default anyway.)
- 7. The POSIX.2 startup files are executed (`$ENV') rather than the
- normal Bash files.
+ 7. The POSIX 1003.2 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.
@@ -48,49 +48,52 @@ The following list is what's changed when `POSIX mode' is in effect:
13. Redirection operators do not perform filename expansion on the word
in the redirection unless the shell is interactive.
- 14. Function names must be valid shell `name's. That is, they may not
+ 14. Redirection operators do not perform word splitting on the word in
+ the redirection.
+
+ 15. 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.
- 15. POSIX.2 `special' builtins are found before shell functions during
- command lookup.
+ 16. POSIX 1003.2 `special' builtins are found before shell functions
+ during command lookup.
- 16. If a POSIX.2 special builtin returns an error status, a
+ 17. If a POSIX 1003.2 special builtin returns an error status, a
non-interactive shell exits. The fatal errors are those listed in
the POSIX.2 standard, and include things like passing incorrect
options, redirection errors, variable assignment errors for
assignments preceding the command name, and so on.
- 17. If the `cd' builtin finds a directory to change to using
+ 18. If the `cd' builtin finds a directory to change to using
`$CDPATH', the value it assigns to the `PWD' variable does not
contain any symbolic links, as if `cd -P' had been executed.
- 18. If `$CDPATH' is set, the `cd' builtin will not implicitly append
+ 19. If `$CDPATH' is set, the `cd' builtin will not implicitly append
the current directory to it. This means that `cd' will fail if no
valid directory name can be constructed from any of the entries in
`$CDPATH', even if the a directory with the same name as the name
given as an argument to `cd' exists in the current directory.
- 19. A non-interactive shell exits with an error status if a variable
+ 20. 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.
- 20. A non-interactive shell exits with an error status if the iteration
+ 21. 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.
- 21. Process substitution is not available.
+ 22. Process substitution is not available.
- 22. Assignment statements preceding POSIX.2 special builtins persist
- in the shell environment after the builtin completes.
+ 23. Assignment statements preceding POSIX 1003.2 special builtins
+ persist in the shell environment after the builtin completes.
- 23. The `export' and `readonly' builtin commands display their output
- in the format required by POSIX.2.
+ 24. The `export' and `readonly' builtin commands display their output
+ in the format required by POSIX 1003.2.
-There is other POSIX.2 behavior that Bash does not implement.
+There is other POSIX 1003.2 behavior that Bash does not implement.
Specifically:
1. Assignment statements affect the execution environment of all
diff --git a/CWRU/changelog b/CWRU/changelog
index cd683aaf..7a0a0f09 100644
--- a/CWRU/changelog
+++ b/CWRU/changelog
@@ -5210,3 +5210,2531 @@ cross-build/opennt.cache
files are
[bash-2.03 released]
+
+ 2/19
+ ----
+configure.in
+ - changed OPENNT_ROOT to INTERIX_ROOT for building on Interix
+
+support/config.guess
+ - added two stanzas for Interix running on alpha and intel hardware
+
+ 2/22
+ ----
+config-bot.h
+ - if PROMPT_STRING_DECODE is not defined, #undef PPROMPT before
+ redefining it, to avoid warning messages
+
+execute_cmd.c
+ - set jobs_hack in execute_subshell_builtin_or_function only if
+ JOB_CONTROL is defined
+
+ 2/24
+ ----
+trap.c
+ - fixed an obscure bug caused by a race condition in run_pending_traps.
+ Read the comments in the source code for a full description of the
+ problem and solution
+
+ 3/1
+ ---
+aclocal.m4
+ - new test, BASH_STRUCT_TIMEVAL, which tries to compile a code
+ fragment that includes <sys/time.h> and <time.h> as appropriate
+ and defines HAVE_TIMEVAL if the compile succeeds
+
+configure.in
+ - call BASH_STRUCT_TIMEVAL rather than running a pair of
+ AC_HEADER_EGREPs on sys/time.h and time.h
+
+lib/readline/histfile.c
+ - include "posixstat.h" rather than <sys/stat.h>
+ - in history_truncate_file, only try to truncate if the history file
+ is a regular file
+
+ 3/2
+ ---
+aclocal.m4
+ - changed BASH_STRUCT_TIMEVAL back to using a pair of
+ AC_EGREP_HEADERs instead of compiling a program fragment
+
+lib/readline/readline.c
+ - readline_internal_charloop should cast the first argument to
+ _rl_dispatch to `unsigned char' to avoid problems with negative
+ array indices on systems where signed chars are the default
+
+lib/readline/kill.c
+ - instead of doing a sequence of next_history() calls in
+ rl_yank_nth_arg_internal, save and restore the history
+ position explicitly after finding the correct entry. This
+ attempts to ensure that rl_yank_nth_arg leaves the history
+ pointer set to the same position as when it was called.
+ Fix from Vasco Pedro <vp@di.fct.unl.pt>
+
+ 3/5
+ ---
+redir.c
+ - broke code that opens file for redirection in do_redirection_internal
+ into a separate function: redir_open(path, flags, mode, ri)
+
+general.h
+ - changed STREQN so that it evaluates to 1 (strings are equivalent)
+ if N == 0, to match the behavior of strncmp
+
+lib/sh/zwrite.c
+ - new file, zwrite() from builtins/evalstring.c
+
+builtins/evalstring.c
+ - removed private definition of zwrite
+
+builtins/common.c
+ - double_quote needs to protect newlines with backslashes as well
+ - new function, un_double_quote, to remove backslashes proctecting
+ characters that are special in double quotes
+
+builtins/common.h
+ - new extern declaration for un_double_quote
+
+parse.y
+ - changed read_token_word to requote the expanded value of $'...'
+ using single_quote
+ - added a new flag to parse_matched_pair: P_ALLOWESC. It allows
+ backslashes to quote embedded single quotes, and is used by
+ the $'...' translation code for better ksh93-compatibility
+ - changed localeexpand to call mk_msgstr on the string passed
+ before displaying it if all we're doing is displaying translatable
+ strings in `po' format. mk_msgstr quotes backslashes and double
+ quotes in the string passed with backslashes, and encloses the
+ result in double quotes. If only -D is supplied, the string is
+ not changed at all -- this is what ksh93 does
+
+lib/readline/rlconf.h
+ - removed PAREN_MATCHING #define, paren matching is always compiled
+ into readline
+
+lib/readline/parens.c
+ - removed code that was active if PAREN_MATCHING was not defined
+ - added _rl_enable_paren_matching, which is called when the readline
+ variable `blink-matching-paren' is assigned a value and changes
+ the appropriate key bindings in emacs_standard_keymap
+
+lib/readline/bind.c
+ - no more PAREN_MATCHING defines, `blink-matching-paren' is always
+ available
+ - if `blink-matching-paren' is assigned a value, call
+ _rl_enable_paren_matching (rl_blink_matching_paren)
+
+lib/readline/emacs_keymap.c
+ - removed PAREN_MATCHING defines; the default key bindings for
+ ), ], and } are self-insert
+
+ 3/7
+ ---
+stringlib.c
+ - added an extra argument to ansicstr so that `echo -e' will not
+ convert \' to '
+
+externs.h
+ - changed extern declaration for ansicstr
+
+parse.y, builtins/{echo,printf}.def
+ - changed calls to ansicstr() appropriately
+
+eval.c
+ - in parse_string_to_word_list, if an unexpected token is encountered
+ that causes the string to not parse to a simple command, or to
+ completely consume the string, display an error message and jump
+ back to the top level after restoring the parsing environment,
+ returning an error status from the attempted assignment
+
+ 3/8
+ ---
+lib/glob/fnmatch.c
+ - fixed patscan and extmatch to handle embedded [...](...) patterns
+ better
+
+tests/{extglob2.{tests,right},run-extglob2}
+ - an additional set of ksh extended globbing tests, cribbed from zsh
+
+ 3/10
+ ----
+general.c
+ - changed unset_nodelay_mode slightly to make sure it handles both
+ O_NDELAY and O_NONBLOCK if they have different values; it now
+ returns a value of 0 on success (or no action); -1 on failure
+
+general.h
+ - changed extern declaration for unset_nodelay_mode
+
+
+lib/readline/shell.c
+ - new function: unset_nodelay_mode; identical to definition in
+ general.c
+
+lib/readline/input.c
+ - changed rl_getc to call unset_nodelay_mode if the read fails with
+ errno == EWOULDBLOCK || errno == EAGAIN
+
+ 3/11
+ ----
+lib/termcap/termcap.c
+ - minor changes from termutils-2.0
+ - minor change to MS-DOS version of valid_filename_p so MS-DOS-specific
+ code from tgetent() can be removed (from Michel@smr.nl)
+
+lib/readline/bind.c
+ - in _rl_read_file, null-terminate the buffer at the number of
+ characters actually read, not what stat() says the file size is
+ - use ~/_inputrc as a last-ditch inputrc filename on MS-DOS
+
+lib/readline/complete.c
+ - change printable_part to handle MS-DOS `drive-letter:' pathname
+ prefixes
+ - removed __GO32__ code, since it's for DJGPP 1.x, which is not
+ supported any more, and they don't work for DJGPP 2.x
+ - added code to support MS-DOS drive letter prefixes and //X/...
+ to filename_completion_function
+ - _rl_completion_case_fold defaults to 1 on MS-DOS
+
+lib/readline/{display,input,readline,rltty,signals,terminal}.c
+ - removed __GO32__ code
+
+lib/readline/histfile.c
+ - make read_history_range and history_truncate_file work with the
+ actual number of characters read from the file, not the file size
+ as reported by stat()
+
+lib/readline/readline.c
+ - change bind_arrow_keys_internal to bind MS-DOS arrow keys to the
+ appropriate functions if __MSDOS__ is defined
+
+lib/readline/rltty.c
+ - make sure set_winsize is always defined, with a null body if
+ TIOCGWINSZ is not defined
+
+lib/readline/shell.c
+ - include <stdio.h>, since this file uses sprintf
+
+support/shobj-conf
+ - MS-DOS does not support shared objects
+
+lib/tilde/tilde.c
+ - change tilde_find_suffix and isolate_tilde_prefix to understand
+ backslash as a pathname separator on MS-DOS
+
+ 3/12
+ ----
+lib/readline/{bind,readline,terminal}.c
+ - no longer need to include <signal.h>
+
+lib/readline/terminal.c
+ - don't need to include <setjmp.h>
+
+builtins/history.def
+ - broke the code than handles deleting a particular history entry
+ from the history list out into a separate function: delete_histent
+ - added `-d offset' option to delete the history entry at position
+ OFFSET, as displayed when the history is listed
+
+jobs.c, nojobs.c
+ - new function, count_all_jobs(), returns the number of active jobs
+ in the jobs list
+
+jobs.h
+ - extern declaration for count_all_jobs()
+
+configure.in
+ - check for C library function ttyname()
+
+config.h.in
+ - define HAVE_TTYNAME if configure finds ttyname(3)
+
+parse.y
+ - two new escape sequences for decode_prompt_string:
+
+ \j number of active jobs in jobs list
+ \l basename of shell's tty device name
+
+doc/{bash.1,bashref.texi}, lib/readline/doc/hsuser.texi
+ - documented new `history -d' option
+ - documented new \j and \l prompt string expansion sequences
+
+lib/readline/bind.c
+ - new static state variable, currently_reading_init_file, set to
+ 1 while _rl_read_init_file is operating on a file
+ - changed _rl_init_file_error to include the name and line number
+ from the init file only if currently_reading_init_file is non-zero
+ (this is needed since applications like bash can call
+ rl_parse_and_bind, and error messages from those calls would be
+ misleading if they referred to the last inputrc file read
+
+bashline.c
+ - support for a `extended command keymap', which will allow
+ readline key sequences to be bound to unix commands using an
+ auxiliary keymap and a special function that knows how to execute
+ commands from it
+ - bind_keyseq_to_unix_command supports `bind -x'
+ - bash_execute_unix_command is the readline callback that looks in
+ an auxiliary keymap to find the shell command to execute for a
+ particular key sequence
+ - new variable, no_empty_command_completion, which suppresses $PATH
+ searching for command completion when TAB is typed on an empty
+ line
+
+bashline.h
+ - extern declaration for new function bind_keyseq_to_unix_command
+
+builtins/bind.def
+ - added `-x' option to bind a key sequence to a shell command
+
+builtins/help.def
+ - added `-s' option to just print a builtin's short_doc
+
+builtins/shopt.def
+ - added new shell option, no_empty_cmd_completion', mirroring value
+ of no_empty_command_completion
+
+doc/{bash.1,bashref.texi}
+ - documented new `bind -x' option
+ - documented new shopt `no_empty_cmd_completion' option
+ - documented new `help -s' option
+
+Makefile.in
+ - changed RELSTATUS to `devel'
+
+_distribution
+ - changed to `2.04'
+
+ 3/15
+ ----
+support/shobj-conf
+ - add `-h $@' to linking options on Solaris 2 with gcc
+
+expr.c
+ - changes to add {pre,post}-{inc,dec}rement operators (++id, --id,
+ id++, id--). These are somewhat more liberal than ksh93, and
+ may require more strict syntax checking down the line
+
+tests/arith.{tests,right}
+ - additional tests for {pre,post}-{inc,dec}rement operators
+
+ 3/16
+ ----
+command.h
+ - structures and types for ksh-93-style arithmetic `for' command
+
+configure.in
+ - new `--enable-arith-for-command' option to compile arithmetic for
+ command code into the shell
+
+config.h.in
+ - new define, ARITH_FOR_COMMAND, turned on by configure
+
+parse.y
+ - changed read_token_word to parse a set of arithmetic for expressions
+ between (( and )) as long as the last token read before the `(('
+ was FOR
+ - added grammar rules to build arithmetic for commands
+
+make_cmd.c
+ - functions to parse (( ... )) into the three sub-expressions needed
+ for the arithmetic for command and create the command structures
+ (done this way instead of in the grammar rules to avoid forcing
+ users to quote special characters between the (( and )) )
+
+make_cmd.h
+ - extern declaration for make_arith_for_command
+
+copy_cmd.c
+ - code to copy arithmetic for commands
+
+dispose_cmd.c
+ - code to dispose of arithmetic for commands
+
+print_cmd.c
+ - code to print arithmetic for commands
+
+execute_cmd.c
+ - code to execute arithmetic for commands and note that they are
+ shell control structures for the piping code
+
+doc/{bash.1,bashref.texi}
+ - documented new arithmetic for command
+
+doc/bashref.texi
+ - documented new configure --enable-arith-for-command option
+
+ 3/17
+ ----
+builtins/read.def
+ - added `-t timeout' option and code to support it
+
+ 3/18
+ ----
+examples/loadables/Makefile.in
+ - various clean targets need to descend into perl
+
+examples/loadables/perl/Makefile.in
+ - added mostlyclean and maintainer-clean targets
+
+include
+ - new directory, with files from lib/posixheaders
+
+lib/posixheaders
+ - removed
+
+{posixwait,unionwait,maxpath}.h
+ - moved from top src directory to include subdir
+
+Makefile.in,builtins/Makefile.in,lib/{glob,malloc,sh,tilde}/Makefile.in
+ - updated dependencies and file lists for new include directory
+ - added BASHINCDIR variable, added -I${BASHINCDIR} to cc's include path
+
+MANIFEST,support/SYMLINKS
+ - updated for new include directory
+
+lib/readline/{ansi_stdlib,posixdir,posixjmp,posixstat,rlstdc}.h
+ - changed symlinks to point to ../../include rather than
+ ../posixheaders
+
+builtins/common.h
+ - changed `#include "../stdc.h"' to `#include "stdc.h"'
+
+builtins/{cd,exec,fc,history,pushd,source,type,umask,printf}.def
+builtins/{mkbuiltins,common,evalfile,evalstring,getopt}.c
+ - changed include specifications:
+ ../posixstat.h -> posixstat.h
+ ../filecntl.h -> filecntl.h
+ ../maxpath.h -> maxpath.h
+ ../memalloc.h -> memalloc.h
+
+include/shtty.h
+ - new file, contents of bashtty.h and code from jobs.c that includes
+ the appropriate terminal file
+
+lib/sh/shtty.c
+ - new file with some tty manipulation utility functions
+
+bashtty.h
+ - removed
+
+jobs.c, nojobs.c
+ - include shtty.h instead of bashty.h and other code that includes
+ the correct system-dependent tty include file
+
+lib/sh/Makefile.in
+ - added shtty.o as part of libsh.a
+
+MANIFEST
+ - added include/shtty.h and lib/sh/shtty.c, removed bashtty.h
+
+ 3/19
+ ----
+lib/readline/display.c
+ - some more __MSDOS__ code to make readline work better with DJGPP:
+ output \r instead of tputs(term_cr, ...)
+
+lib/readline/terminal.c
+ - some changes for __DJGPP__ (one is of dubious value -- doesn't
+ DJGPP have a termcap library?)
+
+ 3/23
+ ----
+configure.in
+ - make sure that the $CC argument to shobj-conf is quoted
+
+support/shobj-conf
+ - changes to SGI SHOBJ_LDFLAGS from David Kaelbling <drk@sgi.com>
+
+ 3/24
+ ----
+lib/sh/zread.c
+ - interface to read(2) that restarts automatically if errno == EINTR
+
+externs.h
+ - new declarations for functions in lib/sh/{zread,zwrite}.c
+
+lib/sh/Makefile.in, Makefile.in
+ - add zread.c, zread.o to appropriate file lists
+
+{subst,input}.c, builtins/{evalstring.c,read.def}
+ - converted some loops around read() to call zread() instead
+
+lib/readline/rltty.h
+ - new struct _rl_tty_chars to save tty special characters
+
+lib/readline/rltty.c
+ - new function save_tty_chars to save tty special characters
+ (currently they're only saved -- nothing looks at them yet)
+ - two new internal library functions, _rl_disable_tty_signals ()
+ and _rl_restore_tty_signals (), intended to disable tty driver
+ signal processing for readline's literal-next code, so users
+ can do stuff like ^V^C and have ^C end up in the readline
+ buffer even if ^C is the terminal's interrupt character
+
+lib/readline/readline.c
+ - changed rl_quoted_insert to disable and restore tty signal
+ handling around the call to rl_read_key (), so users can put
+ tty special chars into the readline buffer
+
+ 3/25
+ ----
+expr.c
+ - added `,' operator (expr1 , expr2) -- both expr1 and expr2 are
+ evaluated and the return value is the value of expr2. Precedence
+ is higher than assignment (which makes it highest)
+ - make `lasttp' (pointer to last token) part of the expression
+ context that is saved and restored by {push,pop}_context. This
+ is used only in error reporting
+
+doc/{bash.1,bashref.texi}
+ - documented new `,' arithmetic operator
+ - cleaned up some of the language concerning variables referenced
+ by name within an arithmetic expression
+
+lib/readline/readline.c
+ - new application-settable variable, rl_num_chars_to_read, which, if
+ set to a non-zero value, causes readline to return after reading
+ that many characters (or at least that many characters, if
+ rl_startup_hook is used to prime the input buffer) rather than
+ when reading a character bound to accept-line
+
+lib/readline/readline.h
+ - extern declaration for rl_num_chars_to_read
+
+builtins/read.def
+ - added new `-n nchars' option to read NCHARS from stdin rather than
+ a complete line. Works both with and without using readline
+
+doc/{bash.1,builtins.texi}
+ - documented new `read -n nchars' option
+
+ 3/26
+ ----
+execute_cmd.c
+ - make sure all uses of PIDs are of type pid_t
+
+redir.c
+ - broke stdin_redirects into two functions: stdin_redirection, which
+ checks a single redirection specification, and a new stdin_redirects,
+ which does what it did before but calls stdin_redirection for each
+ redirection in the chain
+
+ 3/29
+ ----
+aclocal.m4
+ - new test, BASH_CHECK_DEV_STDIN, checks for /dev/stdin. If it's
+ present HAVE_DEV_STDIN is defined and it's assumed that /dev/stdout
+ and /dev/stderr are present as well
+
+configure.in
+ - call BASH_CHECK_DEV_STDIN
+
+config.h.in
+ - add HAVE_DEV_STDIN, initially undefined
+
+test.c
+ - add /dev/std{in,out,err} to the special filenames that are handled
+ by test_stat() if HAVE_DEV_STDIN is not defined
+
+doc/{bash.1,bashref.texi}
+ - documented conditional expressions' handling of /dev/std{in,out,err}
+
+stringlib.c
+ - new function, find_string_in_alist, to find (or match as an extended
+ glob pattern) a string in a STRING_INT_ALIST and return the
+ associated token value
+
+externs.h
+ - extern declaration for find_string_in_alist
+
+redir.c
+ - new STRING_INT_ALIST list of filenames the redirection code handles
+ specially (_redir_special_filenames)
+ - new function, redir_special_open () to handle filenames found in
+ _redir_special_filenames (framework for /dev/tcp and /dev/udp, but
+ those are not implemented get)
+
+doc/{bash.1,bashref.texi}
+ - documented special filename handling in redirections
+
+ 3/30
+ ----
+builtins/read.def
+ - added `-d delim' option, like ksh93, to read until delim rather
+ than newline
+
+doc/{bash.1,bashref.texi}
+ - documented new read `-d delim' option
+
+configure.in
+ - look for gethostbyname(3), inet_aton(3)
+ - look for <netdb.h> and <netinet/in.h>
+ - call BASH_FUNC_GETHOSTBYNAME if gethostbyname(3) is not in libc
+ - check for u_int and u_long types, default to `unsigned int' and
+ `unsigned long' respectively
+ - new enable option `--enable-net-redirections' to compile in the
+ /dev/tcp and /dev/udp redirection code
+
+aclocal.m4
+ - new macro, BASH_FUNC_GETHOSTBYNAME, looks for gethostbyname(3) in
+ the socket libraries if it's not found in libc
+
+config.h.in
+ - new defines: HAVE_GETHOSTBYNAME, HAVE_INET_ATON, HAVE_NETDB_H,
+ HAVE_NETINET_IN_H, NETWORK_REDIRECTIONS
+ - new defines: u_int, u_long
+
+lib/sh/inet_aton.c
+ - new file, from GNU libc, slightly modified to remove inet_addr()
+
+lib/sh/netopen.c
+ - new file, functions to create tcp/udp network connections. Exports
+ a single function: netopen(pathname)
+
+externs.h
+ - extern declaration for netopen()
+
+lib/sh/Makefile.in, Makefile.in, MANIFEST
+ - added appropriate references to inet_aton.c and netopen.c
+
+config-bot.h
+ - if HAVE_SYS_SOCKET_H, HAVE_GETPEERNAME, and HAVE_NETINET_IN_H are
+ all defined, define HAVE_NETWORK
+
+redir.c
+ - call netopen for pathnames of the form /dev/(tcp|udp)/host/port
+ if HAVE_NETWORK is defined; print a warning message otherwise
+ - /dev/tcp and /dev/udp code is only compiled in if
+ NETWORK_REDIRECTIONS is defined
+
+ 3/31
+ ----
+lib/sh/zread.c
+ - new function, zsyncfd(fd) which syncs the kernel's seek pointer on
+ FD with the last character returned by zreadc()
+
+externs.h
+ - extern declaration for zsyncfd
+
+builtins/read.def
+ - use zreadc if the input is not unbuffered (this cuts the number
+ of read(2) calls *way* down)
+ - if input is not unbuffered, call zsyncfd before returning to make
+ sure zreadc's buffering doesn't consume too much input
+
+ 4/1
+ ---
+Makefile.in
+ - install bashbug with mode 555
+
+ 4/2
+ ---
+shell.c
+ - make want_pending_command and read_from_stdin global rather than
+ local variables
+
+flags.c
+ - change which_set_flags to insert `c' and `s' if the `-c' and `-s'
+ invocation options, respectively, were supplied at shell startup
+
+bashline.c
+ - change bash_directory_completion_hook to change the logic for
+ deciding whether or not to parameter expand the directory name --
+ now we expand only if there's a `$' (still has problems if the
+ user quoted the `$') or a `` pair. Fixes bug reported by
+ chuckjr@sinclair.net. To fix the `$' problem, could possibly
+ check what the user typed with rl_line_buffer and start, end
+ parameters to gen_completion_matches
+ - changed attempt_shell_completion to slightly adjust the logic for
+ deciding whether or not a word is in a command position: if the
+ word being completed has a single opening single or double quote
+ before the command separator, treat it as a candidate for (quoted)
+ command word completion
+ - now that we understand partially-quoted strings as completion
+ candidates, we can do command completion on certain unclosed
+ uses of $(...
+
+subst.c
+ - change extract_delimited_string to not return an error for an
+ unclosed construct if DOING_COMPLETION is non-zero
+
+ 4/5
+ ---
+expr.c
+ - fixed `ss=09 ; let ss=10' bug by introducing one-token lookahead
+ after a string token is parsed. If the next token is `=', we
+ don't evaluate the variable's value as an expression, since it's
+ not going to be used
+
+variables.h
+ - added new member to struct variable: exportstr -- for the future
+ caching of strings to be placed into the environment
+ - extern declaration for bind_variable_value
+
+variables.c
+ - make sure that the `exportstr' member of a struct variable is
+ initialized correctly, and put code in to free it where appropriate
+ (if non-null)
+ - new function, bind_variable_value(VAR, VALUE); make shell variable
+ VAR have value VALUE
+ - make sure var->exportstr is invalidated when a variable or function
+ is assigned a value
+
+builtins/declare.def
+ - call bind_variable_value instead of duplicating some of bind_variable
+ inline
+
+ 4/6
+ ---
+variables.h
+ - new macros, VSETATTR and VUNSETATTR to set and clear variable
+ attributes
+
+builtins{read,set,setattr,declare}.def,{execute_cmd,expr,shell,subst,variables}.c
+ - change to use VSETATTR and VUNSETATTR
+
+ 4/7
+ ---
+doc/Makefile.in
+ - if htmldir is set by configure, install the html files into that
+ directory with `make install' and remove them with `make uninstall'
+
+Makefile.in,doc/Makefile.in
+ - htmldir is set by configure and passed from the Makefile to the
+ install in the doc subdirectory
+
+configure.in
+ - substitute `htmldir' into Makefiles
+
+support/config.guess
+ - some small changes for Apple's Rhapsody
+
+lib/termcap/Makefile.in
+ - make the `distclean' and `maintainer-clean' targets remove Makefile
+
+lib/termcap/ltcap.h
+ - new private library include file, for Rhapsody __private_extern__
+ define
+
+lib/termcap/{termcap,tparam}.c
+ - include "ltcap.h"
+ - if HAVE_CONFIG_H is defined, include <stdlib.h> if HAVE_STDLIB_H is
+ defined, otherwise declare getenv, malloc, realloc as extern
+ - add __private_extern__ qualifier for extern data that Rhapsody
+ requires
+
+shell.c
+ - don't run the startup files in the rshd case if shell_level is >= 2
+ This should catch the case of
+ rsh machine bash -c 'echo a'
+ running the .bashrc twice, once for the shell started by rshd and
+ one for the shell running -c command
+
+ 4/8
+ ---
+variables.c
+ - in initialize_shell_variables, unset the export attribute from
+ SSH_CLIENT if it exists and we got it from the initial environment
+
+shell.c
+ - don't bother unsetting export attribute from SSH_CLIENT, since we
+ now do it in initialize_shell_variables
+
+lib/readline/display.c
+ - don't check prompt_this_line[-2] in rl_redisplay if prompt_this_line
+ isn't at least 2 characters after the start of rl_display_prompt
+
+lib/readline/histfile.c
+ - change the name of the default history file to _history on MS-DOS
+
+lib/readline/histlib.h
+ - add an extern declaration for history_offset
+
+lib/readline/hist{expand,search}.c
+ - remove extern declaration for history_offset; now in histlib.h
+
+lib/readline/xmalloc.h
+ - new file, extern declarations for xmalloc, xrealloc, xfree
+
+lib/readline/rlprivate.h
+ - new file, with extern declarations for `readline private' global
+ variables and functions
+
+lib/readline/rlshell.h
+ - new file, with extern function declarations for stuff in shell.c
+
+lib/readline/Makefile.in
+ - add dependencies on xmalloc.h, rlshell.h
+ - add xmalloc.h, rlprivate.h to list of header files
+
+MANIFEST
+ - add lib/readline/xmalloc.h, lib/readline/rlprivate.h,
+ lib/readline/rlshell.h
+
+Makefile.in
+ - add $(RL_LIBSRC)/xmalloc, $(RL_LIBSRC)/rlprivate.h,
+ $(RL_LIBSRC)/rlshell.h to READLINE_SOURCE variable
+
+lib/readline/{bind,complete,display,funmap,histexpand,histfile,history,input,
+isearch,keymaps,kill,macro,readline,search,shell,util,vi_mode}.c
+ - include "xmalloc.h" rather than extern declarations for xmalloc,
+ xrealloc, xfree
+
+lib/readline/terminal.c
+ - new function, used in two places, _emx_get_screensize for EMX
+
+lib/readline/readline.c
+ - EMX apparently no longer needs _emx_build_environ
+
+lib/readline/signals.c
+ - support for __EMX__ in rl_signal_handler
+ - don't set the old handler passed to rl_set_sighandler to
+ rl_signal_handler, because that would cause infinite recursion if
+ that signal were generated
+
+lib/readline/xmalloc.c
+ - no longer the same as lib/malloc/xmalloc.c, which is no longer
+ used by anyone
+ - changes to include xmalloc.h, define READLINE_LIBRARY, change
+ some of the argument types
+
+lib/tilde/tilde.c
+ - add prototypes for extern function declarations if __STDC__
+ defined
+
+lib/readline/{terminal,bind,readline,nls,histexpand}.c
+ - include "rlshell.h" for function prototypes
+
+ 4/9
+ ---
+lib/readline/{bind,callback,complete,display,input,isearch,kill,macro,nls,
+parens,readline,rltty,search,signals,terminal,util,vi_mode}.c
+ - include "rlprivate.h"
+ - remove extern declarations already in rlprivate.h
+
+xmalloc.c
+ - xfree should take a PTR_T as its argument
+
+general.h
+ - change prototype for xfree to use void * instead of char *
+
+lib/malloc/malloc.c
+ - define PTR_T like it is defined in general.h
+ - malloc() returns a PTR_T
+ - free() takes a PTR_T as its argument
+ - realloc() returns a PTR_T and takes a PTR_T as its first argument
+ - memalign returns a PTR_T
+ - valloc returns a PTR_T
+ - calloc returns a PTR_T
+ - cfree() takes a PTR_T
+
+variables.c
+ - new function: char **all_variables_matching_prefix (char *prefix)
+
+variables.h
+ - extern declaration for all_variables_matching_prefix
+
+bashline.c
+ - converted variable_completion_function to use
+ all_variables_matching_prefix
+
+stringlib.c
+ - new function, char **alloc_array(n), allocates an argv-style
+ array of strings with room for N members
+
+externs.h
+ - extern declaration for alloc_array
+
+ 4/13
+ ----
+lib/readline/keymaps.c
+ - include "readline.h"
+ - remove extern function declarations
+
+include/stdc.h
+ - break the definition of __P out from a strict __STDC__ block,
+ since __GNUC__ and __cplusplus also indicate that prototypes
+ are available
+
+lib/readline/readline.h
+ - adjust conditional declaration of rl_message, since __cplusplus
+ indicates that prototypes are available
+
+lib/readline/rlstdc.h
+ - private copy, modified, no longer symlinked to ../../include/stdc.h
+ - __P is defined if __GNUC__ or __cplusplus is defined
+ - removed defines for __STRING, const, inline, signed, volatile, since
+ readline does not use them
+
+lib/readline/{search,readline}.c
+ - extern declaration for _rl_free_history_entry with prototypes,
+ since it's not in rlprivate.h
+
+lib/readline/history.h
+ - added some missing `extern's in function declarations
+
+lib/readline/undo.c
+ - include "rlprivate.h"
+
+lib/readline/shell.c
+ - include "rlshell.h"
+
+lib/readline/Makefile.in
+ - update dependencies for undo.c, shell.c
+
+lib/tilde/tilde.h
+ - add #define for __P if not already defined
+ - use prototypes in extern function declarations with __P()
+
+lib/readline/doc/rluserman.texinfo
+ - new file, derived from rlman.texinfo
+
+{bashline,findcmd,general,pathexp}.c, builtins/getopts.def
+ - call alloc_array(N) instead of (char **)xmalloc (N * sizeof (char *))
+
+subst.c
+ - added code to implement ksh-93 ${!prefix*} expansion
+
+doc/{bash.1,bashref.texi}
+ - documented new ${!prefix*} expansion
+
+ 4/15
+ ----
+execute_cmd.c
+ - new variable, this_shell_function, points to SHELL_VAR of currently
+ executing shell function
+
+variables.c
+ - new dynamic variable, FUNCNAME -- invisible when not executing shell
+ function
+
+doc/{bash.1,bashref.texi}
+ - documented new FUNCNAME variable
+
+ 4/16
+ ----
+support/rlvers.sh
+ - add -T option to specify correct termcap library
+
+configure.in
+ - Irix 4.x still needs to link with -lsun if it contains a replacement
+ getpwent function that works with NIS
+ - if we're configuring with an already-installed readline library,
+ call BASH_CHECK_LIB_TERMCAP and pass the resulting $TERMCAP_LIB to
+ support/rlvers.sh
+
+lib/readline/readline.c
+ - in rl_forward, if rl_point ends up being < 0, set it to 0
+
+lib/readline/exammples/excallback.c
+ - new callback example code, from `Jeff Solomon <jsolomon@stanford.edu>'
+
+lib/sh/getcwd.c
+ - define NULL as 0 if not defined by one of the standard include files
+ - cast result of malloc and realloc to (char *) where appropriate
+
+variables.c
+ - new functions for use by dynamic variables: null_assign and
+ null_array_assign. Used as assign_func for a particular variable,
+ they cause assignments to that variable to be silently ignored
+ - FUNCNAME and GROUPS are no longer readonly
+ - FUNCNAME changed to use null_assign
+ - GROUPS changed to use null_array_assign. This means that the
+ variable can be unset if desired (like for Oracle startup scripts),
+ but cannot be assigned to
+
+doc/{bash.1,bashref.texi}
+ - added text about assignments being silently discarded to descriptions
+ of FUNCNAME and GROUPS
+ - removed text saying that GROUPS is readonly
+ - added standard text about GROUPS being unset and losing its special
+ properties, even if reset
+
+command.h
+ - new command type, cm_subshell, actually causes the shell to fork
+ and then executes the command in the SUBSHELL_COM struct
+
+parse.y
+ - ( ... ) now creates a command of type cm_subshell, with the same
+ flag CMD_WANT_SUBSHELL as previous
+
+make_cmd.c
+ - new function make_subshell_command
+
+make_cmd.h
+ - extern declaration for make_subshell_command
+
+dispose_cmd.c
+ - code to destroy a SUBSHELL_COM
+
+copy_cmd.c
+ - code to duplicate a SUBSHELL_COM
+
+print_cmd.c
+ - code to print a SUBSHELL_COM
+
+execute_cmd.c
+ - broke the code that handles executing commands in subshells out of
+ execute_command_internal into a new function, execute_in_subshell,
+ with the same arguments
+ - executing a command of type cm_subshell is just a slightly special
+ case, handled in execute_in_subshell
+
+ 4/18
+ ----
+execute_cmd.c
+ - changed code in execute_command_internal that executes subshell
+ commands to check for command->type == cm_subshell in addition to
+ checking that commmand->flags & CMD_WANT_SUBSHELL is non-zero
+ - changed execute_in_subshell to set the CMD_NO_FORK flag on the
+ command to be executed by a command of type cm_subshell
+ (command->value.Subshell->command), if that command is a simple
+ command (type == cm_simple) or a nested subshell (type == cm_subshell)
+ and is not being timed
+ - changed execute_command_internal to just call and return the value
+ returned by execute_in_subshell if it gets a command of type
+ cm_subshell with flags including CMD_NO_FORK
+
+lib/malloc/malloc.c
+ - morecore() should always return through morecore_done, not with a
+ simple `return'
+
+ 4/20
+ ----
+variables.c
+ - new function, quote_array_assignment_chars, backslash quotes all
+ `[' and `]' before an `=' in a word that's part of the body of a
+ compound array assignment. Needed because we run the list through
+ the globbing code now. Don't bother if `=' does not appear in
+ the string or if the first char is not `['
+ - call quote_array_assignment_chars from assign_array_var_from_string
+ now
+
+eval.c
+ - moved parse_string_to_word_list to parse.y
+
+parse.y
+ - moved parse_string_to_word_list here. Much simpler -- no longer
+ tries to parse a command, but just reads tokens using read_token().
+ Any token but a WORD or ASSIGNMENT_WORD causes a syntax error.
+ Don't have to mess around with saving global_command or calling
+ parse_command, but do need to save and restore the history stuff,
+ so the array assignment doesn't get saved on the history list
+
+ 4/21
+ ----
+nojobs.c
+ - changed to use functions in lib/sh/shtty.c (tt{get,set}attr) for
+ the terminal attributes
+ - added a `flags' field to struct proc_status, flags are PROC_RUNNING
+ and PROC_NOTIFIED (status has been returned to `wait')
+ - functions check flags & PROC_RUNNING to check whether or not a
+ particular process is still alive; PROC_RUNNING is reset by
+ set_pid_status
+ - new function, mark_dead_jobs_as_notified, same function as the one
+ in jobs.c
+ - cleanup_dead_jobs reaps jobs only if they're dead and not marked
+ as notified
+ - wait_for_background pids marks all pids as notified and reaps them
+ before it returns, since it's called by the `wait' builtin
+ - wait_for_single_pid marks the pid being waited for as notified so
+ its slot can be reclaimed -- it's only called by the `wait' builtin
+ - new function, process_exit_status, to turn what wait(2) takes into
+ an exit status
+
+ 4/22
+ ----
+nojobs.c
+ - add_pid takes a new second argument, async_p, which is non-zero if
+ the process is in the background
+ - new flag, PROC_ASYNC, set by add_pid
+ - set_pid_status now sets the PROC_NOTIFIED flag if PROC_ASYNC is unset,
+ so foreground jobs get cleaned up right away
+ - changed mark_dead_jobs_as_notified to take a `force' argument; if
+ non-zero, it marks only enough dead jobs to make the number of
+ un-notified dead jobs < CHILD_MAX
+ - new function, reap_dead_jobs, same as in jobs.c
+
+execute_cmd.c
+ - don't need separate cases for REAP any more
+
+ 4/23
+ ----
+builtins/printf.def
+ - new function, tescape, which processes a single backslash
+ escape sequence and returns the number of characters consumed by
+ the argument string (code taken from bexpand)
+ - changed bexpand to call tescape rather than do backslash-escape
+ sequence conversion itself
+ - changed occurrences of `illegal' in error messages to `invalid'
+ - printf no longer calls ansicstr to translate backslash-escape
+ sequences; the mainline printf code now calls tescape whenever it
+ hits a backslash
+
+ 4/26
+ ----
+subst.c
+ - new variable, garglist, set to list of words to be expanded after
+ leading assignment statements are removed
+ - command_substitute now calls maybe_make_exported_env before making
+ the child process if there are no variable assignments preceding
+ the command currently being expanded, or if the command currently
+ being expanded consists only of variable assignments
+
+execute_cmd.c
+ - the `early fork' code in execute_simple_command now calls
+ maybe_make_export_env before forking because execute_disk_command
+ would do that in the vast majority of cases, and this will obviate
+ the need to do it for subsequent commands if the environment does
+ not change
+
+ 4/27
+ ----
+variables.h
+ - more macros to manipulate the exportstr member of a SHELL_VAR
+ - changed initialize_shell_variables to cache the value from the
+ environment as the initial exportstr for all imported variables
+ - changed make_var_array to use exportstr if it exists, instead
+ of computing the value
+ - changed make_var_array to cache exportstr for exported functions,
+ so they don't have to be deparsed every time the export env is
+ remade
+
+ 4/28
+ ----
+lib/readline/{histlib,rldefs}.h
+ - changed STREQN macro to evaluate to 1 if the third argument is 0
+
+lib/readline/search.c
+ - changed rl_history_search_{for,back}ward so they leave point at
+ the end of the line when the string to search for is empty, like
+ previous-history and next-history
+ - broke common code out of rl_history_search_{for,back}ward into
+ a new function, rl_history_search_reinit
+ - rewrote rl_history_search_internal to be more like the
+ non-incremental search functions, use noninc_search_from_pos,
+ and leave the last history line found in the current line buffer
+ if the search fails
+ - new function, make_history_line_current, takes care of making
+ the current line buffer a copy of the history entry passed as an
+ argument; used by rl_history_search_internal and noninc_dosearch
+
+subst.c
+ - make ${!prefix@} be the same as ${!prefix*} for (undocumented)
+ ksh93 compatibility
+
+ 4/30
+ ----
+lib/readline/doc/rltech.texinfo
+ - added note about including <readline/readline.h>, and that <stdio.h>
+ should be included before readline.h
+
+lib/readline/doc/hstech.texinfo
+ - added note about including <readline/history.h>
+
+lib/readline/doc/manvers.texinfo
+ - updated version to 4.1
+
+lib/readline/{bind,complete,display,isearch,nls,parens,readline,signals,tilde,
+histexpand}.c
+ - added prototypes with __P((...)) for forward static function
+ declarations
+
+lib/readline/display.c
+ - broke the code that initializes VISIBLE_LINE and INVISIBLE_LINE out
+ of rl_redisplay into a new function, init_line_structures, which
+ takes an argument giving the minimum number of characters that the
+ line must hold
+ - new function for use by applications that want to display the
+ initial prompt themselves rather than having the first call to
+ readline do it: rl_on_new_line_with_prompt (modified from code in
+ the CLISP distribution)
+
+lib/readline/readline.c
+ - new external variable, rl_already_prompted, to let readline know
+ that the prompt string has already been displayed on the screen
+ before the first call to readline
+ - test rl_already_prompted before displaying the prompt in
+ readline_internal_setup
+ - if rl_already_prompted is non-zero, readline_internal_setup calls
+ rl_on_new_line_with_prompt instead of rl_on_new_line
+
+lib/readline/readline.h
+ - extern declaration for rl_on_new_line_with_prompt
+ - extern declaration for rl_already_prompted
+
+lib/readline/doc/rltech.texinfo
+ - documented rl_on_new_line_with_prompt and rl_already_prompted
+
+builtins/read.def
+ - new -s option (silent mode). Input from a terminal is not echoed
+
+doc/{bash.1,bashref.texi}
+ - documented new `-s' option to read builtin
+
+ 5/3
+ ---
+lib/readline/vi_mode.c
+ - replaced references to rl_getc with (*rl_getc_function)
+
+[bash-2.04-devel frozen]
+
+ 5/5
+ ---
+subst.c
+ - make sure that verify_substring_values always passes malloc'd
+ memory to maybe_expand_string as the string to be expanded,
+ since it gets freed on errors
+
+support/shobj-conf
+ - don't need -R option for shared libraries on Solaris
+ - new stanza for OSF/1 machines with gcc
+
+lib/readline/readline.c
+ - new variable, rl_gnu_readline_p, always 1. Available to allow
+ readline users to test whether or not they're linking against
+ the true readline, rather than some bogus replacement (from CLISP)
+
+lib/readline/readline.h
+ - extern declaration for rl_gnu_readline_p
+
+hashlib.h, hashcmd.h
+ - added prototypes to extern function declarations
+
+pcomplete.h
+ - new file, declarations for the programmable completion stuff
+
+pcomplib.c
+ - new file, library functions for programmable completion
+
+ 5/6
+ ---
+builtins/complete.def
+ - new file, interface to programmable completion management
+
+configure.in
+ - new enable argument --enable-progcomp, defines
+ PROGRAMMABLE_COMPLETION
+
+config.h.in
+ - #define for PROGRAMMABLE_COMPLETION
+
+config-bot.h
+ - if PROGRAMMABLE_COMPLETION is defined and READLINE is not,
+ #undef PROGRAMMABLE_COMPLETION
+
+pcomplete.c
+ - new file, placeholder for programmable completion generators and
+ associated functions
+
+Makefile.in, builtins/Makefile.in
+ - changes to add pcomplete.c, builtins/complete.def
+
+ 5/7
+ ---
+subst.c
+ - new function, #ifdef READLINE, skip_to_delim (s, i, delims).
+ Starting at s[i], return the index of the first character in s
+ that is contained in delims. Understands shell quoting.
+ - added two arguments to list_string_with_quotes: an index to
+ watch for, and a pointer to int to return the index into the
+ created word list of the word containing the sentinel. Now
+ compiled in all the time. The returned index starts at 1.
+
+subst.h
+ - extern declarations for char_is_quoted, unclosed_pair, and
+ skip_to_delim
+ - changed extern declaration for list_string_with_quotes, moved
+ it out of the #ifdef ARRAY_VARS section
+
+bashline.c
+ - removed extern declarations for char_is_quoted and unclosed_pair
+
+variables.c
+ - new function, SHELL_VAR **all_exported_variables()
+ = new function, SHELL_VAR **all_array_variables(), #ifdef ARRAY_VARS
+
+variables.h
+ - extern declaration for all_exported_variables, all_array_variables
+
+lib/sh/strpbrk.c
+ - replacement if we don't have strpbrk(3)
+
+configure.in, config.h.in
+ - check for strpbrk(3), define HAVE_STRPBRK if found
+
+builtins/shopt.def
+ - new function, char **get_shopt_options (), returns an array of
+ shopt option names
+
+builtins/set.def
+ - new function, char **get_minus_o_opts (), returns an array of
+ `set -o' option names
+
+builtins/common.h
+ - extern declarations for get_shopt_options, get_minus_o_opts
+
+ 5/10
+ ----
+pathexp.c
+ - make the POSIX_GLOB_LIBRARY code implement the GLOBIGNORE stuff
+
+ 5/11
+ ----
+array.c
+ - new convenience function, char **array_to_argv (ARRAY *),
+ converts an array to a list of string values
+
+array.h
+ - extern declaration for array_to_argv
+
+execute_cmd.c
+ - new convenience function, int execute_shell_function (SHELL_VAR *,
+ WORD_LIST *)
+
+execute_cmd.h
+ - extern declaration for execute_shell_function
+
+builtins/evalstring.c
+ - make parse_and_execute unwind_protect current_prompt_string
+ if the shell is interactive
+
+ 5/12
+ ----
+variables.c
+ - moved bind_int_variable from expr.c to here; it now returns a
+ SHELL_VAR *, like the other variable binding functions
+
+variables.h
+ - extern declaration for bind_int_variable
+
+ 5/14
+ ----
+bashline.c, parse.y, general.c, make_cmd.c, subst.c, braces.c, execute_cmd.c
+ - replaced some common code sequences with calls to substring()
+
+lib/readline/doc/rltech.texinfo
+ - fixed small typo in description of rl_completion_entry_function
+
+ 5/18
+ ----
+stringlib.c
+ - new function, strcreplace(char *string, int c, char *text, int do_glob)
+ replaces all occurrences of C in STRING with TEXT. Backslash may
+ be used to quote C. If DO_GLOB is non-zero, the replacement TEXT
+ is quoted to protect globbing characters.
+
+externs.h
+ - extern declaration for strcreplace
+
+bashhist.c
+ - use strcreplace in expand_histignore_pattern
+
+pcomplete.c
+ - finished initial implementation of programmable completion
+
+alias.c
+ - code to set the aliases itemlist to dirty when an alias is added
+ or removed, if PROGRAMMABLE_COMPLETION is defined
+
+variables.c
+ - code to set the functions itemlist to dirty when a shell function
+ is added or removed, if PROGRAMMABLE_COMPLETION is defined
+
+builtins/enable.def
+ - code to set the builtins itemlist to dirty when a shell builtin
+ is added or removed, if PROGRAMMABLE_COMPLETION is defined
+ - code to set the enabled and disabled itemlists to dirty when a
+ builtin is enabled or disabled, if PROGRAMMABLE_COMPLETION is
+ defined
+
+builtins/shopt.def
+ - new shell option, `progcomp', on if programmable_completion_enabled
+ (from pcomplete.c) is non-zero
+
+doc/{bash.1,bashref.texi}
+ - note that `${' is not eligible for brace expansion to avoid
+ conflicts with parameter expansion
+
+ 5/19
+ ----
+builtins/complete.def
+ - added a new `compgen' builtin for use by completion functions
+
+ 5/21
+ ----
+bashline.c
+ - new function, void clear_hostname_list(void), to delete all the
+ entries in the hostname completion list
+
+bashline.h
+ - extern declaration for clear_hostname_list
+
+variables.c
+ - changed sv_hostfile to clear the hostname list if $HOSTFILE is
+ unset
+
+doc/{bash.1,bashref.texi}
+ - documented new behavior of HOSTFILE when it's unset
+ - added some awkwardly-worded text to make it clear that an
+ interactive shell cannot be started with non-option arguments
+ or with the -c option
+
+shell.c
+ - restored NON_INTERACTIVE_LOGIN_SHELLS test, so that if it is
+ defined, shells with argv[0][0] == '-' and not in posix mode
+ run the startup files even if non-interactive
+
+config-top.h
+ - added commented-out #define for NON_INTERACTIVE_LOGIN_SHELLS
+
+ 5/24
+ ----
+subst.c
+ - make sure the characters in IFS are cast to unsigned before being
+ indexed in ifscmap (expand_word_internal)
+
+ 5/25
+ ----
+parse.y
+ - change grammar rule for arithmetic for expressions to handle a
+ list_terminator after the `))' instead of requiring a newline_list
+
+subst.c
+ - fix so that variable indirection can reference the shell's special
+ variables (like $0...$9, $$, $#, etc.)
+
+pcomplete.c
+ - changed gen_wordlist_matches to use split_at_delims to split the
+ string at $IFS first, then expand each individual word
+
+ 5/27
+ ----
+lib/readline/histfile.c
+ - change things so that O_BINARY mode is used when reading and writing
+ the history file on cygwin32 as well as OS/2 (__EMX__)
+
+parse.y
+ - add calls to push_delimiter and pop_delimiter around the call
+ to parse_matched_pair when parsing $'...' and $"..." so the
+ history entry is added correctly
+
+ 5/28
+ ----
+doc/{bash.1,bashref.texi}, lib/readline/doc/rluser.texinfo
+ - documented new programmable completion facilities
+
+doc/bashref.texi
+ - documented new configure `--enable-progcomp' option
+
+ 6/1
+ ---
+variables.c
+ - if make_local_variable is being asked to make a local shadow
+ variable of a read-only variable, print an error message and
+ return NULL
+ - if make_local_variable returns NULL to make_local_array_variable,
+ just return it
+
+builtins/declare.def
+ - if we're making local variables, and make_local_array_variable or
+ make_local_variable returns NULL, just flag an error and go on
+
+ 6/2
+ ---
+Makefile.in
+ - changed release status to `alpha1'
+
+[bash-2.04-alpha1 frozen]
+
+ 6/18
+ ----
+bashline.c
+ - fixed find_cmd_start so that it doesn't spin-loop on commands with
+ a command separator like `;' or `&'. Problem was not incrementing
+ `os' past the delimiter found
+
+ 6/21
+ ----
+variables.c
+ - cosmetic change: introduced two macros to encapsulate initialization
+ of dynamic variables
+
+ 6/23
+ ----
+pcomplib.c
+ - new function: num_progcomps(void), returns the number of entries in
+ the programmable completions hash table
+
+pcomplete.h
+ - extern declaration for num_progcomps
+
+bashline.c
+ - make sure some programmable completions have been defined before
+ diving into the programmable completion code
+
+shell.c
+ - in open_shell_script, move the fd opened to the script to a high
+ one with move_to_high_fd in all cases -- the buffered input code
+ still has problems if fd == 0 and later on fd 0 is closed or
+ redirected (cf. input.c:check_bash_input())
+
+builtins/printf.def
+ - getlong() now calls strtol directly with a third argument of 0 so
+ it can handle 0x (hex) and 0 (octal) prefixes, which legal_number
+ does not -- this has implications for arguments to %d that begin
+ with `0'
+
+lib/sh/getenv.c
+ - make sure that the variable found in the temporary environment has
+ a non-null value before calling savestring() on it
+
+subst.c
+ - make sure split_at_delims returns 0 in *nwp and *cwp if handed a
+ null or empty string
+
+pcomplete.c
+ - make sure build_arg_list handles lwords == 0, as it will be if an
+ empty command line is handed to the programmable completion code
+ (like compgen -C xyz)
+
+execute_cmd.c
+ - make sure execute_shell_function passes a non-null bitmap of fds to
+ close to execute_function, allocating and deallocating it locally
+
+sig.c
+ - don't mess with SIGPROF in initialize_terminating_signals
+
+jobs.c, nojobs.c
+ - if the user has requested it with checkwinsize, check for a new
+ window size after a job exits due to a signal as well as being
+ stopped
+
+lib/readline/kill.c
+ - changed rl_kill_region to set the point to the beginning of the
+ region after the kill is performed
+
+ 6/24
+ ----
+configure.in
+ - make sure ranges ([1-9]*) are protected with [...] for m4 quoting
+
+variables.c
+ - make sure that bind_variable_value honors `set -a' and that it
+ marks the environment for recreation if necessary
+
+ 6/25
+ ----
+lib/readline/complete.c
+ - if we're completing at the end of the line, find_completion_word
+ shouldn't test whether the character is a special word break
+ char and (possibly) advance rl_point past the end of the buffer
+
+parse.y
+ - change mk_msgstr to write embedded newlines as `\n"<NL>"', as the
+ PO file format apparently requires
+
+ 6/28
+ ----
+lib/readline/display.c
+ - code to manage the growth of the inv_lbreaks and vis_lbreaks arrays
+ beyond 256, since there are pathalogical command lines that can
+ have more than 256 line breaks for redisplay
+
+ 6/30
+ ----
+stringlib.c
+ - include pathexp.h for extern declaration of quote_globbing_chars
+
+variables.h
+ - change CACHE_EXPORTSTR to savestring() the value and not set the
+ att_importstr flag
+
+ 7/6
+ ---
+support/bashbug.sh
+ - bashbug now accepts --help and --version options
+
+bashline.c
+ - change bash_quote_filename to use single quotes if the user
+ does not specify an opening quote character and the filename being
+ completed contains newlines
+
+ 7/8
+ ---
+configure.in, aclocal.m4, config.h.in
+ - BASH_TYPE_INT32_T --> BASH_TYPE_BITS32_T; int32_t --> bits32_t
+ - BASH_TYPE_U_INT32_T --> BASH_TYPE_U_BITS32_T; u_int32_t --> u_bits32_t
+
+lib/malloc/{malloc,gmalloc}.c, lib/sh/inet_aton.c
+ - int32_t --> bits32_t; u_int32_t --> u_bits32_t
+
+aclocal.m4
+ - new tests: BASH_TYPE_BITS16_T, BASH_TYPE_U_BITS16_T
+
+configure.in
+ - add check for sizeof short, sizeof char
+ - call BASH_TYPE_BITS16_T, BASH_TYPE_U_BITS16_T
+
+config.h.in
+ - new #defines for bits16_t, u_bits16_t
+
+lib/malloc/malloc.c
+ - use u_bits16_t for type of mi_magic2
+
+
+ 7/16
+ ----
+lib/readline/display.c
+ - new private library function, _rl_strip_prompt, to remove instances
+ of RL_PROMPT_{START,END}_IGNORE from the passed prompt string
+
+lib/readline/rlprivate.h
+ - extern declaration for _rl_strip_prompt
+
+lib/readline/readline.c
+ - call _rl_strip_prompt before outputting the prompt if we're not
+ doing any echoing of input chars (readline_echoing_p == 0)
+
+Makefile.in
+ - tentative change to rule for parser-built: use $< instead of
+ `y.tab.h' in recipe
+
+ 7/19
+ ----
+support/config.{guess,sub}
+ - add code to handle all versions of Mac OS (e.g., Mac OS X)
+
+ 7/26
+ ----
+lib/readline/bind.c
+ - on cygwin32, treat \r\n as a line terminator when reading the
+ inputrc file
+
+ 7/29
+ ----
+lib/sh/netopen.c
+ - fixed problem in _getaddr with copying the address returned from
+ gethostbyname to the `struct in_addr *' argument -- hostnames
+ now work in /dev/(tcp|udp)/host/port
+
+ 8/2
+ ---
+configure.in
+ - on Apple Rhapsody systems, set LOCAL_CFLAGS to -DRHAPSODY
+
+variables.h
+ - changes from Apple for building fat binaries on Rhapsody,
+ setting HOSTYPE, OSTYPE, VENDOR, and MACHTYPE
+
+lib/readline/terminal.c
+ - some work on the `dumb terminal' setup code in _rl_init_terminal_io
+ to make sure it's complete for use by the redisplay code and some
+ stuff in {readline,complete}.c
+
+lib/readline/display.c
+ - new function, _rl_current_display_line, returns the number of
+ lines down from the first `screen line' of the current readline
+ line the cursor is
+
+lib/readline/readline.c
+ - make rl_refresh_line call _rl_current_display_line
+
+lib/readline/rlprivate.h
+ - extern declaration for _rl_current_display_line
+
+ 8/3
+ ---
+doc/bashref.texi
+ - reorganized slightly:
+ o a new shell builtins chapter
+ o a new shell variables chapter
+ o a new special builtins section
+ o bourne shell features chapter removed
+ o alias builtins moved to the bash builtins section
+ o bourne shell differences moved to appendix
+ o order of readline and history chapters swapped
+ o indices are now unnumbered appendices
+ o some text cleaned up and some explanatory text added
+
+lib/readline/terminal.c
+ - if a calling application is using a custom redisplay function,
+ don't call tgetent to get the terminal attributes, since those
+ are used only by the redisplay code. Still get the window
+ size, though
+
+lib/glob/fnmatch.c
+ - range comparisons in bracket expressions no longer use strcoll(3),
+ since in some locales (de, for example), [A-Z] matches all
+ characters
+
+parse.y, print_cmd.c
+ - some changes to make sure the shell compiles when
+ DPAREN_ARITHMETIC is not defined but ARITH_FOR_COMMAND is
+
+ 8/5
+ ---
+redir.c
+ - in the here document code in do_redirection_internal, check
+ that the file descriptor returned by here_document_to_fd is not
+ the same as a file descriptor specified as the redirector
+ before closing it
+
+ 8/6
+ ---
+parse.y
+ - make sure the pipline rule for `timespec BANG pipeline' sets the
+ CMD_INVERT_RETURN flag for the pipeline command
+
+builtins/wait.def
+ - use setjmp with a special jump buffer to take longjmps in the
+ case that a SIGINT is received while waiting for jobs or processes
+ it makes wait return with a status > 128, as POSIX.2 specifies
+
+{jobs,nojobs}.c
+ - changed wait_sigint_handler to longjmp to wait_intr_buf if it's
+ executing the wait builtin and SIGINT is trapped. It calls
+ trap_handler to make sure a pending trap for SIGINT is set also,
+ so the trap is taken when the wait builtin returns
+
+ 8/9
+ ---
+jobs.c
+ - save and restore the value of errno in sigchld_handler
+
+trap.c
+ - save and restore the value of errno in trap_handler
+
+ 8/10
+ ----
+Makefile.in
+ - changed release status to beta1
+
+ 8/13
+ ----
+include/posixtime.h
+ - new file to encapsulate the <time.h> and <sys/time.h> mess
+
+Makefile.in
+ - add posixtime.h to list of include files in BASHINCFILES
+ - update dependencies for general.o, execute_cmd.o
+
+general.c, execute_cmd.c, builtins/times.def
+ - include posixtime.h instead of <time.h>, <sys/time.h>
+
+general.c
+ - protect inclusion of <sys/times.h> with HAVE_SYS_TIMES_H check
+
+builtins/Makefile.in
+ - update dependencies for times.o
+
+ 8/16
+ ----
+lib/sh/timeval.c
+ - moved functions dealing with struct timevals here from general.c
+ and execute_cmd.c
+
+lib/sh/clock.c
+ - moved functions dealing with clock_ts here from general.c
+ (print_time_in_hz renamed to print_clock_t)
+
+externs.h
+ - moved extern declarations for timeval_to_secs and print_timeval
+ here from general.h
+ - moved extern declarations for clock_t_to_secs and print_clock_t
+ here from general.h
+
+builtins/times.def
+ - calls to print_time_in_hz changed to print_clock_t
+
+Makefile.in
+ - added references for lib/sh/timeval.c and lib/sh/clock.c
+
+lib/sh/Makefile.in
+ - clock.o and timeval.o are now included in libsh.a
+
+ 8/23
+ ----
+execute_cmd.c
+ - make sure last_command_exit_value is updated before running a
+ DEBUG trap in the cm_simple case of execute_command_internal
+
+lib/readline/display.c
+ - new function, static void redraw_prompt (char *), used to
+ redraw the last line of a multiline prompt that possibly
+ contains terminal escape sequences
+ - call redraw_prompt from _rl_redisplay_after_sigwinch
+
+ 8/24
+ ----
+lib/readline/bind.c
+ - new struct with names of string-valued readline variables and
+ handler functions to call when the variable is set
+ - changed rl_variable_bind to use functions to find boolean vars
+ and string vars in their respective lists
+ - new function, bool_to_int, to translate a boolean value that may
+ appear as an argument to `set <boolean-var-name>' to 1 or 0
+ - new function, hack_special_boolean_var, called if the element in
+ the boolean_vars struct has the V_SPECIAL flag set, to provide
+ any necessary other action when a boolean variable is set
+ - new functions to be called when each string variable is set;
+ called by rl_variable_bind
+
+execute_cmd.c
+ - do_piping no longer sets pipes to O_TEXT mode if __CYGWIN32__
+ is defined
+
+ 8/25
+ ----
+subst.c
+ - parameter_brace_patsub now mallocs a local copy of `patsub', because
+ if it starts with a `/' we increment it, and functions down the call
+ chain will free that on an error (and if we pass the incremented
+ value, will try to free unallocated memory)
+ - pos_params now short-circuits and returns a null string immediately
+ if start == end, meaning we want 0 positional parameters
+
+ 8/26
+ ----
+subst.c
+ - fixed pat_subst to correctly handle a null replacement string with
+ a null pattern string prefixed with `%' or `#'
+
+ 9/3
+ ---
+variables.c
+ - don't import shell functions from the environment if the shell was
+ started with -n
+
+ 9/8
+ ---
+subst.c
+ - if a command substitution is being performed inside a shell function,
+ catch `return' in command_substitute so that a return inside the
+ command substitution doesn't jump back to execute_function (or one
+ of its brethren) and go on with the command
+
+parse.y
+ - in history_delimiting_chars, if the first line is `for var' and
+ command_oriented_history is active, we don't want a semicolon if
+ the next token to be read is `in', but we do want one otherwise.
+ All we can do is check shell_input_line and see if the next chars
+ are `in' -- if so, we return " "
+
+ 9/16
+ ----
+builtins/hash.def
+ - don't allow `hash -p /pathname/with/slashes name' if the shell
+ is restricted
+
+doc/{bash.1,bashref.texi}
+ - updated description of restricted shell mode
+
+lib/readline/display.c
+ - fixed a bug in _rl_update_final which used the inv_lbreaks array
+ to index into visible_line
+
+jobs.c
+ - waitchld() need not go through the pain of setting up an environment
+ to execute traps on SIGCHLD if children_exited == 0
+ - waitchld returns -1 if waitpid() returns -1 with errno == ECHILD,
+ indicating that there are no unwaited-for child processes, and it
+ has not yet reaped any dead children
+ - wait_for, wait_for_single_pid return -1 if waitchld() returns -1
+ - new function, mark_all_jobs_as_dead
+ - wait_for_background_pids calls mark_all_jobs_as_dead if
+ wait_for_single_pid returns -1 with errno == ECHILD, since there are
+ no unwaited-for child processes
+
+subst.c
+ - tentative change: subshells started for command substitution no
+ longer unconditionally disable job control
+
+ 9/17
+ ----
+parse.y
+ - new function: save_token_state(). Saves the value of last_read_token
+ and the two previous tokens in an allocated array and returns the
+ array
+ - new function: restore_token_state(ts). TS is an array returned by
+ save_token_state. last_read_token and the two previous tokens are
+ set from the values in TS
+
+trap.c
+ - run_pending_traps calls save_token_state and restore_token_state
+ around the call to parse_and_execute, which will call the parser
+ and possibly leave it in a state where reserved words will not be
+ recognized (_run_trap_internal, too)
+
+ 9/20
+ ----
+support/bashbug.sh
+ - if sendmail is used as $RMAIL, pass `-i -t' as arguments so changes
+ made by the user to the recipient headers in the message are
+ honored
+
+ 9/21
+ ----
+bashhist.c
+ - if histverify has been set, make sure a `:p' modifier to a history
+ expansion prints the result
+
+builtins/echo.def
+ - new extern variable, xpg_echo, set to 1 if DEFAULT_ECHO_TO_USG is
+ defined and 0 otherwise
+ - echo_builtin now sets the initial value of do_v9 from xpg_echo
+
+builtins/shopt.def
+ - new shopt option, `xpg_echo', turns backslash escape expansion by
+ `echo' on and off at runtime
+
+builtins/{bash.1,bashref.texi}
+ - documented new `xpg_echo' shell option
+
+tests/{builtins.tests,builtins2.sub,shopt.tests}
+ - changes for new `xpg_echo' shell option
+
+configure.in
+ - changes for FreeBSD-3.x ELF to add `-rdynamic' to LOCAL_LDFLAGS.
+ This allows dynamic loading of builtins
+
+support/shobj-conf
+ - changes to handle FreeBSD-3.x elf or a.out object file formats
+
+ 9/23
+ ----
+[bash-2.04-beta1 released]
+
+ 9/24
+ ----
+jobs.c
+ - wait_for returns -1 only if the shell is currently executing the
+ `wait' builtin, since that's the only thing that cares
+
+execute_cmd.c
+ - moved cases of close_fd_bitmap to before calls to do_piping to
+ handle some pathological cases
+
+ 9/29
+ ----
+execute_cmd.c
+ - save the command line in execute_simple_command before making the
+ export environment, since maybe_make_export_env clobbers
+ the_printed_command if there are exported functions
+
+ 9/30
+ ----
+configure.in,config.h.in
+ - check explicitly for setvbuf; define HAVE_SETVBUF if found
+
+configure.in
+ - change opt_gnu_malloc to opt_bash_malloc, since the bash malloc
+ is not really the gnu malloc anymore
+ - new argument, --with-bash-malloc, identical to --with-gnu-malloc
+ - AC_DEFINE(USING_BASH_MALLOC) if opt_bash_malloc is enabled
+
+config.h.in
+ - new #define for USING_BASH_MALLOC
+
+doc/bashref.texi
+ - updated installation section to add --with-bash-malloc and
+ change description of --with-gnu-malloc
+
+lib/sh/setlinebuf.c
+ - change name of function to sh_setlinebuf, just returns 0 if
+ HAVE_SETVBUF and HAVE_SETLINEBUF are undefined
+ - prefer setvbuf to setlinebuf if we have both
+ - if we're using setvbuf, use a local buffer for stdin and stdout
+ local buffer is BUFSIZ unless we're using the bash malloc
+ (USING_BASH_MALLOC is defined), in which case it's 1008 (which
+ the bash malloc rounds up to 1024)
+
+ 10/4
+ ----
+input.c
+ - if USING_BASH_MALLOC is defined, set the max buffer size to 8176,
+ which the bash malloc rounds up to 8192
+
+ 10/5
+ ----
+pcomplete.c
+ - new function, pcomp_filename_completion_function, a wrapper for
+ filename_completion_function that dequotes the filename first
+
+bashline.c
+ - changed bash_directory_completion_matches to dequote the filename
+ before passing it (indirectly) to filename_completion_function
+
+execute_cmd.c
+ - change execute_command to defer calling unlink_fifo_list until any
+ shell function has finished executing (variable_context == 0)
+
+configure.in
+ - added AC_CYGWIN, AC_MINGW32, AC_EXEEXT
+
+ 10/8
+ ----
+subst.c
+ - expand_word_internal(): changes some things to avoid small (2 or 3
+ byte) calls to xmalloc -- added a label and some gotos (BEWARE)
+ - changed make_dev_fd_filename so it doesn't call sprintf anymore
+
+ 10/27
+ -----
+execute_cmd.c
+ - make execute_select_command handle the effects of the `continue'
+ builtin correctly
+
+ 11/5
+ ----
+Makefile.in
+ - RELSTATUS changed to `beta2'
+
+ 11/8
+ ----
+[bash-2.04-beta2 released]
+
+ 11/9
+ ----
+shell.c
+ - make run_startup_files check for ssh2 as well as ssh1
+
+ 11/19
+ -----
+parse.y
+ - make sure parsing conditional commands isn't confused by unexpected
+ tokens (like `[[)]]')
+
+builtins/common.c
+ - fix get_job_spec to return NO_JOB for numeric job specs that are
+ beyond the size of the jobs table
+
+builtins/type.def
+ - change describe_command to report `not found' if a path search
+ returns the same string as the command name and the command name
+ does not match an executable file. This has implications for
+ `type' and `command -[vV]'.
+ - if a command is not found in $PATH, but an executable file with the
+ name supplied exists in the current directory, make the command
+ into a full pathname for the `command' builtin. This has
+ implications for `type' and `command -[vV]'
+
+subst.c
+ - new function, expand_prompt_string, expands prompt string and
+ returns the string passed if an error occurs
+
+subst.h
+ - extern declaration for expand_prompt_string
+
+parse.y
+ - decode_prompt_string calls expand_prompt_string instead of
+ expand_string_unsplit
+
+ 11/22
+ -----
+builtins/echo.def
+ - return EXECUTION_FAILURE if ferror(stdout) is true
+
+ 11/23
+ -----
+locale.c
+ - if LC_ALL is unset, call setlocale(LC_ALL, lc_all), because lc_all
+ holds the default locale
+
+ 11/29
+ -----
+lib/readline/shell.c
+ - define NULL as 0 if it's not defined
+ - change single_quote to allocate 4 characters in new string for
+ each character in the old one (like builtins/common.c:single_quote)
+
+locale.c
+ - when a locale variable (LC_*) is unset, pass "" to setlocale()
+ to get the default locale set, since value is NULL
+
+lib/sh/makepath.c
+ - new function, sh_makepath(char *path, char *dir, int flags)
+
+Makefile.in
+ - changed version to beta3
+
+builtins/type.def
+ - changed describe_command to use sh_makepath()
+
+builtins/cd.def
+ - removed private declaration of mkpath(), changed to use sh_makepath
+
+general.c
+ - changed make_absolute to use sh_makepath
+ - changed full_pathname to use sh_makepath
+
+findcmd.c
+ - removed private definition of make_full_pathname, changed to use
+ sh_makepath
+
+doc/{bashref.texi,bash.1}
+ - added text to description of `getopts' to make it clear that getopts
+ may be used to parse option characters other than letters, and
+ that `:' and `?' may not be used as option characters
+
+eval.c
+ - when processing a jump_to_top_level(EXITPROG), make sure the shell
+ doesn't think it's still in a function by setting variable_context
+ to 0
+
+doc/rbash.1
+ - a skeletal man page for rbash, adapted from debian
+
+support/bashbug.sh
+ - try to find a default editor if EDITOR is unset, rather than blindly
+ using `emacs'
+
+ 11/30
+ -----
+support/config.{guess,sub}
+ - many changes from the latest `automake' distribution, from the
+ Debian folks
+
+ 12/2
+ ----
+lib/readline/keymaps.h, lib/tilde/tilde.h
+ - added support for C++ compilation (`extern "C" {...}')
+
+ 12/3
+ ----
+subst.c
+ - in process_substitute, make sure the child resets the O_NONBLOCK
+ flag on the file descriptor opened for read to a named pipe
+
+jobs.c
+ - new function, raw_job_exit_status, returns exit status of last job
+ in pipeline
+ - change job_exit_status to call raw_job_exit_status and pass the
+ result to process_exit_status
+ - in notify_of_job_status, get termination status from call to
+ raw_job_exit_status, rather than the first job in the pipeline
+ (fixes debian bug #15165)
+
+bashhist.c
+ - changed bash_history to not add shell comment lines to the history
+ file (fixes debian bug #21901). Uses new function shell_comment(L)
+ which returns 1 if L is a shell comment line. Doesn't handle
+ comments embedded in lines yet
+
+redir.c
+ - when running in POSIX.2 mode, bash no longer performs word splitting
+ on the expanded value of the word supplied as the filename argument
+ to a redirection operator (fixes debian bug #30460)
+
+doc/bashref.texi
+ - added new redirection stuff to POSIX Mode section (from previous fix)
+
+ 12/6
+ ----
+hashlib.h
+ - removed extra semicolon at end of HASH_ENTRIES define
+
+redir.c
+ - replaced toggling of disallow_filename_globbing flag with setting
+ flags in redirection word to include W_NOGLOB if the shell is in
+ POSIX mode and not interactive when expanding the filename argument
+ to a redirection
+
+ 12/7
+ ----
+builtins/common.c
+ - new function, backslash_quote_for_double_quotes(char *), quotes
+ characters special when in double quotes in the string passed as
+ an argument.
+ #ifdef PROMPT_STRING_DECODE; called by decode_prompt_string
+
+builtins/common.h
+ - extern declaration for backslash_quote_for_double_quotes
+
+parse.y
+ - call backslash_quote_for_double_quotes instead of backslash_quote
+ in decode_prompt_string
+
+ 12/9
+ ----
+parse.y
+ - before expanding the \u prompt string escape sequence, make sure
+ current_user.user_name is non-null and call get_current_user_info
+ if it is
+
+ 12/10
+ -----
+support/mkversion.sh
+ - changes to avoid relying on floating point output format, which
+ can be locale-specific
+
+ 12/14
+ -----
+print_cmd.c
+ - changes to named_function_string (for normal function printing)
+ and print_function_def (for printing function definitions embedded
+ in other commands) to print redirections that should be attached
+ to the function as a whole after the closing brace
+
+tests/func1.sub
+ - tests for printing functions with attached redirections, called by
+ func.tests
+
+ 12/16
+ -----
+lib/readline/complete.c
+ - if we're completing files in the root directory and executing the
+ visible-stats code, don't pass an empty pathname to
+ rl_directory_completion_hook, because, for bash, that will be
+ expanded to the current directory. Just pass `/' instead.
+
+lib/tilde/tilde.c
+ - fix to tilde_expand_word for Cygwin to avoid creating pathnames
+ beginning with `//' if $HOME == `/'
+
+variables.c
+ - don't bother with the exportstr validation on cygwin systems,
+ or even using exportstr at all, since that system has weird
+ environment variables
+
+ 12/17
+ -----
+configure.in
+ - new option, --enable-xpg-echo-default, new name for
+ --enable-usg-echo-default (which is still present for backwards
+ compatibility)
+
+configure.in, config.h.in, builtins/echo.def
+ - DEFAULT_ECHO_TO_USG -> DEFAULT_ECHO_TO_XPG
+
+ 12/29
+ -----
+aclocal.m4
+ - changed a couple of tests to avoid creating files with known
+ names in /tmp
+
+support/rlvers.sh
+ - changed to create files in /tmp/rlvers
+
+support/mksignames.c
+ - now understands the POSIX.1b real-time signal names on systems
+ that support them
+
+ 12/30
+ -----
+[bash-2.04-beta3 released]
+
+ 12/31
+ -----
+redir.c
+ - try some more things to avoid race file replacements in
+ here_document_to_fd
+
+parse.y
+ - two new functions:
+ get_current_prompt_level: returns 2 if current prompt is $PS2,
+ 1 otherwise
+ set_current_prompt_level: sets current prompt to $PS2 if arg
+ is 2, $PS1 otherwise
+
+copy_cmd.c
+ - make sure to copy the `line' member in copy_arith_for_command
+
+pcomplete.c
+ - free up `lwords' and `line' after evaluating any command or shell
+ function in gen_compspec_completions
+ - after filtering any matches specified by cs->filterpat in
+ gen_compspec_completions, free ret->list (the members have
+ already been copied or freed by filter_stringlist)
+
+bashline.c
+ - free what find_cmd_name returns after calling the programmable
+ completion code
+
+ 1/4/2000
+ --------
+subst.c
+ - make call_expand_word_internal set w->word to NULL if either
+ expand_word_error or expand_word_fatal is returned
+
+ 1/7
+ ---
+parse.y
+ - two new functions: set_current_prompt_level(int) and
+ get_current_prompt_level() to set and get the `level' of
+ current_prompt_string (1 if $PS1, 2 if $PS2)
+
+externs.h
+ - extern declarations for {get,set}_current_prompt_level
+
+builtins/evalstring.c
+ - add an unwind_protect to save and restore the current prompt
+ string pointers using {get,set}_current_prompt_level
+
+ 1/9
+ ---
+Makefile.in
+ - changed release status to `beta4'
+
+ 1/18
+ ----
+[bash-2.04-beta4 released]
+
+ 1/19
+ ----
+configure.in
+ - moved checks for non-unix variants to beginning of tests
+
+Makefile.in, {builtins,support}/Makefile.in
+ - added some $(EXEEXT) suffixes to generated programs for non-Unix
+ systems
+
+ 1/20
+ ----
+parse.y
+ - make get_current_prompt_level return 1 if current_prompt_string is
+ NULL (as it would be while sourcing startup files)
+
+support/rlvers.sh
+ - rmdir $TDIR in the exit trap
+ - move the exit trap after we successfully create $TDIR
+
+ 1/21
+ ----
+subst.c
+ - several changes to split_at_delims to make non-whitespace
+ delimiters create separate fields containing those delimiters,
+ like the shell parser does with meta characters. This allows
+ redirection operators, for example, to be treated as separate
+ words by the programmable completion code
+
+examples/complete/complete-examples
+ - added new function: _redir_op, which return true if the word
+ passed as an argument contains a redirection operator (just
+ bare-bones for now)
+ - changed set completion function to use _redir_op as an example
+
+parse.y
+ - make parse_string_to_word_list save and restore the value of
+ shell_input_line_terminator, since an assignment like
+ COMPREPLY=() inside a shell function called by the programmable
+ completion code can change shell_input_line_terminator out from
+ underneath shell_getc(). shell_getc will set the input line
+ terminator to EOF when it gets EOF from the getter function, and
+ the string getter function returns EOF at EOS. parse_and_execute
+ tests for EOS directly and never gets EOF from shell_getc, so it
+ does not have this problem.
+
+ 1/24
+ ----
+lib/readline/funmap.c
+ - #define QSFUNC like in complete.c
+ - cast _rl_qsort_string_compare to a QSFUNC * in the call to qsort
+
+lib/readline/terminal.c
+ - correct a typo in usage of the __EMX__ preprocessor define
+ - fix a reversed usage of `#if defined (__DJGPP__)' in
+ _rl_control_keypad
+ - remove extern declarations for _rl_in_stream and _rl_out_stream
+
+lib/readline/rlprivate.h
+ - add extern declaration for _rl_in_stream, since there's already
+ one for _rl_out_stream
+
+builtins/ulimit.def
+ - if bash is using ulimit(2), make sure that getfilesize() returns
+ the value multiplied by 512 to convert it from a number of blocks
+ to a number of bytes
+
+ 1/25
+ ----
+execute_cmd.c
+ - make sure execute_command_internal sets last_command_exit_value
+ correctly when inverting the return value of a (...) subshell
+ command
+
+tests/{run-invert,invert.{tests,right}}
+ - new tests for return value inversion
+
+configure.in
+ - compile without bash malloc on m68k-motorola-sysv due to a file
+ descriptor leak in closedir(3) -- the motorola implementation
+ requires that freed memory be readable so it can free the dirent
+ and then look back at it to find the file descriptor
+
+expr.c
+ - fix negative exponents in v**e to return an eval error
+
+ 2/1
+ ---
+Makefile.in
+ - changed status to beta5
+
+jobs.c
+ - fixed a problem with checking the wrong process when checking to
+ see whether or not we need to reset the tty state. The old code
+ checked the first process in a pipeline; the new code checks all
+ processes in the pipeline to see whether any of them exited due
+ to a signal or was stopped. If none were signalled or stopped,
+ the code uses the exit status of the last process in the job's
+ pipeline
+
+ 2/4
+ ---
+[bash-2.04-beta5 released]
+
+eval.c
+ - call set_current_prompt_level instead of setting prompt_string_pointer
+ directly
+
+ 2/10
+ ----
+[bash-2.04-beta5 re-released to net]
+
+ 2/11
+ ----
+sig.c
+ - make sure SIGCHLD is defined in initialize_shell_signals before
+ trying to use it in sigdelset() (DJGPP fix)
+
+ 2/14
+ ----
+lib/sh/shtty.c
+ - include <unistd.h> before <shtty.h>
+ - separate tests for ONLCR, ONOCR, ONLRET to cope with systems like
+ DJGPP that don't implement the full POSIX termios option set
+
+builtins/psize.sh
+ - set TMPDIR only if it's not already set
+
+lib/glob/glob.c
+ - if a system doesn't define _POSIX_SOURCE but has a `struct dirent'
+ without a d_ino member, define REAL_DIR_ENTRY to 1 so all entries
+ are read
+
+configure.in
+ - check for <arpa/inet.h> header file
+
+config.h.in
+ - add HAVE_ARPA_INET_H define
+
+lib/sh/inet_aton.c
+ - don't compile unless HAVE_NETWORK, HAVE_NETINET_IN_H, and
+ HAVE_ARPA_INET_H are all defined in config.h or config-bot.h
+
+ 2/16
+ ----
+subst.c
+ - if we have a construct like "${@:-}", we need to note that we're
+ not using whatever is in $@ (we're using the rhs), so the special
+ double-quoting $@ rules do not apply
+
+ 2/21
+ ----
+lib/readline/signals.c
+ - declare SigHandler before using it on non-POSIX systems
+
+lib/sh/{zread,zwrite}.c
+ - include <sys/types.h> unconditionally
+
+configure.in
+ - m68k-motorola-sysv should be m68k-sysv in the section that sets
+ opt_bash_malloc to no for certain systems
+
+builtins/complete.def
+ - fixed a typo (stoppped) when printing out completion actions
+
+ 2/22
+ ----
+lib/sh/netopen.c
+ - include <arpa/inet.h> if it's present
+
+aclocal.m4
+ - new macro, BASH_FUNC_INET_ATON, checks for inet_aton(3) including
+ <netinet/in.h> and <arpa/inet.h>, which some systems require to
+ resolve the function
+
+configure.in
+ - if autoconf can't fund inet_aton on its own, try BASH_FUNC_INET_ATON
+
+pcomplete.c
+ - fixed a memory leak in gen_wordlist_completions
+ - changed gen_wordlist_completions to do prefix-matching against the
+ word being completed
+
+doc/bash.1, lib/readline/doc/rluser.texinfo
+ - documented the change in behavior of the -W option to complete and
+ compgen
+
+builtins/umask.def
+ - if parse_symbolic_mode() returns -1, symbolic_umask needs to return
+ -1 as well, otherwise the umask will be changed inappropriately
+
+input.c
+ - always compile in getc_with_restart and ungetc_with_restart
+
+parse.y
+ - yy_stream_get and yy_stream_unget now call getc_with_restart and
+ ungetc_with_restart, respectively, to avoid problems with some
+ systems not restarting the read(2) when signals that bash handles
+ are received during the read (since bash installs its signal
+ handlers without the SA_RESTART flag)
+
+lib/readline/complete.c
+ - don't default rl_completion_case_fold to 1 if __DJGPP__ is defined
+
+ 2/25
+ ----
+subst.c
+ - renamed `varlist' to `subst_assign_varlist' and made it global
+
+jobs.c
+ - when running a SIGCHLD trap, need to unwind-protect
+ subst_assign_varlist and set it to NULL before running the trap
+ command (fix from ericw@bestnet.org and doogie@debian.org)
+
+ 2/28
+ ----
+lib/readline/doc/rltech.texinfo
+ - document rl_funmap_names()
+
+ 2/29
+ ----
+subst.c
+ - change split_at_delims to set the current word more appropriately
+ when the cursor is between two words. Should probably change this
+ again to set the current word like this only when the cursor is at
+ whitespace or another delim just before the word start
+
+ 3/1
+ ---
+lib/sh/shtty.c
+ - more checks for flag bits being defined before using them
+
+ 3/7
+ ---
+variables.h
+ - fix typo in COPY_EXPORTSTR definition
+
+ 3/14
+ ----
+subst.c
+ - changed split_at_delims so that if the cursor is at whitespace
+ between words, and we're interested in the current word (cwp != NULL),
+ make a new empty word and set the cwp to that word
+
+locale.c
+ - support for setting LC_NUMERIC locale category based on value of
+ LC_NUMERIC shell variable
+
+variables.c
+ - LC_NUMERIC is now treated specially
+
+doc/{bash.1,bashref.texi}
+ - LC_NUMERIC updates
+
+ 3/15
+ ----
+pcomplete.c
+ - fix to avoid freeing memory twice
diff --git a/INSTALL b/INSTALL
index 1211e359..74d284b7 100644
--- a/INSTALL
+++ b/INSTALL
@@ -3,18 +3,44 @@ 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' and `doc' directories, and the each
-directory under `lib'). 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.
+(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
@@ -34,25 +60,6 @@ contain the patch level of the Bash distribution, `0' for example. The
script `support/mkconffiles' has been provided to automate the creation
of these files.
-The simplest way to compile Bash is:
-
- 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 awhile. While running, it prints some
- 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.
-
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
@@ -116,7 +123,7 @@ than `/usr/local' by giving `configure' the option `--prefix=PATH'.
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.
+use PATH as the prefix for installing programs and libraries.
Documentation and other data files will still use the regular prefix.
Specifying the System Type
@@ -171,14 +178,14 @@ Operation Controls
script, and exit.
`configure' also accepts some other, not widely used, boilerplate
-options.
+options. `configure --help' prints the complete list.
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 `gnu-malloc'
+`--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'.
@@ -189,6 +196,15 @@ 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 `lib/malloc/malloc.c'. This
+ is not the same `malloc' that appears in GNU libc, but an older
+ version derived from the 4.2 BSD `malloc'. This `malloc' is very
+ fast, but wastes 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
@@ -200,25 +216,19 @@ the Bash `configure' recognizes.
2, but a modified version of the `malloc' from glibc version 1.
This is somewhat slower than the default `malloc', but wastes less
space on a per-allocation basis, and will return memory to the
- operating system under some circumstances.
+ operating system under certain circumstances.
`--with-gnu-malloc'
- Use the GNU version of `malloc' in `lib/malloc/malloc.c'. This is
- not the same `malloc' that appears in GNU libc, but an older
- version derived from the 4.2 BSD `malloc'. This `malloc' is very
- fast, but wastes 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.
+ A synonym for `--with-bash-malloc'.
`--with-installed-readline'
- Define this to make bash link with a locally-installed version of
- Readline rather than the version in lib/readline. This works only
- with readline 4.0 and later versions.
+ Define this to make Bash link with a locally-installed version of
+ Readline rather than the version in `lib/readline'. This works
+ only with Readline 4.1 and later versions.
`--with-purify'
- Define this to use the Purify memory allocation checker from Pure
- Software.
+ 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
@@ -240,13 +250,18 @@ options, but it is processed first, so individual options may be
enabled using `enable-FEATURE'.
All of the following options except for `disabled-builtins' and
-`usg-echo-default' are enabled by default, unless the operating system
+`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::.).
@@ -261,9 +276,9 @@ does not provide the necessary support.
`--enable-command-timing'
Include support for recognizing `time' as a reserved word and for
- displaying timing statistics for the pipeline following `time'.
- This allows pipelines as well as shell builtins and functions to
- be timed.
+ 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
@@ -289,16 +304,21 @@ does not provide the necessary support.
`--enable-help-builtin'
Include the `help' builtin, which displays help on shell builtins
- and variables.
+ and variables (*note Bash Builtins::.).
`--enable-history'
Include command history and the `fc' and `history' builtin
- commands.
+ commands (*note Bash History Facilities::.).
`--enable-job-control'
This enables the job control features (*note Job Control::.), if
the operating system supports them.
+`--enable-net-redirections'
+ This enables the special handling of filenames of the form
+ `/dev/tcp/HOST/PORT' and `/dev/udp/HOST/PORT' when used in
+ redirections (*note Redirections::.).
+
`--enable-process-substitution'
This enables process substitution (*note Process Substitution::.)
if the operating system provides the necessary support.
@@ -309,6 +329,11 @@ does not provide the necessary support.
strings. See *Note Printing a Prompt::, for a complete list of
prompt string escape sequences.
+`--enable-progcomp'
+ Enable the programmable completion facilities (*note Programmable
+ Completion::.). If Readline is not enabled, this option has no
+ effect.
+
`--enable-readline'
Include support for command-line editing and history with the Bash
version of the Readline library (*note Command Line Editing::.).
@@ -323,11 +348,17 @@ does not provide the necessary support.
menus (*note Conditional Constructs::.).
`--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 makes the Bash
- `echo' behave more like the System V version.
+ 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 2. *Note Bash Builtins::, for a
+ description of the escape sequences that `echo' recognizes.
-The file `config.h.top' contains C Preprocessor `#define' statements
+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
diff --git a/MANIFEST b/MANIFEST
index c1521194..18dd03ae 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -11,18 +11,21 @@ cross-build d
doc d
examples d
examples/bashdb 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/malloc d
-lib/posixheaders d
lib/readline d
lib/readline/doc d
lib/readline/examples d
@@ -90,6 +93,8 @@ bracecomp.c f
nojobs.c f
error.c f
xmalloc.c f
+pcomplete.c f
+pcomplib.c f
alias.h f
builtins.h f
bashhist.h f
@@ -97,8 +102,6 @@ bashline.h f
variables.h f
array.h f
jobs.h f
-maxpath.h f
-filecntl.h f
findcmd.h f
hashlib.h f
quit.h f
@@ -106,6 +109,7 @@ flags.h f
shell.h f
pathexp.h f
parser.h f
+pcomplete.h f
sig.h f
test.h f
trap.h f
@@ -120,7 +124,6 @@ subst.h f
dispose_cmd.h f
hashcmd.h f
bashansi.h f
-bashtty.h f
bashjmp.h f
bashintl.h f
make_cmd.h f
@@ -131,14 +134,6 @@ mailcheck.h f
pathnames.h f
y.tab.c f
y.tab.h f
-posixdir.h f
-posixjmp.h f
-posixstat.h f
-posixwait.h f
-unionwait.h f
-stdc.h f
-ansi_stdlib.h f
-memalloc.h f
parser-built f
builtins/ChangeLog f
builtins/Makefile.in f
@@ -149,6 +144,7 @@ builtins/builtin.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
@@ -199,6 +195,19 @@ cross-build/win32sig.h f
cross-build/x86-beos.cache f
cross-build/beos-sig.h f
cross-build/opennt.cache f
+include/ansi_stdlib.h f
+include/filecntl.h f
+include/maxpath.h f
+include/memalloc.h f
+include/posixdir.h f
+include/posixjmp.h f
+include/posixstat.h f
+include/posixtime.h f
+include/posixwait.h f
+include/shtty.h f
+include/stdc.h f
+include/systimes.h f
+include/unionwait.h f
lib/glob/ChangeLog f
lib/glob/Makefile.in f
lib/glob/fnmatch.c f
@@ -220,13 +229,6 @@ lib/malloc/omalloc.c f
lib/malloc/stub.c f
lib/malloc/i386-alloca.s f
lib/malloc/x386-alloca.s f
-lib/posixheaders/posixdir.h f
-lib/posixheaders/posixjmp.h f
-lib/posixheaders/posixstat.h f
-lib/posixheaders/ansi_stdlib.h f
-lib/posixheaders/stdc.h f
-lib/posixheaders/memalloc.h f
-lib/posixheaders/filecntl.h f
lib/readline/COPYING f
lib/readline/Makefile.in f
lib/readline/ChangeLog f
@@ -265,6 +267,7 @@ lib/readline/tilde.c f
lib/readline/tilde.h f
lib/readline/rldefs.h f
lib/readline/rlconf.h f
+lib/readline/rlshell.h f
lib/readline/rltty.h f
lib/readline/rlwinsize.h f
lib/readline/readline.h f
@@ -278,15 +281,19 @@ lib/readline/posixjmp.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/xmalloc.h f
lib/readline/doc/Makefile f
lib/readline/doc/manvers.texinfo f
lib/readline/doc/rlman.texinfo f
lib/readline/doc/rltech.texinfo f
lib/readline/doc/rluser.texinfo f
+lib/readline/doc/rluserman.texinfo f
lib/readline/doc/hist.texinfo f
lib/readline/doc/hstech.texinfo f
lib/readline/doc/hsuser.texinfo 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
@@ -295,19 +302,31 @@ lib/readline/examples/rl.c f
lib/readline/examples/Inputrc f
lib/sh/Makefile.in f
lib/sh/clktck.c f
+lib/sh/clock.c f
lib/sh/getcwd.c f
lib/sh/getenv.c f
+lib/sh/inet_aton.c f
lib/sh/itos.c f
+lib/sh/makepath.c f
+lib/sh/netopen.c f
lib/sh/oslib.c f
lib/sh/rename.c f
lib/sh/setlinebuf.c f
+lib/sh/shquote.c f
+lib/sh/shtty.c f
lib/sh/strcasecmp.c f
lib/sh/strerror.c f
+lib/sh/strpbrk.c f
lib/sh/strtod.c f
lib/sh/strtol.c f
lib/sh/strtoul.c f
+lib/sh/times.c f
+lib/sh/timeval.c f
lib/sh/vprint.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
@@ -353,13 +372,14 @@ 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/readline.3 f
doc/texinfo.tex f
doc/bashref.texi f
doc/bashref.info f
-doc/builtins.1 f
doc/article.ms f
doc/htmlpost.sh f 755
support/Makefile.in f
@@ -391,6 +411,7 @@ examples/bashdb/README f
examples/bashdb/bashdb f
examples/bashdb/bashdb.fns f
examples/bashdb/bashdb.pre f
+examples/complete/complete-examples f
examples/loadables/README f
examples/loadables/template.c f
examples/loadables/Makefile.in f
@@ -419,6 +440,11 @@ examples/loadables/sync.c f
examples/loadables/mkdir.c f
examples/loadables/ln.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/functions/array-stuff f
examples/functions/autoload f
examples/functions/autoload.v2 f
examples/functions/autoload.v3 f
@@ -440,6 +466,7 @@ examples/functions/isnum2 f
examples/functions/jdate.bash f
examples/functions/jj.bash f
examples/functions/keep f
+examples/functions/ksh-compat-test f
examples/functions/kshenv f
examples/functions/login f
examples/functions/lowercase f
@@ -460,12 +487,15 @@ 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/bcsh.sh f
+examples/scripts/center 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
@@ -477,6 +507,9 @@ examples/scripts/spin.bash f
examples/scripts/timeout 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
@@ -484,11 +517,20 @@ 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/arith-for.tests f
+tests/arith-for.right f
tests/arith.tests f
tests/arith.right f
tests/array.tests f
@@ -499,7 +541,8 @@ tests/braces-tests f
tests/braces.right f
tests/builtins.tests f
tests/builtins.right f
-tests/builtins.sub1 f
+tests/builtins1.sub f
+tests/builtins2.sub f
tests/source1.sub f
tests/source2.sub f
tests/source3.sub f
@@ -528,8 +571,11 @@ tests/exp-tests f
tests/exp.right f
tests/extglob.tests f
tests/extglob.right f
+tests/extglob2.tests f
+tests/extglob2.right f
tests/func.tests f
tests/func.right f
+tests/func1.sub f
tests/getopts.tests f
tests/getopts.right f
tests/getopts1.sub f
@@ -558,15 +604,19 @@ tests/ifs-3.right f
tests/input-line.sh f
tests/input-line.sub f
tests/input.right 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/jobs.right f
tests/more-exp.tests f
tests/more-exp.right f
tests/new-exp.tests f
tests/new-exp1.sub f
tests/new-exp2.sub f
+tests/new-exp3.sub f
tests/new-exp.right f
tests/nquote.tests f
tests/nquote.right f
@@ -582,6 +632,9 @@ tests/quote.tests f
tests/quote.right f
tests/read.tests f
tests/read.right f
+tests/read1.sub f
+tests/read2.sub f
+tests/read3.sub f
tests/redir.tests f
tests/redir.right f
tests/redir1.sub f
@@ -597,6 +650,7 @@ tests/rsh.tests f
tests/rsh.right f
tests/run-all f
tests/run-minimal f
+tests/run-arith-for f
tests/run-arith f
tests/run-array f
tests/run-array2 f
@@ -610,6 +664,7 @@ tests/run-errors f
tests/run-execscript f
tests/run-exp-tests f
tests/run-extglob f
+tests/run-extglob2 f
tests/run-func f
tests/run-getopts f
tests/run-glob-test f
@@ -618,6 +673,7 @@ tests/run-histexpand f
tests/run-history f
tests/run-ifs-tests f
tests/run-input-test f
+tests/run-invert f
tests/run-jobs f
tests/run-more-exp f
tests/run-new-exp f
@@ -645,7 +701,7 @@ tests/shopt.tests f
tests/shopt.right f
tests/strip.tests f
tests/strip.right f
-tests/test-tests f
+tests/test.tests f
tests/test.right f
tests/tilde-tests f
tests/tilde.right f
@@ -658,8 +714,10 @@ tests/varenv.right f
tests/varenv.sh f
tests/version f
tests/version.mini f
-tests/misc/perftest 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
@@ -668,6 +726,7 @@ 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
diff --git a/Makefile.in b/Makefile.in
index 8f288bbe..16eb3728 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -1,5 +1,21 @@
-# Makefile for bash-2.03, version 2.103
+# Makefile for bash-2.04, version 2.115
#
+# Copyright (C) 1996 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
+
# Make sure the first target in the makefile is the right one
all: .made
@@ -20,6 +36,8 @@ man1dir = $(mandir)/$(manpfx)$(man1ext)
man3ext = 3
man3dir = $(mandir)/$(manpfx)$(man3ext)
+htmldir = @htmldir@
+
topdir = @top_srcdir@
BUILD_DIR = @BUILD_DIR@
srcdir = @srcdir@
@@ -40,9 +58,7 @@ INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
INSTALLMODE= -m 0755
-
-COMPRESS = gzip
-COMPRESS_EXT = .gz
+INSTALLMODE2 = -m 0555
TESTSCRIPT = @TESTSCRIPT@
@@ -58,7 +74,8 @@ PURIFY = @PURIFY@
$(CC) $(CCFLAGS) -c $<
# The name of this program and some version information.
-Program = bash
+EXEEXT = @EXEEXT@
+Program = bash$(EXEEXT)
Version = @BASHVERS@
PatchLevel = @BASHPATCH@
RELSTATUS = release
@@ -93,7 +110,7 @@ SYSTEM_FLAGS = -DPROGRAM='"$(Program)"' -DCONF_HOSTTYPE='"$(Machine)"' -DCONF_OS
CCFLAGS = $(PROFILE_FLAGS) $(SYSTEM_FLAGS) $(LOCAL_DEFS) \
$(DEFS) $(LOCAL_CFLAGS) $(CPPFLAGS) $(INCLUDES) $(CFLAGS)
-INCLUDES = -I. @RL_INCLUDE@ -I$(srcdir) -I$(LIBSRC) -I$(includedir)
+INCLUDES = -I. @RL_INCLUDE@ -I$(srcdir) -I$(BASHINCDIR) -I$(LIBSRC) -I$(includedir)
GCC_LINT_FLAGS = -ansi -Wall -Wshadow -Wpointer-arith -Wcast-qual \
-Wwrite-strings -Werror -Wstrict-prototypes \
@@ -124,7 +141,12 @@ SHLIB_SOURCE = ${SH_LIBSRC}/clktck.c ${SH_LIBSRC}/getcwd.c \
${SH_LIBSRC}/strcasecmp.c ${SH_LIBSRC}/strerror.c \
${SH_LIBSRC}/strtod.c ${SH_LIBSRC}/strtol.c \
${SH_LIBSRC}/strtoul.c ${SH_LIBSRC}/vprint.c \
- ${SH_LIBSRC}/itos.c ${SH_LIBSRC}/rename.c
+ ${SH_LIBSRC}/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
SHLIB_LIB = -lsh
SHLIB_LIBNAME = libsh.a
@@ -149,7 +171,8 @@ READLINE_SOURCE = $(RL_LIBSRC)/rldefs.h $(RL_LIBSRC)/rlconf.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)/rlstdc.h ${RL_LIBSRC}/xmalloc.h \
+ $(RL_LIBSRC)/rlshell.h ${RL_LIBSRC}/rlprivate.h \
$(RL_LIBSRC)/funmap.c $(RL_LIBSRC)/emacs_keymap.c \
$(RL_LIBSRC)/search.c $(RL_LIBSRC)/vi_keymap.c \
$(RL_LIBSRC)/keymaps.c $(RL_LIBSRC)/parens.c \
@@ -263,9 +286,14 @@ $(MALLOC_LIBRARY): ${MALLOC_SOURCE}
$(MAKE) $(MFLAGS) \
MALLOC_CFLAGS="$(MALLOC_CFLAGS)" ${MALLOC_TARGET} ) || exit 1
-BASHPOSIX_LIB = $(LIBSRC)/posixheaders
-BASHPOSIX_SUPPORT = $(BASHPOSIX_LIB)/posixstat.h $(BASHPOSIX_LIB)/ansi_stdlib.h \
- $(BASHPOSIX_LIB)/memalloc.h $(BASHPOSIX_LIB)/stdc.h
+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
LIBRARIES = $(READLINE_LIB) $(HISTORY_LIB) $(TERMCAP_LIB) $(GLOB_LIB) \
$(TILDE_LIB) $(MALLOC_LIB) $(SHLIB_LIB) $(LOCAL_LIBS)
@@ -287,16 +315,17 @@ CSOURCES = shell.c eval.c parse.y general.c make_cmd.c print_cmd.c y.tab.c \
test.c trap.c alias.c jobs.c nojobs.c $(ALLOC_FILES) braces.c \
input.c bashhist.c array.c sig.c pathexp.c \
unwind_prot.c siglist.c bashline.c bracecomp.c error.c \
- list.c stringlib.c locale.c findcmd.c redir.c xmalloc.c
+ list.c stringlib.c locale.c findcmd.c redir.c \
+ pcomplete.c pcomplib.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 maxpath.h \
- quit.h posixdir.h posixstat.h filecntl.h unwind_prot.h ansi_stdlib.h \
+ general.h variables.h config.h $(ALLOC_HEADERS) alias.h \
+ quit.h unwind_prot.h \
command.h input.h error.h bashansi.h dispose_cmd.h make_cmd.h \
subst.h externs.h siglist.h bashhist.h bashline.h bashtypes.h \
- array.h sig.h mailcheck.h bashtty.h bashintl.h bashjmp.h ${GRAM_H} \
- posixwait.h execute_cmd.h memalloc.h parser.h pathexp.h pathnames.h \
- posixjmp.h stdc.h unionwait.h $(BASHPOSIX_SUPPORT)
+ array.h sig.h mailcheck.h bashintl.h bashjmp.h ${GRAM_H} \
+ execute_cmd.h parser.h pathexp.h pathnames.h pcomplete.h \
+ $(BASHINCFILES)
SOURCES = $(CSOURCES) $(HSOURCES) $(BUILTIN_DEFS)
@@ -312,7 +341,8 @@ OBJECTS = shell.o eval.o y.tab.o general.o make_cmd.o print_cmd.o $(GLOBO) \
expr.o flags.o $(JOBS_O) subst.o hashcmd.o hashlib.o mailcheck.o \
trap.o input.o unwind_prot.o pathexp.o sig.o test.o version.o \
alias.o array.o braces.o bracecomp.o bashhist.o bashline.o \
- siglist.o list.o stringlib.o locale.o findcmd.o redir.o xmalloc.o
+ siglist.o list.o stringlib.o locale.o findcmd.o redir.o \
+ pcomplete.o pcomplib.o xmalloc.o
# Where the source code of the shell builtins resides.
BUILTIN_SRCDIR=$(srcdir)/builtins
@@ -322,7 +352,8 @@ DEFDIR = $(dot)/builtins
BUILTIN_DEFS = $(DEFSRC)/alias.def $(DEFSRC)/bind.def $(DEFSRC)/break.def \
$(DEFSRC)/builtin.def $(DEFSRC)/cd.def $(DEFSRC)/colon.def \
- $(DEFSRC)/command.def $(DEFSRC)/declare.def \
+ $(DEFSRC)/command.def ${DEFSRC}/complete.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 \
@@ -370,16 +401,17 @@ SIGNAMES_SUPPORT = $(SUPPORT_SRC)mksignames.c
SUPPORT_SRC = $(srcdir)/support/
SDIR = $(dot)/support/
-TESTS_SUPPORT = recho zecho printenv
-CREATED_SUPPORT = signames.h recho zecho printenv tests/recho tests/zecho \
- tests/printenv mksignames lsignames.h
+TESTS_SUPPORT = recho$(EXEEXT) zecho$(EXEEXT) printenv$(EXEEXT)
+CREATED_SUPPORT = signames.h recho$(EXEEXT) zecho$(EXEEXT) printenv$(EXEEXT) \
+ tests/recho$(EXEEXT) tests/zecho$(EXEEXT) \
+ tests/printenv$(EXEEXT) mksignames$(EXEEXT) lsignames.h
CREATED_CONFIGURE = config.h config.cache config.status config.log \
stamp-h
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 \
- support/Makefile
+ examples/loadables/perl/Makefile support/Makefile
# Keep GNU Make from exporting the entire environment for small machines.
.NOEXPORT:
@@ -421,7 +453,7 @@ version.h: $(SOURCES) config.h Makefile
# old rules
GRAM_H = parser-built
-y.tab.o: y.tab.c ${GRAM_H} command.h stdc.h input.h
+y.tab.o: y.tab.c ${GRAM_H} command.h ${BASHINCDIR}/stdc.h input.h
${GRAM_H}: y.tab.h
@-if test -f y.tab.h ; then \
cmp -s $@ y.tab.h 2>/dev/null || cp -p y.tab.h $@; \
@@ -433,7 +465,7 @@ y.tab.c y.tab.h: parse.y
# experimental new rules - work with GNU make but not BSD (or OSF) make
#y.tab.o: y.tab.c y.tab.h
-#y.tab.c y.tab.h: parse.y command.h stdc.h input.h
+#y.tab.c y.tab.h: parse.y command.h ${BASHINCDIR}/stdc.h input.h
# -if test -f y.tab.h; then mv -f y.tab.h old-y.tab.h; fi
# $(YACC) -d $(srcdir)/parse.y
# -if cmp -s old-y.tab.h y.tab.h; then mv old-y.tab.h y.tab.h; fi
@@ -468,12 +500,12 @@ $(SHLIB_LIBRARY): config.h ${SHLIB_SOURCE}
@(cd ${SH_LIBDIR} && \
$(MAKE) $(MFLAGS) ${SHLIB_LIBNAME}) || exit 1
-mksignames: $(SUPPORT_SRC)mksignames.c
+mksignames$(EXEEXT): $(SUPPORT_SRC)mksignames.c
$(CC_FOR_BUILD) $(CCFLAGS) $(CPPFLAGS) -o $@ $(SUPPORT_SRC)mksignames.c
# make a list of signals for the local system -- this is done when we're
# *not* cross-compiling
-lsignames.h: mksignames
+lsignames.h: mksignames$(EXEEXT)
$(RM) $@
./mksignames $@
@@ -481,7 +513,7 @@ lsignames.h: mksignames
signames.h: $(SIGNAMES_H)
-if cmp -s $(SIGNAMES_H) $@ ; then :; else $(RM) $@ ; $(CP) $(SIGNAMES_H) $@ ; fi
-$(BUILTINS_LIBRARY): $(BUILTIN_DEFS) $(BUILTIN_C_SRC) config.h memalloc.h
+$(BUILTINS_LIBRARY): $(BUILTIN_DEFS) $(BUILTIN_C_SRC) config.h ${BASHINCDIR}/memalloc.h
@(cd $(DEFDIR) && $(MAKE) $(MFLAGS) libbuiltins.a ) || exit 1
# these require special rules to circumvent make builtin rules
@@ -550,11 +582,11 @@ installdirs:
install: .made installdirs
$(INSTALL_PROGRAM) $(INSTALLMODE) $(Program) $(bindir)/$(Program)
- $(INSTALL_PROGRAM) $(INSTALLMODE) bashbug $(bindir)/bashbug
+ $(INSTALL_PROGRAM) $(INSTALLMODE2) bashbug $(bindir)/bashbug
-( cd $(DOCDIR) ; $(MAKE) $(MFLAGS) \
man1dir=$(man1dir) man1ext=$(man1ext) \
man3dir=$(man3dir) man3ext=$(man3ext) \
- infodir=$(infodir) $@ )
+ infodir=$(infodir) htmldir=$(htmldir) $@ )
install-strip:
$(MAKE) $(MFLAGS) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' \
@@ -624,13 +656,13 @@ maintainer-clean: basic-clean
$(RM) $(CREATED_CONFIGURE) $(CREATED_MAKEFILES)
$(RM) $(CREATED_SUPPORT) Makefile
-recho: $(SUPPORT_SRC)recho.c
+recho$(EXEEXT): $(SUPPORT_SRC)recho.c
@$(CC) $(CCFLAGS) -o $@ $(SUPPORT_SRC)recho.c
-zecho: $(SUPPORT_SRC)zecho.c
+zecho$(EXEEXT): $(SUPPORT_SRC)zecho.c
@$(CC) $(CCFLAGS) -o $@ $(SUPPORT_SRC)zecho.c
-printenv: $(SUPPORT_SRC)printenv.c
+printenv$(EXEEXT): $(SUPPORT_SRC)printenv.c
@$(CC) $(CCFLAGS) -o $@ $(SUPPORT_SRC)printenv.c
test tests check: force $(Program) $(TESTS_SUPPORT)
@@ -645,13 +677,13 @@ symlinks:
dist: force
@echo Bash distributions are created using $(srcdir)/support/mkdist.
@echo Here is a sample of the necessary commands:
- @echo $(Program) $(srcdir)/support/mkdist -m $(srcdir)/MANIFEST -s $(srcdir) -r ${Program} $(Version)
- @echo tar cf $(Program)-$(Version).tar ${Program}-$(Version)
- @echo gzip $(Program)-$(Version).tar
+ @echo $(Program) $(srcdir)/support/mkdist -m $(srcdir)/MANIFEST -s $(srcdir) -r ${Program} $(Version)-${RELSTATUS}
+ @echo tar cf $(Program)-$(Version)-${RELSTATUS}.tar ${Program}-$(Version)-${RELSTATUS}
+ @echo gzip $(Program)-$(Version)-${RELSTATUS}.tar
depend: depends
-sdepend: force
+depends: force
$(Program) $(SUPPORT_SRC)mkdep -c ${CC} -- ${CCFLAGS} ${CSOURCES}
############################ DEPENDENCIES ###############################
@@ -674,213 +706,230 @@ builtins/exit.o: config-top.h
builtins/kill.o: config-top.h
# shell basics
-copy_cmd.o: shell.h config.h bashjmp.h posixjmp.h command.h stdc.h error.h
+copy_cmd.o: shell.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
copy_cmd.o: general.h bashtypes.h variables.h array.h hashlib.h
-copy_cmd.o: quit.h maxpath.h unwind_prot.h dispose_cmd.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 ansi_stdlib.h
-dispose_cmd.o: shell.h config.h bashjmp.h posixjmp.h command.h stdc.h
+dispose_cmd.o: bashansi.h ${BASHINCDIR}/ansi_stdlib.h
+dispose_cmd.o: shell.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h
dispose_cmd.o: error.h general.h bashtypes.h variables.h array.h hashlib.h
-dispose_cmd.o: quit.h maxpath.h unwind_prot.h dispose_cmd.h
+dispose_cmd.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
dispose_cmd.o: make_cmd.h subst.h sig.h pathnames.h externs.h
-error.o: config.h bashtypes.h bashansi.h ansi_stdlib.h flags.h stdc.h error.h
+error.o: config.h bashtypes.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h flags.h ${BASHINCDIR}/stdc.h error.h
error.o: command.h general.h externs.h input.h bashhist.h
-eval.o: config.h bashansi.h ansi_stdlib.h trap.h flags.h ${DEFSRC}/common.h
-eval.o: shell.h config.h bashjmp.h posixjmp.h command.h stdc.h error.h
+eval.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h trap.h flags.h ${DEFSRC}/common.h
+eval.o: shell.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
eval.o: general.h bashtypes.h variables.h array.h hashlib.h
-eval.o: quit.h maxpath.h unwind_prot.h dispose_cmd.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 filecntl.h posixstat.h bashansi.h ansi_stdlib.h
-execute_cmd.o: shell.h config.h bashjmp.h posixjmp.h command.h stdc.h error.h
+execute_cmd.o: config.h bashtypes.h ${BASHINCDIR}/filecntl.h ${BASHINCDIR}/posixstat.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
+execute_cmd.o: shell.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
execute_cmd.o: general.h bashtypes.h variables.h array.h hashlib.h
-execute_cmd.o: quit.h maxpath.h unwind_prot.h dispose_cmd.h
+execute_cmd.o: 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: memalloc.h ${GRAM_H} flags.h builtins.h jobs.h quit.h siglist.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}/fnmatch.h
-expr.o: config.h bashansi.h ansi_stdlib.h
-expr.o: shell.h config.h bashjmp.h posixjmp.h command.h stdc.h error.h
+execute_cmd.o: ${BASHINCDIR}/posixtime.h
+expr.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
+expr.o: shell.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
expr.o: general.h bashtypes.h variables.h array.h hashlib.h
-expr.o: quit.h maxpath.h unwind_prot.h dispose_cmd.h
+expr.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
expr.o: make_cmd.h subst.h sig.h pathnames.h externs.h
-findcmd.o: config.h bashtypes.h filecntl.h posixstat.h bashansi.h
-findcmd.o: ansi_stdlib.h memalloc.h shell.h bashjmp.h posixjmp.h command.h
-findcmd.o: stdc.h error.h general.h variables.h quit.h maxpath.h unwind_prot.h
+findcmd.o: config.h bashtypes.h ${BASHINCDIR}/filecntl.h ${BASHINCDIR}/posixstat.h bashansi.h
+findcmd.o: ${BASHINCDIR}/ansi_stdlib.h ${BASHINCDIR}/memalloc.h shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h
+findcmd.o: ${BASHINCDIR}/stdc.h error.h general.h variables.h quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h
findcmd.o: dispose_cmd.h make_cmd.h subst.h sig.h pathnames.h externs.h
findcmd.o: flags.h hashlib.h pathexp.h hashcmd.h
flags.o: config.h flags.h
-flags.o: shell.h config.h bashjmp.h posixjmp.h command.h stdc.h error.h
+flags.o: shell.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
flags.o: general.h bashtypes.h variables.h array.h hashlib.h
-flags.o: quit.h maxpath.h unwind_prot.h dispose_cmd.h
+flags.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
flags.o: make_cmd.h subst.h sig.h pathnames.h externs.h
-general.o: config.h bashtypes.h posixstat.h filecntl.h bashansi.h ansi_stdlib.h
-general.o: shell.h config.h bashjmp.h posixjmp.h command.h stdc.h error.h
+general.o: config.h bashtypes.h ${BASHINCDIR}/posixstat.h ${BASHINCDIR}/filecntl.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
+general.o: shell.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
general.o: general.h bashtypes.h variables.h array.h hashlib.h
-general.o: quit.h maxpath.h unwind_prot.h dispose_cmd.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: maxpath.h
-hashcmd.o: config.h posixstat.h bashtypes.h bashansi.h ansi_stdlib.h
-hashcmd.o: shell.h config.h bashjmp.h posixjmp.h command.h stdc.h error.h
+general.o: ${BASHINCDIR}/maxpath.h ${BASHINCDIR}/posixtime.h
+hashcmd.o: config.h ${BASHINCDIR}/posixstat.h bashtypes.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
+hashcmd.o: shell.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
hashcmd.o: general.h bashtypes.h variables.h array.h hashcmd.h
-hashcmd.o: execute_cmd.h findcmd.h stdc.h
-hashlib.o: config.h bashansi.h ansi_stdlib.h
-hashlib.o: shell.h config.h bashjmp.h posixjmp.h command.h stdc.h error.h
+hashcmd.o: execute_cmd.h findcmd.h ${BASHINCDIR}/stdc.h
+hashlib.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
+hashlib.o: shell.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
hashlib.o: general.h bashtypes.h variables.h array.h hashlib.h
-hashlib.o: quit.h maxpath.h unwind_prot.h dispose_cmd.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 filecntl.h posixstat.h bashansi.h ansi_stdlib.h
-input.o: command.h stdc.h general.h input.h error.h externs.h
-list.o: shell.h config.h bashjmp.h posixjmp.h command.h stdc.h error.h
+input.o: config.h bashtypes.h ${BASHINCDIR}/filecntl.h ${BASHINCDIR}/posixstat.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
+input.o: command.h ${BASHINCDIR}/stdc.h general.h input.h error.h externs.h
+list.o: shell.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
list.o: general.h bashtypes.h variables.h array.h hashlib.h
-list.o: quit.h maxpath.h unwind_prot.h dispose_cmd.h
+list.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
list.o: make_cmd.h subst.h sig.h pathnames.h externs.h
-locale.o: config.h bashtypes.h bashintl.h bashansi.h ansi_stdlib.h
-locale.o: shell.h config.h bashjmp.h posixjmp.h command.h stdc.h error.h
+locale.o: config.h bashtypes.h bashintl.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
+locale.o: shell.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
locale.o: general.h bashtypes.h variables.h array.h hashlib.h
-locale.o: quit.h maxpath.h unwind_prot.h dispose_cmd.h
+locale.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
locale.o: make_cmd.h subst.h sig.h pathnames.h externs.h
-mailcheck.o: config.h bashtypes.h posixstat.h bashansi.h ansi_stdlib.h
-mailcheck.o: shell.h config.h bashjmp.h posixjmp.h command.h stdc.h error.h
+mailcheck.o: config.h bashtypes.h ${BASHINCDIR}/posixstat.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
+mailcheck.o: shell.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
mailcheck.o: general.h bashtypes.h variables.h array.h hashlib.h
-mailcheck.o: quit.h maxpath.h unwind_prot.h dispose_cmd.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 filecntl.h bashansi.h
-make_cmd.o: command.h stdc.h general.h error.h flags.h make_cmd.h
+make_cmd.o: config.h bashtypes.h ${BASHINCDIR}/filecntl.h bashansi.h
+make_cmd.o: command.h ${BASHINCDIR}/stdc.h general.h error.h flags.h make_cmd.h
make_cmd.o: variables.h array.h hashlib.h subst.h input.h externs.h
make_cmd.o: jobs.h quit.h siglist.h
-y.tab.o: config.h bashtypes.h bashansi.h ansi_stdlib.h memalloc.h
-y.tab.o: shell.h config.h bashjmp.h posixjmp.h command.h stdc.h error.h
+y.tab.o: config.h bashtypes.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h ${BASHINCDIR}/memalloc.h
+y.tab.o: shell.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
y.tab.o: general.h bashtypes.h variables.h array.h hashlib.h
-y.tab.o: quit.h maxpath.h unwind_prot.h dispose_cmd.h
+y.tab.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
y.tab.o: make_cmd.h subst.h sig.h pathnames.h externs.h
y.tab.o: trap.h flags.h parser.h input.h mailcheck.h $(DEFSRC)/common.h
y.tab.o: $(DEFDIR)/builtext.h bashline.h bashhist.h jobs.h siglist.h alias.h
-pathexp.o: config.h bashtypes.h bashansi.h ansi_stdlib.h
-pathexp.o: shell.h config.h bashjmp.h posixjmp.h command.h stdc.h error.h
+pathexp.o: config.h bashtypes.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
+pathexp.o: shell.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
pathexp.o: general.h bashtypes.h variables.h array.h hashlib.h
-pathexp.o: quit.h maxpath.h unwind_prot.h dispose_cmd.h
+pathexp.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
pathexp.o: make_cmd.h subst.h sig.h pathnames.h externs.h
pathexp.o: pathexp.h flags.h
pathexp.o: $(GLOB_LIBSRC)/glob.h $(GLOB_LIBSRC)/fnmatch.h
-print_cmd.o: config.h bashansi.h ansi_stdlib.h
-print_cmd.o: shell.h config.h bashjmp.h posixjmp.h command.h stdc.h error.h
+print_cmd.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
+print_cmd.o: shell.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
print_cmd.o: general.h bashtypes.h variables.h array.h hashlib.h
-print_cmd.o: quit.h maxpath.h unwind_prot.h dispose_cmd.h
+print_cmd.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
print_cmd.o: make_cmd.h subst.h sig.h pathnames.h externs.h
print_cmd.o: ${GRAM_H} $(DEFSRC)/common.h
-redir.o: config.h bashtypes.h posixstat.h bashansi.h ansi_stdlib.h filecntl.h
-redir.o: memalloc.h shell.h bashjmp.h posixjmp.h command.h stdc.h error.h
-redir.o: general.h variables.h array.h hashlib.h quit.h maxpath.h unwind_prot.h
+redir.o: config.h bashtypes.h ${BASHINCDIR}/posixstat.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h ${BASHINCDIR}/filecntl.h
+redir.o: ${BASHINCDIR}/memalloc.h shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
+redir.o: general.h variables.h array.h hashlib.h quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h
redir.o: dispose_cmd.h make_cmd.h subst.h sig.h pathnames.h externs.h
redir.o: flags.h execute_cmd.h redir.h input.h
-shell.o: config.h bashtypes.h posixstat.h bashansi.h ansi_stdlib.h filecntl.h
-shell.o: shell.h config.h bashjmp.h posixjmp.h command.h stdc.h error.h
+shell.o: config.h bashtypes.h ${BASHINCDIR}/posixstat.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h ${BASHINCDIR}/filecntl.h
+shell.o: shell.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
shell.o: general.h bashtypes.h variables.h array.h hashlib.h
-shell.o: quit.h maxpath.h unwind_prot.h dispose_cmd.h
+shell.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
shell.o: make_cmd.h subst.h sig.h pathnames.h externs.h
shell.o: flags.h trap.h mailcheck.h builtins.h $(DEFSRC)/common.h
shell.o: jobs.h siglist.h input.h execute_cmd.h findcmd.h bashhist.h
shell.o: ${GLOB_LIBSRC}/fnmatch.h
sig.o: config.h bashtypes.h
-sig.o: shell.h config.h bashjmp.h posixjmp.h command.h stdc.h error.h
+sig.o: shell.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
sig.o: general.h bashtypes.h variables.h array.h hashlib.h
-sig.o: quit.h maxpath.h unwind_prot.h dispose_cmd.h
+sig.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
sig.o: make_cmd.h subst.h sig.h pathnames.h externs.h
sig.o: jobs.h siglist.h trap.h $(DEFSRC)/common.h bashline.h bashhist.h
siglist.o: config.h bashtypes.h siglist.h trap.h
stringlib.o: bashtypes.h
-stringlib.o: shell.h config.h bashjmp.h posixjmp.h command.h stdc.h error.h
+stringlib.o: shell.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
stringlib.o: general.h bashtypes.h variables.h array.h hashlib.h
-stringlib.o: quit.h maxpath.h unwind_prot.h dispose_cmd.h
+stringlib.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
stringlib.o: make_cmd.h subst.h sig.h pathnames.h externs.h
-subst.o: config.h bashtypes.h bashansi.h ansi_stdlib.h posixstat.h
-subst.o: shell.h config.h bashjmp.h posixjmp.h command.h stdc.h error.h
+subst.o: config.h bashtypes.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h ${BASHINCDIR}/posixstat.h
+subst.o: shell.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
subst.o: general.h bashtypes.h variables.h array.h hashlib.h
-subst.o: quit.h maxpath.h unwind_prot.h dispose_cmd.h
+subst.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
subst.o: make_cmd.h subst.h sig.h pathnames.h externs.h
-subst.o: flags.h jobs.h siglist.h execute_cmd.h filecntl.h trap.h pathexp.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}/fnmatch.h
-test.o: bashtypes.h posixstat.h filecntl.h
-test.o: shell.h config.h bashjmp.h posixjmp.h command.h stdc.h error.h
+test.o: bashtypes.h ${BASHINCDIR}/posixstat.h ${BASHINCDIR}/filecntl.h
+test.o: shell.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
test.o: general.h bashtypes.h variables.h array.h hashlib.h
-test.o: quit.h maxpath.h unwind_prot.h dispose_cmd.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 ansi_stdlib.h
-trap.o: shell.h config.h bashjmp.h posixjmp.h command.h stdc.h error.h
+trap.o: config.h bashtypes.h trap.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
+trap.o: shell.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
trap.o: general.h bashtypes.h variables.h array.h hashlib.h
-trap.o: quit.h maxpath.h unwind_prot.h dispose_cmd.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
-unwind_prot.o: config.h bashtypes.h bashansi.h ansi_stdlib.h command.h stdc.h
+unwind_prot.o: config.h bashtypes.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h command.h ${BASHINCDIR}/stdc.h
unwind_prot.o: general.h unwind_prot.h quit.h sig.h
-variables.o: config.h bashtypes.h posixstat.h bashansi.h ansi_stdlib.h
-variables.o: shell.h config.h bashjmp.h posixjmp.h command.h stdc.h error.h
+variables.o: config.h bashtypes.h ${BASHINCDIR}/posixstat.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
+variables.o: shell.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
variables.o: general.h bashtypes.h variables.h array.h hashlib.h
-variables.o: quit.h maxpath.h unwind_prot.h dispose_cmd.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
+variables.o: pcomplete.h
version.o: version.h .build
-xmalloc.o: config.h bashtypes.h ansi_stdlib.h error.h
+xmalloc.o: config.h bashtypes.h ${BASHINCDIR}/ansi_stdlib.h error.h
# job control
-jobs.o: config.h bashtypes.h trap.h filecntl.h input.h bashtty.h
-jobs.o: bashansi.h ansi_stdlib.h
-jobs.o: shell.h config.h bashjmp.h posixjmp.h command.h stdc.h error.h
+jobs.o: config.h bashtypes.h trap.h ${BASHINCDIR}/filecntl.h input.h ${BASHINCDIR}/shtty.h
+jobs.o: bashansi.h ${BASHINCDIR}/ansi_stdlib.h
+jobs.o: shell.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
jobs.o: general.h bashtypes.h variables.h array.h hashlib.h
-jobs.o: quit.h maxpath.h unwind_prot.h dispose_cmd.h
+jobs.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
jobs.o: make_cmd.h subst.h sig.h pathnames.h externs.h
jobs.o: jobs.h flags.h $(DEFSRC)/common.h $(DEFDIR)/builtext.h
-nojobs.o: config.h bashtypes.h filecntl.h bashjmp.h posixjmp.h
-nojobs.o: command.h stdc.h general.h jobs.h quit.h siglist.h externs.h
-nojobs.o: sig.h error.h bashtty.h input.h
+jobs.o: ${BASHINCDIR}/posixwait.h ${BASHINCDIR}/unionwait.h
+nojobs.o: config.h bashtypes.h ${BASHINCDIR}/filecntl.h bashjmp.h ${BASHINCDIR}/posixjmp.h
+nojobs.o: command.h ${BASHINCDIR}/stdc.h general.h jobs.h quit.h siglist.h externs.h
+nojobs.o: sig.h error.h ${BASHINCDIR}/shtty.h input.h
# shell features that may be compiled in
-array.o: config.h bashansi.h ansi_stdlib.h
-array.o: shell.h config.h bashjmp.h posixjmp.h command.h stdc.h error.h
+array.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
+array.o: shell.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
array.o: general.h bashtypes.h variables.h array.h hashlib.h
-array.o: quit.h maxpath.h unwind_prot.h dispose_cmd.h
+array.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
array.o: make_cmd.h subst.h sig.h pathnames.h externs.h
array.o: $(DEFSRC)/common.h
-braces.o: config.h bashansi.h ansi_stdlib.h
-braces.o: shell.h config.h bashjmp.h posixjmp.h command.h stdc.h error.h
+braces.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
+braces.o: shell.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
braces.o: general.h bashtypes.h variables.h array.h hashlib.h
-braces.o: quit.h maxpath.h unwind_prot.h dispose_cmd.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
-alias.o: config.h bashansi.h ansi_stdlib.h command.h stdc.h
+alias.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h command.h ${BASHINCDIR}/stdc.h
alias.o: general.h bashtypes.h externs.h alias.h
+alias.o: pcomplete.h
+
+pcomplib.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h bashtypes.h
+pcomplib.o: ${BASHINCDIR}/stdc.h hashlib.h pcomplete.h shell.h
+pcomplib.o: bashjmp.h command.h general.h error.h variables.h quit.h
+pcomplib.o: unwind_prot.h dispose_cmd.h make_cmd.h subst.h sig.h pathnames.h
+pcomplib.o: externs.h ${BASHINCDIR}/maxpath.h
+
+pcomplete.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h bashtypes.h
+pcomplete.o: ${BASHINCDIR}/stdc.h hashlib.h pcomplete.h shell.h
+pcomplete.o: bashjmp.h command.h general.h error.h variables.h quit.h
+pcomplete.o: unwind_prot.h dispose_cmd.h make_cmd.h subst.h sig.h pathnames.h
+pcomplete.o: externs.h ${BASHINCDIR}/maxpath.h
# library support files
-bashhist.o: config.h bashtypes.h bashansi.h ansi_stdlib.h posixstat.h
-bashhist.o: filecntl.h
-bashhist.o: shell.h config.h bashjmp.h posixjmp.h command.h stdc.h error.h
+bashhist.o: config.h bashtypes.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h ${BASHINCDIR}/posixstat.h
+bashhist.o: ${BASHINCDIR}/filecntl.h
+bashhist.o: shell.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
bashhist.o: general.h bashtypes.h variables.h array.h hashlib.h
-bashhist.o: quit.h maxpath.h unwind_prot.h dispose_cmd.h
+bashhist.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
bashhist.o: make_cmd.h subst.h sig.h pathnames.h externs.h
bashhist.o: flags.h input.h parser.h pathexp.h $(DEFSRC)/common.h bashline.h
bashhist.o: $(GLOB_LIBSRC)/fnmatch.h
-bashline.o: config.h bashtypes.h posixstat.h bashansi.h ansi_stdlib.h
-bashline.o: shell.h config.h bashjmp.h posixjmp.h command.h stdc.h error.h
+bashline.o: config.h bashtypes.h ${BASHINCDIR}/posixstat.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
+bashline.o: shell.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
bashline.o: general.h bashtypes.h variables.h array.h hashlib.h
-bashline.o: quit.h maxpath.h unwind_prot.h dispose_cmd.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
-bracecomp.o: config.h bashansi.h ansi_stdlib.h
-bracecomp.o: shell.h config.h bashjmp.h posixjmp.h command.h stdc.h error.h
+bashline.o: pcomplete.h
+bracecomp.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
+bracecomp.o: shell.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h command.h ${BASHINCDIR}/stdc.h error.h
bracecomp.o: general.h bashtypes.h variables.h array.h hashlib.h
-bracecomp.o: quit.h maxpath.h unwind_prot.h dispose_cmd.h
+bracecomp.o: quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
bracecomp.o: make_cmd.h subst.h sig.h pathnames.h externs.h
-bracecomp.o: shell.h bashjmp.h posixjmp.h sig.h command.h hashlib.h builtins.h general.h
+bracecomp.o: shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h command.h hashlib.h builtins.h general.h
bracecomp.o: quit.h alias.h config.h variables.h
-bracecomp.o: dispose_cmd.h make_cmd.h subst.h externs.h stdc.h
+bracecomp.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
# library dependencies
@@ -910,183 +959,191 @@ variables.o: $(TILDE_LIBSRC)/tilde.h
# XXX - dependencies checked through here
# builtin c sources
-builtins/bashgetopt.o: config.h bashansi.h ansi_stdlib.h
+builtins/bashgetopt.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
builtins/bashgetopt.o: shell.h config.h bashjmp.h command.h general.h error.h
-builtins/bashgetopt.o: variables.h quit.h maxpath.h unwind_prot.h dispose_cmd.h
+builtins/bashgetopt.o: variables.h quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
builtins/bashgetopt.o: make_cmd.h subst.h sig.h pathnames.h externs.h
builtins/bashgetopt.o: $(DEFSRC)/common.h
-builtins/common.o: bashtypes.h posixstat.h bashansi.h ansi_stdlib.h
-builtins/common.o: shell.h config.h bashjmp.h posixjmp.h sig.h command.h
-builtins/common.o: memalloc.h variables.h input.h siglist.h
-builtins/common.o: quit.h unwind_prot.h maxpath.h jobs.h builtins.h
+builtins/common.o: bashtypes.h ${BASHINCDIR}/posixstat.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
+builtins/common.o: shell.h config.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h command.h
+builtins/common.o: ${BASHINCDIR}/memalloc.h variables.h input.h siglist.h
+builtins/common.o: quit.h unwind_prot.h ${BASHINCDIR}/maxpath.h jobs.h builtins.h
builtins/common.o: dispose_cmd.h make_cmd.h subst.h externs.h bashhist.h
-builtins/common.o: execute_cmd.h stdc.h general.h error.h pathnames.h
+builtins/common.o: execute_cmd.h ${BASHINCDIR}/stdc.h general.h error.h pathnames.h
builtins/common.o: ${DEFDIR}/builtext.h
-builtins/evalfile.o: bashtypes.h posixstat.h filecntl.h bashansi.h ansi_stdlib.h
+builtins/evalfile.o: bashtypes.h ${BASHINCDIR}/posixstat.h ${BASHINCDIR}/filecntl.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
builtins/evalfile.o: shell.h config.h bashjmp.h command.h general.h error.h
-builtins/evalfile.o: variables.h quit.h maxpath.h unwind_prot.h dispose_cmd.h
+builtins/evalfile.o: variables.h quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
builtins/evalfile.o: make_cmd.h subst.h sig.h pathnames.h externs.h
builtins/evalfile.o: jobs.h builtins.h flags.h input.h execute_cmd.h
builtins/evalfile.o: bashhist.h $(DEFSRC)/common.h
-builtins/evalstring.o: config.h bashansi.h ansi_stdlib.h
-builtins/evalstring.o: shell.h bashjmp.h posixjmp.h sig.h command.h siglist.h
-builtins/evalstring.o: memalloc.h variables.h input.h
-builtins/evalstring.o: quit.h unwind_prot.h maxpath.h jobs.h builtins.h
+builtins/evalstring.o: config.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
+builtins/evalstring.o: shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h command.h siglist.h
+builtins/evalstring.o: ${BASHINCDIR}/memalloc.h variables.h input.h
+builtins/evalstring.o: quit.h unwind_prot.h ${BASHINCDIR}/maxpath.h jobs.h builtins.h
builtins/evalstring.o: dispose_cmd.h make_cmd.h subst.h externs.h
builtins/evalstring.o: jobs.h builtins.h flags.h input.h execute_cmd.h
builtins/evalstring.o: bashhist.h $(DEFSRC)/common.h
-builtins/getopt.o: config.h memalloc.h
+builtins/getopt.o: config.h ${BASHINCDIR}/memalloc.h
builtins/getopt.o: shell.h bashjmp.h command.h general.h error.h
-builtins/getopt.o: variables.h quit.h maxpath.h unwind_prot.h dispose_cmd.h
+builtins/getopt.o: variables.h quit.h ${BASHINCDIR}/maxpath.h unwind_prot.h dispose_cmd.h
builtins/getopt.o: make_cmd.h subst.h sig.h pathnames.h externs.h
builtins/getopt.o: $(DEFSRC)/getopt.h
-builtins/mkbuiltins.o: config.h bashtypes.h posixstat.h filecntl.h
-builtins/mkbuiltins.o: bashansi.h ansi_stdlib.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 memalloc.h error.h general.h maxpath.h
+builtins/alias.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h ${BASHINCDIR}/maxpath.h
builtins/alias.o: quit.h $(DEFSRC)/common.h
-builtins/alias.o: shell.h bashjmp.h posixjmp.h sig.h command.h stdc.h unwind_prot.h
+builtins/alias.o: shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h command.h ${BASHINCDIR}/stdc.h unwind_prot.h
builtins/alias.o: dispose_cmd.h make_cmd.h subst.h externs.h variables.h
-builtins/bind.o: command.h config.h memalloc.h error.h general.h maxpath.h
-builtins/bind.o: dispose_cmd.h make_cmd.h subst.h externs.h stdc.h
-builtins/bind.o: shell.h bashjmp.h posixjmp.h sig.h unwind_prot.h variables.h quit.h
+builtins/bind.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h ${BASHINCDIR}/maxpath.h
+builtins/bind.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/bind.o: shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h quit.h
builtins/bind.o: $(DEFSRC)/bashgetopt.h
-builtins/break.o: command.h config.h memalloc.h error.h general.h maxpath.h
-builtins/break.o: shell.h bashjmp.h posixjmp.h sig.h unwind_prot.h variables.h quit.h
-builtins/break.o: dispose_cmd.h make_cmd.h subst.h externs.h stdc.h
-builtins/builtin.o: command.h config.h memalloc.h error.h general.h maxpath.h
+builtins/break.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h ${BASHINCDIR}/maxpath.h
+builtins/break.o: shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h quit.h
+builtins/break.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/builtin.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h ${BASHINCDIR}/maxpath.h
builtins/builtin.o: quit.h $(DEFSRC)/common.h
-builtins/builtin.o: shell.h bashjmp.h posixjmp.h sig.h unwind_prot.h variables.h
-builtins/builtin.o: dispose_cmd.h make_cmd.h subst.h externs.h stdc.h
-builtins/cd.o: command.h config.h memalloc.h error.h general.h maxpath.h
-builtins/cd.o: shell.h bashjmp.h posixjmp.h sig.h unwind_prot.h variables.h
-builtins/cd.o: dispose_cmd.h make_cmd.h subst.h externs.h stdc.h
+builtins/builtin.o: shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h
+builtins/builtin.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/cd.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h ${BASHINCDIR}/maxpath.h
+builtins/cd.o: shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h
+builtins/cd.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
builtins/cd.o: $(DEFSRC)/common.h quit.h
-builtins/command.o: command.h config.h memalloc.h error.h general.h maxpath.h
+builtins/command.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h ${BASHINCDIR}/maxpath.h
builtins/command.o: quit.h $(DEFSRC)/bashgetopt.h
-builtins/command.o: shell.h bashjmp.h posixjmp.h sig.h unwind_prot.h variables.h
-builtins/command.o: dispose_cmd.h make_cmd.h subst.h externs.h stdc.h
-builtins/declare.o: command.h config.h memalloc.h error.h general.h maxpath.h
-builtins/declare.o: shell.h bashjmp.h posixjmp.h sig.h unwind_prot.h variables.h quit.h
-builtins/declare.o: dispose_cmd.h make_cmd.h subst.h externs.h stdc.h
-builtins/echo.o: command.h config.h memalloc.h error.h general.h maxpath.h
-builtins/echo.o: shell.h bashjmp.h posixjmp.h sig.h unwind_prot.h variables.h quit.h
-builtins/echo.o: dispose_cmd.h make_cmd.h subst.h externs.h stdc.h
-builtins/enable.o: command.h config.h memalloc.h error.h general.h maxpath.h
-builtins/enable.o: shell.h bashjmp.h posixjmp.h sig.h unwind_prot.h variables.h quit.h
-builtins/enable.o: dispose_cmd.h make_cmd.h subst.h externs.h stdc.h
-builtins/eval.o: command.h config.h memalloc.h error.h general.h maxpath.h
-builtins/eval.o: shell.h bashjmp.h posixjmp.h sig.h unwind_prot.h variables.h quit.h
-builtins/eval.o: dispose_cmd.h make_cmd.h subst.h externs.h stdc.h
+builtins/command.o: shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h
+builtins/command.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/declare.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h ${BASHINCDIR}/maxpath.h
+builtins/declare.o: shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h quit.h
+builtins/declare.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/echo.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h ${BASHINCDIR}/maxpath.h
+builtins/echo.o: shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h quit.h
+builtins/echo.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/enable.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h ${BASHINCDIR}/maxpath.h
+builtins/enable.o: shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h quit.h
+builtins/enable.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/enable.o: pcomplete.h
+builtins/eval.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h ${BASHINCDIR}/maxpath.h
+builtins/eval.o: shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h quit.h
+builtins/eval.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
builtins/exec.o: bashtypes.h
-builtins/exec.o: command.h config.h memalloc.h error.h general.h maxpath.h
-builtins/exec.o: shell.h bashjmp.h posixjmp.h sig.h unwind_prot.h variables.h
+builtins/exec.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h ${BASHINCDIR}/maxpath.h
+builtins/exec.o: shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h
builtins/exec.o: 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 stdc.h
+builtins/exec.o: findcmd.h flags.h quit.h $(DEFSRC)/common.h ${BASHINCDIR}/stdc.h
builtins/exit.o: bashtypes.h
-builtins/exit.o: command.h config.h memalloc.h error.h general.h maxpath.h
-builtins/exit.o: shell.h bashjmp.h posixjmp.h sig.h unwind_prot.h variables.h quit.h
-builtins/exit.o: dispose_cmd.h make_cmd.h subst.h externs.h stdc.h
-builtins/fc.o: bashtypes.h posixstat.h
-builtins/fc.o: bashansi.h ansi_stdlib.h builtins.h command.h stdc.h
-builtins/fc.o: command.h config.h memalloc.h error.h general.h maxpath.h
-builtins/fc.o: flags.h unwind_prot.h variables.h shell.h bashjmp.h posixjmp.h sig.h
-builtins/fc.o: dispose_cmd.h make_cmd.h subst.h externs.h stdc.h quit.h
+builtins/exit.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h ${BASHINCDIR}/maxpath.h
+builtins/exit.o: shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h quit.h
+builtins/exit.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/fc.o: bashtypes.h ${BASHINCDIR}/posixstat.h
+builtins/fc.o: bashansi.h ${BASHINCDIR}/ansi_stdlib.h builtins.h command.h ${BASHINCDIR}/stdc.h
+builtins/fc.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h ${BASHINCDIR}/maxpath.h
+builtins/fc.o: flags.h unwind_prot.h variables.h shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h
+builtins/fc.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h quit.h
builtins/fc.o: $(DEFSRC)/bashgetopt.h bashhist.h
builtins/fg_bg.o: bashtypes.h
-builtins/fg_bg.o: command.h config.h memalloc.h error.h general.h maxpath.h
-builtins/fg_bg.o: shell.h bashjmp.h posixjmp.h sig.h unwind_prot.h variables.h quit.h
-builtins/fg_bg.o: dispose_cmd.h make_cmd.h subst.h externs.h stdc.h
-builtins/getopts.o: command.h config.h memalloc.h error.h general.h maxpath.h
-builtins/getopts.o: shell.h bashjmp.h posixjmp.h sig.h unwind_prot.h variables.h quit.h
-builtins/getopts.o: dispose_cmd.h make_cmd.h subst.h externs.h stdc.h
+builtins/fg_bg.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h ${BASHINCDIR}/maxpath.h
+builtins/fg_bg.o: shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h quit.h
+builtins/fg_bg.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/getopts.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h ${BASHINCDIR}/maxpath.h
+builtins/getopts.o: shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h quit.h
+builtins/getopts.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
builtins/hash.o: bashtypes.h
-builtins/hash.o: builtins.h command.h findcmd.h stdc.h $(DEFSRC)/common.h
-builtins/hash.o: command.h config.h memalloc.h error.h general.h maxpath.h
-builtins/hash.o: shell.h bashjmp.h posixjmp.h sig.h unwind_prot.h variables.h quit.h
-builtins/help.o: command.h config.h memalloc.h error.h general.h maxpath.h
-builtins/help.o: dispose_cmd.h make_cmd.h subst.h externs.h stdc.h
-builtins/help.o: shell.h bashjmp.h posixjmp.h sig.h unwind_prot.h variables.h quit.h
+builtins/hash.o: builtins.h command.h findcmd.h ${BASHINCDIR}/stdc.h $(DEFSRC)/common.h
+builtins/hash.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h ${BASHINCDIR}/maxpath.h
+builtins/hash.o: shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h quit.h
+builtins/help.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h ${BASHINCDIR}/maxpath.h
+builtins/help.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/help.o: shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h quit.h
builtins/help.o: $(GLOB_LIBSRC)/glob.h
builtins/history.o: bashtypes.h
-builtins/history.o: command.h config.h memalloc.h error.h general.h maxpath.h
-builtins/history.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h stdc.h
-builtins/history.o: filecntl.h shell.h bashjmp.h posixjmp.h sig.h unwind_prot.h
+builtins/history.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h ${BASHINCDIR}/maxpath.h
+builtins/history.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/history.o: ${BASHINCDIR}/filecntl.h shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h
builtins/history.o: bashhist.h variables.h
-builtins/inlib.o: command.h config.h memalloc.h error.h general.h maxpath.h
-builtins/inlib.o: shell.h bashjmp.h posixjmp.h sig.h unwind_prot.h variables.h quit.h
-builtins/inlib.o: dispose_cmd.h make_cmd.h subst.h externs.h stdc.h
-builtins/jobs.o: command.h config.h memalloc.h error.h general.h maxpath.h
+builtins/inlib.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h ${BASHINCDIR}/maxpath.h
+builtins/inlib.o: shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h quit.h
+builtins/inlib.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/jobs.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h ${BASHINCDIR}/maxpath.h
builtins/jobs.o: quit.h $(DEFSRC)/bashgetopt.h
-builtins/jobs.o: shell.h bashjmp.h posixjmp.h sig.h unwind_prot.h variables.h
-builtins/jobs.o: dispose_cmd.h make_cmd.h subst.h externs.h stdc.h
-builtins/kill.o: command.h config.h memalloc.h error.h general.h maxpath.h
-builtins/kill.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h stdc.h
-builtins/kill.o: shell.h bashjmp.h posixjmp.h sig.h trap.h unwind_prot.h variables.h
-builtins/let.o: command.h config.h memalloc.h error.h general.h maxpath.h
-builtins/let.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h stdc.h
-builtins/let.o: shell.h bashjmp.h posixjmp.h sig.h unwind_prot.h variables.h
-builtins/printf.o: config.h memalloc.h bashjmp.h command.h error.h
+builtins/jobs.o: shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h
+builtins/jobs.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/kill.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h ${BASHINCDIR}/maxpath.h
+builtins/kill.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/kill.o: shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h trap.h unwind_prot.h variables.h
+builtins/let.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h ${BASHINCDIR}/maxpath.h
+builtins/let.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/let.o: shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h
+builtins/printf.o: config.h ${BASHINCDIR}/memalloc.h bashjmp.h command.h error.h
builtins/printf.o: general.h quit.h dispose_cmd.h make_cmd.h subst.h
builtins/printf.o: externs.h sig.h pathnames.h shell.h unwind_prot.h
-builtins/printf.o: variables.h stdc.h $(DEFSRC)/bashgetopt.h
-builtins/pushd.o: command.h config.h memalloc.h error.h general.h maxpath.h
-builtins/pushd.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h stdc.h
-builtins/pushd.o: shell.h bashjmp.h posixjmp.h sig.h unwind_prot.h variables.h
+builtins/printf.o: variables.h ${BASHINCDIR}/stdc.h $(DEFSRC)/bashgetopt.h
+builtins/pushd.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h ${BASHINCDIR}/maxpath.h
+builtins/pushd.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/pushd.o: shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h
builtins/pushd.o: $(DEFSRC)/common.h
-builtins/read.o: command.h config.h memalloc.h error.h general.h maxpath.h
-builtins/read.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h stdc.h
-builtins/read.o: shell.h bashjmp.h posixjmp.h sig.h unwind_prot.h variables.h
-builtins/return.o: command.h config.h memalloc.h error.h general.h maxpath.h
-builtins/return.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h stdc.h
-builtins/return.o: shell.h bashjmp.h posixjmp.h sig.h unwind_prot.h variables.h
-builtins/set.o: command.h config.h memalloc.h error.h general.h maxpath.h
-builtins/set.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h stdc.h
-builtins/set.o: shell.h bashjmp.h posixjmp.h sig.h unwind_prot.h variables.h flags.h
-builtins/setattr.o: command.h config.h memalloc.h error.h general.h maxpath.h
+builtins/read.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h ${BASHINCDIR}/maxpath.h
+builtins/read.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/read.o: shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h
+builtins/return.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h ${BASHINCDIR}/maxpath.h
+builtins/return.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/return.o: shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h
+builtins/set.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h ${BASHINCDIR}/maxpath.h
+builtins/set.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/set.o: shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h flags.h
+builtins/setattr.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h ${BASHINCDIR}/maxpath.h
builtins/setattr.o: quit.h $(DEFSRC)/common.h $(DEFSRC)/bashgetopt.h
-builtins/setattr.o: shell.h bashjmp.h posixjmp.h sig.h unwind_prot.h variables.h
-builtins/setattr.o: dispose_cmd.h make_cmd.h subst.h externs.h stdc.h
-builtins/shift.o: command.h config.h memalloc.h error.h general.h maxpath.h
-builtins/shift.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h stdc.h
-builtins/shift.o: shell.h bashjmp.h posixjmp.h sig.h unwind_prot.h variables.h
-builtins/shift.o: dispose_cmd.h make_cmd.h subst.h externs.h stdc.h
-builtins/shopt.o: command.h config.h memalloc.h error.h general.h
+builtins/setattr.o: shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h
+builtins/setattr.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/shift.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h ${BASHINCDIR}/maxpath.h
+builtins/shift.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/shift.o: shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h
+builtins/shift.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/shopt.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h
builtins/shopt.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h
-builtins/shopt.o: shell.h bashjmp.h posixjmp.h unwind_prot.h variables.h maxpath.h
+builtins/shopt.o: shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h unwind_prot.h variables.h ${BASHINCDIR}/maxpath.h
builtins/shopt.o: $(DEFSRC)/common.h $(DEFSRC)/bashgetopt.h
-builtins/source.o: command.h config.h memalloc.h error.h general.h maxpath.h
-builtins/source.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h stdc.h
-builtins/source.o: shell.h bashjmp.h posixjmp.h sig.h unwind_prot.h variables.h
+builtins/source.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h ${BASHINCDIR}/maxpath.h
+builtins/source.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/source.o: shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h
builtins/source.o: findcmd.h
-builtins/suspend.o: command.h config.h memalloc.h error.h general.h maxpath.h
-builtins/suspend.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h stdc.h
-builtins/suspend.o: shell.h bashjmp.h posixjmp.h sig.h unwind_prot.h variables.h
-builtins/test.o: command.h config.h memalloc.h error.h general.h maxpath.h
-builtins/test.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h stdc.h
-builtins/test.o: shell.h bashjmp.h posixjmp.h sig.h unwind_prot.h variables.h
+builtins/suspend.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h ${BASHINCDIR}/maxpath.h
+builtins/suspend.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/suspend.o: shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h
+builtins/test.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h ${BASHINCDIR}/maxpath.h
+builtins/test.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/test.o: shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h
builtins/test.o: test.h
-builtins/times.o: command.h config.h memalloc.h error.h general.h maxpath.h
-builtins/times.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h stdc.h
-builtins/times.o: shell.h bashjmp.h posixjmp.h sig.h unwind_prot.h variables.h
-builtins/trap.o: command.h config.h memalloc.h error.h general.h maxpath.h
+builtins/times.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h ${BASHINCDIR}/maxpath.h
+builtins/times.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/times.o: shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h
+builtins/trap.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h ${BASHINCDIR}/maxpath.h
builtins/trap.o: quit.h $(DEFSRC)/common.h
-builtins/trap.o: shell.h bashjmp.h posixjmp.h sig.h unwind_prot.h variables.h
-builtins/trap.o: dispose_cmd.h make_cmd.h subst.h externs.h stdc.h
-builtins/type.o: command.h config.h memalloc.h error.h general.h maxpath.h
+builtins/trap.o: shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h
+builtins/trap.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/type.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h ${BASHINCDIR}/maxpath.h
builtins/type.o: quit.h $(DEFSRC)/common.h findcmd.h
-builtins/type.o: shell.h bashjmp.h posixjmp.h sig.h unwind_prot.h variables.h
-builtins/type.o: dispose_cmd.h make_cmd.h subst.h externs.h stdc.h
-builtins/ulimit.o: command.h config.h memalloc.h error.h general.h maxpath.h
-builtins/ulimit.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h stdc.h
-builtins/ulimit.o: shell.h bashjmp.h posixjmp.h sig.h unwind_prot.h variables.h
-builtins/umask.o: command.h config.h memalloc.h error.h general.h maxpath.h
-builtins/umask.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h stdc.h
-builtins/umask.o: shell.h bashjmp.h posixjmp.h sig.h unwind_prot.h variables.h
-builtins/wait.o: command.h config.h memalloc.h error.h general.h maxpath.h
-builtins/wait.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h stdc.h
-builtins/wait.o: shell.h bashjmp.h posixjmp.h sig.h unwind_prot.h variables.h
+builtins/type.o: shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h
+builtins/type.o: dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/ulimit.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h ${BASHINCDIR}/maxpath.h
+builtins/ulimit.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/ulimit.o: shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h
+builtins/umask.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h ${BASHINCDIR}/maxpath.h
+builtins/umask.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/umask.o: shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h
+builtins/wait.o: command.h config.h ${BASHINCDIR}/memalloc.h error.h general.h ${BASHINCDIR}/maxpath.h
+builtins/wait.o: quit.h dispose_cmd.h make_cmd.h subst.h externs.h ${BASHINCDIR}/stdc.h
+builtins/wait.o: shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h unwind_prot.h variables.h
+
+builtins/complete.o: config.h shell.h bashjmp.h ${BASHINCDIR}/posixjmp.h sig.h
+builtins/complete.o: unwind_prot.h variables.h
+builtins/complete.o: bashtypes.h bashansi.h ${BASHINCDIR}/ansi_stdlib.h
+builtins/complete.o: builtins.h
+builtins/complete.o: pcomplete.h
+builtins/complete.o: ${DEFSRC}/common.h ${DEFSRC}/bashgetopt.h
# builtin library dependencies
builtins/bind.o: $(RL_LIBSRC)/chardefs.h $(RL_LIBSRC)/readline.h
@@ -1106,6 +1163,7 @@ builtins/builtin.o: $(DEFSRC)/builtin.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
diff --git a/NEWS b/NEWS
index 9999ab77..55a8dd22 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,111 @@
+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 (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 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.
diff --git a/NOTES b/NOTES
index 1e4d5611..2ce96143 100644
--- a/NOTES
+++ b/NOTES
@@ -26,6 +26,10 @@ Platform-Specific Configuration and Operation Notes
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
+
If you are using GNU libc, especially on a linux system
(Configuring --without-gnu-malloc will still result in lib/malloc/libmalloc.a
@@ -202,9 +206,13 @@ being built and linked against, but there is only a stub file in the archive.)
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.
+ 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, or 7 is
+ complicated.
-11. Building a statically-linked bash on Solaris 2.5.x or 2.6 is complicated.
It's not possible to build a completely statically-linked binary, since
part of the C library depends on dynamic linking. The following recipe
assumes that you're using gcc and the Solaris ld (/usr/ccs/bin/ld).
diff --git a/README b/README
index 08689085..3eceeb50 100644
--- a/README
+++ b/README
@@ -1,7 +1,7 @@
Introduction
============
-This is GNU Bash, version 2.03. Bash is the GNU Project's Bourne
+This is GNU Bash, version 2.04. Bash is the GNU Project's Bourne
Again SHell, a complete implementation of the POSIX.2 shell spec,
but also with interactive command line editing, job control on
architectures that support it, csh-like features such as history
@@ -51,21 +51,20 @@ Reporting Bugs
Bug reports for bash should be sent to:
- bug-bash@prep.ai.mit.edu
+ bug-bash@gnu.org
using the `bashbug' program that is built and installed at the same
time as bash.
-The discussion list `bug-bash@prep.ai.mit.edu' often contains
-information about new ports of Bash, or discussions of new features or
-behavior changes that people would like. This mailing list is also
-available as a usenet newsgroup: gnu.bash.bug.
+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@prep.ai.mit.edu with the following
-information:
+please send mail to bug-bash@gnu.org with the following information:
* the version number and release status of Bash (e.g., 2.01-release)
* the machine and OS that it is running on (look at the file
@@ -79,7 +78,7 @@ information:
The `bashbug' program includes much of this automatically.
If you would like to contact the Bash maintainers directly, send mail
-to bash-maintainers@prep.ai.mit.edu.
+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.
diff --git a/aclocal.m4 b/aclocal.m4
index c277a0c6..f8f5b74b 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -316,13 +316,19 @@ AC_CACHE_VAL(bash_cv_opendir_not_robust,
main()
{
DIR *dir;
-int fd;
-unlink("/tmp/not_a_directory");
-fd = open("/tmp/not_a_directory", O_WRONLY|O_CREAT, 0666);
+int fd, err;
+err = mkdir("/tmp/bash-aclocal", 0700);
+if (err < 0) {
+ perror("mkdir");
+ exit(1);
+}
+unlink("/tmp/bash-aclocal/not_a_directory");
+fd = open("/tmp/bash-aclocal/not_a_directory", O_WRONLY|O_CREAT|O_EXCL, 0666);
write(fd, "\n", 1);
close(fd);
-dir = opendir("/tmp/not_a_directory");
-unlink("/tmp/not_a_directory");
+dir = opendir("/tmp/bash-aclocal/not_a_directory");
+unlink("/tmp/bash-aclocal/not_a_directory");
+rmdir("/tmp/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)
@@ -354,25 +360,59 @@ AC_DEFINE(VOID_SIGHANDLER)
fi
])
-AC_DEFUN(BASH_TYPE_INT32_T,
+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(int32_t, int)
+ AC_CHECK_TYPE(bits32_t, int)
elif test "$ac_cv_sizeof_long" = 4; then
- AC_CHECK_TYPE(int32_t, long)
+ AC_CHECK_TYPE(bits32_t, long)
else
- AC_CHECK_TYPE(int32_t, int)
+ AC_CHECK_TYPE(bits32_t, int)
fi
])
-AC_DEFUN(BASH_TYPE_U_INT32_T,
+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_int32_t, unsigned int)
+ AC_CHECK_TYPE(u_bits32_t, unsigned int)
elif test "$ac_cv_sizeof_long" = 4; then
- AC_CHECK_TYPE(u_int32_t, unsigned long)
+ AC_CHECK_TYPE(u_bits32_t, unsigned long)
else
- AC_CHECK_TYPE(u_int32_t, unsigned int)
+ AC_CHECK_TYPE(u_bits32_t, unsigned int)
fi
])
@@ -387,6 +427,9 @@ else
fi
])
+dnl
+dnl A signed 64-bit quantity
+dnl
AC_DEFUN(BASH_TYPE_BITS64_T,
[
if test "$ac_sv_sizeof_char_p" = 8; then
@@ -427,6 +470,20 @@ if test $bash_cv_func_lstat = yes; then
fi
])
+AC_DEFUN(BASH_FUNC_INET_ATON,
+[
+AC_CACHE_CHECK([for inet_aton], bash_cv_func_inet_aton,
+[AC_TRY_LINK([
+#include <sys/types.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+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)
+fi
+])
+
AC_DEFUN(BASH_STRUCT_TERMIOS_LDISC,
[AC_MSG_CHECKING([for a c_line member of struct termios])
AC_CACHE_VAL(bash_cv_termios_ldisc,
@@ -845,7 +902,7 @@ AC_CACHE_VAL(bash_cv_sys_named_pipes,
/* Add more tests in here as appropriate. */
main()
{
-int fd;
+int fd, err;
#if defined (HAVE_MKFIFO)
exit (0);
@@ -858,12 +915,19 @@ exit (1);
#if defined (NeXT)
exit (1);
#endif
-
-fd = mknod ("/tmp/sh-np-autoconf", 0666 | S_IFIFO, 0);
-if (fd == -1)
+err = mkdir("/tmp/bash-aclocal", 0700);
+if (err < 0) {
+ perror ("mkdir");
+ exit(1);
+}
+fd = mknod ("/tmp/bash-aclocal/sh-np-autoconf", 0666 | S_IFIFO, 0);
+if (fd == -1) {
+ rmdir ("/tmp/bash-aclocal");
exit (1);
+}
close(fd);
-unlink ("/tmp/sh-np-autoconf");
+unlink ("/tmp/bash-aclocal/sh-np-autoconf");
+rmdir ("/tmp/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)
@@ -1037,12 +1101,32 @@ elif test $bash_cv_dev_fd = "whacky"; then
fi
])
+AC_DEFUN(BASH_CHECK_DEV_STDIN,
+[AC_MSG_CHECKING(whether /dev/stdin stdout stderr are available)
+AC_CACHE_VAL(bash_cv_dev_stdin,
+[if test -d /dev/fd && test -r /dev/stdin; then
+ bash_cv_dev_stdin=present
+ elif test -d /proc/self/fd && test -r /dev/stdin; then
+ bash_cv_dev_stdin=present
+ else
+ bash_cv_dev_stdin=absent
+ fi
+])
+AC_MSG_RESULT($bash_cv_dev_stdin)
+if test $bash_cv_dev_stdin = "present"; then
+ AC_DEFINE(HAVE_DEV_STDIN)
+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 Check for the presence of getpeername (the only networking function
-dnl bash currently requires) in libsocket. If libsocket is present,
-dnl check for libnsl and add it to LIBS if it's there, since most
-dnl systems with libsocket require linking with libnsl as well.
-dnl This should only be called if getpeername was not found in libc.
+dnl NOTE: IF WE FIND GETPEERNAME, WE ASSUME THAT WE HAVE BIND/CONNECT
+dnl AS WELL
dnl
AC_DEFUN(BASH_CHECK_SOCKLIB,
[
@@ -1084,6 +1168,32 @@ if test $bash_cv_have_socklib = yes; then
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 <netdb.h>],
+[ 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_DEFAULT_MAIL_DIR,
[AC_MSG_CHECKING(for default mail directory)
AC_CACHE_VAL(bash_cv_mail_dir,
@@ -1299,3 +1409,19 @@ switch (0) case 0: case (sizeof (off_t) <= 4):;
if test $bash_cv_off_t_64 = yes; then
AC_DEFINE(HAVE_OFF_T_64)
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
+])
diff --git a/alias.c b/alias.c
index 13b7f57c..183fe270 100644
--- a/alias.c
+++ b/alias.c
@@ -7,7 +7,7 @@
Bash is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 1, or (at your option)
+ the Free Software Foundation; either version 2, or (at your option)
any later version.
Bash is distributed in the hope that it will be useful, but WITHOUT
@@ -17,7 +17,7 @@
You should have received a copy of the GNU General Public License
along with Bash; see the file COPYING. If not, write to the Free
- Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#include "config.h"
@@ -37,6 +37,10 @@
#include "externs.h"
#include "alias.h"
+#if defined (PROGRAMMABLE_COMPLETION)
+# include "pcomplete.h"
+#endif
+
static int qsort_alias_compare ();
/* Non-zero means expand all words on the line. Otherwise, expand
@@ -121,6 +125,9 @@ add_alias (name, value)
elt = add_hash_item (savestring (name), aliases);
elt->data = (char *)temp;
+#if defined (PROGRAMMABLE_COMPLETION)
+ set_itemlist_dirty (&it_aliases);
+#endif
}
}
@@ -155,6 +162,9 @@ remove_alias (name)
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);
@@ -170,6 +180,9 @@ delete_all_aliases ()
flush_hash_table (aliases, free_alias_data);
dispose_hash_table (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.
@@ -433,21 +446,22 @@ char *
alias_expand (string)
char *string;
{
- int line_len = 1 + strlen (string);
- char *line = (char *)xmalloc (line_len);
register int i, j, start;
- char *token = xmalloc (line_len);
- int tl, real_start, expand_next, expand_this_token;
+ char *line, *token;
+ int line_len, tl, real_start, expand_next, expand_this_token;
alias_t *alias;
+ line_len = strlen (string) + 1;
+ line = xmalloc (line_len);
+ token = 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
+ 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 (;;)
diff --git a/alias.h b/alias.h
index 7b7cac75..a199d8c0 100644
--- a/alias.h
+++ b/alias.h
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with Bash; see the file COPYING. If not, write to the Free
- Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if !defined (_ALIAS_H_)
#define _ALIAS_H_
diff --git a/array.c b/array.c
index 57eac2d6..6e2d39cc 100644
--- a/array.c
+++ b/array.c
@@ -8,6 +8,25 @@
* Chet Ramey
* chet@ins.cwru.edu
*/
+
+/* Copyright (C) 1997 Free Software Foundation, Inc.
+
+ This file is part of GNU Bash, the Bourne Again SHell.
+
+ Bash is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free
+ Software Foundation; either version 2, or (at your option) any later
+ version.
+
+ Bash is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with Bash; see the file COPYING. If not, write to the Free Software
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+
#include "config.h"
#if defined (ARRAY_VARS)
@@ -441,6 +460,26 @@ ARRAY *a;
return (REVERSE_LIST(list, WORD_LIST *));
}
+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 = alloc_array (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);
+}
+
ARRAY *
assign_word_list (array, list)
ARRAY *array;
diff --git a/array.h b/array.h
index 15e2a564..620ccbec 100644
--- a/array.h
+++ b/array.h
@@ -1,5 +1,24 @@
/* array.h -- definitions for the interface exported by array.c that allows
the rest of the shell to manipulate array variables. */
+
+/* Copyright (C) 1997 Free Software Foundation, Inc.
+
+ This file is part of GNU Bash, the Bourne Again SHell.
+
+ Bash is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free
+ Software Foundation; either version 2, or (at your option) any later
+ version.
+
+ Bash is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with Bash; see the file COPYING. If not, write to the Free Software
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+
#ifndef _ARRAY_H_
#define _ARRAY_H_
@@ -41,6 +60,8 @@ extern WORD_LIST *array_to_word_list __P((ARRAY *));
extern ARRAY *word_list_to_array __P((WORD_LIST *));
extern ARRAY *assign_word_list __P((ARRAY *, WORD_LIST *));
+extern char **array_to_argv __P((ARRAY *));
+
extern char *array_to_assignment_string __P((ARRAY *));
extern char *quoted_array_assignment_string __P((ARRAY *));
extern char *array_to_string __P((ARRAY *, char *, int));
diff --git a/bashansi.h b/bashansi.h
index 44119701..4e9f9073 100644
--- a/bashansi.h
+++ b/bashansi.h
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if !defined (_BASHANSI_H_)
#define _BASHANSI_H_
diff --git a/bashhist.c b/bashhist.c
index ed88b2cc..3cc544c3 100644
--- a/bashhist.c
+++ b/bashhist.c
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#include "config.h"
@@ -408,7 +408,7 @@ pre_process_line (line, print_changes, addit)
if (expanded < 0)
internal_error ("%s", history_value);
#if defined (READLINE)
- else if (hist_verify == 0)
+ else if (hist_verify == 0 || expanded == 2)
#else
else
#endif
@@ -457,6 +457,34 @@ pre_process_line (line, print_changes, addit)
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 == '#');
+}
+
+/* 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);
+}
+
/* Add LINE to the history list depending on the value of HISTORY_CONTROL. */
void
maybe_add_history (line)
@@ -476,7 +504,8 @@ maybe_add_history (line)
if (current_command_line_count > 1)
#endif
{
- bash_add_history (line);
+ if (literal_history || dstack.delimiter_depth != 0 || shell_comment (line) == 0)
+ bash_add_history (line);
return;
}
@@ -637,51 +666,15 @@ expand_histignore_pattern (pat)
char *pat;
{
HIST_ENTRY *phe;
- char *ret, *p, *r, *t;
- int len, rlen, ind, tlen;
+ char *ret;
phe = last_history_entry ();
if (phe == (HIST_ENTRY *)0)
return (savestring (pat));
- len = strlen (phe->line);
- rlen = len + strlen (pat) + 2;
- ret = xmalloc (rlen);
+ ret = strcreplace (pat, '&', phe->line, 1);
- for (p = pat, r = ret; p && *p; )
- {
- if (*p == '&')
- {
- ind = r - ret;
- if (glob_pattern_p (phe->line) || strchr (phe->line, '\\'))
- {
- t = quote_globbing_chars (phe->line);
- tlen = strlen (t);
- RESIZE_MALLOCED_BUFFER (ret, ind, tlen, rlen, rlen);
- r = ret + ind; /* in case reallocated */
- strcpy (r, t);
- r += tlen;
- free (t);
- }
- else
- {
- tlen = strlen (phe->line);
- RESIZE_MALLOCED_BUFFER (ret, ind, tlen, rlen, rlen);
- r = ret + ind; /* in case reallocated */
- strcpy (r, phe->line);
- r += len;
- }
- p++;
- continue;
- }
-
- if (*p == '\\' && p[1] == '&')
- p++;
-
- *r++ = *p++;
- }
- *r = '\0';
return ret;
}
diff --git a/bashhist.h b/bashhist.h
index d7bade05..6f8405fc 100644
--- a/bashhist.h
+++ b/bashhist.h
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if !defined (_BASHHIST_H_)
#define _BASHHIST_H_
diff --git a/bashintl.h b/bashintl.h
index 50d0553a..f9e6cdbb 100644
--- a/bashintl.h
+++ b/bashintl.h
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if !defined (_BASHINTL_H_)
#define _BASHINTL_H_
diff --git a/bashjmp.h b/bashjmp.h
index ec21e6cb..2b441893 100644
--- a/bashjmp.h
+++ b/bashjmp.h
@@ -1,5 +1,23 @@
/* bashjmp.h -- wrapper for setjmp.h with necessary bash definitions. */
+/* 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 2, or (at your option)
+ any later version.
+
+ Bash is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
+ License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Bash; see the file COPYING. If not, write to the Free
+ Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+
#ifndef _BASHJMP_H_
#define _BASHJMP_H_
diff --git a/bashline.c b/bashline.c
index 03af185a..cb4de05a 100644
--- a/bashline.c
+++ b/bashline.c
@@ -6,7 +6,7 @@
Bash is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 1, or (at your option)
+ the Free Software Foundation; either version 2, or (at your option)
any later version.
Bash is distributed in the hope that it will be useful, but WITHOUT
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with Bash; see the file COPYING. If not, write to the Free
- Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#include "config.h"
@@ -49,6 +49,10 @@
# include "alias.h"
#endif
+#if defined (PROGRAMMABLE_COMPLETION)
+# include "pcomplete.h"
+#endif
+
#if defined (BRACE_COMPLETION)
extern void bash_brace_completion ();
#endif /* BRACE_COMPLETION */
@@ -57,6 +61,7 @@ extern void bash_brace_completion ();
static void shell_expand_line ();
static void display_shell_version (), operate_and_get_next ();
static void bash_ignore_filenames ();
+static void bash_ignore_everything ();
static void cleanup_expansion_error (), set_up_new_line ();
#if defined (BANG_HISTORY)
@@ -78,7 +83,6 @@ static void bash_push_line ();
static char **attempt_shell_completion ();
static char *variable_completion_function ();
static char *hostname_completion_function ();
-static char *command_word_completion_function ();
static char *command_subst_completion_function ();
static void dynamic_complete_history ();
@@ -86,7 +90,8 @@ static char *glob_complete_word ();
static void bash_glob_expand_word ();
static void bash_glob_list_expansions ();
-static void snarf_hosts_from_file (), add_host_name ();
+static void snarf_hosts_from_file ();
+static void add_host_name ();
static char *bash_dequote_filename ();
static char *bash_quote_filename ();
@@ -95,6 +100,11 @@ static char *bash_quote_filename ();
static int posix_edit_macros ();
#endif
+#if defined (PROGRAMMABLE_COMPLETION)
+static char **prog_complete_matches;
+static int old_rl_completion_append_character;
+#endif
+
/* Variables used here but defined in other files. */
extern int posixly_correct, no_symbolic_links;
extern int rl_explicit_arg;
@@ -103,10 +113,6 @@ extern STRING_INT_ALIST word_token_alist[];
extern Function *rl_last_func;
extern int rl_filename_completion_desired;
-/* Helper functions from subst.c */
-extern int char_is_quoted ();
-extern int unclosed_pair ();
-
/* 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
@@ -139,6 +145,9 @@ int bash_readline_initialized = 0;
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;
+
static char *bash_completer_word_break_characters = " \t\n\"'@><=;|&(:";
static char *bash_nohostname_word_break_characters = " \t\n\"'><=;|&(:";
@@ -386,8 +395,10 @@ display_shell_version (count, c)
/* **************************************************************** */
/* If the user requests hostname completion, then simply build a list
- of hosts, and complete from that forever more. */
+ 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;
@@ -504,6 +515,27 @@ snarf_hosts_from_file (filename)
fclose (file);
}
+/* Return the hostname list. */
+char **
+get_hostname_list ()
+{
+ if (hostname_list_initialized == 0)
+ initialize_hostname_list ();
+ return (hostname_list);
+}
+
+void
+clear_hostname_list ()
+{
+ register int i;
+
+ if (hostname_list_initialized == 0)
+ return;
+ for (i = 0; i < hostname_list_length; i++)
+ free (hostname_list[i]);
+ hostname_list_length = 0;
+}
+
/* Return a NULL terminated list of hostnames which begin with TEXT.
Initialize the hostname list the first time if neccessary.
The array is malloc ()'ed, but not the individual strings. */
@@ -524,7 +556,7 @@ hostnames_matching (text)
what is desired. */
if (*text == '\0')
{
- result = (char **)xmalloc ((1 + hostname_list_length) * sizeof (char *));
+ result = alloc_array (1 + hostname_list_length);
for (i = 0; i < hostname_list_length; i++)
result[i] = hostname_list[i];
result[i] = (char *)NULL;
@@ -656,6 +688,87 @@ posix_edit_macros (count, key)
/* */
/* **************************************************************** */
+#define COMMAND_SEPARATORS ";|&{(`"
+
+static int
+check_redir (ti)
+ int ti;
+{
+ register int this_char, prev_char;
+
+ /* Handle the two character tokens `>&', `<&', and `>|'.
+ We are not in a command position after one of these. */
+ this_char = rl_line_buffer[ti];
+ prev_char = rl_line_buffer[ti - 1];
+
+ if ((this_char == '&' && (prev_char == '<' || prev_char == '>')) ||
+ (this_char == '|' && prev_char == '>'))
+ return (1);
+ else if ((this_char == '{' && prev_char == '$') || /* } */
+ (char_is_quoted (rl_line_buffer, ti)))
+ return (1);
+ return (0);
+}
+
+#if defined (PROGRAMMABLE_COMPLETION)
+static int
+find_cmd_start (start)
+ int start;
+{
+ register int s, os;
+
+ os = 0;
+ while (((s = skip_to_delim (rl_line_buffer, os, COMMAND_SEPARATORS)) <= start) &&
+ rl_line_buffer[s])
+ os = s+1;
+ return os;
+}
+
+static int
+find_cmd_end (end)
+ int end;
+{
+ register int e;
+
+ e = skip_to_delim (rl_line_buffer, end, COMMAND_SEPARATORS);
+ return e;
+}
+
+static char *
+find_cmd_name (start)
+ int start;
+{
+ char *name;
+ register int s, e;
+
+ for (s = start; whitespace (rl_line_buffer[s]); s++)
+ ;
+
+ /* skip until a shell break character */
+ e = skip_to_delim (rl_line_buffer, s, "()<>;&| \t\n");
+
+ name = substring (rl_line_buffer, s, e);
+
+ return (name);
+}
+
+static char *
+prog_complete_return (text, matchnum)
+ char *text;
+ int matchnum;
+{
+ static int ind;
+
+ if (matchnum == 0)
+ ind = 0;
+
+ if (prog_complete_matches == 0 || prog_complete_matches[ind] == 0)
+ return (char *)NULL;
+ return (prog_complete_matches[ind++]);
+}
+
+#endif /* PROGRAMMABLE_COMPLETION */
+
/* Do some completion on TEXT. The indices of TEXT in RL_LINE_BUFFER are
at START and END. Return an array of matches, or NULL if none. */
static char **
@@ -663,10 +776,10 @@ attempt_shell_completion (text, start, end)
char *text;
int start, end;
{
- int in_command_position, ti;
+ int in_command_position, ti, saveti, qc;
char **matches, *command_separator_chars;
- command_separator_chars = ";|&{(`";
+ command_separator_chars = COMMAND_SEPARATORS;
matches = (char **)NULL;
rl_ignore_some_completions_function = (Function *)filename_completion_ignore;
@@ -675,10 +788,23 @@ attempt_shell_completion (text, start, end)
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 (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)
{
@@ -689,21 +815,10 @@ attempt_shell_completion (text, start, end)
}
else if (member (rl_line_buffer[ti], command_separator_chars))
{
- register int this_char, prev_char;
-
in_command_position++;
- /* Handle the two character tokens `>&', `<&', and `>|'.
- We are not in a command position after one of these. */
- this_char = rl_line_buffer[ti];
- prev_char = rl_line_buffer[ti - 1];
-
- if ((this_char == '&' && (prev_char == '<' || prev_char == '>')) ||
- (this_char == '|' && prev_char == '>'))
- in_command_position = 0;
- else if ((this_char == '{' && prev_char == '$') ||
- (char_is_quoted (rl_line_buffer, ti)))
- in_command_position = 0;
+ if (check_redir (ti) == 1)
+ in_command_position = 0;
}
else
{
@@ -715,20 +830,59 @@ attempt_shell_completion (text, start, end)
/* 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, 0, "`") == 0)
+ *text != '`' && unclosed_pair (rl_line_buffer, end, "`") == 0)
in_command_position = 0;
/* Special handling for command substitution. If *TEXT is a backquote,
it can be the start or end of an old-style command substitution, or
unmatched. If it's unmatched, both calls to unclosed_pair will
succeed. */
- if (*text == '`' && unclosed_pair (rl_line_buffer, start, "`") &&
- unclosed_pair (rl_line_buffer, end, "`"))
+ if (*text == '`' &&
+ (in_command_position || (unclosed_pair (rl_line_buffer, start, "`") &&
+ unclosed_pair (rl_line_buffer, end, "`"))))
matches = completion_matches (text, command_subst_completion_function);
- /* Variable name? */
+#if defined (PROGRAMMABLE_COMPLETION)
+ /* Attempt programmable completion. */
+ if (!matches && in_command_position == 0 && prog_completion_enabled &&
+ (num_progcomps () > 0) && current_prompt_string == ps1_prompt)
+ {
+ int s, e, foundcs;
+ char *n;
+
+ /* XXX - don't free the members */
+ if (prog_complete_matches)
+ free (prog_complete_matches);
+ prog_complete_matches = (char **)NULL;
+
+ s = find_cmd_start (start);
+ e = find_cmd_end (end);
+ n = find_cmd_name (s);
+ prog_complete_matches = programmable_completions (n, text, s, e, &foundcs);
+ 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. */
+ if (foundcs)
+ {
+ /* Turn what the programmable completion code returns into what
+ readline wants. I should have made compute_lcd_of_matches
+ external... */
+ matches = completion_matches (text, prog_complete_return);
+ rl_attempted_completion_over = 1; /* no default */
+ return (matches);
+ }
+ }
+#endif
+
+ /* New posix-style command substitution or variable name? */
if (!matches && *text == '$')
- matches = completion_matches (text, variable_completion_function);
+ {
+ if (qc != '\'' && text[1] == '(') /* ) */
+ matches = completion_matches (text, command_subst_completion_function);
+ else
+ matches = completion_matches (text, variable_completion_function);
+ }
/* If the word starts in `~', and there is no slash in the word, then
try completing this word as a username. */
@@ -745,14 +899,22 @@ attempt_shell_completion (text, start, end)
and command names. */
if (!matches && in_command_position)
{
- matches = 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)
- rl_ignore_some_completions_function = (Function *)bash_ignore_filenames;
+ if (start == 0 && end == 0 && text[0] == '\0' && no_empty_command_completion)
+ {
+ matches = (char **)NULL;
+ rl_ignore_some_completions_function = (Function *)bash_ignore_everything;
+ }
+ else
+ {
+ matches = 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 = (Function *)bash_ignore_filenames;
+ }
}
/* This could be a globbing pattern, so try to expand it using pathname
@@ -776,7 +938,7 @@ attempt_shell_completion (text, start, end)
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. */
-static char *
+char *
command_word_completion_function (hint_text, state)
char *hint_text;
int state;
@@ -1081,8 +1243,7 @@ variable_completion_function (text, state)
int state;
char *text;
{
- register SHELL_VAR *var = (SHELL_VAR *)NULL;
- static SHELL_VAR **varlist = (SHELL_VAR **)NULL;
+ static char **varlist = (char **)NULL;
static int varlist_index;
static char *varname = (char *)NULL;
static int namelen;
@@ -1106,20 +1267,10 @@ variable_completion_function (text, state)
namelen = strlen (varname);
if (varlist)
- free (varlist);
- varlist = all_visible_variables ();
- varlist_index = 0;
- }
-
- while (varlist && varlist[varlist_index])
- {
- var = varlist[varlist_index];
+ free_array (varlist);
- /* Compare. You can't do better than Zayre. No text is also
- a match. */
- if (!*varname || (strncmp (varname, var->name, namelen) == 0))
- break;
- varlist_index++;
+ varlist = all_variables_matching_prefix (varname);
+ varlist_index = 0;
}
if (!varlist || !varlist[varlist_index])
@@ -1128,7 +1279,7 @@ variable_completion_function (text, state)
}
else
{
- char *value = xmalloc (4 + strlen (var->name));
+ char *value = xmalloc (4 + strlen (varlist[varlist_index]));
if (first_char_loc)
{
@@ -1137,7 +1288,7 @@ variable_completion_function (text, state)
value[1] = '{';
}
- strcpy (&value[first_char_loc], var->name);
+ strcpy (value + first_char_loc, varlist[varlist_index]);
if (first_char_loc == 2)
strcat (value, "}");
@@ -1479,9 +1630,9 @@ _ignore_completion_names (names, name_func)
filenames. The pointers are copied back to NAMES when done. */
for (nidx = 1; names[nidx]; nidx++)
;
- newnames = (char **)xmalloc ((nidx + 1) * (sizeof (char *)));
+ newnames = alloc_array (nidx + 1);
#ifdef NO_FORCE_FIGNORE
- oldnames = (char **)xmalloc ((nidx - 1) * (sizeof (char *)));
+ oldnames = alloc_array (nidx - 1);
oidx = 0;
#endif
@@ -1605,6 +1756,20 @@ bash_ignore_filenames (names)
_ignore_completion_names (names, test_for_directory);
}
+static int
+return_zero (name)
+ char *name;
+{
+ return 0;
+}
+
+static void
+bash_ignore_everything (names)
+ char **names;
+{
+ _ignore_completion_names (names, return_zero);
+}
+
/* Handle symbolic link references and other directory name
expansions while hacking completion. */
static int
@@ -1612,13 +1777,28 @@ bash_directory_completion_hook (dirname)
char **dirname;
{
char *local_dirname, *new_dirname, *t;
- int return_value = 0;
+ int return_value, should_expand_dirname;
WORD_LIST *wl;
+ return_value = should_expand_dirname = 0;
local_dirname = *dirname;
- new_dirname = savestring (local_dirname);
- if (strchr (local_dirname, '$') || strchr (local_dirname, '`'))
+
+#if 0
+ should_expand_dirname = strchr (local_dirname, '$') || strchr (local_dirname, '`');
+#else
+ if (strchr (local_dirname, '$'))
+ should_expand_dirname = 1;
+ else
+ {
+ t = strchr (local_dirname, '`');
+ if (t && unclosed_pair (local_dirname, strlen (local_dirname), "`") == 0)
+ should_expand_dirname = 1;
+ }
+#endif
+
+ if (should_expand_dirname)
{
+ new_dirname = savestring (local_dirname);
wl = expand_string (new_dirname, 0);
if (wl)
{
@@ -1969,9 +2149,9 @@ bash_specific_completion (what_to_do, generator)
#endif /* SPECIFIC_COMPLETION_FUNCTIONS */
/* Filename quoting for completion. */
-/* A function to strip quotes that are not protected by backquotes. It
- allows single quotes to appear within double quotes, and vice versa.
- It should be smarter. */
+/* 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;
@@ -2071,8 +2251,14 @@ bash_quote_filename (s, rtype, qcp)
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. */
- if (*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 && strchr (mtext, '\n'))
+ cs = COMPLETE_SQUOTE;
+ else if (*qcp == '"')
cs = COMPLETE_DQUOTE;
else if (*qcp == '\'')
cs = COMPLETE_SQUOTE;
@@ -2127,4 +2313,186 @@ bash_quote_filename (s, rtype, qcp)
return ret;
}
+/* Support for binding readline key sequences to Unix commands. */
+static Keymap cmd_xmap;
+
+static int
+bash_execute_unix_command (count, key)
+ int count; /* ignored */
+ int key;
+{
+ Keymap ckmap; /* current keymap */
+ Keymap xkmap; /* unix command executing keymap */
+ register int i;
+ char *cmd;
+
+ /* First, we need to find the right command to execute. This is tricky,
+ because we might have already indirected into another keymap. */
+ ckmap = rl_get_keymap ();
+ if (ckmap != rl_executing_keymap)
+ {
+ /* bogus. we have to search. only handle one level of indirection. */
+ for (i = 0; i < KEYMAP_SIZE; i++)
+ {
+ if (ckmap[i].type == ISKMAP && (Keymap)ckmap[i].function == rl_executing_keymap)
+ break;
+ }
+ if (i < KEYMAP_SIZE)
+ xkmap = (Keymap)cmd_xmap[i].function;
+ else
+ {
+ crlf ();
+ internal_error ("bash_execute_unix_command: cannot find keymap for command");
+ rl_forced_update_display ();
+ return 1;
+ }
+ }
+ else
+ xkmap = cmd_xmap;
+
+ cmd = (char *)xkmap[key].function;
+
+ if (cmd == 0)
+ {
+ ding ();
+ return 1;
+ }
+
+ crlf (); /* move to a new line */
+
+ cmd = savestring (cmd);
+ parse_and_execute (cmd, "bash_execute_unix_command", 0);
+
+ /* and restore the readline buffer and display after command execution. */
+ rl_forced_update_display ();
+ return 0;
+}
+
+static void
+init_unix_command_map ()
+{
+ cmd_xmap = rl_make_bare_keymap ();
+}
+
+static int
+isolate_sequence (string, ind, need_dquote, startp)
+ char *string;
+ int ind, need_dquote, *startp;
+{
+ register int i;
+ int c, passc, delim;
+
+ for (i = ind; string[i] && whitespace (string[i]); i++)
+ ;
+ /* NEED_DQUOTE means that the first non-white character *must* be `"'. */
+ if (need_dquote && string[i] != '"')
+ {
+ builtin_error ("%s: first non-whitespace character is not `\"'", string);
+ return -1;
+ }
+
+ /* We can have delimited strings even if NEED_DQUOTE == 0, like the command
+ string to bind the key sequence to. */
+ delim = (string[i] == '"' || string[i] == '\'') ? string[i] : 0;
+
+ if (startp)
+ *startp = delim ? ++i : i;
+
+ for (passc = 0; c = string[i]; i++)
+ {
+ if (passc)
+ {
+ passc = 0;
+ continue;
+ }
+ if (c == '\\')
+ {
+ passc++;
+ continue;
+ }
+ if (c == delim)
+ break;
+ }
+
+ if (delim && string[i] != delim)
+ {
+ builtin_error ("%s: no closing `%c'", string, delim);
+ return -1;
+ }
+
+ return i;
+}
+
+int
+bind_keyseq_to_unix_command (line)
+ char *line;
+{
+ Keymap kmap;
+ char *kseq, *value;
+ int i, kstart, len, ok;
+
+ if (cmd_xmap == 0)
+ init_unix_command_map ();
+
+ kmap = rl_get_keymap ();
+
+ /* We duplicate some of the work done by rl_parse_and_bind here, but
+ this code only has to handle `"keyseq": ["]command["]' and can
+ generate an error for anything else. */
+ i = isolate_sequence (line, 0, 1, &kstart);
+ if (i < 0)
+ return -1;
+
+ /* Create the key sequence string to pass to rl_generic_bind */
+ kseq = substring (line, kstart, i);
+
+ for ( ; line[i] && line[i] != ':'; i++)
+ ;
+ if (line[i] != ':')
+ {
+ builtin_error ("%s: missing colon separator", line);
+ return -1;
+ }
+
+ i = isolate_sequence (line, i + 1, 0, &kstart);
+ if (i < 0)
+ return -1;
+
+ /* Create the value string containing the command to execute. */
+ value = substring (line, kstart, i);
+
+ /* Save the command to execute and the key sequence in the CMD_XMAP */
+ rl_generic_bind (ISMACR, kseq, value, cmd_xmap);
+
+ /* and bind the key sequence in the current keymap to a function that
+ understands how to execute from CMD_XMAP */
+ rl_set_key (kseq, (Function *)bash_execute_unix_command, kmap);
+
+ return 0;
+}
+
+/* Used by the programmable completion code. Complete TEXT as a filename,
+ but return only directories as matches. Dequotes the filename before
+ attempting to find matches. */
+char **
+bash_directory_completion_matches (text)
+ char *text;
+{
+ char **m1;
+ char *dfn;
+ int qc;
+
+ qc = (text[0] == '"' || text[0] == '\'') ? text[0] : 0;
+ dfn = bash_dequote_filename (text, qc);
+ m1 = completion_matches (dfn, filename_completion_function);
+ free (dfn);
+
+ if (m1 == 0 || m1[0] == 0)
+ return m1;
+ /* We don't bother recomputing the lcd of the matches, because it will just
+ get thrown away by the programmable completion code and recomputed
+ later. */
+ (void)bash_ignore_filenames (m1);
+ return m1;
+}
#endif /* READLINE */
diff --git a/bashline.h b/bashline.h
index 8e84a018..b5155dc5 100644
--- a/bashline.h
+++ b/bashline.h
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if !defined (_BASHLINE_H_)
#define _BASHLINE_H_
@@ -30,4 +30,14 @@ extern void initialize_readline __P((void));
extern void bashline_reinitialize __P((void));
extern int bash_re_edit __P((char *));
+extern int bind_keyseq_to_unix_command __P((char *));
+
+/* Used by programmable completion code. */
+extern char *command_word_completion_function __P((char *, int));
+
+extern char **get_hostname_list __P((void));
+extern void clear_hostname_list __P((void));
+
+extern char **bash_directory_completion_matches __P((char *));
+
#endif /* _BASHLINE_H_ */
diff --git a/bashtty.h b/bashtty.h
deleted file mode 100644
index f2ceb258..00000000
--- a/bashtty.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/* bashtty.h -- what kind of tty driver do we have? */
-
-/* Copyright (C) 1993 Free Software Foundation, Inc.
-
- This file is part of GNU Bash, the Bourne Again SHell.
-
- Bash is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free
- Software Foundation; either version 2, or (at your option) any later
- version.
-
- Bash is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- for more details.
-
- You should have received a copy of the GNU General Public License along
- with Bash; see the file COPYING. If not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#if !defined (_BASHTTY_H_)
-#define _BASHTTY_H_
-
-#if defined (_POSIX_VERSION) && defined (HAVE_TERMIOS_H) && defined (HAVE_TCGETATTR) && !defined (TERMIOS_MISSING)
-# define TERMIOS_TTY_DRIVER
-#else
-# if defined (HAVE_TERMIO_H)
-# define TERMIO_TTY_DRIVER
-# else
-# define NEW_TTY_DRIVER
-# endif
-#endif
-
-#endif /* _BASHTTY_H */
diff --git a/bashtypes.h b/bashtypes.h
index 540ff5bc..c3739485 100644
--- a/bashtypes.h
+++ b/bashtypes.h
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if !defined (_BASHTYPES_H_)
# define _BASHTYPES_H_
diff --git a/bracecomp.c b/bracecomp.c
index f28570f7..eb1b8897 100644
--- a/bracecomp.c
+++ b/bracecomp.c
@@ -20,7 +20,7 @@
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#include "config.h"
#if defined (BRACE_EXPANSION) && defined (READLINE)
diff --git a/braces.c b/braces.c
index a6c3aa06..93af4994 100644
--- a/braces.c
+++ b/braces.c
@@ -6,7 +6,7 @@
Bash is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 1, or (at your option)
+ the Free Software Foundation; either version 2, or (at your option)
any later version.
Bash is distributed in the hope that it will be useful, but WITHOUT
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with Bash; see the file COPYING. If not, write to the Free
- Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
/* Stuff in curly braces gets expanded before all other shell expansions. */
@@ -117,9 +117,13 @@ brace_expand (text)
return (result);
}
+#if defined (SHELL)
+ amble = substring (text, start, i);
+#else
amble = (char *)xmalloc (1 + (i - start));
strncpy (amble, &text[start], (i - start));
amble[i - start] = '\0';
+#endif
#if defined (SHELL)
/* If the amble does not contain an unquoted BRACE_ARG_SEPARATOR, then
@@ -175,9 +179,13 @@ expand_amble (text)
for (start = 0, i = 0, c = 1; c; start = ++i)
{
c = brace_gobbler (text, &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);
diff --git a/builtins.h b/builtins.h
index 318ef8e1..eece7a0b 100644
--- a/builtins.h
+++ b/builtins.h
@@ -6,7 +6,7 @@
Bash is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 1, or (at your option)
+ the Free Software Foundation; either version 2, or (at your option)
any later version.
Bash is distributed in the hope that it will be useful, but WITHOUT
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with Bash; see the file COPYING. If not, write to the Free
- Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#include "config.h"
diff --git a/builtins/Makefile.in b/builtins/Makefile.in
index 1c546c96..652fb08c 100644
--- a/builtins/Makefile.in
+++ b/builtins/Makefile.in
@@ -1,5 +1,22 @@
# This Makefile for building libbuiltins.a is in -*- text -*- for Emacs.
#
+# Copyright (C) 1996 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
+
+#
SHELL = @MAKE_SHELL@
RANLIB = @RANLIB@
CC = @CC@
@@ -9,6 +26,8 @@ ARFLAGS = @ARFLAGS@
RM = rm -f
CP = cp
+EXEEXT = @EXEEXT@
+
srcdir = @srcdir@
VPATH = .:@srcdir@
topdir = @top_srcdir@
@@ -25,12 +44,14 @@ LDFLAGS = @LDFLAGS@ $(LOCAL_LDFLAGS) $(CFLAGS)
LOCAL_LDFLAGS = @LOCAL_LDFLAGS@
LIBS = @LIBS@
-INCLUDES = -I. -I.. @RL_INCLUDE@ -I$(topdir) -I$(topdir)/lib -I$(srcdir)
+BASHINCDIR = ${topdir}/include
+
+INCLUDES = -I. -I.. @RL_INCLUDE@ -I$(topdir) -I$(BASHINCDIR) -I$(topdir)/lib -I$(srcdir)
CCFLAGS = ${PROFILE_FLAGS} $(DEFS) $(LOCAL_DEFS) $(SYSTEM_FLAGS) $(CPPFLAGS) \
${INCLUDES} $(LOCAL_CFLAGS) $(CFLAGS)
-MKBUILTINS = mkbuiltins
+MKBUILTINS = mkbuiltins$(EXEEXT)
DIRECTDEFINE = -D $(srcdir)
# xxx this is bad style
@@ -68,7 +89,7 @@ DEFSRC = $(srcdir)/alias.def $(srcdir)/bind.def $(srcdir)/break.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)/printf.def $(srcdir)/complete.def
STATIC_SOURCE = common.c evalstring.c evalfile.c getopt.c bashgetopt.c \
getopt.h
@@ -80,7 +101,7 @@ OFILES = builtins.o \
exit.o fc.o fg_bg.o hash.o help.o history.o jobs.o kill.o let.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
+ wait.o getopts.o shopt.o printf.o getopt.o bashgetopt.o complete.o
CREATED_FILES = builtext.h builtins.c psize.aux pipesize.h
@@ -112,7 +133,7 @@ mkbuiltins.o: mkbuiltins.c
$(RM) $@
$(CC_FOR_BUILD) -c $(CCFLAGS) $<
-mkbuiltins: mkbuiltins.o
+mkbuiltins$(EXEEXT): mkbuiltins.o
$(CC_FOR_BUILD) $(PROFILE_FLAGS) $(LDFLAGS) -o $(MKBUILTINS) mkbuiltins.o $(LIBS)
# rules for deficient makes, like SunOS
@@ -188,274 +209,286 @@ 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 $(topdir)/ansi_stdlib.h
+bashgetopt.o: ../config.h $(topdir)/bashansi.h $(BASHINCDIR)/ansi_stdlib.h
bashgetopt.o: $(topdir)/shell.h $(topdir)/bashjmp.h
bashgetopt.o: $(topdir)/command.h $(topdir)/general.h $(topdir)/error.h
-bashgetopt.o: $(topdir)/variables.h $(topdir)/quit.h $(topdir)/maxpath.h
+bashgetopt.o: $(topdir)/variables.h $(topdir)/quit.h $(BASHINCDIR)/maxpath.h
bashgetopt.o: $(topdir)/unwind_prot.h $(topdir)/dispose_cmd.h
bashgetopt.o: $(topdir)/make_cmd.h $(topdir)/subst.h $(topdir)/sig.h
bashgetopt.o: $(topdir)/pathnames.h $(topdir)/externs.h $(srcdir)/common.h
-common.o: $(topdir)/bashtypes.h $(topdir)/posixstat.h $(topdir)/bashansi.h $(topdir)/ansi_stdlib.h
-common.o: $(topdir)/shell.h ../config.h $(topdir)/bashjmp.h $(topdir)/posixjmp.h
+common.o: $(topdir)/bashtypes.h $(BASHINCDIR)/posixstat.h $(topdir)/bashansi.h $(BASHINCDIR)/ansi_stdlib.h
+common.o: $(topdir)/shell.h ../config.h $(topdir)/bashjmp.h $(BASHINCDIR)/posixjmp.h
common.o: $(topdir)/sig.h $(topdir)/command.h
-common.o: $(topdir)/general.h $(topdir)/stdc.h $(topdir)/memalloc.h
+common.o: $(topdir)/general.h $(BASHINCDIR)/stdc.h $(BASHINCDIR)/memalloc.h
common.o: $(topdir)/variables.h $(topdir)/input.h
common.o: $(topdir)/siglist.h $(topdir)/bashhist.h $(topdir)/quit.h
-common.o: $(topdir)/unwind_prot.h $(topdir)/maxpath.h $(topdir)/jobs.h
+common.o: $(topdir)/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 $(topdir)/pathnames.h ./builtext.h
-evalfile.o: $(topdir)/bashtypes.h $(topdir)/posixstat.h $(topdir)/filecntl.h
-evalfile.o: $(topdir)/bashansi.h $(topdir)/ansi_stdlib.h
+evalfile.o: $(topdir)/bashtypes.h $(BASHINCDIR)/posixstat.h ${BASHINCDIR}/filecntl.h
+evalfile.o: $(topdir)/bashansi.h $(BASHINCDIR)/ansi_stdlib.h
evalfile.o: $(topdir)/shell.h ../config.h $(topdir)/bashjmp.h
evalfile.o: $(topdir)/command.h $(topdir)/general.h $(topdir)/error.h
-evalfile.o: $(topdir)/variables.h $(topdir)/quit.h $(topdir)/maxpath.h
+evalfile.o: $(topdir)/variables.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: $(topdir)/pathnames.h $(topdir)/externs.h
evalfile.o: $(topdir)/jobs.h $(topdir)/builtins.h $(topdir)/flags.h
evalfile.o: $(topdir)/input.h $(topdir)/execute_cmd.h
evalfile.o: $(topdir)/bashhist.h $(srcdir)/common.h
-evalstring.o: ../config.h $(topdir)/bashansi.h $(topdir)/ansi_stdlib.h
-evalstring.o: $(topdir)/shell.h $(topdir)/bashjmp.h $(topdir)/posixjmp.h
+evalstring.o: ../config.h $(topdir)/bashansi.h $(BASHINCDIR)/ansi_stdlib.h
+evalstring.o: $(topdir)/shell.h $(topdir)/bashjmp.h $(BASHINCDIR)/posixjmp.h
evalstring.o: $(topdir)/sig.h $(topdir)/command.h $(topdir)/siglist.h
-evalstring.o: $(topdir)/memalloc.h $(topdir)/variables.h $(topdir)/input.h
+evalstring.o: $(BASHINCDIR)/memalloc.h $(topdir)/variables.h $(topdir)/input.h
evalstring.o: $(topdir)/quit.h $(topdir)/unwind_prot.h
-evalstring.o: $(topdir)/maxpath.h $(topdir)/jobs.h $(topdir)/builtins.h
+evalstring.o: $(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
-getopt.o: ../config.h $(topdir)/memalloc.h
+getopt.o: ../config.h $(BASHINCDIR)/memalloc.h
getopt.o: $(topdir)/shell.h $(topdir)/bashjmp.h $(topdir)/command.h
getopt.o: $(topdir)/general.h $(topdir)/error.h $(topdir)/variables.h
-getopt.o: $(topdir)/quit.h $(topdir)/maxpath.h $(topdir)/unwind_prot.h
+getopt.o: $(topdir)/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 $(topdir)/pathnames.h $(topdir)/externs.h
getopt.o: $(srcdir)/getopt.h
-mkbuiltins.o: ../config.h $(topdir)/bashtypes.h $(topdir)/posixstat.h
-mkbuiltins.o: $(topdir)/filecntl.h
-mkbuiltins.o: $(topdir)/bashansi.h $(topdir)/ansi_stdlib.h
+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 $(topdir)/memalloc.h
-alias.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/maxpath.h
+alias.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
+alias.o: $(topdir)/error.h $(topdir)/general.h $(BASHINCDIR)/maxpath.h
alias.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
alias.o: $(topdir)/subst.h $(topdir)/externs.h $(srcdir)/common.h
alias.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
-bind.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h $(topdir)/error.h
+bind.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h $(topdir)/error.h
bind.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
bind.o: $(topdir)/subst.h $(topdir)/externs.h $(srcdir)/bashgetopt.h
-bind.o: $(topdir)/general.h $(topdir)/maxpath.h $(topdir)/bashline.h
+bind.o: $(topdir)/general.h $(BASHINCDIR)/maxpath.h $(topdir)/bashline.h
bind.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
-break.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h
+break.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
break.o: $(topdir)/error.h $(topdir)/general.h
break.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
-break.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/maxpath.h
+break.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
break.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
-builtin.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h
+builtin.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
builtin.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/externs.h
-builtin.o: $(topdir)/quit.h $(srcdir)/common.h $(topdir)/maxpath.h
+builtin.o: $(topdir)/quit.h $(srcdir)/common.h $(BASHINCDIR)/maxpath.h
builtin.o: $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/subst.h
builtin.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
-cd.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h $(topdir)/error.h
+cd.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h $(topdir)/error.h
cd.o: $(topdir)/general.h $(topdir)/quit.h $(topdir)/dispose_cmd.h
cd.o: $(topdir)/make_cmd.h $(topdir)/subst.h $(topdir)/externs.h
cd.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
-cd.o: $(srcdir)/common.h $(topdir)/maxpath.h
-command.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h
+cd.o: $(srcdir)/common.h $(BASHINCDIR)/maxpath.h
+command.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
command.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/externs.h
-command.o: $(topdir)/quit.h $(srcdir)/bashgetopt.h $(topdir)/maxpath.h
+command.o: $(topdir)/quit.h $(srcdir)/bashgetopt.h $(BASHINCDIR)/maxpath.h
command.o: $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/subst.h
command.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
-declare.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h
+declare.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
declare.o: $(topdir)/error.h $(topdir)/general.h
declare.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
-declare.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/maxpath.h
+declare.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
declare.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
-echo.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h $(topdir)/error.h
+echo.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h $(topdir)/error.h
echo.o: $(topdir)/general.h $(topdir)/subst.h $(topdir)/externs.h
echo.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
echo.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
-echo.o: $(topdir)/maxpath.h
-enable.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h
+echo.o: $(BASHINCDIR)/maxpath.h
+enable.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
enable.o: $(topdir)/error.h $(topdir)/general.h
enable.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
enable.o: $(topdir)/subst.h $(topdir)/externs.h
enable.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
-enable.o: $(topdir)/maxpath.h
-eval.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h
+enable.o: $(BASHINCDIR)/maxpath.h
+enable.o: $(topdir)/pcomplete.h
+eval.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
eval.o: $(topdir)/error.h $(topdir)/general.h
eval.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
eval.o: $(topdir)/subst.h $(topdir)/externs.h
eval.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
-eval.o: $(topdir)/maxpath.h
+eval.o: $(BASHINCDIR)/maxpath.h
exec.o: $(topdir)/bashtypes.h
-exec.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h
+exec.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
exec.o: $(topdir)/error.h $(topdir)/general.h
exec.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
exec.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/flags.h
exec.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
-exec.o: $(srcdir)/common.h $(topdir)/execute_cmd.h $(topdir)/maxpath.h
+exec.o: $(srcdir)/common.h $(topdir)/execute_cmd.h $(BASHINCDIR)/maxpath.h
exec.o: $(topdir)/findcmd.h
exit.o: $(topdir)/bashtypes.h
-exit.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h
+exit.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
exit.o: $(topdir)/error.h $(topdir)/general.h
exit.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
exit.o: $(topdir)/subst.h $(topdir)/externs.h
exit.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
-exit.o: $(topdir)/maxpath.h ./builtext.h
-fc.o: $(topdir)/bashtypes.h $(topdir)/posixstat.h
+exit.o: $(BASHINCDIR)/maxpath.h ./builtext.h
+fc.o: $(topdir)/bashtypes.h $(BASHINCDIR)/posixstat.h
fc.o: $(topdir)/builtins.h $(topdir)/command.h $(srcdir)/bashgetopt.h
fc.o: $(topdir)/bashhist.h
-fc.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h $(topdir)/error.h
-fc.o: $(topdir)/general.h $(topdir)/maxpath.h
+fc.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h $(topdir)/error.h
+fc.o: $(topdir)/general.h $(BASHINCDIR)/maxpath.h
fc.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
fc.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/shell.h
fc.o: $(topdir)/flags.h $(topdir)/unwind_prot.h $(topdir)/variables.h
-fc.o: $(topdir)/bashansi.h $(topdir)/ansi_stdlib.h
+fc.o: $(topdir)/bashansi.h $(BASHINCDIR)/ansi_stdlib.h
fg_bg.o: $(topdir)/bashtypes.h
-fg_bg.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h
+fg_bg.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
fg_bg.o: $(topdir)/error.h $(topdir)/general.h
fg_bg.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
-fg_bg.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/maxpath.h
+fg_bg.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
fg_bg.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
-getopts.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h
+getopts.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
getopts.o: $(topdir)/error.h $(topdir)/general.h
getopts.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
-getopts.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/maxpath.h
+getopts.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
getopts.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
hash.o: $(topdir)/builtins.h $(topdir)/command.h $(topdir)/quit.h
hash.o: $(topdir)/findcmd.h $(topdir)/hashlib.h
-hash.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h
+hash.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
hash.o: $(topdir)/error.h $(topdir)/general.h
hash.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
-hash.o: $(srcdir)/common.h $(topdir)/maxpath.h
-help.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h
+hash.o: $(srcdir)/common.h $(BASHINCDIR)/maxpath.h
+help.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
help.o: $(topdir)/error.h $(topdir)/general.h
help.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
-help.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/maxpath.h
+help.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
help.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
history.o: $(topdir)/bashtypes.h
-history.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h
+history.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
history.o: $(topdir)/error.h $(topdir)/general.h
history.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
history.o: $(topdir)/subst.h $(topdir)/externs.h
-history.o: $(topdir)/filecntl.h $(topdir)/shell.h $(topdir)/unwind_prot.h
-history.o: $(topdir)/variables.h $(topdir)/bashhist.h $(topdir)/maxpath.h
-inlib.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h
+history.o: ${BASHINCDIR}/filecntl.h $(topdir)/shell.h $(topdir)/unwind_prot.h
+history.o: $(topdir)/variables.h $(topdir)/bashhist.h $(BASHINCDIR)/maxpath.h
+inlib.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
inlib.o: $(topdir)/error.h $(topdir)/general.h
inlib.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
-inlib.o: $(topdir)/maxpath.h $(topdir)/subst.h $(topdir)/externs.h
+inlib.o: $(BASHINCDIR)/maxpath.h $(topdir)/subst.h $(topdir)/externs.h
inlib.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
-jobs.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h $(topdir)/error.h
+jobs.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h $(topdir)/error.h
jobs.o: $(topdir)/general.h $(topdir)/quit.h $(srcdir)/bashgetopt.h
-jobs.o: $(topdir)/maxpath.h $(topdir)/externs.h
+jobs.o: $(BASHINCDIR)/maxpath.h $(topdir)/externs.h
jobs.o: $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/subst.h
jobs.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
-kill.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h $(topdir)/error.h
+kill.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h $(topdir)/error.h
kill.o: $(topdir)/general.h $(topdir)/subst.h $(topdir)/externs.h
kill.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
kill.o: $(topdir)/shell.h $(topdir)/trap.h $(topdir)/unwind_prot.h
-kill.o: $(topdir)/variables.h $(topdir)/maxpath.h
-let.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h
+kill.o: $(topdir)/variables.h $(BASHINCDIR)/maxpath.h
+let.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
let.o: $(topdir)/error.h $(topdir)/general.h
let.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
-let.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/maxpath.h
+let.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
let.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
-printf.o: ../config.h $(topdir)/memalloc.h $(topdir)/bashjmp.h
+printf.o: ../config.h $(BASHINCDIR)/memalloc.h $(topdir)/bashjmp.h
printf.o: $(topdir)/command.h $(topdir)/error.h $(topdir)/general.h
printf.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
printf.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/sig.h
printf.o: $(topdir)/pathnames.h $(topdir)/shell.h $(topdir)/unwind_prot.h
-printf.o: $(topdir)/variables.h $(topdir)/stdc.h $(srcdir)/bashgetopt.h
-pushd.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h
+printf.o: $(topdir)/variables.h $(BASHINCDIR)/stdc.h $(srcdir)/bashgetopt.h
+pushd.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
pushd.o: $(topdir)/error.h $(topdir)/general.h
pushd.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
pushd.o: $(topdir)/subst.h $(topdir)/externs.h
pushd.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
-pushd.o: $(topdir)/maxpath.h $(srcdir)/common.h ./builtext.h
-read.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h
+pushd.o: $(BASHINCDIR)/maxpath.h $(srcdir)/common.h ./builtext.h
+read.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
read.o: $(topdir)/error.h $(topdir)/general.h
read.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
-read.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/maxpath.h
+read.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
read.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
-return.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h
+read.o: $(BASHINCDIR)/shtty.h
+return.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
return.o: $(topdir)/error.h $(topdir)/general.h
return.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
-return.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/maxpath.h
+return.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
return.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
-set.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h
+set.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
set.o: $(topdir)/general.h $(topdir)/subst.h $(topdir)/externs.h
set.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
set.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
-set.o: $(topdir)/maxpath.h $(topdir)/error.h
-setattr.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h
-setattr.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/maxpath.h
+set.o: $(BASHINCDIR)/maxpath.h $(topdir)/error.h
+setattr.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
+setattr.o: $(topdir)/error.h $(topdir)/general.h $(BASHINCDIR)/maxpath.h
setattr.o: $(topdir)/quit.h $(srcdir)/common.h $(srcdir)/bashgetopt.h
setattr.o: $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/subst.h
setattr.o: $(topdir)/externs.h
setattr.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
-shift.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h
+shift.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
shift.o: $(topdir)/error.h $(topdir)/general.h
shift.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
-shift.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/maxpath.h
+shift.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
shift.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
-source.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h
+source.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
source.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/findcmd.h
source.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
-source.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/maxpath.h
+source.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
source.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
-suspend.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h
+suspend.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
suspend.o: $(topdir)/error.h $(topdir)/general.h
suspend.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
-suspend.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/maxpath.h
+suspend.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
suspend.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
-test.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h
+test.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
test.o: $(topdir)/error.h $(topdir)/general.h
test.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
-test.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/maxpath.h
+test.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
test.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
test.o: $(topdir)/test.h
-times.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h
+times.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
times.o: $(topdir)/error.h $(topdir)/general.h
times.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
-times.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/maxpath.h
+times.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
times.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
-trap.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h
+times.o: $(BASHINCDIR)/posixtime.h
+trap.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
trap.o: $(topdir)/error.h $(topdir)/general.h $(topdir)/externs.h
-trap.o: $(topdir)/quit.h $(srcdir)/common.h $(topdir)/maxpath.h
+trap.o: $(topdir)/quit.h $(srcdir)/common.h $(BASHINCDIR)/maxpath.h
trap.o: $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/subst.h
trap.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
trap.o: $(topdir)/findcmd.h
-type.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h
+type.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
type.o: $(topdir)/error.h $(topdir)/general.h
-type.o: $(topdir)/quit.h $(srcdir)/common.h $(topdir)/maxpath.h
+type.o: $(topdir)/quit.h $(srcdir)/common.h $(BASHINCDIR)/maxpath.h
type.o: $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h $(topdir)/subst.h
type.o: $(topdir)/externs.h $(topdir)/hashcmd.h
type.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
-ulimit.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h
+ulimit.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
ulimit.o: $(topdir)/error.h $(topdir)/general.h
ulimit.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
-ulimit.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/maxpath.h
+ulimit.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
ulimit.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
-umask.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h
+umask.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
umask.o: $(topdir)/error.h $(topdir)/general.h
umask.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
-umask.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/maxpath.h
+umask.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
umask.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
-wait.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h
+wait.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
wait.o: $(topdir)/error.h $(topdir)/general.h
wait.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
-wait.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/maxpath.h
+wait.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
wait.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
-shopt.o: $(topdir)/command.h ../config.h $(topdir)/memalloc.h
+shopt.o: $(topdir)/command.h ../config.h $(BASHINCDIR)/memalloc.h
shopt.o: $(topdir)/error.h $(topdir)/general.h
shopt.o: $(topdir)/quit.h $(topdir)/dispose_cmd.h $(topdir)/make_cmd.h
-shopt.o: $(topdir)/subst.h $(topdir)/externs.h $(topdir)/maxpath.h
+shopt.o: $(topdir)/subst.h $(topdir)/externs.h $(BASHINCDIR)/maxpath.h
shopt.o: $(topdir)/shell.h $(topdir)/unwind_prot.h $(topdir)/variables.h
shopt.o: $(srcdir)/common.h $(srcdir)/bashgetopt.h
+complete.o: ../config.h
+complete.o: ${topdir}/shell.h ${topdir}/bashjmp.h ${BASHINCDIR}/posixjmp.h ${topdir}/sig.h
+complete.o: ${topdir}/unwind_prot.h ${topdir}/variables.h
+complete.o: ${topdir}/bashtypes.h ${topdir}/bashansi.h ${BASHINCDIR}/ansi_stdlib.h
+complete.o: ${topdir}/builtins.h
+complete.o: ${topdir}/pcomplete.h
+complete.o: ${srcdir}/common.h ${srcdir}/bashgetopt.h
+
#bind.o: $(RL_LIBSRC)chardefs.h $(RL_LIBSRC)readline.h $(RL_LIBSRC)keymaps.h
diff --git a/builtins/alias.def b/builtins/alias.def
index dec72f64..50e7ffcc 100644
--- a/builtins/alias.def
+++ b/builtins/alias.def
@@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 1, or (at your option) any later
+Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$BUILTIN alias
$FUNCTION alias_builtin
diff --git a/builtins/bashgetopt.c b/builtins/bashgetopt.c
index 65b8d087..17bb5782 100644
--- a/builtins/bashgetopt.c
+++ b/builtins/bashgetopt.c
@@ -6,7 +6,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 1, or (at your option) any later
+Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -16,7 +16,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#include <config.h>
diff --git a/builtins/bashgetopt.h b/builtins/bashgetopt.h
index 0360dbb8..773fc000 100644
--- a/builtins/bashgetopt.h
+++ b/builtins/bashgetopt.h
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
/* See getopt.h for the explanation of these variables. */
diff --git a/builtins/bind.def b/builtins/bind.def
index 6b8ac56b..5adfe381 100644
--- a/builtins/bind.def
+++ b/builtins/bind.def
@@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 1, or (at your option) any later
+Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$PRODUCES bind.c
@@ -26,7 +26,7 @@ $PRODUCES bind.c
$BUILTIN bind
$DEPENDS_ON READLINE
$FUNCTION bind_builtin
-$SHORT_DOC bind [-lpvsPVS] [-m keymap] [-f filename] [-q name] [-u name] [-r keyseq] [keyseq:readline-function]
+$SHORT_DOC bind [-lpvsPVS] [-m keymap] [-f filename] [-q name] [-u name] [-r keyseq] [-x keyseq:shell-command] [keyseq:readline-function]
Bind a key sequence to a Readline function, or to a macro. The
syntax is equivalent to that found in ~/.inputrc, but must be
passed as a single argument: bind '"\C-x\C-r": re-read-init-file'.
@@ -40,6 +40,8 @@ Arguments we accept:
-p List functions and bindings in a form that can be
reused as input.
-r keyseq Remove the binding for KEYSEQ.
+ -x keyseq:shell-command Cause SHELL-COMMAND to be executed when KEYSEQ
+ is entered.
-f filename Read key bindings from FILENAME.
-q function-name Query about which keys invoke the named function.
-u function-name Unbind all keys which are bound to the named function.
@@ -93,6 +95,7 @@ extern int no_line_editing;
#define SFLAG 0x0200
#define SSFLAG 0x0400
#define UFLAG 0x0800
+#define XFLAG 0x1000
int
bind_builtin (list)
@@ -102,7 +105,7 @@ bind_builtin (list)
FILE *old_rl_outstream;
Keymap kmap, saved_keymap;
int flags, opt;
- char *initfile, *map_name, *fun_name, *unbind_name, *remove_seq;
+ char *initfile, *map_name, *fun_name, *unbind_name, *remove_seq, *cmd_seq;
if (no_line_editing)
return (EXECUTION_FAILURE);
@@ -122,7 +125,7 @@ bind_builtin (list)
rl_outstream = stdout;
reset_internal_getopt ();
- while ((opt = internal_getopt (list, "lvpVPsSf:q:u:m:r:")) != EOF)
+ while ((opt = internal_getopt (list, "lvpVPsSf:q:u:m:r:x:")) != EOF)
{
switch (opt)
{
@@ -167,6 +170,10 @@ bind_builtin (list)
case 'S':
flags |= SSFLAG;
break;
+ case 'x':
+ flags |= XFLAG;
+ cmd_seq = list_optarg;
+ break;
default:
builtin_usage ();
BIND_RETURN (EX_USAGE);
@@ -242,6 +249,9 @@ bind_builtin (list)
}
}
+ if (flags & XFLAG)
+ return_code = bind_keyseq_to_unix_command (cmd_seq);
+
/* Process the rest of the arguments as binding specifications. */
while (list)
{
diff --git a/builtins/break.def b/builtins/break.def
index e99d136a..d996536d 100644
--- a/builtins/break.def
+++ b/builtins/break.def
@@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 1, or (at your option) any later
+Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$PRODUCES break.c
diff --git a/builtins/builtin.def b/builtins/builtin.def
index b18960c9..21dbb59e 100644
--- a/builtins/builtin.def
+++ b/builtins/builtin.def
@@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 1, or (at your option) any later
+Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$PRODUCES builtin.c
diff --git a/builtins/cd.def b/builtins/cd.def
index b6bf692f..47616230 100644
--- a/builtins/cd.def
+++ b/builtins/cd.def
@@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 1, or (at your option) any later
+Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$PRODUCES cd.c
#include <config.h>
@@ -30,8 +30,8 @@ $PRODUCES cd.c
#endif
#include "../bashtypes.h"
-#include "../posixdir.h"
-#include "../posixstat.h"
+#include "posixdir.h"
+#include "posixstat.h"
#ifndef _MINIX
#include <sys/param.h>
#endif
@@ -45,7 +45,7 @@ $PRODUCES cd.c
#include "../shell.h"
#include "../flags.h"
-#include "../maxpath.h"
+#include "maxpath.h"
#include "common.h"
#include "bashgetopt.h"
@@ -83,45 +83,6 @@ instead of following symbolic links; the -L option forces symbolic links
to be followed.
$END
-/* Take PATH, an element from $CDPATH, and DIR, a directory name, and paste
- them together into PATH/DIR. Tilde expansion is performed on PATH if
- DOTILDE is non-zero. If PATH is the empty string, it is converted to
- `./', since a null element in $CDPATH means the current directory. */
-static char *
-mkpath (path, dir, dotilde)
- char *path, *dir;
- int dotilde;
-{
- int dirlen, pathlen;
- char *ret, *xpath;
-
- if (*path == '\0')
- {
- xpath = xmalloc (2);
- xpath[0] = '.';
- xpath[1] = '\0';
- pathlen = 1;
- }
- else
- {
- xpath = (dotilde && *path == '~') ? bash_tilde_expand (path) : path;
- pathlen = strlen (xpath);
- }
-
- dirlen = strlen (dir);
- ret = xmalloc (2 + dirlen + pathlen);
- strcpy (ret, xpath);
- if (xpath[pathlen - 1] != '/')
- {
- ret[pathlen++] = '/';
- ret[pathlen] = '\0';
- }
- strcpy (ret + pathlen, dir);
- if (xpath != path)
- free (xpath);
- return (ret);
-}
-
static int
bindpwd (no_symlinks)
int no_symlinks;
@@ -245,7 +206,7 @@ cd_builtin (list)
{
/* OPT is 1 if the path element is non-empty */
opt = path[0] != '\0';
- temp = mkpath (path, dirname, 1);
+ temp = sh_makepath (path, dirname, MP_DOTILDE);
free (path);
if (stat (temp, &sb) < 0 || S_ISDIR (sb.st_mode) == 0)
diff --git a/builtins/colon.def b/builtins/colon.def
index 7fd96566..e00428d5 100644
--- a/builtins/colon.def
+++ b/builtins/colon.def
@@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 1, or (at your option) any later
+Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$PRODUCES colon.c
diff --git a/builtins/command.def b/builtins/command.def
index 415b6d15..a3f25f2f 100644
--- a/builtins/command.def
+++ b/builtins/command.def
@@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 1, or (at your option) any later
+Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$PRODUCES command.c
diff --git a/builtins/common.c b/builtins/common.c
index 696901e0..a92e4d90 100644
--- a/builtins/common.c
+++ b/builtins/common.c
@@ -4,7 +4,7 @@
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
- Software Foundation; either version 1, or (at your option) any later
+ Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -14,7 +14,7 @@
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#include <config.h>
@@ -27,7 +27,7 @@
#include <stdio.h>
#include "../bashtypes.h"
-#include "../posixstat.h"
+#include "posixstat.h"
#include <signal.h>
#include <errno.h>
@@ -43,7 +43,7 @@
#include "../bashansi.h"
#include "../shell.h"
-#include "../maxpath.h"
+#include "maxpath.h"
#include "../flags.h"
#include "../jobs.h"
#include "../builtins.h"
@@ -63,6 +63,12 @@
extern int errno;
#endif /* !errno */
+#ifdef __STDC__
+typedef int QSFUNC (const void *, const void *);
+#else
+typedef int QSFUNC ();
+#endif
+
extern int no_symbolic_links, interactive, interactive_shell;
extern int indirection_level, startup_state, subshell_environment;
extern int line_number;
@@ -462,7 +468,7 @@ get_job_spec (list)
if (digit (*word) && all_digits (word))
{
job = atoi (word);
- return (job - 1);
+ return (job >= job_slots ? NO_JOB : job - 1);
}
substring = 0;
@@ -701,13 +707,8 @@ shell_builtin_compare (sbp1, sbp2)
void
initialize_shell_builtins ()
{
-#ifdef _MINIX
- qsort (shell_builtins, num_shell_builtins, sizeof (struct builtin),
- (int (*)(const void *, const void *))shell_builtin_compare);
-#else
qsort (shell_builtins, num_shell_builtins, sizeof (struct builtin),
- shell_builtin_compare);
-#endif
+ (QSFUNC *)shell_builtin_compare);
}
/* **************************************************************** */
@@ -767,6 +768,7 @@ double_quote (string)
case '$':
case '`':
case '\\':
+ case '\n': /* XXX */
*r++ = '\\';
default:
*r++ = c;
@@ -780,6 +782,37 @@ double_quote (string)
return (result);
}
+/* Remove backslashes that are quoting characters that are special between
+ double quotes. Return a new string. */
+char *
+un_double_quote (string)
+ char *string;
+{
+ register int c, pass_next;
+ char *result, *r, *s;
+
+ r = result = xmalloc (strlen (string) + 1);
+
+ for (pass_next = 0, s = string; s && (c = *s); s++)
+ {
+ if (pass_next)
+ {
+ *r++ = c;
+ pass_next = 0;
+ continue;
+ }
+ if (c == '\\' && strchr (slashify_in_quotes, s[1]))
+ {
+ pass_next = 1;
+ continue;
+ }
+ *r++ = c;
+ }
+
+ *r = '\0';
+ return result;
+}
+
/* Quote special characters in STRING using backslashes. Return a new
string. */
char *
@@ -827,6 +860,41 @@ backslash_quote (string)
return (result);
}
+#if defined (PROMPT_STRING_DECODE)
+/* Quote characters that get special treatment when in double quotes in STRING
+ using backslashes. Return a new string. */
+char *
+backslash_quote_for_double_quotes (string)
+ char *string;
+{
+ int c;
+ char *result, *r, *s;
+
+ result = xmalloc (2 * strlen (string) + 1);
+
+ for (r = result, s = string; s && (c = *s); s++)
+ {
+ switch (c)
+ {
+ case '"':
+ case '$':
+ case '`':
+ case '\\':
+ case '\n':
+ *r++ = '\\';
+ *r++ = c;
+ break;
+ default:
+ *r++ = c;
+ break;
+ }
+ }
+
+ *r = '\0';
+ return (result);
+}
+#endif /* PROMPT_STRING_DECODE */
+
int
contains_shell_metas (string)
char *string;
diff --git a/builtins/common.h b/builtins/common.h
index f6fa101d..1404354d 100644
--- a/builtins/common.h
+++ b/builtins/common.h
@@ -16,12 +16,12 @@
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if !defined (__COMMON_H)
# define __COMMON_H
-#include "../stdc.h"
+#include "stdc.h"
#define ISOPTION(s, c) (s[0] == '-' && !s[2] && s[1] == c)
@@ -72,7 +72,9 @@ extern void initialize_shell_builtins __P((void));
extern char *single_quote __P((char *));
extern char *double_quote __P((char *));
+extern char *un_double_quote __P((char *));
extern char *backslash_quote __P((char *));
+extern char *backslash_quote_for_double_quotes __P((char *));
extern int contains_shell_metas __P((char *));
/* Functions from set.def */
@@ -81,9 +83,11 @@ extern void list_minus_o_opts __P((int, int));
extern int set_minus_o_option __P((int, char *));
extern int minus_o_option_value __P((char *));
extern void reset_shell_options __P((void));
+extern char **get_minus_o_opts __P((void));
/* Functions from shopt.def */
extern void reset_shopt_options __P((void));
+extern char **get_shopt_options __P((void));
/* Functions from type.def */
extern int describe_command __P((char *, int, int));
diff --git a/builtins/complete.def b/builtins/complete.def
new file mode 100644
index 00000000..6ff29f14
--- /dev/null
+++ b/builtins/complete.def
@@ -0,0 +1,512 @@
+This file is complete.def, from which is created complete.c.
+It implements the builtins "complete" and "compgen" in Bash.
+
+Copyright (C) 1999 Free Software Foundation, Inc.
+
+This file is part of GNU Bash, the Bourne Again SHell.
+
+Bash is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2, or (at your option) any later
+version.
+
+Bash is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License along
+with Bash; see the file COPYING. If not, write to the Free Software
+Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
+
+$PRODUCES complete.c
+
+$BUILTIN complete
+$DEPENDS_ON PROGRAMMABLE_COMPLETION
+$FUNCTION complete_builtin
+$SHORT_DOC complete [-abcdefjkvu] [-pr] [-A action] [-G globpat] [-W wordlist] [-P prefix] [-S suffix] [-X filterpat] [-F function] [-C command] [name ...]
+For each NAME, specify how arguments are to be completed.
+If the -p option is supplied, or if no options are supplied, existing
+completion specifications are printed in a way that allows them to be
+reused as input. The -r option removes a completion specification for
+each NAME, or, if no NAMEs are supplied, all completion specifications.
+$END
+
+#include <config.h>
+
+#include <stdio.h>
+
+#include "../bashtypes.h"
+
+#if defined (HAVE_UNISTD_H)
+# include <unistd.h>
+#endif
+
+#include "../bashansi.h"
+
+#include "../shell.h"
+#include "../builtins.h"
+#include "../pcomplete.h"
+
+#include "common.h"
+#include "bashgetopt.h"
+
+#define STRDUP(x) ((x) ? savestring (x) : (char *)NULL)
+
+static int remove_cmd_completions ();
+
+static void print_all_completions ();
+static int print_cmd_completions ();
+
+static char *Aarg, *Garg, *Warg, *Parg, *Sarg, *Xarg, *Farg, *Carg;
+
+static struct _compacts {
+ char *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_BUILTIN, 0 }, /* for now */
+ { "hostname", CA_HOSTNAME, 0 },
+ { "job", CA_JOB, 'j' },
+ { "keyword", CA_KEYWORD, 'k' },
+ { "running", CA_RUNNING, 0 },
+ { "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 },
+};
+
+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;
+}
+
+/* Build the actions from the options specified in LIST. ACTP is a pointer
+ to an unsigned long in which to place the bitmap of actions. PP, if
+ non-null, gets 1 if -p is supplied; RP, if non-null, gets 1 if -r is
+ supplied. If either is null, the corresponding option generates an
+ error. This also sets variables corresponding to options that take
+ arguments as a side effect; the caller should ensure that those variables
+ are set to NULL before calling build_actions. Return value:
+ EX_USAGE = bad option
+ EXECUTION_SUCCESS = some options supplied
+ EXECUTION_FAILURE = no options supplied
+*/
+
+static int
+build_actions (list, pp, rp, actp)
+ WORD_LIST *list;
+ int *pp, *rp;
+ unsigned long *actp;
+{
+ int opt, ind, pflag, rflag, opt_given;
+ unsigned long acts;
+
+ acts = (unsigned long)0L;
+ opt_given = 0;
+
+ reset_internal_getopt ();
+ while ((opt = internal_getopt (list, "abcdefjkpruvA:G:W:P:S:X:F:C:")) != -1)
+ {
+ opt_given = 1;
+ switch (opt)
+ {
+ case 'r':
+ if (rp)
+ {
+ *rp = 1;
+ break;
+ }
+ else
+ {
+ builtin_error ("illegal option: -r");
+ builtin_usage ();
+ return (EX_USAGE);
+ }
+
+ case 'p':
+ if (pp)
+ {
+ *pp = 1;
+ break;
+ }
+ else
+ {
+ builtin_error ("illegal option: -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 'j':
+ acts |= CA_JOB;
+ break;
+ case 'k':
+ acts |= CA_KEYWORD;
+ break;
+ case 'u':
+ acts |= CA_USER;
+ break;
+ case 'v':
+ acts |= CA_VARIABLE;
+ 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 '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;
+ default:
+ builtin_usage ();
+ return (EX_USAGE);
+ }
+ }
+
+ *actp = acts;
+ return (opt_given ? EXECUTION_SUCCESS : EXECUTION_FAILURE);
+}
+
+/* Add, remove, and display completion specifiers. */
+int
+complete_builtin (list)
+ WORD_LIST *list;
+{
+ int opt_given, pflag, rflag, rval;
+ unsigned long acts;
+ char *cmd;
+ COMPSPEC *cs;
+
+ if (list == 0)
+ {
+ print_all_completions ();
+ return (EXECUTION_SUCCESS);
+ }
+
+ opt_given = pflag = rflag = 0;
+ acts = (unsigned long)0L;
+ Aarg = Garg = Warg = Parg = Sarg = Xarg = Farg = Carg = (char *)NULL;
+ cs = (COMPSPEC *)NULL;
+
+ /* Build the actions from the arguments. Also sets the [A-Z]arg variables
+ as a side effect if they are supplied as options. */
+ rval = build_actions (list, &pflag, &rflag, &acts);
+ if (rval == EX_USAGE)
+ return (rval);
+ opt_given = rval != EXECUTION_FAILURE;
+
+ list = loptend;
+
+ /* -p overrides everything else */
+ if (pflag || (list == 0 && opt_given == 0))
+ {
+ if (list == 0)
+ {
+ print_all_completions ();
+ return (EXECUTION_SUCCESS);
+ }
+ return (print_cmd_completions (list));
+ }
+
+ /* next, -r overrides everything else. */
+ if (rflag)
+ {
+ if (list == 0)
+ {
+ clear_progcomps ();
+ return (EXECUTION_SUCCESS);
+ }
+ return (remove_cmd_completions (list));
+ }
+
+ if (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 = alloc_compspec ();
+ cs->actions = acts;
+
+ 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 ; list; list = list->next)
+ {
+ /* Add CS as the compspec for the specified commands. */
+ cmd = list->word->word;
+ if (add_progcomp (cmd, cs) == 0)
+ rval = EXECUTION_FAILURE;
+ }
+
+ 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 (remove_progcomp (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 = 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)
+
+static void
+print_one_completion (cmd, cs)
+ char *cmd;
+ COMPSPEC *cs;
+{
+ unsigned long acts;
+ char *x;
+
+ printf ("complete ");
+
+ acts = cs->actions;
+
+ /* simple flags first */
+ 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_KEYWORD, "-k");
+ PRINTOPT (CA_JOB, "-j");
+ 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");
+
+ /* simple arguments that don't require quoting */
+ PRINTARG (cs->funcname, "-F");
+ PRINTARG (cs->command, "-C");
+
+ printf ("%s\n", cmd);
+}
+
+static void
+print_all_completions ()
+{
+ print_all_compspecs (print_one_completion);
+}
+
+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 = find_compspec (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 (ret);
+}
+
+$BUILTIN compgen
+$DEPENDS_ON PROGRAMMABLE_COMPLETION
+$FUNCTION compgen_builtin
+$SHORT_DOC compgen [-abcdefjkvu] [-A action] [-G globpat] [-W wordlist] [-P prefix] [-S suffix] [-X filterpat] [-F function] [-C command] [word]
+Display the possible completions depending on the options. Intended
+to be used from within a shell function generating possible completions.
+If the optional WORD argument is supplied, matches against WORD are
+generated.
+$END
+
+int
+compgen_builtin (list)
+ WORD_LIST *list;
+{
+ int rval;
+ unsigned long acts;
+ COMPSPEC *cs;
+ STRINGLIST *sl;
+ char *word;
+
+ if (list == 0)
+ return (EXECUTION_SUCCESS);
+
+ acts = (unsigned long)0L;
+ Aarg = Garg = Warg = Parg = Sarg = Xarg = Farg = Carg = (char *)NULL;
+ cs = (COMPSPEC *)NULL;
+
+ /* Build the actions from the arguments. Also sets the [A-Z]arg variables
+ as a side effect if they are supplied as options. */
+ rval = build_actions (list, (int *)NULL, (int *)NULL, &acts);
+ if (rval == EX_USAGE)
+ return (rval);
+ if (rval == EXECUTION_FAILURE)
+ return (EXECUTION_SUCCESS);
+
+ list = loptend;
+
+ word = (list && list->word) ? list->word->word : "";
+
+ if (Farg)
+ internal_warning ("compgen: -F option may not work as you expect");
+ if (Carg)
+ internal_warning ("compgen: -C option may not work as you expect");
+
+ /* If we get here, we need to build a compspec and evaluate it. */
+ cs = alloc_compspec ();
+ cs->actions = acts;
+ 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);
+ if (sl)
+ {
+ if (sl->list)
+ {
+ rval = EXECUTION_SUCCESS;
+ print_stringlist (sl, (char *)NULL);
+ }
+ free_stringlist (sl);
+ }
+
+ free_compspec (cs);
+ return (rval);
+}
diff --git a/builtins/declare.def b/builtins/declare.def
index 3bdca64c..c6664d98 100644
--- a/builtins/declare.def
+++ b/builtins/declare.def
@@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 1, or (at your option) any later
+Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$PRODUCES declare.c
@@ -255,10 +255,15 @@ declare_internal (list, local_var)
{
#if defined (ARRAY_VARS)
if ((flags_on & att_array) || making_array_special)
- make_local_array_variable (name);
+ var = make_local_array_variable (name);
else
#endif
- make_local_variable (name);
+ var = make_local_variable (name);
+ if (var == 0)
+ {
+ any_failed++;
+ NEXT_VARIABLE ();
+ }
}
/* If we are declaring a function, then complain about it in some way.
@@ -297,8 +302,8 @@ declare_internal (list, local_var)
}
else /* declare -[fF] -[rx] name [name...] */
{
- var->attributes |= flags_on;
- var->attributes &= ~flags_off;
+ VSETATTR (var, flags_on);
+ VUNSETATTR (var, flags_off);
}
}
else
@@ -364,22 +369,18 @@ declare_internal (list, local_var)
var = convert_var_to_array (var);
#endif /* ARRAY_VARS */
- var->attributes |= flags_on;
- var->attributes &= ~flags_off;
+ VSETATTR (var, flags_on);
+ VUNSETATTR (var, flags_off);
#if defined (ARRAY_VARS)
if (offset && assigning_array_special)
assign_array_var_from_string (var, value);
else
#endif
- /* This essentially duplicates the internals of bind_variable() */
+ /* bind_variable_value duplicates the essential internals of
+ bind_variable() */
if (offset)
- {
- var->attributes &= ~att_invisible;
- t = make_variable_value (var, value);
- FREE (var->value);
- var->value = t;
- }
+ bind_variable_value (var, value);
/* If we found this variable in the temporary environment, as with
`var=value declare -x var', make sure it is treated identically
diff --git a/builtins/echo.def b/builtins/echo.def
index e8b6edb2..e1015b33 100644
--- a/builtins/echo.def
+++ b/builtins/echo.def
@@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 1, or (at your option) any later
+Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$PRODUCES echo.c
#include <config.h>
@@ -67,6 +67,17 @@ $END
# 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)
+int xpg_echo = 1;
+#else
+int xpg_echo = 0;
+#endif /* DEFAULT_ECHO_TO_XPG */
+
/* 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. */
@@ -77,15 +88,7 @@ echo_builtin (list)
int display_return, do_v9, i, len;
char *temp, *s;
-#if defined (DEFAULT_ECHO_TO_USG)
-/* System V machines already have a /bin/sh with a v9 behaviour. We
- give Bash the identical behaviour for these machines so that the
- existing system shells won't barf. */
- do_v9 = 1;
-#else
- do_v9 = 0;
-#endif /* DEFAULT_ECHO_TO_USG */
-
+ do_v9 = xpg_echo;
display_return = 1;
for (; list && (temp = list->word->word) && *temp == '-'; list = list->next)
@@ -133,7 +136,7 @@ just_echo:
while (list)
{
i = len = 0;
- temp = do_v9 ? ansicstr (list->word->word, STRLEN (list->word->word), &i, &len)
+ temp = do_v9 ? ansicstr (list->word->word, STRLEN (list->word->word), 1, &i, &len)
: list->word->word;
if (temp)
{
@@ -163,5 +166,10 @@ just_echo:
if (display_return)
putchar ('\n');
fflush (stdout);
+ if (ferror (stdout))
+ {
+ clearerr (stdout);
+ return (EXECUTION_FAILURE);
+ }
return (EXECUTION_SUCCESS);
}
diff --git a/builtins/enable.def b/builtins/enable.def
index 20842d5a..0f701a27 100644
--- a/builtins/enable.def
+++ b/builtins/enable.def
@@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 1, or (at your option) any later
+Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$PRODUCES enable.c
@@ -56,6 +56,10 @@ $END
#include "common.h"
#include "bashgetopt.h"
+#if defined (PROGRAMMABLE_COMPLETION)
+# include "../pcomplete.h"
+#endif
+
#if defined (HAVE_DLOPEN) && defined (HAVE_DLSYM)
static int dyn_load_builtin ();
#endif
@@ -163,6 +167,9 @@ enable_builtin (list)
filter |= SPECIAL;
result = dyn_load_builtin (list, filter, filename);
+#if defined (PROGRAMMABLE_COMPLETION)
+ set_itemlist_dirty (&it_builtins);
+#endif
}
#endif
#if defined (HAVE_DLCLOSE)
@@ -175,6 +182,9 @@ enable_builtin (list)
result = EXECUTION_FAILURE;
list = list->next;
}
+#if defined (PROGRAMMABLE_COMPLETION)
+ set_itemlist_dirty (&it_builtins);
+#endif
}
#endif
else
@@ -237,6 +247,11 @@ enable_shell_command (name, disable_p)
else
b->flags |= BUILTIN_ENABLED;
+#if defined (PROGRAMMABLE_COMPLETION)
+ set_itemlist_dirty (&it_enabled);
+ set_itemlist_dirty (&it_disabled);
+#endif
+
return (EXECUTION_SUCCESS);
}
diff --git a/builtins/eval.def b/builtins/eval.def
index c37b99a4..db48e129 100644
--- a/builtins/eval.def
+++ b/builtins/eval.def
@@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 1, or (at your option) any later
+Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$PRODUCES eval.c
diff --git a/builtins/evalfile.c b/builtins/evalfile.c
index bb3217d3..dad987ae 100644
--- a/builtins/evalfile.c
+++ b/builtins/evalfile.c
@@ -4,7 +4,7 @@
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
- Software Foundation; either version 1, or (at your option) any later
+ Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -14,7 +14,7 @@
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#include <config.h>
@@ -23,8 +23,8 @@
#endif
#include "../bashtypes.h"
-#include "../posixstat.h"
-#include "../filecntl.h"
+#include "posixstat.h"
+#include "filecntl.h"
#include <stdio.h>
#include <signal.h>
diff --git a/builtins/evalstring.c b/builtins/evalstring.c
index 56d2e1bc..37516bb6 100644
--- a/builtins/evalstring.c
+++ b/builtins/evalstring.c
@@ -4,7 +4,7 @@
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
- Software Foundation; either version 1, or (at your option) any later
+ Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -14,7 +14,7 @@
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#include <config.h>
@@ -30,7 +30,7 @@
#include <errno.h>
-#include "../filecntl.h"
+#include "filecntl.h"
#include "../bashansi.h"
#include "../shell.h"
@@ -54,6 +54,7 @@ extern int errno;
#define IS_BUILTIN(s) (builtin_address_internal(s, 0) != (struct builtin *)NULL)
extern void run_trap_cleanup ();
+extern int zwrite ();
extern int interactive, interactive_shell;
extern int indirection_level, startup_state, subshell_environment;
@@ -94,7 +95,7 @@ parse_and_execute (string, from_file, flags)
char *from_file;
int flags;
{
- int code;
+ int code, x;
volatile int should_jump_to_top_level, last_result;
char *orig_string;
COMMAND *volatile command;
@@ -119,6 +120,12 @@ parse_and_execute (string, from_file, flags)
# endif /* BANG_HISTORY */
#endif /* HISTORY */
+ if (interactive_shell)
+ {
+ x = get_current_prompt_level ();
+ add_unwind_protect (set_current_prompt_level, x);
+ }
+
add_unwind_protect (pop_stream, (char *)NULL);
if (orig_string)
add_unwind_protect (xfree, orig_string);
@@ -282,36 +289,6 @@ parse_and_execute (string, from_file, flags)
return (last_result);
}
-/* Write NB bytes from BUF to file descriptor FD, retrying the write if
- it is interrupted. We retry three times if we get a zero-length
- write. Any other signal causes this function to return prematurely. */
-static int
-zwrite (fd, buf, nb)
- int fd;
- unsigned char *buf;
- int nb;
-{
- int n, i, nt;
-
- for (n = nb, nt = 0;;)
- {
- i = write (fd, buf, n);
- if (i > 0)
- {
- n -= i;
- if (n <= 0)
- return nb;
- }
- else if (i == 0)
- {
- if (++nt > 3)
- return (nb - n);
- }
- else if (errno != EINTR)
- return -1;
- }
-}
-
/* Handle a $( < file ) command substitution. This expands the filename,
returning errors as appropriate, then just cats the file to the standard
output. */
@@ -349,10 +326,7 @@ cat_file (r)
rval = 0;
while (1)
{
- /* Retry the reads on EINTR. Any other error causes a break from the
- loop. */
- while ((nr = read (fd, lbuf, sizeof(lbuf))) < 0 && errno == EINTR)
- ;
+ nr = zread (fd, lbuf, sizeof(lbuf));
if (nr == 0)
break;
else if (nr < 0)
diff --git a/builtins/exec.def b/builtins/exec.def
index d7166d78..d578b635 100644
--- a/builtins/exec.def
+++ b/builtins/exec.def
@@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 1, or (at your option) any later
+Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$PRODUCES exec.c
@@ -37,7 +37,7 @@ $END
#include <config.h>
#include "../bashtypes.h"
-#include "../posixstat.h"
+#include "posixstat.h"
#include <signal.h>
#include <errno.h>
diff --git a/builtins/exit.def b/builtins/exit.def
index 37f1d7bf..5ebb8776 100644
--- a/builtins/exit.def
+++ b/builtins/exit.def
@@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 1, or (at your option) any later
+Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$PRODUCES exit.c
diff --git a/builtins/fc.def b/builtins/fc.def
index 064420ba..0c30ebb3 100644
--- a/builtins/fc.def
+++ b/builtins/fc.def
@@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 1, or (at your option) any later
+Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$PRODUCES fc.c
@@ -53,7 +53,7 @@ $END
# include <sys/param.h>
#endif
#include "../bashtypes.h"
-#include "../posixstat.h"
+#include "posixstat.h"
#ifndef _MINIX
# include <sys/file.h>
#endif
@@ -70,8 +70,8 @@ $END
#include "../shell.h"
#include "../builtins.h"
#include "../flags.h"
-#include "../maxpath.h"
#include "../bashhist.h"
+#include "maxpath.h"
#include <readline/history.h>
#include "bashgetopt.h"
#include "common.h"
diff --git a/builtins/fg_bg.def b/builtins/fg_bg.def
index 2f1b826c..0a694f3a 100644
--- a/builtins/fg_bg.def
+++ b/builtins/fg_bg.def
@@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 1, or (at your option) any later
+Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$PRODUCES fg_bg.c
diff --git a/builtins/getopt.c b/builtins/getopt.c
index ff44340a..6ea34018 100644
--- a/builtins/getopt.c
+++ b/builtins/getopt.c
@@ -15,7 +15,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#include <config.h>
@@ -27,7 +27,7 @@
#endif
#include <stdio.h>
-#include "../memalloc.h"
+#include "memalloc.h"
#include "../shell.h"
#include "getopt.h"
diff --git a/builtins/getopt.h b/builtins/getopt.h
index cf5854ac..997bfd72 100644
--- a/builtins/getopt.h
+++ b/builtins/getopt.h
@@ -13,7 +13,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
/* XXX THIS HAS BEEN MODIFIED FOR INCORPORATION INTO BASH XXX */
diff --git a/builtins/getopts.def b/builtins/getopts.def
index 941b666f..dcd4ec3d 100644
--- a/builtins/getopts.def
+++ b/builtins/getopts.def
@@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 1, or (at your option) any later
+Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$PRODUCES getopts.c
@@ -194,7 +194,7 @@ dogetopts (argc, argv)
;
for (words = rest_of_args; words; words = words->next, i++)
;
- v = (char **)xmalloc ((i + 1) * sizeof (char *));
+ v = alloc_array (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++)
diff --git a/builtins/hash.def b/builtins/hash.def
index f601c10d..8fa96536 100644
--- a/builtins/hash.def
+++ b/builtins/hash.def
@@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 1, or (at your option) any later
+Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$PRODUCES hash.c
@@ -106,6 +106,14 @@ hash_builtin (list)
if (expunge_hash_table)
flush_hashed_filenames ();
+#if defined (RESTRICTED_SHELL)
+ if (restricted && pathname && strchr (pathname, '/'))
+ {
+ builtin_error ("%s: restricted", pathname);
+ return (EXECUTION_FAILURE);
+ }
+#endif
+
for (opt = EXECUTION_SUCCESS; list; list = list->next)
{
/* Add or rehash the specified commands. */
diff --git a/builtins/help.def b/builtins/help.def
index cd59d3c3..43822296 100644
--- a/builtins/help.def
+++ b/builtins/help.def
@@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 1, or (at your option) any later
+Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -17,17 +17,19 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$PRODUCES help.c
$BUILTIN help
$FUNCTION help_builtin
$DEPENDS_ON HELP_BUILTIN
-$SHORT_DOC help [pattern ...]
+$SHORT_DOC help [-s] [pattern ...]
Display helpful information about builtin commands. If PATTERN is
specified, gives detailed help on all commands matching PATTERN,
-otherwise a list of the builtins is printed.
+otherwise a list of the builtins is printed. The -s option
+restricts the output for each builtin command matching PATTERN to
+a short usage synopsis.
$END
#include <config.h>
@@ -64,14 +66,17 @@ help_builtin (list)
{
register int i, j;
char *pattern, *name;
- int plen, match_found;
+ int plen, match_found, sflag;
- /* Placeholder for future options. */
+ sflag = 0;
reset_internal_getopt ();
- while ((i = internal_getopt (list, "")) != -1)
+ while ((i = internal_getopt (list, "s")) != -1)
{
switch (i)
{
+ case 's':
+ sflag = 1;
+ break;
default:
builtin_usage ();
return (EX_USAGE);
@@ -108,8 +113,9 @@ help_builtin (list)
{
printf ("%s: %s\n", name, shell_builtins[i].short_doc);
- for (j = 0; shell_builtins[i].long_doc[j]; j++)
- printf (" %s\n", shell_builtins[i].long_doc[j]);
+ if (sflag == 0)
+ for (j = 0; shell_builtins[i].long_doc[j]; j++)
+ printf (" %s\n", shell_builtins[i].long_doc[j]);
match_found++;
}
diff --git a/builtins/history.def b/builtins/history.def
index 92094d68..07c08f36 100644
--- a/builtins/history.def
+++ b/builtins/history.def
@@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 1, or (at your option) any later
+Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -17,18 +17,19 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$PRODUCES history.c
$BUILTIN history
$FUNCTION history_builtin
$DEPENDS_ON HISTORY
-$SHORT_DOC history [-c] [n] or history -awrn [filename] or history -ps arg [arg...]
+$SHORT_DOC history [-c] [-d offset] [n] or history -awrn [filename] or history -ps arg [arg...]
Display the history list with line numbers. Lines listed with
with a `*' have been modified. Argument of N says to list only
-the last N lines. The -c option causes the history list to be
-cleared by deleting all of the entries. The `-w' option writes out the
+the last N lines. The `-c' option causes the history list to be
+cleared by deleting all of the entries. The `-d' option deletes
+the history entry at offset OFFSET. The `-w' option writes out the
current history to the history file; `-r' means to read the file and
append the contents to the history list instead. `-a' means
to append history lines from this session to the history file.
@@ -49,8 +50,8 @@ $END
#ifndef _MINIX
# include <sys/file.h>
#endif
-#include "../posixstat.h"
-#include "../filecntl.h"
+#include "posixstat.h"
+#include "filecntl.h"
#include <errno.h>
#include <stdio.h>
#if defined (HAVE_UNISTD_H)
@@ -72,6 +73,7 @@ extern int errno;
static void display_history ();
static void push_history ();
static int expand_and_print_history ();
+static int delete_histent ();
#define AFLAG 0x01
#define RFLAG 0x02
@@ -80,17 +82,19 @@ static int expand_and_print_history ();
#define SFLAG 0x10
#define PFLAG 0x20
#define CFLAG 0x40
+#define DFLAG 0x80
int
history_builtin (list)
WORD_LIST *list;
{
int flags, opt, result;
- char *filename;
+ char *filename, *delete_arg;
+ long delete_offset;
flags = 0;
reset_internal_getopt ();
- while ((opt = internal_getopt (list, "acnpsrw")) != -1)
+ while ((opt = internal_getopt (list, "acd:npsrw")) != -1)
{
switch (opt)
{
@@ -112,6 +116,10 @@ history_builtin (list)
case 's':
flags |= SFLAG;
break;
+ case 'd':
+ flags |= DFLAG;
+ delete_arg = list_optarg;
+ break;
case 'p':
#if defined (BANG_HISTORY)
flags |= PFLAG;
@@ -153,6 +161,26 @@ history_builtin (list)
return (EXECUTION_SUCCESS);
}
#endif
+ else if (flags & DFLAG)
+ {
+ if (legal_number (delete_arg, &delete_offset) == 0)
+ {
+ builtin_error ("%s: not a valid history position", delete_arg);
+ return (EXECUTION_FAILURE);
+ }
+ opt = delete_offset;
+ if (opt < history_base || opt < 0 || opt > (history_base + history_length))
+ {
+ builtin_error ("%d: not a valid history position", opt);
+ return (EXECUTION_FAILURE);
+ }
+ result = 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)
{
display_history (list);
@@ -224,11 +252,28 @@ display_history (list)
}
}
+/* Delete and free the history list entry at offset I. */
+static int
+delete_histent (i)
+ int i;
+{
+ HIST_ENTRY *discard;
+
+ discard = remove_history (i);
+ if (discard)
+ {
+ if (discard->line)
+ free (discard->line);
+ free ((char *) discard);
+ }
+ return 1;
+}
+
static int
delete_last_history ()
{
register int i;
- HIST_ENTRY **hlist, *histent, *discard;
+ HIST_ENTRY **hlist, *histent;
hlist = history_list ();
if (hlist == NULL)
@@ -243,14 +288,7 @@ delete_last_history ()
if (histent == NULL)
return 0;
- discard = remove_history (i);
- if (discard)
- {
- if (discard->line)
- free (discard->line);
- free ((char *) discard);
- }
- return (1);
+ return (delete_histent (i));
}
/* Remove the last entry in the history list and add each argument in
diff --git a/builtins/inlib.def b/builtins/inlib.def
index 291eea11..ff068f83 100644
--- a/builtins/inlib.def
+++ b/builtins/inlib.def
@@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 1, or (at your option) any later
+Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$PRODUCES inlib.c
#include <config.h>
diff --git a/builtins/jobs.def b/builtins/jobs.def
index 4cc9b77b..3b573b56 100644
--- a/builtins/jobs.def
+++ b/builtins/jobs.def
@@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 1, or (at your option) any later
+Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$PRODUCES jobs.c
diff --git a/builtins/kill.def b/builtins/kill.def
index 6efb37b3..43927173 100644
--- a/builtins/kill.def
+++ b/builtins/kill.def
@@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 1, or (at your option) any later
+Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$PRODUCES kill.c
diff --git a/builtins/let.def b/builtins/let.def
index fd037cd9..1dbe0a89 100644
--- a/builtins/let.def
+++ b/builtins/let.def
@@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 1, or (at your option) any later
+Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$BUILTIN let
$FUNCTION let_builtin
diff --git a/builtins/mkbuiltins.c b/builtins/mkbuiltins.c
index 2151eb44..3098ad6f 100644
--- a/builtins/mkbuiltins.c
+++ b/builtins/mkbuiltins.c
@@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 1, or (at your option) any later
+Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#include <config.h>
@@ -33,8 +33,8 @@ Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#include <sys/file.h>
#endif
-#include "../posixstat.h"
-#include "../filecntl.h"
+#include "posixstat.h"
+#include "filecntl.h"
#include "../bashansi.h"
#include <stdio.h>
@@ -1036,7 +1036,7 @@ char *structfile_header[] = {
"",
" Bash is free software; you can redistribute it and/or modify it",
" under the terms of the GNU General Public License as published by",
- " the Free Software Foundation; either version 1, or (at your option)",
+ " the Free Software Foundation; either version 2, or (at your option)",
" any later version.",
"",
" Bash is distributed in the hope that it will be useful, but WITHOUT",
@@ -1046,7 +1046,7 @@ char *structfile_header[] = {
"",
" You should have received a copy of the GNU General Public License",
" along with Bash; see the file COPYING. If not, write to the Free",
- " Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */",
+ " Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */",
"",
"/* 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",
diff --git a/builtins/printf.def b/builtins/printf.def
index b573ecec..f0b45904 100644
--- a/builtins/printf.def
+++ b/builtins/printf.def
@@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 1, or (at your option) any later
+Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -54,7 +54,7 @@ $END
#include "../bashansi.h"
#include "../shell.h"
-#include "../stdc.h"
+#include "stdc.h"
#include "bashgetopt.h"
#if !defined (errno)
@@ -74,12 +74,13 @@ extern int errno;
} while (0)
#define PRETURN(value) \
- do { free (format); fflush (stdout); return (value); } while (0)
+ do { /* free (format); */ fflush (stdout); return (value); } while (0)
#define SKIP1 "#-+ 0"
#define SKIP2 "*0123456789"
static void printstr __P((char *, char *, int, int, int));
+static int tescape __P((char *, int, char *, int *));
static char *bexpand __P((char *, int, int *, int *));
static char *mklong __P((char *, int));
static int getchr __P((void));
@@ -125,12 +126,12 @@ printf_builtin (list)
if (list->word->word == 0 || list->word->word[0] == '\0')
return (EXECUTION_SUCCESS);
- format = ansicstr (list->word->word, strlen (list->word->word), (int *)NULL, &fmtlen);
+ format = list->word->word;
garglist = list->next;
/* If the format string is empty after preprocessing, return immediately. */
- if ((format == 0 || *format == 0) && fmtlen == 0)
+ if (format == 0 || *format == 0)
return (EXECUTION_SUCCESS);
/* Basic algorithm is to scan the format string for conversion
@@ -139,15 +140,25 @@ printf_builtin (list)
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. */
-#define FMTIND (fmt - format)
do
{
/* find next format specification */
- for (fmt = format; FMTIND < fmtlen; fmt++)
+ for (fmt = format; *fmt; fmt++)
{
precision = fieldwidth = foundmod = 0;
+ if (*fmt == '\\')
+ {
+ fmt++;
+ /* A NULL third argument to tescape means to not do special
+ processing for \c. */
+ fmt += tescape (fmt, 1, &nextch, (int *)NULL);
+ putchar (nextch);
+ fmt--; /* for loop will increment it for us again */
+ continue;
+ }
+
if (*fmt != '%')
{
putchar (*fmt);
@@ -301,10 +312,10 @@ printf_builtin (list)
break;
}
- /* We output unrecognized format characters, but we print a
- warning message and return a failure exit status. */
+ /* We don't output unrecognized format characters; we print an
+ error message and return a failure exit status. */
default:
- builtin_error ("`%c': illegal format character", convch);
+ builtin_error ("`%c': invalid format character", convch);
PRETURN (EXECUTION_FAILURE);
}
@@ -430,14 +441,114 @@ printstr (fmt, string, len, fieldwidth, precision)
#define HEXVALUE(c) \
((c) >= 'a' && (c) <= 'f' ? (c)-'a'+10 : (c) >= 'A' && (c) <= 'F' ? (c)-'A'+10 : (c)-'0')
-
+
+/* 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. */
+static int
+tescape (estart, trans_squote, cp, sawc)
+ char *estart;
+ int trans_squote;
+ char *cp;
+ int *sawc;
+{
+ register char *p;
+ int temp, c, evalue;
+
+ p = estart;
+
+ 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': *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;
+
+ /* %b octal constants are `\0' followed by one, two, or three
+ octal digits... */
+ case '0':
+ for (temp = 3, evalue = 0; isoctal (*p) && temp--; p++)
+ evalue = (evalue * 8) + OCTVALUE (*p);
+ *cp = evalue;
+ break;
+
+ /* but, as an extension, the other echo-like octal escape
+ sequences are supported as well. */
+ case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7':
+ for (temp = 2, evalue = c - '0'; isoctal (*p) && temp--; p++)
+ evalue = (evalue * 8) + OCTVALUE (*p);
+ *cp = evalue;
+ break;
+
+ /* And, as another extension, we allow \xNNN, where each N is a
+ hex digit. */
+ case 'x':
+ for (temp = 3, evalue = 0; isxdigit (*p) && temp--; p++)
+ evalue = (evalue * 16) + HEXVALUE (*p);
+ if (temp == 3)
+ {
+ builtin_error ("missing hex digit for \\x");
+ *cp = '\\';
+ return 0;
+ }
+ *cp = evalue;
+ break;
+
+ case '\\': /* \\ -> \ */
+ *cp = c;
+ break;
+
+ case '\'': /* TRANS_SQUOTE != 0 means \' -> ' */
+ if (trans_squote)
+ *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 c, temp;
- char *ret, *r, *s;
+ int temp;
+ char *ret, *r, *s, c;
if (string == 0 || *string == '\0')
{
@@ -457,74 +568,13 @@ bexpand (string, len, sawc, lenp)
*r++ = c;
continue;
}
-
- switch (c = *s++)
+ temp = 0;
+ s += tescape (s, 0, &c, &temp);
+ if (temp)
{
-#if defined (__STDC__)
- case 'a': c = '\a'; break;
-#else
- case 'a': c = '\007'; break;
-#endif
-
- case 'b': c = '\b'; break;
-
- case 'e': c = '\033'; break; /* ESC -- non-ANSI */
-
- case 'f': c = '\f'; break;
-
- case 'n': c = '\n'; break;
-
- case 'r': c = '\r'; break;
-
- case 't': c = '\t'; break;
-
- case 'v': c = '\v'; break;
-
- /* %b octal constants are `\0' followed by one, two, or three
- octal digits... */
- case '0':
- for (temp = 3, c = 0; isoctal (*s) && temp--; s++)
- c = (c * 8) + OCTVALUE (*s);
- break;
-
- /* but, as an extension, the other echo-like octal escape
- sequences are supported as well. */
- case '1': case '2': case '3': case '4':
- case '5': case '6': case '7':
- for (temp = 2, c -= '0'; isoctal (*s) && temp--; s++)
- c = (c * 8) + OCTVALUE (*s);
- break;
-
- /* And, as another extension, we allow \xNNN, where each N is a
- hex digit. */
- case 'x':
- for (temp = 3, c = 0; isxdigit (*s) && temp--; s++)
- c = (c * 16) + HEXVALUE (*s);
- if (temp == 3)
- {
- builtin_error ("missing hex digit for \\x");
- *r++ = '\\';
- c = 'x';
- }
- break;
-
- case '\\':
-#if 0
- case '\'': /* XXX */
- case '"': /* XXX */
-#endif
- break;
-
- case 'c':
if (sawc)
*sawc = 1;
- *r = '\0';
- if (lenp)
- *lenp = r - ret;
- return ret;
-
- /* other backslash escapes are passed through unaltered */
- default: *r++ = '\\'; break;
+ break;
}
*r++ = c;
@@ -600,6 +650,7 @@ getlong (lp)
long *lp;
{
long ret;
+ char *ep;
if (garglist == 0)
{
@@ -614,11 +665,14 @@ getlong (lp)
}
errno = 0;
- /* legal_number does not currently detect overflow, but it should.
- Someday it will. */
- if (legal_number (garglist->word->word, &ret) == 0)
+ /* If we use 0 as the third argument, we can handle octal and hex, which
+ legal_number does not. (This was
+ if (legal_number (garglist->word->word, &ret) == 0)
+ ) */
+ ret = strtol (garglist->word->word, &ep, 0);
+ if (*ep != '\0')
{
- builtin_error ("%s: illegal number", garglist->word->word);
+ builtin_error ("%s: invalid number", garglist->word->word);
return (1);
}
else if (errno == ERANGE)
@@ -656,7 +710,7 @@ getulong (ulp)
if (*ep)
{
- builtin_error ("%s: illegal number", garglist->word->word);
+ builtin_error ("%s: invalid number", garglist->word->word);
return (1);
}
else if (errno == ERANGE)
diff --git a/builtins/psize.c b/builtins/psize.c
index 596f97fd..c2154728 100644
--- a/builtins/psize.c
+++ b/builtins/psize.c
@@ -6,7 +6,7 @@
Bash is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 1, or (at your option)
+ the Free Software Foundation; either version 2, or (at your option)
any later version.
Bash is distributed in the hope that it will be useful, but WITHOUT
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with Bash; see the file COPYING. If not, write to the Free
- Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
/* 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
diff --git a/builtins/psize.sh b/builtins/psize.sh
index 84f1f2a4..2c874f55 100755
--- a/builtins/psize.sh
+++ b/builtins/psize.sh
@@ -3,7 +3,7 @@
# psize.sh -- determine this system's pipe size, and write a define to
# pipesize.h so ulimit.c can use it.
-TMPDIR=/tmp
+: ${TMPDIR:=/tmp}
TMPNAME=pipsize.$$
TMPFILE=$TMPDIR/$TMPNAME
diff --git a/builtins/pushd.def b/builtins/pushd.def
index c80271ff..4866f41c 100644
--- a/builtins/pushd.def
+++ b/builtins/pushd.def
@@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 1, or (at your option) any later
+Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$PRODUCES pushd.c
@@ -113,7 +113,7 @@ $END
#include <tilde/tilde.h>
#include "../shell.h"
-#include "../maxpath.h"
+#include "maxpath.h"
#include "common.h"
#include "builtext.h"
diff --git a/builtins/read.def b/builtins/read.def
index 61288afd..8e16152d 100644
--- a/builtins/read.def
+++ b/builtins/read.def
@@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 1, or (at your option) any later
+Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -17,44 +17,53 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$PRODUCES read.c
$BUILTIN read
$FUNCTION read_builtin
-$SHORT_DOC read [-r] [-p prompt] [-a array] [-e] [name ...]
+$SHORT_DOC read [-ers] [-t timeout] [-p prompt] [-a array] [-n nchars] [-d delim] [name ...]
One line is read from the standard input, and the first word is
assigned to the first NAME, the second word to the second NAME, and so
on, with leftover words assigned to the last NAME. Only the characters
-found in $IFS are recognized as word delimiters. The return code is
-zero, unless end-of-file is encountered. If no NAMEs are supplied, the
-line read is stored in the REPLY variable. If the -r option is given,
-this signifies `raw' input, and backslash escaping is disabled. If
-the `-p' option is supplied, the string supplied as an argument is
-output without a trailing newline before attempting to read. If -a is
-supplied, the words read are assigned to sequential indices of ARRAY,
-starting at zero. If -e is supplied and the shell is interactive,
-readline is used to obtain the line.
+found in $IFS are recognized as word delimiters. If no NAMEs are supplied,
+the line read is stored in the REPLY variable. If the -r option is given,
+this signifies `raw' input, and backslash escaping is disabled. The
+-d option causes read to continue until the first character of DELIM is
+read, rather than newline. If the `-p' option is supplied, the string
+PROMPT is output without a trailing newline before attempting to read.
+If -a is supplied, the words read are assigned to sequential indices of
+ARRAY, starting at zero. If -e is supplied and the shell is interactive,
+readline is used to obtain the line. If -n is supplied with a non-zero
+NCHARS argument, read returns after NCHARS characters have been read.
+The -s option causes input coming from a terminal to not be echoed.
+
+The -t option causes read to time out and return failure if a complete line
+of input is not read within TIMEOUT seconds. The return code is zero,
+unless end-of-file is encountered or read times out.
$END
#include <config.h>
+#include "bashtypes.h"
+#include "posixstat.h"
+
#include <stdio.h>
#if defined (HAVE_UNISTD_H)
-# ifdef _MINIX
-# include <sys/types.h>
-# endif
# include <unistd.h>
#endif
+#include <signal.h>
#include <errno.h>
#include "../shell.h"
#include "common.h"
#include "bashgetopt.h"
+#include <shtty.h>
+
#if defined (READLINE)
#include "../bashline.h"
#include <readline/readline.h>
@@ -70,9 +79,29 @@ extern int interrupt_immediately;
#if defined (READLINE)
static char *edit_line ();
+static void set_eol_delim ();
+static void reset_eol_delim ();
#endif
static SHELL_VAR *bind_read_variable ();
+static procenv_t alrmbuf;
+static SigHandler *old_alrm;
+static int delim;
+
+static sighandler
+sigalrm (s)
+ int s;
+{
+ longjmp (alrmbuf, 1);
+}
+
+static void
+reset_alarm ()
+{
+ set_signal_handler (SIGALRM, old_alrm);
+ alarm (0);
+}
+
/* 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
@@ -84,10 +113,14 @@ read_builtin (list)
WORD_LIST *list;
{
register char *varname;
- int size, i, raw, pass_next, saw_escape, eof, opt, retval, edit;
+ int size, i, pass_next, saw_escape, eof, opt, retval, code;
+ int input_is_tty, input_is_pipe, unbuffered_read;
+ int raw, edit, tmout, nchars, silent;
+ long timeoutval, ncharsval;
char c;
char *input_string, *orig_input_string, *ifs_chars, *prompt, *arrayname;
char *e, *t, *t1;
+ struct stat tsb;
SHELL_VAR *var;
#if defined (ARRAY_VARS)
WORD_LIST *alist;
@@ -99,6 +132,7 @@ read_builtin (list)
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;
#if defined (READLINE)
@@ -106,8 +140,12 @@ read_builtin (list)
rlind = 0;
#endif
+ tmout = -1; /* no timeout */
+ nchars = input_is_tty = input_is_pipe = unbuffered_read = 0;
+ delim = '\n'; /* read until newline */
+
reset_internal_getopt ();
- while ((opt = internal_getopt (list, "erp:a:")) != -1)
+ while ((opt = internal_getopt (list, "erp:a:d:t:n:s")) != -1)
{
switch (opt)
{
@@ -117,6 +155,9 @@ read_builtin (list)
case 'p':
prompt = list_optarg;
break;
+ case 's':
+ silent = 1;
+ break;
case 'e':
#if defined (READLINE)
edit = 1;
@@ -127,6 +168,29 @@ read_builtin (list)
arrayname = list_optarg;
break;
#endif
+ case 't':
+ code = legal_number (list_optarg, &timeoutval);
+ if (code == 0 || timeoutval < 0)
+ {
+ builtin_error ("%s: invalid timeout specification", list_optarg);
+ return (EXECUTION_FAILURE);
+ }
+ else
+ tmout = timeoutval;
+ break;
+ case 'n':
+ code = legal_number (list_optarg, &ncharsval);
+ if (code == 0 || ncharsval < 0)
+ {
+ builtin_error ("%s: invalid number specification", list_optarg);
+ return (EXECUTION_FAILURE);
+ }
+ else
+ nchars = ncharsval;
+ break;
+ case 'd':
+ delim = *list_optarg;
+ break;
default:
builtin_usage ();
return (EX_USAGE);
@@ -134,6 +198,10 @@ read_builtin (list)
}
list = loptend;
+ /* `read -t 0 var' returns failure immediately. */
+ if (tmout == 0)
+ return (EXECUTION_FAILURE);
+
/* IF IFS is unset, we use the default of " \t\n". */
var = find_variable ("IFS");
ifs_chars = var ? value_cell (var) : " \t\n";
@@ -149,12 +217,20 @@ read_builtin (list)
#endif
interrupt_immediately++;
- /* If the -p or -e flags were given, but input is not coming from the
+ input_is_tty = isatty (0);
+ if (input_is_tty == 0)
+#ifndef __CYGWIN32__
+ input_is_pipe = (lseek (0, 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) && (isatty (0) == 0))
+ if ((prompt || edit || silent) && input_is_tty == 0)
{
prompt = (char *)NULL;
- edit = 0;
+ edit = silent = 0;
}
if (prompt && edit == 0)
@@ -166,6 +242,67 @@ read_builtin (list)
pass_next = 0; /* Non-zero signifies last char was backslash. */
saw_escape = 0; /* Non-zero signifies that we saw an escape char */
+ if (tmout > 0)
+ {
+ /* Turn off the timeout if stdin is a regular file (e.g. from
+ input redirection). */
+ if ((fstat (0, &tsb) < 0) || S_ISREG (tsb.st_mode))
+ tmout = -1;
+ }
+
+ if (tmout > 0)
+ {
+ code = setjmp (alrmbuf);
+ if (code)
+ {
+ run_unwind_frame ("read_builtin");
+ return (EXECUTION_FAILURE);
+ }
+ old_alrm = set_signal_handler (SIGALRM, sigalrm);
+ add_unwind_protect (reset_alarm, (char *)NULL);
+ alarm (tmout);
+ }
+
+ /* 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 ();
+ if (silent)
+ ttcbreak ();
+ else
+ ttonechar ();
+ add_unwind_protect ((Function *)ttrestore, (char *)NULL);
+ }
+ }
+ else if (silent) /* turn off echo but leave term in canonical mode */
+ {
+ ttsave ();
+ ttnoecho ();
+ add_unwind_protect ((Function *)ttrestore, (char *)NULL);
+ }
+
+ unbuffered_read = (nchars > 0) || (delim != '\n') || input_is_pipe;
+
for (eof = 0;;)
{
#if defined (READLINE)
@@ -192,8 +329,11 @@ read_builtin (list)
{
#endif
- while (((retval = read (0, &c, 1)) < 0) && errno == EINTR)
- ;
+ if (unbuffered_read)
+ retval = zread (0, &c, 1);
+ else
+ retval = zreadc (0, &c);
+
if (retval <= 0)
{
eof = 1;
@@ -227,7 +367,7 @@ read_builtin (list)
continue;
}
- if (c == '\n')
+ if (c == delim)
break;
if (c == CTLESC || c == CTLNUL)
@@ -237,9 +377,36 @@ read_builtin (list)
}
input_string[i++] = c;
+
+ if (nchars > 0 && i >= nchars)
+ break;
}
input_string[i] = '\0';
+ if (tmout > 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 ();
+ }
+ else
+#endif
+ if (input_is_tty)
+ ttrestore ();
+ }
+ else if (silent)
+ ttrestore ();
+
+ if (unbuffered_read == 0)
+ zsyncfd (0);
+
interrupt_immediately--;
discard_unwind_frame ("read_builtin");
@@ -294,7 +461,7 @@ read_builtin (list)
}
else
var = bind_variable ("REPLY", input_string);
- var->attributes &= ~att_invisible;
+ VUNSETATTR (var, att_invisible);
#if 0
free (orig_input_string);
#else
@@ -360,7 +527,7 @@ read_builtin (list)
}
stupidly_hack_special_variables (varname);
- var->attributes &= ~att_invisible;
+ VUNSETATTR (var, att_invisible);
}
/* Now assign the rest of the line to the last variable argument. */
@@ -390,7 +557,7 @@ read_builtin (list)
var = bind_read_variable (list->word->word, input_string);
stupidly_hack_special_variables (list->word->word);
if (var)
- var->attributes &= ~att_invisible;
+ VUNSETATTR (var, att_invisible);
free (orig_input_string);
return (retval);
@@ -434,8 +601,55 @@ edit_line (p)
return ret;
len = strlen (ret);
ret = xrealloc (ret, len + 2);
- ret[len++] = '\n';
+ ret[len++] = delim;
ret[len] = '\0';
return ret;
}
+
+static int old_delim_ctype;
+static Function *old_delim_func;
+static int old_newline_ctype;
+static Function *old_newline_func;
+
+static int 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 (c)
+ int c;
+{
+ 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
index 527fc156..cf970e9e 100644
--- a/builtins/reserved.def
+++ b/builtins/reserved.def
@@ -8,7 +8,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 1, or (at your option) any later
+Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -18,7 +18,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$BUILTIN for
$SHORT_DOC for NAME [in WORDS ... ;] do COMMANDS; done
diff --git a/builtins/return.def b/builtins/return.def
index e88808c8..9f9b5286 100644
--- a/builtins/return.def
+++ b/builtins/return.def
@@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 1, or (at your option) any later
+Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$PRODUCES return.c
@@ -42,6 +42,7 @@ $END
#include "common.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
diff --git a/builtins/set.def b/builtins/set.def
index 423a0671..fd7dc993 100644
--- a/builtins/set.def
+++ b/builtins/set.def
@@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 1, or (at your option) any later
+Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$PRODUCES set.c
@@ -266,6 +266,23 @@ list_minus_o_opts (mode, reusable)
}
}
+char **
+get_minus_o_opts ()
+{
+ char **ret;
+ int n, i, ind;
+
+ n = (sizeof (o_options) / sizeof (o_options[0])) +
+ (sizeof (binary_o_options) / sizeof (binary_o_options[0]));
+ ret = alloc_array (n + 1);
+ for (i = ind = 0; o_options[i].name; i++)
+ ret[ind++] = o_options[i].name;
+ for (i = 0; binary_o_options[i].name; i++)
+ ret[ind++] = binary_o_options[i].name;
+ ret[ind] = (char *)NULL;
+ return ret;
+}
+
static int
set_ignoreeof (on_or_off, option_name)
int on_or_off;
@@ -457,7 +474,7 @@ set_shellopts ()
note whether or not the variable was exported. */
if (v)
{
- v->attributes &= ~att_readonly;
+ VUNSETATTR (v, att_readonly);
exported = exported_p (v);
}
else
@@ -468,9 +485,9 @@ set_shellopts ()
/* 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. */
- v->attributes |= att_readonly;
+ VSETATTR (v, att_readonly);
if (mark_modified_vars && exported == 0 && exported_p (v))
- v->attributes &= ~att_exported;
+ VUNSETATTR (v, att_exported);
free (value);
}
diff --git a/builtins/setattr.def b/builtins/setattr.def
index 1fadee65..8112cf68 100644
--- a/builtins/setattr.def
+++ b/builtins/setattr.def
@@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 1, or (at your option) any later
+Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$PRODUCES setattr.c
@@ -381,13 +381,13 @@ set_var_attribute (name, attribute, undo)
if (var == 0)
{
var = bind_variable (name, (char *)NULL);
- var->attributes |= att_invisible;
+ VSETATTR (var, att_invisible);
}
}
if (var)
SETVARATTR (var, attribute, undo);
- if (var && ((var->attributes & att_exported) || (attribute & att_exported)))
+ if (var && (exported_p (var) || (attribute & att_exported)))
array_needs_making++; /* XXX */
}
diff --git a/builtins/shift.def b/builtins/shift.def
index cc2a4f2b..e028d364 100644
--- a/builtins/shift.def
+++ b/builtins/shift.def
@@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 1, or (at your option) any later
+Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$PRODUCES shift.c
diff --git a/builtins/shopt.def b/builtins/shopt.def
index 1ee5b541..550b7f61 100644
--- a/builtins/shopt.def
+++ b/builtins/shopt.def
@@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 1, or (at your option) any later
+Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$PRODUCES shopt.c
@@ -64,6 +64,7 @@ extern int cdspelling, expand_aliases;
extern int check_window_size;
extern int glob_ignore_case;
extern int hup_on_exit;
+extern int xpg_echo;
#if defined (EXTENDED_GLOB)
extern int extended_glob;
@@ -76,9 +77,14 @@ extern int force_append_history;
#if defined (READLINE)
extern int hist_verify, history_reediting, perform_hostname_completion;
+extern int no_empty_command_completion;
extern void enable_hostname_completion ();
#endif
+#if defined (PROGRAMMABLE_COMPLETION)
+extern int prog_completion_enabled;
+#endif
+
#if defined (RESTRICTED_SHELL)
extern int restricted_shell;
extern char *shell_name;
@@ -126,14 +132,21 @@ static struct {
{ "lithist", &literal_history, (Function *)NULL },
#endif
{ "mailwarn", &mail_warning, (Function *)NULL },
+#if defined (READLINE)
+ { "no_empty_cmd_completion", &no_empty_command_completion, (Function *)NULL },
+#endif
{ "nocaseglob", &glob_ignore_case, (Function *)NULL },
{ "nullglob", &allow_null_glob_expansion, (Function *)NULL },
+#if defined (PROGRAMMABLE_COMPLETION)
+ { "progcomp", &prog_completion_enabled, (Function *)NULL },
+#endif
{ "promptvars", &promptvars, (Function *)NULL },
#if defined (RESTRICTED_SHELL)
{ "restricted_shell", &restricted_shell, set_restricted_shell },
#endif
{ "shift_verbose", &print_shift_error, (Function *)NULL },
{ "sourcepath", &source_uses_path, (Function *)NULL },
+ { "xpg_echo", &xpg_echo, (Function *)NULL },
{ (char *)0, (int *)0, (Function *)NULL }
};
@@ -429,3 +442,17 @@ set_restricted_shell (mode)
return (0);
}
#endif /* RESTRICTED_SHELL */
+
+char **
+get_shopt_options ()
+{
+ char **ret;
+ int n, i;
+
+ n = sizeof (shopt_vars) / sizeof (shopt_vars[0]);
+ ret = alloc_array (n + 1);
+ for (i = 0; shopt_vars[i].name; i++)
+ ret[i] = savestring (shopt_vars[i].name);
+ ret[i] = (char *)NULL;
+ return ret;
+}
diff --git a/builtins/source.def b/builtins/source.def
index 8979f0b1..2da47a16 100644
--- a/builtins/source.def
+++ b/builtins/source.def
@@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 1, or (at your option) any later
+Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$PRODUCES source.c
@@ -39,8 +39,8 @@ $END
#include <config.h>
#include "../bashtypes.h"
-#include "../posixstat.h"
-#include "../filecntl.h"
+#include "posixstat.h"
+#include "filecntl.h"
#ifndef _MINIX
# include <sys/file.h>
#endif
diff --git a/builtins/suspend.def b/builtins/suspend.def
index 3e949baf..62a2b4e2 100644
--- a/builtins/suspend.def
+++ b/builtins/suspend.def
@@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 1, or (at your option) any later
+Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$PRODUCES suspend.c
diff --git a/builtins/test.def b/builtins/test.def
index abae8b4a..f8445de9 100644
--- a/builtins/test.def
+++ b/builtins/test.def
@@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 1, or (at your option) any later
+Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$PRODUCES test.c
diff --git a/builtins/times.def b/builtins/times.def
index 630642c5..4dba7248 100644
--- a/builtins/times.def
+++ b/builtins/times.def
@@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 1, or (at your option) any later
+Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$PRODUCES times.c
@@ -41,16 +41,7 @@ $END
#include "../bashtypes.h"
#include "../shell.h"
-#if TIME_WITH_SYS_TIME
-# include <sys/time.h>
-# include <time.h>
-#else
-# if defined (HAVE_SYS_TIME_H)
-# include <sys/time.h>
-# else
-# include <time.h>
-# endif
-#endif
+#include <posixtime.h>
#if defined (HAVE_SYS_TIMES_H)
# include <sys/times.h>
@@ -84,21 +75,19 @@ times_builtin (list)
#else
# if defined (HAVE_TIMES)
- /* As of System V.3, HP-UX 6.5, and other ATT-like systems, this stuff is
- returned in terms of clock ticks (HZ from sys/param.h). C'mon, guys.
- This kind of stupid clock-dependent stuff is exactly the reason 4.2BSD
- introduced the `timeval' struct. */
+ /* This uses the POSIX.1/XPG5 times(2) interface, which fills in a
+ `struct tms' with values of type clock_t. */
struct tms t;
times (&t);
- print_time_in_hz (stdout, t.tms_utime);
+ print_clock_t (stdout, t.tms_utime);
putchar (' ');
- print_time_in_hz (stdout, t.tms_stime);
+ print_clock_t (stdout, t.tms_stime);
putchar ('\n');
- print_time_in_hz (stdout, t.tms_cutime);
+ print_clock_t (stdout, t.tms_cutime);
putchar (' ');
- print_time_in_hz (stdout, t.tms_cstime);
+ print_clock_t (stdout, t.tms_cstime);
putchar ('\n');
# else /* !HAVE_TIMES */
printf ("0.00 0.00\n0.00 0.00\n");
diff --git a/builtins/trap.def b/builtins/trap.def
index 522e2a46..8bba165d 100644
--- a/builtins/trap.def
+++ b/builtins/trap.def
@@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 1, or (at your option) any later
+Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$PRODUCES trap.c
diff --git a/builtins/type.def b/builtins/type.def
index c9338ba9..9a4ef0d6 100644
--- a/builtins/type.def
+++ b/builtins/type.def
@@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 1, or (at your option) any later
+Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$PRODUCES type.c
@@ -44,7 +44,7 @@ $END
#include <config.h>
#include "../bashtypes.h"
-#include "../posixstat.h"
+#include "posixstat.h"
#if defined (HAVE_UNISTD_H)
# include <unistd.h>
@@ -66,6 +66,8 @@ $END
extern int find_reserved_word ();
+extern char *this_command_name;
+
/* 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
@@ -210,8 +212,8 @@ describe_command (command, verbose, all)
char *command;
int verbose, all;
{
- int found, i, found_file;
- char *full_path;
+ int found, i, found_file, f;
+ char *full_path, *x, *cwd;
SHELL_VAR *func;
#if defined (ALIAS)
alias_t *alias;
@@ -232,7 +234,7 @@ describe_command (command, verbose, all)
printf ("%s is aliased to `%s'\n", command, alias->value);
else if (verbose == 4)
{
- char *x = single_quote (alias->value);
+ x = single_quote (alias->value);
printf ("alias %s=%s\n", command, x);
free (x);
}
@@ -313,7 +315,7 @@ describe_command (command, verbose, all)
check to see if it is executable. */
if (absolute_program (command))
{
- int f = file_status (command);
+ f = file_status (command);
if (f & FS_EXECABLE)
{
if (verbose == 1)
@@ -361,6 +363,23 @@ describe_command (command, verbose, all)
if (!full_path)
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. */
+ if (STREQ (full_path, command))
+ {
+ f = file_status (full_path);
+ if ((f & FS_EXECABLE) == 0)
+ {
+ free (full_path);
+ full_path = (char *)NULL;
+ if (all == 0)
+ break;
+ }
+ else if (verbose >= 2)
+ full_path = sh_makepath ((char *)NULL, full_path, MP_DOCWD);
+ }
+
found_file++;
found = 1;
diff --git a/builtins/ulimit.def b/builtins/ulimit.def
index f3d0c8e5..e57e76de 100644
--- a/builtins/ulimit.def
+++ b/builtins/ulimit.def
@@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 1, or (at your option) any later
+Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$PRODUCES ulimit.c
@@ -547,7 +547,11 @@ filesize(valuep)
if ((result = ulimit (1, 0L)) < 0)
return -1;
else
+# if 0
*valuep = (RLIMTYPE) result;
+# else
+ *valuep = (RLIMTYPE) result * 512L;
+# endif
return 0;
#else
errno = EINVAL;
diff --git a/builtins/umask.def b/builtins/umask.def
index 5b98c0c8..9205c94a 100644
--- a/builtins/umask.def
+++ b/builtins/umask.def
@@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 1, or (at your option) any later
+Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$PRODUCES umask.c
@@ -36,7 +36,7 @@ $END
#include <config.h>
#include "../bashtypes.h"
-#include "../filecntl.h"
+#include "filecntl.h"
#ifndef _MINIX
# include <sys/file.h>
#endif
@@ -48,7 +48,7 @@ $END
#include <stdio.h>
#include "../shell.h"
-#include "../posixstat.h"
+#include "posixstat.h"
#include "common.h"
#include "bashgetopt.h"
@@ -295,6 +295,8 @@ symbolic_umask (list)
more intuitive and easier to deal with. It is complemented
again before being returned. */
bits = parse_symbolic_mode (list->word->word, ~um);
+ if (bits == -1)
+ return (-1);
um = ~bits & 0777;
return (um);
diff --git a/builtins/wait.def b/builtins/wait.def
index 11fe85a9..2e3fac57 100644
--- a/builtins/wait.def
+++ b/builtins/wait.def
@@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 1, or (at your option) any later
+Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
$BUILTIN wait
$FUNCTION wait_builtin
@@ -59,6 +59,8 @@ $END
extern int interrupt_immediately;
+procenv_t wait_intr_buf;
+
/* 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
@@ -70,7 +72,7 @@ int
wait_builtin (list)
WORD_LIST *list;
{
- int status;
+ int status, code;
if (no_options (list))
return (EX_USAGE);
@@ -81,6 +83,21 @@ wait_builtin (list)
unwind_protect_int (interrupt_immediately);
interrupt_immediately++;
+ /* 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. */
+ code = setjmp (wait_intr_buf);
+ if (code)
+ {
+ status = 128 + SIGINT;
+ WAIT_RETURN (status);
+ }
+
/* We support jobs or pids.
wait <pid-or-job> [pid-or-job ...] */
diff --git a/command.h b/command.h
index f91171e5..72fc3916 100644
--- a/command.h
+++ b/command.h
@@ -17,7 +17,7 @@
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if !defined (_COMMAND_H_)
#define _COMMAND_H_
@@ -55,7 +55,7 @@ enum r_instruction {
/* 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, cm_cond, cm_arith_for, cm_subshell };
/* Possible values for the `flags' field of a WORD_DESC. */
#define W_HASDOLLAR 0x01 /* Dollar sign present. */
@@ -151,6 +151,10 @@ typedef struct command {
#if defined (COND_COMMAND)
struct cond_com *Cond;
#endif
+#if defined (ARITH_FOR_COMMAND)
+ struct arith_for_com *ArithFor;
+#endif
+ struct subshell_com *Subshell;
} value;
} COMMAND;
@@ -188,6 +192,17 @@ typedef struct for_com {
members of MAP_LIST. */
} FOR_COM;
+#if defined (ARITH_FOR_COMMAND)
+typedef struct arith_for_com {
+ int flags;
+ int line; /* generally used for error messages */
+ WORD_LIST *init;
+ WORD_LIST *test;
+ WORD_LIST *step;
+ COMMAND *action;
+} ARITH_FOR_COM;
+#endif
+
#if defined (SELECT_COMMAND)
/* KSH SELECT command. */
typedef struct select_com {
@@ -267,6 +282,11 @@ typedef struct group_com {
COMMAND *command;
} GROUP_COM;
+typedef struct subshell_com {
+ int flags;
+ COMMAND *command;
+} SUBSHELL_COM;
+
extern COMMAND *global_command;
/* Possible command errors */
diff --git a/config-bot.h b/config-bot.h
index b4635ed0..3091533a 100644
--- a/config-bot.h
+++ b/config-bot.h
@@ -44,8 +44,12 @@
# define HISTORY
#endif
+#if defined (PROGRAMMABLE_COMPLETION) && !defined (READLINE)
+# undef PROGRAMMABLE_COMPLETION
+#endif
+
#if !defined (V9_ECHO)
-# undef DEFAULT_ECHO_TO_USG
+# undef DEFAULT_ECHO_TO_XPG
#endif
#if defined (JOB_CONTROL_MISSING)
@@ -66,6 +70,11 @@
# undef HAVE_STRCOLL
#endif
+#if defined (HAVE_SYS_SOCKET_H) && defined (HAVE_GETPEERNAME) && defined (HAVE_NETINET_IN_H)
+# define HAVE_NETWORK
+#endif
+
#if !defined (PROMPT_STRING_DECODE)
+# undef PPROMPT
# define PPROMPT "$ "
#endif
diff --git a/config-top.h b/config-top.h
index ec11b8db..c78ee804 100644
--- a/config-top.h
+++ b/config-top.h
@@ -53,3 +53,7 @@
/* 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 */
diff --git a/config.h.in b/config.h.in
index e1ff9a1d..9b4c6076 100644
--- a/config.h.in
+++ b/config.h.in
@@ -6,7 +6,7 @@
Bash is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 1, or (at your option)
+ the Free Software Foundation; either version 2, or (at your option)
any later version.
Bash is distributed in the hope that it will be useful, but WITHOUT
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with Bash; see the file COPYING. If not, write to the Free
- Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#ifndef _CONFIG_H_
#define _CONFIG_H_
@@ -65,10 +65,11 @@
# define BRACE_COMPLETION
#endif /* BRACE_EXPANSION */
-/* Define DEFAULT_ECHO_TO_USG if you want the echo builtin to interpret
- the backslash-escape characters by default, like the System V echo.
+/* 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_USG
+#undef DEFAULT_ECHO_TO_XPG
/* Define HELP_BUILTIN if you want the `help' shell builtin and the long
documentation strings compiled into the shell. */
@@ -118,6 +119,19 @@
command. */
#undef COND_COMMAND
+/* 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 AFS if you are using Transarc's AFS. */
#undef AFS
@@ -128,6 +142,9 @@
/* Beginning of autoconf additions. */
+/* Define if using the bash version of malloc in lib/malloc/malloc.c */
+#undef USING_BASH_MALLOC
+
/* Define if using alloca.c. */
#undef C_ALLOCA
@@ -202,17 +219,29 @@
/* Define to `int' if <sys/types.h> doesn't define. */
#undef pid_t
+/* Define to `short' if <sys/types.h> doesn't define. */
+#undef bits16_t
+
+/* Define to `unsigned short' if <sys/types.h> doesn't define. */
+#undef u_bits16_t
+
/* Define to `int' if <sys/types.h> doesn't define. */
-#undef int32_t
+#undef bits32_t
/* Define to `unsigned int' if <sys/types.h> doesn't define. */
-#undef u_int32_t
+#undef u_bits32_t
+
+/* Define to `double' if <sys/types.h> doesn't define. */
+#undef bits64_t
/* Define to `int' if <sys/types.h> doesn't define. */
#undef ptrdiff_t
-/* Define to `double' if <sys/types.h> doesn't define. */
-#undef bits64_t
+/* Define to `unsigned int' if <sys/types.h> doesn't define. */
+#undef u_int
+
+/* Define to `unsigned long' if <sys/types.h> doesn't define. */
+#undef u_long
/* Define to `unsigned' if <sys/types.h> doesn't define. */
#undef size_t
@@ -261,6 +290,10 @@
#undef DUP2_BROKEN
+#undef HAVE_GETHOSTBYNAME
+
+#undef HAVE_INET_ATON
+
#undef HAVE_GETRLIMIT
#undef HAVE_GETRUSAGE
@@ -287,6 +320,8 @@
#undef DEV_FD_PREFIX
+#undef HAVE_DEV_STDIN
+
#undef HAVE_GETPW_DECLS
#undef HAVE_QUAD_T
@@ -425,6 +460,10 @@
/* Define if you have the setlocale function. */
#undef HAVE_SETLOCALE
+/* 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 strcasecmp function. */
@@ -436,6 +475,9 @@
/* Define if you have the strerror function. */
#undef HAVE_STRERROR
+/* Define if you have the strpbrk function. */
+#undef HAVE_STRPBRK
+
/* Define if you have the strtod function. */
#undef HAVE_STRTOD
@@ -457,6 +499,8 @@
/* Define if you have the ulimit function. */
#undef HAVE_ULIMIT
+#undef HAVE_TTYNAME
+
#undef HAVE_WAITPID
#undef HAVE_TCGETPGRP
@@ -549,6 +593,15 @@
/* Define if you have the <stddef.h> header file. */
#undef HAVE_STDDEF_H
+/* Define if you have the <netdh.h> header file. */
+#undef HAVE_NETDB_H
+
+/* Define if you have the <netinet/in.h> header file. */
+#undef HAVE_NETINET_IN_H
+
+/* Define if you have the <arpa/inet.h> header file. */
+#undef HAVE_ARPA_INET_H
+
#undef HAVE_LIBDL
#undef HAVE_LIBSUN
diff --git a/configure b/configure
index d6e29f44..838c861b 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,18 @@
#! /bin/sh
-# From configure.in for Bash 2.03, version 2.49, from autoconf version 2.12
+# From configure.in for Bash 2.04, version 2.77, from autoconf version 2.13
+
+
+
+
+
+
+
+
+
+
+
+
@@ -90,7 +102,7 @@
# Guess values for system-dependent variables and create Makefiles.
-# Generated automatically using autoconf version 2.12
+# Generated automatically using autoconf version 2.13
# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc.
#
# This configure script is free software; the Free Software Foundation
@@ -103,11 +115,13 @@ ac_default_prefix=/usr/local
ac_help="$ac_help
--with-afs if you are running AFS"
ac_help="$ac_help
+--with-bash-malloc use the Bash version of malloc"
+ac_help="$ac_help
--with-curses use the curses library instead of the termcap library"
ac_help="$ac_help
--with-glibc-malloc use the GNU C library version of malloc"
ac_help="$ac_help
---with-gnu-malloc use the GNU version of malloc"
+--with-gnu-malloc synonym for --with-bash-malloc"
ac_help="$ac_help
--with-installed-readline use a version of the readline library that is already installed"
ac_help="$ac_help
@@ -119,6 +133,8 @@ ac_help="$ac_help
ac_help="$ac_help
--enable-alias enable shell aliases"
ac_help="$ac_help
+--enable-arith-for-command enable arithmetic for command"
+ac_help="$ac_help
--enable-array-variables include shell array variables"
ac_help="$ac_help
--enable-bang-history turn on csh-style history substitution"
@@ -143,8 +159,12 @@ ac_help="$ac_help
ac_help="$ac_help
--enable-job-control enable job control features"
ac_help="$ac_help
+--enable-net-redirections enable /dev/tcp/host/port redirection"
+ac_help="$ac_help
--enable-process-substitution enable process substitution"
ac_help="$ac_help
+--enable-progcomp enable programmable completion and the complete builtin"
+ac_help="$ac_help
--enable-prompt-string-decoding turn on escape character decoding in prompts"
ac_help="$ac_help
--enable-readline turn on command line editing"
@@ -153,7 +173,9 @@ ac_help="$ac_help
ac_help="$ac_help
--enable-select include select command"
ac_help="$ac_help
---enable-usg-echo-default make the echo builtin expand escape sequences by default"
+--enable-usg-echo-default a synonym for --enable-xpg-echo-default"
+ac_help="$ac_help
+--enable-xpg-echo-default make the echo builtin expand escape sequences by default"
ac_help="$ac_help
--enable-profiling allow profiling with gprof"
ac_help="$ac_help
@@ -196,6 +218,7 @@ mandir='${prefix}/man'
# Initialize some other variables.
subdirs=
MFLAGS= MAKEFLAGS=
+SHELL=${CONFIG_SHELL-/bin/sh}
# Maximum number of lines to put in a shell here document.
ac_max_here_lines=12
@@ -479,7 +502,7 @@ EOF
verbose=yes ;;
-version | --version | --versio | --versi | --vers)
- echo "configure generated by autoconf version 2.12"
+ echo "configure generated by autoconf version 2.13"
exit 0 ;;
-with-* | --with-*)
@@ -649,9 +672,11 @@ ac_ext=c
# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
ac_cpp='$CPP $CPPFLAGS'
ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
-ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
cross_compiling=$ac_cv_prog_cc_cross
+ac_exeext=
+ac_objext=o
if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
# Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu.
if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
@@ -691,33 +716,33 @@ ac_configure=$ac_aux_dir/configure # This should be Cygnus configure.
# Make sure we can run config.sub.
-if $ac_config_sub sun4 >/dev/null 2>&1; then :
+if ${CONFIG_SHELL-/bin/sh} $ac_config_sub sun4 >/dev/null 2>&1; then :
else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; }
fi
echo $ac_n "checking host system type""... $ac_c" 1>&6
-echo "configure:700: checking host system type" >&5
+echo "configure:725: checking host system type" >&5
host_alias=$host
case "$host_alias" in
NONE)
case $nonopt in
NONE)
- if host_alias=`$ac_config_guess`; then :
+ if host_alias=`${CONFIG_SHELL-/bin/sh} $ac_config_guess`; then :
else { echo "configure: error: can not guess host type; you must specify one" 1>&2; exit 1; }
fi ;;
*) host_alias=$nonopt ;;
esac ;;
esac
-host=`$ac_config_sub $host_alias`
+host=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $host_alias`
host_cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
host_vendor=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
echo "$ac_t""$host" 1>&6
-opt_gnu_malloc=yes
+opt_bash_malloc=yes
opt_glibc_malloc=no
opt_purify=no
opt_purecov=no
@@ -725,24 +750,27 @@ opt_afs=no
opt_curses=no
opt_with_installed_readline=no
+#htmldir=
+
case "${host_cpu}-${host_os}" in
-alpha*-*) opt_gnu_malloc=no ;; # alpha running osf/1 or linux
-*Ccray*-*) opt_gnu_malloc=no ;; # Crays
-*-osf1*) opt_gnu_malloc=no ;; # other osf/1 machines
-sparc-svr4*) opt_gnu_malloc=no ;; # sparc SVR4, SVR4.2
-sparc-netbsd*) opt_gnu_malloc=no ;; # needs 8-byte alignment
-mips-irix6*) opt_gnu_malloc=no ;; # needs 8-byte alignment
-sparc-linux*) opt_gnu_malloc=no ;; # sparc running linux; requires ELF
-#*-freebsd*) opt_gnu_malloc=no ;; # they claim it's better
-*-aix*) opt_gnu_malloc=no ;; # AIX machines
-*-nextstep*) opt_gnu_malloc=no ;; # NeXT machines running NeXTstep
-*-rhapsody*) opt_gnu_malloc=no ;; # Apple Rhapsody
-*-dgux*) opt_gnu_malloc=no ;; # DG/UX machines
-*-qnx*) opt_gnu_malloc=no ;; # QNX 4.2
-*-machten4) opt_gnu_malloc=no ;; # MachTen 4.x
-*-bsdi2.1|*-bsdi3.?) opt_gnu_malloc=no ; : ${CC:=shlicc2} ;; # for loadable builtins
-*-beos*) opt_gnu_malloc=no ;; # they say it's suitable
-*-cygwin32*) opt_gnu_malloc=no ;; # Cygnus's CYGWIN32 environment
+alpha*-*) opt_bash_malloc=no ;; # alpha running osf/1 or linux
+*Ccray*-*) 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*) opt_bash_malloc=no ;; # they claim it's better
+*-aix*) opt_bash_malloc=no ;; # AIX machines
+*-nextstep*) opt_bash_malloc=no ;; # NeXT machines running NeXTstep
+*-rhapsody*) opt_bash_malloc=no ;; # Apple Rhapsody
+*-dgux*) opt_bash_malloc=no ;; # DG/UX machines
+*-qnx*) opt_bash_malloc=no ;; # QNX 4.2
+*-machten4) opt_bash_malloc=no ;; # MachTen 4.x
+*-bsdi2.1|*-bsdi3.?) opt_bash_malloc=no ; : ${CC:=shlicc2} ;; # for loadable builtins
+*-beos*) opt_bash_malloc=no ;; # they say it's suitable
+*-cygwin32*) opt_bash_malloc=no ;; # Cygnus's CYGWIN32 environment
esac
# Check whether --with-afs or --without-afs was given.
@@ -751,6 +779,12 @@ if test "${with_afs+set}" = set; then
opt_afs=$withval
fi
+# Check whether --with-bash-malloc or --without-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 or --without-curses was given.
if test "${with_curses+set}" = set; then
withval="$with_curses"
@@ -766,7 +800,7 @@ fi
# Check whether --with-gnu-malloc or --without-gnu-malloc was given.
if test "${with_gnu_malloc+set}" = set; then
withval="$with_gnu_malloc"
- opt_gnu_malloc=$withval
+ opt_bash_malloc=$withval
fi
# Check whether --with-installed-readline or --without-installed-readline was given.
@@ -791,9 +825,13 @@ fi
if test "$opt_glibc_malloc" = yes; then
MALLOC_TARGET=gmalloc
MALLOC_SRC=gmalloc.c
-elif test "$opt_gnu_malloc" = yes; then
+elif test "$opt_bash_malloc" = yes; then
MALLOC_TARGET=malloc
MALLOC_SRC=malloc.c
+ cat >> confdefs.h <<\EOF
+#define USING_BASH_MALLOC 1
+EOF
+
else
MALLOC_TARGET=stubmalloc
MALLOC_SRC=stub.c
@@ -839,8 +877,11 @@ opt_extended_glob=yes
opt_brace_expansion=yes
opt_disabled_builtins=no
opt_command_timing=yes
-opt_usg_echo=no
+opt_xpg_echo=no
opt_cond_command=yes
+opt_arith_for_command=yes
+opt_net_redirs=yes
+opt_progcomp=yes
opt_static_link=no
opt_profiling=no
@@ -858,7 +899,8 @@ if test $opt_minimal_config = yes; then
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_extended_glob=no opt_cond_command=no opt_arith_for_command=no
+ opt_net_redirs=no opt_progcomp=no
fi
# Check whether --enable-alias or --disable-alias was given.
@@ -867,6 +909,12 @@ if test "${enable_alias+set}" = set; then
opt_alias=$enableval
fi
+# Check whether --enable-arith-for-command or --disable-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 or --disable-array-variables was given.
if test "${enable_array_variables+set}" = set; then
enableval="$enable_array_variables"
@@ -939,12 +987,24 @@ if test "${enable_job_control+set}" = set; then
opt_job_control=$enableval
fi
+# Check whether --enable-net-redirections or --disable-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 or --disable-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 or --disable-progcomp was given.
+if test "${enable_progcomp+set}" = set; then
+ enableval="$enable_progcomp"
+ opt_progcomp=$enableval
+fi
+
# Check whether --enable-prompt-string-decoding or --disable-prompt-string-decoding was given.
if test "${enable_prompt_string_decoding+set}" = set; then
enableval="$enable_prompt_string_decoding"
@@ -972,7 +1032,13 @@ fi
# Check whether --enable-usg-echo-default or --disable-usg-echo-default was given.
if test "${enable_usg_echo_default+set}" = set; then
enableval="$enable_usg_echo_default"
- opt_usg_echo=$enableval
+ opt_xpg_echo=$enableval
+fi
+
+# Check whether --enable-xpg-echo-default or --disable-xpg-echo-default was given.
+if test "${enable_xpg_echo_default+set}" = set; then
+ enableval="$enable_xpg_echo_default"
+ opt_xpg_echo=$enableval
fi
@@ -1063,9 +1129,9 @@ cat >> confdefs.h <<\EOF
EOF
fi
-if test $opt_usg_echo = yes ; then
+if test $opt_xpg_echo = yes ; then
cat >> confdefs.h <<\EOF
-#define DEFAULT_ECHO_TO_USG 1
+#define DEFAULT_ECHO_TO_XPG 1
EOF
fi
@@ -1081,6 +1147,24 @@ cat >> confdefs.h <<\EOF
EOF
fi
+if test $opt_arith_for_command = yes; then
+cat >> confdefs.h <<\EOF
+#define ARITH_FOR_COMMAND 1
+EOF
+
+fi
+if test $opt_net_redirs = yes; then
+cat >> confdefs.h <<\EOF
+#define NETWORK_REDIRECTIONS 1
+EOF
+
+fi
+if test $opt_progcomp = yes; then
+cat >> confdefs.h <<\EOF
+#define PROGRAMMABLE_COMPLETION 1
+EOF
+
+fi
if test "$opt_minimal_config" = yes; then
TESTSCRIPT=run-minimal
@@ -1093,7 +1177,9 @@ fi
-BASHVERS=2.03
+
+
+BASHVERS=2.04
BASHPATCH=0
echo "Beginning configuration for bash-$BASHVERS for ${host_cpu}-${host_vendor}-${host_os}"
@@ -1101,15 +1187,16 @@ echo "Beginning configuration for bash-$BASHVERS for ${host_cpu}-${host_vendor}-
# Extract the first word of "gcc", so it can be a program name with args.
set dummy gcc; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1105: checking for $ac_word" >&5
+echo "configure:1191: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
if test -n "$CC"; then
ac_cv_prog_CC="$CC" # Let the user override the test.
else
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
- for ac_dir in $PATH; do
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
test -z "$ac_dir" && ac_dir=.
if test -f $ac_dir/$ac_word; then
ac_cv_prog_CC="gcc"
@@ -1130,16 +1217,17 @@ 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
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1134: checking for $ac_word" >&5
+echo "configure:1221: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
if test -n "$CC"; then
ac_cv_prog_CC="$CC" # Let the user override the test.
else
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
ac_prog_rejected=no
- for ac_dir in $PATH; do
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
test -z "$ac_dir" && ac_dir=.
if test -f $ac_dir/$ac_word; then
if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then
@@ -1174,25 +1262,61 @@ else
echo "$ac_t""no" 1>&6
fi
+ if test -z "$CC"; then
+ case "`uname -s`" in
+ *win32* | *WIN32*)
+ # Extract the first word of "cl", so it can be a program name with args.
+set dummy cl; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:1272: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ ac_cv_prog_CC="cl"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+fi
+fi
+CC="$ac_cv_prog_CC"
+if test -n "$CC"; then
+ echo "$ac_t""$CC" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+ ;;
+ esac
+ fi
test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; }
fi
echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
-echo "configure:1182: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
+echo "configure:1304: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
ac_ext=c
# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
ac_cpp='$CPP $CPPFLAGS'
ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
-ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
cross_compiling=$ac_cv_prog_cc_cross
-cat > conftest.$ac_ext <<EOF
-#line 1192 "configure"
+cat > conftest.$ac_ext << EOF
+
+#line 1315 "configure"
#include "confdefs.h"
+
main(){return(0);}
EOF
-if { (eval echo configure:1196: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1320: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
ac_cv_prog_cc_works=yes
# If we can't run a trivial program, we are probably using a cross compiler.
if (./conftest; exit) 2>/dev/null; then
@@ -1206,18 +1330,24 @@ else
ac_cv_prog_cc_works=no
fi
rm -fr conftest*
+ac_ext=c
+# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
+ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+cross_compiling=$ac_cv_prog_cc_cross
echo "$ac_t""$ac_cv_prog_cc_works" 1>&6
if test $ac_cv_prog_cc_works = no; then
{ echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; }
fi
echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
-echo "configure:1216: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "configure:1346: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6
cross_compiling=$ac_cv_prog_cc_cross
echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
-echo "configure:1221: checking whether we are using GNU C" >&5
+echo "configure:1351: checking whether we are using GNU C" >&5
if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1226,7 +1356,7 @@ else
yes;
#endif
EOF
-if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1230: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
+if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1360: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
ac_cv_prog_gcc=yes
else
ac_cv_prog_gcc=no
@@ -1237,11 +1367,15 @@ echo "$ac_t""$ac_cv_prog_gcc" 1>&6
if test $ac_cv_prog_gcc = yes; then
GCC=yes
- ac_test_CFLAGS="${CFLAGS+set}"
- ac_save_CFLAGS="$CFLAGS"
- CFLAGS=
- echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
-echo "configure:1245: checking whether ${CC-cc} accepts -g" >&5
+else
+ GCC=
+fi
+
+ac_test_CFLAGS="${CFLAGS+set}"
+ac_save_CFLAGS="$CFLAGS"
+CFLAGS=
+echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
+echo "configure:1379: checking whether ${CC-cc} accepts -g" >&5
if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1256,20 +1390,24 @@ rm -f conftest*
fi
echo "$ac_t""$ac_cv_prog_cc_g" 1>&6
- if test "$ac_test_CFLAGS" = set; then
- CFLAGS="$ac_save_CFLAGS"
- elif test $ac_cv_prog_cc_g = yes; then
+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="-O2"
+ CFLAGS="-g"
fi
else
- GCC=
- test "${CFLAGS+set}" = set || CFLAGS="-g"
+ if test "$GCC" = yes; then
+ CFLAGS="-O2"
+ else
+ CFLAGS=
+ fi
fi
echo $ac_n "checking whether large file support needs explicit enabling""... $ac_c" 1>&6
-echo "configure:1273: checking whether large file support needs explicit enabling" >&5
+echo "configure:1411: checking whether large file support needs explicit enabling" >&5
ac_getconfs=''
ac_result=yes
ac_set=''
@@ -1300,8 +1438,9 @@ yes)
done ;;
esac
+
echo $ac_n "checking for POSIXized ISC""... $ac_c" 1>&6
-echo "configure:1305: checking for POSIXized ISC" >&5
+echo "configure:1444: checking for POSIXized ISC" >&5
if test -d /etc/conf/kconfig.d &&
grep _POSIX_VERSION /usr/include/sys/unistd.h >/dev/null 2>&1
then
@@ -1322,7 +1461,7 @@ else
fi
echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
-echo "configure:1326: checking how to run the C preprocessor" >&5
+echo "configure:1465: checking how to run the C preprocessor" >&5
# On Suns, sometimes $CPP names a directory.
if test -n "$CPP" && test -d "$CPP"; then
CPP=
@@ -1337,14 +1476,14 @@ else
# On the NeXT, cc -E runs the code through the compiler's parser,
# not just through cpp.
cat > conftest.$ac_ext <<EOF
-#line 1341 "configure"
+#line 1480 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1347: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:1486: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
:
else
@@ -1354,14 +1493,31 @@ else
rm -rf conftest*
CPP="${CC-cc} -E -traditional-cpp"
cat > conftest.$ac_ext <<EOF
-#line 1358 "configure"
+#line 1497 "configure"
+#include "confdefs.h"
+#include <assert.h>
+Syntax Error
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:1503: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ :
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ CPP="${CC-cc} -nologo -E"
+ cat > conftest.$ac_ext <<EOF
+#line 1514 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1364: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:1520: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
:
else
@@ -1374,6 +1530,8 @@ fi
rm -f conftest*
fi
rm -f conftest*
+fi
+rm -f conftest*
ac_cv_prog_CPP="$CPP"
fi
CPP="$ac_cv_prog_CPP"
@@ -1384,18 +1542,18 @@ echo "$ac_t""$CPP" 1>&6
ac_safe=`echo "minix/config.h" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for minix/config.h""... $ac_c" 1>&6
-echo "configure:1388: checking for minix/config.h" >&5
+echo "configure:1546: checking for minix/config.h" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1393 "configure"
+#line 1551 "configure"
#include "confdefs.h"
#include <minix/config.h>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1398: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:1556: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
eval "ac_cv_header_$ac_safe=yes"
@@ -1432,6 +1590,102 @@ EOF
fi
+echo $ac_n "checking for Cygwin environment""... $ac_c" 1>&6
+echo "configure:1595: checking for Cygwin environment" >&5
+if eval "test \"`echo '$''{'ac_cv_cygwin'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1600 "configure"
+#include "confdefs.h"
+
+int main() {
+
+#ifndef __CYGWIN__
+#define __CYGWIN__ __CYGWIN32__
+#endif
+return __CYGWIN__;
+; return 0; }
+EOF
+if { (eval echo configure:1611: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ ac_cv_cygwin=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ ac_cv_cygwin=no
+fi
+rm -f conftest*
+rm -f conftest*
+fi
+
+echo "$ac_t""$ac_cv_cygwin" 1>&6
+CYGWIN=
+test "$ac_cv_cygwin" = yes && CYGWIN=yes
+echo $ac_n "checking for mingw32 environment""... $ac_c" 1>&6
+echo "configure:1628: checking for mingw32 environment" >&5
+if eval "test \"`echo '$''{'ac_cv_mingw32'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1633 "configure"
+#include "confdefs.h"
+
+int main() {
+return __MINGW32__;
+; return 0; }
+EOF
+if { (eval echo configure:1640: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ ac_cv_mingw32=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ ac_cv_mingw32=no
+fi
+rm -f conftest*
+rm -f conftest*
+fi
+
+echo "$ac_t""$ac_cv_mingw32" 1>&6
+MINGW32=
+test "$ac_cv_mingw32" = yes && MINGW32=yes
+
+
+echo $ac_n "checking for executable suffix""... $ac_c" 1>&6
+echo "configure:1659: checking for executable suffix" >&5
+if eval "test \"`echo '$''{'ac_cv_exeext'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test "$CYGWIN" = yes || test "$MINGW32" = yes; then
+ ac_cv_exeext=.exe
+else
+ rm -f conftest*
+ echo 'int main () { return 0; }' > conftest.$ac_ext
+ ac_cv_exeext=
+ if { (eval echo configure:1669: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then
+ for file in conftest.*; do
+ case $file in
+ *.c | *.o | *.obj) ;;
+ *) ac_cv_exeext=`echo $file | sed -e s/conftest//` ;;
+ esac
+ done
+ else
+ { echo "configure: error: installation or configuration problem: compiler cannot create executables." 1>&2; exit 1; }
+ fi
+ rm -f conftest*
+ test x"${ac_cv_exeext}" = x && ac_cv_exeext=no
+fi
+fi
+
+EXEEXT=""
+test x"${ac_cv_exeext}" != xno && EXEEXT=${ac_cv_exeext}
+echo "$ac_t""${ac_cv_exeext}" 1>&6
+ac_exeext=$EXEEXT
+
+
SIGNAMES_H=lsignames.h
@@ -1494,13 +1748,13 @@ fi
if test $ac_cv_prog_gcc = yes; then
echo $ac_n "checking whether ${CC-cc} needs -traditional""... $ac_c" 1>&6
-echo "configure:1498: checking whether ${CC-cc} needs -traditional" >&5
+echo "configure:1752: checking whether ${CC-cc} needs -traditional" >&5
if eval "test \"`echo '$''{'ac_cv_prog_gcc_traditional'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
ac_pattern="Autoconf.*'x'"
cat > conftest.$ac_ext <<EOF
-#line 1504 "configure"
+#line 1758 "configure"
#include "confdefs.h"
#include <sgtty.h>
Autoconf TIOCGETP
@@ -1518,7 +1772,7 @@ rm -f conftest*
if test $ac_cv_prog_gcc_traditional = no; then
cat > conftest.$ac_ext <<EOF
-#line 1522 "configure"
+#line 1776 "configure"
#include "confdefs.h"
#include <termio.h>
Autoconf TCGETA
@@ -1545,16 +1799,173 @@ if test "$opt_readline" = yes && test "$opt_with_installed_readline" = "yes"
then
+ if test -z "$TERMCAP_LIB" ; then
+
+if test "X$bash_cv_termcap_lib" = "X"; then
+_bash_needmsg=yes
+else
+echo $ac_n "checking which library has the termcap functions""... $ac_c" 1>&6
+echo "configure:1809: checking which library has the termcap functions" >&5
+_bash_needmsg=
+fi
+if eval "test \"`echo '$''{'bash_cv_termcap_lib'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ echo $ac_n "checking for tgetent in -ltermcap""... $ac_c" 1>&6
+echo "configure:1816: checking for tgetent in -ltermcap" >&5
+ac_lib_var=`echo termcap'_'tgetent | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ ac_save_LIBS="$LIBS"
+LIBS="-ltermcap $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 1824 "configure"
+#include "confdefs.h"
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char tgetent();
+
+int main() {
+tgetent()
+; return 0; }
+EOF
+if { (eval echo configure:1835: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest*
+LIBS="$ac_save_LIBS"
+
+fi
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ bash_cv_termcap_lib=libtermcap
+else
+ echo "$ac_t""no" 1>&6
+echo $ac_n "checking for tgetent in -lcurses""... $ac_c" 1>&6
+echo "configure:1854: checking for tgetent in -lcurses" >&5
+ac_lib_var=`echo curses'_'tgetent | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ ac_save_LIBS="$LIBS"
+LIBS="-lcurses $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 1862 "configure"
+#include "confdefs.h"
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char tgetent();
+
+int main() {
+tgetent()
+; return 0; }
+EOF
+if { (eval echo configure:1873: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest*
+LIBS="$ac_save_LIBS"
+
+fi
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ bash_cv_termcap_lib=libcurses
+else
+ echo "$ac_t""no" 1>&6
+echo $ac_n "checking for tgetent in -lncurses""... $ac_c" 1>&6
+echo "configure:1892: checking for tgetent in -lncurses" >&5
+ac_lib_var=`echo ncurses'_'tgetent | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ ac_save_LIBS="$LIBS"
+LIBS="-lncurses $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 1900 "configure"
+#include "confdefs.h"
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char tgetent();
+
+int main() {
+tgetent()
+; return 0; }
+EOF
+if { (eval echo configure:1911: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest*
+LIBS="$ac_save_LIBS"
+
+fi
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ bash_cv_termcap_lib=libncurses
+else
+ echo "$ac_t""no" 1>&6
+bash_cv_termcap_lib=gnutermcap
+fi
+
+fi
+
+fi
+
+fi
+
+if test "X$_bash_needmsg" = "Xyes"; then
+echo $ac_n "checking which library has the termcap functions""... $ac_c" 1>&6
+echo "configure:1940: checking which library has the termcap functions" >&5
+fi
+echo "$ac_t""using $bash_cv_termcap_lib" 1>&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 = libncurses; then
+TERMCAP_LIB=-lncurses
+TERMCAP_DEP=
+else
+TERMCAP_LIB=-lcurses
+TERMCAP_DEP=
+fi
+
+ fi
+
test "x$prefix" = xNONE && _rl_prefix=$ac_default_prefix || _rl_prefix=${prefix}
test "x$exec_prefix" = xNONE && _rl_exec_prefix=${_rl_prefix} || _rl_exec_prefix=${exec_prefix}
echo $ac_n "checking version of installed readline library""... $ac_c" 1>&6
-echo "configure:1553: checking version of installed readline library" >&5
- _rl_version=`exec_prefix=${_rl_exec_prefix} ${CONFIG_SHELL-/bin/sh} ${srcdir}/support/rlvers.sh -C "${CC}" -L ${libdir}`
+echo "configure:1964: checking version of installed readline library" >&5
+ _rl_version=`exec_prefix=${_rl_exec_prefix} ${CONFIG_SHELL-/bin/sh} ${srcdir}/support/rlvers.sh -C "${CC}" -L ${libdir} -T ${TERMCAP_LIB}`
echo "$ac_t""$_rl_version" 1>&6
case "$_rl_version" in
- 3*|4*|5*|6*|7*|8*|9*) ;;
+ 4.[1-9]*|5*|6*|7*|8*|9*) ;;
*) opt_with_installed_readline=no
echo "configure: warning: installed readline library is too old to be linked with bash" 1>&2
echo "configure: warning: using private bash version" 1>&2
@@ -1623,28 +2034,30 @@ fi
# SunOS /usr/etc/install
# IRIX /sbin/install
# AIX /bin/install
+# 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"
# ./install, which can be erroneously created by make from ./install.sh.
echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
-echo "configure:1631: checking for a BSD compatible install" >&5
+echo "configure:2043: checking for a BSD compatible install" >&5
if test -z "$INSTALL"; then
if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
- IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS="${IFS}:"
+ IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS=":"
for ac_dir in $PATH; do
# Account for people who put trailing slashes in PATH elements.
case "$ac_dir/" in
/|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;;
*)
# OSF1 and SCO ODT 3.0 have their own names for install.
- for ac_prog in ginstall installbsd scoinst install; do
+ # Don't use installbsd from OSF since it installs stuff as root
+ # by default.
+ for ac_prog in ginstall scoinst install; do
if test -f $ac_dir/$ac_prog; then
if test $ac_prog = install &&
grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then
# AIX install. It has an incompatible calling convention.
- # OSF/1 installbsd also uses dspmsg, but is usable.
:
else
ac_cv_path_install="$ac_dir/$ac_prog -c"
@@ -1674,20 +2087,23 @@ echo "$ac_t""$INSTALL" 1>&6
# It thinks the first close brace ends the variable substitution.
test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
+test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}'
+
test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
# Extract the first word of "ar", so it can be a program name with args.
set dummy ar; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1683: checking for $ac_word" >&5
+echo "configure:2098: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_AR'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
if test -n "$AR"; then
ac_cv_prog_AR="$AR" # Let the user override the test.
else
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
- for ac_dir in $PATH; do
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
test -z "$ac_dir" && ac_dir=.
if test -f $ac_dir/$ac_word; then
ac_cv_prog_AR="ar"
@@ -1708,15 +2124,16 @@ test -n "$ARFLAGS" || ARFLAGS="cr"
# Extract the first word of "ranlib", so it can be a program name with args.
set dummy ranlib; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1712: checking for $ac_word" >&5
+echo "configure:2128: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
if test -n "$RANLIB"; then
ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
else
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
- for ac_dir in $PATH; do
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
test -z "$ac_dir" && ac_dir=.
if test -f $ac_dir/$ac_word; then
ac_cv_prog_RANLIB="ranlib"
@@ -1739,15 +2156,16 @@ do
# Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1743: checking for $ac_word" >&5
+echo "configure:2160: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_YACC'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
if test -n "$YACC"; then
ac_cv_prog_YACC="$YACC" # Let the user override the test.
else
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
- for ac_dir in $PATH; do
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
test -z "$ac_dir" && ac_dir=.
if test -f $ac_dir/$ac_word; then
ac_cv_prog_YACC="$ac_prog"
@@ -1769,7 +2187,7 @@ done
test -n "$YACC" || YACC="yacc"
echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6
-echo "configure:1773: checking whether ${MAKE-make} sets \${MAKE}" >&5
+echo "configure:2191: checking whether ${MAKE-make} sets \${MAKE}" >&5
set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -1797,7 +2215,7 @@ fi
case "$host_os" in
-opennt*|interix*) MAKE_SHELL="$OPENNT_ROOT/bin/sh" ;;
+opennt*|interix*) MAKE_SHELL="$INTERIX_ROOT/bin/sh" ;;
*) MAKE_SHELL=/bin/sh ;;
esac
@@ -1805,19 +2223,19 @@ esac
# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works
# for constant arguments. Useless!
echo $ac_n "checking for working alloca.h""... $ac_c" 1>&6
-echo "configure:1809: checking for working alloca.h" >&5
+echo "configure:2227: checking for working alloca.h" >&5
if eval "test \"`echo '$''{'ac_cv_header_alloca_h'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1814 "configure"
+#line 2232 "configure"
#include "confdefs.h"
#include <alloca.h>
int main() {
char *p = alloca(2 * sizeof(int));
; return 0; }
EOF
-if { (eval echo configure:1821: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2239: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
ac_cv_header_alloca_h=yes
else
@@ -1838,25 +2256,30 @@ EOF
fi
echo $ac_n "checking for alloca""... $ac_c" 1>&6
-echo "configure:1842: checking for alloca" >&5
+echo "configure:2260: checking for alloca" >&5
if eval "test \"`echo '$''{'ac_cv_func_alloca_works'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1847 "configure"
+#line 2265 "configure"
#include "confdefs.h"
#ifdef __GNUC__
# define alloca __builtin_alloca
#else
-# if HAVE_ALLOCA_H
-# include <alloca.h>
+# ifdef _MSC_VER
+# include <malloc.h>
+# define alloca _alloca
# else
-# ifdef _AIX
- #pragma alloca
+# if HAVE_ALLOCA_H
+# include <alloca.h>
# else
-# ifndef alloca /* predefined by HP cc +Olibcalls */
+# ifdef _AIX
+ #pragma alloca
+# else
+# ifndef alloca /* predefined by HP cc +Olibcalls */
char *alloca ();
+# endif
# endif
# endif
# endif
@@ -1866,7 +2289,7 @@ int main() {
char *p = (char *) alloca(1);
; return 0; }
EOF
-if { (eval echo configure:1870: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2293: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
ac_cv_func_alloca_works=yes
else
@@ -1891,19 +2314,19 @@ if test $ac_cv_func_alloca_works = no; then
# 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=alloca.o
+ ALLOCA=alloca.${ac_objext}
cat >> confdefs.h <<\EOF
#define C_ALLOCA 1
EOF
echo $ac_n "checking whether alloca needs Cray hooks""... $ac_c" 1>&6
-echo "configure:1902: checking whether alloca needs Cray hooks" >&5
+echo "configure:2325: checking whether alloca needs Cray hooks" >&5
if eval "test \"`echo '$''{'ac_cv_os_cray'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1907 "configure"
+#line 2330 "configure"
#include "confdefs.h"
#if defined(CRAY) && ! defined(CRAY2)
webecray
@@ -1928,12 +2351,12 @@ echo "$ac_t""$ac_cv_os_cray" 1>&6
if test $ac_cv_os_cray = yes; then
for ac_func in _getb67 GETB67 getb67; do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:1932: checking for $ac_func" >&5
+echo "configure:2355: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1937 "configure"
+#line 2360 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -1956,7 +2379,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:1960: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2383: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@@ -1983,7 +2406,7 @@ done
fi
echo $ac_n "checking stack direction for C alloca""... $ac_c" 1>&6
-echo "configure:1987: checking stack direction for C alloca" >&5
+echo "configure:2410: checking stack direction for C alloca" >&5
if eval "test \"`echo '$''{'ac_cv_c_stack_direction'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1991,7 +2414,7 @@ else
ac_cv_c_stack_direction=0
else
cat > conftest.$ac_ext <<EOF
-#line 1995 "configure"
+#line 2418 "configure"
#include "confdefs.h"
find_stack_direction ()
{
@@ -2010,7 +2433,7 @@ main ()
exit (find_stack_direction() < 0);
}
EOF
-if { (eval echo configure:2014: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:2437: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
ac_cv_c_stack_direction=1
else
@@ -2032,7 +2455,7 @@ EOF
fi
echo $ac_n "checking whether getpgrp takes no argument""... $ac_c" 1>&6
-echo "configure:2036: checking whether getpgrp takes no argument" >&5
+echo "configure:2459: checking whether getpgrp takes no argument" >&5
if eval "test \"`echo '$''{'ac_cv_func_getpgrp_void'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -2040,7 +2463,7 @@ else
{ echo "configure: error: cannot check getpgrp if cross compiling" 1>&2; exit 1; }
else
cat > conftest.$ac_ext <<EOF
-#line 2044 "configure"
+#line 2467 "configure"
#include "confdefs.h"
/*
@@ -2095,7 +2518,7 @@ main()
}
EOF
-if { (eval echo configure:2099: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:2522: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
ac_cv_func_getpgrp_void=yes
else
@@ -2119,7 +2542,7 @@ EOF
fi
echo $ac_n "checking whether setvbuf arguments are reversed""... $ac_c" 1>&6
-echo "configure:2123: checking whether setvbuf arguments are reversed" >&5
+echo "configure:2546: checking whether setvbuf arguments are reversed" >&5
if eval "test \"`echo '$''{'ac_cv_func_setvbuf_reversed'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -2127,7 +2550,7 @@ else
{ echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
else
cat > conftest.$ac_ext <<EOF
-#line 2131 "configure"
+#line 2554 "configure"
#include "confdefs.h"
#include <stdio.h>
/* If setvbuf has the reversed format, exit 0. */
@@ -2141,7 +2564,7 @@ main () {
exit(0); /* Non-reversed systems segv here. */
}
EOF
-if { (eval echo configure:2145: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:2568: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
ac_cv_func_setvbuf_reversed=yes
else
@@ -2165,12 +2588,12 @@ EOF
fi
echo $ac_n "checking for vprintf""... $ac_c" 1>&6
-echo "configure:2169: checking for vprintf" >&5
+echo "configure:2592: checking for vprintf" >&5
if eval "test \"`echo '$''{'ac_cv_func_vprintf'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2174 "configure"
+#line 2597 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char vprintf(); below. */
@@ -2193,7 +2616,7 @@ vprintf();
; return 0; }
EOF
-if { (eval echo configure:2197: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2620: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_vprintf=yes"
else
@@ -2217,12 +2640,12 @@ fi
if test "$ac_cv_func_vprintf" != yes; then
echo $ac_n "checking for _doprnt""... $ac_c" 1>&6
-echo "configure:2221: checking for _doprnt" >&5
+echo "configure:2644: checking for _doprnt" >&5
if eval "test \"`echo '$''{'ac_cv_func__doprnt'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2226 "configure"
+#line 2649 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char _doprnt(); below. */
@@ -2245,7 +2668,7 @@ _doprnt();
; return 0; }
EOF
-if { (eval echo configure:2249: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2672: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func__doprnt=yes"
else
@@ -2270,7 +2693,7 @@ fi
fi
echo $ac_n "checking for wait3 that fills in rusage""... $ac_c" 1>&6
-echo "configure:2274: checking for wait3 that fills in rusage" >&5
+echo "configure:2697: checking for wait3 that fills in rusage" >&5
if eval "test \"`echo '$''{'ac_cv_func_wait3_rusage'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -2278,7 +2701,7 @@ else
ac_cv_func_wait3_rusage=no
else
cat > conftest.$ac_ext <<EOF
-#line 2282 "configure"
+#line 2705 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/time.h>
@@ -2309,7 +2732,7 @@ main() {
}
}
EOF
-if { (eval echo configure:2313: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:2736: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
ac_cv_func_wait3_rusage=yes
else
@@ -2332,7 +2755,7 @@ EOF
fi
echo $ac_n "checking for working strcoll""... $ac_c" 1>&6
-echo "configure:2336: checking for working strcoll" >&5
+echo "configure:2759: checking for working strcoll" >&5
if eval "test \"`echo '$''{'ac_cv_func_strcoll_works'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -2340,7 +2763,7 @@ else
ac_cv_func_strcoll_works=no
else
cat > conftest.$ac_ext <<EOF
-#line 2344 "configure"
+#line 2767 "configure"
#include "confdefs.h"
#include <string.h>
main ()
@@ -2350,7 +2773,7 @@ main ()
strcoll ("123", "456") >= 0);
}
EOF
-if { (eval echo configure:2354: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:2777: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
ac_cv_func_strcoll_works=yes
else
@@ -2375,9 +2798,9 @@ fi
if test "$ac_cv_func_vprintf" = no; then
echo $ac_n "checking for declaration of vprintf in stdio.h""... $ac_c" 1>&6
-echo "configure:2379: checking for declaration of vprintf in stdio.h" >&5
+echo "configure:2802: checking for declaration of vprintf in stdio.h" >&5
cat > conftest.$ac_ext <<EOF
-#line 2381 "configure"
+#line 2804 "configure"
#include "confdefs.h"
#include <stdio.h>
EOF
@@ -2398,12 +2821,12 @@ EOF
fi
echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6
-echo "configure:2402: checking return type of signal handlers" >&5
+echo "configure:2825: checking return type of signal handlers" >&5
if eval "test \"`echo '$''{'ac_cv_type_signal'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2407 "configure"
+#line 2830 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <signal.h>
@@ -2420,7 +2843,7 @@ int main() {
int i;
; return 0; }
EOF
-if { (eval echo configure:2424: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2847: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_type_signal=void
else
@@ -2440,12 +2863,12 @@ EOF
echo $ac_n "checking for __setostype""... $ac_c" 1>&6
-echo "configure:2444: checking for __setostype" >&5
+echo "configure:2867: checking for __setostype" >&5
if eval "test \"`echo '$''{'ac_cv_func___setostype'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2449 "configure"
+#line 2872 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char __setostype(); below. */
@@ -2468,7 +2891,7 @@ __setostype();
; return 0; }
EOF
-if { (eval echo configure:2472: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2895: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func___setostype=yes"
else
@@ -2491,12 +2914,12 @@ else
fi
echo $ac_n "checking for wait3""... $ac_c" 1>&6
-echo "configure:2495: checking for wait3" >&5
+echo "configure:2918: checking for wait3" >&5
if eval "test \"`echo '$''{'ac_cv_func_wait3'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2500 "configure"
+#line 2923 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char wait3(); below. */
@@ -2519,7 +2942,7 @@ wait3();
; return 0; }
EOF
-if { (eval echo configure:2523: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2946: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_wait3=yes"
else
@@ -2543,12 +2966,12 @@ fi
echo $ac_n "checking for mkfifo""... $ac_c" 1>&6
-echo "configure:2547: checking for mkfifo" >&5
+echo "configure:2970: checking for mkfifo" >&5
if eval "test \"`echo '$''{'ac_cv_func_mkfifo'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2552 "configure"
+#line 2975 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char mkfifo(); below. */
@@ -2571,7 +2994,7 @@ mkfifo();
; return 0; }
EOF
-if { (eval echo configure:2575: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2998: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_mkfifo=yes"
else
@@ -2603,12 +3026,12 @@ for ac_func in dup2 select getdtablesize getgroups gethostname \
getrlimit getrusage gettimeofday waitpid tcgetpgrp rename
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:2607: checking for $ac_func" >&5
+echo "configure:3030: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2612 "configure"
+#line 3035 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -2631,7 +3054,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:2635: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3058: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@@ -2659,15 +3082,16 @@ done
for ac_func in bcopy bzero confstr getcwd strcasecmp setenv putenv \
setlinebuf setlocale strchr strerror strtod strtol \
strtoul tcgetattr uname sysconf ulimit times tzset \
- siginterrupt memmove
+ siginterrupt memmove ttyname gethostbyname inet_aton \
+ strpbrk setvbuf
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:2666: checking for $ac_func" >&5
+echo "configure:3090: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2671 "configure"
+#line 3095 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -2690,7 +3114,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:2694: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3118: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@@ -2719,18 +3143,18 @@ for ac_hdr in libintl.h
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:2723: checking for $ac_hdr" >&5
+echo "configure:3147: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2728 "configure"
+#line 3152 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2733: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:3157: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
eval "ac_cv_header_$ac_safe=yes"
@@ -2758,12 +3182,12 @@ done
for ac_func in gettext textdomain bindtextdomain
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:2762: checking for $ac_func" >&5
+echo "configure:3186: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2767 "configure"
+#line 3191 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -2786,7 +3210,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:2790: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3214: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@@ -2813,7 +3237,7 @@ done
if test "$ac_cv_func_bindtextdomain" = "no"; then
echo $ac_n "checking for bindtextdomain in -lintl""... $ac_c" 1>&6
-echo "configure:2817: checking for bindtextdomain in -lintl" >&5
+echo "configure:3241: checking for bindtextdomain in -lintl" >&5
ac_lib_var=`echo intl'_'bindtextdomain | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -2821,7 +3245,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lintl $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 2825 "configure"
+#line 3249 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -2832,7 +3256,7 @@ int main() {
bindtextdomain()
; return 0; }
EOF
-if { (eval echo configure:2836: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3260: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -2863,12 +3287,12 @@ fi
for ac_func in gettext textdomain bindtextdomain
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:2867: checking for $ac_func" >&5
+echo "configure:3291: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2872 "configure"
+#line 3296 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -2891,7 +3315,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:2895: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3319: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@@ -2920,7 +3344,7 @@ fi
if test "$opt_static_link" != yes; then
echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6
-echo "configure:2924: checking for dlopen in -ldl" >&5
+echo "configure:3348: checking for dlopen in -ldl" >&5
ac_lib_var=`echo dl'_'dlopen | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -2928,7 +3352,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-ldl $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 2932 "configure"
+#line 3356 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -2939,7 +3363,7 @@ int main() {
dlopen()
; return 0; }
EOF
-if { (eval echo configure:2943: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3367: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -2969,12 +3393,12 @@ fi
for ac_func in dlopen dlclose dlsym
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:2973: checking for $ac_func" >&5
+echo "configure:3397: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2978 "configure"
+#line 3402 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -2997,7 +3421,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:3001: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3425: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@@ -3024,12 +3448,12 @@ done
fi
echo $ac_n "checking for sys_siglist declaration in signal.h or unistd.h""... $ac_c" 1>&6
-echo "configure:3028: checking for sys_siglist declaration in signal.h or unistd.h" >&5
+echo "configure:3452: checking for sys_siglist declaration in signal.h or unistd.h" >&5
if eval "test \"`echo '$''{'ac_cv_decl_sys_siglist'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 3033 "configure"
+#line 3457 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <signal.h>
@@ -3041,7 +3465,7 @@ int main() {
char *msg = *(sys_siglist + 1);
; return 0; }
EOF
-if { (eval echo configure:3045: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3469: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_decl_sys_siglist=yes
else
@@ -3067,12 +3491,12 @@ for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr that defines DIR""... $ac_c" 1>&6
-echo "configure:3071: checking for $ac_hdr that defines DIR" >&5
+echo "configure:3495: checking for $ac_hdr that defines DIR" >&5
if eval "test \"`echo '$''{'ac_cv_header_dirent_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 3076 "configure"
+#line 3500 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <$ac_hdr>
@@ -3080,7 +3504,7 @@ int main() {
DIR *dirp = 0;
; return 0; }
EOF
-if { (eval echo configure:3084: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3508: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
eval "ac_cv_header_dirent_$ac_safe=yes"
else
@@ -3105,7 +3529,7 @@ done
# Two versions of opendir et al. are in -ldir and -lx on SCO Xenix.
if test $ac_header_dirent = dirent.h; then
echo $ac_n "checking for opendir in -ldir""... $ac_c" 1>&6
-echo "configure:3109: checking for opendir in -ldir" >&5
+echo "configure:3533: checking for opendir in -ldir" >&5
ac_lib_var=`echo dir'_'opendir | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -3113,7 +3537,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-ldir $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 3117 "configure"
+#line 3541 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -3124,7 +3548,7 @@ int main() {
opendir()
; return 0; }
EOF
-if { (eval echo configure:3128: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3552: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -3146,7 +3570,7 @@ fi
else
echo $ac_n "checking for opendir in -lx""... $ac_c" 1>&6
-echo "configure:3150: checking for opendir in -lx" >&5
+echo "configure:3574: checking for opendir in -lx" >&5
ac_lib_var=`echo x'_'opendir | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -3154,7 +3578,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lx $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 3158 "configure"
+#line 3582 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -3165,7 +3589,7 @@ int main() {
opendir()
; return 0; }
EOF
-if { (eval echo configure:3169: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3593: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -3188,12 +3612,12 @@ fi
fi
echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6
-echo "configure:3192: checking whether time.h and sys/time.h may both be included" >&5
+echo "configure:3616: checking whether time.h and sys/time.h may both be included" >&5
if eval "test \"`echo '$''{'ac_cv_header_time'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 3197 "configure"
+#line 3621 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/time.h>
@@ -3202,7 +3626,7 @@ int main() {
struct tm *tp;
; return 0; }
EOF
-if { (eval echo configure:3206: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3630: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_header_time=yes
else
@@ -3225,22 +3649,22 @@ fi
for ac_hdr 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 \
- stddef.h
+ stddef.h netdb.h
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:3233: checking for $ac_hdr" >&5
+echo "configure:3657: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 3238 "configure"
+#line 3662 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:3243: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:3667: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
eval "ac_cv_header_$ac_safe=yes"
@@ -3271,18 +3695,58 @@ for ac_hdr in sys/ptem.h sys/pte.h sys/stream.h sys/select.h sys/file.h \
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:3275: checking for $ac_hdr" >&5
+echo "configure:3699: checking for $ac_hdr" >&5
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 3704 "configure"
+#include "confdefs.h"
+#include <$ac_hdr>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:3709: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=yes"
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=no"
+fi
+rm -f conftest*
+fi
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_hdr 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+done
+
+for ac_hdr in netinet/in.h arpa/inet.h
+do
+ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+echo "configure:3739: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 3280 "configure"
+#line 3744 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:3285: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:3749: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
eval "ac_cv_header_$ac_safe=yes"
@@ -3308,20 +3772,111 @@ fi
done
+if test "$ac_cv_func_inet_aton" != 'yes'; then
+
+echo $ac_n "checking for inet_aton""... $ac_c" 1>&6
+echo "configure:3779: checking for inet_aton" >&5
+if eval "test \"`echo '$''{'bash_cv_func_inet_aton'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 3784 "configure"
+#include "confdefs.h"
+
+#include <sys/types.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+struct in_addr ap;
+int main() {
+ inet_aton("127.0.0.1", &ap);
+; return 0; }
+EOF
+if { (eval echo configure:3795: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ bash_cv_func_inet_aton=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ bash_cv_func_inet_aton=no
+fi
+rm -f conftest*
+fi
+
+echo "$ac_t""$bash_cv_func_inet_aton" 1>&6
+if test $bash_cv_func_inet_aton = yes; then
+ cat >> confdefs.h <<\EOF
+#define HAVE_INET_ATON 1
+EOF
+
+fi
+
+fi
+
+case "$host_os" in
+irix4*) echo $ac_n "checking for getpwent in -lsun""... $ac_c" 1>&6
+echo "configure:3819: checking for getpwent in -lsun" >&5
+ac_lib_var=`echo sun'_'getpwent | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ ac_save_LIBS="$LIBS"
+LIBS="-lsun $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 3827 "configure"
+#include "confdefs.h"
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char getpwent();
+
+int main() {
+getpwent()
+; return 0; }
+EOF
+if { (eval echo configure:3838: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest*
+LIBS="$ac_save_LIBS"
+
+fi
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_lib=HAVE_LIB`echo sun | sed -e 's/[^a-zA-Z0-9_]/_/g' \
+ -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_lib 1
+EOF
+
+ LIBS="-lsun $LIBS"
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+ ;;
+esac
+
if test "$ac_cv_func_getpeername" = no; then
if test "X$bash_cv_have_socklib" = "X"; then
_bash_needmsg=
else
echo $ac_n "checking for socket library""... $ac_c" 1>&6
-echo "configure:3318: checking for socket library" >&5
+echo "configure:3873: checking for socket library" >&5
_bash_needmsg=yes
fi
if eval "test \"`echo '$''{'bash_cv_have_socklib'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
echo $ac_n "checking for getpeername in -lsocket""... $ac_c" 1>&6
-echo "configure:3325: checking for getpeername in -lsocket" >&5
+echo "configure:3880: checking for getpeername in -lsocket" >&5
ac_lib_var=`echo socket'_'getpeername | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -3329,7 +3884,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lsocket -lnsl $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 3333 "configure"
+#line 3888 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -3340,7 +3895,7 @@ int main() {
getpeername()
; return 0; }
EOF
-if { (eval echo configure:3344: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3899: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -3373,14 +3928,14 @@ if test $bash_cv_have_socklib = yes; then
_bash_needmsg=
else
echo $ac_n "checking for libnsl""... $ac_c" 1>&6
-echo "configure:3377: checking for libnsl" >&5
+echo "configure:3932: checking for libnsl" >&5
_bash_needmsg=yes
fi
if eval "test \"`echo '$''{'bash_cv_have_libnsl'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
echo $ac_n "checking for t_open in -lnsl""... $ac_c" 1>&6
-echo "configure:3384: checking for t_open in -lnsl" >&5
+echo "configure:3939: checking for t_open in -lnsl" >&5
ac_lib_var=`echo nsl'_'t_open | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -3388,7 +3943,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lnsl $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 3392 "configure"
+#line 3947 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -3399,7 +3954,7 @@ int main() {
t_open()
; return 0; }
EOF
-if { (eval echo configure:3403: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3958: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -3442,14 +3997,61 @@ EOF
fi
fi
+if test "$ac_cv_func_gethostbyname" = no; then
+ if test "X$bash_cv_have_gethostbyname" = "X"; then
+_bash_needmsg=yes
+else
+echo $ac_n "checking for gethostbyname in socket library""... $ac_c" 1>&6
+echo "configure:4006: checking for gethostbyname in socket library" >&5
+_bash_needmsg=
+fi
+if eval "test \"`echo '$''{'bash_cv_have_gethostbyname'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 4013 "configure"
+#include "confdefs.h"
+#include <netdb.h>
+int main() {
+ struct hostent *hp;
+ hp = gethostbyname("localhost");
+
+; return 0; }
+EOF
+if { (eval echo configure:4022: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ bash_cv_have_gethostbyname=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ bash_cv_have_gethostbyname=no
+fi
+rm -f conftest*
+
+fi
+
+if test "X$_bash_needmsg" = Xyes; then
+ echo $ac_n "checking for gethostbyname in socket library""... $ac_c" 1>&6
+echo "configure:4037: checking for gethostbyname in socket library" >&5
+fi
+echo "$ac_t""$bash_cv_have_gethostbyname" 1>&6
+if test "$bash_cv_have_gethostbyname" = yes; then
+cat >> confdefs.h <<\EOF
+#define HAVE_GETHOSTBYNAME 1
+EOF
+
+fi
+
+fi
echo $ac_n "checking for uid_t in sys/types.h""... $ac_c" 1>&6
-echo "configure:3448: checking for uid_t in sys/types.h" >&5
+echo "configure:4050: checking for uid_t in sys/types.h" >&5
if eval "test \"`echo '$''{'ac_cv_type_uid_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 3453 "configure"
+#line 4055 "configure"
#include "confdefs.h"
#include <sys/types.h>
EOF
@@ -3478,7 +4080,7 @@ EOF
fi
echo $ac_n "checking type of array argument to getgroups""... $ac_c" 1>&6
-echo "configure:3482: checking type of array argument to getgroups" >&5
+echo "configure:4084: checking type of array argument to getgroups" >&5
if eval "test \"`echo '$''{'ac_cv_type_getgroups'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -3486,7 +4088,7 @@ else
ac_cv_type_getgroups=cross
else
cat > conftest.$ac_ext <<EOF
-#line 3490 "configure"
+#line 4092 "configure"
#include "confdefs.h"
/* Thanks to Mike Rendell for this test. */
@@ -3511,7 +4113,7 @@ main()
}
EOF
-if { (eval echo configure:3515: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:4117: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
ac_cv_type_getgroups=gid_t
else
@@ -3525,7 +4127,7 @@ fi
if test $ac_cv_type_getgroups = cross; then
cat > conftest.$ac_ext <<EOF
-#line 3529 "configure"
+#line 4131 "configure"
#include "confdefs.h"
#include <unistd.h>
EOF
@@ -3549,12 +4151,12 @@ EOF
echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
-echo "configure:3553: checking for ANSI C header files" >&5
+echo "configure:4155: checking for ANSI C header files" >&5
if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 3558 "configure"
+#line 4160 "configure"
#include "confdefs.h"
#include <stdlib.h>
#include <stdarg.h>
@@ -3562,8 +4164,8 @@ else
#include <float.h>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:3566: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out`
+{ (eval echo configure:4168: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
ac_cv_header_stdc=yes
@@ -3579,7 +4181,7 @@ rm -f conftest*
if test $ac_cv_header_stdc = yes; then
# SunOS 4.x string.h does not declare mem*, contrary to ANSI.
cat > conftest.$ac_ext <<EOF
-#line 3583 "configure"
+#line 4185 "configure"
#include "confdefs.h"
#include <string.h>
EOF
@@ -3597,7 +4199,7 @@ fi
if test $ac_cv_header_stdc = yes; then
# ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
cat > conftest.$ac_ext <<EOF
-#line 3601 "configure"
+#line 4203 "configure"
#include "confdefs.h"
#include <stdlib.h>
EOF
@@ -3618,7 +4220,7 @@ if test "$cross_compiling" = yes; then
:
else
cat > conftest.$ac_ext <<EOF
-#line 3622 "configure"
+#line 4224 "configure"
#include "confdefs.h"
#include <ctype.h>
#define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
@@ -3629,7 +4231,7 @@ if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
exit (0); }
EOF
-if { (eval echo configure:3633: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:4235: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
:
else
@@ -3653,12 +4255,12 @@ EOF
fi
echo $ac_n "checking for off_t""... $ac_c" 1>&6
-echo "configure:3657: checking for off_t" >&5
+echo "configure:4259: checking for off_t" >&5
if eval "test \"`echo '$''{'ac_cv_type_off_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 3662 "configure"
+#line 4264 "configure"
#include "confdefs.h"
#include <sys/types.h>
#if STDC_HEADERS
@@ -3667,7 +4269,7 @@ else
#endif
EOF
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- egrep "off_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
+ egrep "(^|[^a-zA-Z_0-9])off_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
rm -rf conftest*
ac_cv_type_off_t=yes
else
@@ -3686,12 +4288,12 @@ EOF
fi
echo $ac_n "checking for mode_t""... $ac_c" 1>&6
-echo "configure:3690: checking for mode_t" >&5
+echo "configure:4292: checking for mode_t" >&5
if eval "test \"`echo '$''{'ac_cv_type_mode_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 3695 "configure"
+#line 4297 "configure"
#include "confdefs.h"
#include <sys/types.h>
#if STDC_HEADERS
@@ -3700,7 +4302,7 @@ else
#endif
EOF
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- egrep "mode_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
+ egrep "(^|[^a-zA-Z_0-9])mode_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
rm -rf conftest*
ac_cv_type_mode_t=yes
else
@@ -3719,12 +4321,12 @@ EOF
fi
echo $ac_n "checking for uid_t in sys/types.h""... $ac_c" 1>&6
-echo "configure:3723: checking for uid_t in sys/types.h" >&5
+echo "configure:4325: checking for uid_t in sys/types.h" >&5
if eval "test \"`echo '$''{'ac_cv_type_uid_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 3728 "configure"
+#line 4330 "configure"
#include "confdefs.h"
#include <sys/types.h>
EOF
@@ -3753,12 +4355,12 @@ EOF
fi
echo $ac_n "checking for pid_t""... $ac_c" 1>&6
-echo "configure:3757: checking for pid_t" >&5
+echo "configure:4359: checking for pid_t" >&5
if eval "test \"`echo '$''{'ac_cv_type_pid_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 3762 "configure"
+#line 4364 "configure"
#include "confdefs.h"
#include <sys/types.h>
#if STDC_HEADERS
@@ -3767,7 +4369,7 @@ else
#endif
EOF
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- egrep "pid_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
+ egrep "(^|[^a-zA-Z_0-9])pid_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
rm -rf conftest*
ac_cv_type_pid_t=yes
else
@@ -3786,12 +4388,12 @@ EOF
fi
echo $ac_n "checking for size_t""... $ac_c" 1>&6
-echo "configure:3790: checking for size_t" >&5
+echo "configure:4392: checking for size_t" >&5
if eval "test \"`echo '$''{'ac_cv_type_size_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 3795 "configure"
+#line 4397 "configure"
#include "confdefs.h"
#include <sys/types.h>
#if STDC_HEADERS
@@ -3800,7 +4402,7 @@ else
#endif
EOF
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- egrep "size_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
+ egrep "(^|[^a-zA-Z_0-9])size_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
rm -rf conftest*
ac_cv_type_size_t=yes
else
@@ -3819,12 +4421,12 @@ EOF
fi
echo $ac_n "checking for time_t""... $ac_c" 1>&6
-echo "configure:3823: checking for time_t" >&5
+echo "configure:4425: checking for time_t" >&5
if eval "test \"`echo '$''{'ac_cv_type_time_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 3828 "configure"
+#line 4430 "configure"
#include "confdefs.h"
#include <sys/types.h>
#if STDC_HEADERS
@@ -3833,7 +4435,7 @@ else
#endif
EOF
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- egrep "time_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
+ egrep "(^|[^a-zA-Z_0-9])time_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
rm -rf conftest*
ac_cv_type_time_t=yes
else
@@ -3853,12 +4455,12 @@ fi
echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6
-echo "configure:3857: checking return type of signal handlers" >&5
+echo "configure:4459: checking return type of signal handlers" >&5
if eval "test \"`echo '$''{'ac_cv_type_signal'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 3862 "configure"
+#line 4464 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <signal.h>
@@ -3875,7 +4477,7 @@ int main() {
int i;
; return 0; }
EOF
-if { (eval echo configure:3879: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:4481: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_type_signal=void
else
@@ -3894,8 +4496,86 @@ EOF
+echo $ac_n "checking size of char""... $ac_c" 1>&6
+echo "configure:4501: checking size of char" >&5
+if eval "test \"`echo '$''{'ac_cv_sizeof_char'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test "$cross_compiling" = yes; then
+ ac_cv_sizeof_char=1
+else
+ cat > conftest.$ac_ext <<EOF
+#line 4509 "configure"
+#include "confdefs.h"
+#include <stdio.h>
+main()
+{
+ FILE *f=fopen("conftestval", "w");
+ if (!f) exit(1);
+ fprintf(f, "%d\n", sizeof(char));
+ exit(0);
+}
+EOF
+if { (eval echo configure:4520: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+then
+ ac_cv_sizeof_char=`cat conftestval`
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -fr conftest*
+ ac_cv_sizeof_char=0
+fi
+rm -fr conftest*
+fi
+
+fi
+echo "$ac_t""$ac_cv_sizeof_char" 1>&6
+cat >> confdefs.h <<EOF
+#define SIZEOF_CHAR $ac_cv_sizeof_char
+EOF
+
+
+echo $ac_n "checking size of short""... $ac_c" 1>&6
+echo "configure:4540: checking size of short" >&5
+if eval "test \"`echo '$''{'ac_cv_sizeof_short'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test "$cross_compiling" = yes; then
+ ac_cv_sizeof_short=2
+else
+ cat > conftest.$ac_ext <<EOF
+#line 4548 "configure"
+#include "confdefs.h"
+#include <stdio.h>
+main()
+{
+ FILE *f=fopen("conftestval", "w");
+ if (!f) exit(1);
+ fprintf(f, "%d\n", sizeof(short));
+ exit(0);
+}
+EOF
+if { (eval echo configure:4559: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+then
+ ac_cv_sizeof_short=`cat conftestval`
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -fr conftest*
+ ac_cv_sizeof_short=0
+fi
+rm -fr conftest*
+fi
+
+fi
+echo "$ac_t""$ac_cv_sizeof_short" 1>&6
+cat >> confdefs.h <<EOF
+#define SIZEOF_SHORT $ac_cv_sizeof_short
+EOF
+
+
echo $ac_n "checking size of int""... $ac_c" 1>&6
-echo "configure:3899: checking size of int" >&5
+echo "configure:4579: checking size of int" >&5
if eval "test \"`echo '$''{'ac_cv_sizeof_int'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -3903,7 +4583,7 @@ else
ac_cv_sizeof_int=4
else
cat > conftest.$ac_ext <<EOF
-#line 3907 "configure"
+#line 4587 "configure"
#include "confdefs.h"
#include <stdio.h>
main()
@@ -3914,7 +4594,7 @@ main()
exit(0);
}
EOF
-if { (eval echo configure:3918: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:4598: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
ac_cv_sizeof_int=`cat conftestval`
else
@@ -3934,7 +4614,7 @@ EOF
echo $ac_n "checking size of long""... $ac_c" 1>&6
-echo "configure:3938: checking size of long" >&5
+echo "configure:4618: checking size of long" >&5
if eval "test \"`echo '$''{'ac_cv_sizeof_long'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -3942,7 +4622,7 @@ else
ac_cv_sizeof_long=4
else
cat > conftest.$ac_ext <<EOF
-#line 3946 "configure"
+#line 4626 "configure"
#include "confdefs.h"
#include <stdio.h>
main()
@@ -3953,7 +4633,7 @@ main()
exit(0);
}
EOF
-if { (eval echo configure:3957: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:4637: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
ac_cv_sizeof_long=`cat conftestval`
else
@@ -3973,7 +4653,7 @@ EOF
echo $ac_n "checking size of char *""... $ac_c" 1>&6
-echo "configure:3977: checking size of char *" >&5
+echo "configure:4657: checking size of char *" >&5
if eval "test \"`echo '$''{'ac_cv_sizeof_char_p'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -3981,7 +4661,7 @@ else
ac_cv_sizeof_char_p=4
else
cat > conftest.$ac_ext <<EOF
-#line 3985 "configure"
+#line 4665 "configure"
#include "confdefs.h"
#include <stdio.h>
main()
@@ -3992,7 +4672,7 @@ main()
exit(0);
}
EOF
-if { (eval echo configure:3996: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:4676: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
ac_cv_sizeof_char_p=`cat conftestval`
else
@@ -4012,7 +4692,7 @@ EOF
echo $ac_n "checking size of double""... $ac_c" 1>&6
-echo "configure:4016: checking size of double" >&5
+echo "configure:4696: checking size of double" >&5
if eval "test \"`echo '$''{'ac_cv_sizeof_double'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -4020,7 +4700,7 @@ else
ac_cv_sizeof_double=8
else
cat > conftest.$ac_ext <<EOF
-#line 4024 "configure"
+#line 4704 "configure"
#include "confdefs.h"
#include <stdio.h>
main()
@@ -4031,7 +4711,7 @@ main()
exit(0);
}
EOF
-if { (eval echo configure:4035: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:4715: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
ac_cv_sizeof_double=`cat conftestval`
else
@@ -4051,15 +4731,46 @@ EOF
+echo $ac_n "checking for u_int""... $ac_c" 1>&6
+echo "configure:4736: checking for u_int" >&5
+if eval "test \"`echo '$''{'ac_cv_type_u_int'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 4741 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+#if STDC_HEADERS
+#include <stdlib.h>
+#include <stddef.h>
+#endif
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ egrep "(^|[^a-zA-Z_0-9])u_int[^a-zA-Z_0-9]" >/dev/null 2>&1; then
+ rm -rf conftest*
+ ac_cv_type_u_int=yes
+else
+ rm -rf conftest*
+ ac_cv_type_u_int=no
+fi
+rm -f conftest*
-if test "$ac_cv_sizeof_int" = 4; then
- echo $ac_n "checking for int32_t""... $ac_c" 1>&6
-echo "configure:4058: checking for int32_t" >&5
-if eval "test \"`echo '$''{'ac_cv_type_int32_t'+set}'`\" = set"; then
+fi
+echo "$ac_t""$ac_cv_type_u_int" 1>&6
+if test $ac_cv_type_u_int = no; then
+ cat >> confdefs.h <<\EOF
+#define u_int unsigned int
+EOF
+
+fi
+
+echo $ac_n "checking for u_long""... $ac_c" 1>&6
+echo "configure:4769: checking for u_long" >&5
+if eval "test \"`echo '$''{'ac_cv_type_u_long'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 4063 "configure"
+#line 4774 "configure"
#include "confdefs.h"
#include <sys/types.h>
#if STDC_HEADERS
@@ -4068,32 +4779,34 @@ else
#endif
EOF
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- egrep "int32_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
+ egrep "(^|[^a-zA-Z_0-9])u_long[^a-zA-Z_0-9]" >/dev/null 2>&1; then
rm -rf conftest*
- ac_cv_type_int32_t=yes
+ ac_cv_type_u_long=yes
else
rm -rf conftest*
- ac_cv_type_int32_t=no
+ ac_cv_type_u_long=no
fi
rm -f conftest*
fi
-echo "$ac_t""$ac_cv_type_int32_t" 1>&6
-if test $ac_cv_type_int32_t = no; then
+echo "$ac_t""$ac_cv_type_u_long" 1>&6
+if test $ac_cv_type_u_long = no; then
cat >> confdefs.h <<\EOF
-#define int32_t int
+#define u_long unsigned long
EOF
fi
-elif test "$ac_cv_sizeof_long" = 4; then
- echo $ac_n "checking for int32_t""... $ac_c" 1>&6
-echo "configure:4092: checking for int32_t" >&5
-if eval "test \"`echo '$''{'ac_cv_type_int32_t'+set}'`\" = set"; then
+
+
+if test "$ac_cv_sizeof_short" = 2; then
+ echo $ac_n "checking for bits16_t""... $ac_c" 1>&6
+echo "configure:4805: checking for bits16_t" >&5
+if eval "test \"`echo '$''{'ac_cv_type_bits16_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 4097 "configure"
+#line 4810 "configure"
#include "confdefs.h"
#include <sys/types.h>
#if STDC_HEADERS
@@ -4102,32 +4815,66 @@ else
#endif
EOF
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- egrep "int32_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
+ egrep "(^|[^a-zA-Z_0-9])bits16_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
rm -rf conftest*
- ac_cv_type_int32_t=yes
+ ac_cv_type_bits16_t=yes
else
rm -rf conftest*
- ac_cv_type_int32_t=no
+ ac_cv_type_bits16_t=no
fi
rm -f conftest*
fi
-echo "$ac_t""$ac_cv_type_int32_t" 1>&6
-if test $ac_cv_type_int32_t = no; then
+echo "$ac_t""$ac_cv_type_bits16_t" 1>&6
+if test $ac_cv_type_bits16_t = no; then
cat >> confdefs.h <<\EOF
-#define int32_t long
+#define bits16_t short
EOF
fi
+elif test "$ac_cv_sizeof_char" = 2; then
+ echo $ac_n "checking for bits16_t""... $ac_c" 1>&6
+echo "configure:4839: checking for bits16_t" >&5
+if eval "test \"`echo '$''{'ac_cv_type_bits16_t'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 4844 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+#if STDC_HEADERS
+#include <stdlib.h>
+#include <stddef.h>
+#endif
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ egrep "(^|[^a-zA-Z_0-9])bits16_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
+ rm -rf conftest*
+ ac_cv_type_bits16_t=yes
else
- echo $ac_n "checking for int32_t""... $ac_c" 1>&6
-echo "configure:4126: checking for int32_t" >&5
-if eval "test \"`echo '$''{'ac_cv_type_int32_t'+set}'`\" = set"; then
+ rm -rf conftest*
+ ac_cv_type_bits16_t=no
+fi
+rm -f conftest*
+
+fi
+echo "$ac_t""$ac_cv_type_bits16_t" 1>&6
+if test $ac_cv_type_bits16_t = no; then
+ cat >> confdefs.h <<\EOF
+#define bits16_t char
+EOF
+
+fi
+
+else
+ echo $ac_n "checking for bits16_t""... $ac_c" 1>&6
+echo "configure:4873: checking for bits16_t" >&5
+if eval "test \"`echo '$''{'ac_cv_type_bits16_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 4131 "configure"
+#line 4878 "configure"
#include "confdefs.h"
#include <sys/types.h>
#if STDC_HEADERS
@@ -4136,20 +4883,125 @@ else
#endif
EOF
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- egrep "int32_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
+ egrep "(^|[^a-zA-Z_0-9])bits16_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
rm -rf conftest*
- ac_cv_type_int32_t=yes
+ ac_cv_type_bits16_t=yes
else
rm -rf conftest*
- ac_cv_type_int32_t=no
+ ac_cv_type_bits16_t=no
fi
rm -f conftest*
fi
-echo "$ac_t""$ac_cv_type_int32_t" 1>&6
-if test $ac_cv_type_int32_t = no; then
+echo "$ac_t""$ac_cv_type_bits16_t" 1>&6
+if test $ac_cv_type_bits16_t = no; then
cat >> confdefs.h <<\EOF
-#define int32_t int
+#define bits16_t short
+EOF
+
+fi
+
+fi
+
+
+if test "$ac_cv_sizeof_short" = 2; then
+ echo $ac_n "checking for u_bits16_t""... $ac_c" 1>&6
+echo "configure:4910: checking for u_bits16_t" >&5
+if eval "test \"`echo '$''{'ac_cv_type_u_bits16_t'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 4915 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+#if STDC_HEADERS
+#include <stdlib.h>
+#include <stddef.h>
+#endif
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ egrep "(^|[^a-zA-Z_0-9])u_bits16_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
+ rm -rf conftest*
+ ac_cv_type_u_bits16_t=yes
+else
+ rm -rf conftest*
+ ac_cv_type_u_bits16_t=no
+fi
+rm -f conftest*
+
+fi
+echo "$ac_t""$ac_cv_type_u_bits16_t" 1>&6
+if test $ac_cv_type_u_bits16_t = no; then
+ cat >> confdefs.h <<\EOF
+#define u_bits16_t unsigned short
+EOF
+
+fi
+
+elif test "$ac_cv_sizeof_char" = 2; then
+ echo $ac_n "checking for u_bits16_t""... $ac_c" 1>&6
+echo "configure:4944: checking for u_bits16_t" >&5
+if eval "test \"`echo '$''{'ac_cv_type_u_bits16_t'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 4949 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+#if STDC_HEADERS
+#include <stdlib.h>
+#include <stddef.h>
+#endif
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ egrep "(^|[^a-zA-Z_0-9])u_bits16_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
+ rm -rf conftest*
+ ac_cv_type_u_bits16_t=yes
+else
+ rm -rf conftest*
+ ac_cv_type_u_bits16_t=no
+fi
+rm -f conftest*
+
+fi
+echo "$ac_t""$ac_cv_type_u_bits16_t" 1>&6
+if test $ac_cv_type_u_bits16_t = no; then
+ cat >> confdefs.h <<\EOF
+#define u_bits16_t unsigned char
+EOF
+
+fi
+
+else
+ echo $ac_n "checking for u_bits16_t""... $ac_c" 1>&6
+echo "configure:4978: checking for u_bits16_t" >&5
+if eval "test \"`echo '$''{'ac_cv_type_u_bits16_t'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 4983 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+#if STDC_HEADERS
+#include <stdlib.h>
+#include <stddef.h>
+#endif
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ egrep "(^|[^a-zA-Z_0-9])u_bits16_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
+ rm -rf conftest*
+ ac_cv_type_u_bits16_t=yes
+else
+ rm -rf conftest*
+ ac_cv_type_u_bits16_t=no
+fi
+rm -f conftest*
+
+fi
+echo "$ac_t""$ac_cv_type_u_bits16_t" 1>&6
+if test $ac_cv_type_u_bits16_t = no; then
+ cat >> confdefs.h <<\EOF
+#define u_bits16_t unsigned short
EOF
fi
@@ -4158,13 +5010,13 @@ fi
if test "$ac_cv_sizeof_int" = 4; then
- echo $ac_n "checking for u_int32_t""... $ac_c" 1>&6
-echo "configure:4163: checking for u_int32_t" >&5
-if eval "test \"`echo '$''{'ac_cv_type_u_int32_t'+set}'`\" = set"; then
+ echo $ac_n "checking for bits32_t""... $ac_c" 1>&6
+echo "configure:5015: checking for bits32_t" >&5
+if eval "test \"`echo '$''{'ac_cv_type_bits32_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 4168 "configure"
+#line 5020 "configure"
#include "confdefs.h"
#include <sys/types.h>
#if STDC_HEADERS
@@ -4173,32 +5025,32 @@ else
#endif
EOF
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- egrep "u_int32_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
+ egrep "(^|[^a-zA-Z_0-9])bits32_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
rm -rf conftest*
- ac_cv_type_u_int32_t=yes
+ ac_cv_type_bits32_t=yes
else
rm -rf conftest*
- ac_cv_type_u_int32_t=no
+ ac_cv_type_bits32_t=no
fi
rm -f conftest*
fi
-echo "$ac_t""$ac_cv_type_u_int32_t" 1>&6
-if test $ac_cv_type_u_int32_t = no; then
+echo "$ac_t""$ac_cv_type_bits32_t" 1>&6
+if test $ac_cv_type_bits32_t = no; then
cat >> confdefs.h <<\EOF
-#define u_int32_t unsigned int
+#define bits32_t int
EOF
fi
elif test "$ac_cv_sizeof_long" = 4; then
- echo $ac_n "checking for u_int32_t""... $ac_c" 1>&6
-echo "configure:4197: checking for u_int32_t" >&5
-if eval "test \"`echo '$''{'ac_cv_type_u_int32_t'+set}'`\" = set"; then
+ echo $ac_n "checking for bits32_t""... $ac_c" 1>&6
+echo "configure:5049: checking for bits32_t" >&5
+if eval "test \"`echo '$''{'ac_cv_type_bits32_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 4202 "configure"
+#line 5054 "configure"
#include "confdefs.h"
#include <sys/types.h>
#if STDC_HEADERS
@@ -4207,32 +5059,32 @@ else
#endif
EOF
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- egrep "u_int32_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
+ egrep "(^|[^a-zA-Z_0-9])bits32_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
rm -rf conftest*
- ac_cv_type_u_int32_t=yes
+ ac_cv_type_bits32_t=yes
else
rm -rf conftest*
- ac_cv_type_u_int32_t=no
+ ac_cv_type_bits32_t=no
fi
rm -f conftest*
fi
-echo "$ac_t""$ac_cv_type_u_int32_t" 1>&6
-if test $ac_cv_type_u_int32_t = no; then
+echo "$ac_t""$ac_cv_type_bits32_t" 1>&6
+if test $ac_cv_type_bits32_t = no; then
cat >> confdefs.h <<\EOF
-#define u_int32_t unsigned long
+#define bits32_t long
EOF
fi
else
- echo $ac_n "checking for u_int32_t""... $ac_c" 1>&6
-echo "configure:4231: checking for u_int32_t" >&5
-if eval "test \"`echo '$''{'ac_cv_type_u_int32_t'+set}'`\" = set"; then
+ echo $ac_n "checking for bits32_t""... $ac_c" 1>&6
+echo "configure:5083: checking for bits32_t" >&5
+if eval "test \"`echo '$''{'ac_cv_type_bits32_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 4236 "configure"
+#line 5088 "configure"
#include "confdefs.h"
#include <sys/types.h>
#if STDC_HEADERS
@@ -4241,20 +5093,20 @@ else
#endif
EOF
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- egrep "u_int32_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
+ egrep "(^|[^a-zA-Z_0-9])bits32_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
rm -rf conftest*
- ac_cv_type_u_int32_t=yes
+ ac_cv_type_bits32_t=yes
else
rm -rf conftest*
- ac_cv_type_u_int32_t=no
+ ac_cv_type_bits32_t=no
fi
rm -f conftest*
fi
-echo "$ac_t""$ac_cv_type_u_int32_t" 1>&6
-if test $ac_cv_type_u_int32_t = no; then
+echo "$ac_t""$ac_cv_type_bits32_t" 1>&6
+if test $ac_cv_type_bits32_t = no; then
cat >> confdefs.h <<\EOF
-#define u_int32_t unsigned int
+#define bits32_t int
EOF
fi
@@ -4262,14 +5114,14 @@ fi
fi
-if test "$ac_cv_sizeof_int" = "$ac_cv_sizeof_char_p"; then
- echo $ac_n "checking for ptrdiff_t""... $ac_c" 1>&6
-echo "configure:4268: checking for ptrdiff_t" >&5
-if eval "test \"`echo '$''{'ac_cv_type_ptrdiff_t'+set}'`\" = set"; then
+if test "$ac_cv_sizeof_int" = 4; then
+ echo $ac_n "checking for u_bits32_t""... $ac_c" 1>&6
+echo "configure:5120: checking for u_bits32_t" >&5
+if eval "test \"`echo '$''{'ac_cv_type_u_bits32_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 4273 "configure"
+#line 5125 "configure"
#include "confdefs.h"
#include <sys/types.h>
#if STDC_HEADERS
@@ -4278,32 +5130,32 @@ else
#endif
EOF
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- egrep "ptrdiff_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
+ egrep "(^|[^a-zA-Z_0-9])u_bits32_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
rm -rf conftest*
- ac_cv_type_ptrdiff_t=yes
+ ac_cv_type_u_bits32_t=yes
else
rm -rf conftest*
- ac_cv_type_ptrdiff_t=no
+ ac_cv_type_u_bits32_t=no
fi
rm -f conftest*
fi
-echo "$ac_t""$ac_cv_type_ptrdiff_t" 1>&6
-if test $ac_cv_type_ptrdiff_t = no; then
+echo "$ac_t""$ac_cv_type_u_bits32_t" 1>&6
+if test $ac_cv_type_u_bits32_t = no; then
cat >> confdefs.h <<\EOF
-#define ptrdiff_t int
+#define u_bits32_t unsigned int
EOF
fi
-elif test "$ac_cv_sizeof_long" = "$ac_cv_sizeof_char_p"; then
- echo $ac_n "checking for ptrdiff_t""... $ac_c" 1>&6
-echo "configure:4302: checking for ptrdiff_t" >&5
-if eval "test \"`echo '$''{'ac_cv_type_ptrdiff_t'+set}'`\" = set"; then
+elif test "$ac_cv_sizeof_long" = 4; then
+ echo $ac_n "checking for u_bits32_t""... $ac_c" 1>&6
+echo "configure:5154: checking for u_bits32_t" >&5
+if eval "test \"`echo '$''{'ac_cv_type_u_bits32_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 4307 "configure"
+#line 5159 "configure"
#include "confdefs.h"
#include <sys/types.h>
#if STDC_HEADERS
@@ -4312,32 +5164,32 @@ else
#endif
EOF
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- egrep "ptrdiff_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
+ egrep "(^|[^a-zA-Z_0-9])u_bits32_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
rm -rf conftest*
- ac_cv_type_ptrdiff_t=yes
+ ac_cv_type_u_bits32_t=yes
else
rm -rf conftest*
- ac_cv_type_ptrdiff_t=no
+ ac_cv_type_u_bits32_t=no
fi
rm -f conftest*
fi
-echo "$ac_t""$ac_cv_type_ptrdiff_t" 1>&6
-if test $ac_cv_type_ptrdiff_t = no; then
+echo "$ac_t""$ac_cv_type_u_bits32_t" 1>&6
+if test $ac_cv_type_u_bits32_t = no; then
cat >> confdefs.h <<\EOF
-#define ptrdiff_t long
+#define u_bits32_t unsigned long
EOF
fi
else
- echo $ac_n "checking for ptrdiff_t""... $ac_c" 1>&6
-echo "configure:4336: checking for ptrdiff_t" >&5
-if eval "test \"`echo '$''{'ac_cv_type_ptrdiff_t'+set}'`\" = set"; then
+ echo $ac_n "checking for u_bits32_t""... $ac_c" 1>&6
+echo "configure:5188: checking for u_bits32_t" >&5
+if eval "test \"`echo '$''{'ac_cv_type_u_bits32_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 4341 "configure"
+#line 5193 "configure"
#include "confdefs.h"
#include <sys/types.h>
#if STDC_HEADERS
@@ -4346,20 +5198,20 @@ else
#endif
EOF
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- egrep "ptrdiff_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
+ egrep "(^|[^a-zA-Z_0-9])u_bits32_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
rm -rf conftest*
- ac_cv_type_ptrdiff_t=yes
+ ac_cv_type_u_bits32_t=yes
else
rm -rf conftest*
- ac_cv_type_ptrdiff_t=no
+ ac_cv_type_u_bits32_t=no
fi
rm -f conftest*
fi
-echo "$ac_t""$ac_cv_type_ptrdiff_t" 1>&6
-if test $ac_cv_type_ptrdiff_t = no; then
+echo "$ac_t""$ac_cv_type_u_bits32_t" 1>&6
+if test $ac_cv_type_u_bits32_t = no; then
cat >> confdefs.h <<\EOF
-#define ptrdiff_t int
+#define u_bits32_t unsigned int
EOF
fi
@@ -4369,12 +5221,12 @@ fi
if test "$ac_sv_sizeof_char_p" = 8; then
echo $ac_n "checking for bits64_t""... $ac_c" 1>&6
-echo "configure:4373: checking for bits64_t" >&5
+echo "configure:5225: checking for bits64_t" >&5
if eval "test \"`echo '$''{'ac_cv_type_bits64_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 4378 "configure"
+#line 5230 "configure"
#include "confdefs.h"
#include <sys/types.h>
#if STDC_HEADERS
@@ -4383,7 +5235,7 @@ else
#endif
EOF
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- egrep "bits64_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
+ egrep "(^|[^a-zA-Z_0-9])bits64_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
rm -rf conftest*
ac_cv_type_bits64_t=yes
else
@@ -4403,12 +5255,12 @@ fi
elif test "$ac_cv_sizeof_double" = 8; then
echo $ac_n "checking for bits64_t""... $ac_c" 1>&6
-echo "configure:4407: checking for bits64_t" >&5
+echo "configure:5259: checking for bits64_t" >&5
if eval "test \"`echo '$''{'ac_cv_type_bits64_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 4412 "configure"
+#line 5264 "configure"
#include "confdefs.h"
#include <sys/types.h>
#if STDC_HEADERS
@@ -4417,7 +5269,7 @@ else
#endif
EOF
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- egrep "bits64_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
+ egrep "(^|[^a-zA-Z_0-9])bits64_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
rm -rf conftest*
ac_cv_type_bits64_t=yes
else
@@ -4437,12 +5289,12 @@ fi
elif test "$ac_cv_sizeof_long" = 8; then
echo $ac_n "checking for bits64_t""... $ac_c" 1>&6
-echo "configure:4441: checking for bits64_t" >&5
+echo "configure:5293: checking for bits64_t" >&5
if eval "test \"`echo '$''{'ac_cv_type_bits64_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 4446 "configure"
+#line 5298 "configure"
#include "confdefs.h"
#include <sys/types.h>
#if STDC_HEADERS
@@ -4451,7 +5303,7 @@ else
#endif
EOF
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- egrep "bits64_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
+ egrep "(^|[^a-zA-Z_0-9])bits64_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
rm -rf conftest*
ac_cv_type_bits64_t=yes
else
@@ -4471,12 +5323,12 @@ fi
else
echo $ac_n "checking for bits64_t""... $ac_c" 1>&6
-echo "configure:4475: checking for bits64_t" >&5
+echo "configure:5327: checking for bits64_t" >&5
if eval "test \"`echo '$''{'ac_cv_type_bits64_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 4480 "configure"
+#line 5332 "configure"
#include "confdefs.h"
#include <sys/types.h>
#if STDC_HEADERS
@@ -4485,7 +5337,7 @@ else
#endif
EOF
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- egrep "bits64_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
+ egrep "(^|[^a-zA-Z_0-9])bits64_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
rm -rf conftest*
ac_cv_type_bits64_t=yes
else
@@ -4506,13 +5358,119 @@ fi
fi
+
+if test "$ac_cv_sizeof_int" = "$ac_cv_sizeof_char_p"; then
+ echo $ac_n "checking for ptrdiff_t""... $ac_c" 1>&6
+echo "configure:5365: checking for ptrdiff_t" >&5
+if eval "test \"`echo '$''{'ac_cv_type_ptrdiff_t'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 5370 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+#if STDC_HEADERS
+#include <stdlib.h>
+#include <stddef.h>
+#endif
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ egrep "(^|[^a-zA-Z_0-9])ptrdiff_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
+ rm -rf conftest*
+ ac_cv_type_ptrdiff_t=yes
+else
+ rm -rf conftest*
+ ac_cv_type_ptrdiff_t=no
+fi
+rm -f conftest*
+
+fi
+echo "$ac_t""$ac_cv_type_ptrdiff_t" 1>&6
+if test $ac_cv_type_ptrdiff_t = no; then
+ cat >> confdefs.h <<\EOF
+#define ptrdiff_t int
+EOF
+
+fi
+
+elif test "$ac_cv_sizeof_long" = "$ac_cv_sizeof_char_p"; then
+ echo $ac_n "checking for ptrdiff_t""... $ac_c" 1>&6
+echo "configure:5399: checking for ptrdiff_t" >&5
+if eval "test \"`echo '$''{'ac_cv_type_ptrdiff_t'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 5404 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+#if STDC_HEADERS
+#include <stdlib.h>
+#include <stddef.h>
+#endif
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ egrep "(^|[^a-zA-Z_0-9])ptrdiff_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
+ rm -rf conftest*
+ ac_cv_type_ptrdiff_t=yes
+else
+ rm -rf conftest*
+ ac_cv_type_ptrdiff_t=no
+fi
+rm -f conftest*
+
+fi
+echo "$ac_t""$ac_cv_type_ptrdiff_t" 1>&6
+if test $ac_cv_type_ptrdiff_t = no; then
+ cat >> confdefs.h <<\EOF
+#define ptrdiff_t long
+EOF
+
+fi
+
+else
+ echo $ac_n "checking for ptrdiff_t""... $ac_c" 1>&6
+echo "configure:5433: checking for ptrdiff_t" >&5
+if eval "test \"`echo '$''{'ac_cv_type_ptrdiff_t'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 5438 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+#if STDC_HEADERS
+#include <stdlib.h>
+#include <stddef.h>
+#endif
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ egrep "(^|[^a-zA-Z_0-9])ptrdiff_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
+ rm -rf conftest*
+ ac_cv_type_ptrdiff_t=yes
+else
+ rm -rf conftest*
+ ac_cv_type_ptrdiff_t=no
+fi
+rm -f conftest*
+
+fi
+echo "$ac_t""$ac_cv_type_ptrdiff_t" 1>&6
+if test $ac_cv_type_ptrdiff_t = no; then
+ cat >> confdefs.h <<\EOF
+#define ptrdiff_t int
+EOF
+
+fi
+
+fi
+
+
echo $ac_n "checking whether stat file-mode macros are broken""... $ac_c" 1>&6
-echo "configure:4511: checking whether stat file-mode macros are broken" >&5
+echo "configure:5469: checking whether stat file-mode macros are broken" >&5
if eval "test \"`echo '$''{'ac_cv_header_stat_broken'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 4516 "configure"
+#line 5474 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/stat.h>
@@ -4562,51 +5520,16 @@ EOF
fi
-cat > conftest.$ac_ext <<EOF
-#line 4567 "configure"
-#include "confdefs.h"
-#include <sys/time.h>
-EOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- egrep "struct timeval" >/dev/null 2>&1; then
- rm -rf conftest*
- bash_cv_struct_timeval=yes
-fi
-rm -f conftest*
-
-if test -z "$bash_cv_struct_timeval"; then
-cat > conftest.$ac_ext <<EOF
-#line 4580 "configure"
-#include "confdefs.h"
-#include <time.h>
-EOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- egrep "struct timeval" >/dev/null 2>&1; then
- rm -rf conftest*
- bash_cv_struct_timeval=yes
-else
- rm -rf conftest*
- bash_cv_struct_timeval=no
-fi
-rm -f conftest*
-
-fi
-if test $bash_cv_struct_timeval = yes; then
-cat >> confdefs.h <<\EOF
-#define HAVE_TIMEVAL 1
-EOF
-
-fi
echo $ac_n "checking whether byte ordering is bigendian""... $ac_c" 1>&6
-echo "configure:4603: checking whether byte ordering is bigendian" >&5
+echo "configure:5526: checking whether byte ordering is bigendian" >&5
if eval "test \"`echo '$''{'ac_cv_c_bigendian'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
ac_cv_c_bigendian=unknown
# See if sys/param.h defines the BYTE_ORDER macro.
cat > conftest.$ac_ext <<EOF
-#line 4610 "configure"
+#line 5533 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/param.h>
@@ -4617,11 +5540,11 @@ int main() {
#endif
; return 0; }
EOF
-if { (eval echo configure:4621: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:5544: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
# It does; now see whether it defined to BIG_ENDIAN or not.
cat > conftest.$ac_ext <<EOF
-#line 4625 "configure"
+#line 5548 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/param.h>
@@ -4632,7 +5555,7 @@ int main() {
#endif
; return 0; }
EOF
-if { (eval echo configure:4636: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:5559: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_c_bigendian=yes
else
@@ -4652,7 +5575,7 @@ if test "$cross_compiling" = yes; then
{ echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
else
cat > conftest.$ac_ext <<EOF
-#line 4656 "configure"
+#line 5579 "configure"
#include "confdefs.h"
main () {
/* Are we little or big endian? From Harbison&Steele. */
@@ -4665,7 +5588,7 @@ main () {
exit (u.c[sizeof (long) - 1] == 1);
}
EOF
-if { (eval echo configure:4669: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:5592: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
ac_cv_c_bigendian=no
else
@@ -4692,7 +5615,7 @@ fi
# Pull the hash mark out of the macro call to avoid m4 problems.
ac_msg="whether #! works in shell scripts"
echo $ac_n "checking $ac_msg""... $ac_c" 1>&6
-echo "configure:4696: checking $ac_msg" >&5
+echo "configure:5619: checking $ac_msg" >&5
if eval "test \"`echo '$''{'ac_cv_sys_interpreter'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -4710,6 +5633,7 @@ rm -f conftest
fi
echo "$ac_t""$ac_cv_sys_interpreter" 1>&6
+interpval="$ac_cv_sys_interpreter"
if test $ac_cv_sys_interpreter = yes; then
cat >> confdefs.h <<\EOF
@@ -4718,7 +5642,7 @@ EOF
fi
echo $ac_n "checking for restartable system calls""... $ac_c" 1>&6
-echo "configure:4722: checking for restartable system calls" >&5
+echo "configure:5646: checking for restartable system calls" >&5
if eval "test \"`echo '$''{'ac_cv_sys_restartable_syscalls'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -4726,7 +5650,7 @@ else
{ echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
else
cat > conftest.$ac_ext <<EOF
-#line 4730 "configure"
+#line 5654 "configure"
#include "confdefs.h"
/* Exit 0 (true) if wait returns something other than -1,
i.e. the pid of the child, which means that wait was restarted
@@ -4744,7 +5668,7 @@ main () {
}
EOF
-if { (eval echo configure:4748: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:5672: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
ac_cv_sys_restartable_syscalls=yes
else
@@ -4769,12 +5693,12 @@ fi
if test "$ac_cv_func_lstat" = "no"; then
echo $ac_n "checking for lstat""... $ac_c" 1>&6
-echo "configure:4773: checking for lstat" >&5
+echo "configure:5697: checking for lstat" >&5
if eval "test \"`echo '$''{'bash_cv_func_lstat'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 4778 "configure"
+#line 5702 "configure"
#include "confdefs.h"
#include <sys/types.h>
@@ -4784,7 +5708,7 @@ int main() {
lstat(".",(struct stat *)0);
; return 0; }
EOF
-if { (eval echo configure:4788: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:5712: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
bash_cv_func_lstat=yes
else
@@ -4807,7 +5731,7 @@ fi
fi
echo $ac_n "checking if dup2 fails to clear the close-on-exec flag""... $ac_c" 1>&6
-echo "configure:4811: checking if dup2 fails to clear the close-on-exec flag" >&5
+echo "configure:5735: checking if dup2 fails to clear the close-on-exec flag" >&5
if eval "test \"`echo '$''{'bash_cv_dup2_broken'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -4816,7 +5740,7 @@ else
bash_cv_dup2_broken=no
else
cat > conftest.$ac_ext <<EOF
-#line 4820 "configure"
+#line 5744 "configure"
#include "confdefs.h"
#include <sys/types.h>
@@ -4836,7 +5760,7 @@ main()
}
EOF
-if { (eval echo configure:4840: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:5764: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
bash_cv_dup2_broken=yes
else
@@ -4861,7 +5785,7 @@ fi
echo $ac_n "checking whether pgrps need synchronization""... $ac_c" 1>&6
-echo "configure:4865: checking whether pgrps need synchronization" >&5
+echo "configure:5789: checking whether pgrps need synchronization" >&5
if eval "test \"`echo '$''{'bash_cv_pgrp_pipe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -4870,7 +5794,7 @@ else
bash_cv_pgrp_pipe=no
else
cat > conftest.$ac_ext <<EOF
-#line 4874 "configure"
+#line 5798 "configure"
#include "confdefs.h"
#ifdef HAVE_UNISTD_H
@@ -4922,7 +5846,7 @@ main()
}
EOF
-if { (eval echo configure:4926: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:5850: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
bash_cv_pgrp_pipe=no
else
@@ -4947,13 +5871,13 @@ fi
echo $ac_n "checking for type of signal functions""... $ac_c" 1>&6
-echo "configure:4951: checking for type of signal functions" >&5
+echo "configure:5875: checking for type of signal functions" >&5
if eval "test \"`echo '$''{'bash_cv_signal_vintage'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 4957 "configure"
+#line 5881 "configure"
#include "confdefs.h"
#include <signal.h>
int main() {
@@ -4966,7 +5890,7 @@ int main() {
; return 0; }
EOF
-if { (eval echo configure:4970: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:5894: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
bash_cv_signal_vintage=posix
else
@@ -4975,7 +5899,7 @@ else
rm -rf conftest*
cat > conftest.$ac_ext <<EOF
-#line 4979 "configure"
+#line 5903 "configure"
#include "confdefs.h"
#include <signal.h>
int main() {
@@ -4985,7 +5909,7 @@ int main() {
; return 0; }
EOF
-if { (eval echo configure:4989: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:5913: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
bash_cv_signal_vintage=4.2bsd
else
@@ -4994,7 +5918,7 @@ else
rm -rf conftest*
cat > conftest.$ac_ext <<EOF
-#line 4998 "configure"
+#line 5922 "configure"
#include "confdefs.h"
#include <signal.h>
@@ -5007,7 +5931,7 @@ int main() {
; return 0; }
EOF
-if { (eval echo configure:5011: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:5935: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
bash_cv_signal_vintage=svr3
else
@@ -5049,7 +5973,7 @@ fi
if test "$ac_cv_sys_restartable_syscalls" = "no"; then
echo $ac_n "checking for restartable system calls with posix sigaction""... $ac_c" 1>&6
-echo "configure:5053: checking for restartable system calls with posix sigaction" >&5
+echo "configure:5977: checking for restartable system calls with posix sigaction" >&5
if eval "test \"`echo '$''{'bash_cv_sys_restartable_syscalls'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -5057,7 +5981,7 @@ else
echo "configure: warning: cannot check restartable syscalls if cross compiling" 1>&2
else
cat > conftest.$ac_ext <<EOF
-#line 5061 "configure"
+#line 5985 "configure"
#include "confdefs.h"
/* Exit 0 (true) if wait returns something other than -1,
i.e. the pid of the child, which means that wait was restarted
@@ -5091,7 +6015,7 @@ main ()
}
EOF
-if { (eval echo configure:5095: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:6019: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
bash_cv_sys_restartable_syscalls=yes
else
@@ -5117,12 +6041,12 @@ fi
fi
echo $ac_n "checking for sys_errlist and sys_nerr""... $ac_c" 1>&6
-echo "configure:5121: checking for sys_errlist and sys_nerr" >&5
+echo "configure:6045: checking for sys_errlist and sys_nerr" >&5
if eval "test \"`echo '$''{'bash_cv_sys_errlist'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 5126 "configure"
+#line 6050 "configure"
#include "confdefs.h"
#include <errno.h>
int main() {
@@ -5131,7 +6055,7 @@ extern char *sys_errlist[];
char *msg = sys_errlist[sys_nerr - 1];
; return 0; }
EOF
-if { (eval echo configure:5135: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:6059: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
bash_cv_sys_errlist=yes
else
@@ -5152,7 +6076,7 @@ fi
echo $ac_n "checking for sys_siglist in system C library""... $ac_c" 1>&6
-echo "configure:5156: checking for sys_siglist in system C library" >&5
+echo "configure:6080: checking for sys_siglist in system C library" >&5
if eval "test \"`echo '$''{'bash_cv_sys_siglist'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -5161,7 +6085,7 @@ else
bash_cv_sys_siglist=no
else
cat > conftest.$ac_ext <<EOF
-#line 5165 "configure"
+#line 6089 "configure"
#include "confdefs.h"
#include <sys/types.h>
@@ -5178,7 +6102,7 @@ char *msg = sys_siglist[2];
exit(msg == 0);
}
EOF
-if { (eval echo configure:5182: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:6106: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
bash_cv_sys_siglist=yes
else
@@ -5201,12 +6125,12 @@ EOF
fi
echo $ac_n "checking for _sys_siglist in signal.h or unistd.h""... $ac_c" 1>&6
-echo "configure:5205: checking for _sys_siglist in signal.h or unistd.h" >&5
+echo "configure:6129: checking for _sys_siglist in signal.h or unistd.h" >&5
if eval "test \"`echo '$''{'bash_cv_decl_under_sys_siglist'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 5210 "configure"
+#line 6134 "configure"
#include "confdefs.h"
#include <sys/types.h>
@@ -5218,7 +6142,7 @@ int main() {
char *msg = _sys_siglist[2];
; return 0; }
EOF
-if { (eval echo configure:5222: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:6146: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
bash_cv_decl_under_sys_siglist=yes
else
@@ -5239,7 +6163,7 @@ fi
echo $ac_n "checking for _sys_siglist in system C library""... $ac_c" 1>&6
-echo "configure:5243: checking for _sys_siglist in system C library" >&5
+echo "configure:6167: checking for _sys_siglist in system C library" >&5
if eval "test \"`echo '$''{'bash_cv_under_sys_siglist'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -5248,7 +6172,7 @@ else
bash_cv_under_sys_siglist=no
else
cat > conftest.$ac_ext <<EOF
-#line 5252 "configure"
+#line 6176 "configure"
#include "confdefs.h"
#include <sys/types.h>
@@ -5265,7 +6189,7 @@ char *msg = (char *)_sys_siglist[2];
exit(msg == 0);
}
EOF
-if { (eval echo configure:5269: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:6193: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
bash_cv_under_sys_siglist=yes
else
@@ -5289,12 +6213,12 @@ fi
echo $ac_n "checking whether signal handlers are of type void""... $ac_c" 1>&6
-echo "configure:5293: checking whether signal handlers are of type void" >&5
+echo "configure:6217: checking whether signal handlers are of type void" >&5
if eval "test \"`echo '$''{'bash_cv_void_sighandler'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 5298 "configure"
+#line 6222 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <signal.h>
@@ -5309,7 +6233,7 @@ int main() {
int i;
; return 0; }
EOF
-if { (eval echo configure:5313: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:6237: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
bash_cv_void_sighandler=yes
else
@@ -5329,12 +6253,12 @@ EOF
fi
echo $ac_n "checking for clock_t""... $ac_c" 1>&6
-echo "configure:5333: checking for clock_t" >&5
+echo "configure:6257: checking for clock_t" >&5
if eval "test \"`echo '$''{'bash_cv_type_clock_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 5338 "configure"
+#line 6262 "configure"
#include "confdefs.h"
#include <sys/types.h>
#if STDC_HEADERS
@@ -5365,12 +6289,12 @@ EOF
fi
echo $ac_n "checking for sigset_t""... $ac_c" 1>&6
-echo "configure:5369: checking for sigset_t" >&5
+echo "configure:6293: checking for sigset_t" >&5
if eval "test \"`echo '$''{'bash_cv_type_sigset_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 5374 "configure"
+#line 6298 "configure"
#include "confdefs.h"
#include <sys/types.h>
#if STDC_HEADERS
@@ -5401,12 +6325,12 @@ EOF
fi
echo $ac_n "checking for quad_t""... $ac_c" 1>&6
-echo "configure:5405: checking for quad_t" >&5
+echo "configure:6329: checking for quad_t" >&5
if eval "test \"`echo '$''{'bash_cv_type_quad_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 5410 "configure"
+#line 6334 "configure"
#include "confdefs.h"
#include <sys/types.h>
#if STDC_HEADERS
@@ -5442,12 +6366,12 @@ EOF
fi
echo $ac_n "checking for size and type of struct rlimit fields""... $ac_c" 1>&6
-echo "configure:5446: checking for size and type of struct rlimit fields" >&5
+echo "configure:6370: checking for size and type of struct rlimit fields" >&5
if eval "test \"`echo '$''{'bash_cv_type_rlimit'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 5451 "configure"
+#line 6375 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/resource.h>
@@ -5455,7 +6379,7 @@ int main() {
rlim_t xxx;
; return 0; }
EOF
-if { (eval echo configure:5459: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:6383: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
bash_cv_type_rlimit=rlim_t
else
@@ -5468,7 +6392,7 @@ if test "$cross_compiling" = yes; then
bash_cv_type_rlimit=long
else
cat > conftest.$ac_ext <<EOF
-#line 5472 "configure"
+#line 6396 "configure"
#include "confdefs.h"
#include <sys/types.h>
@@ -5484,7 +6408,7 @@ main()
exit(1);
}
EOF
-if { (eval echo configure:5488: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:6412: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
bash_cv_type_rlimit=quad_t
else
@@ -5516,12 +6440,12 @@ fi
echo $ac_n "checking for a c_line member of struct termios""... $ac_c" 1>&6
-echo "configure:5520: checking for a c_line member of struct termios" >&5
+echo "configure:6444: checking for a c_line member of struct termios" >&5
if eval "test \"`echo '$''{'bash_cv_termios_ldisc'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 5525 "configure"
+#line 6449 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <termios.h>
@@ -5529,7 +6453,7 @@ int main() {
struct termios t; int i; i = t.c_line;
; return 0; }
EOF
-if { (eval echo configure:5533: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:6457: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
bash_cv_termios_ldisc=yes
else
@@ -5549,12 +6473,12 @@ EOF
fi
echo $ac_n "checking for a c_line member of struct termio""... $ac_c" 1>&6
-echo "configure:5553: checking for a c_line member of struct termio" >&5
+echo "configure:6477: checking for a c_line member of struct termio" >&5
if eval "test \"`echo '$''{'bash_cv_termio_ldisc'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 5558 "configure"
+#line 6482 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <termio.h>
@@ -5562,7 +6486,7 @@ int main() {
struct termio t; int i; i = t.c_line;
; return 0; }
EOF
-if { (eval echo configure:5566: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:6490: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
bash_cv_termio_ldisc=yes
else
@@ -5583,12 +6507,12 @@ fi
echo $ac_n "checking if struct dirent has a d_ino member""... $ac_c" 1>&6
-echo "configure:5587: checking if struct dirent has a d_ino member" >&5
+echo "configure:6511: checking if struct dirent has a d_ino member" >&5
if eval "test \"`echo '$''{'bash_cv_dirent_has_dino'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 5592 "configure"
+#line 6516 "configure"
#include "confdefs.h"
#include <stdio.h>
@@ -5617,7 +6541,7 @@ struct dirent d; int z; z = d.d_ino;
; return 0; }
EOF
-if { (eval echo configure:5621: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:6545: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
bash_cv_dirent_has_dino=yes
else
@@ -5639,12 +6563,12 @@ fi
echo $ac_n "checking if struct dirent has a d_fileno member""... $ac_c" 1>&6
-echo "configure:5643: checking if struct dirent has a d_fileno member" >&5
+echo "configure:6567: checking if struct dirent has a d_fileno member" >&5
if eval "test \"`echo '$''{'bash_cv_dirent_has_d_fileno'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 5648 "configure"
+#line 6572 "configure"
#include "confdefs.h"
#include <stdio.h>
@@ -5673,7 +6597,7 @@ struct dirent d; int z; z = d.d_fileno;
; return 0; }
EOF
-if { (eval echo configure:5677: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:6601: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
bash_cv_dirent_has_d_fileno=yes
else
@@ -5694,12 +6618,12 @@ EOF
fi
echo $ac_n "checking for struct winsize in sys/ioctl.h and termios.h""... $ac_c" 1>&6
-echo "configure:5698: checking for struct winsize in sys/ioctl.h and termios.h" >&5
+echo "configure:6622: checking for struct winsize in sys/ioctl.h and termios.h" >&5
if eval "test \"`echo '$''{'bash_cv_struct_winsize_header'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 5703 "configure"
+#line 6627 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/ioctl.h>
@@ -5707,7 +6631,7 @@ int main() {
struct winsize x;
; return 0; }
EOF
-if { (eval echo configure:5711: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:6635: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
bash_cv_struct_winsize_header=ioctl_h
else
@@ -5715,7 +6639,7 @@ else
cat conftest.$ac_ext >&5
rm -rf conftest*
cat > conftest.$ac_ext <<EOF
-#line 5719 "configure"
+#line 6643 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <termios.h>
@@ -5723,7 +6647,7 @@ int main() {
struct winsize x;
; return 0; }
EOF
-if { (eval echo configure:5727: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:6651: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
bash_cv_struct_winsize_header=termios_h
else
@@ -5754,14 +6678,60 @@ else
echo "$ac_t""not found" 1>&6
fi
+echo $ac_n "checking for struct timeval in sys/time.h and time.h""... $ac_c" 1>&6
+echo "configure:6683: checking for struct timeval in sys/time.h and time.h" >&5
+if eval "test \"`echo '$''{'bash_cv_struct_timeval'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+
+cat > conftest.$ac_ext <<EOF
+#line 6689 "configure"
+#include "confdefs.h"
+#include <sys/time.h>
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ egrep "struct timeval" >/dev/null 2>&1; then
+ rm -rf conftest*
+ bash_cv_struct_timeval=yes
+else
+ rm -rf conftest*
+ cat > conftest.$ac_ext <<EOF
+#line 6700 "configure"
+#include "confdefs.h"
+#include <time.h>
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ egrep "struct timeval" >/dev/null 2>&1; then
+ rm -rf conftest*
+ bash_cv_struct_timeval=yes
+else
+ rm -rf conftest*
+ bash_cv_struct_timeval=no
+fi
+rm -f conftest*
+
+fi
+rm -f conftest*
+
+
+fi
+
+echo "$ac_t""$bash_cv_struct_timeval" 1>&6
+if test $bash_cv_struct_timeval = yes; then
+ cat >> confdefs.h <<\EOF
+#define HAVE_TIMEVAL 1
+EOF
+
+fi
+
echo $ac_n "checking for the existence of strsignal""... $ac_c" 1>&6
-echo "configure:5760: checking for the existence of strsignal" >&5
+echo "configure:6730: checking for the existence of strsignal" >&5
if eval "test \"`echo '$''{'bash_cv_have_strsignal'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 5765 "configure"
+#line 6735 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <signal.h>
@@ -5769,7 +6739,7 @@ int main() {
char *s = (char *)strsignal(2);
; return 0; }
EOF
-if { (eval echo configure:5773: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:6743: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
bash_cv_have_strsignal=yes
else
@@ -5790,7 +6760,7 @@ EOF
fi
echo $ac_n "checking if opendir() opens non-directories""... $ac_c" 1>&6
-echo "configure:5794: checking if opendir() opens non-directories" >&5
+echo "configure:6764: checking if opendir() opens non-directories" >&5
if eval "test \"`echo '$''{'bash_cv_opendir_not_robust'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -5800,7 +6770,7 @@ else
else
cat > conftest.$ac_ext <<EOF
-#line 5804 "configure"
+#line 6774 "configure"
#include "confdefs.h"
#include <stdio.h>
@@ -5826,17 +6796,23 @@ else
main()
{
DIR *dir;
-int fd;
-unlink("/tmp/not_a_directory");
-fd = open("/tmp/not_a_directory", O_WRONLY|O_CREAT, 0666);
+int fd, err;
+err = mkdir("/tmp/bash-aclocal", 0700);
+if (err < 0) {
+ perror("mkdir");
+ exit(1);
+}
+unlink("/tmp/bash-aclocal/not_a_directory");
+fd = open("/tmp/bash-aclocal/not_a_directory", O_WRONLY|O_CREAT|O_EXCL, 0666);
write(fd, "\n", 1);
close(fd);
-dir = opendir("/tmp/not_a_directory");
-unlink("/tmp/not_a_directory");
+dir = opendir("/tmp/bash-aclocal/not_a_directory");
+unlink("/tmp/bash-aclocal/not_a_directory");
+rmdir("/tmp/bash-aclocal");
exit (dir == 0);
}
EOF
-if { (eval echo configure:5840: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:6816: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
bash_cv_opendir_not_robust=yes
else
@@ -5859,7 +6835,7 @@ EOF
fi
echo $ac_n "checking for declaration of printf in <stdio.h>""... $ac_c" 1>&6
-echo "configure:5863: checking for declaration of printf in <stdio.h>" >&5
+echo "configure:6839: checking for declaration of printf in <stdio.h>" >&5
if eval "test \"`echo '$''{'bash_cv_printf_declared'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -5869,7 +6845,7 @@ else
else
cat > conftest.$ac_ext <<EOF
-#line 5873 "configure"
+#line 6849 "configure"
#include "confdefs.h"
#include <stdio.h>
@@ -5886,7 +6862,7 @@ exit(pf == 0);
}
EOF
-if { (eval echo configure:5890: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:6866: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
bash_cv_printf_declared=yes
else
@@ -5909,7 +6885,7 @@ EOF
fi
echo $ac_n "checking whether ulimit can substitute for getdtablesize""... $ac_c" 1>&6
-echo "configure:5913: checking whether ulimit can substitute for getdtablesize" >&5
+echo "configure:6889: checking whether ulimit can substitute for getdtablesize" >&5
if eval "test \"`echo '$''{'bash_cv_ulimit_maxfds'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -5919,7 +6895,7 @@ else
else
cat > conftest.$ac_ext <<EOF
-#line 5923 "configure"
+#line 6899 "configure"
#include "confdefs.h"
main()
@@ -5929,7 +6905,7 @@ exit (maxfds == -1L);
}
EOF
-if { (eval echo configure:5933: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:6909: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
bash_cv_ulimit_maxfds=yes
else
@@ -5952,7 +6928,7 @@ EOF
fi
echo $ac_n "checking to see if getenv can be redefined""... $ac_c" 1>&6
-echo "configure:5956: checking to see if getenv can be redefined" >&5
+echo "configure:6932: checking to see if getenv can be redefined" >&5
if eval "test \"`echo '$''{'bash_cv_getenv_redef'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -5962,7 +6938,7 @@ else
else
cat > conftest.$ac_ext <<EOF
-#line 5966 "configure"
+#line 6942 "configure"
#include "confdefs.h"
#ifdef HAVE_UNISTD_H
@@ -5997,7 +6973,7 @@ exit(s == 0); /* force optimizer to leave getenv in */
}
EOF
-if { (eval echo configure:6001: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:6977: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
bash_cv_getenv_redef=yes
else
@@ -6020,7 +6996,7 @@ EOF
fi
echo $ac_n "checking if getcwd() calls popen()""... $ac_c" 1>&6
-echo "configure:6024: checking if getcwd() calls popen()" >&5
+echo "configure:7000: checking if getcwd() calls popen()" >&5
if eval "test \"`echo '$''{'bash_cv_getcwd_calls_popen'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -6030,7 +7006,7 @@ else
else
cat > conftest.$ac_ext <<EOF
-#line 6034 "configure"
+#line 7010 "configure"
#include "confdefs.h"
#include <stdio.h>
@@ -6085,7 +7061,7 @@ main()
}
EOF
-if { (eval echo configure:6089: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:7065: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
bash_cv_getcwd_calls_popen=no
else
@@ -6108,12 +7084,12 @@ EOF
fi
echo $ac_n "checking for declaration of sbrk in <unistd.h>""... $ac_c" 1>&6
-echo "configure:6112: checking for declaration of sbrk in <unistd.h>" >&5
+echo "configure:7088: checking for declaration of sbrk in <unistd.h>" >&5
if eval "test \"`echo '$''{'bash_cv_sbrk_declared'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 6117 "configure"
+#line 7093 "configure"
#include "confdefs.h"
#include <unistd.h>
EOF
@@ -6139,7 +7115,7 @@ fi
echo $ac_n "checking for presence of POSIX-style sigsetjmp/siglongjmp""... $ac_c" 1>&6
-echo "configure:6143: checking for presence of POSIX-style sigsetjmp/siglongjmp" >&5
+echo "configure:7119: checking for presence of POSIX-style sigsetjmp/siglongjmp" >&5
if eval "test \"`echo '$''{'bash_cv_func_sigsetjmp'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -6149,7 +7125,7 @@ else
else
cat > conftest.$ac_ext <<EOF
-#line 6153 "configure"
+#line 7129 "configure"
#include "confdefs.h"
#ifdef HAVE_UNISTD_H
@@ -6190,7 +7166,7 @@ exit(1);
#endif
}
EOF
-if { (eval echo configure:6194: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:7170: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
bash_cv_func_sigsetjmp=present
else
@@ -6214,7 +7190,7 @@ fi
echo $ac_n "checking whether or not strcoll and strcmp differ""... $ac_c" 1>&6
-echo "configure:6218: checking whether or not strcoll and strcmp differ" >&5
+echo "configure:7194: checking whether or not strcoll and strcmp differ" >&5
if eval "test \"`echo '$''{'bash_cv_func_strcoll_broken'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -6224,7 +7200,7 @@ else
else
cat > conftest.$ac_ext <<EOF
-#line 6228 "configure"
+#line 7204 "configure"
#include "confdefs.h"
#include <stdio.h>
@@ -6263,7 +7239,7 @@ char *v[];
}
EOF
-if { (eval echo configure:6267: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:7243: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
bash_cv_func_strcoll_broken=yes
else
@@ -6289,7 +7265,7 @@ fi
echo $ac_n "checking if signal handlers must be reinstalled when invoked""... $ac_c" 1>&6
-echo "configure:6293: checking if signal handlers must be reinstalled when invoked" >&5
+echo "configure:7269: checking if signal handlers must be reinstalled when invoked" >&5
if eval "test \"`echo '$''{'bash_cv_must_reinstall_sighandlers'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -6299,7 +7275,7 @@ else
else
cat > conftest.$ac_ext <<EOF
-#line 6303 "configure"
+#line 7279 "configure"
#include "confdefs.h"
#include <signal.h>
@@ -6346,7 +7322,7 @@ main()
}
EOF
-if { (eval echo configure:6350: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:7326: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
bash_cv_must_reinstall_sighandlers=no
else
@@ -6370,7 +7346,7 @@ fi
echo $ac_n "checking for presence of necessary job control definitions""... $ac_c" 1>&6
-echo "configure:6374: checking for presence of necessary job control definitions" >&5
+echo "configure:7350: checking for presence of necessary job control definitions" >&5
if eval "test \"`echo '$''{'bash_cv_job_control_missing'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -6380,7 +7356,7 @@ else
else
cat > conftest.$ac_ext <<EOF
-#line 6384 "configure"
+#line 7360 "configure"
#include "confdefs.h"
#include <sys/types.h>
@@ -6427,7 +7403,7 @@ exit(1);
exit(0);
}
EOF
-if { (eval echo configure:6431: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:7407: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
bash_cv_job_control_missing=present
else
@@ -6450,7 +7426,7 @@ EOF
fi
echo $ac_n "checking for presence of named pipes""... $ac_c" 1>&6
-echo "configure:6454: checking for presence of named pipes" >&5
+echo "configure:7430: checking for presence of named pipes" >&5
if eval "test \"`echo '$''{'bash_cv_sys_named_pipes'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -6460,7 +7436,7 @@ else
else
cat > conftest.$ac_ext <<EOF
-#line 6464 "configure"
+#line 7440 "configure"
#include "confdefs.h"
#include <sys/types.h>
@@ -6472,7 +7448,7 @@ else
/* Add more tests in here as appropriate. */
main()
{
-int fd;
+int fd, err;
#if defined (HAVE_MKFIFO)
exit (0);
@@ -6485,16 +7461,23 @@ exit (1);
#if defined (NeXT)
exit (1);
#endif
-
-fd = mknod ("/tmp/sh-np-autoconf", 0666 | S_IFIFO, 0);
-if (fd == -1)
+err = mkdir("/tmp/bash-aclocal", 0700);
+if (err < 0) {
+ perror ("mkdir");
+ exit(1);
+}
+fd = mknod ("/tmp/bash-aclocal/sh-np-autoconf", 0666 | S_IFIFO, 0);
+if (fd == -1) {
+ rmdir ("/tmp/bash-aclocal");
exit (1);
+}
close(fd);
-unlink ("/tmp/sh-np-autoconf");
+unlink ("/tmp/bash-aclocal/sh-np-autoconf");
+rmdir ("/tmp/bash-aclocal");
exit(0);
}
EOF
-if { (eval echo configure:6498: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:7481: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
bash_cv_sys_named_pipes=present
else
@@ -6518,12 +7501,12 @@ fi
echo $ac_n "checking for TIOCGWINSZ in sys/ioctl.h""... $ac_c" 1>&6
-echo "configure:6522: checking for TIOCGWINSZ in sys/ioctl.h" >&5
+echo "configure:7505: checking for TIOCGWINSZ in sys/ioctl.h" >&5
if eval "test \"`echo '$''{'bash_cv_tiocgwinsz_in_ioctl'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 6527 "configure"
+#line 7510 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/ioctl.h>
@@ -6531,7 +7514,7 @@ int main() {
int x = TIOCGWINSZ;
; return 0; }
EOF
-if { (eval echo configure:6535: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:7518: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
bash_cv_tiocgwinsz_in_ioctl=yes
else
@@ -6552,12 +7535,12 @@ EOF
fi
echo $ac_n "checking for TIOCSTAT in sys/ioctl.h""... $ac_c" 1>&6
-echo "configure:6556: checking for TIOCSTAT in sys/ioctl.h" >&5
+echo "configure:7539: checking for TIOCSTAT in sys/ioctl.h" >&5
if eval "test \"`echo '$''{'bash_cv_tiocstat_in_ioctl'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 6561 "configure"
+#line 7544 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/ioctl.h>
@@ -6565,7 +7548,7 @@ int main() {
int x = TIOCSTAT;
; return 0; }
EOF
-if { (eval echo configure:6569: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:7552: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
bash_cv_tiocstat_in_ioctl=yes
else
@@ -6586,12 +7569,12 @@ EOF
fi
echo $ac_n "checking for FIONREAD in sys/ioctl.h""... $ac_c" 1>&6
-echo "configure:6590: checking for FIONREAD in sys/ioctl.h" >&5
+echo "configure:7573: checking for FIONREAD in sys/ioctl.h" >&5
if eval "test \"`echo '$''{'bash_cv_fionread_in_ioctl'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 6595 "configure"
+#line 7578 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/ioctl.h>
@@ -6599,7 +7582,7 @@ int main() {
int x = FIONREAD;
; return 0; }
EOF
-if { (eval echo configure:6603: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:7586: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
bash_cv_fionread_in_ioctl=yes
else
@@ -6621,19 +7604,19 @@ fi
echo $ac_n "checking for speed_t in sys/types.h""... $ac_c" 1>&6
-echo "configure:6625: checking for speed_t in sys/types.h" >&5
+echo "configure:7608: checking for speed_t in sys/types.h" >&5
if eval "test \"`echo '$''{'bash_cv_speed_t_in_sys_types'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 6630 "configure"
+#line 7613 "configure"
#include "confdefs.h"
#include <sys/types.h>
int main() {
speed_t x;
; return 0; }
EOF
-if { (eval echo configure:6637: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:7620: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
bash_cv_speed_t_in_sys_types=yes
else
@@ -6654,12 +7637,12 @@ EOF
fi
echo $ac_n "checking whether programs are able to redeclare getpw functions""... $ac_c" 1>&6
-echo "configure:6658: checking whether programs are able to redeclare getpw functions" >&5
+echo "configure:7641: checking whether programs are able to redeclare getpw functions" >&5
if eval "test \"`echo '$''{'bash_cv_can_redecl_getpw'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 6663 "configure"
+#line 7646 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <pwd.h>
@@ -6670,7 +7653,7 @@ int main() {
struct passwd *z; z = getpwent(); z = getpwuid(0); z = getpwnam("root");
; return 0; }
EOF
-if { (eval echo configure:6674: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:7657: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
bash_cv_can_redecl_getpw=yes
else
@@ -6693,12 +7676,12 @@ fi
case "$host_os" in
hpux*) echo $ac_n "checking whether $host_os needs _KERNEL for RLIMIT defines""... $ac_c" 1>&6
-echo "configure:6697: checking whether $host_os needs _KERNEL for RLIMIT defines" >&5
+echo "configure:7680: checking whether $host_os needs _KERNEL for RLIMIT defines" >&5
if eval "test \"`echo '$''{'bash_cv_kernel_rlimit'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 6702 "configure"
+#line 7685 "configure"
#include "confdefs.h"
#include <sys/types.h>
@@ -6711,7 +7694,7 @@ int main() {
; return 0; }
EOF
-if { (eval echo configure:6715: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:7698: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
bash_cv_kernel_rlimit=no
else
@@ -6719,7 +7702,7 @@ else
cat conftest.$ac_ext >&5
rm -rf conftest*
cat > conftest.$ac_ext <<EOF
-#line 6723 "configure"
+#line 7706 "configure"
#include "confdefs.h"
#include <sys/types.h>
@@ -6734,7 +7717,7 @@ int main() {
; return 0; }
EOF
-if { (eval echo configure:6738: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:7721: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
bash_cv_kernel_rlimit=yes
else
@@ -6768,14 +7751,14 @@ if test "X$bash_cv_termcap_lib" = "X"; then
_bash_needmsg=yes
else
echo $ac_n "checking which library has the termcap functions""... $ac_c" 1>&6
-echo "configure:6772: checking which library has the termcap functions" >&5
+echo "configure:7755: checking which library has the termcap functions" >&5
_bash_needmsg=
fi
if eval "test \"`echo '$''{'bash_cv_termcap_lib'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
echo $ac_n "checking for tgetent in -ltermcap""... $ac_c" 1>&6
-echo "configure:6779: checking for tgetent in -ltermcap" >&5
+echo "configure:7762: checking for tgetent in -ltermcap" >&5
ac_lib_var=`echo termcap'_'tgetent | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -6783,7 +7766,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-ltermcap $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 6787 "configure"
+#line 7770 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -6794,7 +7777,7 @@ int main() {
tgetent()
; return 0; }
EOF
-if { (eval echo configure:6798: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:7781: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -6813,7 +7796,7 @@ if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
else
echo "$ac_t""no" 1>&6
echo $ac_n "checking for tgetent in -lcurses""... $ac_c" 1>&6
-echo "configure:6817: checking for tgetent in -lcurses" >&5
+echo "configure:7800: checking for tgetent in -lcurses" >&5
ac_lib_var=`echo curses'_'tgetent | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -6821,7 +7804,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lcurses $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 6825 "configure"
+#line 7808 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -6832,7 +7815,7 @@ int main() {
tgetent()
; return 0; }
EOF
-if { (eval echo configure:6836: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:7819: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -6851,7 +7834,7 @@ if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
else
echo "$ac_t""no" 1>&6
echo $ac_n "checking for tgetent in -lncurses""... $ac_c" 1>&6
-echo "configure:6855: checking for tgetent in -lncurses" >&5
+echo "configure:7838: checking for tgetent in -lncurses" >&5
ac_lib_var=`echo ncurses'_'tgetent | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -6859,7 +7842,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lncurses $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 6863 "configure"
+#line 7846 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -6870,7 +7853,7 @@ int main() {
tgetent()
; return 0; }
EOF
-if { (eval echo configure:6874: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:7857: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -6899,7 +7882,7 @@ fi
if test "X$_bash_needmsg" = "Xyes"; then
echo $ac_n "checking which library has the termcap functions""... $ac_c" 1>&6
-echo "configure:6903: checking which library has the termcap functions" >&5
+echo "configure:7886: checking which library has the termcap functions" >&5
fi
echo "$ac_t""using $bash_cv_termcap_lib" 1>&6
if test $bash_cv_termcap_lib = gnutermcap && test -z "$prefer_curses"; then
@@ -6922,7 +7905,7 @@ fi
echo $ac_n "checking whether /dev/fd is available""... $ac_c" 1>&6
-echo "configure:6926: checking whether /dev/fd is available" >&5
+echo "configure:7909: checking whether /dev/fd is available" >&5
if eval "test \"`echo '$''{'bash_cv_dev_fd'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -6957,8 +7940,31 @@ EOF
fi
+echo $ac_n "checking whether /dev/stdin stdout stderr are available""... $ac_c" 1>&6
+echo "configure:7945: checking whether /dev/stdin stdout stderr are available" >&5
+if eval "test \"`echo '$''{'bash_cv_dev_stdin'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -d /dev/fd && test -r /dev/stdin; then
+ bash_cv_dev_stdin=present
+ elif test -d /proc/self/fd && test -r /dev/stdin; then
+ bash_cv_dev_stdin=present
+ else
+ bash_cv_dev_stdin=absent
+ fi
+
+fi
+
+echo "$ac_t""$bash_cv_dev_stdin" 1>&6
+if test $bash_cv_dev_stdin = "present"; then
+ cat >> confdefs.h <<\EOF
+#define HAVE_DEV_STDIN 1
+EOF
+
+fi
+
echo $ac_n "checking for default mail directory""... $ac_c" 1>&6
-echo "configure:6962: checking for default mail directory" >&5
+echo "configure:7968: checking for default mail directory" >&5
if eval "test \"`echo '$''{'bash_cv_mail_dir'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -7045,7 +8051,8 @@ EOF
hpux9*) LOCAL_CFLAGS="-DHPUX9 -DHPUX" ;;
hpux*) LOCAL_CFLAGS=-DHPUX ;;
dgux*) LOCAL_CFLAGS=-D_DGUX_SOURCE; LOCAL_LIBS=-ldgc ;;
-isc*) LOCAL_CFLAGS=-Disc386;;
+isc*) LOCAL_CFLAGS=-Disc386 ;;
+rhapsody*) LOCAL_CFLAGS=-DRHAPSODY ;;
sco3.2v5*) LOCAL_CFLAGS="-b elf -DWAITPID_BROKEN -DNO_MEMSCRAMBLE -DPATH_MAX=1024" ;;
sco3.2v4*) LOCAL_CFLAGS="-DMUST_UNBLOCK_CHLD -DNO_MEMSCRAMBLE -DPATH_MAX=1024" ;;
sco3.2*) LOCAL_CFLAGS=-DMUST_UNBLOCK_CHLD ;;
@@ -7065,6 +8072,12 @@ aix4.2*) LOCAL_LDFLAGS="-bexpall -brtl" ;;
bsdi4*-*gcc*) LOCAL_LDFLAGS="-rdynamic" ;; # allow dynamic loading, like Linux
esac
+case "${host_os}" in
+freebsd3*) if test -x /usr/bin/objformat && test "`/usr/bin/objformat`" = "elf" ; then
+ LOCAL_LDFLAGS=-rdynamic # allow dynamic loading
+ fi ;;
+esac
+
case "$host_cpu" in
*cray*) LOCAL_CFLAGS="-DCRAY" ;; # shell var so config.h can use it
esac
@@ -7085,8 +8098,8 @@ esac
if test "$ac_cv_func_dlopen" = "yes" && test -f ${srcdir}/support/shobj-conf
then
echo $ac_n "checking shared object configuration for loadable builtins""... $ac_c" 1>&6
-echo "configure:7089: checking shared object configuration for loadable builtins" >&5
- eval `${CONFIG_SHELL-/bin/sh} ${srcdir}/support/shobj-conf -C ${CC} -c ${host_cpu} -o ${host_os} -v ${host_vendor}`
+echo "configure:8102: checking shared object configuration for loadable builtins" >&5
+ eval `${CONFIG_SHELL-/bin/sh} ${srcdir}/support/shobj-conf -C "${CC}" -c ${host_cpu} -o ${host_os} -v ${host_vendor}`
@@ -7108,6 +8121,7 @@ case "$srcdir" in
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
@@ -7160,7 +8174,7 @@ EOF
# 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.
(set) 2>&1 |
- case `(ac_space=' '; set) 2>&1` in
+ case `(ac_space=' '; set | grep ac_space) 2>&1` in
*ac_space=\ *)
# `set' does not quote correctly, so add quotes (double-quote substitution
# turns \\\\ into \\, and sed turns \\ into \).
@@ -7227,7 +8241,7 @@ do
echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion"
exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;;
-version | --version | --versio | --versi | --vers | --ver | --ve | --v)
- echo "$CONFIG_STATUS generated by autoconf version 2.12"
+ echo "$CONFIG_STATUS generated by autoconf version 2.13"
exit 0 ;;
-help | --help | --hel | --he | --h)
echo "\$ac_cs_usage"; exit 0 ;;
@@ -7241,7 +8255,7 @@ ac_given_INSTALL="$INSTALL"
trap 'rm -fr `echo "Makefile builtins/Makefile lib/readline/Makefile lib/glob/Makefile \
lib/malloc/Makefile lib/sh/Makefile lib/termcap/Makefile \
lib/tilde/Makefile doc/Makefile support/Makefile \
- examples/loadables/Makefile config.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
+ examples/loadables/Makefile examples/loadables/perl/Makefile config.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
EOF
cat >> $CONFIG_STATUS <<EOF
@@ -7250,9 +8264,11 @@ sed 's/%@/@@/; s/@%/@@/; s/%g\$/@g/; /@g\$/s/[\\\\&%]/\\\\&/g;
s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > conftest.subs <<\\CEOF
$ac_vpsub
$extrasub
+s%@SHELL@%$SHELL%g
s%@CFLAGS@%$CFLAGS%g
s%@CPPFLAGS@%$CPPFLAGS%g
s%@CXXFLAGS@%$CXXFLAGS%g
+s%@FFLAGS@%$FFLAGS%g
s%@DEFS@%$DEFS%g
s%@LDFLAGS@%$LDFLAGS%g
s%@LIBS@%$LIBS%g
@@ -7280,8 +8296,10 @@ s%@TESTSCRIPT@%$TESTSCRIPT%g
s%@PURIFY@%$PURIFY%g
s%@MALLOC_TARGET@%$MALLOC_TARGET%g
s%@MALLOC_SRC@%$MALLOC_SRC%g
+s%@htmldir@%$htmldir%g
s%@CC@%$CC%g
s%@CPP@%$CPP%g
+s%@EXEEXT@%$EXEEXT%g
s%@SIGNAMES_H@%$SIGNAMES_H%g
s%@CC_FOR_BUILD@%$CC_FOR_BUILD%g
s%@STATIC_LD@%$STATIC_LD%g
@@ -7293,6 +8311,7 @@ s%@HISTORY_LIB@%$HISTORY_LIB%g
s%@HISTORY_DEP@%$HISTORY_DEP%g
s%@HIST_LIBDIR@%$HIST_LIBDIR%g
s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g
+s%@INSTALL_SCRIPT@%$INSTALL_SCRIPT%g
s%@INSTALL_DATA@%$INSTALL_DATA%g
s%@AR@%$AR%g
s%@RANLIB@%$RANLIB%g
@@ -7364,7 +8383,7 @@ cat >> $CONFIG_STATUS <<EOF
CONFIG_FILES=\${CONFIG_FILES-"Makefile builtins/Makefile lib/readline/Makefile lib/glob/Makefile \
lib/malloc/Makefile lib/sh/Makefile lib/termcap/Makefile \
lib/tilde/Makefile doc/Makefile support/Makefile \
- examples/loadables/Makefile"}
+ examples/loadables/Makefile examples/loadables/perl/Makefile"}
EOF
cat >> $CONFIG_STATUS <<\EOF
for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then
diff --git a/configure.in b/configure.in
index fe5d8201..d74f1d3b 100644
--- a/configure.in
+++ b/configure.in
@@ -1,18 +1,18 @@
dnl
-dnl Configure script for bash-2.03
+dnl Configure script for bash-2.04
dnl
dnl report bugs to chet@po.cwru.edu
dnl
dnl Process this file with autoconf to produce a configure script.
-dnl checks for version info
-AC_REVISION([for Bash 2.03, version 2.49, from autoconf version] AC_ACVERSION)dnl
+dnl checks for version info
+AC_REVISION([for Bash 2.04, version 2.77, from autoconf version] AC_ACVERSION)dnl
AC_INIT(shell.h)
AC_CONFIG_HEADER(config.h)
dnl make sure we are using a recent autoconf version
-AC_PREREQ(2.10)
+AC_PREREQ(2.12)
dnl where to find install.sh, config.sub, and config.guess
AC_CONFIG_AUX_DIR(./support)
@@ -22,7 +22,7 @@ dnl parsing options
AC_CANONICAL_HOST
dnl configure defaults
-opt_gnu_malloc=yes
+opt_bash_malloc=yes
opt_glibc_malloc=no
opt_purify=no
opt_purecov=no
@@ -30,35 +30,39 @@ opt_afs=no
opt_curses=no
opt_with_installed_readline=no
+#htmldir=
+
dnl some systems should be configured without gnu 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_gnu_malloc=no ;; # alpha running osf/1 or linux
-*[Cc]ray*-*) opt_gnu_malloc=no ;; # Crays
-*-osf1*) opt_gnu_malloc=no ;; # other osf/1 machines
-sparc-svr4*) opt_gnu_malloc=no ;; # sparc SVR4, SVR4.2
-sparc-netbsd*) opt_gnu_malloc=no ;; # needs 8-byte alignment
-mips-irix6*) opt_gnu_malloc=no ;; # needs 8-byte alignment
-sparc-linux*) opt_gnu_malloc=no ;; # sparc running linux; requires ELF
-#*-freebsd*) opt_gnu_malloc=no ;; # they claim it's better
-*-aix*) opt_gnu_malloc=no ;; # AIX machines
-*-nextstep*) opt_gnu_malloc=no ;; # NeXT machines running NeXTstep
-*-rhapsody*) opt_gnu_malloc=no ;; # Apple Rhapsody
-*-dgux*) opt_gnu_malloc=no ;; # DG/UX machines
-*-qnx*) opt_gnu_malloc=no ;; # QNX 4.2
-*-machten4) opt_gnu_malloc=no ;; # MachTen 4.x
-*-bsdi2.1|*-bsdi3.?) opt_gnu_malloc=no ; : ${CC:=shlicc2} ;; # for loadable builtins
-*-beos*) opt_gnu_malloc=no ;; # they say it's suitable
-*-cygwin32*) opt_gnu_malloc=no ;; # Cygnus's CYGWIN32 environment
+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*) opt_bash_malloc=no ;; # they claim it's better
+*-aix*) opt_bash_malloc=no ;; # AIX machines
+*-nextstep*) opt_bash_malloc=no ;; # NeXT machines running NeXTstep
+*-rhapsody*) opt_bash_malloc=no ;; # Apple Rhapsody
+*-dgux*) opt_bash_malloc=no ;; # DG/UX machines
+*-qnx*) opt_bash_malloc=no ;; # QNX 4.2
+*-machten4) opt_bash_malloc=no ;; # MachTen 4.x
+*-bsdi2.1|*-bsdi3.?) opt_bash_malloc=no ; : ${CC:=shlicc2} ;; # for loadable builtins
+*-beos*) opt_bash_malloc=no ;; # they say it's suitable
+*-cygwin32*) opt_bash_malloc=no ;; # Cygnus's CYGWIN32 environment
esac
dnl arguments to configure
dnl packages
AC_ARG_WITH(afs, --with-afs if you are running AFS, opt_afs=$withval)
+AC_ARG_WITH(bash-malloc, --with-bash-malloc use the Bash version of malloc,opt_bash_malloc=$withval)
AC_ARG_WITH(curses, --with-curses use the curses library instead of the termcap library,opt_curses=$withval)
AC_ARG_WITH(glibc-malloc, --with-glibc-malloc use the GNU C library version of malloc,opt_glibc_malloc=$withval)
-AC_ARG_WITH(gnu-malloc, --with-gnu-malloc use the GNU version of malloc,opt_gnu_malloc=$withval)
+AC_ARG_WITH(gnu-malloc, --with-gnu-malloc synonym for --with-bash-malloc,opt_bash_malloc=$withval)
AC_ARG_WITH(installed-readline, --with-installed-readline use a version of the readline library that is already installed, opt_with_installed_readline=$withval)
AC_ARG_WITH(purecov, --with-purecov configure to postprocess with pure coverage, opt_purecov=$withval)
AC_ARG_WITH(purify, --with-purify configure to postprocess with purify, opt_purify=$withval)
@@ -67,9 +71,10 @@ dnl test for glibc malloc first because it can override the default
if test "$opt_glibc_malloc" = yes; then
MALLOC_TARGET=gmalloc
MALLOC_SRC=gmalloc.c
-elif test "$opt_gnu_malloc" = yes; then
+elif test "$opt_bash_malloc" = yes; then
MALLOC_TARGET=malloc
MALLOC_SRC=malloc.c
+ AC_DEFINE(USING_BASH_MALLOC)
else
MALLOC_TARGET=stubmalloc
MALLOC_SRC=stub.c
@@ -113,8 +118,11 @@ opt_extended_glob=yes
opt_brace_expansion=yes
opt_disabled_builtins=no
opt_command_timing=yes
-opt_usg_echo=no
+opt_xpg_echo=no
opt_cond_command=yes
+opt_arith_for_command=yes
+opt_net_redirs=yes
+opt_progcomp=yes
dnl options that affect how bash is compiled and linked
opt_static_link=no
@@ -131,10 +139,12 @@ if test $opt_minimal_config = yes; then
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_extended_glob=no opt_cond_command=no opt_arith_for_command=no
+ opt_net_redirs=no opt_progcomp=no
fi
AC_ARG_ENABLE(alias, --enable-alias enable shell aliases, opt_alias=$enableval)
+AC_ARG_ENABLE(arith-for-command, --enable-arith-for-command enable arithmetic for command, opt_arith_for_command=$enableval)
AC_ARG_ENABLE(array-variables, --enable-array-variables include shell array variables, opt_array_variables=$enableval)
AC_ARG_ENABLE(bang-history, --enable-bang-history turn on csh-style history substitution, opt_bang_history=$enableval)
AC_ARG_ENABLE(brace-expansion, --enable-brace-expansion include brace expansion, opt_brace_expansion=$enableval)
@@ -147,12 +157,15 @@ AC_ARG_ENABLE(extended-glob, --enable-extended-glob include ksh-style extended p
AC_ARG_ENABLE(help-builtin, --enable-help-builtin include the help builtin, opt_help=$enableval)
AC_ARG_ENABLE(history, --enable-history turn on command history, opt_history=$enableval)
AC_ARG_ENABLE(job-control, --enable-job-control enable job control features, opt_job_control=$enableval)
+AC_ARG_ENABLE(net-redirections, --enable-net-redirections enable /dev/tcp/host/port redirection, opt_net_redirs=$enableval)
AC_ARG_ENABLE(process-substitution, --enable-process-substitution enable process substitution, opt_process_subst=$enableval)
+AC_ARG_ENABLE(progcomp, --enable-progcomp enable programmable completion and the complete builtin, opt_progcomp=$enableval)
AC_ARG_ENABLE(prompt-string-decoding, --enable-prompt-string-decoding turn on escape character decoding in prompts, opt_prompt_decoding=$enableval)
AC_ARG_ENABLE(readline, --enable-readline turn on command line editing, opt_readline=$enableval)
AC_ARG_ENABLE(restricted, --enable-restricted enable a restricted shell, opt_restricted=$enableval)
AC_ARG_ENABLE(select, --enable-select include select command, opt_select=$enableval)
-AC_ARG_ENABLE(usg-echo-default, --enable-usg-echo-default make the echo builtin expand escape sequences by default, opt_usg_echo=$enableval)
+AC_ARG_ENABLE(usg-echo-default, --enable-usg-echo-default a synonym for --enable-xpg-echo-default, opt_xpg_echo=$enableval)
+AC_ARG_ENABLE(xpg-echo-default, --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(profiling, --enable-profiling allow profiling with gprof, opt_profiling=$enableval)
@@ -200,8 +213,8 @@ fi
if test $opt_command_timing = yes; then
AC_DEFINE(COMMAND_TIMING)
fi
-if test $opt_usg_echo = yes ; then
-AC_DEFINE(DEFAULT_ECHO_TO_USG)
+if test $opt_xpg_echo = yes ; then
+AC_DEFINE(DEFAULT_ECHO_TO_XPG)
fi
if test $opt_extended_glob = yes ; then
AC_DEFINE(EXTENDED_GLOB)
@@ -209,6 +222,15 @@ fi
if test $opt_cond_command = yes ; then
AC_DEFINE(COND_COMMAND)
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_minimal_config" = yes; then
TESTSCRIPT=run-minimal
@@ -222,6 +244,8 @@ AC_SUBST(PURIFY)
AC_SUBST(MALLOC_TARGET)
AC_SUBST(MALLOC_SRC)
+AC_SUBST(htmldir)
+
dnl Use GNU m4 macros to get the distribution and patchlevel information
dnl into configure without requiring the files to be distributed
[BASHVERS=]dnl
@@ -236,9 +260,16 @@ dnl AC_PROG_CC sets $cross_compiling to `yes' if cross-compiling for a
dnl different environment
AC_PROG_CC
BASH_LARGE_FILE_SUPPORT
+
+dnl test for Unix variants
AC_ISC_POSIX
AC_MINIX
+dnl test for non-Unix variants
+AC_CYGWIN
+AC_MINGW32
+AC_EXEEXT
+
dnl BEGIN changes for cross-building for cygwin32 and BeOS
SIGNAMES_H=lsignames.h
@@ -322,15 +353,19 @@ then
dnl we duplicate some work that's done later here so we can look in
dnl the correct directory for the readline library
+ if test -z "$TERMCAP_LIB" ; then
+ BASH_CHECK_LIB_TERMCAP
+ fi
+
test "x$prefix" = xNONE && _rl_prefix=$ac_default_prefix || _rl_prefix=${prefix}
test "x$exec_prefix" = xNONE && _rl_exec_prefix=${_rl_prefix} || _rl_exec_prefix=${exec_prefix}
AC_MSG_CHECKING(version of installed readline library)
- _rl_version=`exec_prefix=${_rl_exec_prefix} ${CONFIG_SHELL-/bin/sh} ${srcdir}/support/rlvers.sh -C "${CC}" -L ${libdir}`
+ _rl_version=`exec_prefix=${_rl_exec_prefix} ${CONFIG_SHELL-/bin/sh} ${srcdir}/support/rlvers.sh -C "${CC}" -L ${libdir} -T ${TERMCAP_LIB}`
AC_MSG_RESULT($_rl_version)
case "$_rl_version" in
- 3*|4*|5*|6*|7*|8*|9*) ;;
+ 4.[[1-9]]*|5*|6*|7*|8*|9*) ;;
*) opt_with_installed_readline=no
AC_MSG_WARN(installed readline library is too old to be linked with bash)
AC_MSG_WARN(using private bash version)
@@ -395,7 +430,7 @@ AC_PROG_YACC
AC_PROG_MAKE_SET
case "$host_os" in
-opennt*|interix*) MAKE_SHELL="$OPENNT_ROOT/bin/sh" ;;
+opennt*|interix*) MAKE_SHELL="$INTERIX_ROOT/bin/sh" ;;
*) MAKE_SHELL=/bin/sh ;;
esac
AC_SUBST(MAKE_SHELL)
@@ -437,7 +472,8 @@ dnl checks for c library functions
AC_CHECK_FUNCS(bcopy bzero confstr getcwd strcasecmp setenv putenv \
setlinebuf setlocale strchr strerror strtod strtol \
strtoul tcgetattr uname sysconf ulimit times tzset \
- siginterrupt memmove)
+ siginterrupt memmove ttyname gethostbyname inet_aton \
+ strpbrk setvbuf)
dnl checks for locale functions
AC_CHECK_HEADERS(libintl.h)
@@ -467,18 +503,31 @@ AC_HEADER_TIME
AC_CHECK_HEADERS(unistd.h stdlib.h stdarg.h varargs.h limits.h string.h \
memory.h locale.h termcap.h termio.h termios.h dlfcn.h \
- stddef.h)
+ stddef.h netdb.h)
AC_CHECK_HEADERS(sys/ptem.h sys/pte.h sys/stream.h sys/select.h sys/file.h \
sys/resource.h sys/param.h sys/socket.h \
sys/time.h sys/times.h sys/wait.h)
+AC_CHECK_HEADERS(netinet/in.h arpa/inet.h)
+
+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].?
-dnl AC_CHECK_LIB(sun, getpwent)
+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_SOCKLIB
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
@@ -491,25 +540,26 @@ AC_CHECK_TYPE(time_t, long)
AC_TYPE_SIGNAL
+AC_CHECK_SIZEOF(char, 1)
+AC_CHECK_SIZEOF(short, 2)
AC_CHECK_SIZEOF(int, 4)
AC_CHECK_SIZEOF(long, 4)
AC_CHECK_SIZEOF(char *, 4)
AC_CHECK_SIZEOF(double, 8)
-BASH_TYPE_INT32_T
-BASH_TYPE_U_INT32_T
-BASH_TYPE_PTRDIFF_T
+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
-AC_HEADER_EGREP(struct timeval, sys/time.h, bash_cv_struct_timeval=yes, )
-if test -z "$bash_cv_struct_timeval"; then
-AC_HEADER_EGREP(struct timeval, time.h, bash_cv_struct_timeval=yes, bash_cv_struct_timeval=no)
-fi
-if test $bash_cv_struct_timeval = yes; then
-AC_DEFINE(HAVE_TIMEVAL)
-fi
dnl C compiler characteristics
AC_C_BIGENDIAN
@@ -554,6 +604,7 @@ BASH_STRUCT_TERMIO_LDISC
BASH_STRUCT_DIRENT_D_INO
BASH_STRUCT_DIRENT_D_FILENO
BASH_STRUCT_WINSIZE
+BASH_STRUCT_TIMEVAL
dnl presence and behavior of C library functions
BASH_FUNC_STRSIGNAL
@@ -596,6 +647,7 @@ AC_SUBST(TERMCAP_LIB)
AC_SUBST(TERMCAP_DEP)
BASH_CHECK_DEV_FD
+BASH_CHECK_DEV_STDIN
BASH_DEFAULT_MAIL_DIR
if test "$bash_cv_job_control_missing" = missing; then
@@ -629,7 +681,8 @@ 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;;
+isc*) LOCAL_CFLAGS=-Disc386 ;;
+rhapsody*) LOCAL_CFLAGS=-DRHAPSODY ;;
sco3.2v5*) LOCAL_CFLAGS="-b elf -DWAITPID_BROKEN -DNO_MEMSCRAMBLE -DPATH_MAX=1024" ;;
sco3.2v4*) LOCAL_CFLAGS="-DMUST_UNBLOCK_CHLD -DNO_MEMSCRAMBLE -DPATH_MAX=1024" ;;
sco3.2*) LOCAL_CFLAGS=-DMUST_UNBLOCK_CHLD ;;
@@ -650,6 +703,13 @@ aix4.2*) LOCAL_LDFLAGS="-bexpall -brtl" ;;
bsdi4*-*gcc*) LOCAL_LDFLAGS="-rdynamic" ;; # allow dynamic loading, like Linux
esac
+dnl FreeBSD-3.x can have either a.out or ELF
+case "${host_os}" in
+freebsd3*) if test -x /usr/bin/objformat && test "`/usr/bin/objformat`" = "elf" ; then
+ LOCAL_LDFLAGS=-rdynamic # allow dynamic loading
+ fi ;;
+esac
+
case "$host_cpu" in
*cray*) LOCAL_CFLAGS="-DCRAY" ;; # shell var so config.h can use it
esac
@@ -670,7 +730,7 @@ esac
if test "$ac_cv_func_dlopen" = "yes" && test -f ${srcdir}/support/shobj-conf
then
AC_MSG_CHECKING(shared object configuration for loadable builtins)
- eval `${CONFIG_SHELL-/bin/sh} ${srcdir}/support/shobj-conf -C ${CC} -c ${host_cpu} -o ${host_os} -v ${host_vendor}`
+ eval `${CONFIG_SHELL-/bin/sh} ${srcdir}/support/shobj-conf -C "${CC}" -c ${host_cpu} -o ${host_os} -v ${host_vendor}`
AC_SUBST(SHOBJ_CC)
AC_SUBST(SHOBJ_CFLAGS)
AC_SUBST(SHOBJ_LD)
@@ -692,6 +752,7 @@ case "$srcdir" in
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
@@ -724,7 +785,7 @@ AC_SUBST(LOCAL_DEFS)
AC_OUTPUT([Makefile builtins/Makefile lib/readline/Makefile lib/glob/Makefile \
lib/malloc/Makefile lib/sh/Makefile lib/termcap/Makefile \
lib/tilde/Makefile doc/Makefile support/Makefile \
- examples/loadables/Makefile],
+ examples/loadables/Makefile examples/loadables/perl/Makefile],
[
# Makefile uses this timestamp file to record whether config.h is up to date.
echo timestamp > stamp-h
diff --git a/copy_cmd.c b/copy_cmd.c
index 2ccea518..964a3e77 100644
--- a/copy_cmd.c
+++ b/copy_cmd.c
@@ -8,7 +8,7 @@
Bash is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 1, or (at your option)
+ the Free Software Foundation; either version 2, or (at your option)
any later version.
Bash is distributed in the hope that it will be useful, but WITHOUT
@@ -18,7 +18,7 @@
You should have received a copy of the GNU General Public License
along with Bash; see the file COPYING. If not, write to the Free
- Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#include "config.h"
@@ -152,6 +152,24 @@ copy_for_command (com)
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;
@@ -163,6 +181,18 @@ copy_group_command (com)
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 CASE_COM *
copy_case_command (com)
CASE_COM *com;
@@ -290,6 +320,12 @@ copy_command (command)
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 =
@@ -301,6 +337,10 @@ copy_command (command)
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_case:
new_command->value.Case = copy_case_command (command->value.Case);
break;
diff --git a/dispose_cmd.c b/dispose_cmd.c
index 10670235..7a9f2027 100644
--- a/dispose_cmd.c
+++ b/dispose_cmd.c
@@ -6,7 +6,7 @@
Bash is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 1, or (at your option)
+ the Free Software Foundation; either version 2, or (at your option)
any later version.
Bash is distributed in the hope that it will be useful, but WITHOUT
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with Bash; see the file COPYING. If not, write to the Free
- Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#include "config.h"
@@ -61,6 +61,21 @@ dispose_command (command)
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);
@@ -68,6 +83,13 @@ dispose_command (command)
break;
}
+ case cm_subshell:
+ {
+ dispose_command (command->value.Subshell->command);
+ free (command->value.Subshell);
+ break;
+ }
+
case cm_case:
{
register CASE_COM *c;
diff --git a/dispose_cmd.h b/dispose_cmd.h
index 8fc2f78b..595a6ad7 100644
--- a/dispose_cmd.h
+++ b/dispose_cmd.h
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if !defined (_DISPOSE_CMD_H_)
#define _DISPOSE_CMD_H_
diff --git a/doc/FAQ b/doc/FAQ
index 08037d80..5c678e9f 100644
--- a/doc/FAQ
+++ b/doc/FAQ
@@ -1,4 +1,4 @@
-This is the Bash FAQ, version 3.0, for Bash version 2.03.
+This is the Bash FAQ, version 3.7, for Bash version 2.04.
This document contains a set of frequently-asked questions concerning
Bash, the GNU Bourne-Again Shell. Bash is a freely-available command
@@ -15,6 +15,8 @@ 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:
@@ -34,8 +36,8 @@ A10) What is the bash `posix mode'?
Section B: The latest version
-B1) What's new in version 2.03?
-B2) Are there any user-visible incompatibilities between bash-2.03 and
+B1) What's new in version 2.04?
+B2) Are there any user-visible incompatibilities between bash-2.04 and
bash-1.14.7?
Section C: Differences from other Unix shells
@@ -56,26 +58,18 @@ D5) How can I pipe standard output and standard error from one command to
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: How can I get bash to do certain things, and why does bash do
- things the way it does?
+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) How can I get bash to read and display eight-bit characters?
-E4) How do I write a function `x' to replace builtin command `x', but
- still invoke the command from within the function?
-E5) When I have terminal escape sequences in my prompt, why does bash
+E3) When I have terminal escape sequences in my prompt, why does bash
wrap lines at the wrong column?
-E6) How can I find the value of a shell variable whose name is the value
- of another shell variable?
-E7) If I pipe the output of a command into `read variable', why doesn't
+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?
-E8) I have a bunch of shell scripts that use backslash-escaped characters
+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?
-E9) Why doesn't a while or for loop get suspended when I type ^Z?
-E10) How can I make the bash `time' reserved word print timing output that
- looks like the output from my system's /usr/bin/time?
+E6) Why doesn't a while or for loop get suspended when I type ^Z?
Section F: Things to watch out for on certain Unix versions
@@ -87,15 +81,31 @@ F3) Why does bash dump core after I interrupt username completion or
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?
+
+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 G: Where do I go from here?
+Section H: Where do I go from here?
-G1) How do I report bugs in bash, and where should I look for fixes and
+H1) How do I report bugs in bash, and where should I look for fixes and
advice?
-G2) What kind of bash documentation is there?
-G3) What's coming in future versions?
-G4) What's on the bash `wish list'?
-G5) When will the next release appear?
+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
@@ -120,22 +130,22 @@ of Case Western Reserve University.
A2) What's the latest version?
-The latest version is 2.03, first made available on Friday, 19 Feburary 1999.
+The latest version is 2.04, first made available on Friday, 17 March 2000.
A3) Where can I get it?
Bash is the GNU project's shell, and so is available from the
master GNU archive site, ftp.gnu.org, and its mirrors. The
latest version is also available for FTP from ftp.cwru.edu.
-The following URLs tell how to get version 2.03:
+The following URLs tell how to get version 2.04:
-ftp://ftp.gnu.org/pub/gnu/bash-2.03.tar.gz
-ftp://ftp.cwru.edu/pub/bash/bash-2.03.tar.gz
+ftp://ftp.gnu.org/pub/gnu/bash/bash-2.04.tar.gz
+ftp://ftp.cwru.edu/pub/bash/bash-2.04.tar.gz
Formatted versions of the documentation are available with the URLs:
-ftp://ftp.gnu.org/pub/gnu/bash-doc-2.03.tar.gz
-ftp://ftp.cwru.edu/pub/bash/bash-doc-2.03.tar.gz
+ftp://ftp.gnu.org/pub/gnu/bash/bash-doc-2.04.tar.gz
+ftp://ftp.cwru.edu/pub/bash/bash-doc-2.04.tar.gz
A4) On what machines will bash run?
@@ -150,25 +160,25 @@ More information appears in the file `INSTALL' in the distribution.
A5) Will bash run on operating systems other than Unix?
Configuration specifics for Unix-like systems such as QNX and
-LynxOS are included in the distribution. Bash-2.03 should
+LynxOS are included in the distribution. Bash-2.04 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 as part of their GNU-Win32
+The port was done by Cygnus Solutions as part of their CYGWIN
project. For more information about the project, look at the URL
-http://www.cygnus.com/misc/gnu-win32
+http:/sourceware.cygnus.com/cygwin
Cygnus originally ported bash-1.14.7, and that port was part of their
-early GNU-Win32 releases. Cygnus has also done a port of bash-2.01 to the
-GNU-Win32 environment, and it is available as part of their current
-release. (They may have upgraded by now.)
+early GNU-Win32 (the original name) releases. Cygnus has also done a
+port of bash-2.02.1 to the CYGWIN environment, and it is available as
+part of their current release. (They may have upgraded by now.)
-Bash-2.03 should require no local Cygnus changes to build and run under
-GNU-WIN32.
+Bash-2.04 should require no local Cygnus changes to build and run under
+CYGWIN.
The Cygnus port works only on Intel machines. There is a port of bash
(I don't know which version) to the alpha/NT environment available from
@@ -185,7 +195,7 @@ but Interix users should fetch
ftp://ftp.interix.com/pub/tw/unsup/bash.diffs.tar.gz
and read the README.OpenNT file in that archive. It will detail the
-arguments configure needs to build on Interix. A configure cache
+arguments `configure' needs to build on Interix. A configure cache
file for Interix is in the bash distribution in cross-build/opennt.cache;
copy that to `config.cache' before starting configure.
@@ -203,6 +213,15 @@ The corresponding source is
ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2gnu/bsh1147s.zip
+Mark Elbrecht <snowball3@bigfoot.com> has sent me notice that bash-2.03
+has become available for DJGPP V2. The files are available as:
+
+ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2gnu/bsh203b.zip binary
+ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2gnu/bsh203d.zip documentation
+ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2gnu/bsh203s.zip source
+
+Mark has begun to work with bash-2.04.
+
Ports of bash-1.12 and bash-2.0 are available for OS/2 from
ftp://hobbes.nmsu.edu/pub/os2/util/shell/bash_112.zip
@@ -211,6 +230,10 @@ ftp://hobbes.nmsu.edu/pub/os2/util/shell/bash-2.0(253).zip
I haven't looked at either, but the second appears to be a binary-only
distribution. Beware.
+I have received word that Bash (I'm not sure which version, but I
+believe that it's at least bash-2.02.1) is the standard shell on
+BeOS.
+
A6) How can I build bash with gcc?
Bash configures to use gcc by default if it is available. Read the
@@ -262,6 +285,33 @@ 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) to do the
+right thing.
+
+`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
+
+
A8) I just changed my login shell to bash, and now I can't FTP into my
machine. Why not?
@@ -324,16 +374,59 @@ Reference Manual.
Section B: The latest version
-B1) What's new in version 2.03?
-
-Bash-2.03 has a very few new features, in keeping with the convention
+B1) What's new in version 2.04?
+
+Bash-2.04 contains the following new features (see the manual page for
+complete descriptions and the CHANGES and NEWS files in the bash-2.04
+distribution):
+
+o Programmable word completion with the new `complete' and `compgen' builtins;
+ examples are provided in examples/complete/complete-examples
+o `history' has a new `-d' option to delete a history entry
+o `bind' has a new `-x' option to bind key sequences to shell commands
+o The prompt expansion code has new `\j' and `\l' escape sequences
+o The `no_empty_command_completion' shell option, if enabled, inhibits
+ 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, has 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
+
+
+A short feature history dating from bash-2.0:
+
+Bash-2.03 had very few new features, in keeping with the convention
that odd-numbered releases provide mainly bug fixes. A number of new
features were added to Readline, mostly at the request of the Cygnus
folks.
-a new shopt option, `restricted_shell', so that startup files can test
+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
+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
@@ -342,7 +435,7 @@ Bash may now be linked against an already-installed Readline library,
All shells begun with the `--login' option will source the login shell
startup files, even if the shell is not interactive
-There are lots of changes to the version of the Readline library released
+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.
@@ -412,11 +505,11 @@ grammar tighter and smaller (66 reduce-reduce conflicts gone)
lots of code now smaller and faster
test suite greatly expanded
-B2) Are there any user-visible incompatibilities between bash-2.03 and
+B2) Are there any user-visible incompatibilities between bash-2.04 and
bash-1.14.7?
-There are a few incompatibilities between version 1.14.7 and version 2.03.
-They are detailed in the file COMPAT in the bash-2.03 distribution.
+There are a few incompatibilities between version 1.14.7 and version 2.04.
+They are detailed in the file COMPAT in the bash-2.04 distribution.
Section C: Differences from other Unix shells
@@ -431,13 +524,15 @@ Things bash has that sh does not:
`!' reserved word to invert pipeline return value
`time' reserved word to time pipelines and shell builtins
the `function' reserved word
- the select compound command and reserved word
+ the `select' compound command and reserved word
+ arithmetic for command: for ((expr1 ; expr2; expr3 )); do list; done
new $'...' and $"..." quoting
the $(...) form of command substitution
the $(<filename) form of command substitution, equivalent to
$(cat filename)
the ${#param} parameter value length operator
the ${!param} indirect parameter expansion operator
+ the ${!param*} prefix expansion operator
the ${param:length[:offset]} parameter substring operator
the ${param/pat[/string]} parameter pattern substitution operator
expansions to perform substring removal (${p%[%]w}, ${p#[#]w})
@@ -448,16 +543,18 @@ Things bash has that sh does not:
ENV, PS3, PS4, DIRSTACK, PIPESTATUS, HISTSIZE, HISTFILE,
HISTFILESIZE, HISTCONTROL, HISTIGNORE, GLOBIGNORE, GROUPS,
PROMPT_COMMAND, FCEDIT, FIGNORE, IGNOREEOF, INPUTRC,
- SHELLOPTS, OPTERR, HOSTFILE, TMOUT, histchars, auto_resume
+ SHELLOPTS, OPTERR, HOSTFILE, TMOUT, FUNCNAME, histchars,
+ auto_resume
DEBUG trap
variable arrays with new compound assignment syntax
redirections: <>, &>, >|
prompt string special char translation and variable expansion
- auto-export of modified values of variables in initial environment
+ 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 -p.
- export -n/-f/-p/name=value, pwd -L/-P, read -e/-p/-a,
+ export -n/-f/-p/name=value, pwd -L/-P,
+ read -e/-p/-a/-t/-n/-d/-s,
readonly -a/-f/name=value, trap -l, set +o,
set -b/-m/-o option/-h/-p/-B/-C/-H/-P,
unset -f/-v, ulimit -m/-p/-u,
@@ -473,12 +570,13 @@ Things bash has that sh does not:
process substitution
aliases and alias/unalias builtins
local variables in functions and `local' builtin
- readline and command-line editing
+ readline and command-line editing with programmable completion
command history and history/fc builtins
csh-like history expansion
- other new bash builtins: bind, command, builtin, declare/typeset,
- dirs, enable, fc, help, history, logout,
- popd, pushd, disown, shopt, printf
+ other new bash builtins: bind, command, compgen, complete, builtin,
+ declare/typeset, dirs, enable, fc, help,
+ history, logout, popd, pushd, disown, shopt,
+ printf
exported functions
filename generation when using output redirection (command >a*)
POSIX.2-style globbing character classes
@@ -489,6 +587,8 @@ Things bash has that sh does not:
variable assignments preceding commands affect only that command,
even for builtins and functions
posix mode
+ redirection to /dev/fd/N, /dev/stdin, /dev/stdout, /dev/stderr,
+ /dev/tcp/host/port, /dev/udp/host/port
Things sh has that bash does not:
uses variable SHACCT to do shell accounting
@@ -521,11 +621,13 @@ C2) How does bash differ from the Korn shell, version ksh88?
Things bash has or uses that ksh88 does not:
long invocation options
`!' reserved word
+ arithmetic for command: for ((expr1 ; expr2; expr3 )); do list; done
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:length[:offset]} parameter substring operator
the ${param/pat[/string]} parameter pattern substitution operator
variables: BASH, BASH_VERSION, BASH_VERSINFO, UID, EUID, SHLVL,
@@ -533,18 +635,19 @@ Things bash has or uses that ksh88 does not:
HISTFILESIZE, HISTIGNORE, HISTCONTROL, PROMPT_COMMAND,
IGNOREEOF, FIGNORE, INPUTRC, HOSTFILE, DIRSTACK,
PIPESTATUS, HOSTNAME, OPTERR, SHELLOPTS, GLOBIGNORE,
- GROUPS, histchars, auto_resume
+ GROUPS, FUNCNAME, histchars, auto_resume
prompt expansion with backslash escapes and command substitution
redirection: &> (stdout and stderr)
- more extensive and extensible editing and completion
+ 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, 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 -u,
- umask -S, alias -p, shopt, disown, printf
+ read -e/-p/-a/-t/-n/-d/-s, 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 -u, umask -S, alias -p, shopt,
+ disown, printf, complete, compgen
`!' csh-style history expansion
POSIX.2-style globbing character classes
POSIX.2-style globbing equivalence classes
@@ -552,10 +655,11 @@ Things bash has or uses that ksh88 does not:
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
Things ksh88 has or uses that bash does not:
tracked aliases
- variables: ERRNO, FPATH, COLUMNS, LINES, EDITOR, VISUAL
+ variables: ERRNO, FPATH, EDITOR, VISUAL
co-processes (|&, >&p, <&p)
weirdly-scoped functions
typeset +f to list all function names without definitions
@@ -574,30 +678,29 @@ Implementation differences:
C3) Which new features in ksh-93 are not in bash, and which are?
-New things in ksh-93 not in bash-2.03:
+New things in ksh-93 not in bash-2.04:
associative arrays
floating point arithmetic
- ++, --, comma arithmetic operators
math library functions
${!name[sub]} name of subscript for associative array
- ${!prefix*} and {!prefix@} variable name prefix expansions
`.' is allowed in variable names to create a hierarchical namespace
more extensive compound assignment syntax
discipline functions
`sleep' and `getconf' builtins (bash has loadable versions)
typeset -n and `nameref' variables
KEYBD trap
- variables: .sh.edchar, .sh.edmode, .sh.edcol, .sh.edtext, HISTEDIT,
- .sh.version, .sh.name, .sh.subscript, .sh.value
+ variables: .sh.edchar, .sh.edmode, .sh.edcol, .sh.edtext, .sh.version,
+ .sh.name, .sh.subscript, .sh.value, HISTEDIT
backreferences in pattern matching
- print -f (bash has a loadable version of print and the printf builtin)
+ print -f (bash uses printf)
`fc' has been renamed to `hist'
- read -t/-d
`.' can execute shell functions
-New things in ksh-93 present in bash-2.03:
- ?: arithmetic operator
- expansions: ${!param}, ${param:offset[:len]}, ${param/pat[/str]}
+New things in ksh-93 present in bash-2.04:
+ 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
the `!' reserved word
loadable builtins -- but ksh uses `builtin' while bash uses `enable'
@@ -607,6 +710,7 @@ New things in ksh-93 present in bash-2.03:
set -o notify/-C
changes to kill builtin
read -A (bash uses read -a)
+ read -t/-d
trap -p
exec -c/-a
`.' restores the positional parameters when it completes
@@ -638,7 +742,7 @@ the following function definition to your .bashrc:
which()
{
- builtin type -p "$@"
+ builtin type "$@"
}
If you're moving from tcsh and would like to bring `where' along
@@ -771,8 +875,8 @@ 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 that do not have direct bash equivalents.
-Most, however, can be emulated with very little trouble.
+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
-------------- ---------------
@@ -784,6 +888,14 @@ 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 fc=hist
+$HISTEDIT $FCEDIT
+
Section E: How can I get bash to do certain things, and why does bash do
things the way it does?
@@ -835,62 +947,7 @@ You can build a version of bash that will not report SIGPIPE errors
by uncommenting the definition of DONT_REPORT_SIGPIPE in the file
config-top.h.
-E3) How can I get bash to read and display eight-bit characters?
-
-This is a process requiring several steps.
-
-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. 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 meta-flag on'
- bash$ bind 'set output-meta on'
-
-The `set' commands between the single quotes may also be placed
-in ~/.inputrc.
-
-E4) 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.
-
-E5) When I have terminal escape sequences in my prompt, why does bash
+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
@@ -906,38 +963,7 @@ 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.
-E6) 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.
-
-E7) If I pipe the output of a command into `read variable', why doesn't
+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
@@ -993,13 +1019,13 @@ this.
This is the general approach -- in most cases you will not need to
set $IFS to a different value.
-E8) I have a bunch of shell scripts that use backslash-escaped characters
+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 modelled after the 9th Edition
+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
@@ -1013,7 +1039,11 @@ configure with the --enable-usg-echo-default option to turn this
on. Be aware that this will cause some of the tests run when you
type `make tests' to fail.
-E9) Why doesn't a while or for loop get suspended when I type ^Z?
+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
@@ -1028,38 +1058,6 @@ 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.
-E10) How can I make the bash `time' reserved word print timing output that
- looks like the output from my system's /usr/bin/time?
-
-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'
-
Section F: Things to watch out for on certain Unix versions
F1) Why can't I use command line editing in my `cmdtool'?
@@ -1156,16 +1154,211 @@ is, in fact, a syntax error. Redirections may only precede `simple
commands'. A subshell construct such as the above is one of the shell's
`compound commands'. A redirection may only follow a compound command.
-The file CWRU/sh-redir-hack in the bash-2.03 distribution is an
+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-2.04 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.
-Section G: Where do I go from here?
+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
+
+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. 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 meta-flag on'
+ bash$ bind 'set output-meta on'
+
+The `set' commands between the single quotes may also be placed
+in ~/.inputrc.
+
+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.
+
+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.
+
+Section H: Where do I go from here?
-G1) How do I report bugs in bash, and where should I look for fixes and
+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
@@ -1183,7 +1376,7 @@ and problems also take place there.
To reach the bash maintainers directly, send mail to
bash-maintainers@gnu.org.
-G2) What kind of bash documentation is there?
+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:
@@ -1213,36 +1406,33 @@ A second edition of this book is available, published in January, 1998.
The ISBN number is 1-56592-347-2. Look for it in the same fine bookstores
or on the web.
-G3) What's coming in future versions?
+H3) What's coming in future versions?
These are features I plan to include in a future version of bash.
-a bash debugger (a minimally-tested version is included with bash-2.02)
-Programmable completion a la zsh/tcsh
+a bash debugger (a minimally-tested version is included with bash-2.04)
+associative arrays
-G4) What's on the bash `wish list' for future versions?
+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.
-associative arrays (not really all that hard)
breaking some of the shell functionality into embeddable libraries
+a module system like zsh's, using dynamic loading like builtins
better internationalization using GNU `gettext'
an option to use external files for the long `help' text
-timeouts for the `read' builtin
-the ksh-93 ${!prefix*} and ${!prefix@} operators
-arithmetic ++ and -- prefix and postfix operators
date-stamped command history
-a way to bind readline editing key sequences to shell commands
-a mechanism to open network connections and assign them to file descriptors
- using redirection (like ksh /dev/{tcp,udp})
+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)
-G5) When will the next release appear?
+H5) When will the next release appear?
-The next version will appear sometime in 1999. Never make
+The next version will appear sometime in 2000 or 2001. Never make
predictions.
-This document is Copyright 1995-1999 by Chester Ramey.
+This document is Copyright 1995-2000 by Chester Ramey.
Permission is hereby granted, without written agreement and
without license or royalty fees, to use, copy, and distribute
diff --git a/doc/Makefile.in b/doc/Makefile.in
index f0794daa..9d006434 100644
--- a/doc/Makefile.in
+++ b/doc/Makefile.in
@@ -1,5 +1,22 @@
# This Makefile is for the Bash/documentation directory -*- text -*-.
#
+# Copyright (C) 1996 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
+
+#
SHELL = @MAKE_SHELL@
RM = rm -f
@@ -7,8 +24,14 @@ topdir = @top_srcdir@
srcdir = @srcdir@
VPATH = .:@srcdir@
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+
infodir = @infodir@
+# set this to a directory name to have the HTML files installed
+htmldir = @htmldir@
+
mandir = @mandir@
manpfx = man
@@ -34,7 +57,9 @@ TEXI2HTML = ${topdir}/support/texi2html
MAN2HTML = ${BUILD_DIR}/support/man2html
HTMLPOST = ${srcdir}/htmlpost.sh
QUIETPS = #set this to -q to shut up dvips
-DVIPS = dvips -D 300 $(QUIETPS) -o $@ # tricky
+PAPERSIZE = letter # change to a4 for A4-size paper
+PSDPI = 300 # could be 600 if you like
+DVIPS = dvips -D ${PSDPI} $(QUIETPS) -t ${PAPERSIZE} -o $@ # tricky
TEXINPUTDIR = $(RL_LIBDIR)/doc
MKDIRS = ${topdir}/support/mkdirs
@@ -85,10 +110,10 @@ RLUSER = $(RL_LIBDIR)/doc/rluser.texinfo
all: ps info dvi text html
nodvi: ps info text html
-PSFILES = bash.ps bashbug.ps readline.ps article.ps builtins.ps
+PSFILES = bash.ps bashbug.ps readline.ps article.ps builtins.ps rbash.ps
DVIFILES = bashref.dvi bashref.ps
INFOFILES = bashref.info
-MAN0FILES = bash.0 bashbug.0 builtins.0 readline.0
+MAN0FILES = bash.0 bashbug.0 builtins.0 rbash.0 readline.0
HTMLFILES = bashref.html bash.html
ps: ${PSFILES}
@@ -110,6 +135,16 @@ bashref.info: $(srcdir)/bashref.texi $(HSUSER) $(RLUSER)
bashref.html: bashref.texi $(HSUSER) $(RLUSER)
$(TEXI2HTML) -menu -monolithic -I $(TEXINPUTDIR) $(srcdir)/bashref.texi
+new-bashref.dvi: $(srcdir)/new-bashref.texi $(HSUSER) $(RLUSER)
+ TEXINPUTS=.:$(TEXINPUTDIR):$$TEXINPUTS $(TEXI2DVI) $(srcdir)/new-bashref.texi
+
+new-bashref.ps: new-bashref.dvi
+ $(RM) $@
+ $(DVIPS) new-bashref.dvi
+
+new-bashref.info: $(srcdir)/new-bashref.texi $(HSUSER) $(RLUSER)
+ $(MAKEINFO) --no-split -I$(TEXINPUTDIR) $(srcdir)/new-bashref.texi
+
bash.dvi: bash.texinfo $(HSUSER) $(RLUSER)
TEXINPUTS=.:$(TEXINPUTDIR):$$TEXINPUTS $(TEXI2DVI) bash.texinfo
@@ -122,9 +157,11 @@ bash.ps: bash.1
bash.html: bash.1 $(MAN2HTML)
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
readline.0: readline.3
readline.ps: readline.3
article.ps: article.ms
@@ -139,17 +176,26 @@ faq: ${CREATED_FAQ}
faq.version: FAQ.version FAQ
sh mkfaqvers FAQ.version > $@
-faq.news: FAQ FAQ.headers.news 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 > $@
+ cat faq.headers.news faq.version FAQ > $@
-faq.news2: FAQ FAQ.headers.news2 faq.version
+faq.news2: FAQ faq.headers.news2 faq.version
$(RM) $@
- cat FAQ.headers.news2 faq.version FAQ > $@
+ cat faq.headers.news2 faq.version FAQ > $@
-faq.mail: FAQ FAQ.headers.mail faq.version
+faq.mail: FAQ faq.headers.mail faq.version
$(RM) $@
- cat FAQ.headers.mail faq.version FAQ > $@
+ cat faq.headers.mail faq.version FAQ > $@
clean:
$(RM) *.aux *.bak *.cp *.fn *.ky *.log *.pg *.toc *.tp *.vr *.cps \
@@ -169,6 +215,9 @@ installdirs:
# uncomment the next line to create the directory for the readline man page
# -test -d $(man3dir) || $(SHELL) ${MKDIRS} $(man3dir)
-test -d $(infodir) || $(SHELL) ${MKDIRS} $(infodir)
+ -if [ -n "$(htmldir)" ]; then \
+ test -d $(htmldir) || $(SHELL) ${MKDIRS} $(htmldir) ; \
+ fi
install: info installdirs
-$(INSTALL_DATA) $(srcdir)/bash.1 $(man1dir)/bash.${man1ext}
@@ -182,11 +231,20 @@ install: info installdirs
if $(SHELL) -c 'install-info --version' >/dev/null 2>&1; then \
install-info --dir-file=$(infodir)/dir $(infodir)/bash.info; \
else true; fi
+# if htmldir is set, install the html files into that directory
+ -if [ -n "${htmldir}" ]; then \
+ $(INSTALL_DATA) $(srcdir)/bash.html $(htmldir) ; \
+ $(INSTALL_DATA) $(srcdir)/bashref.html $(htmldir) ; \
+ fi
uninstall:
-$(RM) $(man1dir)/bash.${man1ext} $(man1dir)/bashbug.${man1ext}
-$(RM) $(man3dir)/readline.${man3ext}
$(RM) $(infodir)/bash.info
+ -if [ -n "$(htmldir)" ]; then \
+ $(RM) $(htmldir)/bash.html ; \
+ $(RM) $(htmldir)/bashref.html ; \
+ fi
# for use by chet
inst: bashref.texi
diff --git a/doc/bash.1 b/doc/bash.1
index 739d34d6..d1dd7524 100644
--- a/doc/bash.1
+++ b/doc/bash.1
@@ -6,11 +6,12 @@
.\" Case Western Reserve University
.\" chet@ins.CWRU.Edu
.\"
-.\" Last Change: Wed Jan 20 16:47:14 EST 1999
+.\" Last Change: Tue Mar 14 11:36:43 EST 2000
.\"
.\" bash_builtins, strip all but Built-Ins section
.if \n(zZ=1 .ig zZ
-.TH BASH 1 "1999 Jan 20" GNU
+.if \n(zY=1 .ig zY
+.TH BASH 1 "2000 Mar 14" "GNU Bash-2.04"
.\"
.\" There's some problem with having a `@'
.\" in a tagged paragraph with the BSD man macros.
@@ -151,7 +152,7 @@ below).
.B \-\-noediting
Do not use the GNU
.B readline
-library to read command lines if interactive.
+library to read command lines when the shell is interactive.
.TP
.B \-\-noprofile
Do not read either the system-wide startup file
@@ -228,7 +229,11 @@ or one started with the
.B \-\-login
option.
.PP
-An \fIinteractive\fP shell is one whose standard input and output are
+An \fIinteractive\fP shell is one started without non-option arguments
+and without the
+.B \-c
+option
+whose standard input and output are
both connected to terminals (as determined by
.IR isatty (3)),
or one started with the
@@ -548,24 +553,24 @@ denote AND lists and OR lists, respectively.
An AND list has the form
.RS
.PP
-\fIcommand\fP \fB&&\fP \fIcommand2\fP
+\fIcommand1\fP \fB&&\fP \fIcommand2\fP
.RE
.PP
.I command2
is executed if, and only if,
-.I command
+.I command1
returns an exit status of zero.
.PP
An OR list has the form
.RS
.PP
-\fIcommand\fP \fB\(bv\(bv\fP \fIcommand2\fP
+\fIcommand1\fP \fB\(bv\(bv\fP \fIcommand2\fP
.PP
.RE
.PP
.I command2
is executed if and only if
-.I command
+.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.
@@ -658,10 +663,11 @@ the entire conditional expression.
.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
+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).
@@ -669,6 +675,19 @@ 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
@@ -701,7 +720,7 @@ is the exit status of the last command executed in
.IR list ,
or zero if no commands were executed.
.TP
-\fBcase\fP \fIword\fP \fBin\fP [ ( \fIpattern\fP [ \fB|\fP \fIpattern\fP ] \
+\fBcase\fP \fIword\fP \fBin\fP [ [(] \fIpattern\fP [ \fB|\fP \fIpattern\fP ] \
... ) \fIlist\fP ;; ] ... \fBesac\fP
A \fBcase\fP command first expands \fIword\fP, and tries to match
it against each \fIpattern\fP in turn, using the same matching rules
@@ -784,8 +803,14 @@ parameter expansion.
Each of the \fImetacharacters\fP listed above under
.SM
.B DEFINITIONS
-has special meaning to the shell and must be quoted if they are to
-represent themselves. There are three quoting mechanisms: the
+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, 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
@@ -866,6 +891,9 @@ vertical tab
.TP
.B \e\e
backslash
+.TP
+.B \e'
+single quote
.TP
.B \e\fInnn\fP
the character whose ASCII code is the octal value \fInnn\fP
@@ -877,7 +905,7 @@ the character whose ASCII code is the hexadecimal value \fInnn\fP
.PD
.RE
.LP
-The translated result is single-quoted, as if the dollar sign had
+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) will cause
@@ -920,8 +948,8 @@ If
.I value
is not given, the variable is assigned the null string. All
.I values
-undergo tilde expansion, parameter and variable expansion, string
-expansion, command substitution, arithmetic expansion, and quote
+undergo tilde expansion, parameter and variable expansion,
+command substitution, arithmetic expansion, and quote
removal (see
.SM
.B EXPANSION
@@ -1087,7 +1115,16 @@ shell startup. This variable is readonly.
.TP
.B GROUPS
An array variable containing the list of groups of which the current
-user is a member. This variable is readonly.
+user is a member.
+Assignments to
+.SM
+.B GROUPS
+have no effect and are silently discarded.
+If
+.SM
+.B GROUPS
+is unset, it loses its special properties, even if it is
+subsequently reset.
.TP
.B BASH
Expands to the full file name used to invoke this instance of
@@ -1180,6 +1217,19 @@ If
is unset, it loses its special properties, even if it is
subsequently reset.
.TP
+.B FUNCNAME
+The name of any currently-executing shell function.
+This variable exists only when a shell function is executing.
+Assignments to
+.SM
+.B FUNCNAME
+have no effect and are silently discarded.
+If
+.SM
+.B FUNCNAME
+is unset, it loses its special properties, even if it is
+subsequently reset.
+.TP
.B DIRSTACK
An array variable (see
.B Arrays
@@ -1267,6 +1317,37 @@ If this variable is in the environment when
starts up, each shell option in the list will be enabled before
reading any startup files.
This variable is read-only.
+.TP
+.B COMP_WORDS
+An array variable (see \fBArrays\fP below) consisting of the individual
+words in the current command line.
+This variable is available only in shell functions invoked by the
+programmable completion facilities (see \fBProgrammable Completion\fP
+below).
+.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_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).
.PD
.PP
The following variables are used by the shell. In some cases,
@@ -1351,11 +1432,11 @@ the current mailfile.
Example:
.RS
.PP
-\fBMAILPATH\fP='/usr/spool/mail/bfox?"You have mail":~/shell\-mail?"$_ has mail!"'
+\fBMAILPATH\fP='/var/mail/bfox?"You have mail":~/shell\-mail?"$_ has mail!"'
.PP
.B Bash
supplies a default value for this variable, but the location of the user
-mail files that it uses is system dependent (e.g., /usr/spool/mail/\fB$USER\fP).
+mail files that it uses is system dependent (e.g., /var/mail/\fB$USER\fP).
.RE
.TP
.B PS1
@@ -1494,6 +1575,9 @@ matching.
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 PROMPT_COMMAND
If set, the value is executed as a command prior to issuing each primary
prompt.
@@ -1564,8 +1648,8 @@ If set to a value of
.IR ignorespace ,
lines which begin with a
.B space
-character are not entered on the history list. If set to
-a value of
+character are not entered on the history list.
+If set to a value of
.IR ignoredups ,
lines matching the last history line are not entered.
A value of
@@ -1585,14 +1669,14 @@ not tested, and are added to the history regardless of the value of
.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 fully specify the line (no implicit
+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
.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.
+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
.BR HISTIGNORE .
@@ -1602,12 +1686,10 @@ The two or three characters which control history expansion
and tokenization (see
.SM
.B HISTORY EXPANSION
-below). The first character is the
-.IR "history expansion character" ,
+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
-.IR "quick substitution"
+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'.
@@ -1622,10 +1704,23 @@ parser to treat the rest of the line as a comment.
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 file may be changed interactively; the next
-time hostname completion is attempted
+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 already existing database.
+adds the contents of the new file to the existing list.
+If
+.SM
+.B HOSTFILE
+is set, but has no value, \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 auto_resume
This variable controls how the shell interacts with the user and
@@ -1655,6 +1750,11 @@ be a prefix of a stopped job's name; this provides functionality
analogous to the
.B %
job identifier.
+.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).
.PD
.SS Arrays
.B Bash
@@ -1720,7 +1820,7 @@ referencing element zero.
.PP
The
.B unset
-builtin is used to destroy arrays. \fBunset\fP \fBname\fP[\fIsubscript\fP]
+builtin is used to destroy arrays. \fBunset\fP \fIname\fP[\fIsubscript\fP]
destroys the array element at index \fIsubscript\fP.
\fBunset\fP \fIname\fP, where \fIname\fP is an array, or
\fBunset\fP \fIname\fP[\fIsubscript\fP], where
@@ -1805,6 +1905,8 @@ and closing braces, and at least one unquoted comma.
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
@@ -1934,9 +2036,11 @@ If the first character of \fIparameter\fP is an exclamation point,
a level of variable indirection is introduced.
\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 used in the rest of the substitution, rather
+expanded and that value is used in the rest of the substitution, rather
than the value of \fIparameter\fP itself.
This is known as \fIindirect expansion\fP.
+The exception to this is the expansion of ${!\fIprefix\fP*}
+described below.
.PP
In each of the cases below, \fIword\fP is subject to tilde expansion,
parameter expansion, command substitution, and arithmetic expansion.
@@ -1993,10 +2097,10 @@ ${\fIparameter\fP\fB:\fP\fIoffset\fP}
${\fIparameter\fP\fB:\fP\fIoffset\fP\fB:\fP\fIlength\fP}
.PD
\fBSubstring Expansion.\fP
-Expands to up to \fIlength\fP characters of \fIparameter\fP,
-starting at the characters specified by \fIoffset\fP.
+Expands to up to \fIlength\fP characters of \fIparameter\fP
+starting at the character specified by \fIoffset\fP.
If \fIlength\fP is omitted, expands to the substring of
-\fIparameter\fP, starting at the character specified by \fIoffset\fP.
+\fIparameter\fP starting at the character specified by \fIoffset\fP.
\fIlength\fP and \fIoffset\fP are arithmetic expressions (see
.SM
.B
@@ -2013,6 +2117,13 @@ members of the array beginning with ${\fIparameter\fP[\fIoffset\fP]}.
Substring indexing is zero-based unless the positional parameters
are used, in which case the indexing starts at 1.
.TP
+${\fB!\fP\fIprefix\fP\fB*\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.
+.TP
${\fB#\fP\fIparameter\fP}
The length in characters of the value of \fIparameter\fP is substituted.
If
@@ -2206,7 +2317,7 @@ 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.
.PP
-When available, \fIprocess substitution\fP is performed
+When available, process substitution is performed
simultaneously with parameter and variable expansion,
command substitution,
and arithmetic expansion.
@@ -2272,8 +2383,7 @@ is null, no word splitting occurs.
.PP
Explicit null arguments (\^\f3"\^"\fP or \^\f3'\^'\fP\^) are retained.
Unquoted implicit null arguments, resulting from the expansion of
-.I parameters
-that have no values, are removed.
+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.
.PP
@@ -2289,7 +2399,6 @@ option has been set,
scans each word for the characters
.BR * ,
.BR ? ,
-.BR ( ,
and
.BR [ .
If one of these characters appears, then the word is
@@ -2453,7 +2562,7 @@ the syntax \fB[.\fP\fIsymbol\fP\fB.]\fP matches the collating symbol
.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
+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:
@@ -2511,7 +2620,7 @@ the redirection refers to the standard output (file descriptor
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, and pathname expansion.
+expansion, quote removal, pathname expansion, and word splitting.
If it expands to more than one word,
.B bash
reports an error.
@@ -2537,6 +2646,36 @@ because the standard error was duplicated as 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:
+.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, \fBbash\fP attempts to open a TCP connection
+to the corresponding 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, \fBbash\fP attempts to open a UDP connection
+to the corresponding socket.
+.PD
+.RE
+.PP
A failure to open or create a file causes the redirection to fail.
.SS Redirecting Input
.PP
@@ -2578,7 +2717,7 @@ and the
.B noclobber
option to the
.B set
-builtin has been enabled, the redirection will fail if the filename
+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
@@ -2657,8 +2796,8 @@ The format of here-documents is as follows:
.fi
.RE
.PP
-No parameter expansion, command substitution, pathname
-expansion, or arithmetic expansion is performed on
+No parameter expansion, command substitution, arithmetic expansion,
+or pathname expansion is performed on
.IR word .
If any characters in
.I word
@@ -2670,7 +2809,7 @@ 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. In the latter
-case, the pair
+case, the character sequence
.B \e<newline>
is ignored, and
.B \e
@@ -2746,11 +2885,9 @@ or on file descriptor 0 if
.I n
is not specified. If the file does not exist, it is created.
.SH ALIASES
-Aliases allow a string to be substituted for a word when it is used
+\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
-.I aliases
-that may be set and unset with the
+The shell maintains a list of aliases that may be set and unset with the
.B alias
and
.B unalias
@@ -2786,7 +2923,10 @@ command, and removed with the
command.
.PP
There is no mechanism for using arguments in the replacement text.
-If arguments are needed, a shell function should be used.
+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
@@ -2828,15 +2968,24 @@ 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
+during its execution.
+The special parameter
.B #
is updated to reflect the change. Positional parameter 0
-is unchanged. All other aspects of the shell execution
+is unchanged.
+The
+.SM
+.B FUNCNAME
+variable is set to the name of the function while the function
+is executing.
+All other aspects of the shell execution
environment are identical between a function and its caller
with the exception that the
.SM
@@ -2891,12 +3040,20 @@ certain circumstances (see the \fBlet\fP builtin command and
\fBArithmetic Expansion\fP).
Evaluation is done in long integers with no check for overflow,
though division by 0 is trapped and flagged as an error.
+The operators and their precedence and associativity 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
@@ -2941,12 +3098,18 @@ conditional evaluation
.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.
-The value of a parameter is coerced to a long integer within
-an expression. A shell variable need not have its integer attribute
+performed before the expression is evaluated.
+Within an expression, shell variables may also be referenced by name
+without using the parameter expansion syntax.
+The value of a variable is evaluated as an arithmetic expression
+when it is referenced.
+A shell variable need not have its integer attribute
turned on to be used in an expression.
.PP
Constants with a leading 0 are interpreted as octal numbers.
@@ -2954,7 +3117,7 @@ A leading 0x or 0X denotes hexadecimal.
Otherwise, numbers take the form [\fIbase#\fP]n, where \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.
+If \fIbase#\fP is omitted, then base 10 is used.
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
@@ -2970,7 +3133,10 @@ 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.
If any \fIfile\fP argument to one of the primaries is of the form
-/dev/fd/\fIn\fP, then file descriptor \fIn\fP is checked.
+\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.
.sp 1
.PD 0
.TP
@@ -3162,7 +3328,7 @@ searches each element of the
.B PATH
for a directory containing an executable file by that name.
.B Bash
-uses a hash table to remember the full file names of executable
+uses a hash table to remember the full pathnames of executable
files (see
.B hash
under
@@ -3276,8 +3442,8 @@ This is a list of
\fIname\fP\-\fIvalue\fP pairs, of the form
.IR "name\fR=\fPvalue" .
.PP
-The shell allows you to manipulate the environment in several
-ways. On invocation, the shell scans its own environment and
+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
@@ -3328,8 +3494,8 @@ command in its environment.
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, \fBbash\fP uses
-the value of 128+\fBsignal\fP as the exit status.
+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
@@ -3467,7 +3633,7 @@ uses the
abstraction as the basis for job control.
.PP
To facilitate the implementation of the user interface to job
-control, the system maintains the notion of a \fIcurrent terminal
+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
@@ -3491,13 +3657,13 @@ If the operating system on which
is running supports
job control,
.B bash
-allows you to use it.
+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 you to
+causes that process to be stopped and returns control to
.BR bash .
Typing the
.I "delayed suspend"
@@ -3622,6 +3788,12 @@ the hostname up to the first `.'
.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
@@ -3693,8 +3865,8 @@ list, which may include commands restored from the history file
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,
-string expansion, and quote removal, subject to the value of the
+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
@@ -3806,6 +3978,7 @@ The following symbolic character names are recognized:
.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"
@@ -3980,8 +4153,7 @@ If set to \fBnone\fP, readline never rings the bell. If set to
If set to \fBaudible\fP, readline attempts to ring the terminal's bell.
.TP
.B comment\-begin (``#'')
-The string that is inserted when the
-.B readline
+The string that is inserted when the readline
.B insert\-comment
command is executed.
This command is bound to
@@ -4007,7 +4179,7 @@ on the terminal.
.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 prepending an
+by stripping the eighth bit and prefixing an
escape character (in effect, using escape as the \fImeta prefix\fP).
.TP
.B disable\-completion (Off)
@@ -4178,7 +4350,7 @@ 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 \fIisearch-terminators\fP
+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.
@@ -4186,6 +4358,7 @@ 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
@@ -4203,6 +4376,10 @@ typed by the user or be part of the contents of the current line.
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
@@ -4224,7 +4401,7 @@ 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 this, or the previous, word. Words are
+Move back to the start of the current or previous word. Words are
composed of alphanumeric characters (letters and digits).
.TP
.B clear\-screen (C\-l)
@@ -4280,8 +4457,7 @@ 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 current cursor
-position (the \fIpoint\fP).
+between the start of the current line and the point.
This is a non-incremental search.
.TP
.B history\-search\-backward
@@ -4379,12 +4555,14 @@ Insert the character typed.
.TP
.B transpose\-chars (C\-t)
Drag the character before point forward over the character at point.
-Point moves forward as well. If point is at the end of the line, then
-transpose the two characters before point. Negative arguments don't work.
+Point moves forward as well.
+If point is at the end of the line, then transpose the two characters
+before point.
+Negative arguments have no effect.
.TP
.B transpose\-words (M\-t)
-Drag the word behind the cursor past the word in front of the cursor
-moving the cursor over that word as well.
+Drag the word before point past the word after point,
+moving the point over that word as well.
.TP
.B upcase\-word (M\-u)
Uppercase the current (or following) word. With a negative argument,
@@ -4403,7 +4581,7 @@ capitalize the previous word, but do not move point.
.PD 0
.TP
.B kill\-line (C\-k)
-Kill the text from the current cursor position to the end of the line.
+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.
@@ -4411,31 +4589,30 @@ Kill backward to the beginning of the line.
.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
+.\" 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 the
-cursor is.
+Kill all characters on the current line, no matter where point is.
.TP
.B kill\-word (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 \fBforward\-word\fP.
+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 the cursor. Word boundaries are the same as
-those used by \fBbackward\-word\fP.
+Kill the word behind point.
+Word boundaries are the same as those used by \fBbackward\-word\fP.
.TP
.B unix\-word\-rubout (C\-w)
-Kill the word behind the cursor, using white space as a word boundary.
+Kill the word behind point, using white space as a word boundary.
The word boundaries are different from \fBbackward\-kill\-word\fP.
+The killed text is saved on the kill-ring.
.TP
.B delete\-horizontal\-space (M\-\e)
Delete all spaces and tabs around point.
.TP
.B kill\-region
-Kill the text between the point and \fImark\fP (saved cursor position).
-This text is referred to as the \fIregion\fP.
+Kill the text in the current region.
.TP
.B copy\-region\-as\-kill
Copy the text in the region to the kill buffer.
@@ -4515,9 +4692,9 @@ 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).
+end of the line (like \fBdelete\-char\fP).
If at the end of the line, behaves identically to
-\fBpossible-completions\fP.
+\fBpossible\-completions\fP.
This command is unbound by default.
.TP
.B complete\-filename (M\-/)
@@ -4568,7 +4745,7 @@ the text against lines from the history list for possible
completion matches.
.TP
.B complete\-into\-braces (M\-{)
-Perform filename completion and return the list of possible completions
+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).
@@ -4641,11 +4818,11 @@ A character is read and point is moved to the previous occurrence of that
character. A negative count searches for subsequent occurrences.
.TP
.B insert\-comment (M\-#)
-The value of the
-.B readline
+The value of the readline
.B comment\-begin
variable is inserted at the beginning of the current line, and the line
-is accepted as if a newline had been typed. This makes the current 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.
.TP
.B glob\-expand\-word (C\-x *)
@@ -4679,6 +4856,129 @@ of an \fIinputrc\fP file.
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 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.
+.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 filename 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, arithmetic expansion, and pathname 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
+.B COMP_LINE
+and
+.SM
+.B COMP_POINT
+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 is the
+name of the command whose arguments are being completed, the
+second argument is the word being completed, and the third argument
+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.
+.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.
+.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 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.
.SH HISTORY
When the
.B \-o history
@@ -4686,10 +4986,13 @@ option to the
.B set
builtin is enabled, the shell provides access to the
\fIcommand history\fP,
-the list of commands previously typed. The text of the last
+the list of commands previously typed.
+The value of the \fBHISTSIZE\fP 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 in a history list. The shell
+commands (default 500) is saved. The shell
stores each command in the history list prior to parameter and
variable expansion (see
.SM
@@ -4701,23 +5004,25 @@ values of the shell variables
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
-.B HISTFILESIZE
-lines.
+.BR HISTFILESIZE .
When an interactive shell exits, the last
.SM
-.B HISTSIZE
+.B $HISTSIZE
lines are copied from the history list to
.SM
-.BR HISTFILE .
+.BR $HISTFILE .
If the
.B histappend
shell option is enabled
@@ -4750,9 +5055,9 @@ below) may be used to list or edit and re-execute a portion of
the history list.
The
.B history
-builtin can be used to display or modify the history list and
+builtin may be used to display or modify the history list and
manipulate the history file.
-When using the command-line editing, search commands
+When using command-line editing, search commands
are available in each editing mode that provide access to the
history list.
.PP
@@ -5125,6 +5430,8 @@ job control.
.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
.PD
Display current
@@ -5188,6 +5495,10 @@ 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.
.PD
.PP
The return value is 0 unless an unrecognized option is given or an
@@ -5308,6 +5619,176 @@ cannot be found, the exit status is 127. Otherwise, the exit status of the
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
+.PD 0
+\fBcomplete\fP [\fB\-abcdefjkvu\fP] [\fB\-A\fP \fIaction\fP] [\fB\-G\fP \fIglobpat\fP] [\fB\-W\fP \fIwordlist\fP] [\fB\-P\fP \fIprefix\fP] [\fB\-S\fP \fIsuffix\fP]
+.br
+[\fB\-X\fP \fIfilterpat\fP] [\fB\-F\fP \fIfunction\fP] [\fB\-C\fP \fIcommand\fP] \fIname\fP [\fIname ...\fP]
+.TP
+\fBcomplete\fP \fB\-pr\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.
+.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\-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 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 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\-G\fP \fIglobpat\fP
+The filename expansion pattern \fIglobpat\fP is expanded to generate
+the possible completions.
+.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\-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 it finishes, the possible completions are retrieved from the value
+of the
+.SM
+.B COMPREPLY
+array variable.
+.TP 8
+\fB\-X\fP \fIfilterpat\fP
+\fIfilterpat\fP 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
+\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.
+.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.
+.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
\fBcontinue\fP [\fIn\fP]
Resume the next iteration of the enclosing
.BR for ,
@@ -5385,7 +5866,9 @@ makes each
\fIname\fP local, as with the
.B local
command. 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 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
@@ -5393,7 +5876,7 @@ using the compound assignment syntax (see
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 \-f.
+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]
@@ -5481,6 +5964,9 @@ the following backslash-escaped characters is enabled. The
.B \-E
option disables the interpretation of these escape characters,
even on systems where they are interpreted by default.
+The \fBxpg_echo\fP shell option to the may be used to
+dynamically determine whether or not \fBecho\fP expands these
+escape characters by default.
.B echo
does not interpret
.B \-\-
@@ -5533,7 +6019,7 @@ the character whose ASCII code is the hexadecimal value \fInnn\fP
\fBenable\fP [\fB\-adnps\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 with specifying a full pathname,
+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,
@@ -5566,7 +6052,7 @@ 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 a problem loading a new builtin
+is not a shell builtin or there is an error loading a new builtin
from a shared object.
.TP
\fBeval\fP [\fIarg\fP ...]
@@ -5590,7 +6076,7 @@ become the arguments to \fIcommand\fP.
If the
.B \-l
option is supplied,
-the shell places a dash in the zeroth arg passed to
+the shell places a dash at the beginning of the zeroth arg passed to
.IR command .
This is what
.IR login (1)
@@ -5679,7 +6165,8 @@ command number). If
.I last
is not specified it is set to
the current command for listing (so that
-.B fc \-l \-10
+.if n ``fc \-l \-10''
+.if t \f(CWfc \-l \-10\fP
prints the last 10 commands) and to
.I first
otherwise.
@@ -5771,9 +6258,11 @@ specifies a job that was started without job control.
.B getopts
is used by shell procedures to parse positional parameters.
.I optstring
-contains the option letters to be recognized; if a letter
+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
@@ -5888,7 +6377,7 @@ The return status is true unless a
.I name
is not found or an invalid option is supplied.
.TP
-\fBhelp\fP [\fIpattern\fP]
+\fBhelp\fP [\fB\-s\fP] [\fIpattern\fP]
Display helpful information about builtin commands. If
.I pattern
is specified,
@@ -5896,11 +6385,18 @@ is specified,
gives detailed help on all commands matching
.IR pattern ;
otherwise help for all the builtins and shell control structures
-is printed. The return status is 0 unless no command matches
+is printed.
+The \fB\-s\fP option restricts the information displayed to a short
+usage synopsis.
+The return status is 0 unless no command matches
.IR pattern .
.TP
.PD 0
-\fBhistory\fP [\fB\-c\fP] [\fIn\fP]
+\fBhistory [\fIn\fP]
+.TP
+\fBhistory\fP \fB\-c\fP
+.TP
+\fBhistory \-d\fP \fIoffset\fP
.TP
\fBhistory\fP \fB\-anrw\fP [\fIfilename\fP]
.TP
@@ -5924,6 +6420,12 @@ 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 (history lines entered since the
beginning of the current \fBbash\fP session) to the history file.
@@ -5942,9 +6444,6 @@ and use them as the current history.
Write the current history to the history file, overwriting the
history file's contents.
.TP
-.B \-c
-Clear the history list by deleting all the entries.
-.TP
.B \-p
Perform history substitution on the following \fIargs\fP and display
the result on the standard output.
@@ -5960,8 +6459,10 @@ history list is removed before the
are added.
.PD
.PP
-The return value is 0 unless an invalid option is encountered or an
-error occurs while reading or writing the history file.
+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
.PD 0
@@ -6077,11 +6578,12 @@ evaluates to 0,
.B let
returns 1; 0 is returned otherwise.
.TP
-\fBlocal\fP [\fIname\fP[=\fIvalue\fP] ...]
+\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
@@ -6094,9 +6596,10 @@ an error to use
.B local
when not within a function. The return status is 0 unless
.B local
-is used outside a function, or an invalid
+is used outside a function, an invalid
.I name
-is supplied.
+is supplied, or
+\fIname\fP is a readonly variable.
.TP
.B logout
Exit a login shell.
@@ -6114,15 +6617,25 @@ Arguments, if supplied, have the following meanings:
Removes the \fIn\fPth entry counting from the left of the list
shown by
.BR dirs ,
-starting with zero. For example: ``popd +0''
-removes the first directory, ``popd +1'' the second.
+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: ``popd -0''
-removes the last directory, ``popd -1'' the next to last.
+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.
.TP
.B \-n
Suppresses the normal change of directory when removing directories
@@ -6156,7 +6669,8 @@ In addition to the standard \fIprintf\fP(1) formats, %b causes
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.
+appropriate, had been supplied. The return value is zero on success,
+non-zero on failure.
.TP
.PD 0
\fBpushd\fP [\fB\-n\fP] [\fIdir\fP]
@@ -6188,7 +6702,7 @@ starting with zero) is at the top.
Suppresses the normal change of directory when adding directories
to the stack, so that only the stack is manipulated.
.TP
-.B dir
+.I dir
Adds
.I dir
to the directory stack at the top, making it the
@@ -6213,8 +6727,8 @@ fails.
.RE
.TP
\fBpwd\fP [\fB\-LP\fP]
-Print the absolute file name of the current working directory.
-The file name printed contains no symbolic links if the
+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
@@ -6223,12 +6737,12 @@ option to the
builtin command is enabled.
If the
.B \-L
-option is used, symbolic links are followed.
+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\-er\fP] [\fB\-a\fP \fIaname\fP] [\fB\-p\fP \fIprompt\fP] [\fIname\fP ...]
+\fBread\fP [\fB\-ers\fP] [\fB\-t\fP \fItimeout\fP] [\fB\-a\fP \fIaname\fP] [\fB\-p\fP \fIprompt\fP] [\fB\-n\fP \fInchars\fP] [\fB\-d\fP \fIdelim\fP] [\fIname\fP ...]
One line is read from the standard input, and the first word
is assigned to the first
.IR name ,
@@ -6249,18 +6763,7 @@ Options, if supplied, have the following meanings:
.RS
.PD 0
.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 \-p
-Display \fIprompt\fP, without a
-trailing newline, before attempting to read any input. The prompt
-is displayed only if input is coming from a terminal.
-.TP
-.B \-a
+.B \-a \fIaname\fP
The words are assigned to sequential indices
of the array variable
.IR aname ,
@@ -6269,6 +6772,10 @@ starting at 0.
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,
@@ -6277,6 +6784,31 @@ is coming from a terminal,
.SM
.B READLINE
above) is used to obtain the line.
+.TP
+.B \-n \fInchars\fP
+\fBread\fP returns after reading \fInchars\fP characters rather than
+waiting for a complete line of input.
+.TP
+.B \-p \fIprompt\fP
+Display \fIprompt\fP, 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 is not read within \fItimeout\fP seconds.
+This option has no effect if \fBread\fP is not reading input from the
+terminal or a pipe.
.PD
.PP
If no
@@ -6284,7 +6816,8 @@ If no
are supplied, the line read is assigned to the variable
.SM
.BR REPLY .
-The return code is zero, unless end-of-file is encountered.
+The return code is zero, unless end-of-file is encountered or \fBread\fP
+times out.
.RE
.TP
\fBreadonly\fP [\fB\-apf\fP] [\fIname\fP ...]
@@ -6308,7 +6841,8 @@ arguments are given, or if the
option is supplied, a list of all readonly names is printed.
The
.B \-p
-option causes output to be displayed in a format thatmay be reused as input.
+option causes output to be displayed in a format that
+may be reused as input.
The return status is 0 unless an invalid option is encountered,
one of the
.I names
@@ -6523,12 +7057,16 @@ the standard output.
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 \fBSHELLOPTS\fP variable, if it appears in the
-environment, is ignored.
+environment, and the
+.SM
+.B SHELLOPTS
+variable, if it appears in the environment, is ignored.
If the shell is started with the effective user (group) id not equal to the
real user (group) id, and the \fB\-p\fP option is not supplied, these actions
are taken and the effective user id is set to the real user id.
@@ -6812,6 +7350,14 @@ 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 \fBPATH\fP for possible completions when
+completion is attempted on an empty line.
+.TP 8
.B nocaseglob
If set,
.B bash
@@ -6829,6 +7375,11 @@ files (see
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 variable and parameter expansion after
being expanded as described in
@@ -6858,6 +7409,10 @@ If set, the
.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
.TP
\fBsuspend\fP [\fB\-f\fP]
@@ -6989,13 +7544,12 @@ is the null string the signal specified by each
is ignored by the shell and by the commands it invokes.
If
.I arg
-is
+is not present and
.B \-p
-then the trap commands associated with
-each
+has been supplied, then the trap commands associated with each
.I sigspec
-are displayed. If no arguments are supplied or if
-only
+are displayed.
+If no arguments are supplied or if only
.B \-p
is given,
.B trap
@@ -7188,10 +7742,7 @@ to that accepted by
.IR chmod (1).
If
.I mode
-is omitted, or if the
-.B \-S
-option is supplied, the
-current value of the mask is printed.
+is omitted, the current value of the mask is printed.
The
.B \-S
option causes the mask to be printed in symbolic form; the
@@ -7205,7 +7756,7 @@ 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 \fIname\fPs from the list of defined aliases. If
+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
@@ -7240,6 +7791,10 @@ If any of
.BR LINENO ,
.SM
.BR HISTCMD ,
+.SM
+.BR FUNCNAME ,
+.SM
+.BR GROUPS ,
or
.SM
.B DIRSTACK
@@ -7265,6 +7820,8 @@ process or job waited for.
.\" bash_builtins
.if \n(zZ=1 .ig zZ
.SH "RESTRICTED SHELL"
+.\" rbash.1
+.zY
.PP
If
.B bash
@@ -7298,6 +7855,12 @@ 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 \fBSHELLOPTS\fP from the shell environment at startup
@@ -7334,10 +7897,12 @@ 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 Features\fP, Brian Fox and Chet Ramey
+\fIBash Reference Manual\fP, Brian Fox and Chet Ramey
.TP
\fIThe Gnu Readline Library\fP, Brian Fox and Chet Ramey
.TP
@@ -7375,7 +7940,7 @@ Individual \fIreadline\fP initialization file
.SH AUTHORS
Brian Fox, Free Software Foundation
.br
-bfox@gnu.ai.MIT.Edu
+bfox@gnu.org
.PP
Chet Ramey, Case Western Reserve University
.br
@@ -7451,3 +8016,4 @@ reporting until some time after the command is entered.
.PP
Array variables may not (yet) be exported.
.zZ
+.zY
diff --git a/doc/bashref.info b/doc/bashref.info
index 01450d08..3b2b6da8 100644
--- a/doc/bashref.info
+++ b/doc/bashref.info
@@ -1,4 +1,4 @@
-This is Info file bashref.info, produced by Makeinfo version 1.67 from
+This is Info file bashref.info, produced by Makeinfo version 1.68 from
the input file /usr/homes/chet/src/bash/src/doc/bashref.texi.
INFO-DIR-SECTION Utilities
@@ -9,9 +9,9 @@ END-INFO-DIR-ENTRY
This text is a brief description of the features that are present in
the Bash shell.
-This is Edition 2.3, last updated 20 January 1999,
+This is Edition 2.4, last updated 14 March 2000,
of `The GNU Bash Reference Manual',
-for `Bash', Version 2.03.
+for `Bash', Version 2.04.
Copyright (C) 1991-1999 Free Software Foundation, Inc.
@@ -38,8 +38,8 @@ Bash Features
This text is a brief description of the features that are present in
the Bash shell.
- This is Edition 2.3, last updated 20 January 1999, of `The GNU Bash
-Reference Manual', for `Bash', Version 2.03.
+ This is Edition 2.4, last updated 14 March 2000, of `The GNU Bash
+Reference Manual', for `Bash', Version 2.04.
Copyright (C) 1991, 1993, 1996 Free Software Foundation, Inc.
@@ -63,8 +63,9 @@ on shell behavior.
* Basic Shell Features:: The shell "building blocks".
-* Bourne Shell Features:: Features similar to those found in the
- Bourne shell.
+* 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.
@@ -81,6 +82,10 @@ on shell behavior.
* 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.
+
* Builtin Index:: Index of Bash builtin commands.
* Reserved Word Index:: Index of Bash reserved words.
@@ -111,23 +116,23 @@ File: bashref.info, Node: What is Bash?, Next: What is a shell?, Up: Introduc
What is Bash?
=============
- Bash 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 `/bin/sh', which appeared in the
-Seventh Edition Bell Labs Research version of Unix.
+ 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 `/bin/sh', 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'. It is intended to be
-a conformant implementation of the IEEE POSIX Shell and Tools
-specification (IEEE Working Group 1003.2). It offers functional
+ 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 specification (IEEE Working Group 1003.2). It offers functional
improvements over `sh' for both interactive and programming use.
- While the GNU operating system will include a version of `csh', Bash
-will be 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, Windows 95, and Windows NT.
+ 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, Windows 95/98, and Windows NT.

File: bashref.info, Node: What is a shell?, Prev: What is Bash?, Up: Introduction
@@ -137,35 +142,41 @@ What is a shell?
At its base, a shell is simply a macro processor that executes
commands. A Unix shell is both a command interpreter, which provides
-the user interface to the rich set of Unix utilities, and a programming
+the user interface to the rich set of GNU utilities, and a programming
language, allowing these utilitites 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 like
+commands have the same status as system commands in directories such as
`/bin', allowing users or groups to establish custom environments.
- A shell allows execution of Unix commands, both synchronously and
+ 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, and the shell allows control
-over the contents of their environment. Unix shells also provide a
-small set of built-in commands ("builtins") implementing functionality
-impossible (e.g., `cd', `break', `continue', and `exec'), or
-inconvenient (`history', `getopts', `kill', or `pwd', for example) to
-obtain via separate utilities. Shells may be used interactively or
-non-interactively: they accept input typed from the keyboard or from a
-file. All of the shell builtins are described in subsequent sections.
+the input and output of those commands. Moreover, the shell allows
+control over the contents of commands' environments. Shells may be
+used interactively or non-interactively: they accept input typed from
+the keyboard or from a file.
+
+ Shells also provide a small set of built-in commands ("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 have begun offering features geared specifically for
-interactive use rather than to augment the programming language. These
-interactive features include job control, command line editing, history
-and aliases. Each of these features is described in this manual.
+ Shells offer features geared specifically for interactive use rather
+than to augment the programming language. These interactive features
+include job control, command line editing, history and aliases. Each
+of these features is described in this manual.

File: bashref.info, Node: Definitions, Next: Basic Shell Features, Prev: Introduction, Up: Top
@@ -241,12 +252,12 @@ Definitions
A synonym for `exit status'.
`signal'
- A mechanism by which a process may be notified by the kernal of an
+ 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.2 standard.
+ POSIX 1003.2 standard.
`token'
A sequence of characters considered a single unit by the shell.
@@ -256,7 +267,7 @@ Definitions
A `token' that is not an `operator'.

-File: bashref.info, Node: Basic Shell Features, Next: Bourne Shell Features, Prev: Definitions, Up: Top
+File: bashref.info, Node: Basic Shell Features, Next: Shell Builtin Commands, Prev: Definitions, Up: Top
Basic Shell Features
********************
@@ -298,6 +309,20 @@ Shell Syntax
* 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: bashref.info, Node: Shell Operation, Next: Quoting, Up: Shell Syntax
@@ -321,7 +346,7 @@ reads and executes a command. Basically, the shell does the following:
4. Performs the various shell expansions (*note Shell Expansions::.),
breaking the expanded tokens into lists of filenames (*note
- Filename Expansion::.) and commands and arguments.
+ Filename Expansion::.) and commands and arguments.
5. Performs any necessary redirections (*note Redirections::.) and
removes the redirection operators and their operands from the
@@ -356,10 +381,13 @@ 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
+ Each of the shell metacharacters (*note Definitions::.) has special
meaning to the shell and must be quoted if it is to represent itself.
-There are three quoting mechanisms: the ESCAPE CHARACTER, single
-quotes, and double quotes.
+When the command history expansion facilities are being used, 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: bashref.info, Node: Escape Character, Next: Single Quotes, Up: Quoting
@@ -380,9 +408,9 @@ File: bashref.info, Node: Single Quotes, Next: Double Quotes, Prev: Escape Ch
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.
+ 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: bashref.info, Node: Double Quotes, Next: ANSI-C Quoting, Prev: Single Quotes, Up: Quoting
@@ -390,16 +418,16 @@ File: bashref.info, Node: Double Quotes, Next: ANSI-C Quoting, Prev: Single Q
Double Quotes
.............
- Enclosing characters in double quotes preserves the literal value of
-all characters within the quotes, with the exception of `$', ``', and
-`\'. 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.
+ Enclosing characters in double quotes (`"') preserves the literal
+value of all characters within the quotes, with the exception of `$',
+``', and `\'. 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.
The special parameters `*' and `@' have special meaning when in
double quotes (*note Shell Parameter Expansion::.).
@@ -442,6 +470,9 @@ present, are decoded as follows:
`\\'
backslash
+`\''
+ single quote
+
`\NNN'
the character whose `ASCII' code is the octal value NNN (one to
three digits)
@@ -450,7 +481,8 @@ present, are decoded as follows:
the character whose `ASCII' code is the hexadecimal value NNN (one
to three digits)
-The result is single-quoted, as if the dollar sign had not been present.
+The expanded result is single-quoted, as if the dollar sign had not
+been present.

File: bashref.info, Node: Locale Translation, Prev: ANSI-C Quoting, Up: Quoting
@@ -475,8 +507,8 @@ Bash Builtins::.), 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 Is This Shell Interactive?::, for a
-description of what makes a shell interactive.
+interactive shells. *Note Interactive Shells::, for a description of
+what makes a shell interactive.

File: bashref.info, Node: Shell Commands, Next: Shell Functions, Prev: Shell Syntax, Up: Basic Shell Features
@@ -484,6 +516,14 @@ File: bashref.info, Node: Shell Commands, Next: Shell Functions, Prev: Shell
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.
@@ -503,11 +543,12 @@ 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.
+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.1 `waitpid' function, or 128+N if
-the command was terminated by signal N.
+exit status as provided by the POSIX 1003.1 `waitpid' function, or
+128+N if the command was terminated by signal N.

File: bashref.info, Node: Pipelines, Next: Lists, Prev: Simple Commands, Up: Shell Commands
@@ -560,9 +601,10 @@ followed by `;' and `&', which have equal precedence.
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). The standard
-input for asynchronous commands, in the absence of any explicit
-redirections, is redirected from `/dev/null'.
+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
@@ -570,15 +612,15 @@ exit status of the last command executed.
The control operators `&&' and `||' denote AND lists and OR lists,
respectively. An AND list has the form
- COMMAND && COMMAND2
+ COMMAND1 && COMMAND2
-COMMAND2 is executed if, and only if, COMMAND returns an exit status of
-zero.
+COMMAND2 is executed if, and only if, COMMAND1 returns an exit status
+of zero.
An OR list has the form
- COMMAND || COMMAND2
+ COMMAND1 || COMMAND2
-COMMAND2 is executed if, and only if, COMMAND returns a non-zero exit
+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
@@ -592,7 +634,7 @@ Looping Constructs
Bash supports the following looping constructs.
- Note that wherever you see a `;' in the description of a command's
+ Note that wherever a `;' appears in the description of a command's
syntax, it may be replaced with one or more newlines.
`until'
@@ -618,10 +660,25 @@ syntax, it may be replaced with one or more newlines.
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, `in "$@"' is assumed. 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.
+ 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 LIST 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.
@@ -767,8 +824,8 @@ Conditional Constructs
`EXPRESSION1 || EXPRESSION2'
True if either EXPRESSION1 or EXPRESSION2 is true.
- The && and || commands do not execute EXPRESSION2 if the value of
- EXPRESSION1 is sufficient to determine the return value of the
+ The `&&' and `||' commands do not execute EXPRESSION2 if the value
+ of EXPRESSION1 is sufficient to determine the return value of the
entire conditional expression.

@@ -815,7 +872,9 @@ 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. Shell functions are executed in the current shell
+"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:
@@ -828,11 +887,18 @@ COMMAND-LIST between { and }. This list is executed whenever NAME is
specified as the name of a command. The exit status of a function is
the exit status of the last command executed in the body.
+ Note that for historical reasons, the curly braces that surround the
+body of the function must be separated from the body by `blank's or
+newlines. This is because the braces are reserved words and are only
+recognized as such when they are separated by whitespace. Also, the
+COMMAND-LIST must be terminated with a semicolon 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. Positional
-parameter `0' is unchanged.
+parameter `0' is unchanged. The `FUNCNAME' variable is set to the name
+of the function while the function is executing.
If the builtin command `return' is executed in a function, the
function completes and execution resumes with the next command after
@@ -892,8 +958,10 @@ Positional Parameters
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}'. Positional parameters may not be assigned to
-with assignment statements. The positional parameters are temporarily
+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
@@ -933,9 +1001,9 @@ only be referenced; assignment to them is not allowed.
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).
+ (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
@@ -955,12 +1023,13 @@ only be referenced; assignment to them is not allowed.
used to invoke Bash, as given by argument zero.
`_'
- At shell startup, set to the absolute filename of the shell or
- shell script being executed as passed in the argument list.
- Subsequently, expands to the last argument to the previous command,
- after expansion. Also set to the full pathname of each command
- executed and placed in the environment exported to that command.
- When checking mail, this parameter holds the name of the mail file.
+ (An underscore.) At shell startup, set to the absolute filename
+ of the shell or shell script being executed as passed in the
+ argument list. Subsequently, expands to the last argument to the
+ previous command, after expansion. Also set to the full pathname
+ of each command executed and placed in the environment exported to
+ that command. When checking mail, this parameter holds the name
+ of the mail file.

File: bashref.info, Node: Shell Expansions, Next: Redirections, Prev: Shell Parameters, Up: Basic Shell Features
@@ -1014,7 +1083,7 @@ 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
+ After all expansions, `quote removal' (*note Quote Removal::.) is
performed.

@@ -1028,7 +1097,7 @@ generated. This mechanism is similar to FILENAME EXPANSION (*note
Filename Expansion::.), but the file names generated need not exist.
Patterns to be brace expanded take the form of an optional PREAMBLE,
followed by a series of comma-separated strings between a pair of
-braces, followed by an optional POSTSCRIPT. The preamble is prepended
+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.
@@ -1040,7 +1109,9 @@ are not sorted; left to right order is preserved. For example,
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 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. Any incorrectly
@@ -1144,13 +1215,17 @@ of variable indirection is introduced. Bash uses the value of the
variable formed from the rest of PARAMETER as the name of the variable;
this variable is then expanded and that value is used in the rest of
the substitution, rather than the value of PARAMETER itself. This is
-known as `indirect expansion'.
+known as `indirect expansion'. The exception to this is the expansion
+of ${!PREFIX*} described below.
In each of the cases below, WORD is subject to tilde expansion,
parameter expansion, command substitution, and arithmetic expansion.
-When not performing substring expansion, Bash tests for a parameter
+
+ When not performing substring expansion, Bash tests for a parameter
that is unset or null; omitting the colon results in a test only for a
-parameter that is unset.
+parameter that is unset. Put another way, if the colon is included,
+the operator tests for both existence and that the value is not null;
+if the colon is omitted, the operator tests only for existence.
`${PARAMETER:-WORD}'
If PARAMETER is unset or null, the expansion of WORD is
@@ -1174,9 +1249,9 @@ parameter that is unset.
`${PARAMETER:OFFSET}'
`${PARAMETER:OFFSET:LENGTH}'
- Expands to up to LENGTH characters of PARAMETER, starting at the
+ Expands to up to LENGTH characters of PARAMETER starting at the
character specified by OFFSET. If LENGTH is omitted, expands to
- the substring of PARAMETER, starting at the character specified by
+ the substring of PARAMETER starting at the character specified by
OFFSET. LENGTH and OFFSET are arithmetic expressions (*note Shell
Arithmetic::.). This is referred to as Substring Expansion.
@@ -1190,6 +1265,10 @@ parameter that is unset.
the positional parameters are used, in which case the indexing
starts at 1.
+`${!PREFIX*}'
+ Expands to the names of variables whose names begin with PREFIX,
+ separated by the first character of the `IFS' special variable.
+
`${#PARAMETER}'
The length in characters of the expanded value of PARAMETER is
substituted. If PARAMETER is `*' or `@', the value substituted is
@@ -1250,7 +1329,8 @@ Command Substitution
--------------------
Command substitution allows the output of a command to replace the
-command name. There are two forms:
+command itself. Command substitution occurs when a command is enclosed
+as follows:
$(COMMAND)
or
@@ -1316,7 +1396,9 @@ some file in `/dev/fd'. The name of this file 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.
+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.
When available, process substitution is performed simultaneously with
parameter and variable expansion, command substitution, and arithmetic
@@ -1346,7 +1428,7 @@ characters is also treated as a delimiter. If the value of `IFS' is
null, no word splitting occurs.
Explicit null arguments (`""' or `''') are retained. Unquoted
-implicit null arguments, resulting from the expansion of PARAMETERs
+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.
@@ -1363,17 +1445,17 @@ Filename Expansion
* 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 file
+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 file
names matching the pattern. If no matching file names 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 shell option `nocaseglob' is enabled, the match is
performed without regard to the case of alphabetic characters.
- When a pattern is used for filename generation, the character `.' at
-the start of a filename or immediately following a slash must be
+ When a pattern is used for filename generation, 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 file name, the slash character must always be matched
explicitly. In other cases, the `.' character is not treated specially.
@@ -1384,7 +1466,7 @@ description of the `nocaseglob', `nullglob', 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. The filenames `.' and `..' are
+removed from the list of matches. The filenames `.' and `..' are
always ignored, even when `GLOBIGNORE' is set. However, setting
`GLOBIGNORE' has the effect of enabling the `dotglob' shell option, so
all other filenames beginning with a `.' will match. To get the old
@@ -1421,7 +1503,7 @@ quoted if they are to be matched literally.
Within `[' and `]', CHARACTER CLASSES can be specified using the
syntax `[:'CLASS`:]', where CLASS is one of the following classes
- defined in the POSIX.2 standard:
+ defined in the POSIX 1003.2 standard:
alnum alpha ascii blank cntrl digit graph lower
print punct space upper xdigit
@@ -1432,7 +1514,7 @@ quoted if they are to be matched literally.
collation weight (as defined by the current locale) as the
character C.
- Within `[' and `]', the syntax `[.'SYMBOL`.]' matches the
+ Within `[' and `]', the syntax `[.'SYMBOL`.]' matches the
collating symbol SYMBOL.
If the `extglob' shell option is enabled using the `shopt' builtin,
@@ -1488,21 +1570,46 @@ 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, and filename expansion. If it expands to
-more than one word, Bash reports an error.
+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 and standard error to the file DIRLIST,
-while the command
+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 duplicated as 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:
+
+`/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, Bash attempts to open a TCP connection to the
+ corresponding socket.
+
+`/dev/udp/HOST/PORT'
+ If HOST is a valid hostname or Internet address, and PORT is an
+ integer port number, Bash attempts to open a UDP connection to the
+ corresponding socket.
+
A failure to open or create a file causes the redirection to fail.
Redirecting Input
@@ -1529,7 +1636,7 @@ to zero size.
If the redirection operator is `>', and the `noclobber' option to
the `set' builtin has been enabled, the redirection will fail if the
-filename whose name results from the expansion of WORD exists and is a
+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.
@@ -1576,14 +1683,14 @@ as the standard input for a command.
HERE-DOCUMENT
DELIMITER
- No parameter expansion, command substitution, filename expansion, or
-arithmetic expansion is performed on WORD. If any characters in WORD
+ No parameter expansion, command substitution, arithmetic expansion,
+or filename expansion is performed on WORD. If any characters in WORD
are 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. In the latter case,
-the pair `\newline' is ignored, and `\' must be used to quote the
-characters `\', `$', and ``'.
+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
@@ -1703,7 +1810,7 @@ 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 above in *Note Shell Functions::.
+ 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
@@ -1809,7 +1916,7 @@ Environment
ENVIRONMENT. This is a list of name-value pairs, of the form
`name=value'.
- Bash allows you to manipulate the environment in several ways. On
+ 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'
@@ -1936,39 +2043,62 @@ 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 kernel'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. 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.
+ 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: bashref.info, Node: Bourne Shell Features, Next: Bash Features, Prev: Basic Shell Features, Up: Top
+File: bashref.info, Node: Shell Builtin Commands, Next: Shell Variables, Prev: Basic Shell Features, Up: Top
-Bourne Shell Style Features
-***************************
+Shell Builtin Commands
+**********************
* Menu:
* Bourne Shell Builtins:: Builtin commands inherited from the Bourne
Shell.
-* Bourne Shell Variables:: Variables which Bash uses in the same way
- as the Bourne Shell.
-* Other Bourne Shell Features:: Addtional aspects of Bash which behave in
- the same way as the Bourne Shell.
+* Bash Builtins:: Table of builtins specific to Bash.
+* The Set Builtin:: This builtin is so overloaded it
+ deserves its own section.
+* Special Builtins:: Builtin commands classified specially by
+ POSIX.2.
- This section briefly summarizes things which Bash inherits from the
-Bourne Shell: builtins, variables, and other features. It also lists
-the significant differences between Bash and the Bourne Shell. Many of
-the builtins have been extended by POSIX or Bash.
+ 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 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.

-File: bashref.info, Node: Bourne Shell Builtins, Next: Bourne Shell Variables, Up: Bourne Shell Features
+File: bashref.info, Node: Bourne Shell Builtins, Next: Bash Builtins, Up: Shell Builtin Commands
Bourne Shell Builtins
=====================
@@ -1977,22 +2107,23 @@ Bourne Shell Builtins
Shell. These commands are implemented as specified by the POSIX 1003.2
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. The current directory
+ `PATH' variable is used to find FILENAME. 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.
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.
+ cannot be read, the return status is non-zero. This builtin is
+ equivalent to `source'.
`break'
break [N]
@@ -2031,17 +2162,18 @@ standard.
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 in the zeroth arg 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 no
+ dash at the beginning of the zeroth arg 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 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.
+ 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'
@@ -2060,18 +2192,19 @@ standard.
`getopts'
getopts OPTSTRING NAME [ARGS]
`getopts' is used by shell scripts to parse positional parameters.
- 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' 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.
+ 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 (`?') 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
@@ -2112,12 +2245,12 @@ standard.
`pwd'
pwd [-LP]
- Print the current working directory. If the `-P' option is
- supplied, the path printed will not contain symbolic links. If
- the `-L' option is supplied, the path 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.
+ 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 [-apf] [NAME] ...
@@ -2134,12 +2267,15 @@ standard.
`return'
return [N]
- Cause a shell function to exit with the return value N. This may
- also be used to terminate execution of a script being executed
- with the `.' builtin, returning either N or the exit status of the
+ Cause a shell function to exit with the return value N. If N is
+ not supplied, the return value is the exit status of the last
+ command executed in the function. This may also be used to
+ terminate execution of a script being executed with the `.' (or
+ `source') builtin, returning either N or the exit status of the
last command executed within the script as the exit status of the
script. The return status is false if `return' is used outside a
- function and not during the execution of a script by `.'.
+ function and not during the execution of a script by `.' or
+ `source'.
`shift'
shift [N]
@@ -2148,8 +2284,9 @@ standard.
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. The return status is zero unless N is greater than `$#'
- or less than zero, non-zero otherwise.
+ 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'
`['
@@ -2157,6 +2294,9 @@ standard.
must be a separate argument. Expressions are composed of the
primaries described below in *Note Bash Conditional Expressions::.
+ 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.
@@ -2225,16 +2365,17 @@ standard.
specified signals are reset to the values they 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 `-p', the shell displays the trap commands associated
- with each SIGSPEC. If no arguments are supplied, or only `-p' is
- given, `trap' prints the list of commands associated with each
- signal number in a form that may be reused as shell input. Each
- SIGSPEC is either a signal name such as `SIGINT' (with or without
- the `SIG' prefix) or a signal number. If a SIGSPEC is `0' or
- `EXIT', ARG is executed when the shell exits. If a SIGSPEC is
- `DEBUG', the command ARG is executed after every simple command.
- The `-l' option causes the shell to print a list of signal names
- and their corresponding numbers.
+ 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. Each SIGSPEC is either a signal
+ name such as `SIGINT' (with or without the `SIG' prefix) or a
+ signal number. If a SIGSPEC is `0' or `EXIT', ARG is executed
+ when the shell exits. If a SIGSPEC is `DEBUG', the command ARG is
+ executed after every simple command. The `-l' option causes the
+ shell to print a list of signal names and their corresponding
+ numbers.
Signals ignored upon entry to the shell cannot be trapped or reset.
Trapped signals are reset to their original values in a child
@@ -2256,6 +2397,10 @@ standard.
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 [-fv] [NAME]
Each variable or function NAME is removed. If no options are
@@ -2266,628 +2411,37 @@ standard.
zero unless a NAME does not exist or is readonly.

-File: bashref.info, Node: Bourne Shell Variables, Next: Other Bourne Shell Features, Prev: Bourne Shell Builtins, Up: Bourne Shell Features
-
-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 and the `MAILPATH' variable
- is not set, Bash informs the user of the arrival of mail in the
- specified file.
-
-`MAILPATH'
- A colon-separated list of filenames which the shell periodically
- checks for new mail. Each list entry can specify the message that
- is printed when new mail arrives in the mail file by separating
- the file name from the message with a `?'. 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.
-
-`PS1'
- The primary prompt string. The default value is `\s-\v\$ '.
-
-`PS2'
- The secondary prompt string. The default value is `> '.
-
-
-File: bashref.info, Node: Other Bourne Shell Features, Prev: Bourne Shell Variables, Up: Bourne Shell Features
-
-Other Bourne Shell Features
-===========================
-
-* Menu:
-
-* Major Differences From The Bourne Shell:: Major differences between
- Bash and the Bourne shell.
-
- Bash implements essentially the same grammar, parameter and variable
-expansion, redirection, and quoting as the Bourne Shell. Bash uses the
-POSIX 1003.2 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 subsequent sections.
-
-
-File: bashref.info, Node: Major Differences From The Bourne Shell, Up: Other Bourne Shell Features
-
-Major Differences From The SVR4.2 Bourne Shell
-----------------------------------------------
-
- * Bash is POSIX-conformant, even where the POSIX specification
- differs from traditional `sh' behavior.
-
- * Bash has multi-character invocation options (*note Invoking
- Bash::.).
-
- * Bash has command-line editing (*note Command Line Editing::.) and
- the `bind' builtin.
-
- * Bash has command history (*note Bash History Facilities::.) and the
- `history' and `fc' builtins to manipulate 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.
-
- * 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 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::.).
-
- * 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 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::.).
-
- * 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.
-
- * Bash implements the full set of POSIX.2 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.
-
- * 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.
-
- * 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::.).
-
- * 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' builtins 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 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 `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 Bash Builtins::.).
-
- * Bash has much more optional behavior controllable with the `set'
- builtin (*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.
-
- * The `trap' builtin (*note Bourne Shell Builtins::.) allows a
- `DEBUG' pseudo-signal specification, similar to `EXIT'. Commands
- specified with a `DEBUG' trap are executed after every simple
- command. The `DEBUG' trap is not inherited by shell functions.
-
- * 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 Printing a 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'.
-
- * 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::.
-
-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.2 special builtins fails, and only
- for certain failures, as enumerated in the POSIX.2 standard.
-
- * The SVR4.2 shell behaves differently when invoked as `jsh' (it
- turns on job control).
-
-
-File: bashref.info, Node: Bash Features, Next: Job Control, Prev: Bourne Shell Features, Up: Top
-
-Bash Features
-*************
-
- This section describes features unique to Bash.
-
-* Menu:
-
-* Invoking Bash:: Command line options that you can give
- to Bash.
-* Bash Startup Files:: When and how Bash executes scripts.
-* Is This Shell Interactive?:: Determining the state of a running Bash.
-* Bash Builtins:: Table of builtins specific to Bash.
-* The Set Builtin:: This builtin is so overloaded it
- deserves its own section.
-* Bash Conditional Expressions:: Primitives used in composing expressions for
- the `test' builtin.
-* Bash Variables:: List of variables that exist in Bash.
-* Shell Arithmetic:: Arithmetic on shell variables.
-* Aliases:: Substituting one command for another.
-* Arrays:: Array Variables.
-* The Directory Stack:: History of visited directories.
-* Printing a Prompt:: Controlling the PS1 string.
-* The Restricted Shell:: A more controlled mode of shell execution.
-* Bash POSIX Mode:: Making Bash behave more closely to what
- the POSIX standard specifies.
-
-
-File: bashref.info, Node: Invoking Bash, Next: Bash Startup Files, Up: Bash Features
-
-Invoking Bash
-=============
-
- bash [long-opt] [-ir] [-abefhkmnptuvxdBCDHP] [-o OPTION] [ARGUMENT ...]
- bash [long-opt] [-abefhkmnptuvxdBCDHP] [-o OPTION] -c STRING [ARGUMENT ...]
- bash [long-opt] -s [-abefhkmnptuvxdBCDHP] [-o OPTION] [ARGUMENT ...]
-
- In addition to the single-character shell command-line options
-(*note The Set Builtin::.), there are several multi-character options
-that you can use. These options must appear on the command line before
-the single-character options in order for them to be recognized.
-
-`--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 sucessfully.
-
-`--login'
- Make this shell act as if it were directly invoked by login. This
- is equivalent to `exec -l bash' but can be issued from another
- shell, such as `csh'. `exec bash --login' will replace the
- current shell with a Bash login shell.
-
-`--noediting'
- Do not use the GNU Readline library (*note Command Line Editing::.)
- to read interactive command lines.
-
-`--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 1003.2 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.
-
-`--rcfile FILENAME'
- Execute commands from FILENAME (instead of `~/.bashrc') in an
- interactive shell.
-
-`--restricted'
- Make the shell a restricted shell (*note The Restricted Shell::.).
-
-`--verbose'
- Equivalent to `-v'.
-
-`--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 STRING'
- Read and execute commands from STRING after processing the
- options, then exit. Any remaining arguments are assigned to the
- positional parameters, starting with `$0'.
-
-`-i'
- Force the shell to run interactively.
-
-`-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 ouput. 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.
-
-`--'
- A `--' signals the end of options and disables further option
- processing. Any arguments after the `--' are treated as filenames
- and arguments.
-
- An *interactive* shell is one whose input and output are both
-connected to terminals (as determined by `isatty(3)'), or one started
-with the `-i' option.
-
- 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: bashref.info, Node: Bash Startup Files, Next: Is This Shell Interactive?, Prev: Invoking Bash, Up: Bash Features
-
-Bash Startup Files
-==================
-
- This section describs how Bash executes its startup files. If any
-of the files exist but cannot be read, Bash reports an error. Tildes
-are expanded in file names as described above under Tilde Expansion
-(*note Tilde Expansion::.).
-
- 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 a login shell exits, 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'.
-
- So, typically, your `~/.bash_profile' contains the line
- `if [ -f `~/.bashrc' ]; then . `~/.bashrc'; fi'
-
-after (or before) any login-specific initializations.
-
- 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 file
-name.
-
- 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.
-
- 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 by the remote shell
-daemon, usually `rshd'. If Bash determines it is being run by rshd, 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 `rshd' does not
-generally invoke the shell with those options or allow them to be
-specified.
-
- If Bash is started with the effective user (group) id not equal to
-the real user (group) id, and the `-p' option is not supplied, no
-startup files are read, shell functions are not inherited from the
-environment, the `SHELLOPTS' variable, if it appears in the
-environment, is ignored, and the effective user id is set to the real
-user id. If the `-p' option is supplied at invocation, the startup
-behavior is the same, but the effective user id is not reset.
-
-
-File: bashref.info, Node: Is This Shell Interactive?, Next: Bash Builtins, Prev: Bash Startup Files, Up: Bash Features
-
-Is This Shell Interactive?
-==========================
-
- As defined in *Note Invoking Bash::, an interactive shell is one
-whose input and output are both connected to terminals (as determined
-by `isatty(3)'), or one started with the `-i' option.
-
- To determine within a startup script whether Bash is running
-interactively or not, 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
-
- Alternatively, startup scripts may test the value of the `-' special
-parameter. It contains `i' when the shell is interactive. For example:
-
- case "$-" in
- *i*) echo This shell is interactive ;;
- *) echo This shell is not interactive ;;
- esac
-
-
-File: bashref.info, Node: Bash Builtins, Next: The Set Builtin, Prev: Is This Shell Interactive?, Up: Bash Features
+File: bashref.info, Node: Bash Builtins, Next: The Set Builtin, Prev: Bourne Shell Builtins, Up: Shell Builtin Commands
Bash Builtin Commands
=====================
This section describes builtin commands which are unique to or have
-been extended in Bash.
+been extended in Bash. Some of these commands are specified in the
+POSIX 1003.2 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] [-lpsvPSV]
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
- Display current Readline (*note Command Line Editing::.) key and
+ Display current Readline (*note Command Line Editing::.) key and
function bindings, or bind a key sequence to a Readline function
- or macro. The binding syntax accepted is identical to that of
- `.inputrc' (*note Readline Init File::.), but each binding must be
- passed as a separate argument: e.g.,
+ or macro. The binding syntax accepted is identical to that of a
+ Readline initialization file (*note Readline Init File::.), but
+ each binding must be passed as a separate argument: e.g.,
`"\C-x\C-r":re-read-init-file'. Options, if supplied, have the
following meanings:
@@ -2903,21 +2457,24 @@ been extended in Bash.
`-p'
Display Readline function names and bindings in such a way
- that they can be re-read.
+ 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 re-read.
+ 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 re-read.
+ 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
@@ -2935,6 +2492,9 @@ been extended in Bash.
`-r KEYSEQ'
Remove any current binding for KEYSEQ.
+ `-x KEYSEQ:SHELL-COMMAND'
+ Cause SHELL-COMMAND to be executed whenever KEYSEQ is entered.
+
The return status is zero unless an invalid option is supplied or
an error occurs.
@@ -3019,6 +2579,8 @@ been extended in Bash.
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' interprets the following escape sequences:
`\a'
alert (bell)
@@ -3062,7 +2624,7 @@ been extended in Bash.
enable [-n] [-p] [-f FILENAME] [-ads] [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 with specifying a full pathname, even though the
+ 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'
@@ -3081,17 +2643,19 @@ been extended in Bash.
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.
+ 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 [PATTERN]
+ help [-s] [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. The return
- status is zero unless no command matches PATTERN.
+ PATTERN, otherwise a list of the builtins is printed. The `-s'
+ option restricts the information displayed to a short usage
+ synopsis. The return status is zero unless no command matches
+ PATTERN.
`let'
let EXPRESSION [EXPRESSION]
@@ -3101,12 +2665,14 @@ been extended in Bash.
evaluates to 0, `let' returns 1; otherwise 0 is returned.
`local'
- local NAME[=VALUE]
+ local [OPTION] NAME[=VALUE]
For each argument, a local variable named NAME is created, and
- assigned VALUE. `local' can only be used within a function; it
- makes the variable NAME have a visible scope restricted to that
- function and its children. The return status is zero unless
- `local' is used outside a function or an invalid NAME is supplied.
+ 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. 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]
@@ -3129,10 +2695,11 @@ been extended in Bash.
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.
+ appropriate, had been supplied. The return value is zero on
+ success, non-zero on failure.
`read'
- read [-a ANAME] [-p PROMPT] [-er] [NAME ...]
+ read [-ers] [-a ANAME] [-p PROMPT] [-t TIMEOUT] [-n NCHARS] [-d DELIM] [NAME ...]
One line is read from the standard input, and the first word is
assigned to the first NAME, the second word to the second NAME,
and so on, with leftover words and their intervening separators
@@ -3143,19 +2710,8 @@ been extended in Bash.
may be used to remove any special meaning for the next character
read and for line continuation. If no names are supplied, the
line read is assigned to the variable `REPLY'. The return code is
- zero, unless end-of-file is encountered. Options, if supplied,
- have the following meanings:
-
- `-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.
-
- `-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.
+ zero, unless end-of-file is encountered or `read' times out.
+ Options, if supplied, have the following meanings:
`-a ANAME'
The words are assigned to sequential indices of the array
@@ -3163,10 +2719,39 @@ been extended in Bash.
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.
+ `-n NCHARS'
+ `read' returns after reading NCHARS characters rather than
+ waiting for a complete line of input.
+
+ `-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 is not read within TIMEOUT seconds. This
+ option has no effect if `read' is not reading input from the
+ terminal or a pipe.
+
`shopt'
shopt [-pqsu] [-o] [OPTNAME ...]
Toggle the values of variables controlling optional shell behavior.
@@ -3242,8 +2827,8 @@ been extended in Bash.
fails.
`expand_aliases'
- If set, aliases are expanded as described below< under Aliases
- (*note Aliases::.). This option is enabled by default for
+ If set, aliases are expanded as described below under Aliases,
+ *Note Aliases::. This option is enabled by default for
interactive shells.
`extglob'
@@ -3290,6 +2875,11 @@ been extended in Bash.
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.
@@ -3298,6 +2888,11 @@ been extended in Bash.
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 variable and parameter
expansion after being expanded (*note Printing a Prompt::.).
@@ -3320,6 +2915,10 @@ been extended in Bash.
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
@@ -3417,8 +3016,14 @@ been extended in Bash.
non-numeric argument other than `unlimited' is supplied as a
LIMIT, 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: bashref.info, Node: The Set Builtin, Next: Bash Conditional Expressions, Prev: Bash Builtins, Up: Bash Features
+File: bashref.info, Node: The Set Builtin, Next: Special Builtins, Prev: Bash Builtins, Up: Shell Builtin Commands
The Set Builtin
===============
@@ -3631,127 +3236,104 @@ The Set Builtin
supplied.

-File: bashref.info, Node: Bash Conditional Expressions, Next: Bash Variables, Prev: The Set Builtin, Up: Bash Features
+File: bashref.info, Node: Special Builtins, Prev: The Set Builtin, Up: Shell Builtin Commands
-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. If any FILE argument to one of
-the primaries is of the form `/dev/fd/N', then file descriptor N is
-checked.
-
-`-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.
+Special Builtins
+================
-`-k FILE'
- True if FILE exists and its "sticky" bit is set.
+ For historical reasons, the POSIX 1003.2 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:
-`-p FILE'
- True if FILE exists and is a named pipe (FIFO).
+ 1. Special builtins are found before shell functions during command
+ lookup.
-`-r FILE'
- True if FILE exists and is readable.
+ 2. If a special builtin returns an error status, a non-interactive
+ shell exits.
-`-s FILE'
- True if FILE exists and has a size greater than zero.
+ 3. Assignment statements preceding the command stay in effect in the
+ shell environment after the command completes.
-`-t FD'
- True if file descriptor FD is open and refers to a terminal.
+ 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::.
-`-u FILE'
- True if FILE exists and its set-user-id bit is set.
+ These are the POSIX special builtins:
+ break : . continue eval exec exit export readonly return set
+ shift trap unset
-`-w FILE'
- True if FILE exists and is writable.
+
+File: bashref.info, Node: Shell Variables, Next: Bash Features, Prev: Shell Builtin Commands, Up: Top
-`-x FILE'
- True if FILE exists and is executable.
+Shell Variables
+***************
-`-O FILE'
- True if FILE exists and is owned by the effective user id.
+* Menu:
-`-G FILE'
- True if FILE exists and is owned by the effective group id.
+* Bourne Shell Variables:: Variables which Bash uses in the same way
+ as the Bourne Shell.
+* Bash Variables:: List of variables that exist in Bash.
-`-L FILE'
- True if FILE exists and is a symbolic link.
+ This chapter describes the shell variables that Bash uses. Bash
+automatically assigns default values to a number of variables.
-`-S FILE'
- True if FILE exists and is a socket.
+
+File: bashref.info, Node: Bourne Shell Variables, Next: Bash Variables, Up: Shell Variables
-`-N FILE'
- True if FILE exists and has been modified since it was last read.
+Bourne Shell Variables
+======================
-`FILE1 -nt FILE2'
- True if FILE1 is newer (according to modification date) than FILE2.
+ Bash uses certain shell variables in the same way as the Bourne
+shell. In some cases, Bash assigns a default value to the variable.
-`FILE1 -ot FILE2'
- True if FILE1 is older than FILE2.
+`CDPATH'
+ A colon-separated list of directories used as a search path for
+ the `cd' builtin command.
-`FILE1 -ef FILE2'
- True if FILE1 and FILE2 have the same device and inode numbers.
+`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::.).
-`-o OPTNAME'
- True if 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::.).
+`IFS'
+ A list of characters that separate fields; used when the shell
+ splits words as part of expansion.
-`-z STRING'
- True if the length of STRING is zero.
+`MAIL'
+ If this parameter is set to a filename and the `MAILPATH' variable
+ is not set, Bash informs the user of the arrival of mail in the
+ specified file.
-`-n STRING'
-`STRING'
- True if the length of STRING is non-zero.
+`MAILPATH'
+ A colon-separated list of filenames which the shell periodically
+ checks for new mail. Each list entry can specify the message that
+ is printed when new mail arrives in the mail file by separating
+ the file name from the message with a `?'. When used in the text
+ of the message, `$_' expands to the name of the current mail file.
-`STRING1 == STRING2'
- True if the strings are equal. `=' may be used in place of `=='.
+`OPTARG'
+ The value of the last option argument processed by the `getopts'
+ builtin.
-`STRING1 != STRING2'
- True if the strings are not equal.
+`OPTIND'
+ The index of the last option argument processed by the `getopts'
+ builtin.
-`STRING1 < STRING2'
- True if STRING1 sorts before STRING2 lexicographically in the
- current locale.
+`PATH'
+ A colon-separated list of directories in which the shell looks for
+ commands.
-`STRING1 > STRING2'
- True if STRING1 sorts after STRING2 lexicographically in the
- current locale.
+`PS1'
+ The primary prompt string. The default value is `\s-\v\$ '.
+ *Note Printing a Prompt::, for the complete list of escape
+ sequences that are expanded before `PS1' is displayed.
-`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.
+`PS2'
+ The secondary prompt string. The default value is `> '.

-File: bashref.info, Node: Bash Variables, Next: Shell Arithmetic, Prev: Bash Conditional Expressions, Up: Bash Features
+File: bashref.info, Node: Bash Variables, Prev: Bourne Shell Variables, Up: Shell Variables
Bash Variables
==============
@@ -3759,6 +3341,10 @@ 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.
@@ -3772,9 +3358,9 @@ normally treat them specially.
The version number of the current instance of Bash.
`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:
+ 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).
@@ -3794,16 +3380,45 @@ normally treat them specially.
`BASH_VERSINFO[5]'
The value of `MACHTYPE'.
+`COMP_WORDS'
+ An array variable consisting of the individual words in the
+ current command line. This variable is available only in shell
+ functions invoked by the programmable completion facilities (*note
+ Programmable Completion::.).
+
+`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::.).
+
+`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::.).
+
`DIRSTACK'
- An array variable (*note Arrays::.) 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.
+ 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.
`EUID'
The numeric effective user id of the current user. This variable
@@ -3827,13 +3442,15 @@ normally treat them specially.
`GROUPS'
An array variable containing the list of groups of which the
- current user is a member. This variable is readonly.
+ current user is a member. Assignments to `GROUPS' have no effect
+ and are silently discarded. 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-char", that is, the
- character which signifies the start of a history expansion,
+ 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
@@ -3849,25 +3466,32 @@ normally treat them specially.
command. If `HISTCMD' is unset, it loses its special properties,
even if it is subsequently reset.
+`FUNCNAME'
+ The name of any currently-executing shell function. This variable
+ exists only when a shell function is executing. Assignments to
+ `FUNCNAME' have no effect and are silently discarded. If
+ `FUNCNAME' is unset, it loses its special properties, even if it
+ is subsequently reset.
+
`HISTCONTROL'
- Set to a value of `ignorespace', it means don't enter lines which
- begin with a space or tab into the history list. Set to a value
- of `ignoredups', it means don't enter lines which match the last
- entered line. A value of `ignoreboth' combines the two options.
- Unset, or set to any other value than those above, means to save
- all lines on the history list. 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'.
+ A value of `ignorespace' means to not enter lines which begin with
+ a space or tab into the history list. A value of `ignoredups'
+ means to not enter lines which match the last entered line. A
+ value of `ignoreboth' combines the two options. Unset, or set to
+ any other value than those above, means to save all lines on the
+ history list. 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'.
`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 fully specify the
+ 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
+ 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'.
@@ -3880,7 +3504,7 @@ normally treat them specially.
`HISTFILE'
The name of the file to which the command history is saved. The
- default is `~/.bash_history'.
+ default value is `~/.bash_history'.
`HISTSIZE'
The maximum number of commands to remember on the history list.
@@ -3890,15 +3514,19 @@ normally treat them specially.
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. The
- default value is 500. The history file is also truncated to this
- size after writing it when an interactive shell exits.
+ history file is also truncated to this size after writing it when
+ an interactive shell exits. The default value is 500.
`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. You
- can change the file interactively; the next time you attempt to
- complete a hostname, Bash will add the contents of the new file to
- the already existing database.
+ 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,
+ 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.
@@ -3917,8 +3545,8 @@ normally treat them specially.
in effect for interactive shells.
`INPUTRC'
- The name of the Readline startup file, overriding the default of
- `~/.inputrc'.
+ The name of the Readline initialization file, overriding the
+ default of `~/.inputrc'.
`LANG'
Used to determine the locale category for any category not
@@ -3944,6 +3572,10 @@ normally treat them specially.
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.
+
`LINENO'
The line number in the script or shell function currently
executing.
@@ -3967,17 +3599,17 @@ normally treat them specially.
A string describing the operating system Bash is running on.
`PIPESTATUS'
- An array variable (*note Arrays::.) containing a list of exit
+ 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).
`PPID'
- The process id of the shell's parent process. This variable is
+ The process ID of the shell's parent process. This variable is
readonly.
`PROMPT_COMMAND'
- If present, this contains a string which is a command to execute
- before the printing of each primary prompt (`$PS1').
+ If set, the value is interpreted as a command to execute before
+ the printing of each primary prompt (`$PS1').
`PS3'
The value of this variable is used as the prompt for the `select'
@@ -3985,8 +3617,8 @@ normally treat them specially.
prompts with `#? '
`PS4'
- This is the prompt printed before the command line is echoed when
- the `-x' option is set (*note The Set Builtin::.). The first
+ 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 `+ '.
@@ -4062,15 +3694,525 @@ normally treat them specially.
`TMOUT'
If set to a value greater than zero, the value is interpreted as
the number of seconds to wait for input after issuing the primary
- prompt. Bash terminates after that number of seconds if input does
- not arrive.
+ prompt when the shell is interactive. Bash terminates after that
+ number of seconds if input does not arrive.
`UID'
The numeric real user id of the current user. This variable is
readonly.

-File: bashref.info, Node: Shell Arithmetic, Next: Aliases, Prev: Bash Variables, Up: Bash Features
+File: bashref.info, Node: Bash Features, Next: Job Control, Prev: Shell Variables, Up: Top
+
+Bash Features
+*************
+
+ This section describes features unique to Bash.
+
+* Menu:
+
+* Invoking Bash:: Command line options that you can give
+ to Bash.
+* Bash Startup Files:: When and how Bash executes scripts.
+* Interactive Shells:: What an interactive shell is.
+* Bash Conditional Expressions:: Primitives used in composing expressions for
+ the `test' builtin.
+* Shell Arithmetic:: Arithmetic on shell variables.
+* Aliases:: Substituting one command for another.
+* Arrays:: Array Variables.
+* The Directory Stack:: History of visited directories.
+* Printing a Prompt:: Controlling the PS1 string.
+* The Restricted Shell:: A more controlled mode of shell execution.
+* Bash POSIX Mode:: Making Bash behave more closely to what
+ the POSIX standard specifies.
+
+
+File: bashref.info, Node: Invoking Bash, Next: Bash Startup Files, Up: Bash Features
+
+Invoking Bash
+=============
+
+ bash [long-opt] [-ir] [-abefhkmnptuvxdBCDHP] [-o OPTION] [ARGUMENT ...]
+ bash [long-opt] [-abefhkmnptuvxdBCDHP] [-o OPTION] -c STRING [ARGUMENT ...]
+ bash [long-opt] -s [-abefhkmnptuvxdBCDHP] [-o OPTION] [ARGUMENT ...]
+
+ In addition to the single-character shell command-line options
+(*note The Set Builtin::.), there are several multi-character options
+that you can use. These options must appear on the command line before
+the single-character options in order for them to be recognized.
+
+`--dump-po-strings'
+ A list of all double-quoted strings preceded by `$' is printed on
+ the standard ouput 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 sucessfully.
+
+`--login'
+ Make this shell act as if it were directly invoked by login. This
+ is equivalent to `exec -l bash' but can be issued from another
+ shell, such as `csh'. `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.
+
+`--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 1003.2 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.
+
+`--rcfile FILENAME'
+ Execute commands from FILENAME (instead of `~/.bashrc') in an
+ interactive shell.
+
+`--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 STRING'
+ Read and execute commands from STRING after processing the
+ options, then exit. Any remaining arguments are assigned to the
+ positional parameters, starting with `$0'.
+
+`-i'
+ Force the shell to run interactively. Interactive shells are
+ described in *Note Interactive Shells::.
+
+`-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 ouput. 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.
+
+`--'
+ A `--' signals the end of options and disables further option
+ processing. Any arguments after the `--' are treated as filenames
+ and arguments.
+
+ 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: bashref.info, Node: Bash Startup Files, Next: Interactive Shells, Prev: Invoking Bash, Up: Bash Features
+
+Bash Startup Files
+==================
+
+ This section describs how Bash executes its startup files. If any
+of the files exist but cannot be read, Bash reports an error. Tildes
+are expanded in file names 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 a login shell exits, 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 file
+name.
+
+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 by the remote shell
+daemon, usually `rshd'. If Bash determines it is being run by rshd, 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 `rshd' does not
+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' variable, if it appears in the
+environment, is ignored, and the effective user id is set to the real
+user id. If the `-p' option is supplied at invocation, the startup
+behavior is the same, but the effective user id is not reset.
+
+
+File: bashref.info, Node: Interactive Shells, Next: Bash Conditional Expressions, Prev: Bash Startup Files, Up: Bash Features
+
+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: bashref.info, Node: What is an Interactive Shell?, Next: Is this Shell Interactive?, Up: Interactive Shells
+
+What is an Interactive Shell?
+-----------------------------
+
+ An interactive shell is one started without non-option arguments,
+unless `-s' is specified, without specifiying 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.
+
+ 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: bashref.info, Node: Is this Shell Interactive?, Next: Interactive Shell Behavior, Prev: What is an Interactive Shell?, Up: Interactive Shells
+
+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: bashref.info, Node: Interactive Shell Behavior, Prev: Is this Shell Interactive?, Up: Interactive Shells
+
+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.
+
+ 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 an interactive shell 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 `hupoxexit' 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 Bash Builtins::).
+
+ 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: bashref.info, Node: Bash Conditional Expressions, Next: Shell Arithmetic, Prev: Interactive Shells, Up: Bash Features
+
+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. 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.
+
+`-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.
+
+`-O FILE'
+ True if FILE exists and is owned by the effective user id.
+
+`-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.
+
+`-S FILE'
+ True if FILE exists and is a socket.
+
+`-N FILE'
+ True if FILE exists and has been modified since it was last read.
+
+`FILE1 -nt FILE2'
+ True if FILE1 is newer (according to modification date) than FILE2.
+
+`FILE1 -ot FILE2'
+ True if FILE1 is older than FILE2.
+
+`FILE1 -ef FILE2'
+ True if FILE1 and FILE2 have the same device and inode numbers.
+
+`-o OPTNAME'
+ True if 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::.).
+
+`-z STRING'
+ True if the length of STRING is zero.
+
+`-n STRING'
+`STRING'
+ True if the length of STRING is non-zero.
+
+`STRING1 == STRING2'
+ True if the strings are equal. `=' may be used in place of `=='.
+
+`STRING1 != STRING2'
+ True if the strings are not equal.
+
+`STRING1 < STRING2'
+ True if STRING1 sorts before STRING2 lexicographically in the
+ current locale.
+
+`STRING1 > STRING2'
+ True if STRING1 sorts after STRING2 lexicographically in the
+ current locale.
+
+`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: bashref.info, Node: Shell Arithmetic, Next: Aliases, Prev: Bash Conditional Expressions, Up: Bash Features
Shell Arithmetic
================
@@ -4079,9 +4221,17 @@ Shell Arithmetic
the shell expansions or by the `let' builtin.
Evaluation is done in long 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.
+though division by 0 is trapped and flagged as an error. The operators
+and their precedence and associativity 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
@@ -4128,20 +4278,24 @@ The levels are listed in order of decreasing precedence.
`= *= /= %= += -= <<= >>= &= ^= |='
assignment
+`expr1 , expr2'
+ comma
+
Shell variables are allowed as operands; parameter expansion is
-performed before the expression is evaluated. The value of a parameter
-is coerced to a long integer within an expression. A shell variable
-need not have its integer attribute turned on to be used in an
-expression.
+performed before the expression is evaluated. Within an expression,
+shell variables may also be referenced by name without using the
+parameter expansion syntax. The value of a variable is evaluated as an
+arithmetic expression when it is referenced. 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 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. 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 interchangably to represent numbers
+BASE`#' is omitted, then base 10 is used. 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 interchangably to represent numbers
between 10 and 35.
Operators are evaluated in order of precedence. Sub-expressions in
@@ -4154,13 +4308,9 @@ File: bashref.info, Node: Aliases, Next: Arrays, Prev: Shell Arithmetic, Up:
Aliases
=======
-* Menu:
-
-* Alias Builtins:: Builtins commands to maniuplate aliases.
-
- Aliases allow a string to be substituted for a word when it is used
+ 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'
+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
@@ -4201,28 +4351,7 @@ 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.
-
-
-File: bashref.info, Node: Alias Builtins, Up: Aliases
-
-Alias Builtins
---------------
-
-`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.
-
-`unalias'
- unalias [-a] [NAME ... ]
-
- Remove each NAME from the list of aliases. If `-a' is supplied,
- all aliases are removed.
+ For almost every purpose, shell functions are preferred over aliases.

File: bashref.info, Node: Arrays, Next: The Directory Stack, Prev: Aliases, Up: Bash Features
@@ -4278,9 +4407,9 @@ is the number of elements in the array. Referencing an array variable
without a subscript is equivalent to referencing element zero.
The `unset' builtin is used to destroy arrays. `unset'
-`name[SUBSCRIPT]' destroys the array element at index SUBSCRIPT.
-`unset' NAME, where NAME is an array, removes the entire array. A
-subscript of `*' or `@' also removes the entire array.
+NAME[SUBSCRIPT] destroys the array element at index SUBSCRIPT. `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 array. The `read' builtin accepts a `-a' option
@@ -4295,6 +4424,11 @@ File: bashref.info, Node: The Directory Stack, Next: Printing a Prompt, Prev:
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
@@ -4304,8 +4438,14 @@ The `dirs' builtin displays the contents of the directory stack.
The contents of the directory stack are also visible as the value of
the `DIRSTACK' shell variable.
+
+File: bashref.info, Node: Directory Stack Builtins, Up: The Directory Stack
+
+Directory Stack Builtins
+------------------------
+
`dirs'
- dirs [+N | -N] [-clvp]
+ dirs [+N | -N] [-clpv]
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.
@@ -4389,8 +4529,9 @@ Controlling the Prompt
======================
The value of the variable `PROMPT_COMMAND' is examined just before
-Bash prints each primary prompt. If it is set and non-null, then the
-value is executed just as if it had been typed on the command line.
+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:
@@ -4410,6 +4551,12 @@ which can appear in the prompt variables:
`\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.
@@ -4466,6 +4613,16 @@ which can appear in the prompt variables:
`\]'
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: bashref.info, Node: The Restricted Shell, Next: Bash POSIX Mode, Prev: Printing a Prompt, Up: Bash Features
@@ -4487,6 +4644,9 @@ with the exception that the following are disallowed:
* 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.
@@ -4513,8 +4673,8 @@ 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.2 standard by changing the behavior to match that
-specified by POSIX.2 in areas where the Bash default differs.
+closely to the POSIX 1003.2 standard by changing the behavior to match
+that specified by POSIX in areas where the Bash default differs.
The following list is what's changed when `POSIX mode' is in effect:
@@ -4529,7 +4689,7 @@ specified by POSIX.2 in areas where the Bash default differs.
4. Reserved words may not be aliased.
- 5. The POSIX.2 `PS1' and `PS2' expansions of `!' to the history
+ 5. The POSIX 1003.2 `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.
@@ -4537,8 +4697,8 @@ specified by POSIX.2 in areas where the Bash default differs.
6. Interactive comments are enabled by default. (Bash has them on by
default anyway.)
- 7. The POSIX.2 startup files are executed (`$ENV') rather than the
- normal Bash files.
+ 7. The POSIX 1003.2 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.
@@ -4558,49 +4718,52 @@ specified by POSIX.2 in areas where the Bash default differs.
13. Redirection operators do not perform filename expansion on the word
in the redirection unless the shell is interactive.
- 14. Function names must be valid shell `name's. That is, they may not
+ 14. Redirection operators do not perform word splitting on the word in
+ the redirection.
+
+ 15. 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.
- 15. POSIX.2 `special' builtins are found before shell functions during
- command lookup.
+ 16. POSIX 1003.2 `special' builtins are found before shell functions
+ during command lookup.
- 16. If a POSIX.2 special builtin returns an error status, a
+ 17. If a POSIX 1003.2 special builtin returns an error status, a
non-interactive shell exits. The fatal errors are those listed in
the POSIX.2 standard, and include things like passing incorrect
options, redirection errors, variable assignment errors for
assignments preceding the command name, and so on.
- 17. If the `cd' builtin finds a directory to change to using
+ 18. If the `cd' builtin finds a directory to change to using
`$CDPATH', the value it assigns to the `PWD' variable does not
contain any symbolic links, as if `cd -P' had been executed.
- 18. If `$CDPATH' is set, the `cd' builtin will not implicitly append
+ 19. If `$CDPATH' is set, the `cd' builtin will not implicitly append
the current directory to it. This means that `cd' will fail if no
valid directory name can be constructed from any of the entries in
`$CDPATH', even if the a directory with the same name as the name
given as an argument to `cd' exists in the current directory.
- 19. A non-interactive shell exits with an error status if a variable
+ 20. 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.
- 20. A non-interactive shell exits with an error status if the iteration
+ 21. 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.
- 21. Process substitution is not available.
+ 22. Process substitution is not available.
- 22. Assignment statements preceding POSIX.2 special builtins persist
- in the shell environment after the builtin completes.
+ 23. Assignment statements preceding POSIX 1003.2 special builtins
+ persist in the shell environment after the builtin completes.
- 23. The `export' and `readonly' builtin commands display their output
- in the format required by POSIX.2.
+ 24. The `export' and `readonly' builtin commands display their output
+ in the format required by POSIX 1003.2.
- There is other POSIX.2 behavior that Bash does not implement.
+ There is other POSIX 1003.2 behavior that Bash does not implement.
Specifically:
1. Assignment statements affect the execution environment of all
@@ -4645,17 +4808,17 @@ 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 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 write to the terminal. Background processes which attempt
-to read from (write to) the terminal are sent a `SIGTTIN' (`SIGTTOU')
-signal by the terminal driver, which, unless caught, suspends the
-process.
+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 write to the terminal. Background processes which
+attempt to read from (write to) the terminal are sent a `SIGTTIN'
+(`SIGTTOU') signal by the terminal driver, which, unless caught,
+suspends the process.
If the operating system on which Bash is running supports job
control, Bash contains facilities to use it. Typing the SUSPEND
@@ -4671,18 +4834,22 @@ 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 name. 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. 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. 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 `%-'. 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 `-'.
+character `%' introduces a job name.
+
+ 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. The previous job may be referenced using `%-'. 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
@@ -4726,7 +4893,7 @@ Job Control Builtins
JOBSPEC specifies a job that was started without job control.
`jobs'
- jobs [-lpnrs] [JOBSPEC]
+ jobs [-lnprs] [JOBSPEC]
jobs -x COMMAND [ARGUMENTS]
The first form lists the active jobs. The options have the
@@ -4774,7 +4941,7 @@ Job Control Builtins
invalid option is encountered.
`wait'
- wait [JOBSPEC|PID]
+ wait [JOBSPEC or PID]
Wait until the child process specified by 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
@@ -4827,336 +4994,14 @@ Job Control Variables
analogous to the `%' job ID.

-File: bashref.info, Node: Using History Interactively, Next: Command Line Editing, Prev: Job Control, Up: Top
-
-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: bashref.info, Node: Bash History Facilities, Next: Bash History Builtins, Up: Using History Interactively
-
-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 text of the last `HISTSIZE'
-commands (default 500) is saved in a history list. 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'). `HISTFILE' is
-truncated, if necessary, to contain no more than the number of lines
-specified by the value of the `HISTFILESIZE' variable. When an
-interactive shell exits, the last `HISTSIZE' lines are copied from the
-history list to `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 not set, no
-truncation is performed.
-
- The builtin command `fc' may be used to list or edit and re-execute
-a portion of the history list. The `history' builtin can be used to
-display or modify the history list and manipulate the history file.
-When using the 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. *Note Bash Builtins::, for a description of
-`shopt'.
-
-
-File: bashref.info, Node: Bash History Builtins, Next: History Interaction, Prev: Bash History Facilities, Up: Using History Interactively
-
-Bash History Builtins
-=====================
-
- Bash provides two builtin commands that allow you to manipulate the
-history list and history file.
-
-`fc'
- `fc [-e ENAME] [-nlr] [FIRST] [LAST]'
- `fc -s [PAT=REP] [COMMAND]'
-
- Fix Command. In the first form, a range of commands from FIRST to
- LAST is selected from the history list. 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.
-
- 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 [-c] [N]
- history [-anrw] [FILENAME]
- history -ps ARG
-
- Display the history list with line numbers. Lines prefixed with
- with a `*' have been modified. An argument of N says to list only
- the last N lines. Options, if supplied, have the following
- meanings:
-
- `-w'
- Write out the current history to the history file.
-
- `-r'
- Read the current history file and append its contents to the
- history list.
-
- `-a'
- Append the new history lines (history lines entered since the
- beginning of the current Bash session) 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.
-
- `-c'
- Clear the history list. This may be combined with the other
- options to replace the history list completely.
-
- `-s'
- The ARGs are added to the end of the history list as a single
- entry.
-
- `-p'
- Perform history substitution on the ARGs and display the
- result on the standard output, without storing the results in
- the history list.
-
- When the `-w', `-r', `-a', or `-n' option 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: bashref.info, Node: History Interaction, Prev: Bash History Builtins, Up: Using History Interactively
-
-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 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.
-
- 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.
-
-* 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: bashref.info, Node: Event Designators, Next: Word Designators, Up: History Interaction
-
-Event Designators
------------------
-
- An event designator is a reference to a command line entry in the
-history list.
-
-`!'
- Start a history substitution, except when followed by a space, tab,
- the end of the line, `=' or `('.
-
-`!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 starting with STRING.
-
-`!?STRING[?]'
- Refer to the most recent command 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: bashref.info, Node: Word Designators, Next: Modifiers, Prev: Event Designators, Up: History Interaction
-
-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 `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: bashref.info, Node: Modifiers, Prev: Word Designators, Up: History Interaction
-
-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'
- Cause changes to be applied over the entire event line. Used in
- conjunction with `s', as in `gs/OLD/NEW/', or with `&'.
-
-
File: bashref.info, Node: Command Line Editing, Next: Installing Bash, Prev: Using History Interactively, Up: Top
Command Line Editing
********************
This chapter describes the basic features of the GNU command line
-editing interface.
+editing interface. Command line editing is provided by the Readline
+library, which is used by several different programs, including Bash.
* Menu:
@@ -5168,6 +5013,11 @@ editing interface.
* 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.
+

File: bashref.info, Node: Introduction and Notation, Next: Readline Interaction, Up: Command Line Editing
@@ -5181,10 +5031,18 @@ keystrokes.
produced when the <k> 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 <k>
-key is pressed. If you do not have a meta key, the identical keystroke
-can be generated by typing <ESC> first, and then typing <k>. Either
-process is known as "metafying" the <k> key.
+produced when the Meta key (if you have one) is depressed, and the <k>
+key is pressed. The Meta key is labeled <ALT> on many keyboards. On
+keyboards with two keys labeled <ALT> (usually to either side of the
+space bar), the <ALT> on the left side is generally set to work as a
+Meta key. The <ALT> 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 <ALT> key, or another key working as a
+Meta key, the identical keystroke can be generated by typing <ESC>
+first, and then typing <k>. Either process is known as "metafying" the
+<k> key.
The text <M-C-k> is read as `Meta-Control-k' and describes the
character produced by "metafying" <C-k>.
@@ -5192,7 +5050,9 @@ character produced by "metafying" <C-k>.
In addition, several keys have their own names. Specifically,
<DEL>, <ESC>, <LFD>, <SPC>, <RET>, and <TAB> all stand for themselves
when seen in this text, or in an init file (*note Readline Init
-File::.).
+File::.). If your keyboard lacks a <LFD> key, typing <C-j> will
+produce the desired character. The <RET> key may be labeled <Return>
+or <Enter> on some keyboards.

File: bashref.info, Node: Readline Interaction, Next: Readline Init File, Prev: Introduction and Notation, Up: Command Line Editing
@@ -5230,18 +5090,17 @@ 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 miss typing a character that you wanted to type,
-and not notice your 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>.
+ 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 basic bare essentials for editing the text of an input line
+list of the bare essentials for editing the text of an input line
follows.
<C-b>
@@ -5250,7 +5109,7 @@ follows.
<C-f>
Move forward one character.
-<DEL>
+<DEL> or <Backspace>
Delete the character to the left of the cursor.
<C-d>
@@ -5259,21 +5118,25 @@ follows.
Printing characters
Insert the character into the line at the cursor.
-<C-_>
+<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 <Backspace> key be set to delete
+the character to the left of the cursor and the <DEL> key set to delete
+the character underneath the cursor, like <C-d>, rather than the
+character to the left of the cursor.)
+

File: bashref.info, Node: Readline Movement Commands, Next: Readline Killing Commands, Prev: Readline Bare Essentials, Up: Readline Interaction
Readline Movement Commands
--------------------------
- The above table describes the most basic possible 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 <DEL>. Here are some commands for moving more rapidly
-about the line.
+ 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
+<DEL>. Here are some commands for moving more rapidly about the line.
<C-a>
Move to the start of the line.
@@ -5303,9 +5166,12 @@ 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. 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.
+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
@@ -5320,12 +5186,14 @@ available to be yanked back later, when you are typing another line.
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.
+ 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-DEL>
- Kill from the cursor the start of the previous word, or if between
- words, to the start of the previous word.
+ Kill from the cursor the start of the previous 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
@@ -5357,7 +5225,7 @@ 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
+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'.
@@ -5369,26 +5237,30 @@ Searching for Commands in the History
-------------------------------------
Readline provides commands for searching through the command history
-(*note Bash History Facilities::.) for lines containing a specified
+(*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. 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 <ESC> 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-s> or <C-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 <RET> will terminate the search and accept the line,
-thereby executing the command from the history list.
+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 <ESC> 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 <RET> will terminate
+the search and accept the line, thereby executing the command from the
+history list.
Non-incremental searches read the entire search string before
starting to search for matching history lines. The search string may be
@@ -5400,12 +5272,13 @@ File: bashref.info, Node: Readline Init File, Next: Bindable Readline Commands
Readline Init File
==================
- Although the Readline library comes with a set of `emacs'-like
+ 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 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'.
+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'.
When a program which uses the Readline library starts up, the init
file is read, and the key bindings are set.
@@ -5441,6 +5314,9 @@ Variable Settings
set editing-mode vi
+ 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.
@@ -5472,7 +5348,7 @@ Variable Settings
`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 prepending an <ESC> character, converting them
+ eighth bit and prefixing an <ESC> character, converting them
to a meta-prefixed key sequence. The default value is `on'.
`disable-completion'
@@ -5557,7 +5433,7 @@ Variable Settings
Key Bindings
The syntax for controlling key bindings in the init file is
- simple. First you have to know the name of the command that you
+ 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.
@@ -5568,6 +5444,10 @@ Key Bindings
key can be expressed in different ways, depending on which is most
comfortable for you.
+ 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:
@@ -5613,10 +5493,10 @@ Key Bindings
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:
@@ -5646,11 +5526,11 @@ Key Bindings
vertical tab
`\NNN'
- the character whose ASCII code is the octal value NNN (one to
- three digits)
+ the character whose `ASCII' code is the octal value NNN (one
+ to three digits)
`\xNNN'
- the character whose ASCII code is the hexadecimal value NNN
+ the character whose `ASCII' code is the hexadecimal value NNN
(one to three digits)
When entering the text of a macro, single or double quotes must be
@@ -5847,7 +5727,15 @@ Bindable Readline Commands
* Miscellaneous Commands:: Other miscellaneous commands.
This section describes Readline commands that may be bound to key
-sequences.
+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: bashref.info, Node: Commands For Moving, Next: Commands For History, Up: Bindable Readline Commands
@@ -5872,7 +5760,7 @@ Commands For Moving
letters and digits.
`backward-word (M-b)'
- Move back to the start of this, or the previous, word. Words are
+ Move back to the start of the current or previous word. Words are
composed of letters and digits.
`clear-screen (C-l)'
@@ -5928,9 +5816,8 @@ Commands For Manipulating The History
`history-search-forward ()'
Search forward through the history for the string of characters
- between the start of the current line and the current cursor
- position (the POINT). This is a non-incremental search. By
- default, this command is unbound.
+ between the start of the current line and the point. 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
@@ -5983,11 +5870,11 @@ Commands For Changing Text
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 don't work.
+ characters of the line. Negative arguments have no effect.
`transpose-words (M-t)'
- Drag the word behind the cursor past the word in front of the
- cursor moving the cursor over that word as well.
+ Drag the word before point past the word after point, moving point
+ past that word as well.
`upcase-word (M-u)'
Uppercase the current (or following) word. With a negative
@@ -6008,41 +5895,38 @@ Killing And Yanking
-------------------
`kill-line (C-k)'
- Kill the text from the current cursor position to the end of the
- line.
+ 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 the cursor to the beginning of the current line.
- The killed text is saved on the kill-ring.
`kill-whole-line ()'
- Kill all characters on the current line, no matter where the
- cursor is. By default, this is unbound.
+ Kill all characters on the current line, no matter point is. By
+ default, this is unbound.
`kill-word (M-d)'
- Kill from the cursor to the end of the current word, or if between
+ 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-DEL)'
- Kill the word behind the cursor. Word boundaries are the same as
+ Kill the word behind point. Word boundaries are the same as
`backward-word'.
`unix-word-rubout (C-w)'
- Kill the word behind the cursor, using white space as a word
- boundary. The killed text is saved on the kill-ring.
+ Kill the word behind point, using white space as a word boundary.
+ 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 between the point and the *mark* (saved cursor
- position). This text is referred to as the REGION. By default,
- this command is unbound.
+ 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
@@ -6179,7 +6063,7 @@ Letting Readline Type For You
matches.
`complete-into-braces (M-{)'
- Perform filename completion and return the list of possible
+ Perform filename completion and insert the list of possible
completions enclosed within braces so the list is available to the
shell (*note Brace Expansion::.).
@@ -6207,7 +6091,7 @@ Some Miscellaneous Commands
---------------------------
`re-read-init-file (C-x C-r)'
- Read in the contents of the inputrc file, and incorporate any
+ Read in the contents of the INPUTRC file, and incorporate any
bindings or variable assignments found there.
`abort (C-g)'
@@ -6254,8 +6138,8 @@ Some Miscellaneous Commands
`insert-comment (M-#)'
The value of the `comment-begin' variable is inserted at the
beginning of the current line, and the line is accepted as if a
- newline had been typed. This makes the current line a shell
- comment.
+ newline had been typed. The default value of `comment-begin'
+ causes this command to make the current line a shell comment.
`dump-functions ()'
Print all of the functions and their key bindings to the Readline
@@ -6318,7 +6202,7 @@ Some Miscellaneous Commands
editing mode, as if the command `set -o emacs' had been executed.

-File: bashref.info, Node: Readline vi Mode, Prev: Bindable Readline Commands, Up: Command Line Editing
+File: bashref.info, Node: Readline vi Mode, Next: Programmable Completion, Prev: Bindable Readline Commands, Up: Command Line Editing
Readline vi Mode
================
@@ -6339,15 +6223,623 @@ the standard `vi' movement keys, move to previous history lines with
`k' and subsequent lines with `j', and so forth.

+File: bashref.info, Node: Programmable Completion, Next: Programmable Completion Builtins, Prev: Readline vi Mode, Up: Command Line Editing
+
+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 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.
+
+ 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, arithmetic expansion, and
+pathname 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' and `COMP_POINT'
+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 is the name of the command whose
+arguments are being completed, the second argument is the word being
+completed, and the third argument 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 (*note Programmable Completion Builtins::.), to
+generate the matches. It must put the possible completions in the
+`COMPREPLY' array variable.
+
+ 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.
+
+ 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 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.
+
+
+File: bashref.info, Node: Programmable Completion Builtins, Prev: Programmable Completion, Up: Command Line Editing
+
+Programmable Completion Builtins
+================================
+
+ Two builtin commands are available to manipulate the programmable
+completion facilities.
+
+`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 [-abcdefjkvu] [-A ACTION] [-G GLOBPAT] [-W WORDLIST]
+ [-P PREFIX] [-S SUFFIX] [-X FILTERPAT] [-F FUNCTION]
+ [-C COMMAND] NAME [NAME ...]'
+ `complete -pr [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 process of applying these completion specifications when word
+ completion is attempted is described above (*note 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.
+
+ `-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.
+
+ `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.
+
+ `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'.
+
+ `-G GLOBPAT'
+ The filename expansion pattern GLOBPAT is expanded to generate
+ the possible completions.
+
+ `-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.
+
+ `-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 finishes, the possible completions are
+ retrieved from the value of the `COMPREPLY' array variable.
+
+ `-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.
+
+ `-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.
+
+ 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.
+
+
+File: bashref.info, Node: Using History Interactively, Next: Command Line Editing, Prev: Job Control, Up: Top
+
+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: bashref.info, Node: Bash History Facilities, Next: Bash History Builtins, Up: Using History Interactively
+
+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 an interactive shell 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 not set, no truncation is
+performed.
+
+ 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: bashref.info, Node: Bash History Builtins, Next: History Interaction, Prev: Bash History Facilities, Up: Using History Interactively
+
+Bash History Builtins
+=====================
+
+ Bash provides two builtin commands which manipulate the history list
+and history file.
+
+`fc'
+ `fc [-e ENAME] [-nlr] [FIRST] [LAST]'
+ `fc -s [PAT=REP] [COMMAND]'
+
+ Fix Command. In the first form, a range of commands from FIRST to
+ LAST is selected from the history list. 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.
+
+ 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 with a `*' have been modified. An argument of
+ N lists only the last N lines. 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 (history lines entered since the
+ beginning of the current Bash session) 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 current history file and append its contents to the
+ history list.
+
+ `-w'
+ Write out the current history 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: bashref.info, Node: History Interaction, Prev: Bash History Builtins, Up: Using History Interactively
+
+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 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.
+
+ 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.
+
+* 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: bashref.info, Node: Event Designators, Next: Word Designators, Up: History Interaction
+
+Event Designators
+-----------------
+
+ An event designator is a reference to a command line entry in the
+history list.
+
+`!'
+ Start a history substitution, except when followed by a space, tab,
+ the end of the line, `=' or `('.
+
+`!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 starting with STRING.
+
+`!?STRING[?]'
+ Refer to the most recent command 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: bashref.info, Node: Word Designators, Next: Modifiers, Prev: Event Designators, Up: History Interaction
+
+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: bashref.info, Node: Modifiers, Prev: Word Designators, Up: History Interaction
+
+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'
+ Cause changes to be applied over the entire event line. Used in
+ conjunction with `s', as in `gs/OLD/NEW/', or with `&'.
+
+
File: bashref.info, Node: Installing Bash, Next: Reporting Bugs, Prev: Command Line Editing, Up: Top
Installing Bash
***************
This chapter provides basic instructions for installing Bash on the
-various supported platforms. The distribution supports nearly every
-version of Unix (and, someday, GNU). Other independent ports exist for
-MS-DOS, OS/2, Windows 95, and Windows NT.
+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, Windows 95/98, and Windows NT.
* Menu:
@@ -6380,18 +6872,45 @@ 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' and `doc' directories, and the each
-directory under `lib'). 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.
+(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
@@ -6411,26 +6930,6 @@ contain the patch level of the Bash distribution, `0' for example. The
script `support/mkconffiles' has been provided to automate the creation
of these files.
- The simplest way to compile Bash is:
-
- 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 awhile. While running, it prints some
- 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.
-
-
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
@@ -6503,7 +7002,7 @@ than `/usr/local' by giving `configure' the option `--prefix=PATH'.
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.
+use PATH as the prefix for installing programs and libraries.
Documentation and other data files will still use the regular prefix.

@@ -6520,7 +7019,8 @@ message saying it can not guess the host type, give it the
type, such as `sun4', or a canonical name with three fields:
`CPU-COMPANY-SYSTEM' (e.g., `sparc-sun-sunos4.1.2').
-See the file `support/config.sub' for the possible values of each field.
+ See the file `support/config.sub' for the possible values of each
+field.

File: bashref.info, Node: Sharing Defaults, Next: Operation Controls, Prev: Specifying the System Type, Up: Installing Bash
@@ -6568,7 +7068,7 @@ operates.
script, and exit.
`configure' also accepts some other, not widely used, boilerplate
-options.
+options. `configure --help' prints the complete list.

File: bashref.info, Node: Optional Features, Prev: Operation Controls, Up: Installing Bash
@@ -6579,8 +7079,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
-`gnu-malloc' or `purify'. To turn off the default use of a package, use
-`--without-PACKAGE'. To configure Bash without a feature that is
+`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
@@ -6589,6 +7089,15 @@ 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 `lib/malloc/malloc.c'. This
+ is not the same `malloc' that appears in GNU libc, but an older
+ version derived from the 4.2 BSD `malloc'. This `malloc' is very
+ fast, but wastes 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
@@ -6600,25 +7109,19 @@ that the Bash `configure' recognizes.
2, but a modified version of the `malloc' from glibc version 1.
This is somewhat slower than the default `malloc', but wastes less
space on a per-allocation basis, and will return memory to the
- operating system under some circumstances.
+ operating system under certain circumstances.
`--with-gnu-malloc'
- Use the GNU version of `malloc' in `lib/malloc/malloc.c'. This is
- not the same `malloc' that appears in GNU libc, but an older
- version derived from the 4.2 BSD `malloc'. This `malloc' is very
- fast, but wastes 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.
+ A synonym for `--with-bash-malloc'.
`--with-installed-readline'
- Define this to make bash link with a locally-installed version of
- Readline rather than the version in lib/readline. This works only
- with readline 4.0 and later versions.
+ Define this to make Bash link with a locally-installed version of
+ Readline rather than the version in `lib/readline'. This works
+ only with Readline 4.1 and later versions.
`--with-purify'
- Define this to use the Purify memory allocation checker from Pure
- Software.
+ 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
@@ -6640,13 +7143,18 @@ 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' and
-`usg-echo-default' are enabled by default, unless the operating system
+`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::.).
@@ -6661,9 +7169,9 @@ does not provide the necessary support.
`--enable-command-timing'
Include support for recognizing `time' as a reserved word and for
- displaying timing statistics for the pipeline following `time'.
- This allows pipelines as well as shell builtins and functions to
- be timed.
+ 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
@@ -6689,16 +7197,21 @@ does not provide the necessary support.
`--enable-help-builtin'
Include the `help' builtin, which displays help on shell builtins
- and variables.
+ and variables (*note Bash Builtins::.).
`--enable-history'
Include command history and the `fc' and `history' builtin
- commands.
+ commands (*note Bash History Facilities::.).
`--enable-job-control'
This enables the job control features (*note Job Control::.), if
the operating system supports them.
+`--enable-net-redirections'
+ This enables the special handling of filenames of the form
+ `/dev/tcp/HOST/PORT' and `/dev/udp/HOST/PORT' when used in
+ redirections (*note Redirections::.).
+
`--enable-process-substitution'
This enables process substitution (*note Process Substitution::.)
if the operating system provides the necessary support.
@@ -6709,6 +7222,11 @@ does not provide the necessary support.
strings. See *Note Printing a Prompt::, for a complete list of
prompt string escape sequences.
+`--enable-progcomp'
+ Enable the programmable completion facilities (*note Programmable
+ Completion::.). If Readline is not enabled, this option has no
+ effect.
+
`--enable-readline'
Include support for command-line editing and history with the Bash
version of the Readline library (*note Command Line Editing::.).
@@ -6723,18 +7241,24 @@ does not provide the necessary support.
menus (*note Conditional Constructs::.).
`--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 makes the Bash
- `echo' behave more like the System V version.
+ 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 2. *Note Bash Builtins::, for a
+ description of the escape sequences that `echo' recognizes.
- The file `config.h.top' contains C Preprocessor `#define' statements
+ 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: bashref.info, Node: Reporting Bugs, Next: Builtin Index, Prev: Installing Bash, Up: Top
+File: bashref.info, Node: Reporting Bugs, Next: Major Differences From The Bourne Shell, Prev: Installing Bash, Up: Top
Reporting Bugs
**************
@@ -6767,7 +7291,318 @@ it provides for filing a bug report.
Please send all reports concerning this manual to <chet@po.CWRU.Edu>.

-File: bashref.info, Node: Builtin Index, Next: Reserved Word Index, Prev: Reporting Bugs, Up: Top
+File: bashref.info, Node: Major Differences From The Bourne Shell, Next: Builtin Index, Prev: Reporting Bugs, Up: Top
+
+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 1003.2 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 SVR4.2 as the baseline reference.
+
+ * Bash is POSIX-conformant, even where the POSIX specification
+ differs from traditional `sh' behavior.
+
+ * 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 two builtin commands, `complete'
+ and `compgen', to manipulate it.
+
+ * Bash has command history (*note Bash History Facilities::.) and the
+ `history' and `fc' builtins to manipulate 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.
+
+ * 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::.).
+
+ * 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 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.
+
+ * Bash implements the full set of POSIX 1003.2 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 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' builtins 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 Bash Builtins::.).
+
+ * Bash has much more optional behavior controllable with the `set'
+ builtin (*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.
+
+ * The `trap' builtin (*note Bourne Shell Builtins::.) allows a
+ `DEBUG' pseudo-signal specification, similar to `EXIT'. Commands
+ specified with a `DEBUG' trap are executed after every simple
+ command. The `DEBUG' trap is not inherited by shell functions.
+
+ * 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 Printing a 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'.
+
+ * 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::.
+
+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 1003.2 special builtins fails, and
+ only for certain failures, as enumerated in the POSIX 1003.2
+ standard.
+
+ * The SVR4.2 shell behaves differently when invoked as `jsh' (it
+ turns on job control).
+
+
+File: bashref.info, Node: Builtin Index, Next: Reserved Word Index, Prev: Major Differences From The Bourne Shell, Up: Top
Index of Shell Builtin Commands
*******************************
@@ -6777,16 +7612,18 @@ Index of Shell Builtin Commands
* .: Bourne Shell Builtins.
* :: Bourne Shell Builtins.
* [: Bourne Shell Builtins.
-* alias: Alias Builtins.
+* alias: Bash Builtins.
* bg: Job Control Builtins.
* bind: Bash Builtins.
* break: Bourne Shell Builtins.
* builtin: Bash Builtins.
* cd: Bourne Shell Builtins.
* command: Bash Builtins.
+* compgen: Programmable Completion Builtins.
+* complete: Programmable Completion Builtins.
* continue: Bourne Shell Builtins.
* declare: Bash Builtins.
-* dirs: The Directory Stack.
+* dirs: Directory Stack Builtins.
* disown: Job Control Builtins.
* echo: Bash Builtins.
* enable: Bash Builtins.
@@ -6805,9 +7642,9 @@ Index of Shell Builtin Commands
* let: Bash Builtins.
* local: Bash Builtins.
* logout: Bash Builtins.
-* popd: The Directory Stack.
+* popd: Directory Stack Builtins.
* printf: Bash Builtins.
-* pushd: The Directory Stack.
+* pushd: Directory Stack Builtins.
* pwd: Bourne Shell Builtins.
* read: Bash Builtins.
* readonly: Bourne Shell Builtins.
@@ -6824,15 +7661,15 @@ Index of Shell Builtin Commands
* typeset: Bash Builtins.
* ulimit: Bash Builtins.
* umask: Bourne Shell Builtins.
-* unalias: Alias Builtins.
+* unalias: Bash Builtins.
* unset: Bourne Shell Builtins.
* wait: Job Control Builtins.

File: bashref.info, Node: Reserved Word Index, Next: Variable Index, Prev: Builtin Index, Up: Top
-Shell Reserved Words
-********************
+Index of Shell Reserved Words
+*****************************
* Menu:
@@ -6883,7 +7720,12 @@ Parameter and Variable Index
* bell-style: Readline Init File Syntax.
* CDPATH: Bourne Shell Variables.
* comment-begin: Readline Init File Syntax.
+* COMP_CWORD: Bash Variables.
+* COMP_LINE: Bash Variables.
+* COMP_POINT: Bash Variables.
+* COMP_WORDS: Bash Variables.
* completion-query-items: Readline Init File Syntax.
+* COMPREPLY: Bash Variables.
* convert-meta: Readline Init File Syntax.
* DIRSTACK: Bash Variables.
* disable-completion: Readline Init File Syntax.
@@ -6893,6 +7735,7 @@ Parameter and Variable Index
* expand-tilde: Readline Init File Syntax.
* FCEDIT: Bash Variables.
* FIGNORE: Bash Variables.
+* FUNCNAME: Bash Variables.
* GLOBIGNORE: Bash Variables.
* GROUPS: Bash Variables.
* histchars: Bash Variables.
@@ -6918,6 +7761,7 @@ Parameter and Variable Index
* LC_COLLATE: Bash Variables.
* LC_CTYPE: Bash Variables.
* LC_MESSAGES: Bash Variables.
+* LC_NUMERIC: Bash Variables.
* LINENO: Bash Variables.
* MACHTYPE: Bash Variables.
* MAIL: Bourne Shell Variables.
@@ -7063,6 +7907,7 @@ Concept Index
* commands, shell: Shell Commands.
* commands, simple: Simple Commands.
* comments, shell: Comments.
+* completion builtins: Programmable Completion Builtins.
* configuration: Basic Installation.
* control operator: Definitions.
* directory stack: The Directory Stack.
@@ -7091,16 +7936,16 @@ Concept Index
* history events: Event Designators.
* history expansion: History Interaction.
* history list: Bash History Facilities.
-* History, how to use: Job Control Variables.
+* History, how to use: Programmable Completion Builtins.
* identifier: Definitions.
* initialization file, readline: Readline Init File.
* installation: Basic Installation.
* interaction, readline: Readline Interaction.
-* interactive shell <1>: Is This Shell Interactive?.
+* interactive shell <1>: Interactive Shells.
* interactive shell: Invoking Bash.
* job: Definitions.
-* job control <1>: Definitions.
-* job control: Job Control Basics.
+* job control <1>: Job Control Basics.
+* job control: Definitions.
* kill ring: Readline Killing Commands.
* killing text: Readline Killing Commands.
* localization: Locale Translation.
@@ -7121,10 +7966,11 @@ Concept Index
* process group: Definitions.
* process group ID: Definitions.
* process substitution: Process Substitution.
+* programmable completion: Programmable Completion.
* prompting: Printing a Prompt.
* quoting: Quoting.
* quoting, ANSI: ANSI-C Quoting.
-* Readline, how to use: Modifiers.
+* Readline, how to use: Job Control Variables.
* redirection: Redirections.
* reserved word: Definitions.
* restricted shell: The Restricted Shell.
@@ -7133,8 +7979,10 @@ Concept Index
* shell function: Shell Functions.
* shell script: Shell Scripts.
* shell variable: Shell Parameters.
+* shell, interactive: Interactive Shells.
* signal: Definitions.
* signal handling: Signals.
+* special builtin <1>: Special Builtins.
* special builtin: Definitions.
* startup files: Bash Startup Files.
* suspending jobs: Job Control Basics.
@@ -7148,120 +7996,126 @@ Concept Index

Tag Table:
-Node: Top1187
-Node: Introduction3146
-Node: What is Bash?3371
-Node: What is a shell?4465
-Node: Definitions6487
-Node: Basic Shell Features9148
-Node: Shell Syntax10371
-Node: Shell Operation10660
-Node: Quoting11954
-Node: Escape Character12979
-Node: Single Quotes13451
-Node: Double Quotes13780
-Node: ANSI-C Quoting14678
-Node: Locale Translation15547
-Node: Comments15968
-Node: Shell Commands16582
-Node: Simple Commands17093
-Node: Pipelines17652
-Node: Lists19179
-Node: Looping Constructs20634
-Node: Conditional Constructs22239
-Node: Command Grouping28177
-Node: Shell Functions29554
-Node: Shell Parameters31518
-Node: Positional Parameters32844
-Node: Special Parameters33593
-Node: Shell Expansions36214
-Node: Brace Expansion38137
-Node: Tilde Expansion39698
-Node: Shell Parameter Expansion42030
-Node: Command Substitution48426
-Node: Arithmetic Expansion49700
-Node: Process Substitution50545
-Node: Word Splitting51439
-Node: Filename Expansion52891
-Node: Pattern Matching54855
-Node: Quote Removal57244
-Node: Redirections57530
-Node: Executing Commands63600
-Node: Simple Command Expansion64267
-Node: Command Search and Execution66190
-Node: Command Execution Environment68193
-Node: Environment70647
-Node: Exit Status72304
-Node: Signals73501
-Node: Shell Scripts75396
-Node: Bourne Shell Features77432
-Node: Bourne Shell Builtins78162
-Node: Bourne Shell Variables92273
-Node: Other Bourne Shell Features93978
-Node: Major Differences From The Bourne Shell94721
-Node: Bash Features106910
-Node: Invoking Bash108013
-Node: Bash Startup Files112198
-Node: Is This Shell Interactive?116342
-Node: Bash Builtins117313
-Node: The Set Builtin138717
-Node: Bash Conditional Expressions145533
-Node: Bash Variables148666
-Node: Shell Arithmetic161096
-Node: Aliases163144
-Node: Alias Builtins165719
-Node: Arrays166335
-Node: The Directory Stack169356
-Node: Printing a Prompt172706
-Node: The Restricted Shell174369
-Node: Bash POSIX Mode175730
-Node: Job Control179891
-Node: Job Control Basics180357
-Node: Job Control Builtins184556
-Node: Job Control Variables188848
-Node: Using History Interactively189998
-Node: Bash History Facilities190677
-Node: Bash History Builtins193018
-Node: History Interaction196386
-Node: Event Designators198938
-Node: Word Designators199865
-Node: Modifiers201114
-Node: Command Line Editing202431
-Node: Introduction and Notation203091
-Node: Readline Interaction204129
-Node: Readline Bare Essentials205321
-Node: Readline Movement Commands206861
-Node: Readline Killing Commands207826
-Node: Readline Arguments209541
-Node: Searching210515
-Node: Readline Init File212263
-Node: Readline Init File Syntax213302
-Node: Conditional Init Constructs222508
-Node: Sample Init File224946
-Node: Bindable Readline Commands228115
-Node: Commands For Moving228865
-Node: Commands For History229712
-Node: Commands For Text232541
-Node: Commands For Killing234508
-Node: Numeric Arguments236657
-Node: Commands For Completion237783
-Node: Keyboard Macros241615
-Node: Miscellaneous Commands242173
-Node: Readline vi Mode246493
-Node: Installing Bash247371
-Node: Basic Installation248448
-Node: Compilers and Options251358
-Node: Compiling For Multiple Architectures252092
-Node: Installation Names253749
-Node: Specifying the System Type254474
-Node: Sharing Defaults255178
-Node: Operation Controls255843
-Node: Optional Features256748
-Node: Reporting Bugs263158
-Node: Builtin Index264229
-Node: Reserved Word Index267632
-Node: Variable Index269090
-Node: Function Index274363
-Node: Concept Index278853
+Node: Top1185
+Node: Introduction3316
+Node: What is Bash?3541
+Node: What is a shell?4642
+Node: Definitions6876
+Node: Basic Shell Features9542
+Node: Shell Syntax10766
+Node: Shell Operation11790
+Node: Quoting13085
+Node: Escape Character14345
+Node: Single Quotes14817
+Node: Double Quotes15152
+Node: ANSI-C Quoting16055
+Node: Locale Translation16957
+Node: Comments17378
+Node: Shell Commands17984
+Node: Simple Commands18865
+Node: Pipelines19488
+Node: Lists21015
+Node: Looping Constructs22529
+Node: Conditional Constructs24976
+Node: Command Grouping30918
+Node: Shell Functions32295
+Node: Shell Parameters34833
+Node: Positional Parameters36159
+Node: Special Parameters37052
+Node: Shell Expansions39711
+Node: Brace Expansion41635
+Node: Tilde Expansion43305
+Node: Shell Parameter Expansion45637
+Node: Command Substitution52439
+Node: Arithmetic Expansion53761
+Node: Process Substitution54606
+Node: Word Splitting55643
+Node: Filename Expansion57095
+Node: Pattern Matching59055
+Node: Quote Removal61450
+Node: Redirections61736
+Node: Executing Commands68607
+Node: Simple Command Expansion69274
+Node: Command Search and Execution71197
+Node: Command Execution Environment73194
+Node: Environment75648
+Node: Exit Status77300
+Node: Signals78497
+Node: Shell Scripts80392
+Node: Shell Builtin Commands82776
+Node: Bourne Shell Builtins84211
+Node: Bash Builtins99107
+Node: The Set Builtin123146
+Node: Special Builtins129959
+Node: Shell Variables130931
+Node: Bourne Shell Variables131367
+Node: Bash Variables133147
+Node: Bash Features147888
+Node: Invoking Bash148770
+Node: Bash Startup Files153441
+Node: Interactive Shells158148
+Node: What is an Interactive Shell?158550
+Node: Is this Shell Interactive?159185
+Node: Interactive Shell Behavior159991
+Node: Bash Conditional Expressions163279
+Node: Shell Arithmetic166574
+Node: Aliases169005
+Node: Arrays171510
+Node: The Directory Stack174530
+Node: Directory Stack Builtins175236
+Node: Printing a Prompt178114
+Node: The Restricted Shell180486
+Node: Bash POSIX Mode181964
+Node: Job Control186258
+Node: Job Control Basics186724
+Node: Job Control Builtins190939
+Node: Job Control Variables195234
+Node: Command Line Editing196384
+Node: Introduction and Notation197382
+Node: Readline Interaction198999
+Node: Readline Bare Essentials200191
+Node: Readline Movement Commands201971
+Node: Readline Killing Commands202927
+Node: Readline Arguments204832
+Node: Searching205806
+Node: Readline Init File207685
+Node: Readline Init File Syntax208739
+Node: Conditional Init Constructs218285
+Node: Sample Init File220723
+Node: Bindable Readline Commands223892
+Node: Commands For Moving225085
+Node: Commands For History225933
+Node: Commands For Text228727
+Node: Commands For Killing230678
+Node: Numeric Arguments232644
+Node: Commands For Completion233770
+Node: Keyboard Macros237602
+Node: Miscellaneous Commands238160
+Node: Readline vi Mode242534
+Node: Programmable Completion243444
+Node: Programmable Completion Builtins248120
+Node: Using History Interactively254226
+Node: Bash History Facilities254905
+Node: Bash History Builtins257466
+Node: History Interaction261038
+Node: Event Designators263590
+Node: Word Designators264517
+Node: Modifiers266146
+Node: Installing Bash267463
+Node: Basic Installation268605
+Node: Compilers and Options271723
+Node: Compiling For Multiple Architectures272457
+Node: Installation Names274114
+Node: Specifying the System Type274837
+Node: Sharing Defaults275544
+Node: Operation Controls276209
+Node: Optional Features277160
+Node: Reporting Bugs284581
+Node: Major Differences From The Bourne Shell285678
+Node: Builtin Index299726
+Node: Reserved Word Index303317
+Node: Variable Index304793
+Node: Function Index310465
+Node: Concept Index314955

End Tag Table
diff --git a/doc/bashref.texi b/doc/bashref.texi
index 4274005b..10b8027d 100644
--- a/doc/bashref.texi
+++ b/doc/bashref.texi
@@ -5,13 +5,13 @@
@c %**end of header
@ignore
-Last Change: Wed Jan 20 16:46:26 EST 1999
+Last Change: Tue Mar 14 11:38:10 EST 2000
@end ignore
-@set EDITION 2.3
-@set VERSION 2.03
-@set UPDATED 20 January 1999
-@set UPDATE-MONTH January 1999
+@set EDITION 2.4
+@set VERSION 2.04
+@set UPDATED 14 March 2000
+@set UPDATE-MONTH March 2000
@iftex
@finalout
@@ -122,8 +122,9 @@ reference on shell behavior.
* Basic Shell Features:: The shell "building blocks".
-* Bourne Shell Features:: Features similar to those found in the
- Bourne shell.
+* 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.
@@ -140,6 +141,10 @@ reference on shell behavior.
* 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.
+
* Builtin Index:: Index of Bash builtin commands.
* Reserved Word Index:: Index of Bash reserved words.
@@ -166,55 +171,61 @@ reference on shell behavior.
@section What is Bash?
Bash is the shell, or command language interpreter,
-that will appear in the @sc{GNU} operating system.
+for the @sc{gnu} operating system.
The name is an acronym for the @samp{Bourne-Again SHell},
-a pun on Steve Bourne, the author of the direct ancestor of the current
-Unix shell @code{/bin/sh},
+a pun on Stephen Bourne, the author of the direct ancestor of
+the current Unix shell @code{/bin/sh},
which appeared in the Seventh Edition Bell Labs Research version
of Unix.
-Bash is an @code{sh}-compatible shell that incorporates useful
+Bash is largely compatible with @code{sh} and incorporates useful
features from the Korn shell @code{ksh} and the C shell @code{csh}.
-It is intended to be a conformant implementation of the @sc{IEEE}
-@sc{POSIX} Shell and Tools specification (@sc{IEEE} Working Group 1003.2).
+It is intended to be a conformant implementation of the @sc{ieee}
+@sc{posix} Shell and Tools specification (@sc{ieee} Working Group 1003.2).
It offers functional improvements over @code{sh} for both interactive and
programming use.
-While the @sc{GNU} operating system will include a version
-of @code{csh}, Bash will be the default shell.
-Like other @sc{GNU} software, Bash is quite portable. It currently runs
+While the @sc{gnu} operating system provides other shells, including
+a version of @code{csh}, Bash is the default shell.
+Like other @sc{gnu} software, Bash is quite portable. It currently runs
on nearly every version of Unix and a few other operating systems @minus{}
-independently-supported ports exist for @sc{MS-DOS}, @sc{OS/2},
-Windows @sc{95}, and Windows @sc{NT}.
+independently-supported ports exist for @sc{ms-dos}, @sc{os/2},
+Windows @sc{95/98}, and Windows @sc{nt}.
@node What is a shell?
@section What is a shell?
At its base, a shell is simply a macro processor that executes
commands. A Unix shell is both a command interpreter, which
-provides the user interface to the rich set of Unix utilities,
+provides the user interface to the rich set of @sc{gnu} utilities,
and a programming language, allowing these utilitites to be
combined. Files containing commands can be created, and become
commands themselves. These new commands have the same status as
-system commands in directories like @file{/bin}, allowing users
+system commands in directories such as @file{/bin}, allowing users
or groups to establish custom environments.
-A shell allows execution of Unix commands, both synchronously and
+A shell allows execution of @sc{gnu} commands, both synchronously and
asynchronously.
The shell waits for synchronous commands to complete before accepting
more input; asynchronous commands continue to execute in parallel
with the shell while it reads and executes additional commands.
The @dfn{redirection} constructs permit
-fine-grained control of the input and output of those commands,
-and the shell allows control over the contents of their
-environment. Unix shells also provide a small set of built-in
+fine-grained control of the input and output of those commands.
+Moreover, the shell allows control over the contents of commands'
+environments.
+Shells may be used interactively or non-interactively: they accept
+input typed from the keyboard or from a file.
+
+Shells also provide a small set of built-in
commands (@dfn{builtins}) implementing functionality impossible
-(e.g., @code{cd}, @code{break}, @code{continue}, and
-@code{exec}), or inconvenient (@code{history}, @code{getopts},
-@code{kill}, or @code{pwd}, for example) to obtain via separate
-utilities. Shells may be used interactively or
-non-interactively: they accept input typed from the keyboard or
-from a file. All of the shell builtins are described in
+or inconvenient to obtain via separate utilities.
+For example, @code{cd}, @code{break}, @code{continue}, and
+@code{exec}) cannot be implemented outside of the shell because
+they directly manipulate the shell itself.
+The @code{history}, @code{getopts}, @code{kill}, or @code{pwd}
+builtins, among others, could be implemented in separate utilities,
+but they are more convenient to use as builtin commands.
+All of the shell builtins are described in
subsequent sections.
While executing commands is essential, most of the power (and
@@ -222,7 +233,7 @@ 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 have begun offering features geared specifically for
+Shells offer features geared specifically for
interactive use rather than to augment the programming language.
These interactive features include job control, command line
editing, history and aliases. Each of these features is
@@ -237,7 +248,7 @@ These definitions are used throughout the remainder of this manual.
@item POSIX
@cindex POSIX
A family of open system standards based on Unix. Bash
-is concerned with @sc{POSIX} 1003.2, the Shell and Tools Standard.
+is concerned with @sc{posix} 1003.2, the Shell and Tools Standard.
@item blank
A space or tab character.
@@ -301,7 +312,7 @@ A @code{control operator} or a @code{redirection operator}.
@item process group
@cindex process group
A collection of related processes each having the same process
-group @sc{ID}.
+group @sc{id}.
@item process group ID
@cindex process group ID
@@ -320,13 +331,13 @@ A synonym for @code{exit status}.
@item signal
@cindex signal
-A mechanism by which a process may be notified by the kernal
+A mechanism by which a process may be notified by the kernel
of an event occurring in the system.
@item special builtin
@cindex special builtin
A shell builtin command that has been classified as special by the
-@sc{POSIX.2} standard.
+@sc{posix} 1003.2 standard.
@item token
@cindex token
@@ -346,7 +357,7 @@ Bash is an acronym for @samp{Bourne-Again SHell}.
The Bourne shell is
the traditional Unix shell originally written by Stephen Bourne.
All of the Bourne shell builtin commands are available in Bash,
-and the rules for evaluation and quoting are taken from the @sc{POSIX}
+and the rules for evaluation and quoting are taken from the @sc{posix}
1003.2 specification for the `standard' Unix shell.
This chapter briefly summarizes the shell's `building blocks':
@@ -377,6 +388,21 @@ and to named files, and how the shell executes commands.
* Comments:: How to specify comments.
@end menu
+When the shell reads input, it proceeds through a
+sequence of operations. If the input indicates the beginning of a
+comment, the shell ignores the comment symbol (@samp{#}), and the rest
+of that line.
+
+Otherwise, roughly speaking, the shell reads its input and
+divides the input into words and operators, employing the quoting rules
+to select which meanings to assign various words and characters.
+
+The shell then parses these tokens into commands and other constructs,
+removes the special meaning of certain words or characters, expands
+others, redirects input and output as needed, executes the specified
+command, waits for the command's exit status, and makes that exit status
+available for further inspection or processing.
+
@node Shell Operation
@subsection Shell Operation
@@ -441,7 +467,12 @@ parameter expansion.
Each of the shell metacharacters (@pxref{Definitions})
has special meaning to the shell and must be quoted if it is to
-represent itself. There are three quoting mechanisms: the
+represent itself.
+When the command history expansion facilities are being used, the
+@var{history expansion} character, usually @samp{!}, must be quoted
+to prevent history expansion. @xref{Bash History Facilities} for
+more details concerning history expansion.
+There are three quoting mechanisms: the
@var{escape character}, single quotes, and double quotes.
@node Escape Character
@@ -456,14 +487,14 @@ the input stream and effectively ignored).
@node Single Quotes
@subsubsection Single Quotes
-Enclosing characters in single quotes preserves the literal value
+Enclosing characters in single quotes (@samp{'}) preserves the literal value
of each character within the quotes. A single quote may not occur
between single quotes, even when preceded by a backslash.
@node Double Quotes
@subsubsection Double Quotes
-Enclosing characters in double quotes preserves the literal value
+Enclosing characters in double quotes (@samp{"}) preserves the literal value
of all characters within the quotes, with the exception of
@samp{$}, @samp{`}, and @samp{\}.
The characters @samp{$} and @samp{`}
@@ -508,6 +539,8 @@ horizontal tab
vertical tab
@item \\
backslash
+@item \'
+single quote
@item \@var{nnn}
the character whose @code{ASCII} code is the octal value @var{nnn}
(one to three digits)
@@ -517,7 +550,8 @@ the character whose @code{ASCII} code is the hexadecimal value @var{nnn}
@end table
@noindent
-The result is single-quoted, as if the dollar sign had not been present.
+The expanded result is single-quoted, as if the dollar sign had not
+been present.
@node Locale Translation
@subsubsection Locale-Specific Translation
@@ -542,12 +576,21 @@ causes that word and all remaining characters on that line to
be ignored. An interactive shell without the @code{interactive_comments}
option enabled does not allow comments. The @code{interactive_comments}
option is on by default in interactive shells.
-@xref{Is This Shell Interactive?}, for a description of what makes
+@xref{Interactive Shells}, for a description of what makes
a shell interactive.
@node Shell Commands
@section Shell Commands
@cindex commands, shell
+
+A simple shell command such as @code{echo a b c} consists of the command
+itself followed by arguments, separated by spaces.
+
+More complex shell commands are composed of simple commands arranged together
+in a variety of ways: in a pipeline in which the output of one command
+becomes the input of a second, in a loop or conditional construct, or in
+some other grouping.
+
@menu
* Simple Commands:: The most common type of command.
* Pipelines:: Connecting the input and output of several
@@ -565,12 +608,13 @@ a shell interactive.
A simple command is the kind of command encountered most often.
It's just a sequence of words separated by @code{blank}s, terminated
by one of the shell's control operators (@pxref{Definitions}). The
-first word generally specifies a command to be executed.
+first word generally specifies a command to be executed, with the
+rest of the words being that command's arguments.
The return status (@pxref{Exit Status}) of a simple command is
its exit status as provided
-by the @sc{POSIX.1} @code{waitpid} function, or 128+@var{n} if the command
-was terminated by signal @var{n}.
+by the @sc{posix} 1003.1 @code{waitpid} function, or 128+@var{n} if
+the command was terminated by signal @var{n}.
@node Pipelines
@subsection Pipelines
@@ -598,7 +642,7 @@ 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 @samp{-p} option changes the output format to that specified
-by @sc{POSIX}.
+by @sc{posix}.
The @code{TIMEFORMAT} variable may be set to a format string that
specifies how the timing information should be displayed.
@xref{Bash Variables}, for a description of the available formats.
@@ -633,7 +677,8 @@ the shell executes the command asynchronously in a subshell.
This is known as executing the command in the @var{background}.
The shell does not wait for the command to finish, and the return
status is 0 (true).
-The standard input for asynchronous commands, in the absence of any
+When job control is not active (@pxref{Job Control}),
+the standard input for asynchronous commands, in the absence of any
explicit redirections, is redirected from @code{/dev/null}.
Commands separated by a @samp{;} are executed sequentially; the shell
@@ -641,27 +686,27 @@ waits for each command to terminate in turn. The return status is the
exit status of the last command executed.
The control operators @samp{&&} and @samp{||}
-denote @sc{AND} lists and @sc{OR} lists, respectively.
-An @sc{AND} list has the form
+denote @sc{and} lists and @sc{or} lists, respectively.
+An @sc{and} list has the form
@example
-@var{command} && @var{command2}
+@var{command1} && @var{command2}
@end example
@noindent
-@var{command2} is executed if, and only if, @var{command}
+@var{command2} is executed if, and only if, @var{command1}
returns an exit status of zero.
-An @sc{OR} list has the form
+An @sc{or} list has the form
@example
-@var{command} || @var{command2}
+@var{command1} || @var{command2}
@end example
@noindent
-@var{command2} is executed if, and only if, @var{command}
+@var{command2} is executed if, and only if, @var{command1}
returns a non-zero exit status.
The return status of
-@sc{AND} and @sc{OR} lists is the exit status of the last command
+@sc{and} and @sc{or} lists is the exit status of the last command
executed in the list.
@node Looping Constructs
@@ -670,7 +715,7 @@ executed in the list.
Bash supports the following looping constructs.
-Note that wherever you see a @samp{;} in the description of a
+Note that wherever a @samp{;} appears in the description of a
command's syntax, it may be replaced with one or more newlines.
@table @code
@@ -708,10 +753,29 @@ for @var{name} [in @var{words} @dots{}]; do @var{commands}; done
@end example
Expand @var{words}, and execute @var{commands} once for each member
in the resultant list, with @var{name} bound to the current member.
-If @samp{in @var{words}} is not present, @samp{in "$@@"} is assumed.
+If @samp{in @var{words}} is not present, the @code{for} command
+executes the @var{commands} once for each positional parameter that is
+set, as if @samp{in "$@@"} had been specified
+(@pxref{Special Parameters}).
The return status is the exit status of the last command that executes.
If there are no items in the expansion of @var{words}, no commands are
executed, and the return status is zero.
+
+An alternate form of the @code{for} command is also supported:
+
+@example
+for (( @var{expr1} ; @var{expr2} ; @var{expr3} )) ; do @var{commands} ; done
+@end example
+First, the arithmetic expression @var{expr1} is evaluated according
+to the rules described below (@pxref{Shell Arithmetic}).
+The arithmetic expression @var{expr2} is then evaluated repeatedly
+until it evaluates to zero.
+Each time @var{expr2} evaluates to a non-zero value, @var{commands} are
+executed and the arithmetic expression @var{expr3} is evaluated.
+If any expression is omitted, it behaves as if it evaluates to 1.
+The return value is the exit status of the last command in @var{list}
+that is executed, or false if any of the expressions is invalid.
+
@end table
The @code{break} and @code{continue} builtins (@pxref{Bourne Shell Builtins})
@@ -892,7 +956,7 @@ True if both @var{expression1} and @var{expression2} are true.
True if either @var{expression1} or @var{expression2} is true.
@end table
@noindent
-The && and || commands do not execute @var{expression2} if the
+The @code{&&} and @code{||} commands do not execute @var{expression2} if the
value of @var{expression1} is sufficient to determine the return
value of the entire conditional expression.
@@ -947,7 +1011,10 @@ The exit status of both of these constructs is the exit status of
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. Shell functions are executed in the current
+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:
@@ -965,12 +1032,22 @@ This list is executed whenever @var{name} is specified as the
name of a command. The exit status of a function is
the exit status of the last command executed in the body.
+Note that for historical reasons, the curly braces that surround
+the body of the function must be separated from the body by
+@code{blank}s or newlines.
+This is because the braces are reserved words and are only recognized
+as such when they are separated by whitespace.
+Also, the @var{command-list} must be terminated with a semicolon
+or a newline.
+
When a function is executed, the arguments to the
function become the positional parameters
during its execution (@pxref{Positional Parameters}).
The special parameter @samp{#} that expands to the number of
positional parameters is updated to reflect the change.
Positional parameter @code{0} is unchanged.
+The @code{FUNCNAME} variable is set to the name of the function
+while the function is executing.
If the builtin command @code{return}
is executed in a function, the function completes and
@@ -1037,9 +1114,12 @@ A @var{positional parameter} is a parameter denoted by one or more
digits, other than the single digit @code{0}. Positional parameters are
assigned from the shell's arguments when it is invoked,
and may be reassigned using the @code{set} builtin command.
-Positional parameter @code{N} may be referenced as @code{$@{N@}}.
-Positional parameters may not be assigned to
-with assignment statements. The positional parameters are
+Positional parameter @code{N} may be referenced as @code{$@{N@}}, or
+as @code{$N} when @code{N} consists of a single digit.
+Positional parameters may not be assigned to with assignment statements.
+The @code{set} and @code{shift} builtins are used to set and
+unset them (@pxref{Shell Builtin Commands}).
+The positional parameters are
temporarily replaced when a shell function is executed
(@pxref{Shell Functions}).
@@ -1086,17 +1166,17 @@ Expands to the exit status of the most recently executed foreground
pipeline.
@item -
-Expands to the current option flags as specified upon invocation,
-by the @code{set}
+(A hyphen.) Expands to the current option flags as specified upon
+invocation, by the @code{set}
builtin command, or those set by the shell itself
(such as the @samp{-i} option).
@item $
-Expands to the process @sc{ID} of the shell. In a @code{()} subshell, it
-expands to the process @sc{ID} of the invoking shell, not the subshell.
+Expands to the process @sc{id} of the shell. In a @code{()} subshell, it
+expands to the process @sc{id} of the invoking shell, not the subshell.
@item !
-Expands to the process @sc{ID} of the most recently executed background
+Expands to the process @sc{id} of the most recently executed background
(asynchronous) command.
@item 0
@@ -1109,6 +1189,7 @@ executed, if one is present. Otherwise, it is set
to the filename used to invoke Bash, as given by argument zero.
@item _
+(An underscore.)
At shell startup, set to the absolute filename of the shell or shell
script being executed as passed in the argument list.
Subsequently, expands to the last argument to the previous command,
@@ -1175,21 +1256,20 @@ is performed.
@cindex brace expansion
@cindex expansion, brace
-Brace expansion
-is a mechanism by which arbitrary strings
-may be generated. This mechanism is similar to
+Brace expansion is a mechanism by which arbitrary strings may be generated.
+This mechanism is similar to
@var{filename expansion} (@pxref{Filename Expansion}),
-but the file names generated
-need not exist. Patterns to be brace expanded take
-the form of an optional @var{preamble},
-followed by a series of comma-separated strings
-between a pair of braces, followed by an optional @var{postscript}.
-The preamble is prepended 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.
+but the file names generated need not exist.
+Patterns to be brace expanded take the form of an optional @var{preamble},
+followed by a series of comma-separated strings between a pair of braces,
+followed by an optional @var{postscript}.
+The preamble is prefixed to each string contained within the braces, and
+the postscript is then appended to each resulting string, expanding left
+to right.
+
+Brace expansions may be nested.
+The results of each expanded string are not sorted; left to right order
+is preserved.
For example,
@example
bash$ echo a@{d,c,b@}e
@@ -1201,6 +1281,8 @@ and any characters special to other expansions are preserved
in the result. It is strictly textual. Bash
does not apply any syntactic interpretation to the context of the
expansion or the text between the braces.
+To avoid conflicts with parameter expansion, the string @samp{$@{}
+is not considered eligible for brace expansion.
A correctly-formed brace expansion must contain unquoted opening
and closing braces, and at least one unquoted comma.
@@ -1320,12 +1402,17 @@ Bash uses the value of the variable formed from the rest of
expanded and that value is used in the rest of the substitution, rather
than the value of @var{parameter} itself.
This is known as @code{indirect expansion}.
+The exception to this is the expansion of $@{!@var{prefix*@}}
+described below.
In each of the cases below, @var{word} is subject to tilde expansion,
parameter expansion, command substitution, and arithmetic expansion.
+
When not performing substring expansion, Bash tests for a parameter
that is unset or null; omitting the colon results in a test only for a
-parameter that is unset.
+parameter that is unset. Put another way, if the colon is included,
+the operator tests for both existence and that the value is not null;
+if the colon is omitted, the operator tests only for existence.
@table @code
@@ -1357,10 +1444,10 @@ is null or unset, nothing is substituted, otherwise the expansion of
@item $@{@var{parameter}:@var{offset}@}
@itemx $@{@var{parameter}:@var{offset}:@var{length}@}
-Expands to up to @var{length} characters of @var{parameter},
+Expands to up to @var{length} characters of @var{parameter}
starting at the character specified by @var{offset}.
If @var{length} is omitted, expands to the substring of
-@var{parameter}, starting at the character specified by @var{offset}.
+@var{parameter} starting at the character specified by @var{offset}.
@var{length} and @var{offset} are arithmetic expressions
(@pxref{Shell Arithmetic}).
This is referred to as Substring Expansion.
@@ -1376,6 +1463,10 @@ members of the array beginning with @code{$@{@var{parameter}[@var{offset}]@}}.
Substring indexing is zero-based unless the positional parameters
are used, in which case the indexing starts at 1.
+@item $@{!@var{prefix}*@}
+Expands to the names of variables whose names begin with @var{prefix},
+separated by the first character of the @code{IFS} special variable.
+
@item $@{#@var{parameter}@}
The length in characters of the expanded value of @var{parameter} is
substituted.
@@ -1448,7 +1539,8 @@ array in turn, and the expansion is the resultant list.
@cindex command substitution
Command substitution allows the output of a command to replace
-the command name. There are two forms:
+the command itself.
+Command substitution occurs when a command is enclosed as follows:
@example
$(@var{command})
@end example
@@ -1509,7 +1601,7 @@ failure to the standard error and no substitution occurs.
@cindex process substitution
Process substitution is supported on systems that support named
-pipes (@sc{FIFO}s) or the @file{/dev/fd} method of naming open files.
+pipes (@sc{fifo}s) or the @file{/dev/fd} method of naming open files.
It takes the form of
@example
<(@var{list})
@@ -1521,12 +1613,15 @@ or
@end example
@noindent
The process @var{list} is run with its input or output connected to a
-@sc{FIFO} or some file in @file{/dev/fd}. The name of this file is
+@sc{fifo} or some file in @file{/dev/fd}. The name of this file is
passed as an argument to the current command as the result of the
expansion. If the @code{>(@var{list})} form is used, writing to
the file will provide input for @var{list}. If the
@code{<(@var{list})} form is used, the file passed as an
argument should be read to obtain the output of @var{list}.
+Note that no space may appear between the @code{<} or @code{>}
+and the left parenthesis, otherwise the construct would be interpreted
+as a redirection.
When available, process substitution is performed simultaneously with
parameter and variable expansion, command substitution, and arithmetic
@@ -1559,8 +1654,7 @@ If the value of @code{IFS} is null, no word splitting occurs.
Explicit null arguments (@code{""} or @code{''}) are retained.
Unquoted implicit null arguments, resulting from the expansion of
-@var{parameter}s
-that have no values, are removed.
+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.
@@ -1579,7 +1673,7 @@ is performed.
After word splitting, unless the @samp{-f} option has been set
(@pxref{The Set Builtin}), Bash scans each word for the characters
-@samp{*}, @samp{?}, @samp{(}, and @samp{[}.
+@samp{*}, @samp{?}, and @samp{[}.
If one of these characters appears, then the word is
regarded as a @var{pattern},
and replaced with an alphabetically sorted list of
@@ -1624,7 +1718,7 @@ is unset.
@cindex matching, pattern
Any character that appears in a pattern, other than the special pattern
-characters described below, matches itself. The NUL character may not
+characters described below, matches itself. The @sc{nul} character may not
occur in a pattern. The special pattern characters must be quoted if
they are to be matched literally.
@@ -1648,7 +1742,7 @@ character in the set.
Within @samp{[} and @samp{]}, @var{character classes} can be specified
using the syntax
@code{[:}@var{class}@code{:]}, where @var{class} is one of the
-following classes defined in the @sc{POSIX.2} standard:
+following classes defined in the @sc{posix} 1003.2 standard:
@example
alnum alpha ascii blank cntrl digit graph lower
print punct space upper xdigit
@@ -1720,7 +1814,7 @@ 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, and filename expansion.
+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,
@@ -1729,8 +1823,8 @@ the command
ls > @var{dirlist} 2>&1
@end example
@noindent
-directs both standard output and standard error to the file
-@var{dirlist}, while the command
+directs both standard output (file descriptor 1) and standard error
+(file descriptor 2) to the file @var{dirlist}, while the command
@example
ls 2>&1 > @var{dirlist}
@end example
@@ -1739,6 +1833,34 @@ directs only the standard output to file @var{dirlist},
because the standard error was duplicated as standard output
before the standard output was redirected to @var{dirlist}.
+Bash handles several filenames specially when they are used in
+redirections, as described in the following table:
+
+@table @code
+@item /dev/fd/@var{fd}
+If @var{fd} is a valid integer, file descriptor @var{fd} is duplicated.
+
+@item /dev/stdin
+File descriptor 0 is duplicated.
+
+@item /dev/stdout
+File descriptor 1 is duplicated.
+
+@item /dev/stderr
+File descriptor 2 is duplicated.
+
+@item /dev/tcp/@var{host}/@var{port}
+If @var{host} is a valid hostname or Internet address, and @var{port}
+is an integer port number, Bash attempts to open a TCP connection
+to the corresponding socket.
+
+@item /dev/udp/@var{host}/@var{port}
+If @var{host} is a valid hostname or Internet address, and @var{port}
+is an integer port number, Bash attempts to open a UDP connection
+to the corresponding socket.
+
+@end table
+
A failure to open or create a file causes the redirection to fail.
@subsection Redirecting Input
@@ -1768,7 +1890,7 @@ The general format for redirecting output is:
If the redirection operator is @samp{>}, and the @code{noclobber}
option to the @code{set} builtin has been enabled, the redirection
-will fail if the filename whose name results from the expansion of
+will fail if the file whose name results from the expansion of
@var{word} exists and is a regular file.
If the redirection operator is @samp{>|}, or the redirection operator is
@samp{>} and the @code{noclobber} option is not enabled, the redirection
@@ -1825,15 +1947,15 @@ The format of here-documents is as follows:
@var{delimiter}
@end example
-No parameter expansion, command substitution, filename
-expansion, or arithmetic expansion is performed on
+No parameter expansion, command substitution, arithmetic expansion,
+or filename expansion is performed on
@var{word}. If any characters in @var{word} are quoted, the
@var{delimiter} is the result of quote removal on @var{word},
and the lines in the here-document are not expanded.
If @var{word} is unquoted,
all lines of the here-document are subjected to parameter expansion,
command substitution, and arithmetic expansion. In the latter
-case, the pair @code{\newline} is ignored, and @samp{\}
+case, the character sequence @code{\newline} is ignored, and @samp{\}
must be used to quote the characters
@samp{\}, @samp{$}, and @samp{`}.
@@ -1965,7 +2087,7 @@ actions are taken.
@item
If the command name contains no slashes, the shell attempts to
locate it. If there exists a shell function by that name, that
-function is invoked as described above in @ref{Shell Functions}.
+function is invoked as described in @ref{Shell Functions}.
@item
If the name does not match a function, the shell searches for
@@ -2045,7 +2167,7 @@ options enabled by @code{shopt}
shell aliases defined with @code{alias} (@pxref{Aliases})
@item
-various process IDs, including those of background jobs
+various process @sc{id}s, including those of background jobs
(@pxref{Lists}), the value of @code{$$}, and the value of
@code{$PPID}
@@ -2097,8 +2219,8 @@ When a program is invoked it is given an array of strings
called the @var{environment}.
This is a list of name-value pairs, of the form @code{name=value}.
-Bash allows you to manipulate the environment in several
-ways. On invocation, the shell scans its own environment and
+Bash provides several ways to manipulate the environment.
+On invocation, the shell scans its own environment and
creates a parameter for each name found, automatically marking
it for @var{export}
to child processes. Executed commands inherit the environment.
@@ -2137,8 +2259,8 @@ A non-zero exit status indicates failure.
This seemingly counter-intuitive scheme is used so there
is one well-defined way to indicate success and a variety of
ways to indicate various failure modes.
-When a command terminates on a fatal signal whose number is @var{n},
-Bash uses the value 128+@var{n} as the exit status.
+When a command terminates on a fatal signal whose number is @var{N},
+Bash uses the value 128+@var{N} as the exit status.
If a command is not found, the child process created to
execute it returns a status of 127. If a command is found
@@ -2238,10 +2360,14 @@ exception that the locations of commands remembered by the parent
(see the description of @code{hash} in @ref{Bourne Shell Builtins})
are retained by the child.
-Most versions of Unix make this a part of the kernel's command
+Most versions of Unix make this a part of the operating system's command
execution mechanism. If the first line of a script begins with
the two characters @samp{#!}, the remainder of the line specifies
-an interpreter for the program. The arguments to the interpreter
+an interpreter for the program.
+Thus, you can specify Bash, @code{awk}, Perl, or some other
+interpreter and write the rest of the script file in that language.
+
+The arguments to the interpreter
consist of a single optional argument following the interpreter
name on the first line of the script file, followed by the name of
the script file, followed by the rest of the arguments. Bash
@@ -2249,32 +2375,52 @@ 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.
-@node Bourne Shell Features
-@chapter Bourne Shell Style Features
+Bash scripts often begin with @code{#! /bin/bash} (assuming that
+Bash has been installed in @file{/bin}), since this ensures that
+Bash will be used to interpret the script, even if it is executed
+under another shell.
+
+@node Shell Builtin Commands
+@chapter Shell Builtin Commands
@menu
* Bourne Shell Builtins:: Builtin commands inherited from the Bourne
Shell.
-* Bourne Shell Variables:: Variables which Bash uses in the same way
- as the Bourne Shell.
-* Other Bourne Shell Features:: Addtional aspects of Bash which behave in
- the same way as the Bourne Shell.
+* Bash Builtins:: Table of builtins specific to Bash.
+* The Set Builtin:: This builtin is so overloaded it
+ deserves its own section.
+* Special Builtins:: Builtin commands classified specially by
+ POSIX.2.
@end menu
-This section briefly summarizes things which Bash inherits from
-the Bourne Shell: builtins, variables, and other features.
-It also lists the significant differences between Bash and the Bourne Shell.
-Many of the builtins have been extended by @sc{POSIX} or Bash.
+Builtin commands are contained within the shell itself.
+When the name of a builtin command is used as the first word of
+a simple command (@pxref{Simple Commands}), the shell executes
+the command directly, without invoking another program.
+Builtin commands are necessary to implement functionality impossible
+or inconvenient to obtain with separate utilities.
+
+This section briefly the builtins which Bash inherits from
+the Bourne Shell, as well as the builtin commands which are unique
+to or have been extended in Bash.
+
+Several builtin commands are described in other chapters: builtin
+commands which provide the Bash interface to the job control
+facilities (@pxref{Job Control Builtins}), the directory stack
+(@pxref{Directory Stack Builtins}), the command history
+(@pxref{Bash History Builtins}), and the programmable completion
+facilities (@pxref{Programmable Completion Builtins}).
+
+Many of the builtins have been extended by @sc{posix} or Bash.
@node Bourne Shell Builtins
@section Bourne Shell Builtins
-The following shell builtin commands are inherited from the Bourne
-Shell. These commands are implemented as specified by the @sc{POSIX}
-1003.2 standard.
+The following shell builtin commands are inherited from the Bourne Shell.
+These commands are implemented as specified by the @sc{posix} 1003.2 standard.
@table @code
-@item :
+@item : @r{(a colon)}
@btindex :
@example
: [@var{arguments}]
@@ -2282,14 +2428,14 @@ Shell. These commands are implemented as specified by the @sc{POSIX}
Do nothing beyond expanding @var{arguments} and performing redirections.
The return status is zero.
-@item .
+@item . @r{(a period)}
@btindex .
@example
. @var{filename} [@var{arguments}]
@end example
Read and execute commands from the @var{filename} argument in the
current shell context. If @var{filename} does not contain a slash,
-the @code{$PATH} variable is used to find
+the @code{PATH} variable is used to find
@var{filename}. The current directory is searched if @var{filename}
is not found in @code{$PATH}.
If any @var{arguments} are supplied, they become the positional
@@ -2298,6 +2444,7 @@ parameters are unchanged.
The return status is the exit status of the last command executed, or
zero if no commands are executed. If @var{filename} is not found, or
cannot be read, the return status is non-zero.
+This builtin is equivalent to @code{source}.
@item break
@btindex break
@@ -2355,8 +2502,8 @@ exec [-cl] [-a @var{name}] [@var{command} [@var{arguments}]]
@end example
If @var{command}
is supplied, it replaces the shell without creating a new process.
-If the @samp{-l} option is supplied, the shell places a dash in the
-zeroth arg passed to @var{command}.
+If the @samp{-l} option is supplied, the shell places a dash at the
+beginning of the zeroth arg passed to @var{command}.
This is what the @code{login} program does.
The @samp{-c} option causes @var{command} to be executed with an empty
environment.
@@ -2372,6 +2519,7 @@ return status is zero; otherwise the return status is non-zero.
exit [@var{n}]
@end example
Exit the shell, returning a status of @var{n} to the shell's parent.
+If @var{n} is omitted, the exit status is that of the last command executed.
Any trap on @code{EXIT} is executed before the shell terminates.
@item export
@@ -2396,9 +2544,11 @@ with a name that is not a shell function.
getopts @var{optstring} @var{name} [@var{args}]
@end example
@code{getopts} is used by shell scripts to parse positional parameters.
-@var{optstring} contains the option letters to be recognized; if a letter
-is followed by a colon, the option is expected to have an
+@var{optstring} contains the option characters to be recognized; if a
+character is followed by a colon, the option is expected to have an
argument, which should be separated from it by white space.
+The colon (@samp{:}) and question mark (@samp{?}) may not be
+used as option characters.
Each time it is invoked, @code{getopts}
places the next option in the shell variable @var{name}, initializing
@var{name} if it does not exist,
@@ -2463,10 +2613,10 @@ option is supplied.
@example
pwd [-LP]
@end example
-Print the current working directory.
-If the @samp{-P} option is supplied, the path printed will not
+Print the absolute pathname of the current working directory.
+If the @samp{-P} option is supplied, the pathname printed will not
contain symbolic links.
-If the @samp{-L} option is supplied, the path printed may contain
+If the @samp{-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
@@ -2496,12 +2646,14 @@ or the @samp{-f} option is supplied with a name that is not a shell function.
return [@var{n}]
@end example
Cause a shell function to exit with the return value @var{n}.
+If @var{n} is not supplied, the return value is the exit status of the
+last command executed in the function.
This may also be used to terminate execution of a script being executed
-with the @code{.} builtin, returning either @var{n} or the exit status
-of the last command executed within the script as the exit status of the
-script.
+with the @code{.} (or @code{source}) builtin, returning either @var{n} or
+the exit status of the last command executed within the script as the exit
+status of the script.
The return status is false if @code{return} is used outside a function
-and not during the execution of a script by @samp{.}.
+and not during the execution of a script by @code{.} or @code{source}.
@item shift
@btindex shift
@@ -2515,6 +2667,7 @@ Parameters represented by the numbers @code{$#} to @var{n}+1 are unset.
@var{n} must be a non-negative number less than or equal to @code{$#}.
If @var{n} is zero or greater than @code{$#}, the positional parameters
are not changed.
+If @var{n} is not supplied, it is assumed to be 1.
The return status is zero unless @var{n} is greater than @code{$#} or
less than zero, non-zero otherwise.
@@ -2527,6 +2680,9 @@ Each operator and operand must be a separate argument.
Expressions are composed of the primaries described below in
@ref{Bash Conditional Expressions}.
+When the @code{[} form is used, the last argument to the command must
+be a @code{]}.
+
Expressions may be combined using the following operators, listed in
decreasing order of precedence.
@@ -2608,8 +2764,9 @@ equal to @samp{-}, all specified signals are reset to the values
they had when the shell was started.
If @var{arg} is the null string, then the signal specified by
each @var{sigspec} is ignored by the shell and commands it invokes.
-If @var{arg} is @samp{-p}, the shell displays the trap commands
-associated with each @var{sigspec}. If no arguments are supplied, or
+If @var{arg} is not present and @samp{-p} has been supplied,
+the shell displays the trap commands associated with each @var{sigspec}.
+If no arguments are supplied, or
only @samp{-p} is given, @code{trap} prints the list of commands
associated with each signal number in a form that may be reused as
shell input.
@@ -2646,6 +2803,10 @@ is omitted, the output is in a form that may be reused as input.
The return status is zero if the mode is successfully changed or if
no @var{mode} argument is supplied, and non-zero otherwise.
+Note that when the mode is interpreted as an octal number, each number
+of the umask is subtracted from @code{7}. Thus, a umask of @code{022}
+results in permissions of @code{755}.
+
@item unset
@btindex unset
@example
@@ -2661,724 +2822,36 @@ The return status is zero unless a @var{name} does not exist or is
readonly.
@end table
-@node Bourne Shell Variables
-@section Bourne Shell Variables
-
-Bash uses certain shell variables in the same way as the Bourne shell.
-In some cases, Bash assigns a default value to the variable.
-
-@vtable @code
-
-@item CDPATH
-A colon-separated list of directories used as a search path for
-the @code{cd} builtin command.
-
-@item HOME
-The current user's home directory; the default for the @code{cd} builtin
-command.
-The value of this variable is also used by tilde expansion
-(@pxref{Tilde Expansion}).
-
-@item IFS
-A list of characters that separate fields; used when the shell splits
-words as part of expansion.
-
-@item MAIL
-If this parameter is set to a filename and the @code{MAILPATH} variable
-is not set, Bash informs the user of the arrival of mail in
-the specified file.
-
-@item MAILPATH
-A colon-separated list of filenames which the shell periodically checks
-for new mail.
-Each list entry can specify the message that is printed when new mail
-arrives in the mail file by separating the file name from the message with
-a @samp{?}.
-When used in the text of the message, @code{$_} expands to the name of
-the current mail file.
-
-@item OPTARG
-The value of the last option argument processed by the @code{getopts} builtin.
-
-@item OPTIND
-The index of the last option argument processed by the @code{getopts} builtin.
-
-@item PATH
-A colon-separated list of directories in which the shell looks for
-commands.
-
-@item PS1
-The primary prompt string. The default value is @samp{\s-\v\$ }.
-
-@item PS2
-The secondary prompt string. The default value is @samp{> }.
-
-@end vtable
-
-@node Other Bourne Shell Features
-@section Other Bourne Shell Features
-
-@menu
-* Major Differences From The Bourne Shell:: Major differences between
- Bash and the Bourne shell.
-@end menu
-
-Bash implements essentially the same grammar, parameter and
-variable expansion, redirection, and quoting as the Bourne Shell.
-Bash uses the @sc{POSIX} 1003.2 standard as the specification of
-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
-subsequent sections.
-
-@node Major Differences From The Bourne Shell
-@subsection Major Differences From The SVR4.2 Bourne Shell
-
-@itemize @bullet
-
-@item
-Bash is @sc{POSIX}-conformant, even where the @sc{POSIX} specification
-differs from traditional @code{sh} behavior.
-
-@item
-Bash has multi-character invocation options (@pxref{Invoking Bash}).
-
-@item
-Bash has command-line editing (@pxref{Command Line Editing}) and
-the @code{bind} builtin.
-
-@item
-Bash has command history (@pxref{Bash History Facilities}) and the
-@code{history} and @code{fc} builtins to manipulate it.
-
-@item
-Bash implements @code{csh}-like history expansion
-(@pxref{History Interaction}).
-
-@item
-Bash has one-dimensional array variables (@pxref{Arrays}), and the
-appropriate variable expansions and assignment syntax to use them.
-Several of the Bash builtins take options to act on arrays.
-Bash provides a number of built-in array variables.
-
-@item
-The @code{$'@dots{}'} quoting syntax, which expands ANSI-C
-backslash-escaped characters in the text between the single quotes,
-is supported (@pxref{ANSI-C Quoting}).
-
-@item
-Bash supports the @code{$"@dots{}"} quoting syntax to do
-locale-specific translation of the characters between the double
-quotes. The @samp{-D}, @samp{--dump-strings}, and @samp{--dump-po-strings}
-invocation options list the translatable strings found in a script
-(@pxref{Locale Translation}).
-
-@item
-Bash implements the @code{!} keyword to negate the return value of
-a pipeline (@pxref{Pipelines}).
-Very useful when an @code{if} statement needs to act only if a test fails.
-
-@item
-Bash has the @code{time} reserved word and command timing (@pxref{Pipelines}).
-The display of the timing statistics may be controlled with the
-@code{TIMEFORMAT} variable.
-
-@item
-Bash includes the @code{select} compound command, which allows the
-generation of simple menus (@pxref{Conditional Constructs}).
-
-@item
-Bash includes the @code{[[} compound command, which makes conditional
-testing part of the shell grammar (@pxref{Conditional Constructs}).
-
-@item
-Bash includes brace expansion (@pxref{Brace Expansion}) and tilde
-expansion (@pxref{Tilde Expansion}).
-
-@item
-Bash implements command aliases and the @code{alias} and @code{unalias}
-builtins (@pxref{Aliases}).
-
-@item
-Bash provides shell arithmetic, the @code{((} compound command
-(@pxref{Conditional Constructs}),
-and arithmetic expansion (@pxref{Shell Arithmetic}).
-
-@item
-Variables present in the shell's initial environment are automatically
-exported to child processes. The Bourne shell does not normally do
-this unless the variables are explicitly marked using the @code{export}
-command.
-
-@item
-Bash includes the @sc{POSIX} pattern removal @samp{%}, @samp{#}, @samp{%%}
-and @samp{##} expansions to remove leading or trailing substrings from
-variable values (@pxref{Shell Parameter Expansion}).
-
-@item
-The expansion @code{$@{#xx@}}, which returns the length of @code{$@{xx@}},
-is supported (@pxref{Shell Parameter Expansion}).
-
-@item
-The expansion @code{$@{var:}@var{offset}@code{[:}@var{length}@code{]@}},
-which expands to the substring of @code{var}'s value of length
-@var{length}, beginning at @var{offset}, is present
-(@pxref{Shell Parameter Expansion}).
-
-@item
-The expansion
-@code{$@{var/[/]}@var{pattern}@code{[/}@var{replacement}@code{]@}},
-which matches @var{pattern} and replaces it with @var{replacement} in
-the value of @code{var}, is available (@pxref{Shell Parameter Expansion}).
-
-@item
-Bash has @var{indirect} variable expansion using @code{$@{!word@}}
-(@pxref{Shell Parameter Expansion}).
-
-@item
-Bash can expand positional parameters beyond @code{$9} using
-@code{$@{@var{num}@}}.
-
-@item
-The @sc{POSIX} @code{$()} form of command substitution
-is implemented (@pxref{Command Substitution}),
-and preferred to the Bourne shell's @code{``} (which
-is also implemented for backwards compatibility).
-
-@item
-Bash has process substitution (@pxref{Process Substitution}).
-
-@item
-Bash automatically assigns variables that provide information about the
-current user (@code{UID}, @code{EUID}, and @code{GROUPS}), the current host
-(@code{HOSTTYPE}, @code{OSTYPE}, @code{MACHTYPE}, and @code{HOSTNAME}),
-and the instance of Bash that is running (@code{BASH},
-@code{BASH_VERSION}, and @code{BASH_VERSINFO}). @xref{Bash Variables},
-for details.
-
-@item
-The @code{IFS} variable is used to split only the results of expansion,
-not all words (@pxref{Word Splitting}).
-This closes a longstanding shell security hole.
-
-@item
-Bash implements the full set of @sc{POSIX.2} filename expansion operators,
-including @var{character classes}, @var{equivalence classes}, and
-@var{collating symbols} (@pxref{Filename Expansion}).
-
-@item
-Bash implements extended pattern matching features when the @code{extglob}
-shell option is enabled (@pxref{Pattern Matching}).
-
-@item
-It is possible to have a variable and a function with the same name;
-@code{sh} does not separate the two name spaces.
-
-@item
-Bash functions are permitted to have local variables using the
-@code{local} builtin, and thus useful recursive functions may be written.
-
-@item
-Variable assignments preceding commands affect only that command, even
-builtins and functions (@pxref{Environment}).
-In @code{sh}, all variable assignments
-preceding commands are global unless the command is executed from the
-file system.
-
-@item
-Bash performs filename expansion on filenames specified as operands
-to input and output redirection operators.
-
-@item
-Bash contains the @samp{<>} redirection operator, allowing a file to be
-opened for both reading and writing, and the @samp{&>} redirection
-operator, for directing standard output and standard error to the same
-file (@pxref{Redirections}).
-
-@item
-The @code{noclobber} option is available to avoid overwriting existing
-files with output redirection (@pxref{The Set Builtin}).
-The @samp{>|} redirection operator may be used to override @code{noclobber}.
-
-@item
-The Bash @code{cd} and @code{pwd} builtins (@pxref{Bourne Shell Builtins})
-each take @samp{-L} and @samp{-P} builtins to switch between logical and
-physical modes.
-
-@item
-Bash allows a function to override a builtin with the same name, and provides
-access to that builtin's functionality within the function via the
-@code{builtin} and @code{command} builtins (@pxref{Bash Builtins}).
-
-@item
-The @code{command} builtin allows selective disabling of functions
-when command lookup is performed (@pxref{Bash Builtins}).
-
-@item
-Individual builtins may be enabled or disabled using the @code{enable}
-builtin (@pxref{Bash Builtins}).
-
-@item
-The Bash @code{exec} builtin takes additional options that allow users
-to control the contents of the environment passed to the executed
-command, and what the zeroth argument to the command is to be
-(@pxref{Bourne Shell Builtins}).
-
-@item
-Shell functions may be exported to children via the environment
-using @code{export -f} (@pxref{Shell Functions}).
-
-@item
-The Bash @code{export}, @code{readonly}, and @code{declare} builtins can
-take a @samp{-f} option to act on shell functions, a @samp{-p} option to
-display variables with various attributes set in a format that can be
-used as shell input, a @samp{-n} option to remove various variable
-attributes, and @samp{name=value} arguments to set variable attributes
-and values simultaneously.
-
-@item
-The Bash @code{hash} builtin allows a name to be associated with
-an arbitrary filename, even when that filename cannot be found by
-searching the @code{$PATH}, using @samp{hash -p}
-(@pxref{Bourne Shell Builtins}).
-
-@item
-Bash includes a @code{help} builtin for quick reference to shell
-facilities (@pxref{Bash Builtins}).
-
-@item
-The @code{printf} builtin is available to display formatted output
-(@pxref{Bash Builtins}).
-
-@item
-The Bash @code{read} builtin (@pxref{Bash Builtins})
-will read a line ending in @samp{\} with
-the @samp{-r} option, and will use the @code{REPLY} variable as a
-default if no arguments are supplied. The Bash @code{read} builtin
-also accepts a prompt string with the @samp{-p} option and will use
-Readline to obtain the line when given the @samp{-e} option.
-
-@item
-The @code{return} builtin may be used to abort execution of scripts
-executed with the @code{.} or @code{source} builtins
-(@pxref{Bourne Shell Builtins}).
-
-@item
-Bash includes the @code{shopt} builtin, for finer control of shell
-optional capabilities (@pxref{Bash Builtins}).
-
-@item
-Bash has much more optional behavior controllable with the @code{set}
-builtin (@pxref{The Set Builtin}).
-
-@item
-The @code{test} builtin (@pxref{Bourne Shell Builtins})
-is slightly different, as it implements the @sc{POSIX} algorithm,
-which specifies the behavior based on the number of arguments.
-
-@item
-The @code{trap} builtin (@pxref{Bourne Shell Builtins})
-allows a @code{DEBUG} pseudo-signal specification,
-similar to @code{EXIT}. Commands specified with a @code{DEBUG} trap are
-executed after every simple command. The @code{DEBUG} trap is not
-inherited by shell functions.
-
-@item
-The Bash @code{type} builtin is more extensive and gives more information
-about the names it finds (@pxref{Bash Builtins}).
-
-@item
-The Bash @code{umask} builtin permits a @samp{-p} option to cause
-the output to be displayed in the form of a @code{umask} command
-that may be reused as input (@pxref{Bourne Shell Builtins}).
-
-@item
-Bash implements a @code{csh}-like directory stack, and provides the
-@code{pushd}, @code{popd}, and @code{dirs} builtins to manipulate it
-(@pxref{The Directory Stack}).
-Bash also makes the directory stack visible as the value of the
-@code{DIRSTACK} shell variable.
-
-@item
-Bash interprets special backslash-escaped characters in the prompt
-strings when interactive (@pxref{Printing a Prompt}).
-
-@item
-The Bash restricted mode is more useful (@pxref{The Restricted Shell});
-the @sc{SVR4.2} shell restricted mode is too limited.
-
-@item
-The @code{disown} builtin can remove a job from the internal shell
-job table (@pxref{Job Control Builtins}) or suppress the sending
-of @code{SIGHUP} to a job when the shell exits as the result of a
-@code{SIGHUP}.
-
-@item
-The @sc{SVR4.2} shell has two privilege-related builtins
-(@code{mldmode} and @code{priv}) not present in Bash.
-
-@item
-Bash does not have the @code{stop} or @code{newgrp} builtins.
-
-@item
-Bash does not use the @code{SHACCT} variable or perform shell accounting.
-
-@item
-The @sc{SVR4.2} @code{sh} uses a @code{TIMEOUT} variable like Bash uses
-@code{TMOUT}.
-
-@end itemize
-
-@noindent
-More features unique to Bash may be found in @ref{Bash Features}.
-
-@subsection 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 @sc{SVR4.2} shell. For instance:
-
-@itemize @bullet
-
-@item
-Bash does not fork a subshell when redirecting into or out of
-a shell control structure such as an @code{if} or @code{while}
-statement.
-
-@item
-Bash does not allow unbalanced quotes. The @sc{SVR4.2} shell will silently
-insert a needed closing quote at @code{EOF} under certain circumstances.
-This can be the cause of some hard-to-find errors.
-
-@item
-The @sc{SVR4.2} shell uses a baroque memory management scheme based on
-trapping @code{SIGSEGV}. If the shell is started from a process with
-@code{SIGSEGV} blocked (e.g., by using the @code{system()} C library
-function call), it misbehaves badly.
-
-@item
-In a questionable attempt at security, the @sc{SVR4.2} shell,
-when invoked without the @samp{-p} option, will alter its real
-and effective @sc{UID} and @sc{GID} if they are less than some
-magic threshold value, commonly 100.
-This can lead to unexpected results.
-
-@item
-The @sc{SVR4.2} shell does not allow users to trap @code{SIGSEGV},
-@code{SIGALRM}, or @code{SIGCHLD}.
-
-@item
-The @sc{SVR4.2} shell does not allow the @code{IFS}, @code{MAILCHECK},
-@code{PATH}, @code{PS1}, or @code{PS2} variables to be unset.
-
-@item
-The @sc{SVR4.2} shell treats @samp{^} as the undocumented equivalent of
-@samp{|}.
-
-@item
-Bash allows multiple option arguments when it is invoked (@code{-x -v});
-the @sc{SVR4.2} shell allows only one option argument (@code{-xv}). In
-fact, some versions of the shell dump core if the second argument begins
-with a @samp{-}.
-
-@item
-The @sc{SVR4.2} shell exits a script if any builtin fails; Bash exits
-a script only if one of the @sc{POSIX.2} special builtins fails, and
-only for certain failures, as enumerated in the @sc{POSIX.2} standard.
-
-@item
-The @sc{SVR4.2} shell behaves differently when invoked as @code{jsh}
-(it turns on job control).
-@end itemize
-
-@node Bash Features
-@chapter Bash Features
-
-This section describes features unique to Bash.
-
-@menu
-* Invoking Bash:: Command line options that you can give
- to Bash.
-* Bash Startup Files:: When and how Bash executes scripts.
-* Is This Shell Interactive?:: Determining the state of a running Bash.
-* Bash Builtins:: Table of builtins specific to Bash.
-* The Set Builtin:: This builtin is so overloaded it
- deserves its own section.
-* Bash Conditional Expressions:: Primitives used in composing expressions for
- the @code{test} builtin.
-* Bash Variables:: List of variables that exist in Bash.
-* Shell Arithmetic:: Arithmetic on shell variables.
-* Aliases:: Substituting one command for another.
-* Arrays:: Array Variables.
-* The Directory Stack:: History of visited directories.
-* Printing a Prompt:: Controlling the PS1 string.
-* The Restricted Shell:: A more controlled mode of shell execution.
-* Bash POSIX Mode:: Making Bash behave more closely to what
- the POSIX standard specifies.
-@end menu
-
-@node Invoking Bash
-@section Invoking Bash
-
-@example
-bash [long-opt] [-ir] [-abefhkmnptuvxdBCDHP] [-o @var{option}] [@var{argument} @dots{}]
-bash [long-opt] [-abefhkmnptuvxdBCDHP] [-o @var{option}] -c @var{string} [@var{argument} @dots{}]
-bash [long-opt] -s [-abefhkmnptuvxdBCDHP] [-o @var{option}] [@var{argument} @dots{}]
-@end example
-
-In addition to the single-character shell command-line options
-(@pxref{The Set Builtin}), there are several multi-character
-options that you can use. These options must appear on the command
-line before the single-character options in order for them
-to be recognized.
-
-@table @code
-@item --dump-po-strings
-Equivalent to @samp{-D}, but the output is in the GNU @code{gettext}
-PO (portable object) file format.
-
-@item --dump-strings
-Equivalent to @samp{-D}.
-
-@item --help
-Display a usage message on standard output and exit sucessfully.
-
-@item --login
-Make this shell act as if it were directly invoked by login.
-This is equivalent to @samp{exec -l bash} but can be issued from
-another shell, such as @code{csh}. @samp{exec bash --login}
-will replace the current shell with a Bash login shell.
-
-@item --noediting
-Do not use the @sc{GNU} Readline library (@pxref{Command Line Editing})
-to read interactive command lines.
-
-@item --noprofile
-Don't load the system-wide startup file @file{/etc/profile}
-or any of the personal initialization files
-@file{~/.bash_profile}, @file{~/.bash_login}, or @file{~/.profile}
-when Bash is invoked as a login shell.
-
-@item --norc
-Don't read the @file{~/.bashrc} initialization file in an
-interactive shell. This is on by default if the shell is
-invoked as @code{sh}.
-
-@item --posix
-Change the behavior of Bash where the default operation differs
-from the @sc{POSIX} 1003.2 standard to match the standard. This
-is intended to make Bash behave as a strict superset of that
-standard. @xref{Bash POSIX Mode}, for a description of the Bash
-@sc{POSIX} mode.
-
-@item --rcfile @var{filename}
-Execute commands from @var{filename} (instead of @file{~/.bashrc})
-in an interactive shell.
-
-@item --restricted
-Make the shell a restricted shell (@pxref{The Restricted Shell}).
-
-@item --verbose
-Equivalent to @samp{-v}.
-
-@item --version
-Show version information for this instance of
-Bash on the standard output and exit successfully.
-
-@end table
-
-There are several single-character options that may be supplied at
-invocation which are not available with the @code{set} builtin.
-
-@table @code
-@item -c @var{string}
-Read and execute commands from @var{string} after processing the
-options, then exit. Any remaining arguments are assigned to the
-positional parameters, starting with @code{$0}.
-
-@item -i
-Force the shell to run interactively.
-
-@item -r
-Make the shell a restricted shell (@pxref{The Restricted Shell}).
-
-@item -s
-If this option is present, or if no arguments remain after option
-processing, then commands are read from the standard input.
-This option allows the positional parameters to be set
-when invoking an interactive shell.
-
-@item -D
-A list of all double-quoted strings preceded by @samp{$}
-is printed on the standard ouput.
-These are the strings that
-are subject to language translation when the current locale
-is not @code{C} or @code{POSIX} (@pxref{Locale Translation}).
-This implies the @samp{-n} option; no commands will be executed.
-
-@item --
-A @code{--} signals the end of options and disables further option
-processing.
-Any arguments after the @code{--} are treated as filenames and arguments.
-
-@end table
-
-@cindex interactive shell
-An @emph{interactive} shell is one whose input and output are both
-connected to terminals (as determined by @code{isatty(3)}), or one
-started with the @samp{-i} option.
-
-If arguments remain after option processing, and neither the
-@samp{-c} nor the @samp{-s}
-option has been supplied, the first argument is assumed to
-be the name of a file containing shell commands (@pxref{Shell Scripts}).
-When Bash is invoked in this fashion, @code{$0}
-is set to the name of the file, and the positional parameters
-are set to the remaining arguments.
-Bash reads and executes commands from this file, then exits.
-Bash's exit status is the exit status of the last command executed
-in the script. If no commands are executed, the exit status is 0.
-
-@node Bash Startup Files
-@section Bash Startup Files
-@cindex startup files
-
-This section describs how Bash executes its startup files.
-If any of the files exist but cannot be read, Bash reports an error.
-Tildes are expanded in file names as described above under
-Tilde Expansion (@pxref{Tilde Expansion}).
-
-When Bash is invoked as an interactive login shell, or as a
-non-interactive shell with the @samp{--login} option, it first reads and
-executes commands from the file @file{/etc/profile}, if that file exists.
-After reading that file, it looks for @file{~/.bash_profile},
-@file{~/.bash_login}, and @file{~/.profile}, in that order, and reads
-and executes commands from the first one that exists and is readable.
-The @samp{--noprofile} option may be used when the shell is started to
-inhibit this behavior.
-
-When a login shell exits, Bash reads and executes commands from
-the file @file{~/.bash_logout}, if it exists.
-
-When an interactive shell that is not a login shell is started, Bash
-reads and executes commands from @file{~/.bashrc}, if that file exists.
-This may be inhibited by using the @samp{--norc} option.
-The @samp{--rcfile @var{file}} option will force Bash to read and
-execute commands from @var{file} instead of @file{~/.bashrc}.
-
-So, typically, your @file{~/.bash_profile} contains the line
-@example
-@code{if [ -f @file{~/.bashrc} ]; then . @file{~/.bashrc}; fi}
-@end example
-@noindent
-after (or before) any login-specific initializations.
-
-When Bash is started non-interactively, to run a shell script,
-for example, it looks for the variable @code{BASH_ENV} in the environment,
-expands its value if it appears there, and uses the expanded value as
-the name of a file to read and execute. Bash behaves as if the
-following command were executed:
-@example
-@code{if [ -n "$BASH_ENV" ]; then . "$BASH_ENV"; fi}
-@end example
-@noindent
-but the value of the @code{PATH} variable is not used to search for the
-file name.
-
-If Bash is invoked with the name @code{sh}, it tries to mimic the
-startup behavior of historical versions of @code{sh} as closely as
-possible, while conforming to the @sc{POSIX} standard as well.
-
-When invoked as an interactive login shell, or as a non-interactive
-shell with the @samp{--login} option, it first attempts to read
-and execute commands from @file{/etc/profile} and @file{~/.profile}, in
-that order.
-The @samp{--noprofile} option may be used to inhibit this behavior.
-When invoked as an interactive shell with the name @code{sh}, Bash
-looks for the variable @code{ENV}, expands its value if it is defined,
-and uses the expanded value as the name of a file to read and execute.
-Since a shell invoked as @code{sh} does not attempt to read and execute
-commands from any other startup files, the @samp{--rcfile} option has
-no effect.
-A non-interactive shell invoked with the name @code{sh} does not attempt
-to read any other startup files.
-
-When invoked as @code{sh}, Bash enters @sc{POSIX} mode after
-the startup files are read.
-
-When Bash is started in @sc{POSIX} mode, as with the
-@samp{--posix} command line option, it follows the @sc{POSIX} standard
-for startup files.
-In this mode, interactive shells expand the @code{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 by the remote shell
-daemon, usually @code{rshd}. If Bash determines it is being run by
-rshd, it reads and executes commands from @file{~/.bashrc}, if that
-file exists and is readable.
-It will not do this if invoked as @code{sh}.
-The @samp{--norc} option may be used to inhibit this behavior, and the
-@samp{--rcfile} option may be used to force another file to be read, but
-@code{rshd} does not generally invoke the shell with those options or
-allow them to be specified.
-
-If Bash is started with the effective user (group) id not equal to the
-real user (group) id, and the @code{-p} option is not supplied, no startup
-files are read, shell functions are not inherited from the environment,
-the @code{SHELLOPTS} variable, if it appears in the environment, is ignored,
-and the effective user id is set to the real user id.
-If the @code{-p} option is supplied at invocation, the startup behavior is
-the same, but the effective user id is not reset.
-
-@node Is This Shell Interactive?
-@section Is This Shell Interactive?
-@cindex interactive shell
-
-As defined in @ref{Invoking Bash}, an interactive shell
-is one whose input and output are both
-connected to terminals (as determined by @code{isatty(3)}),
-or one started with the @samp{-i} option.
-
-To determine within a startup script whether Bash is
-running interactively or not, examine the variable
-@code{$PS1}; it is unset in non-interactive shells, and set in
-interactive shells. Thus:
-
-@example
-if [ -z "$PS1" ]; then
- echo This shell is not interactive
-else
- echo This shell is interactive
-fi
-@end example
-
-Alternatively, startup scripts may test the value of the @samp{-}
-special parameter.
-It contains @code{i} when the shell is interactive. For example:
-
-@example
-case "$-" in
-*i*) echo This shell is interactive ;;
-*) echo This shell is not interactive ;;
-esac
-@end example
-
@node Bash Builtins
@section Bash Builtin Commands
This section describes builtin commands which are unique to
or have been extended in Bash.
+Some of these commands are specified in the @sc{posix} 1003.2 standard.
@table @code
+@item alias
+@btindex alias
+@example
+alias [@code{-p}] [@var{name}[=@var{value}] @dots{}]
+@end example
+
+Without arguments or with the @samp{-p} option, @code{alias} prints
+the list of aliases on the standard output in a form that allows
+them to be reused as input.
+If arguments are supplied, an alias is defined for each @var{name}
+whose @var{value} is given. If no @var{value} is given, the name
+and value of the alias is printed.
+Aliases are described in @ref{Aliases}.
+
@item bind
@btindex bind
@example
bind [-m @var{keymap}] [-lpsvPSV]
bind [-m @var{keymap}] [-q @var{function}] [-u @var{function}] [-r @var{keyseq}]
bind [-m @var{keymap}] -f @var{filename}
+bind [-m @var{keymap}] -x @var{keyseq:shell-command}
bind [-m @var{keymap}] @var{keyseq:function-name}
@end example
@@ -3386,7 +2859,7 @@ Display current Readline (@pxref{Command Line Editing})
key and function bindings, or
bind a key sequence to a Readline function or macro. The
binding syntax accepted is identical to that of
-@file{.inputrc} (@pxref{Readline Init File}),
+a Readline initialization file (@pxref{Readline Init File}),
but each binding must be passed as a separate argument: e.g.,
@samp{"\C-x\C-r":re-read-init-file}.
Options, if supplied, have the following meanings:
@@ -3411,21 +2884,22 @@ List the names of all Readline functions.
@item -p
Display Readline function names and bindings in such a way that they
-can be re-read.
+can be used as input or in a Readline initialization file.
@item -P
List current Readline function names and bindings.
@item -v
Display Readline variable names and values in such a way that they
-can be re-read.
+can be used as input or in a Readline initialization file.
@item -V
List current Readline variable names and values.
@item -s
Display Readline key sequences bound to macros and the strings they output
-in such a way that they can be re-read.
+in such a way that they can be used as input or in a Readline
+initialization file.
@item -S
Display Readline key sequences bound to macros and the strings they output.
@@ -3442,6 +2916,10 @@ Unbind all keys bound to the named @var{function}.
@item -r @var{keyseq}
Remove any current binding for @var{keyseq}.
+@item -x @var{keyseq:shell-command}
+Cause @var{shell-command} to be executed whenever @var{keyseq} is
+entered.
+
@end table
@noindent
@@ -3528,7 +3006,7 @@ When used in a function, @code{declare} makes each @var{name} local,
as with the @code{local} command.
The return status is zero unless an invalid option is encountered,
-an attempt is made to define a function using @code{-f foo=bar},
+an attempt is made to define a function using @samp{-f foo=bar},
an attempt is made to assign a value to a readonly variable,
an attempt is made to assign a value to an array variable without
using the compound assignment syntax (@pxref{Arrays}),
@@ -3550,6 +3028,9 @@ If the @samp{-e} option is given, interpretation of the following
backslash-escaped characters is enabled.
The @samp{-E} option disables the interpretation of these escape characters,
even on systems where they are interpreted by default.
+The @code{xpg_echo} shell option may be used to
+dynamically determine whether or not @code{echo} expands these
+escape characters by default.
@code{echo} interprets the following escape sequences:
@table @code
@item \a
@@ -3587,7 +3068,7 @@ enable [-n] [-p] [-f @var{filename}] [-ads] [@var{name} @dots{}]
@end example
Enable and disable builtin shell commands.
Disabling a builtin allows a disk command which has the same name
-as a shell builtin to be executed with specifying a full pathname,
+as a shell builtin to be executed without specifying a full pathname,
even though the shell normally searches for builtins before disk commands.
If @samp{-n} is used, the @var{name}s become disabled. Otherwise
@var{name}s are enabled. For example, to use the @code{test} binary
@@ -3605,9 +3086,9 @@ from shared object @var{filename}, on systems that support dynamic loading.
The @samp{-d} option will delete a builtin loaded with @samp{-f}.
If there are no options, a list of the shell builtins is displayed.
-The @samp{-s} option restricts @code{enable} to the @sc{POSIX} special
+The @samp{-s} option restricts @code{enable} to the @sc{posix} special
builtins. If @samp{-s} is used with @samp{-f}, the new builtin becomes
-a special builtin.
+a special builtin (@pxref{Special Builtins}).
The return status is zero unless a @var{name} is not a shell builtin
or there is an error loading a new builtin from a shared object.
@@ -3615,13 +3096,15 @@ or there is an error loading a new builtin from a shared object.
@item help
@btindex help
@example
-help [@var{pattern}]
+help [-s] [@var{pattern}]
@end example
Display helpful information about builtin commands.
If @var{pattern} is specified, @code{help} gives detailed help
on all commands matching @var{pattern}, otherwise a list of
-the builtins is printed. The return status is zero unless no
-command matches @var{pattern}.
+the builtins is printed.
+The @samp{-s} option restricts the information displayed to a short
+usage synopsis.
+The return status is zero unless no command matches @var{pattern}.
@item let
@btindex let
@@ -3637,14 +3120,16 @@ otherwise 0 is returned.
@item local
@btindex local
@example
-local @var{name}[=@var{value}]
+local [@var{option}] @var{name}[=@var{value}]
@end example
For each argument, a local variable named @var{name} is created,
and assigned @var{value}.
+The @var{option} can be any of the options accepted by @code{declare}.
@code{local} can only be used within a function; it makes the variable
@var{name} have a visible scope restricted to that function and its
children. The return status is zero unless @code{local} is used outside
-a function or an invalid @var{name} is supplied.
+a function, an invalid @var{name} is supplied, or @var{name} is a
+readonly variable.
@item logout
@btindex logout
@@ -3674,12 +3159,13 @@ corresponding @var{argument} in a format that can be reused as shell input.
The @var{format} is reused as necessary to consume all of the @var{arguments}.
If the @var{format} requires more @var{arguments} than are supplied, the
extra format specifications behave as if a zero value or null string, as
-appropriate, had been supplied.
+appropriate, had been supplied. The return value is zero on success,
+non-zero on failure.
@item read
@btindex read
@example
-read [-a @var{aname}] [-p @var{prompt}] [-er] [@var{name} @dots{}]
+read [-ers] [-a @var{aname}] [-p @var{prompt}] [-t @var{timeout}] [-n @var{nchars}] [-d @var{delim}] [@var{name} @dots{}]
@end example
One line is read from the standard input, and the first word
is assigned to the first @var{name}, the second word to the second @var{name},
@@ -3693,30 +3179,49 @@ The backslash character @samp{\} may be used to remove any special
meaning for the next character read and for line continuation.
If no names are supplied, the line read is assigned to the
variable @code{REPLY}.
-The return code is zero, unless end-of-file is encountered.
+The return code is zero, unless end-of-file is encountered or @code{read}
+times out.
Options, if supplied, have the following meanings:
@table @code
-@item -r
-If this option is given, backslash does not act as an escape
-character. The backslash is considered to be part of the line.
-In particular, a backslash-newline pair may not be used as a line
-continuation.
-
-@item -p @var{prompt}
-Display @var{prompt}, without a
-trailing newline, before attempting to read any input. The prompt
-is displayed only if input is coming from a terminal.
-
@item -a @var{aname}
The words are assigned to sequential indices of the array variable
@var{aname}, starting at 0.
All elements are removed from @var{aname} before the assignment.
Other @var{name} arguments are ignored.
+@item -d @var{delim}
+The first character of @var{delim} is used to terminate the input line,
+rather than newline.
+
@item -e
-Readline (@pxref{Command Line Editing})
-is used to obtain the line.
+Readline (@pxref{Command Line Editing}) is used to obtain the line.
+
+@item -n @var{nchars}
+@code{read} returns after reading @var{nchars} characters rather than
+waiting for a complete line of input.
+
+@item -p @var{prompt}
+Display @var{prompt}, without a trailing newline, before attempting
+to read any input.
+The prompt is displayed only if input is coming from a terminal.
+
+@item -r
+If this option is given, backslash does not act as an escape character.
+The backslash is considered to be part of the line.
+In particular, a backslash-newline pair may not be used as a line
+continuation.
+
+@item -s
+Silent mode. If input is coming from a terminal, characters are
+not echoed.
+
+@item -t @var{timeout}
+Cause @code{read} to time out and return failure if a complete line of
+input is not read within @var{timeout} seconds.
+This option has no effect if @code{read} is not reading input from the
+terminal or a pipe.
+
@end table
@item shopt
@@ -3807,8 +3312,8 @@ builtin command. An interactive shell does not exit if @code{exec}
fails.
@item expand_aliases
-If set, aliases are expanded as described below< under Aliases
-(@pxref{Aliases}).
+If set, aliases are expanded as described below under Aliases,
+@ref{Aliases}.
This option is enabled by default for interactive shells.
@item extglob
@@ -3857,6 +3362,11 @@ If set, and a file that Bash is checking for mail has been
accessed since the last time it was checked, the message
@code{"The mail in @var{mailfile} has been read"} is displayed.
+@item no_empty_cmd_completion
+If set, and Readline is being used, Bash will not attempt to search
+the @code{PATH} for possible completions when completion is attempted
+on an empty line.
+
@item nocaseglob
If set, Bash matches filenames in a case-insensitive fashion when
performing filename expansion.
@@ -3865,6 +3375,11 @@ performing filename expansion.
If set, Bash allows filename patterns which match no
files to expand to a null string, rather than themselves.
+@item progcomp
+If set, the programmable completion facilities
+(@pxref{Programmable Completion}) are enabled.
+This option is enabled by default.
+
@item promptvars
If set, prompt strings undergo variable and parameter expansion after
being expanded (@pxref{Printing a Prompt}).
@@ -3886,6 +3401,11 @@ number of positional parameters.
If set, the @code{source} builtin uses the value of @code{PATH}
to find the directory containing the file supplied as an argument.
This option is enabled by default.
+
+@item xpg_echo
+If set, the @code{echo} builtin expands backslash-escape sequences
+by default.
+
@end table
@noindent
@@ -4005,6 +3525,16 @@ The return status is zero unless an invalid option is supplied, a
non-numeric argument other than @code{unlimited} is supplied as a
@var{limit}, or an error occurs while setting a new limit.
+@item unalias
+@btindex unalias
+@example
+unalias [-a] [@var{name} @dots{} ]
+@end example
+
+Remove each @var{name} from the list of aliases. If @samp{-a} is
+supplied, all aliases are removed.
+Aliases are described in @ref{Aliases}.
+
@end table
@node The Set Builtin
@@ -4120,7 +3650,7 @@ Same as @code{-P}.
@item posix
Change the behavior of Bash where the default operation differs
-from the @sc{POSIX} 1003.2 standard to match the standard
+from the @sc{posix} 1003.2 standard to match the standard
(@pxref{Bash POSIX Mode}).
This is intended to make Bash behave as a strict superset of that
standard.
@@ -4227,131 +3757,104 @@ The special parameter @code{#} is set to N.
The return status is always zero unless an invalid option is supplied.
@end table
-@node Bash Conditional Expressions
-@section Bash Conditional Expressions
-@cindex expressions, conditional
-
-Conditional expressions are used by the @code{[[} compound command
-and the @code{test} and @code{[} builtin commands.
-
-Expressions may be unary or binary.
-Unary expressions are often used to examine the status of a file.
-There are string operators and numeric comparison operators as well.
-If any @var{file} argument to one of the primaries is of the form
-@file{/dev/fd/@var{N}}, then file descriptor @var{N} is checked.
-
-@table @code
-@item -a @var{file}
-True if @var{file} exists.
-
-@item -b @var{file}
-True if @var{file} exists and is a block special file.
-
-@item -c @var{file}
-True if @var{file} exists and is a character special file.
-
-@item -d @var{file}
-True if @var{file} exists and is a directory.
-
-@item -e @var{file}
-True if @var{file} exists.
-
-@item -f @var{file}
-True if @var{file} exists and is a regular file.
-
-@item -g @var{file}
-True if @var{file} exists and its set-group-id bit is set.
-
-@item -h @var{file}
-True if @var{file} exists and is a symbolic link.
-
-@item -k @var{file}
-True if @var{file} exists and its "sticky" bit is set.
+@node Special Builtins
+@section Special Builtins
+@cindex special builtin
-@item -p @var{file}
-True if @var{file} exists and is a named pipe (FIFO).
+For historical reasons, the @sc{posix} 1003.2 standard has classified
+several builtin commands as @emph{special}.
+When Bash is executing in @sc{posix} mode, the special builtins
+differ from other builtin commands in three respects:
-@item -r @var{file}
-True if @var{file} exists and is readable.
-
-@item -s @var{file}
-True if @var{file} exists and has a size greater than zero.
+@enumerate
+@item
+Special builtins are found before shell functions during command lookup.
-@item -t @var{fd}
-True if file descriptor @var{fd} is open and refers to a terminal.
+@item
+If a special builtin returns an error status, a non-interactive shell exits.
-@item -u @var{file}
-True if @var{file} exists and its set-user-id bit is set.
+@item
+Assignment statements preceding the command stay in effect in the shell
+environment after the command completes.
+@end enumerate
-@item -w @var{file}
-True if @var{file} exists and is writable.
+When Bash is not executing in @sc{posix} mode, these builtins behave no
+differently than the rest of the Bash builtin commands.
+The Bash @sc{posix} mode is described in @ref{Bash POSIX Mode}.
-@item -x @var{file}
-True if @var{file} exists and is executable.
+These are the @sc{posix} special builtins:
+@example
+@w{break : . continue eval exec exit export readonly return set}
+@w{shift trap unset}
+@end example
-@item -O @var{file}
-True if @var{file} exists and is owned by the effective user id.
+@node Shell Variables
+@chapter Shell Variables
-@item -G @var{file}
-True if @var{file} exists and is owned by the effective group id.
+@menu
+* Bourne Shell Variables:: Variables which Bash uses in the same way
+ as the Bourne Shell.
+* Bash Variables:: List of variables that exist in Bash.
+@end menu
-@item -L @var{file}
-True if @var{file} exists and is a symbolic link.
+This chapter describes the shell variables that Bash uses.
+Bash automatically assigns default values to a number of variables.
-@item -S @var{file}
-True if @var{file} exists and is a socket.
+@node Bourne Shell Variables
+@section Bourne Shell Variables
-@item -N @var{file}
-True if @var{file} exists and has been modified since it was last read.
+Bash uses certain shell variables in the same way as the Bourne shell.
+In some cases, Bash assigns a default value to the variable.
-@item @var{file1} -nt @var{file2}
-True if @var{file1} is newer (according to
-modification date) than @var{file2}.
+@vtable @code
-@item @var{file1} -ot @var{file2}
-True if @var{file1} is older than @var{file2}.
+@item CDPATH
+A colon-separated list of directories used as a search path for
+the @code{cd} builtin command.
-@item @var{file1} -ef @var{file2}
-True if @var{file1} and @var{file2} have the same device and
-inode numbers.
+@item HOME
+The current user's home directory; the default for the @code{cd} builtin
+command.
+The value of this variable is also used by tilde expansion
+(@pxref{Tilde Expansion}).
-@item -o @var{optname}
-True if shell option @var{optname} is enabled.
-The list of options appears in the description of the @samp{-o}
-option to the @code{set} builtin (@pxref{The Set Builtin}).
+@item IFS
+A list of characters that separate fields; used when the shell splits
+words as part of expansion.
-@item -z @var{string}
-True if the length of @var{string} is zero.
+@item MAIL
+If this parameter is set to a filename and the @code{MAILPATH} variable
+is not set, Bash informs the user of the arrival of mail in
+the specified file.
-@item -n @var{string}
-@itemx @var{string}
-True if the length of @var{string} is non-zero.
+@item MAILPATH
+A colon-separated list of filenames which the shell periodically checks
+for new mail.
+Each list entry can specify the message that is printed when new mail
+arrives in the mail file by separating the file name from the message with
+a @samp{?}.
+When used in the text of the message, @code{$_} expands to the name of
+the current mail file.
-@item @var{string1} == @var{string2}
-True if the strings are equal.
-@samp{=} may be used in place of @samp{==}.
+@item OPTARG
+The value of the last option argument processed by the @code{getopts} builtin.
-@item @var{string1} != @var{string2}
-True if the strings are not equal.
+@item OPTIND
+The index of the last option argument processed by the @code{getopts} builtin.
-@item @var{string1} < @var{string2}
-True if @var{string1} sorts before @var{string2} lexicographically
-in the current locale.
+@item PATH
+A colon-separated list of directories in which the shell looks for
+commands.
-@item @var{string1} > @var{string2}
-True if @var{string1} sorts after @var{string2} lexicographically
-in the current locale.
+@item PS1
+The primary prompt string. The default value is @samp{\s-\v\$ }.
+@xref{Printing a Prompt}, for the complete list of escape
+sequences that are expanded before @code{PS1} is displayed.
-@item @var{arg1} OP @var{arg2}
-@code{OP} is one of
-@samp{-eq}, @samp{-ne}, @samp{-lt}, @samp{-le}, @samp{-gt}, or @samp{-ge}.
-These arithmetic binary operators return true if @var{arg1}
-is equal to, not equal to, less than, less than or equal to,
-greater than, or greater than or equal to @var{arg2},
-respectively. @var{Arg1} and @var{arg2}
-may be positive or negative integers.
+@item PS2
+The secondary prompt string. The default value is @samp{> }.
-@end table
+@end vtable
@node Bash Variables
@section Bash Variables
@@ -4359,6 +3862,10 @@ may be positive or negative integers.
These variables are set or used by Bash, but other shells
do not normally treat them specially.
+A few variables used by Bash are described in different chapters:
+variables for controlling the job control facilities
+(@pxref{Job Control Variables}).
+
@vtable @code
@item BASH
@@ -4373,8 +3880,8 @@ to read before executing the script. @xref{Bash Startup Files}.
The version number of the current instance of Bash.
@item BASH_VERSINFO
-A readonly array variable whose members hold version information for
-this instance of Bash.
+A readonly array variable (@pxref{Arrays})
+whose members hold version information for this instance of Bash.
The values assigned to the array members are as follows:
@table @code
@@ -4399,9 +3906,40 @@ The value of @code{MACHTYPE}.
@end table
+@item COMP_WORDS
+An array variable consisting of the individual
+words in the current command line.
+This variable is available only in shell functions invoked by the
+programmable completion facilities (@pxref{Programmable Completion}).
+
+@item COMP_CWORD
+An index into @code{$@{COMP_WORDS@}} of the word containing the current
+cursor position.
+This variable is available only in shell functions invoked by the
+programmable completion facilities (@pxref{Programmable Completion}).
+
+@item COMP_LINE
+The current command line.
+This variable is available only in shell functions and external
+commands invoked by the
+programmable completion facilities (@pxref{Programmable Completion}).
+
+@item COMP_POINT
+The index of the current cursor position relative to the beginning of
+the current command.
+If the current cursor position is at the end of the current command,
+the value of this variable is equal to @code{$@{#COMP_LINE@}}.
+This variable is available only in shell functions and external
+commands invoked by the
+programmable completion facilities (@pxref{Programmable Completion}).
+
+@item COMPREPLY
+An array variable from which Bash reads the possible completions
+generated by a shell function invoked by the programmable completion
+facility (@pxref{Programmable Completion}).
+
@item DIRSTACK
-An array variable (@pxref{Arrays})
-containing the current contents of the directory stack.
+An array variable containing the current contents of the directory stack.
Directories appear in the stack in the order they are displayed by the
@code{dirs} builtin.
Assigning to members of this array variable may be used to modify
@@ -4436,13 +3974,16 @@ of matches.
@item GROUPS
An array variable containing the list of groups of which the current
-user is a member. This variable is readonly.
+user is a member.
+Assignments to @code{GROUPS} have no effect and are silently discarded.
+If @code{GROUPS} is unset, it loses its special properties, even if it is
+subsequently reset.
@item histchars
Up to three characters which control history expansion, quick
substitution, and tokenization (@pxref{History Interaction}).
The first character is the
-@dfn{history-expansion-char}, that is, the character which signifies the
+@var{history expansion} character, that is, the character which signifies the
start of a history expansion, normally @samp{!}. The second character is the
character which signifies `quick substitution' when seen as the first
character on a line, normally @samp{^}. The optional third character is the
@@ -4457,11 +3998,19 @@ The history number, or index in the history list, of the current
command. If @code{HISTCMD} is unset, it loses its special properties,
even if it is subsequently reset.
+@item FUNCNAME
+The name of any currently-executing shell function.
+This variable exists only when a shell function is executing.
+Assignments to @code{FUNCNAME} have no effect and are silently discarded.
+If @code{FUNCNAME} is unset, it loses its special properties, even if
+it is subsequently reset.
+
@item HISTCONTROL
-Set to a value of @samp{ignorespace}, it means don't enter lines which
-begin with a space or tab into the history list. Set to a value
-of @samp{ignoredups}, it means don't enter lines which match the last
-entered line. A value of @samp{ignoreboth} combines the two options.
+A value of @samp{ignorespace} means to not enter lines which
+begin with a space or tab into the history list.
+A value of @samp{ignoredups} means to not enter lines which match the last
+entered line.
+A value of @samp{ignoreboth} combines the two options.
Unset, or set to any other value than those above, means to save
all lines on the history list.
The second and subsequent lines of a multi-line compound command are
@@ -4471,12 +4020,12 @@ not tested, and are added to the history regardless of the value of
@item HISTIGNORE
A colon-separated list of patterns used to decide which command
lines should be saved on the history list. Each pattern is
-anchored at the beginning of the line and must fully specify the
+anchored at the beginning of the line and must match the complete
line (no implicit @samp{*} is appended). Each pattern is tested
against the line after the checks specified by @code{HISTCONTROL}
are applied. In addition to the normal shell pattern matching
characters, @samp{&} matches the previous history line. @samp{&}
-may be escaped using a backslash. The backslash is removed
+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
@@ -4490,7 +4039,7 @@ provides the functionality of @code{ignoreboth}.
@item HISTFILE
The name of the file to which the command history is saved. The
-default is @file{~/.bash_history}.
+default value is @file{~/.bash_history}.
@item HISTSIZE
The maximum number of commands to remember on the history list.
@@ -4499,16 +4048,22 @@ The default value is 500.
@item HISTFILESIZE
The maximum number of lines contained in the history file. When this
variable is assigned a value, the history file is truncated, if
-necessary, to contain no more than that number of lines. The default
-value is 500. The history file is also truncated to this size after
+necessary, to contain no more than that number of lines.
+The history file is also truncated to this size after
writing it when an interactive shell exits.
+The default value is 500.
@item HOSTFILE
Contains the name of a file in the same format as @file{/etc/hosts} that
-should be read when the shell needs to complete a hostname. You can
-change the file interactively; the next time you attempt to complete a
-hostname, Bash will add the contents of the new file to the already
-existing database.
+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 @code{HOSTFILE} is set, but has no value, Bash attempts to read
+@file{/etc/hosts} to obtain the list of possible hostname completions.
+When @code{HOSTFILE} is unset, the hostname list is cleared.
@item HOSTNAME
The name of the current host.
@@ -4527,7 +4082,7 @@ If the variable does not exist, then @code{EOF} signifies the end of
input to the shell. This is only in effect for interactive shells.
@item INPUTRC
-The name of the Readline startup file, overriding the default
+The name of the Readline initialization file, overriding the default
of @file{~/.inputrc}.
@item LANG
@@ -4554,12 +4109,15 @@ matching (@pxref{Filename Expansion}).
This variable determines the locale used to translate double-quoted
strings preceded by a @samp{$} (@pxref{Locale Translation}).
+@item LC_NUMERIC
+This variable determines the locale category used for number formatting.
+
@item LINENO
The line number in the script or shell function currently executing.
@item MACHTYPE
A string that fully describes the system type on which Bash
-is executing, in the standard GNU @var{cpu-company-system} format.
+is executing, in the standard @sc{gnu} @var{cpu-company-system} format.
@item MAILCHECK
How often (in seconds) that the shell should check for mail in the
@@ -4582,11 +4140,11 @@ in the most-recently-executed foreground pipeline (which may
contain only a single command).
@item PPID
-The process id of the shell's parent process. This variable
+The process @sc{id} of the shell's parent process. This variable
is readonly.
@item PROMPT_COMMAND
-If present, this contains a string which is a command to execute
+If set, the value is interpreted as a command to execute
before the printing of each primary prompt (@code{$PS1}).
@item PS3
@@ -4595,7 +4153,7 @@ The value of this variable is used as the prompt for the
@code{select} command prompts with @samp{#? }
@item PS4
-This is the prompt printed before the command line is echoed
+The value is the prompt printed before the command line is echoed
when the @samp{-x} option is set (@pxref{The Set Builtin}).
The first character of @code{PS4} is replicated multiple times, as
necessary, to indicate multiple levels of indirection.
@@ -4682,7 +4240,7 @@ A trailing newline is added when the format string is displayed.
@item TMOUT
If set to a value greater than zero, the value is interpreted as
the number of seconds to wait for input after issuing the primary
-prompt.
+prompt when the shell is interactive.
Bash terminates after that number of seconds if input does
not arrive.
@@ -4691,6 +4249,552 @@ The numeric real user id of the current user. This variable is readonly.
@end vtable
+@node Bash Features
+@chapter Bash Features
+
+This section describes features unique to Bash.
+
+@menu
+* Invoking Bash:: Command line options that you can give
+ to Bash.
+* Bash Startup Files:: When and how Bash executes scripts.
+* Interactive Shells:: What an interactive shell is.
+* Bash Conditional Expressions:: Primitives used in composing expressions for
+ the @code{test} builtin.
+* Shell Arithmetic:: Arithmetic on shell variables.
+* Aliases:: Substituting one command for another.
+* Arrays:: Array Variables.
+* The Directory Stack:: History of visited directories.
+* Printing a Prompt:: Controlling the PS1 string.
+* The Restricted Shell:: A more controlled mode of shell execution.
+* Bash POSIX Mode:: Making Bash behave more closely to what
+ the POSIX standard specifies.
+@end menu
+
+@node Invoking Bash
+@section Invoking Bash
+
+@example
+bash [long-opt] [-ir] [-abefhkmnptuvxdBCDHP] [-o @var{option}] [@var{argument} @dots{}]
+bash [long-opt] [-abefhkmnptuvxdBCDHP] [-o @var{option}] -c @var{string} [@var{argument} @dots{}]
+bash [long-opt] -s [-abefhkmnptuvxdBCDHP] [-o @var{option}] [@var{argument} @dots{}]
+@end example
+
+In addition to the single-character shell command-line options
+(@pxref{The Set Builtin}), there are several multi-character
+options that you can use. These options must appear on the command
+line before the single-character options in order for them
+to be recognized.
+
+@table @code
+@item --dump-po-strings
+A list of all double-quoted strings preceded by @samp{$}
+is printed on the standard ouput
+in the @sc{gnu} @code{gettext} PO (portable object) file format.
+Equivalent to @samp{-D} except for the output format.
+
+@item --dump-strings
+Equivalent to @samp{-D}.
+
+@item --help
+Display a usage message on standard output and exit sucessfully.
+
+@item --login
+Make this shell act as if it were directly invoked by login.
+This is equivalent to @samp{exec -l bash} but can be issued from
+another shell, such as @code{csh}. @samp{exec bash --login}
+will replace the current shell with a Bash login shell.
+@xref{Bash Startup Files}, for a description of the special behavior
+of a login shell.
+
+@item --noediting
+Do not use the @sc{gnu} Readline library (@pxref{Command Line Editing})
+to read command lines when the shell is interactive.
+
+@item --noprofile
+Don't load the system-wide startup file @file{/etc/profile}
+or any of the personal initialization files
+@file{~/.bash_profile}, @file{~/.bash_login}, or @file{~/.profile}
+when Bash is invoked as a login shell.
+
+@item --norc
+Don't read the @file{~/.bashrc} initialization file in an
+interactive shell. This is on by default if the shell is
+invoked as @code{sh}.
+
+@item --posix
+Change the behavior of Bash where the default operation differs
+from the @sc{posix} 1003.2 standard to match the standard. This
+is intended to make Bash behave as a strict superset of that
+standard. @xref{Bash POSIX Mode}, for a description of the Bash
+@sc{posix} mode.
+
+@item --rcfile @var{filename}
+Execute commands from @var{filename} (instead of @file{~/.bashrc})
+in an interactive shell.
+
+@item --restricted
+Make the shell a restricted shell (@pxref{The Restricted Shell}).
+
+@item --verbose
+Equivalent to @samp{-v}. Print shell input lines as they're read.
+
+@item --version
+Show version information for this instance of
+Bash on the standard output and exit successfully.
+
+@end table
+
+There are several single-character options that may be supplied at
+invocation which are not available with the @code{set} builtin.
+
+@table @code
+@item -c @var{string}
+Read and execute commands from @var{string} after processing the
+options, then exit. Any remaining arguments are assigned to the
+positional parameters, starting with @code{$0}.
+
+@item -i
+Force the shell to run interactively. Interactive shells are
+described in @ref{Interactive Shells}.
+
+@item -r
+Make the shell a restricted shell (@pxref{The Restricted Shell}).
+
+@item -s
+If this option is present, or if no arguments remain after option
+processing, then commands are read from the standard input.
+This option allows the positional parameters to be set
+when invoking an interactive shell.
+
+@item -D
+A list of all double-quoted strings preceded by @samp{$}
+is printed on the standard ouput.
+These are the strings that
+are subject to language translation when the current locale
+is not @code{C} or @code{POSIX} (@pxref{Locale Translation}).
+This implies the @samp{-n} option; no commands will be executed.
+
+@item --
+A @code{--} signals the end of options and disables further option
+processing.
+Any arguments after the @code{--} are treated as filenames and arguments.
+
+@end table
+
+@cindex interactive shell
+An @emph{interactive} shell is one started without non-option arguments,
+unless @samp{-s} is specified,
+without specifying the @samp{-c} option, and whose input and output are both
+connected to terminals (as determined by @code{isatty(3)}), or one
+started with the @samp{-i} option. @xref{Interactive Shells} for more
+information.
+
+If arguments remain after option processing, and neither the
+@samp{-c} nor the @samp{-s}
+option has been supplied, the first argument is assumed to
+be the name of a file containing shell commands (@pxref{Shell Scripts}).
+When Bash is invoked in this fashion, @code{$0}
+is set to the name of the file, and the positional parameters
+are set to the remaining arguments.
+Bash reads and executes commands from this file, then exits.
+Bash's exit status is the exit status of the last command executed
+in the script. If no commands are executed, the exit status is 0.
+
+@node Bash Startup Files
+@section Bash Startup Files
+@cindex startup files
+
+This section describs how Bash executes its startup files.
+If any of the files exist but cannot be read, Bash reports an error.
+Tildes are expanded in file names as described above under
+Tilde Expansion (@pxref{Tilde Expansion}).
+
+Interactive shells are described in @ref{Interactive Shells}.
+
+@subsubheading Invoked as an interactive login shell, or with @samp{--login}
+
+When Bash is invoked as an interactive login shell, or as a
+non-interactive shell with the @samp{--login} option, it first reads and
+executes commands from the file @file{/etc/profile}, if that file exists.
+After reading that file, it looks for @file{~/.bash_profile},
+@file{~/.bash_login}, and @file{~/.profile}, in that order, and reads
+and executes commands from the first one that exists and is readable.
+The @samp{--noprofile} option may be used when the shell is started to
+inhibit this behavior.
+
+When a login shell exits, Bash reads and executes commands from
+the file @file{~/.bash_logout}, if it exists.
+
+@subsubheading Invoked as an interactive non-login shell
+
+When an interactive shell that is not a login shell is started, Bash
+reads and executes commands from @file{~/.bashrc}, if that file exists.
+This may be inhibited by using the @samp{--norc} option.
+The @samp{--rcfile @var{file}} option will force Bash to read and
+execute commands from @var{file} instead of @file{~/.bashrc}.
+
+So, typically, your @file{~/.bash_profile} contains the line
+@example
+@code{if [ -f ~/.bashrc ]; then . ~/.bashrc; fi}
+@end example
+@noindent
+after (or before) any login-specific initializations.
+
+@subsubheading Invoked non-interactively
+
+When Bash is started non-interactively, to run a shell script,
+for example, it looks for the variable @code{BASH_ENV} in the environment,
+expands its value if it appears there, and uses the expanded value as
+the name of a file to read and execute. Bash behaves as if the
+following command were executed:
+@example
+@code{if [ -n "$BASH_ENV" ]; then . "$BASH_ENV"; fi}
+@end example
+@noindent
+but the value of the @code{PATH} variable is not used to search for the
+file name.
+
+@subsubheading Invoked with name @code{sh}
+
+If Bash is invoked with the name @code{sh}, it tries to mimic the
+startup behavior of historical versions of @code{sh} as closely as
+possible, while conforming to the @sc{posix} standard as well.
+
+When invoked as an interactive login shell, or as a non-interactive
+shell with the @samp{--login} option, it first attempts to read
+and execute commands from @file{/etc/profile} and @file{~/.profile}, in
+that order.
+The @samp{--noprofile} option may be used to inhibit this behavior.
+When invoked as an interactive shell with the name @code{sh}, Bash
+looks for the variable @code{ENV}, expands its value if it is defined,
+and uses the expanded value as the name of a file to read and execute.
+Since a shell invoked as @code{sh} does not attempt to read and execute
+commands from any other startup files, the @samp{--rcfile} option has
+no effect.
+A non-interactive shell invoked with the name @code{sh} does not attempt
+to read any other startup files.
+
+When invoked as @code{sh}, Bash enters @sc{posix} mode after
+the startup files are read.
+
+@subsubheading Invoked in @sc{posix} mode
+
+When Bash is started in @sc{posix} mode, as with the
+@samp{--posix} command line option, it follows the @sc{posix} standard
+for startup files.
+In this mode, interactive shells expand the @code{ENV} variable
+and commands are read and executed from the file whose name is the
+expanded value.
+No other startup files are read.
+
+@subsubheading Invoked by remote shell daemon
+
+Bash attempts to determine when it is being run by the remote shell
+daemon, usually @code{rshd}. If Bash determines it is being run by
+rshd, it reads and executes commands from @file{~/.bashrc}, if that
+file exists and is readable.
+It will not do this if invoked as @code{sh}.
+The @samp{--norc} option may be used to inhibit this behavior, and the
+@samp{--rcfile} option may be used to force another file to be read, but
+@code{rshd} does not generally invoke the shell with those options or
+allow them to be specified.
+
+@subsubheading Invoked with unequal effective and real @sc{uid/gid}s
+
+If Bash is started with the effective user (group) id not equal to the
+real user (group) id, and the @code{-p} option is not supplied, no startup
+files are read, shell functions are not inherited from the environment,
+the @code{SHELLOPTS} variable, if it appears in the environment, is ignored,
+and the effective user id is set to the real user id.
+If the @code{-p} option is supplied at invocation, the startup behavior is
+the same, but the effective user id is not reset.
+
+@node Interactive Shells
+@section Interactive Shells
+@cindex interactive shell
+@cindex shell, interactive
+
+@menu
+* What is an Interactive Shell?:: What determines whether a shell is Interactive.
+* Is this Shell Interactive?:: How to tell if a shell is interactive.
+* Interactive Shell Behavior:: What changes in a interactive shell?
+@end menu
+
+@node What is an Interactive Shell?
+@subsection What is an Interactive Shell?
+
+An interactive shell
+is one started without non-option arguments, unless @samp{-s} is
+specified, without specifiying the @samp{-c} option, and
+whose input and output are both
+connected to terminals (as determined by @code{isatty(3)}),
+or one started with the @samp{-i} option.
+
+An interactive shell generally reads from and writes to a user's
+terminal.
+
+The @samp{-s} invocation option may be used to set the positional parameters
+when an interactive shell is started.
+
+@node Is this Shell Interactive?
+@subsection Is this Shell Interactive?
+
+To determine within a startup script whether or not Bash is
+running interactively,
+test the value of the @samp{-} special parameter.
+It contains @code{i} when the shell is interactive. For example:
+
+@example
+case "$-" in
+*i*) echo This shell is interactive ;;
+*) echo This shell is not interactive ;;
+esac
+@end example
+
+Alternatively, startup scripts may examine the variable
+@code{$PS1}; it is unset in non-interactive shells, and set in
+interactive shells. Thus:
+
+@example
+if [ -z "$PS1" ]; then
+ echo This shell is not interactive
+else
+ echo This shell is interactive
+fi
+@end example
+
+@node Interactive Shell Behavior
+@subsection Interactive Shell Behavior
+
+When the shell is running interactively, it changes its behavior in
+several ways.
+
+@enumerate
+@item
+Startup files are read and executed as described in @ref{Bash Startup Files}.
+
+@item
+Job Control (@pxref{Job Control}) is enabled by default. When job
+control is in effect, Bash ignores the keyboard-generated job control
+signals @code{SIGTTIN}, @code{SIGTTOU}, and @code{SIGTSTP}.
+
+@item
+Bash expands and displays @code{$PS1} before reading the first line
+of a command, and expands and displays @code{$PS2} before reading the
+second and subsequent lines of a multi-line command.
+
+@item
+Bash executes the value of the @code{PROMPT_COMMAND} variable as a command
+before printing the primary prompt, @code{$PS1}
+(@pxref{Bash Variables}).
+
+@item
+Readline (@pxref{Command Line Editing}) is used to read commands from
+the user's terminal.
+
+@item
+Bash inspects the value of the @code{ignoreeof} option to @code{set -o}
+instead of exiting immediately when it receives an @code{EOF} on its
+standard input when reading a command (@pxref{The Set Builtin}).
+
+@item
+Command history (@pxref{Bash History Facilities})
+and history expansion (@pxref{History Interaction})
+are enabled by default.
+Bash will save the command history to the file named by @code{$HISTFILE}
+when an interactive shell exits.
+
+@item
+Alias expansion (@pxref{Aliases}) is performed by default.
+
+@item
+In the absence of any traps, Bash ignores @code{SIGTERM}
+(@pxref{Signals}).
+
+@item
+In the absence of any traps, @code{SIGINT} is caught and handled
+((@pxref{Signals}).
+@code{SIGINT} will interrupt some shell builtins.
+
+@item
+An interactive login shell sends a @code{SIGHUP} to all jobs on exit
+if the @code{hupoxexit} shell option has been enabled (@pxref{Signals}).
+
+@item
+The @samp{-n} invocation option is ignored, and @samp{set -n} has
+no effect (@pxref{The Set Builtin}).
+
+@item
+Bash will check for mail periodically, depending on the values of the
+@code{MAIL}, @code{MAILPATH}, and @code{MAILCHECK} shell variables
+(@pxref{Bash Variables}).
+
+@item
+Expansion errors due to references to unbound shell variables after
+@samp{set -u} has been enabled will not cause the shell to exit
+(@pxref{The Set Builtin}).
+
+@item
+The shell will not exit on expansion errors caused by @var{var} being unset
+or null in @code{$@{@var{var}:?@var{word}@}} expansions
+(@pxref{Shell Parameter Expansion}).
+
+@item
+Redirection errors encountered by shell builtins will not cause the
+shell to exit.
+
+@item
+When running in @sc{posix} mode, a special builtin returning an error
+status will not cause the shell to exit (@pxref{Bash POSIX Mode}).
+@item
+A failed @code{exec} will not cause the shell to exit
+(@pxref{Bourne Shell Builtins}).
+
+@item
+Parser syntax errors will not cause the shell to exit.
+
+@item
+Simple spelling correction for directory arguments to the @code{cd}
+builtin is enabled by default (see the description of the @code{cdspell}
+option to the @code{shopt} builtin in @ref{Bash Builtins}).
+
+@item
+The shell will check the value of the @code{TMOUT} variable and exit
+if a command is not read within the specified number of seconds after
+printing @code{$PS1} (@pxref{Bash Variables}).
+
+@end enumerate
+
+@node Bash Conditional Expressions
+@section Bash Conditional Expressions
+@cindex expressions, conditional
+
+Conditional expressions are used by the @code{[[} compound command
+and the @code{test} and @code{[} builtin commands.
+
+Expressions may be unary or binary.
+Unary expressions are often used to examine the status of a file.
+There are string operators and numeric comparison operators as well.
+If the @var{file} argument to one of the primaries is of the form
+@file{/dev/fd/@var{N}}, then file descriptor @var{N} is checked.
+If the @var{file} argument to one of the primaries is one of
+@file{/dev/stdin}, @file{/dev/stdout}, or @file{/dev/stderr}, file
+descriptor 0, 1, or 2, respectively, is checked.
+
+@table @code
+@item -a @var{file}
+True if @var{file} exists.
+
+@item -b @var{file}
+True if @var{file} exists and is a block special file.
+
+@item -c @var{file}
+True if @var{file} exists and is a character special file.
+
+@item -d @var{file}
+True if @var{file} exists and is a directory.
+
+@item -e @var{file}
+True if @var{file} exists.
+
+@item -f @var{file}
+True if @var{file} exists and is a regular file.
+
+@item -g @var{file}
+True if @var{file} exists and its set-group-id bit is set.
+
+@item -h @var{file}
+True if @var{file} exists and is a symbolic link.
+
+@item -k @var{file}
+True if @var{file} exists and its "sticky" bit is set.
+
+@item -p @var{file}
+True if @var{file} exists and is a named pipe (FIFO).
+
+@item -r @var{file}
+True if @var{file} exists and is readable.
+
+@item -s @var{file}
+True if @var{file} exists and has a size greater than zero.
+
+@item -t @var{fd}
+True if file descriptor @var{fd} is open and refers to a terminal.
+
+@item -u @var{file}
+True if @var{file} exists and its set-user-id bit is set.
+
+@item -w @var{file}
+True if @var{file} exists and is writable.
+
+@item -x @var{file}
+True if @var{file} exists and is executable.
+
+@item -O @var{file}
+True if @var{file} exists and is owned by the effective user id.
+
+@item -G @var{file}
+True if @var{file} exists and is owned by the effective group id.
+
+@item -L @var{file}
+True if @var{file} exists and is a symbolic link.
+
+@item -S @var{file}
+True if @var{file} exists and is a socket.
+
+@item -N @var{file}
+True if @var{file} exists and has been modified since it was last read.
+
+@item @var{file1} -nt @var{file2}
+True if @var{file1} is newer (according to
+modification date) than @var{file2}.
+
+@item @var{file1} -ot @var{file2}
+True if @var{file1} is older than @var{file2}.
+
+@item @var{file1} -ef @var{file2}
+True if @var{file1} and @var{file2} have the same device and
+inode numbers.
+
+@item -o @var{optname}
+True if shell option @var{optname} is enabled.
+The list of options appears in the description of the @samp{-o}
+option to the @code{set} builtin (@pxref{The Set Builtin}).
+
+@item -z @var{string}
+True if the length of @var{string} is zero.
+
+@item -n @var{string}
+@itemx @var{string}
+True if the length of @var{string} is non-zero.
+
+@item @var{string1} == @var{string2}
+True if the strings are equal.
+@samp{=} may be used in place of @samp{==}.
+
+@item @var{string1} != @var{string2}
+True if the strings are not equal.
+
+@item @var{string1} < @var{string2}
+True if @var{string1} sorts before @var{string2} lexicographically
+in the current locale.
+
+@item @var{string1} > @var{string2}
+True if @var{string1} sorts after @var{string2} lexicographically
+in the current locale.
+
+@item @var{arg1} OP @var{arg2}
+@code{OP} is one of
+@samp{-eq}, @samp{-ne}, @samp{-lt}, @samp{-le}, @samp{-gt}, or @samp{-ge}.
+These arithmetic binary operators return true if @var{arg1}
+is equal to, not equal to, less than, less than or equal to,
+greater than, or greater than or equal to @var{arg2},
+respectively. @var{Arg1} and @var{arg2}
+may be positive or negative integers.
+
+@end table
+
@node Shell Arithmetic
@section Shell Arithmetic
@cindex arithmetic, shell
@@ -4703,12 +4807,21 @@ The shell allows arithmetic expressions to be evaluated, as one of
the shell expansions or by the @code{let} builtin.
Evaluation is done in long 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.
+though division by 0 is trapped and flagged as an error.
+The operators and their precedence and associativity are the same
+as in the C language.
+The following list of operators is grouped into levels of
+equal-precedence operators.
+The levels are listed in order of decreasing precedence.
@table @code
+
+@item @var{id}++ @var{id}--
+variable post-increment and post-decrement
+
+@item ++@var{id} --@var{id}
+variable pre-increment and pre-decrement
+
@item - +
unary minus and plus
@@ -4753,19 +4866,25 @@ conditional evaluation
@item = *= /= %= += -= <<= >>= &= ^= |=
assignment
+
+@item expr1 , expr2
+comma
@end table
Shell variables are allowed as operands; parameter expansion is
performed before the expression is evaluated.
-The value of a parameter is coerced to a long integer within
-an expression. A shell variable need not have its integer attribute
-turned on to be used in an expression.
+Within an expression, shell variables may also be referenced by name
+without using the parameter expansion syntax.
+The value of a variable is evaluated as an arithmetic expression
+when it is referenced.
+A shell variable need not have its integer attribute turned on
+to be used in an expression.
Constants with a leading 0 are interpreted as octal numbers.
A leading @samp{0x} or @samp{0X} denotes hexadecimal. Otherwise,
numbers take the form [@var{base}@code{#}]@var{n}, where @var{base}
is a decimal number between 2 and 64 representing the arithmetic
-base, and @var{n} is a number in that base. If @var{base} is
+base, and @var{n} is a number in that base. If @var{base}@code{#} is
omitted, then base 10 is used.
The digits greater than 9 are represented by the lowercase letters,
the uppercase letters, @samp{_}, and @samp{@@}, in that order.
@@ -4781,15 +4900,10 @@ rules above.
@section Aliases
@cindex alias expansion
-@menu
-* Alias Builtins:: Builtins commands to maniuplate aliases.
-@end menu
-
-Aliases allow a string to be substituted for a word when it is used
+@var{Aliases} allow a string to be substituted for a word when it is used
as the first word of a simple command.
-The shell maintains a list of @var{aliases}
-that may be set and unset with the @code{alias} and
-@code{unalias} builtin commands.
+The shell maintains a list of aliases that may be set and unset with
+the @code{alias} and @code{unalias} builtin commands.
The first word of each simple command, if unquoted, is checked to see
if it has an alias.
@@ -4837,36 +4951,7 @@ function is executed. To be safe, always put
alias definitions on a separate line, and do not use @code{alias}
in compound commands.
-For almost every purpose, aliases are superseded by
-shell functions.
-
-@node Alias Builtins
-@subsection Alias Builtins
-
-@table @code
-
-@item alias
-@btindex alias
-@example
-alias [@code{-p}] [@var{name}[=@var{value}] @dots{}]
-@end example
-
-Without arguments or with the @samp{-p} option, @code{alias} prints
-the list of aliases on the standard output in a form that allows
-them to be reused as input.
-If arguments are supplied, an alias is defined for each @var{name}
-whose @var{value} is given. If no @var{value} is given, the name
-and value of the alias is printed.
-
-@item unalias
-@btindex unalias
-@example
-unalias [-a] [@var{name} @dots{} ]
-@end example
-
-Remove each @var{name} from the list of aliases. If @samp{-a} is
-supplied, all aliases are removed.
-@end table
+For almost every purpose, shell functions are preferred over aliases.
@node Arrays
@section Arrays
@@ -4937,7 +5022,7 @@ Referencing an array variable without a subscript is equivalent to
referencing element zero.
The @code{unset} builtin is used to destroy arrays.
-@code{unset} @code{name[@var{subscript}]}
+@code{unset} @var{name[subscript]}
destroys the array element at index @var{subscript}.
@code{unset} @var{name}, where @var{name} is an array, removes the
entire array. A subscript of @samp{*} or @samp{@@} also removes the
@@ -4957,6 +5042,11 @@ reused as input.
@section The Directory Stack
@cindex directory stack
+@menu
+* Directory Stack Builtins:: Bash builtin commands to manipulate
+ the directory stack.
+@end menu
+
The directory stack is a list of recently-visited directories. The
@code{pushd} builtin adds directories to the stack as it changes
the current directory, and the @code{popd} builtin removes specified
@@ -4967,12 +5057,15 @@ of the directory stack.
The contents of the directory stack are also visible
as the value of the @code{DIRSTACK} shell variable.
+@node Directory Stack Builtins
+@subsection Directory Stack Builtins
+
@table @code
@item dirs
@btindex dirs
@example
-dirs [+@var{N} | -@var{N}] [-clvp]
+dirs [+@var{N} | -@var{N}] [-clpv]
@end example
Display the list of currently remembered directories. Directories
are added to the list with the @code{pushd} command; the
@@ -5059,7 +5152,8 @@ executes the equivalent of `@code{cd} @var{dir}'.
@cindex prompting
The value of the variable @code{PROMPT_COMMAND} is examined just before
-Bash prints each primary prompt. If it is set and non-null, then the
+Bash prints each primary prompt. If @code{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
@@ -5076,6 +5170,10 @@ An escape character.
The hostname, up to the first `.'.
@item \H
The hostname.
+@item \j
+The number of jobs currently managed by the shell.
+@item \l
+The basename of the shell's terminal device name.
@item \n
A newline.
@item \r
@@ -5116,6 +5214,18 @@ embed a terminal control sequence into the prompt.
End a sequence of non-printing characters.
@end table
+The command number and the history number are usually different:
+the history number of a command is its position in the history
+list, which may include commands restored from the history file
+(@pxref{Bash History Facilities}), while the command number is
+the position in the sequence of commands executed during the current
+shell session.
+
+After the string is decoded, it is expanded via
+parameter expansion, command substitution, arithmetic
+expansion, and quote removal, subject to the value of the
+@code{promptvars} shell option (@pxref{Bash Builtins}).
+
@node The Restricted Shell
@section The Restricted Shell
@cindex restricted shell
@@ -5139,6 +5249,9 @@ Specifying command names containing slashes.
Specifying a filename containing a slash as an argument to the @code{.}
builtin command.
@item
+Specifying a filename containing a slash as an argument to the @samp{-p}
+option to the @code{hash} builtin command.
+@item
Importing function definitions from the shell environment at startup.
@item
Parsing the value of @code{SHELLOPTS} from the shell environment at startup.
@@ -5162,10 +5275,10 @@ Turning off restricted mode with @samp{set +r} or @samp{set +o restricted}.
Starting Bash with the @samp{--posix} command-line option or executing
@samp{set -o posix} while Bash is running will cause Bash to conform more
-closely to the @sc{POSIX.2} standard by changing the behavior to match that
-specified by @sc{POSIX.2} in areas where the Bash default differs.
+closely to the @sc{posix} 1003.2 standard by changing the behavior to
+match that specified by @sc{posix} in areas where the Bash default differs.
-The following list is what's changed when `@sc{POSIX} mode' is in effect:
+The following list is what's changed when `@sc{posix} mode' is in effect:
@enumerate
@item
@@ -5184,7 +5297,7 @@ exits with a non-zero status is `Done(status)'.
Reserved words may not be aliased.
@item
-The @sc{POSIX.2} @code{PS1} and @code{PS2} expansions of @samp{!} to
+The @sc{posix} 1003.2 @code{PS1} and @code{PS2} expansions of @samp{!} to
the history number and @samp{!!} to @samp{!} are enabled,
and parameter expansion is performed on the values of @code{PS1} and
@code{PS2} regardless of the setting of the @code{promptvars} option.
@@ -5194,7 +5307,7 @@ Interactive comments are enabled by default. (Bash has them on by
default anyway.)
@item
-The @sc{POSIX.2} startup files are executed (@code{$ENV}) rather than
+The @sc{posix} 1003.2 startup files are executed (@code{$ENV}) rather than
the normal Bash files.
@item
@@ -5222,17 +5335,21 @@ Redirection operators do not perform filename expansion on the word
in the redirection unless the shell is interactive.
@item
+Redirection operators do not perform word splitting on the word in the
+redirection.
+
+@item
Function names must be valid shell @code{name}s. That is, they may not
contain characters other than letters, digits, and underscores, and
may not start with a digit. Declaring a function with an invalid name
causes a fatal syntax error in non-interactive shells.
@item
-@sc{POSIX.2} `special' builtins are found before shell functions
+@sc{posix} 1003.2 `special' builtins are found before shell functions
during command lookup.
@item
-If a @sc{POSIX.2} special builtin returns an error status, a
+If a @sc{posix} 1003.2 special builtin returns an error status, a
non-interactive shell exits. The fatal errors are those listed in
the POSIX.2 standard, and include things like passing incorrect options,
redirection errors, variable assignment errors for assignments preceding
@@ -5268,16 +5385,16 @@ variable in a @code{for} statement or the selection variable in a
Process substitution is not available.
@item
-Assignment statements preceding @sc{POSIX.2} special builtins
+Assignment statements preceding @sc{posix} 1003.2 special builtins
persist in the shell environment after the builtin completes.
@item
The @code{export} and @code{readonly} builtin commands display their
-output in the format required by @sc{POSIX.2}.
+output in the format required by @sc{posix} 1003.2.
@end enumerate
-There is other @sc{POSIX.2} behavior that Bash does not implement.
+There is other @sc{posix} 1003.2 behavior that Bash does not implement.
Specifically:
@enumerate
@@ -5323,19 +5440,19 @@ like:
[1] 25647
@end example
@noindent
-indicating that this job is job number 1 and that the process @sc{ID}
+indicating that this job is job number 1 and that the process @sc{id}
of the last process in the pipeline associated with this job is
25647. All of the processes in a single pipeline are members of
the same job. Bash uses the @var{job} abstraction as the
basis for job control.
To facilitate the implementation of the user interface to job
-control, the system maintains the notion of a current terminal
-process group @sc{ID}. Members of this process group (processes whose
-process group @sc{ID} is equal to the current terminal process group
-@sc{ID}) receive keyboard-generated signals such as @code{SIGINT}.
+control, the operating system maintains the notion of a current terminal
+process group @sc{id}. Members of this process group (processes whose
+process group @sc{id} is equal to the current terminal process group
+@sc{id}) receive keyboard-generated signals such as @code{SIGINT}.
These processes are said to be in the foreground. Background
-processes are those whose process group @sc{ID} differs from the
+processes are those whose process group @sc{id} differs from the
terminal's; such processes are immune to keyboard-generated
signals. Only foreground processes are allowed to read from or
write to the terminal. Background processes which attempt to
@@ -5358,14 +5475,10 @@ takes effect immediately, and has the additional side effect of
causing pending output and typeahead to be discarded.
There are a number of ways to refer to a job in the shell. The
-character @samp{%} introduces a job name. Job number @code{n}
-may be referred to as @samp{%n}. A job may also be referred to
-using a prefix of the name used to start it, or using a substring
-that appears in its command line. For example, @samp{%ce} refers
-to a stopped @code{ce} job. Using @samp{%?ce}, on the
-other hand, refers to any job containing the string @samp{ce} in
-its command line. If the prefix or substring matches more than one job,
-Bash reports an error. The symbols @samp{%%} and
+character @samp{%} introduces a job name.
+
+Job number @code{n} may be referred to as @samp{%n}.
+The symbols @samp{%%} and
@samp{%+} refer to the shell's notion of the current job, which
is the last job stopped while it was in the foreground or started
in the background. The
@@ -5374,6 +5487,14 @@ pertaining to jobs (e.g., the output of the @code{jobs} command),
the current job is always flagged with a @samp{+}, and the
previous job with a @samp{-}.
+A job may also be referred to
+using a prefix of the name used to start it, or using a substring
+that appears in its command line. For example, @samp{%ce} refers
+to a stopped @code{ce} job. Using @samp{%?ce}, on the
+other hand, refers to any job containing the string @samp{ce} in
+its command line. If the prefix or substring matches more than one job,
+Bash reports an error.
+
Simply naming a job can be used to bring it into the foreground:
@samp{%1} is a synonym for @samp{fg %1}, bringing job 1 from the
background into the foreground. Similarly, @samp{%1 &} resumes
@@ -5425,7 +5546,7 @@ job control enabled, @var{jobspec} does not specify a valid job or
@item jobs
@btindex jobs
@example
-jobs [-lpnrs] [@var{jobspec}]
+jobs [-lnprs] [@var{jobspec}]
jobs -x @var{command} [@var{arguments}]
@end example
@@ -5434,14 +5555,14 @@ following meanings:
@table @code
@item -l
-List process @sc{ID}s in addition to the normal information.
+List process @sc{id}s in addition to the normal information.
@item -n
Display information only about jobs that have changed status since
the user was last notified of their status.
@item -p
-List only the process @sc{ID} of the job's process group leader.
+List only the process @sc{id} of the job's process group leader.
@item -r
Restrict output to running jobs.
@@ -5457,7 +5578,7 @@ listed.
If the @samp{-x} option is supplied, @code{jobs} replaces any
@var{jobspec} found in @var{command} or @var{arguments} with the
-corresponding process group @sc{ID}, and executes @var{command},
+corresponding process group @sc{id}, and executes @var{command},
passing it @var{argument}s, returning its exit status.
@item kill
@@ -5467,7 +5588,7 @@ kill [-s @var{sigspec}] [-n @var{signum}] [-@var{sigspec}] @var{jobspec} or @var
kill -l [@var{exit_status}]
@end example
Send a signal specified by @var{sigspec} or @var{signum} to the process
-named by job specification @var{jobspec} or process ID @var{pid}.
+named by job specification @var{jobspec} or process @sc{id} @var{pid}.
@var{sigspec} is either a signal name such as @code{SIGINT} (with or without
the @code{SIG} prefix) or a signal number; @var{signum} is a signal number.
If @var{sigspec} and @var{signum} are not present, @code{SIGTERM} is used.
@@ -5483,9 +5604,9 @@ or non-zero if an error occurs or an invalid option is encountered.
@item wait
@btindex wait
@example
-wait [@var{jobspec}|@var{pid}]
+wait [@var{jobspec} or @var{pid}]
@end example
-Wait until the child process specified by process @sc{ID} @var{pid} or job
+Wait until the child process specified by process @sc{id} @var{pid} or job
specification @var{jobspec} exits and return the exit status of the last
command waited for.
If a job spec is given, all processes in the job are waited for.
@@ -5523,7 +5644,7 @@ even if the shell is a login shell.
When job control is not active, the @code{kill} and @code{wait}
builtins do not accept @var{jobspec} arguments. They must be
-supplied process @sc{ID}s.
+supplied process @sc{id}s.
@node Job Control Variables
@section Job Control Variables
@@ -5543,19 +5664,19 @@ the string supplied must match the name of a stopped job exactly;
if set to @samp{substring},
the string supplied needs to match a substring of the name of a
stopped job. The @samp{substring} value provides functionality
-analogous to the @samp{%?} job @sc{ID} (@pxref{Job Control Basics}).
+analogous to the @samp{%?} job @sc{id} (@pxref{Job Control Basics}).
If set to any other value, the supplied string must
be a prefix of a stopped job's name; this provides functionality
-analogous to the @samp{%} job @sc{ID}.
+analogous to the @samp{%} job @sc{id}.
@end vtable
@set readline-appendix
@set history-appendix
-@cindex History, how to use
-@include hsuser.texinfo
@cindex Readline, how to use
@include rluser.texinfo
+@cindex History, how to use
+@include hsuser.texinfo
@clear readline-appendix
@clear history-appendix
@@ -5563,9 +5684,11 @@ analogous to the @samp{%} job @sc{ID}.
@chapter Installing Bash
This chapter provides basic instructions for installing Bash on
-the various supported platforms. The distribution supports nearly every
-version of Unix (and, someday, @sc{GNU}). Other independent ports exist for
-@sc{MS-DOS}, @sc{OS/2}, Windows @sc{95}, and Windows @sc{NT}.
+the various supported platforms. The distribution supports the
+@sc{gnu} operating systems, nearly every version of Unix, and several
+non-Unix systems such as BeOS and Interix.
+Other independent ports exist for
+@sc{ms-dos}, @sc{os/2}, Windows @sc{95/98}, and Windows @sc{nt}.
@menu
* Basic Installation:: Installation instructions.
@@ -5599,12 +5722,39 @@ version of Unix (and, someday, @sc{GNU}). Other independent ports exist for
These are installation instructions for Bash.
+The simplest way to compile Bash is:
+
+@enumerate
+@item
+@code{cd} to the directory containing the source code and type
+@samp{./configure} to configure Bash for your system. If you're
+using @code{csh} on an old version of System V, you might need to
+type @samp{sh ./configure} instead to prevent @code{csh} from trying
+to execute @code{configure} itself.
+
+Running @code{configure} takes some time.
+While running, it prints messages telling which features it is
+checking for.
+
+@item
+Type @samp{make} to compile Bash and build the @code{bashbug} bug
+reporting script.
+
+@item
+Optionally, type @samp{make tests} to run the Bash test suite.
+
+@item
+Type @samp{make install} to install @code{bash} and @code{bashbug}.
+This will also install the manual pages and Info file.
+
+@end enumerate
+
The @code{configure} shell script attempts to guess correct
values for various system-dependent variables used during
compilation. It uses those values to create a @file{Makefile} in
each directory of the package (the top directory, the
-@file{builtins} and @file{doc} directories, and the
-each directory under @file{lib}). It also creates a
+@file{builtins}, @file{doc}, and @file{support} directories,
+each directory under @file{lib}, and several others). It also creates a
@file{config.h} file containing system-dependent definitions.
Finally, it creates a shell script named @code{config.status} that you
can run in the future to recreate the current configuration, a
@@ -5615,6 +5765,16 @@ If at some point
@file{config.cache} contains results you don't want to keep, you
may remove or edit it.
+To find out more about the options and arguments that the
+@code{configure} script understands, type
+
+@example
+bash-2.04$ ./configure --help
+@end example
+
+@noindent
+at the Bash prompt in your Bash source directory.
+
If you need to do unusual things to compile Bash, please
try to figure out how @code{configure} could check whether or not
to do them, and mail diffs or instructions to
@@ -5637,32 +5797,6 @@ contain the patch level of the Bash distribution, @samp{0} for
example. The script @file{support/mkconffiles} has been provided
to automate the creation of these files.
-The simplest way to compile Bash is:
-
-@enumerate
-@item
-@code{cd} to the directory containing the source code and type
-@samp{./configure} to configure Bash for your system. If you're
-using @code{csh} on an old version of System V, you might need to
-type @samp{sh ./configure} instead to prevent @code{csh} from trying
-to execute @code{configure} itself.
-
-Running @code{configure} takes awhile. While running, it prints some
-messages telling which features it is checking for.
-
-@item
-Type @samp{make} to compile Bash and build the @code{bashbug} bug
-reporting script.
-
-@item
-Optionally, type @samp{make tests} to run the Bash test suite.
-
-@item
-Type @samp{make install} to install @code{bash} and @code{bashbug}.
-This will also install the manual pages and Info file.
-
-@end enumerate
-
You can remove the program binaries and object files from the
source code directory by typing @samp{make clean}. To also remove the
files that @code{configure} created (so you can compile Bash for
@@ -5731,14 +5865,14 @@ directories for other architectures.
By default, @samp{make install} will install into
@file{/usr/local/bin}, @file{/usr/local/man}, etc. You can
specify an installation prefix other than @file{/usr/local} by
-giving @code{configure} the option @samp{--prefix=PATH}.
+giving @code{configure} the option @samp{--prefix=@var{PATH}}.
You can specify separate installation prefixes for
architecture-specific files and architecture-independent files.
If you give @code{configure} the option
-@samp{--exec-prefix=PATH}, @samp{make install} will use @samp{PATH} as the
-prefix for installing programs and libraries. Documentation and
-other data files will still use the regular prefix.
+@samp{--exec-prefix=@var{PATH}}, @samp{make install} will use
+@var{PATH} as the prefix for installing programs and libraries.
+Documentation and other data files will still use the regular prefix.
@node Specifying the System Type
@section Specifying the System Type
@@ -5752,7 +5886,7 @@ either be a short name for the system type, such as @samp{sun4},
or a canonical name with three fields: @samp{CPU-COMPANY-SYSTEM}
(e.g., @samp{sparc-sun-sunos4.1.2}).
-@noindent See the file @file{support/config.sub} for the possible
+See the file @file{support/config.sub} for the possible
values of each field.
@node Sharing Defaults
@@ -5776,9 +5910,9 @@ operates.
@table @code
-@item --cache-file=@var{FILE}
+@item --cache-file=@var{file}
Use and save the results of the tests in
-@var{FILE} instead of @file{./config.cache}. Set @var{FILE} to
+@var{file} instead of @file{./config.cache}. Set @var{file} to
@file{/dev/null} to disable caching, for debugging
@code{configure}.
@@ -5790,8 +5924,8 @@ Print a summary of the options to @code{configure}, and exit.
@itemx -q
Do not print messages saying which checks are being made.
-@item --srcdir=@var{DIR}
-Look for the Bash source code in directory @var{DIR}. Usually
+@item --srcdir=@var{dir}
+Look for the Bash source code in directory @var{dir}. Usually
@code{configure} can determine that directory automatically.
@item --version
@@ -5800,18 +5934,18 @@ script, and exit.
@end table
@code{configure} also accepts some other, not widely used, boilerplate
-options.
+options. @samp{configure --help} prints the complete list.
@node Optional Features
@section Optional Features
-The Bash @code{configure} has a number of @samp{--enable-@var{FEATURE}}
-options, where @var{FEATURE} indicates an optional part of Bash.
-There are also several @samp{--with-@var{PACKAGE}} options,
-where @var{PACKAGE} is something like @samp{gnu-malloc} or @samp{purify}.
+The Bash @code{configure} has a number of @samp{--enable-@var{feature}}
+options, where @var{feature} indicates an optional part of Bash.
+There are also several @samp{--with-@var{package}} options,
+where @var{package} is something like @samp{bash-malloc} or @samp{purify}.
To turn off the default use of a package, use
-@samp{--without-@var{PACKAGE}}. To configure Bash without a feature
-that is enabled by default, use @samp{--disable-@var{FEATURE}}.
+@samp{--without-@var{package}}. To configure Bash without a feature
+that is enabled by default, use @samp{--disable-@var{feature}}.
Here is a complete list of the @samp{--enable-} and
@samp{--with-} options that the Bash @code{configure} recognizes.
@@ -5820,38 +5954,41 @@ Here is a complete list of the @samp{--enable-} and
@item --with-afs
Define if you are using the Andrew File System from Transarc.
+@item --with-bash-malloc
+Use the Bash version of
+@code{malloc} in @file{lib/malloc/malloc.c}. This is not the same
+@code{malloc} that appears in @sc{gnu} libc, but an older version
+derived from the 4.2 @sc{bsd} @code{malloc}. This @code{malloc} is
+very fast, but wastes some space on each allocation.
+This option is enabled by default.
+The @file{NOTES} file contains a list of systems for
+which this should be turned off, and @code{configure} disables this
+option automatically for a number of systems.
+
@item --with-curses
Use the curses library instead of the termcap library. This should
be supplied if your system has an inadequate or incomplete termcap
database.
@item --with-glibc-malloc
-Use the @sc{GNU} libc version of @code{malloc} in
+Use the @sc{gnu} libc version of @code{malloc} in
@file{lib/malloc/gmalloc.c}. This is not the version of @code{malloc}
that appears in glibc version 2, but a modified version of the
@code{malloc} from glibc version 1. This is somewhat slower than the
default @code{malloc}, but wastes less space on a per-allocation
basis, and will return memory to the operating system under
-some circumstances.
+certain circumstances.
@item --with-gnu-malloc
-Use the @sc{GNU} version of
-@code{malloc} in @file{lib/malloc/malloc.c}. This is not the same
-@code{malloc} that appears in @sc{GNU} libc, but an older version
-derived from the 4.2 @sc{BSD} @code{malloc}. This @code{malloc} is
-very fast, but wastes some space on each allocation.
-This option is enabled by default.
-The @file{NOTES} file contains a list of systems for
-which this should be turned off, and @code{configure} disables this
-option automatically for a number of systems.
+A synonym for @code{--with-bash-malloc}.
@item --with-installed-readline
-Define this to make bash link with a locally-installed version of Readline
-rather than the version in lib/readline. This works only with readline 4.0
-and later versions.
+Define this to make Bash link with a locally-installed version of Readline
+rather than the version in @file{lib/readline}. This works only with
+Readline 4.1 and later versions.
@item --with-purify
-Define this to use the Purify memory allocation checker from Pure
+Define this to use the Purify memory allocation checker from Rational
Software.
@item --enable-minimal-config
@@ -5874,10 +6011,10 @@ This could be used to build a version to use as root's shell.
The @samp{minimal-config} option can be used to disable all of
the following options, but it is processed first, so individual
-options may be enabled using @samp{enable-@var{FEATURE}}.
+options may be enabled using @samp{enable-@var{feature}}.
All of the following options except for @samp{disabled-builtins} and
-@samp{usg-echo-default} are
+@samp{xpg-echo-default} are
enabled by default, unless the operating system does not provide the
necessary support.
@@ -5886,6 +6023,11 @@ necessary support.
Allow alias expansion and include the @code{alias} and @code{unalias}
builtins (@pxref{Aliases}).
+@item --enable-arith-for-command
+Include support for the alternate form of the @code{for} command
+that behaves like the C language @code{for} statement
+(@pxref{Looping Constructs}).
+
@item --enable-array-variables
Include support for one-dimensional array shell variables
(@pxref{Arrays}).
@@ -5901,8 +6043,9 @@ See @ref{Brace Expansion}, for a complete description.
@item --enable-command-timing
Include support for recognizing @code{time} as a reserved word and for
-displaying timing statistics for the pipeline following @code{time}. This
-allows pipelines as well as shell builtins and functions to be timed.
+displaying timing statistics for the pipeline following @code{time}
+(@pxref{Pipelines}).
+This allows pipelines as well as shell builtins and functions to be timed.
@item --enable-cond-command
Include support for the @code{[[} conditional command
@@ -5929,16 +6072,22 @@ above under @ref{Pattern Matching}.
@item --enable-help-builtin
Include the @code{help} builtin, which displays help on shell builtins and
-variables.
+variables (@pxref{Bash Builtins}).
@item --enable-history
Include command history and the @code{fc} and @code{history}
-builtin commands.
+builtin commands (@pxref{Bash History Facilities}).
@item --enable-job-control
This enables the job control features (@pxref{Job Control}),
if the operating system supports them.
+@item --enable-net-redirections
+This enables the special handling of filenames of the form
+@code{/dev/tcp/@var{host}/@var{port}} and
+@code{/dev/udp/@var{host}/@var{port}}
+when used in redirections (@pxref{Redirections}).
+
@item --enable-process-substitution
This enables process substitution (@pxref{Process Substitution}) if
the operating system provides the necessary support.
@@ -5949,6 +6098,11 @@ in the @code{$PS1}, @code{$PS2}, @code{$PS3}, and @code{$PS4} prompt
strings. See @ref{Printing a Prompt}, for a complete list of prompt
string escape sequences.
+@item --enable-progcomp
+Enable the programmable completion facilities
+(@pxref{Programmable Completion}).
+If Readline is not enabled, this option has no effect.
+
@item --enable-readline
Include support for command-line editing and history with the Bash
version of the Readline library (@pxref{Command Line Editing}).
@@ -5963,13 +6117,20 @@ Include the @code{select} builtin, which allows the generation of simple
menus (@pxref{Conditional Constructs}).
@item --enable-usg-echo-default
+A synonym for @code{--enable-xpg-echo-default}.
+
+@item --enable-xpg-echo-default
Make the @code{echo} builtin expand backslash-escaped characters by default,
-without requiring the @samp{-e} option. This makes the Bash @code{echo}
-behave more like the System V version.
+without requiring the @samp{-e} option.
+This sets the default value of the @code{xpg_echo} shell option to @code{on},
+which makes the Bash @code{echo} behave more like the version specified in
+the Single Unix Specification, version 2.
+@xref{Bash Builtins}, for a description of the escape sequences that
+@code{echo} recognizes.
@end table
-The file @file{config.h.top} contains C Preprocessor
+The file @file{config-top.h} contains C Preprocessor
@samp{#define} statements for options which are not settable from
@code{configure}.
Some of these are not meant to be changed; beware of the consequences if
@@ -6014,24 +6175,426 @@ the template it provides for filing a bug report.
Please send all reports concerning this manual to
@email{chet@@po.CWRU.Edu}.
+@node Major Differences From The Bourne Shell
+@appendix Major Differences From The Bourne Shell
+
+Bash implements essentially the same grammar, parameter and
+variable expansion, redirection, and quoting as the Bourne Shell.
+Bash uses the @sc{posix} 1003.2 standard as the specification of
+how these features are to be implemented. There are some
+differences between the traditional Bourne shell and Bash; this
+section quickly details the differences of significance. A
+number of these differences are explained in greater depth in
+previous sections.
+This section uses the version of @code{sh} included SVR4.2 as
+the baseline reference.
+
+@itemize @bullet
+
+@item
+Bash is @sc{posix}-conformant, even where the @sc{posix} specification
+differs from traditional @code{sh} behavior.
+
+@item
+Bash has multi-character invocation options (@pxref{Invoking Bash}).
+
+@item
+Bash has command-line editing (@pxref{Command Line Editing}) and
+the @code{bind} builtin.
+
+@item
+Bash provides a programmable word completion mechanism
+(@pxref{Programmable Completion}), and two builtin commands,
+@code{complete} and @code{compgen}, to manipulate it.
+
+@item
+Bash has command history (@pxref{Bash History Facilities}) and the
+@code{history} and @code{fc} builtins to manipulate it.
+
+@item
+Bash implements @code{csh}-like history expansion
+(@pxref{History Interaction}).
+
+@item
+Bash has one-dimensional array variables (@pxref{Arrays}), and the
+appropriate variable expansions and assignment syntax to use them.
+Several of the Bash builtins take options to act on arrays.
+Bash provides a number of built-in array variables.
+
+@item
+The @code{$'@dots{}'} quoting syntax, which expands ANSI-C
+backslash-escaped characters in the text between the single quotes,
+is supported (@pxref{ANSI-C Quoting}).
+
+@item
+Bash supports the @code{$"@dots{}"} quoting syntax to do
+locale-specific translation of the characters between the double
+quotes. The @samp{-D}, @samp{--dump-strings}, and @samp{--dump-po-strings}
+invocation options list the translatable strings found in a script
+(@pxref{Locale Translation}).
+
+@item
+Bash implements the @code{!} keyword to negate the return value of
+a pipeline (@pxref{Pipelines}).
+Very useful when an @code{if} statement needs to act only if a test fails.
+
+@item
+Bash has the @code{time} reserved word and command timing (@pxref{Pipelines}).
+The display of the timing statistics may be controlled with the
+@code{TIMEFORMAT} variable.
+
+@item
+Bash implements the @code{for (( @var{expr1} ; @var{expr2} ; @var{expr3} ))}
+arithmetic for command, similar to the C language (@pxref{Looping Constructs}).
+
+@item
+Bash includes the @code{select} compound command, which allows the
+generation of simple menus (@pxref{Conditional Constructs}).
+
+@item
+Bash includes the @code{[[} compound command, which makes conditional
+testing part of the shell grammar (@pxref{Conditional Constructs}).
+
+@item
+Bash includes brace expansion (@pxref{Brace Expansion}) and tilde
+expansion (@pxref{Tilde Expansion}).
+
+@item
+Bash implements command aliases and the @code{alias} and @code{unalias}
+builtins (@pxref{Aliases}).
+
+@item
+Bash provides shell arithmetic, the @code{((} compound command
+(@pxref{Conditional Constructs}),
+and arithmetic expansion (@pxref{Shell Arithmetic}).
+
+@item
+Variables present in the shell's initial environment are automatically
+exported to child processes. The Bourne shell does not normally do
+this unless the variables are explicitly marked using the @code{export}
+command.
+
+@item
+Bash includes the @sc{posix} pattern removal @samp{%}, @samp{#}, @samp{%%}
+and @samp{##} expansions to remove leading or trailing substrings from
+variable values (@pxref{Shell Parameter Expansion}).
+
+@item
+The expansion @code{$@{#xx@}}, which returns the length of @code{$@{xx@}},
+is supported (@pxref{Shell Parameter Expansion}).
+
+@item
+The expansion @code{$@{var:}@var{offset}@code{[:}@var{length}@code{]@}},
+which expands to the substring of @code{var}'s value of length
+@var{length}, beginning at @var{offset}, is present
+(@pxref{Shell Parameter Expansion}).
+
+@item
+The expansion
+@code{$@{var/[/]}@var{pattern}@code{[/}@var{replacement}@code{]@}},
+which matches @var{pattern} and replaces it with @var{replacement} in
+the value of @code{var}, is available (@pxref{Shell Parameter Expansion}).
+
+@item
+The expansion @code{$@{!@var{prefix@}*}} expansion, which expands to
+the names of all shell variables whose names begin with @var{prefix},
+is available (@pxref{Shell Parameter Expansion}).
+
+@item
+Bash has @var{indirect} variable expansion using @code{$@{!word@}}
+(@pxref{Shell Parameter Expansion}).
+
+@item
+Bash can expand positional parameters beyond @code{$9} using
+@code{$@{@var{num}@}}.
+
+@item
+The @sc{posix} @code{$()} form of command substitution
+is implemented (@pxref{Command Substitution}),
+and preferred to the Bourne shell's @code{``} (which
+is also implemented for backwards compatibility).
+
+@item
+Bash has process substitution (@pxref{Process Substitution}).
+
+@item
+Bash automatically assigns variables that provide information about the
+current user (@code{UID}, @code{EUID}, and @code{GROUPS}), the current host
+(@code{HOSTTYPE}, @code{OSTYPE}, @code{MACHTYPE}, and @code{HOSTNAME}),
+and the instance of Bash that is running (@code{BASH},
+@code{BASH_VERSION}, and @code{BASH_VERSINFO}). @xref{Bash Variables},
+for details.
+
+@item
+The @code{IFS} variable is used to split only the results of expansion,
+not all words (@pxref{Word Splitting}).
+This closes a longstanding shell security hole.
+
+@item
+Bash implements the full set of @sc{posix} 1003.2 filename expansion operators,
+including @var{character classes}, @var{equivalence classes}, and
+@var{collating symbols} (@pxref{Filename Expansion}).
+
+@item
+Bash implements extended pattern matching features when the @code{extglob}
+shell option is enabled (@pxref{Pattern Matching}).
+
+@item
+It is possible to have a variable and a function with the same name;
+@code{sh} does not separate the two name spaces.
+
+@item
+Bash functions are permitted to have local variables using the
+@code{local} builtin, and thus useful recursive functions may be written
+(@pxref{Bash Builtins}).
+
+@item
+Variable assignments preceding commands affect only that command, even
+builtins and functions (@pxref{Environment}).
+In @code{sh}, all variable assignments
+preceding commands are global unless the command is executed from the
+file system.
+
+@item
+Bash performs filename expansion on filenames specified as operands
+to input and output redirection operators (@pxref{Redirections}).
+
+@item
+Bash contains the @samp{<>} redirection operator, allowing a file to be
+opened for both reading and writing, and the @samp{&>} redirection
+operator, for directing standard output and standard error to the same
+file (@pxref{Redirections}).
+
+@item
+Bash treats a number of filenames specially when they are
+used in redirection operators (@pxref{Redirections}).
+
+@item
+Bash can open network connections to arbitrary machines and services
+with the redirection operators (@pxref{Redirections}).
+
+@item
+The @code{noclobber} option is available to avoid overwriting existing
+files with output redirection (@pxref{The Set Builtin}).
+The @samp{>|} redirection operator may be used to override @code{noclobber}.
+
+@item
+The Bash @code{cd} and @code{pwd} builtins (@pxref{Bourne Shell Builtins})
+each take @samp{-L} and @samp{-P} builtins to switch between logical and
+physical modes.
+
+@item
+Bash allows a function to override a builtin with the same name, and provides
+access to that builtin's functionality within the function via the
+@code{builtin} and @code{command} builtins (@pxref{Bash Builtins}).
+
+@item
+The @code{command} builtin allows selective disabling of functions
+when command lookup is performed (@pxref{Bash Builtins}).
+
+@item
+Individual builtins may be enabled or disabled using the @code{enable}
+builtin (@pxref{Bash Builtins}).
+
+@item
+The Bash @code{exec} builtin takes additional options that allow users
+to control the contents of the environment passed to the executed
+command, and what the zeroth argument to the command is to be
+(@pxref{Bourne Shell Builtins}).
+
+@item
+Shell functions may be exported to children via the environment
+using @code{export -f} (@pxref{Shell Functions}).
+
+@item
+The Bash @code{export}, @code{readonly}, and @code{declare} builtins can
+take a @samp{-f} option to act on shell functions, a @samp{-p} option to
+display variables with various attributes set in a format that can be
+used as shell input, a @samp{-n} option to remove various variable
+attributes, and @samp{name=value} arguments to set variable attributes
+and values simultaneously.
+
+@item
+The Bash @code{hash} builtin allows a name to be associated with
+an arbitrary filename, even when that filename cannot be found by
+searching the @code{$PATH}, using @samp{hash -p}
+(@pxref{Bourne Shell Builtins}).
+
+@item
+Bash includes a @code{help} builtin for quick reference to shell
+facilities (@pxref{Bash Builtins}).
+
+@item
+The @code{printf} builtin is available to display formatted output
+(@pxref{Bash Builtins}).
+
+@item
+The Bash @code{read} builtin (@pxref{Bash Builtins})
+will read a line ending in @samp{\} with
+the @samp{-r} option, and will use the @code{REPLY} variable as a
+default if no non-option arguments are supplied.
+The Bash @code{read} builtin
+also accepts a prompt string with the @samp{-p} option and will use
+Readline to obtain the line when given the @samp{-e} option.
+The @code{read} builtin also has additional options to control input:
+the @samp{-s} option will turn off echoing of input characters as
+they are read, the @samp{-t} option will allow @code{read} to time out
+if input does not arrive within a specified number of seconds, the
+@samp{-n} option will allow reading only a specified number of
+characters rather than a full line, and the @samp{-d} option will read
+until a particular character rather than newline.
+
+@item
+The @code{return} builtin may be used to abort execution of scripts
+executed with the @code{.} or @code{source} builtins
+(@pxref{Bourne Shell Builtins}).
+
+@item
+Bash includes the @code{shopt} builtin, for finer control of shell
+optional capabilities (@pxref{Bash Builtins}).
+
+@item
+Bash has much more optional behavior controllable with the @code{set}
+builtin (@pxref{The Set Builtin}).
+
+@item
+The @code{test} builtin (@pxref{Bourne Shell Builtins})
+is slightly different, as it implements the @sc{posix} algorithm,
+which specifies the behavior based on the number of arguments.
+
+@item
+The @code{trap} builtin (@pxref{Bourne Shell Builtins})
+allows a @code{DEBUG} pseudo-signal specification,
+similar to @code{EXIT}. Commands specified with a @code{DEBUG} trap are
+executed after every simple command. The @code{DEBUG} trap is not
+inherited by shell functions.
+
+@item
+The Bash @code{type} builtin is more extensive and gives more information
+about the names it finds (@pxref{Bash Builtins}).
+
+@item
+The Bash @code{umask} builtin permits a @samp{-p} option to cause
+the output to be displayed in the form of a @code{umask} command
+that may be reused as input (@pxref{Bourne Shell Builtins}).
+
+@item
+Bash implements a @code{csh}-like directory stack, and provides the
+@code{pushd}, @code{popd}, and @code{dirs} builtins to manipulate it
+(@pxref{The Directory Stack}).
+Bash also makes the directory stack visible as the value of the
+@code{DIRSTACK} shell variable.
+
+@item
+Bash interprets special backslash-escaped characters in the prompt
+strings when interactive (@pxref{Printing a Prompt}).
+
+@item
+The Bash restricted mode is more useful (@pxref{The Restricted Shell});
+the SVR4.2 shell restricted mode is too limited.
+
+@item
+The @code{disown} builtin can remove a job from the internal shell
+job table (@pxref{Job Control Builtins}) or suppress the sending
+of @code{SIGHUP} to a job when the shell exits as the result of a
+@code{SIGHUP}.
+
+@item
+The SVR4.2 shell has two privilege-related builtins
+(@code{mldmode} and @code{priv}) not present in Bash.
+
+@item
+Bash does not have the @code{stop} or @code{newgrp} builtins.
+
+@item
+Bash does not use the @code{SHACCT} variable or perform shell accounting.
+
+@item
+The SVR4.2 @code{sh} uses a @code{TIMEOUT} variable like Bash uses
+@code{TMOUT}.
+
+@end itemize
+
+@noindent
+More features unique to Bash may be found in @ref{Bash Features}.
+
+
+@appendixsec Implementation Differences From The SVR4.2 Shell
+
+Since Bash is a completely new implementation, it does not suffer from
+many of the limitations of the SVR4.2 shell. For instance:
+
+@itemize @bullet
+
+@item
+Bash does not fork a subshell when redirecting into or out of
+a shell control structure such as an @code{if} or @code{while}
+statement.
+
+@item
+Bash does not allow unbalanced quotes. The SVR4.2 shell will silently
+insert a needed closing quote at @code{EOF} under certain circumstances.
+This can be the cause of some hard-to-find errors.
+
+@item
+The SVR4.2 shell uses a baroque memory management scheme based on
+trapping @code{SIGSEGV}. If the shell is started from a process with
+@code{SIGSEGV} blocked (e.g., by using the @code{system()} C library
+function call), it misbehaves badly.
+
+@item
+In a questionable attempt at security, the SVR4.2 shell,
+when invoked without the @samp{-p} option, will alter its real
+and effective @sc{uid} and @sc{gid} if they are less than some
+magic threshold value, commonly 100.
+This can lead to unexpected results.
+
+@item
+The SVR4.2 shell does not allow users to trap @code{SIGSEGV},
+@code{SIGALRM}, or @code{SIGCHLD}.
+
+@item
+The SVR4.2 shell does not allow the @code{IFS}, @code{MAILCHECK},
+@code{PATH}, @code{PS1}, or @code{PS2} variables to be unset.
+
+@item
+The SVR4.2 shell treats @samp{^} as the undocumented equivalent of
+@samp{|}.
+
+@item
+Bash allows multiple option arguments when it is invoked (@code{-x -v});
+the SVR4.2 shell allows only one option argument (@code{-xv}). In
+fact, some versions of the shell dump core if the second argument begins
+with a @samp{-}.
+
+@item
+The SVR4.2 shell exits a script if any builtin fails; Bash exits
+a script only if one of the @sc{posix} 1003.2 special builtins fails, and
+only for certain failures, as enumerated in the @sc{posix} 1003.2 standard.
+
+@item
+The SVR4.2 shell behaves differently when invoked as @code{jsh}
+(it turns on job control).
+@end itemize
+
@node Builtin Index
-@appendix Index of Shell Builtin Commands
+@unnumbered Index of Shell Builtin Commands
@printindex bt
@node Reserved Word Index
-@appendix Shell Reserved Words
+@unnumbered Index of Shell Reserved Words
@printindex rw
@node Variable Index
-@appendix Parameter and Variable Index
+@unnumbered Parameter and Variable Index
@printindex vr
@node Function Index
-@appendix Function Index
+@unnumbered Function Index
@printindex fn
@node Concept Index
-@appendix Concept Index
+@unnumbered Concept Index
@printindex cp
@contents
diff --git a/doc/builtins.1 b/doc/builtins.1
index d0aa6312..bd9a1f8c 100644
--- a/doc/builtins.1
+++ b/doc/builtins.1
@@ -1,6 +1,6 @@
.\" This is a hack to force bash builtins into the whatis database
.\" and to get the list of builtins to come up with the man command.
-.TH BASH_BUILTINS 1 "1996 March 20" GNU
+.TH BASH_BUILTINS 1 "1996 Mar 20" GNU
.SH NAME
bash, :, ., alias, bg, bind, break, builtin, case, cd, command,
continue, declare, dirs, disown, echo, enable, eval, exec, exit,
diff --git a/doc/htmlpost.sh b/doc/htmlpost.sh
index aa015425..51241b17 100755
--- a/doc/htmlpost.sh
+++ b/doc/htmlpost.sh
@@ -6,14 +6,14 @@
# directory of the user running navigator
#
-sed -e 's|<B>gnu.bash.bug</B>|<A HREF="news:gnu.bash.bug">gnu.bash.bug</A>|' \
- -e 's|<I>/bin/bash</I>|<A HREF="file:/bin/bash"><I>/bin/bash</I></A>|' \
- -e 's|<I>/etc/profile</I>|<A HREF="file:/etc/profile"><I>/etc/profile</I></A>|' \
- -e 's|<I>~/.bash_profile</I>|<A HREF="file:~/.bash_profile"><I>~/.bash_profile</I></A>|' \
- -e 's|<I>~/.bash_login</I>|<A HREF="file:~/.bash_login"><I>~/.bash_login</I></A>|' \
- -e 's|<I>~/.profile</I>|<A HREF="file:~/.profile"><I>~/.profile</I></A>|' \
- -e 's|<I>~/.bashrc</I>|<A HREF="file:~/.bashrc"><I>~/.bashrc</I></A>|' \
- -e 's|<I>~/.bash_logout</I>|<A HREF="file:~/.bash_logout"><I>~/.bash_logout</I></A>|' \
- -e 's|<I>~/.bash_history</I>|<A HREF="file:~/.bash_history"><I>~/.bash_history</I></A>|' \
- -e 's|<I>~/.inputrc</I>|<A HREF="file:~/.inputrc"><I>~/.inputrc</I></A>|' \
- -e 's|<I>/etc/inputrc</I>|<A HREF="file:/etc/inputrc"><I>/etc/inputrc</I></A>|'
+sed -e 's|<B>gnu.bash.bug</B>|<A HREF="news:gnu.bash.bug">gnu.bash.bug</A>|g' \
+ -e 's|<I>/bin/bash</I>|<A HREF="file:/bin/bash"><I>/bin/bash</I></A>|g' \
+ -e 's|<I>/etc/profile</I>|<A HREF="file:/etc/profile"><I>/etc/profile</I></A>|g' \
+ -e 's|<I>~/.bash_profile</I>|<A HREF="file:~/.bash_profile"><I>~/.bash_profile</I></A>|g' \
+ -e 's|<I>~/.bash_login</I>|<A HREF="file:~/.bash_login"><I>~/.bash_login</I></A>|g' \
+ -e 's|<I>~/.profile</I>|<A HREF="file:~/.profile"><I>~/.profile</I></A>|g' \
+ -e 's|<I>~/.bashrc</I>|<A HREF="file:~/.bashrc"><I>~/.bashrc</I></A>|g' \
+ -e 's|<I>~/.bash_logout</I>|<A HREF="file:~/.bash_logout"><I>~/.bash_logout</I></A>|g' \
+ -e 's|<I>~/.bash_history</I>|<A HREF="file:~/.bash_history"><I>~/.bash_history</I></A>|g' \
+ -e 's|<I>~/.inputrc</I>|<A HREF="file:~/.inputrc"><I>~/.inputrc</I></A>|g' \
+ -e 's|<I>/etc/inputrc</I>|<A HREF="file:/etc/inputrc"><I>/etc/inputrc</I></A>|g'
diff --git a/doc/rbash.1 b/doc/rbash.1
new file mode 100644
index 00000000..78a247c2
--- /dev/null
+++ b/doc/rbash.1
@@ -0,0 +1,8 @@
+.TH RBASH 1 "1999 Nov 29" GNU
+.SH NAME
+rbash \- restricted bash, see \fBbash\fR(1)
+.SH RESTRICTED SHELL
+.nr zY 1
+.so bash.1
+.SH SEE ALSO
+bash(1)
diff --git a/doc/readline.3 b/doc/readline.3
index 6b36f2f5..c1ed9cf7 100644
--- a/doc/readline.3
+++ b/doc/readline.3
@@ -6,9 +6,9 @@
.\" Case Western Reserve University
.\" chet@ins.CWRU.Edu
.\"
-.\" Last Change: Thu Dec 31 10:16:30 EST 1998
+.\" Last Change: Tue Jun 1 13:28:03 EDT 1999
.\"
-.TH READLINE 3 "1998 Dec 31" GNU
+.TH READLINE 3 "1999 Jun 1" GNU
.\"
.\" File Name macro. This used to be `.PN', for Path Name,
.\" but Sun doesn't seem to like that very much.
@@ -148,6 +148,7 @@ processing key bindings:
.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).
.PP
@@ -564,7 +565,7 @@ 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 this, or the previous, word. Words are
+Move back to the start of the current or previous word. Words are
composed of alphanumeric characters (letters and digits).
.TP
.B clear\-screen (C\-l)
@@ -1172,9 +1173,9 @@ VI Command Mode functions
Individual \fBreadline\fP initialization file
.PD
.SH AUTHORS
-Brian Fox, Free Software Foundation (primary author)
+Brian Fox, Free Software Foundation
.br
-bfox@ai.MIT.Edu
+bfox@gnu.org
.PP
Chet Ramey, Case Western Reserve University
.br
diff --git a/error.c b/error.c
index 0652efe8..2631ab4e 100644
--- a/error.c
+++ b/error.c
@@ -15,7 +15,7 @@
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#include "config.h"
@@ -64,7 +64,7 @@ extern int give_terminal_to ();
/* The current maintainer of the shell. You change this in the
Makefile. */
#if !defined (MAINTAINER)
-#define MAINTAINER "bash-maintainers@prep.ai.mit.edu"
+#define MAINTAINER "bash-maintainers@gnu.org"
#endif
char *the_current_maintainer = MAINTAINER;
@@ -121,7 +121,10 @@ programming_error (reason, arg1, arg2, arg3, arg4, arg5)
}
#endif
+#if 0
fprintf (stderr, "Report this to %s\n", the_current_maintainer);
+#endif
+
fprintf (stderr, "Stopping myself...");
fflush (stderr);
@@ -245,7 +248,10 @@ programming_error (format, va_alist)
}
#endif
+#if 0
fprintf (stderr, "Report this to %s\n", the_current_maintainer);
+#endif
+
fprintf (stderr, "Stopping myself...");
fflush (stderr);
@@ -455,7 +461,6 @@ itrace (format, va_alist)
fflush(stderr);
}
-#if 0
/* A trace function for silent debugging -- doesn't require a control
terminal. */
void
@@ -471,7 +476,7 @@ trace (format, va_alist)
static FILE *tracefp = (FILE *)NULL;
if (tracefp == NULL)
- tracefp = fopen("/usr/tmp/bash-trace.log", "a+");
+ tracefp = fopen("/tmp/bash-trace.log", "a+");
if (tracefp == NULL)
tracefp = stderr;
@@ -493,7 +498,6 @@ trace (format, va_alist)
fflush(tracefp);
}
-#endif /* 0 */
#endif /* USE_VARARGS */
diff --git a/error.h b/error.h
index e0472f97..08640b34 100644
--- a/error.h
+++ b/error.h
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if !defined (_ERROR_H_)
#define _ERROR_H_
diff --git a/eval.c b/eval.c
index 3ca5141f..1ecc5769 100644
--- a/eval.c
+++ b/eval.c
@@ -1,24 +1,22 @@
-/* eval.c -- reading and evaluating commands.
+/* eval.c -- reading and evaluating commands. */
- Copyright (C) 1996 Free Software Foundation, Inc.
+/* Copyright (C) 1996 Free Software Foundation, Inc.
- This file is part of GNU Bash.
+ This file is part of GNU Bash, the Bourne Again SHell.
- Bash is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY. No author or distributor accepts responsibility to
- anyone for the consequences of using it or for whether it serves
- any particular purpose or works at all, unless he says so in
- writing. Refer to the GNU Emacs General Public License for full
- details.
+ Bash is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
- Everyone is granted permission to copy, modify and redistribute
- Bash, but only under the conditions described in the GNU General
- Public License. A copy of this license is supposed to have been
- given to you along with GNU Emacs so you can know your rights and
- responsibilities. It should be in a file named COPYING.
+ 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.
- Among other things, the copyright notice and this notice must be
- preserved on all copies. */
+ You should have received a copy of the GNU General Public License
+ along with Bash; see the file COPYING. If not, write to the Free
+ Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#include "config.h"
@@ -49,11 +47,11 @@ extern int yyparse ();
extern int EOF_reached;
extern int indirection_level, interactive, interactive_shell;
+extern int posixly_correct;
extern int subshell_environment, running_under_emacs;
extern int last_command_exit_value, stdin_redir;
extern int need_here_doc;
extern int current_command_number, current_command_line_count, line_number;
-extern char *ps1_prompt, **prompt_string_pointer;
extern int expand_aliases;
/* Read and execute commands until EOF is reached. This assumes that
@@ -89,6 +87,8 @@ reader_loop ()
case FORCE_EOF:
case EXITPROG:
current_command = (COMMAND *)NULL;
+ if (exit_immediately_on_error)
+ variable_context = 0; /* not in a function */
EOF_Reached = EOF;
goto exec_done;
@@ -228,7 +228,7 @@ read_command ()
int tmout_len, result;
SigHandler *old_alrm;
- prompt_string_pointer = &ps1_prompt;
+ set_current_prompt_level (1);
global_command = (COMMAND *)NULL;
/* Only do timeouts if interactive. */
@@ -264,56 +264,3 @@ read_command ()
return (result);
}
-
-/* Take a string and run it through the shell parser, returning the
- resultant word list. Used by compound array assignment. */
-WORD_LIST *
-parse_string_to_word_list (s, whom)
- char *s, *whom;
-{
- WORD_LIST *wl;
- COMMAND *saved_global;
-#if defined (HISTORY)
- int old_remember_on_history, old_history_expansion_inhibited;
-#endif
-
-#if defined (HISTORY)
- old_remember_on_history = remember_on_history;
-# if defined (BANG_HISTORY)
- old_history_expansion_inhibited = history_expansion_inhibited;
-# endif
- bash_history_disable ();
-#endif
-
- push_stream (1);
-
- saved_global = global_command;
- global_command = (COMMAND *)0;
-
- with_input_from_string (s, whom);
- if (parse_command () != 0 || global_command == 0 || global_command->type != cm_simple)
- {
- if (global_command)
- dispose_command (global_command);
- wl = (WORD_LIST *)NULL;
- }
- else
- {
- wl = global_command->value.Simple->words;
- free (global_command->value.Simple);
- free (global_command);
- }
-
- global_command = saved_global;
-
- pop_stream ();
-
-#if defined (HISTORY)
- remember_on_history = old_remember_on_history;
-# if defined (BANG_HISTORY)
- history_expansion_inhibited = old_history_expansion_inhibited;
-# endif /* BANG_HISTORY */
-#endif /* HISTORY */
-
- return (wl);
-}
diff --git a/examples/complete/complete-examples b/examples/complete/complete-examples
new file mode 100644
index 00000000..3b28dd2a
--- /dev/null
+++ b/examples/complete/complete-examples
@@ -0,0 +1,485 @@
+#
+# Completion examples
+#
+
+#
+# This encapsulates the default bash completion code
+# call with the word to be completed as $1
+#
+# Since programmable completion does not use the bash default completions
+# or the readline default of filename completion when the compspec does
+# not generate any matches, this may be used as a `last resort' in a
+# completion function to mimic the default bash completion behavior.
+#
+_bash_def_completion ()
+{
+ local h t
+ COMPREPLY=()
+
+ # command substitution
+ if [[ "$1" == \$\(* ]]; then
+ t=${1#??}
+ COMPREPLY=( $(compgen -c -P '$(' $t) )
+ fi
+ # variables with a leading `${'
+ if [ ${#COMPREPLY[@]} -eq 0 ] && [[ "$1" == \$\{* ]]; then
+ t=${1#??}
+ COMPREPLY=( $(compgen -v -P '${' -S '}' $t) )
+ fi
+ # variables with a leading `$'
+ if [ ${#COMPREPLY[@]} -eq 0 ] && [[ "$1" == \$* ]]; then
+ t=${1#?}
+ COMPREPLY=( $(compgen -v -P '$' $t ) )
+ fi
+ # username expansion
+ if [ ${#COMPREPLY[@]} -eq 0 ] && [[ "$1" == ~* ]] && [[ "$1" != */* ]]; then
+ t=${1#?}
+ COMPREPLY=( $( compgen -u -P '~' $t ) )
+ fi
+ # hostname
+ if [ ${#COMPREPLY[@]} -eq 0 ] && [[ "$1" == *@* ]]; then
+ h=${1%%@*}
+ t=${1#*@}
+ COMPREPLY=( $( compgen -A hostname -P "${h}@" $t ) )
+ fi
+ # glob pattern
+ if [ ${#COMPREPLY[@]} -eq 0 ]; then
+ # sh-style glob pattern
+ if [[ $1 == *[*?[]* ]]; then
+ COMPREPLY=( $( compgen -G "$1" ) )
+ # ksh-style extended glob pattern - must be complete
+ elif shopt -q extglob && [[ $1 == *[?*+\!@]\(*\)* ]]; then
+ COMPREPLY=( $( compgen -G "$1" ) )
+ fi
+ fi
+
+ # final default is filename completion
+ if [ ${#COMPREPLY[@]} -eq 0 ]; then
+ COMPREPLY=( $(compgen -f "$1" ) )
+ fi
+}
+
+#
+# Return 1 if $1 appears to contain a redirection operator. Handles backslash
+# quoting (barely).
+#
+_redir_op()
+{
+ case "$1" in
+ *\\'[\<\>]'*) return 1;;
+ *[\<\>]*) return 0;;
+ *) return 1;;
+ esac
+}
+
+
+# _redir_test tests the current word ($1) and the previous word ($2) for
+# redirection operators and does filename completion on the current word
+# if either one contains a redirection operator
+_redir_test()
+{
+ if _redir_op "$1" ; then
+ COMPREPLY=( $( compgen -f "$1" ) )
+ return 0
+ elif _redir_op "$2" ; then
+ COMPREPLY=( $( compgen -f "$1" ) )
+ return 0
+ fi
+ return 1
+}
+
+# optional, but without this you can't use extended glob patterns
+shopt -s extglob
+
+#
+# Easy ones for the shell builtins
+#
+# nothing for: alias, break, continue, dirs, echo, eval, exit, getopts,
+# let, logout, popd, printf, pwd, return, shift, suspend, test, times,
+# umask
+#
+
+complete -f -- . source
+complete -A enabled builtin
+complete -d cd
+
+# this isn't exactly right yet -- needs to skip shell functions and
+# do $PATH lookup (or do compgen -c and filter out matches that also
+# appear in compgen -A function)
+complete -c command
+
+# could add -S '=', but that currently screws up because readline appends
+# a space unconditionally
+
+complete -v export local readonly
+complete -A helptopic help # currently same as builtins
+
+complete -d pushd
+
+complete -A shopt shopt
+
+complete -c type
+
+complete -a unalias
+complete -v unset
+
+#
+# Job control builtins: fg, bg, disown, kill, wait
+# kill not done yet
+#
+
+complete -A stopped -P '%' bg
+complete -j -P '%' fg jobs disown
+
+# this is not quite right at this point
+
+_wait_func ()
+{
+ local cur
+ cur=${COMP_WORDS[COMP_CWORD]}
+
+ case "$cur" in
+ %*) COMPREPLY=( $(compgen -A running -P '%' ${cur#?} ) ) ;;
+ [0-9]*) COMPREPLY=( $(jobs -p | grep ^${cur}) ) ;;
+ *) COMPREPLY=( $(compgen -A running -P '%') $(jobs -p) )
+ ;;
+ esac
+}
+complete -F _wait_func wait
+
+#
+# more complicated things, several as yet unimplemented
+#
+
+#complete -F _bind_func bind
+
+_declare_func()
+{
+ local cur prev nflag opts
+
+ cur=${COMP_WORDS[COMP_CWORD]}
+ prev=${COMP_WORDS[COMP_CWORD-1]}
+
+ COMPREPLY=()
+ if (( $COMP_CWORD <= 1 )) || [[ $cur == '-' ]]; then
+ COMPREPLY=(-a -f -F -i -r -x -p)
+ return 0;
+ fi
+ if [[ $cur == '+' ]]; then
+ COMPREPLY=(+i +x)
+ return 0;
+ fi
+ if [[ $prev == '-p' ]]; then
+ COMPREPLY=( $(compgen -v $cur) )
+ return 0;
+ fi
+ return 1
+}
+complete -F _declare_func declare typeset
+
+_enable_func()
+{
+ local cur prev nflag opts
+
+ cur=${COMP_WORDS[COMP_CWORD]}
+ prev=${COMP_WORDS[COMP_CWORD-1]}
+
+ COMPREPLY=()
+ if (( $COMP_CWORD <= 1 )) || [[ $cur == '-' ]]; then
+ COMPREPLY=(-a -d -f -n -p -s)
+ return 0;
+ fi
+ if [[ $prev == '-f' ]]; then
+ COMPREPLY=( $( compgen -f $cur ) )
+ return 0;
+ fi
+ for opts in "${COMP_WORDS[@]}" ; do
+ if [[ $opts == -*n* ]]; then nflag=1; fi
+ done
+
+ if [ -z "$nflag" ] ; then
+ COMPREPLY=( $( compgen -A enabled $cur ) )
+ else
+ COMPREPLY=( $( compgen -A disabled $cur ) )
+ fi
+ return 0;
+}
+complete -F _enable_func enable
+
+_exec_func()
+{
+ local cur prev
+
+ cur=${COMP_WORDS[COMP_CWORD]}
+ prev=${COMP_WORDS[COMP_CWORD-1]}
+
+ if (( $COMP_CWORD <= 1 )) || [[ $cur == '-' ]]; then
+ COMPREPLY=(-a -c -l)
+ return 0;
+ fi
+ if [[ $prev != -*a* ]]; then
+ COMPREPLY=( $( compgen -c $cur ) )
+ return 0
+ fi
+ return 1;
+}
+complete -F _exec_func exec
+
+_fc_func()
+{
+ local cur prev
+
+ cur=${COMP_WORDS[COMP_CWORD]}
+ prev=${COMP_WORDS[COMP_CWORD-1]}
+
+ if (( $COMP_CWORD <= 1 )) || [[ $cur == '-' ]]; then
+ COMPREPLY=(-e -n -l -r -s)
+ return 0;
+ fi
+ if [[ $prev == -*e ]]; then
+ COMPREPLY=( $(compgen -c $cur) )
+ return 0
+ fi
+ return 1
+}
+complete -F _fc_func fc
+
+_hash_func()
+{
+ local cur prev
+
+ cur=${COMP_WORDS[COMP_CWORD]}
+ prev=${COMP_WORDS[COMP_CWORD-1]}
+
+ if (( $COMP_CWORD <= 1 )) || [[ $cur == '-' ]]; then
+ COMPREPLY=(-p -r)
+ return 0;
+ fi
+
+ if [[ $prev == '-p' ]]; then
+ COMPREPLY=( $( compgen -f $cur ) )
+ return 0;
+ fi
+ COMPREPLY=( $( compgen -c $cur ) )
+ return 0
+}
+complete -F _hash_func hash
+
+_history_func()
+{
+ local cur prev
+
+ cur=${COMP_WORDS[COMP_CWORD]}
+ prev=${COMP_WORDS[COMP_CWORD-1]}
+
+ COMPREPLY=()
+ if (( $COMP_CWORD <= 1 )) || [[ $cur == '-' ]]; then
+ COMPREPLY=(-a -c -d -n -r -w -p -s)
+ return 0;
+ fi
+ if [[ $prev == -[anrw] ]]; then
+ COMPREPLY=( $( compgen -f $cur ) )
+ fi
+ return 0
+}
+complete -F _history_func history
+
+#complete -F _read_func read
+
+_set_func ()
+{
+ local cur prev
+
+ cur=${COMP_WORDS[COMP_CWORD]}
+ prev=${COMP_WORDS[COMP_CWORD-1]}
+
+ COMPREPLY=()
+
+ _redir_test "$cur" "$prev" && return 0;
+
+ if (( $COMP_CWORD <= 1 )) || [[ $cur == '-' ]]; then
+ COMPREPLY=(-a -b -e -f -k -m -n -o -p -t -u -v -x -B -C -H -P --)
+ return 0;
+ fi
+ if [[ $cur == '+' ]]; then
+ COMPREPLY=(+a +b +e +f +k +m +n +o +p +t +u +v +x +B +C +H +P)
+ return 0;
+ fi
+ if [[ $prev == [+-]o ]]; then
+ COMPREPLY=( $(compgen -A setopt $cur) )
+ return 0;
+ fi
+ return 1;
+}
+complete -F _set_func set
+
+_trap_func ()
+{
+ local cur
+ cur=${COMP_WORDS[COMP_CWORD]}
+
+ if (( $COMP_CWORD <= 1 )) || [[ $cur == '-' ]]; then
+ COMPREPLY=(-l -p)
+ return 0;
+ fi
+ COMPREPLY=( $( compgen -A signal ${cur}) )
+ return 0
+}
+complete -F _trap_func trap
+
+#
+# meta-completion (completion for complete/compgen)
+#
+_complete_meta_func()
+{
+ local cur prev cmd
+ COMPREPLY=()
+
+ cmd=$1
+
+ cur=${COMP_WORDS[COMP_CWORD]}
+ prev=${COMP_WORDS[COMP_CWORD-1]}
+
+ _redir_test "$cur" "$prev" && return 0;
+
+ if (( $COMP_CWORD <= 1 )) || [[ "$cur" == '-' ]]; then
+ case "$cmd" in
+ complete) COMPREPLY=(-a -b -c -d -e -f -j -k -v -u -r -p -A -G -W -P -S -X -F -C);;
+ compgen) COMPREPLY=(-a -b -c -d -e -f -j -k -v -u -A -G -W -P -S -X -F -C);;
+ esac
+ return 0
+ fi
+
+ if [[ $prev == -A ]]; then
+ COMPREPLY=(alias arrayvar binding builtin command directory \
+disabled enabled export file function helptopic hostname job keyword \
+running setopt shopt signal stopped variable)
+ return 0
+ elif [[ $prev == -F ]]; then
+ COMPREPLY=( $( compgen -A function $cur ) )
+ elif [[ $prev == -C ]]; then
+ COMPREPLY=( $( compgen -c $cur ) )
+ else
+ COMPREPLY=( $( compgen -c $cur ) )
+ fi
+ return 0
+}
+complete -F _complete_meta_func complete compgen
+
+#
+# some completions for shell reserved words
+#
+#complete -c -k time do if then else elif '{'
+
+#
+# external commands
+#
+
+complete -e printenv
+
+complete -c nohup exec nice eval trace truss strace sotruss gdb
+
+_make_targets ()
+{
+ local mdef makef gcmd cur prev i
+
+ COMPREPLY=()
+ cur=${COMP_WORDS[COMP_CWORD]}
+ prev=${COMP_WORDS[COMP_CWORD-1]}
+
+ # if prev argument is -f, return possible filename completions.
+ # we could be a little smarter here and return matches against
+ # `makefile Makefile *.mk', whatever exists
+ case "$prev" in
+ -*f) COMPREPLY=( $(compgen -f $cur ) ); return 0;;
+ esac
+
+ # if we want an option, return the possible posix options
+ case "$cur" in
+ -) COMPREPLY=(-e -f -i -k -n -p -q -r -S -s -t); return 0;;
+ esac
+
+ # make reads `makefile' before `Makefile'
+ if [ -f makefile ]; then
+ mdef=makefile
+ elif [ -f Makefile ]; then
+ mdef=Makefile
+ else
+ mdef=*.mk # local convention
+ fi
+
+ # before we scan for targets, see if a makefile name was specified
+ # with -f
+ for (( i=0; i < ${#COMP_WORDS[@]}; i++ )); do
+ if [[ ${COMP_WORDS[i]} == -*f ]]; then
+ eval makef=${COMP_WORDS[i+1]} # eval for tilde expansion
+ break
+ fi
+ done
+
+ [ -z "$makef" ] && makef=$mdef
+
+ # if we have a partial word to complete, restrict completions to
+ # matches of that word
+ if [ -n "$2" ]; then gcmd='grep "^$2"' ; else gcmd=cat ; fi
+
+ # if we don't want to use *.mk, we can take out the cat and use
+ # test -f $makef and input redirection
+ COMPREPLY=( $(cat $makef 2>/dev/null | awk 'BEGIN {FS=":"} /^[^.# ][^=]*:/ {print $1}' | tr -s ' ' '\012' | sort -u | eval $gcmd ) )
+}
+complete -F _make_targets -X '+($*|*.[cho])' make gmake pmake
+
+_umount_func ()
+{
+ COMPREPLY=( $(mount | awk '{print $1}') )
+}
+complete -F _umount_func umount
+
+_configure_func ()
+{
+ case "$2" in
+ -*) ;;
+ *) return ;;
+ esac
+
+ case "$1" in
+ \~*) eval cmd=$1 ;;
+ *) cmd="$1" ;;
+ esac
+
+ COMPREPLY=( $("$cmd" --help | awk '{if ($1 ~ /--.*/) print $1}' | grep ^"$2" | sort -u) )
+}
+complete -F _configure_func configure
+
+complete -W '"${GROUPS[@]}"' newgrp
+
+complete -f chown ln more cat
+complete -d mkdir rmdir
+complete -f strip
+
+complete -f -X '*.gz' gzip
+complete -f -X '*.Z' compress
+complete -f -X '!*.+(gz|tgz|Gz)' gunzip gzcat zcat zmore
+complete -f -X '!*.Z' uncompress zmore zcat
+
+complete -f -X '!*.+(gif|jpg|jpeg|GIF|JPG|bmp)' xv
+
+complete -f -X '!*.pl' perl perl5
+
+complete -A hostname rsh telnet rlogin ftp ping xping host traceroute nslookup
+complete -A hostname rxterm rxterm3 rxvt2
+
+complete -u su
+
+complete -f -X '!*.+(ps|PS)' gs gv ghostview psselect pswrap
+complete -f -X '!*.+(dvi|DVI)' dvips xdvi dviselect dvitype
+complete -f -X '!*.+(pdf|PDF)' acroread
+complete -f -X '!*.texi*' makeinfo texi2dvi texi2html
+complete -f -X '!*.+(tex|TEX)' tex latex slitex
+
+#
+# other possibilities, left as exercises
+#
+#complete -F _find_func find
+#complete -F _man_func man
+#complete -F _stty_func stty
diff --git a/examples/functions/array-stuff b/examples/functions/array-stuff
new file mode 100644
index 00000000..97ed5123
--- /dev/null
+++ b/examples/functions/array-stuff
@@ -0,0 +1,103 @@
+# usage: reverse arrayname
+reverse()
+{
+ local -a R
+ local -i i
+ local rlen temp
+
+ # make r a copy of the array whose name is passed as an arg
+ eval R=\( \"\$\{$1\[@\]\}\" \)
+
+ # reverse R
+ rlen=${#R[@]}
+
+ for ((i=0; i < rlen/2; i++ ))
+ do
+ temp=${R[i]}
+ R[i]=${R[rlen-i-1]}
+ R[rlen-i-1]=$temp
+ done
+
+ # and assign R back to array whose name is passed as an arg
+ eval $1=\( \"\$\{R\[@\]\}\" \)
+}
+
+A=(1 2 3 4 5 6 7)
+echo "${A[@]}"
+reverse A
+echo "${A[@]}"
+reverse A
+echo "${A[@]}"
+
+# unset last element of A
+alen=${#A[@]}
+unset A[$alen-1]
+echo "${A[@]}"
+
+# ashift -- like shift, but for arrays
+
+ashift()
+{
+ local -a R
+ local n
+
+ case $# in
+ 1) n=1 ;;
+ 2) n=$2 ;;
+ *) echo "$FUNCNAME: usage: $FUNCNAME array [count]" >&2
+ exit 2;;
+ esac
+
+ # make r a copy of the array whose name is passed as an arg
+ eval R=\( \"\$\{$1\[@\]\}\" \)
+
+ # shift R
+ R=( "${R[@]:$n}" )
+
+ # and assign R back to array whose name is passed as an arg
+ eval $1=\( \"\$\{R\[@\]\}\" \)
+}
+
+ashift A 2
+echo "${A[@]}"
+
+ashift A
+echo "${A[@]}"
+
+ashift A 7
+echo "${A[@]}"
+
+# Sort the members of the array whose name is passed as the first non-option
+# arg. If -u is the first arg, remove duplicate array members.
+array_sort()
+{
+ local -a R
+ local u
+
+ case "$1" in
+ -u) u=-u ; shift ;;
+ esac
+
+ if [ $# -eq 0 ]; then
+ echo "array_sort: argument expected" >&2
+ return 1
+ fi
+
+ # make r a copy of the array whose name is passed as an arg
+ eval R=\( \"\$\{$1\[@\]\}\" \)
+
+ # sort R
+ R=( $( printf "%s\n" "${A[@]}" | sort $u) )
+
+ # and assign R back to array whose name is passed as an arg
+ eval $1=\( \"\$\{R\[@\]\}\" \)
+ return 0
+}
+
+A=(3 1 4 1 5 9 2 6 5 3 2)
+array_sort A
+echo "${A[@]}"
+
+A=(3 1 4 1 5 9 2 6 5 3 2)
+array_sort -u A
+echo "${A[@]}"
diff --git a/examples/functions/isnum.bash b/examples/functions/isnum.bash
index 1eff13fb..b7339657 100644
--- a/examples/functions/isnum.bash
+++ b/examples/functions/isnum.bash
@@ -11,7 +11,7 @@
# BASH NOTE: make sure you have executed `shopt -s extglob' before
# trying to use this function, or it will not work
-function isnum # string
+isnum() # string
{
case $1 in
?([-+])+([0-9])?(.)*([0-9])?([Ee]?([-+])+([0-9])) )
@@ -21,3 +21,32 @@ function isnum # string
*) return 1;;
esac
}
+
+isnum2() # string
+{
+ case $1 in
+ ?([-+])+([[:digit:]])?(.)*([[:digit:]])?([Ee]?([-+])+([[:digit:]])) )
+ return 0;;
+ ?([-+])*([[:digit:]])?(.)+([[:digit:]])?([Ee]?([-+])+([[:digit:]])) )
+ return 0;;
+ *) return 1;;
+ esac
+}
+
+isint() # string
+{
+ case $1 in
+ ?([-+])+([0-9]) )
+ return 0;;
+ *) return 1;;
+ esac
+}
+
+isint2() # string
+{
+ case $1 in
+ ?([-+])+([[:digit:]]) )
+ return 0;;
+ *) return 1;;
+ esac
+}
diff --git a/examples/functions/ksh-compat-test b/examples/functions/ksh-compat-test
new file mode 100644
index 00000000..feee965d
--- /dev/null
+++ b/examples/functions/ksh-compat-test
@@ -0,0 +1,40 @@
+#
+# replacements for test/[ that do arithmetic expansion on the operands to
+# the arithmetic operators, like ksh.
+#
+function test()
+{
+ local -i n1 n3
+ case "$#" in
+ 3) case "$2" in
+ -lt|-gt|-eq|-ne|-le|-ge) n1=$(( $1 ))
+ n3=$(( $3 ))
+ builtin test "$n1" $2 "$n3"
+ return $?;;
+ *) builtin test "$@" ;;
+ esac;;
+ *) builtin test "$@" ;;
+ esac
+}
+
+function [()
+{
+ local -i n1 n3
+ case "$#" in
+ 4) case "$2" in
+ -lt|-gt|-eq|-ne|-le|-ge) n1=$(( $1 ))
+ n3=$(( $3 ))
+ builtin [ "$n1" $2 "$n3" ]
+ return $?;;
+ *) builtin [ "$@" ;;
+ esac;;
+ *) builtin [ "$@" ;;
+ esac
+}
+
+q=7
+
+[ q -lt 10 ]
+echo $?
+[ $q -lt 10 ]
+echo $?
diff --git a/examples/functions/kshenv b/examples/functions/kshenv
index 636405e3..35cc2124 100644
--- a/examples/functions/kshenv
+++ b/examples/functions/kshenv
@@ -10,12 +10,13 @@
# are others, but we already have substitutes for them: "history", "type",
# and "hash".
#
-alias r="fc -e -"
+alias r="fc -s"
alias functions="typeset -f"
alias integer="typeset -i"
alias nohup="nohup "
-alias true=":"
-alias false="let 0"
+alias command="command "
+alias stop="kill -s STOP"
+alias redirect="command exec"
alias hist="fc"
#
@@ -29,38 +30,65 @@ alias hist="fc"
whence()
{
- local vflag
+ local vflag pflag fflag defarg c
local path
- vflag=
+ vflag= aflag= pflag= fflag=
path=
if [ "$#" = "0" ] ; then
- echo "whence: argument expected"
- return 1
+ echo "whence: usage: whence [-afpv] name..." >&2
+ return 2
fi
- case "$1" in
- -v) vflag=1 ; shift 1 ;;
- -*) echo "whence: bad option: $1" ; return 1 ;;
- *) ;;
- esac
+
+ OPTIND=1
+ while getopts "avfp" c
+ do
+ case "$c" in
+ a) defarg=-a ;;
+ f) fflag=1 ;; # no-op
+ p) pflag=1 ;;
+ v) vflag=1 ;;
+ ?) echo "whence: $1: unknown option" >&2
+ echo "whence: usage: whence [-afpv] name..." >&2
+ return 2 ;;
+ esac
+ done
+
+ shift $(( $OPTIND - 1 ))
if [ "$#" = "0" ] ; then
- echo "whence: bad argument count"
- return 1
+ echo "whence: usage: whence [-afpv] name..." >&2
+ return 2
fi
for cmd
do
if [ "$vflag" ] ; then
- echo $(builtin type $cmd | sed 1q)
+ if [ -z "$defarg" ]; then
+ builtin type $cmd | sed 1q
+ else
+ if builtin type $defarg -t $cmd | grep 'function$' >/dev/null 2>&1; then
+ # HAIRY awk script to suppress
+ # printing of function body -- could
+ # do it with sed, but I don't have
+ # that kind of time
+ builtin type $defarg $cmd | awk '
+BEGIN {printit = 1;}
+$1 == "'$cmd'" && $2 == "()" {printit=0; next; }
+/^}$/ { if (printit == 0) printit=1 ; else print $0; next ; }
+/.*/ { if (printit) print $0; }'
+ else
+ builtin type $defarg $cmd
+ fi
+ fi
else
- path=$(builtin type -path $cmd)
+ path=$(builtin type $defarg -p $cmd)
if [ "$path" ] ; then
echo $path
else
case "$cmd" in
/*) echo "" ;;
- *) case "$(builtin type -type $cmd)" in
+ *) case "$(builtin type -t $cmd)" in
"") echo "" ;;
*) echo "$cmd" ;;
esac
@@ -88,22 +116,27 @@ cd()
1) builtin cd "$@" ;;
2) old="$1"
new="$2"
- dir=$(echo "$PWD" | sed "s:$old:$new:g")
+ # dir=$(echo "$PWD" | sed "s:$old:$new:g")
+ dir=${PWD//$old/$new}
case "$dir" in
- "$PWD") echo "bash: cd: bad substitution" >&2 ; return 1 ;;
+ "$PWD") case "$PWD" in
+ *$old*) ;;
+ *) echo "$FUNCNAME: bad substitution" >&2 ; return 1 ;;
+ esac ;;
*) echo "$dir"
builtin cd "$dir"
;;
esac
;;
- *) echo "cd: wrong arg count" >&2 ; return 1 ;;
+ *) echo "$FUNCNAME: usage: $FUNCNAME [-LP] [dir] [change]" >&2
+ return 1 ;;
esac
}
#
# ksh print emulation
#
-# print [-Rnprsu[n]] [arg ...]
+# print [-Rnprsu[n]] [-f format] [arg ...]
#
# - end of options
# -R BSD-style -- only accept -n, no escapes
@@ -112,27 +145,34 @@ cd()
# -r no escapes
# -s print to the history file
# -u n redirect output to fd n
+# -f format printf "$format" "$@"
#
print()
{
local eflag=-e
- local nflag=
+ local nflag= fflag= c
local fd=1
OPTIND=1
- while getopts "Rnprsu:" c
+ while getopts "fRnprsu:" c
do
case $c in
R) eflag= ;;
r) eflag= ;;
n) nflag=-n ;;
s) sflag=y ;;
+ f) fflag=y ;;
u) fd=$OPTARG ;;
p) ;;
esac
done
- shift $[ $OPTIND - 1 ]
+ shift $(( $OPTIND - 1 ))
+
+ if [ -n "$fflag" ]; then
+ builtin printf "$@" >&$fd
+ return
+ fi
case "$sflag" in
y) builtin history -s "$*" ;;
diff --git a/examples/functions/lowercase b/examples/functions/lowercase
index a0649f84..e3f866e0 100644
--- a/examples/functions/lowercase
+++ b/examples/functions/lowercase
@@ -9,6 +9,7 @@
lowercase()
{
for file; do
+ [ -f "$file" ] || continue
filename=${file##*/}
case "$filename" in
*/*) dirname=${file%/*} ;;
diff --git a/examples/functions/pathfuncs b/examples/functions/pathfuncs
index 47896bf5..56fdca3d 100644
--- a/examples/functions/pathfuncs
+++ b/examples/functions/pathfuncs
@@ -17,9 +17,6 @@
# AUTHOR:
# Simon J. Gerraty <sjg@zen.void.oz.au>
-# RCSid:
-# $Id: add_path.sh,v 1.1 1995/09/30 12:45:23 sjg Exp $
-#
# @(#)Copyright (c) 1991 Simon J. Gerraty
#
# This file is provided in the hope that it will
diff --git a/examples/functions/which b/examples/functions/which
index 54ace771..ca33703e 100644
--- a/examples/functions/which
+++ b/examples/functions/which
@@ -6,7 +6,7 @@
which()
{
- local aflag sflag ES a
+ local aflag sflag ES a opt
OPTIND=1
while builtin getopts as opt ; do
diff --git a/examples/functions/xfind.bash b/examples/functions/xfind.bash
new file mode 100644
index 00000000..578e8838
--- /dev/null
+++ b/examples/functions/xfind.bash
@@ -0,0 +1,52 @@
+#! /bin/bash
+#From: kaz@cafe.net (Kaz Kylheku)
+#Newsgroups: comp.unix.shell
+#Subject: Why not roll your own @#$% find! (was: splitting directory off from filename)
+#Message-ID: <6n1117$tp1@espresso.cafe.net>
+#Date: Fri, 26 Jun 1998 20:47:34 GMT
+
+# $1 = dirname, $2 = pattern, optional $3 = action
+xfind()
+{
+ local x
+ local dir="$1"
+
+ # descend into specified directory
+
+ builtin cd -L "$1" || {
+ echo "${FUNCNAME}: cannot change dir to $1" >&2
+ return 1
+ }
+
+ #
+ # default action is to print the filename
+ #
+ if [ -n "$3" ]; then
+ action="$3"
+ else
+ action='printf -- "%s\n"'
+ fi
+
+ # process ordinary files that match pattern
+
+ for x in $2 ; do
+ if [ -f "$x" ] ; then
+ eval "$action" "$x"
+ fi
+ done
+
+ # now descend into subdirectories, avoiding symbolic links
+ # and directories that start with a period.
+
+ for x in * ; do
+ if [ -d "$x" -a ! -L "$x" ] ; then
+ $FUNCNAME "$x" "$2" "$action"
+ fi
+ done
+
+ # finally, pop back up
+
+ builtin cd -L ..
+}
+
+#xfind "$@"
diff --git a/examples/loadables/Makefile.in b/examples/loadables/Makefile.in
index 799b4cfc..ab3c5d7e 100644
--- a/examples/loadables/Makefile.in
+++ b/examples/loadables/Makefile.in
@@ -1,7 +1,22 @@
#
# Simple makefile for the sample loadable builtins
#
-#
+# Copyright (C) 1996 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
+
# Include some boilerplate Gnu makefile definitions.
prefix = @prefix@
@@ -43,7 +58,8 @@ SHOBJ_LIBS = @SHOBJ_LIBS@
SHOBJ_STATUS = @SHOBJ_STATUS@
INC = -I. -I.. -I$(topdir) -I$(topdir)/lib -I$(topdir)/builtins \
- -I$(BUILD_DIR) -I$(BUILD_DIR)/lib -I$(BUILD_DIR)/builtins
+ -I$(topdir)/include -I$(BUILD_DIR) -I$(BUILD_DIR)/lib \
+ -I$(BUILD_DIR)/builtins
.c.o:
$(SHOBJ_CC) $(SHOBJ_CFLAGS) $(CFLAGS) $(INC) -c -o $@ $<
@@ -165,11 +181,14 @@ pushd: pushd.o
clean:
$(RM) $(ALLPROG) $(OTHERPROG) *.o
+ -( cd perl && ${MAKE} ${MFLAGS} $@ )
mostlyclean: clean
+ -( cd perl && ${MAKE} ${MFLAGS} $@ )
distclean maintainer-clean: clean
$(RM) Makefile pushd.c
+ -( cd perl && ${MAKE} ${MFLAGS} $@ )
print.o: print.c
truefalse.o: truefalse.c
diff --git a/examples/loadables/getconf.c b/examples/loadables/getconf.c
index 0f264edb..64407cc9 100644
--- a/examples/loadables/getconf.c
+++ b/examples/loadables/getconf.c
@@ -222,16 +222,28 @@ static const struct conf_variable conf_table[] =
#endif
#if defined (_SC_THREADS)
{ "_POSIX_THREADS", SYSCONF, _SC_THREADS },
+#endif
+#if defined (_SC_THREADS)
{ "_POSIX_THREAD_ATTR_STACKADDR", SYSCONF, _SC_THREAD_ATTR_STACKADDR },
+#endif
+#if defined (_SC_THREAD_ATTR_STACKSIZE)
{ "_POSIX_THREAD_ATTR_STACKSIZE", SYSCONF, _SC_THREAD_ATTR_STACKSIZE },
+#endif
+#if defined (_SC_THREAD_PRIORITY_SCHEDULING)
{ "_POSIX_THREAD_PRIORITY_SCHEDULING", SYSCONF, _SC_THREAD_PRIORITY_SCHEDULING },
+#endif
+#if defined (_SC_THREAD_PRIO_INHERIT)
{ "_POSIX_THREAD_PRIO_INHERIT", SYSCONF, _SC_THREAD_PRIO_INHERIT },
+#endif
+#if defined (_SC_THREAD_PRIO_PROTECT)
{ "_POSIX_THREAD_PRIO_PROTECT", SYSCONF, _SC_THREAD_PRIO_PROTECT },
+#endif
+#if defined (_SC_THREAD_PROCESS_SHARED)
{ "_POSIX_THREAD_PROCESS_SHARED", SYSCONF, _SC_THREAD_PROCESS_SHARED },
-# if defined (_SC_THREAD_SAFE_FUNCTIONS)
+#endif
+#if defined (_SC_THREAD_SAFE_FUNCTIONS)
{ "_POSIX_THREAD_SAFE_FUNCTIONS", SYSCONF, _SC_THREAD_SAFE_FUNCTIONS },
-# endif
-#endif /* _SC_THREADS */
+#endif
/* XPG 4.2 Configurable System Variables. */
#if defined (_SC_ATEXIT_MAX)
@@ -249,23 +261,44 @@ static const struct conf_variable conf_table[] =
#if defined (_SC_AIO_LISTIO_MAX)
{ "AIO_LISTIO_MAX", SYSCONF, _SC_AIO_LISTIO_MAX },
+#endif
+#if defined (_SC_AIO_MAX)
{ "AIO_MAX", SYSCONF, _SC_AIO_MAX },
+#endif
+#if defined (_SC_AIO_PRIO_DELTA_MAX)
{ "AIO_PRIO_DELTA_MAX", SYSCONF, _SC_AIO_PRIO_DELTA_MAX },
+#endif
+#if defined (_SC_DELAYTIMER_MAX)
{ "DELAYTIMER_MAX", SYSCONF, _SC_DELAYTIMER_MAX },
+#endif
#if defined (_SC_GETGR_R_SIZE_MAX)
{ "GETGR_R_SIZE_MAX", SYSCONF, _SC_GETGR_R_SIZE_MAX },
#endif
#if defined (_SC_GETPW_R_SIZE_MAX)
{ "GETPW_R_SIZE_MAX", SYSCONF, _SC_GETPW_R_SIZE_MAX },
#endif
+#if defined (_SC_MQ_OPEN_MAX)
{ "MQ_OPEN_MAX", SYSCONF, _SC_MQ_OPEN_MAX },
+#endif
+#if defined (_SC_MQ_PRIO_MAX)
{ "MQ_PRIO_MAX", SYSCONF, _SC_MQ_PRIO_MAX },
+#endif
+#if defined (_SC_RTSIG_MAX)
{ "RTSIG_MAX", SYSCONF, _SC_RTSIG_MAX },
+#endif
+#if defined (_SC_SEM_NSEMS_MAX)
{ "SEM_NSEMS_MAX", SYSCONF, _SC_SEM_NSEMS_MAX },
+#endif
+#if defined (_SC_SEM_VALUE_MAX)
{ "SEM_VALUE_MAX", SYSCONF, _SC_SEM_VALUE_MAX },
+#endif
+#if defined (_SC_SIGQUEUE_MAX)
{ "SIGQUEUE_MAX", SYSCONF, _SC_SIGQUEUE_MAX },
+#endif
+#if defined (_SC_TIMER_MAX)
{ "TIMER_MAX", SYSCONF, _SC_TIMER_MAX },
-#endif /* _SC_AIO_LISTIO_MAX */
+#endif
+
#if defined (_SC_LOGIN_NAME_MAX)
{ "LOGIN_NAME_MAX", SYSCONF, _SC_LOGIN_NAME_MAX },
#endif
@@ -276,12 +309,18 @@ static const struct conf_variable conf_table[] =
{ "TTY_NAME_MAX", SYSCONF, _SC_TTY_NAME_MAX },
#endif
-#if defined (_SC_PTHREAD_DESTRUCTOR_ITERATIONS)
+#if defined (_SC_THREAD_DESTRUCTOR_ITERATIONS)
{ "PTHREAD_DESTRUCTOR_ITERATIONS", SYSCONF, _SC_THREAD_DESTRUCTOR_ITERATIONS },
+#endif
+#if defined (_SC_THREAD_KEYS_MAX)
{ "PTHREAD_KEYS_MAX", SYSCONF, _SC_THREAD_KEYS_MAX },
+#endif
+#if defined (_SC_THREAD_STACK_MIN)
{ "PTHREAD_STACK_MIN", SYSCONF, _SC_THREAD_STACK_MIN },
+#endif
+#if defined (_SC_THREAD_THREADS_MAX)
{ "PTHREAD_THREADS_MAX", SYSCONF, _SC_THREAD_THREADS_MAX },
-#endif /* _SC_PTHREAD_DESTRUCTOR_ITERATIONS */
+#endif
/* XPG 4.2 Optional Facility Configuration Values */
#if defined (_SC_XOPEN_UNIX)
diff --git a/examples/loadables/perl/Makefile.in b/examples/loadables/perl/Makefile.in
new file mode 100644
index 00000000..3af9b854
--- /dev/null
+++ b/examples/loadables/perl/Makefile.in
@@ -0,0 +1,97 @@
+#
+# Makefile for builtin perl interpreter
+#
+#
+# Copyright (C) 1998 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
+
+# Include some boilerplate Gnu makefile definitions.
+prefix = @prefix@
+
+exec_prefix = @exec_prefix@
+bindir = @bindir@
+libdir = @libdir@
+infodir = @infodir@
+includedir = @includedir@
+
+topdir = @top_srcdir@
+BUILD_DIR = @BUILD_DIR@
+srcdir = @srcdir@
+VPATH = .:@srcdir@
+
+@SET_MAKE@
+CC = @CC@
+RM = rm -f
+
+SHELL = @MAKE_SHELL@
+
+PERL5 = perl5
+
+CFLAGS = @CFLAGS@
+
+#
+# These values are generated for configure by ${topdir}/support/shobj-conf.
+# If your system is not supported by that script, but includes facilities for
+# dynamic loading of shared objects, please update the script and send the
+# changes to bash-maintainers@gnu.org.
+#
+SHOBJ_CC = @SHOBJ_CC@
+SHOBJ_CFLAGS = @SHOBJ_CFLAGS@
+SHOBJ_LD = @SHOBJ_LD@
+SHOBJ_LDFLAGS = @SHOBJ_LDFLAGS@
+SHOBJ_XLDFLAGS = @SHOBJ_XLDFLAGS@
+SHOBJ_LIBS = @SHOBJ_LIBS@
+SHOBJ_STATUS = @SHOBJ_STATUS@
+
+# Values used for compiling the perl files
+PERL_LDOPTS = `${PERL5} -MExtUtils::Embed -e ldopts`
+PERL_CFLAGS = ${CCFLAGS} `${PERL5} -MExtUtils::Embed -e ccopts`
+
+SRC = bperl.c iperl.c perlxsi.c
+OBJ = bperl.o iperl.o perlxsi.o
+
+BUILTIN = bperl5
+
+INC = -I. -I.. -I$(topdir) -I$(topdir)/lib -I$(topdir)/builtins \
+ -I$(topdir)/include -I$(BUILD_DIR) -I$(BUILD_DIR)/lib \
+ -I$(BUILD_DIR)/builtins
+
+
+${BUILTIN}: ${OBJ}
+ ${RM} $@
+ ${SHOBJ_LD} ${SHOBJ_LDFLAGS} ${SHOBJ_XLDFLAGS} -o $@ ${OBJ} ${PERL_LDOPTS} ${SHOBJ_LIBS}
+
+bperl.o: bperl.c
+ ${RM} $@
+ $(SHOBJ_CC) $(SHOBJ_CFLAGS) $(CFLAGS) $(INC) -c -o $@ ${srcdir}/bperl.c
+
+iperl.o: iperl.c
+ ${RM} $@
+ $(SHOBJ_CC) ${SHOBJ_CFLAGS} $(PERL_CFLAGS) -c -o $@ ${srcdir}/iperl.c
+
+perlxsi.c:
+ ${PERL5} -MExtUtils::Embed -e xsinit -- -o $@
+
+perlxsi.o: perlxsi.c
+ ${RM} $@
+ ${SHOBJ_CC} ${SHOBJ_CFLAGS} $(PERL_CFLAGS) -c -o $@ perlxsi.c
+
+clean mostlyclean:
+ ${RM} ${OBJ}
+ ${RM} ${BUILTIN}
+
+distclean maintainer-clean: clean
+ ${RM} perlxsi.c
diff --git a/examples/loadables/perl/README b/examples/loadables/perl/README
new file mode 100644
index 00000000..a70a99b5
--- /dev/null
+++ b/examples/loadables/perl/README
@@ -0,0 +1,6 @@
+This illustrates how to build a perl interpreter into bash. It's not
+especially useful; more a proof of concept (it provides none of the
+bash internals to the perl interpreter, for example).
+
+This *may* require adding "-rpath /path/to/perl/CORE" and -lperl options
+when compiling bash itself.
diff --git a/examples/loadables/perl/bperl.c b/examples/loadables/perl/bperl.c
new file mode 100644
index 00000000..77e3f7c1
--- /dev/null
+++ b/examples/loadables/perl/bperl.c
@@ -0,0 +1,46 @@
+/*
+ * perl builtin
+ */
+#include <config.h>
+
+#include <fcntl.h>
+#include <errno.h>
+
+#include "builtins.h"
+#include "shell.h"
+
+#ifndef errno
+extern int errno;
+#endif
+
+extern char **make_builtin_argv ();
+extern char **export_env;
+
+extern int perl_main();
+
+bperl_builtin(list)
+WORD_LIST *list;
+{
+ char **v;
+ int c, r;
+
+ v = make_builtin_argv(list, &c);
+ r = perl_main(c, v, export_env);
+ free(v);
+
+ return r;
+}
+
+char *bperl_doc[] = {
+ "An interface to a perl5 interpreter.",
+ (char *)0
+};
+
+struct builtin bperl_struct = {
+ "bperl",
+ bperl_builtin,
+ BUILTIN_ENABLED,
+ bperl_doc,
+ "bperl [perl options] [file ...]",
+ 0
+};
diff --git a/examples/loadables/perl/iperl.c b/examples/loadables/perl/iperl.c
new file mode 100644
index 00000000..92a60387
--- /dev/null
+++ b/examples/loadables/perl/iperl.c
@@ -0,0 +1,24 @@
+#include <EXTERN.h> /* from the Perl distribution */
+#include <perl.h> /* from the Perl distribution */
+
+extern void xs_init _((void));
+
+static PerlInterpreter *iperl; /*** The Perl interpreter ***/
+
+int
+perl_main(int argc, char **argv, char **env)
+{
+ int r;
+
+ iperl = perl_alloc();
+ perl_construct(iperl);
+ perl_parse(iperl, xs_init, argc, argv, (char **)NULL);
+ r = perl_run(iperl);
+
+PerlIO_flush(PerlIO_stdout());
+PerlIO_flush(PerlIO_stderr());
+
+ perl_destruct(iperl);
+ perl_free(iperl);
+ return (r);
+}
diff --git a/examples/loadables/print.c b/examples/loadables/print.c
index 71449244..80943bc7 100644
--- a/examples/loadables/print.c
+++ b/examples/loadables/print.c
@@ -1,3 +1,7 @@
+/*
+ * print -- loadable ksh-93 style print builtin
+ */
+
#include "bashtypes.h"
#include <errno.h>
@@ -19,8 +23,6 @@ static int printargs ();
static FILE *ofp;
-extern char *ansicstr ();
-
extern char *this_command_name;
static char *print_doc[] = {
@@ -150,7 +152,7 @@ printargs (list, ofp)
for (sawc = 0, l = list; l; l = l->next)
{
- ostr = ansicstr (l->word->word, strlen (l->word->word), &sawc, (int *)0);
+ ostr = ansicstr (l->word->word, strlen (l->word->word), 0, &sawc, (int *)0);
fprintf (ofp, "%s", ostr);
free (ostr);
if (sawc)
@@ -160,4 +162,3 @@ printargs (list, ofp)
}
return (1);
}
-
diff --git a/examples/scripts.v2/rename b/examples/scripts.v2/rename
index 0c9bf1fc..96c46d68 100644
--- a/examples/scripts.v2/rename
+++ b/examples/scripts.v2/rename
@@ -46,8 +46,8 @@ fi
oldpat=$1
newpat=$2
-set $1
-if [ ! -a "$1" ]; then
+set -- $1
+if [ ! -e "$1" ]; then
echo "$name: no files match $oldpat."
exit 1
fi
@@ -79,7 +79,7 @@ while :; do
done
if [ $i -eq 1 ]; then
- print -u2 "No globbing chars in pattern."
+ echo "No globbing chars in pattern." 1>&2
exit 1
fi
diff --git a/examples/scripts/adventure.sh b/examples/scripts/adventure.sh
index 4e223939..846efc6e 100755
--- a/examples/scripts/adventure.sh
+++ b/examples/scripts/adventure.sh
@@ -86,7 +86,8 @@ export PATH
trap 'echo Ouch!' 2 3
#trap '' 18 # disable Berkeley job control
-ash_lk(){ echo " $1 " | fgrep " $2 " >&- 2>&-; }
+#ash_lk(){ echo " $1 " | fgrep " $2 " >&- 2>&-; }
+ash_lk(){ echo " $1 " | fgrep -q " $2 " >/dev/null 2>&1 ; }
ash_pr(){ echo $* | tr ' ' '\012' | pr -5 -t -w75 -l$[ ( $# + 4 ) / 5 ]; }
ash_rm(){ echo " $1 " | sed -e "s/ $2 / /" -e 's/^ //' -e 's/ $//'; }
@@ -97,10 +98,13 @@ set -o emacs
cd
LIM=.limbo # $HOME/$LIM contains "destroyed" objects
-mkdir $LIM >&- 2>&-
+mkdir $LIM || {
+ echo "ash: cannot mkdir $LIM: exiting
+ exit 1
+}
KNAP=.knapsack # $HOME/$KNAP contains objects being "carried"
if [ ! -d $KNAP ]
-then mkdir $KNAP >&- 2>&-
+then mkdir $KNAP >/dev/null 2>&1
if [ $? = 0 ]
then echo 'You found a discarded empty knapsack.'
else echo 'You have no knapsack to carry things in.'
@@ -185,7 +189,7 @@ do room=`pwd`
set --
fi
if [ "$2" ]
- then if mv $obj $2 >&- 2>&-
+ then if mv $obj $2 # >&- 2>&-
then echo "The $obj shimmers and turns into $2."
obs=`ash_rm "$2 $obs" "$obj"`
else echo "There is a cloud of smoke but the $obj is unchanged."
@@ -214,7 +218,7 @@ do room=`pwd`
as) if [ "$2" ]
then if [ -f $2 ]
then echo "You must destroy $2 first."
- else if cp $obj $2 >&- 2>&-
+ else if cp $obj $2 # >&- 2>&-
then echo "Poof! When the smoke clears, you see the new $2."
obs="$obs $2"
else echo 'You hear a dull thud but no clone appears.'
@@ -240,7 +244,7 @@ do room=`pwd`
do if ash_lk "$kn" "$it"
then if [ -w $it ]
then echo "You must destroy $it first."
- else if mv $HOME/$KNAP/$it $it >&- 2>&-
+ else if mv $HOME/$KNAP/$it $it # >&- 2>&-
then echo "$it: dropped."
kn=`ash_rm "$kn" "$it"`
obs=`echo $it $obs`
@@ -281,7 +285,7 @@ do room=`pwd`
for it in $obj $x
do if ash_lk "$obs $hobs $exs $hexs" "$it"
then echo "Upon close inspection of the $it, you see:"
- ls -ld $it 2>&-
+ ls -ld $it 2>/dev/null
if [ $? != 0 ]
then echo "-- when you look directly at the $it, it vanishes."
fi
@@ -300,9 +304,9 @@ do room=`pwd`
case "$1" in
to) if [ "$2" ]
then shift
- if PATH=$OPATH $* <$obj 2>&-
+ if PATH=$OPATH $* <$obj 2>/dev/null
then echo "The $1 monster devours your $obj."
- if rm -f $obj >&- 2>&-
+ if rm -f $obj # >&- 2>&-
then obs=`ash_rm "$obs" "$obj"`
else echo 'But he spits it back up.'
fi
@@ -331,7 +335,7 @@ do room=`pwd`
do if ash_lk "$obs $hobs" "$it"
then if ash_lk "$kn" "$it"
then echo 'You already have one.'
- else if mv $it $HOME/$KNAP/$it >&- 2>&-
+ else if mv $it $HOME/$KNAP/$it # >&- 2>&-
then echo "$it: taken."
kn="$it $kn"
obs=`ash_rm "$obs" "$it"`
@@ -367,7 +371,7 @@ do room=`pwd`
fi
for it in $obj $x
do if ash_lk "$obs $hobs" "$it"
- then if mv $it $HOME/$LIM <&- >&- 2>&-
+ then if mv $it $HOME/$LIM # <&- >&- 2>&-
then if [ $verb = kill ]
then echo "The $it cannot defend himself; he dies."
else echo "You have destroyed the $it; it vanishes."
@@ -457,7 +461,7 @@ do room=`pwd`
then for it in $obj $x
do if ash_lk "$obs $hobs" "$it"
then echo "The $it is already alive and well."
- else if mv $HOME/$LIM/$it $it <&- >&- 2>&-
+ else if mv $HOME/$LIM/$it $it # <&- >&- 2>&-
then echo "The $it staggers to his feet."
obs=`echo $it $obs`
else echo "There are sparks but no $it appears."
@@ -474,11 +478,11 @@ do room=`pwd`
case "$1" in
from) if [ "$2" ]
then shift
- if PATH=$OPATH $* >$obj 2>&-
+ if PATH=$OPATH $* >$obj 2>/dev/null
then echo "The $1 monster drops the $obj."
obs=`echo $obj $obs`
else echo "The $1 monster runs away as you approach."
- rm -f $obj >&- 2>&-
+ rm -f $obj # >&- 2>&-
fi
else echo 'From what?'
fi
diff --git a/examples/scripts/center b/examples/scripts/center
new file mode 100644
index 00000000..8d367d30
--- /dev/null
+++ b/examples/scripts/center
@@ -0,0 +1,24 @@
+#! /bin/bash
+#
+# center - center a group of lines
+#
+# tabs in the lines might cause this to look a little bit off
+#
+#
+
+width=${COLUMNS:-80}
+
+if [[ $# == 0 ]]
+then
+ set -- /dev/stdin
+fi
+
+for file
+do
+ while read -r
+ do
+ printf "%*s\n" $(( (width+${#REPLY})/2 )) "$REPLY"
+ done < $file
+done
+
+exit 0
diff --git a/examples/scripts/line-input.bash b/examples/scripts/line-input.bash
new file mode 100644
index 00000000..02c2bc2c
--- /dev/null
+++ b/examples/scripts/line-input.bash
@@ -0,0 +1,185 @@
+#! /bin/bash
+#
+#From: kaz@cafe.net (Kaz Kylheku)
+#Newsgroups: comp.unix.shell
+#Subject: Funky little bash script
+#Message-ID: <6mspb9$ft2@espresso.cafe.net>
+#Date: Thu, 25 Jun 1998 06:11:39 GMT
+
+#Here is something I wrote a few years ago when I was bored one day.
+#Warning: this contains control characters.
+
+# Line input routine for GNU Bourne-Again Shell
+# plus terminal-control primitives.
+#
+# by Kaz Kylheku
+# June 1996, Vancouver, Canada
+
+
+#
+# Function to disable canonical input processing.
+# Terminal modes are saved into variable "savetty"
+#
+#
+
+function raw
+{
+ savetty=$(stty -g)
+ stty -icanon -isig -echo -echok -echonl inlcr
+}
+
+#
+# Function to restore terminal settings from savetty variable
+#
+
+function restore
+{
+ stty $savetty
+}
+
+#
+# Set terminal MIN and TIME values.
+# If the input argument is a zero, set up terminal to wait for
+# a keystroke indefinitely. If the argument is non-zero, set up
+# an absolute timeout of that many tenths of a second. The inter-keystroke
+# timer facility of the terminal driver is not exploited.
+#
+
+function settimeout
+# $1 = tenths of a second
+{
+ if [ "$1" = "0" ] ; then
+ min=1
+ timeout=0
+ else
+ min=0
+ timeout="$1"
+ fi
+
+ stty min $min time $timeout
+
+ unset min timeout
+}
+
+#
+# Input a single key using 'dd' and echo it to standard output.
+# Launching an external program to get a single keystroke is a bit
+# of a pig, but it's the best you can do! Maybe we could convince the
+# GNU guys to make 'dd' a bash builtin.
+#
+
+function getkey
+{
+ eval $1="\"\$(dd bs=1 count=1 2> /dev/null)\""
+}
+
+#
+# Input a line of text gracefully.
+# The first argument is the name of a variable where the input line is
+# to be stored. If this variable is not empty, its contents are printed
+# and treated as though the user had entered them.
+# The second argument gives the maximum length of the input line; if it
+# is zero, the input is unlimited (bad idea).
+# ^W is used to delete words
+# ^R redraws the line at any time by backspacing over it and reprinting it
+# ^U backspaces to the beginning
+# ^H or ^? (backspace or del) delete a single character
+# ^M (enter) terminates the input
+# all other control keys are ignored and cause a beep when pressed
+#
+#
+
+
+function getline
+{
+ settimeout 0 # No keystroke timeout.
+ save_IFS="$IFS" # Save word delimiter and set it to
+ IFS="" # to null so ${#line} works correctly.
+ eval line=\${$1} # Fetch line contents
+ echo -n "$line" # and print the existing line.
+ while [ 1 ] ; do
+ getkey key # fetch a single keystroke
+ case "$key" in
+  |  ) # BS or DEL
+ if [ ${#line} != 0 ] ; then # if line not empty
+ echo -n " " # print destructive BS
+ line="${line%%?}" # chop last character
+ else # else if line empty
+ echo -n  # beep the terminal
+ fi
+ ;;
+  ) # kill to line beg
+ while [ ${#line} != 0 ] ; do # while line not empty
+ echo -n " " # print BS, space, BS
+ line="${line%?}" # shorten line by 1
+ done
+ ;;
+  ) # redraw line
+ linesave="$line" # save the contents
+ while [ ${#line} != 0 ] ; do # kill to line beg
+ echo -n " "
+ line="${line%?}"
+ done
+ echo -n "$linesave" # reprint, restore
+ line="$linesave"
+ unset linesave # forget temp var
+ ;;
+  )
+ while [ "${line% }" != "$line" -a ${#line} != 0 ] ; do
+ echo -n " "
+ line="${line%?}"
+ done
+ while [ "${line% }" = "$line" -a ${#line} != 0 ] ; do
+ echo -n " "
+ line="${line%?}"
+ done
+ ;;
+  |  |  |  |  |  |  |  |  | | | )
+ echo -n  # ignore various control characters
+ ;; # with an annoying beep
+  |  |  |  |  |  |  |  |  |  |  |  |  )
+ echo -n 
+ ;;
+ ' ' |  |  |  |  |  )
+ echo -n 
+ ;;
+ '' ) # Break out of loop on carriage return.
+ echo # Send a newline to the terminal.
+ break # (Also triggered by NUL char!).
+ ;;
+ * ) # Append character to the end of the line.
+ # If length is restricted, and the line is too
+ # long, then beep...
+
+ if [ "$2" != 0 -a $(( ${#line} >= $2 )) = 1 ] ; then
+ echo -n 
+ else # Otherwise add
+ line="$line$key" # the character.
+ echo -n "$key" # And echo it.
+ fi
+ ;;
+ esac
+ done
+ eval $1=\"\$line\"
+ IFS="$save_IFS"
+ unset line save_IFS
+}
+
+# uncomment the lines below to create a standalone test program
+#
+echo "Line input demo for the GNU Bourne-Again Shell."
+echo "Hacked by Kaz Kylheku"
+echo
+echo "Use ^H/Backspace/Del to erase, ^W to kill words, ^U to kill the"
+echo "whole line of input, ^R to redraw the line."
+echo "Pass an argument to this program to prime the buffer contents"
+raw
+echo -n "go: "
+if [ ${#1} != 0 ] ; then
+ LINE=$1
+fi
+getline LINE 50
+restore
+
+echo "<$LINE>"
+
diff --git a/examples/scripts/vtree3a b/examples/scripts/vtree3a
new file mode 100644
index 00000000..0678764b
--- /dev/null
+++ b/examples/scripts/vtree3a
@@ -0,0 +1,100 @@
+#!/bin/bash
+#
+# Name: dirtree
+# Programmer:
+# Hemant T. Shah
+# Life Insurance Data Processing
+# July 12 1994
+#
+# Description:
+# Print directory tree structure as follows:
+# |___Mail
+# |___scheduler
+# |___cics_scripts
+# |___tar_msdos
+# |___awk
+# |___attributes
+# |___tmp
+# |___News
+# |___dosscsi
+# |___FAQ_xterminal
+# |___shell_history.Z
+# |___FAQ_AIX
+# |___aix_ftp_site
+# |___hp_software
+# |___dnload
+# |___telnet.h
+# |___msdos
+# |___tnetd.tar.Z
+# |___aix
+# |___hp
+# |___xkey.c
+#
+# Conversion to bash v2 syntax done by Chet Ramey
+# - removed command substitutions calling `basename'
+#
+
+ProgramName=${0##*/}
+Path="."
+ShowAll=1
+ShowDir=0
+
+
+ExpandDirectory()
+{
+local object # Local variable
+
+cd "$1"
+
+for object in $PWD/.??* $PWD/*
+do
+ if [ -d $object ]; # It is a directory
+ then
+ echo "${indent}|___${object##*/}/"
+ indent="${indent}! " # Add to indentation
+ if [ -x $object ];
+ then
+ ExpandDirectory $object
+ fi
+ indent=${indent%????} # Remove from indentation
+ elif [ -e $object ]; then
+ if (( ShowAll == 1 ));
+ then
+ echo "${indent}|___${object##*/}"
+ fi
+ fi
+done
+
+}
+
+usage()
+{
+ echo -e "Usage: $ProgramName [-h] [-f] [-d] [path] "
+ echo -e "\t-h ... display this help message."
+ echo -e "\t-f path ... shows all files and directories below path (default)."
+ echo -e "\t-d path ... shows all directories only below path."
+}
+
+while getopts "fd" opt
+do
+ case $opt in
+ f) ShowAll=1 ;;
+ #d) ShowDir=1 ;;
+ d) ShowAll=0 ;;
+ *) usage ; exit 2;;
+ esac
+done
+
+shift $(( $OPTIND - 1 ))
+
+Path=${1:-.}
+
+if [ ! -d "$Path" ]; then
+ echo "$0: error: specified path is not a directory." >&2
+ exit 1
+fi
+
+
+
+echo "!$Path/"
+ExpandDirectory $Path
diff --git a/examples/scripts/websrv.sh b/examples/scripts/websrv.sh
new file mode 100644
index 00000000..e07746bc
--- /dev/null
+++ b/examples/scripts/websrv.sh
@@ -0,0 +1,230 @@
+#!/bin/sh
+#for instructions or updates go to:
+#<A HREF="http://math.ucr.edu:8889/">This script's home page</A>
+#email me questions or comments at:
+#<A HREF="mailto:insom@math.ucr.edu">insom@math.ucr.edu</A>
+#copyright chris ulrich; This software may be used or modified
+#in any way so long as this notice remains intact.
+#
+# WWW server in sh
+# Author: Chris Ulrich <chris@tinker.ucr.edu>
+#
+
+INDEX=index.html
+date=`date`
+DOCHOME=/home/insom/web-docs
+BINHOME=/home/insom/web-bin
+LOGHOME=/home/insom/web-logs
+LOGFILE=$LOGHOME/access_log
+#verbose=:
+verbose=echo
+exec 2>> $LOGHOME/error_log
+
+hheader() {
+echo "HTTP/1.0 200 OK
+Server: WebSH/2.00
+Connection: close
+Date: $date"
+}
+
+header() {
+echo "Content-type: $1
+"
+}
+
+no_url() {
+ header "text/plain"
+ echo "No such url $1"
+}
+
+send() {
+ #case "$#" in 2) ;; *) echo eep! | mailx insom@math.ucr.edu ; exit 3 ;; esac
+ if test -f "$DOCHOME/$2"
+ then
+ header "$1"
+ cat "$DOCHOME/$2"
+ else
+ no_url "$2"
+ fi
+}
+
+LsToHTML() {
+ if test -f "$DOCHOME/$url/.title"
+ then
+ header "text/html; charset=US-ASCII"
+ echo "<pre>"
+ cat "$DOCHOME/$url/.title"
+ echo "</pre>"
+ elif test -f "$DOCHOME/$url/.title.html"
+ then
+ header "text/html; charset=US-ASCII"
+ cat "$DOCHOME/$url/.title.html"
+ else
+ header "text/html; charset=US-ASCII"
+ fi
+
+ case "$url" in
+ /) ;;
+ *) url="$url/"
+ esac
+
+ while read link
+ do
+ case $link in
+ *.cgi) ;;
+ *)
+ echo "<A HREF=\"$url$link\">$link</A> <BR>"
+ ;;
+ esac
+ done
+}
+
+read method data
+
+$verbose "
+$date access from ${TCPREMOTEINFO:=NO-IDENT}@${TCPREMOTEHOST:=$TCPREMOTEIP}
+ on local machine $TCPLOCALHOST
+ $method $data " >> $LOGFILE
+
+for hopeurl in $data
+do
+ url="${url}${url:+ }$second"
+ second="$hopeurl"
+done
+
+case "$second" in
+ *[1-9].*)
+ read inheader
+ while
+ case "$inheader" in
+ ?|'') false
+ ;;
+ *)
+ read inheader
+ ;;
+ esac
+ do
+ :
+ done
+ hheader
+ ;;
+esac
+
+case "$url" in
+ *..*)
+ no_url "$url"
+ exit 1
+ ;;
+ *.txt|*.[ch])
+ send "text/plain; charset=US-ASCII" "$url"
+ ;;
+ *.html)
+ send "text/html; charset=US-ASCII" "$url"
+ ;;
+ *.cgi)
+ if test -x "$DOCHOME/$url"
+ then
+ read message
+ echo "$message" | "$DOCHOME/$url"
+ else
+ no_url "$url"
+ fi
+ ;;
+ *".cgi?"*)
+ oIFS="$IFS"
+ echo "$url" | {
+ IFS='?' read url QUERY_STRING
+ if test -x "$DOCHOME/$url"
+ then
+ IFS="$oIFS"
+ export QUERY_STRING
+ "$DOCHOME/$url"
+ else
+ no_url "$url"
+ fi
+ }
+ ;;
+ *.[Gg][Ii][Ff])
+ send "image/gif" "$url"
+ ;;
+ *.[Jj][Pp][Gg]|*.[Jj][Pp][Ee][Gg])
+ send "image/jpeg" "$url"
+ ;;
+ *.tbl)
+ header "text/html; charset=US-ASCII"
+ echo "<pre>"
+ test -f "$DOCHOME/$url" &&
+ tbl < "$DOCHOME/$url" | nroff ||
+ no_url "$url"
+ echo "</pre>"
+ ;;
+ *.nroff)
+ header "text/html; charset=US-ASCII"
+ echo "<pre>"
+ test -f "$DOCHOME/$url" &&
+ nroff < "$DOCHOME/$url" ||
+ no_url "$url"
+ echo "</pre>"
+ ;;
+ *mp[23])
+ if test -f "$DOCHOME/$url"
+ then
+ header "application/mpstream"
+ echo "+$TCPLOCALIP:${MPSERVPORT:=9001}/$url"
+ else
+ no_url "$url"
+ fi
+ ;;
+ *.[0-9]|*.[0-9][a-z])
+ header "text/html; charset=US-ASCII"
+ echo "<pre>"
+ if test -f "$DOCHOME/$url"
+ then
+ #nroff -man "$DOCHOME/$url" | $BINHOME/man2html
+ echo "perl at the moment is broken, so man2html doesn't work. Sorry."
+ echo "</pre>"
+ else
+ no_url "$url"
+ fi
+ ;;
+ *.???|*.??)
+ send "unknown/data" "$url"
+ ;;
+ */)
+ if test -d "$DOCHOME/$url"
+ then
+ ls "$DOCHOME/$url" | LsToHTML
+ fi
+ ;;
+ *)
+ if test -f "$DOCHOME/$url"
+ then
+ read filetype < "$DOCHOME/$url"
+ case "$filetype" in
+ \#!/*/*|\#!?/*/*)
+ header "text/plain; charset=US-ASCII"
+ cat "$DOCHOME/$url"
+ ;;
+ '<!*>')
+ header "text/html; charset=US-ASCII"
+ cat "$DOCHOME/$url"
+ ;;
+ *)
+ header "text/html; charset=US-ASCII"
+ echo "<pre>"
+ cat "$DOCHOME/$url"
+ echo "</pre>"
+ ;;
+ esac
+ elif test -f "$DOCHOME/$url/$INDEX"
+ then
+ header "text/html; charset=US-ASCII"
+ cat "$DOCHOME/$url/$INDEX"
+ elif test -d "$DOCHOME/$url"
+ then
+ ls "$DOCHOME/$url" | LsToHTML
+ else
+ no_url "$url"
+ fi
+ ;;
+esac
diff --git a/examples/scripts/xterm_title b/examples/scripts/xterm_title
new file mode 100755
index 00000000..72ba099b
--- /dev/null
+++ b/examples/scripts/xterm_title
@@ -0,0 +1,27 @@
+#! /bin/bash
+#
+# xterm_title - print the contents of the xterm title bar
+#
+# Derived from http://www.clark.net/pub/dickey/xterm/xterm.faq.html#how2_title
+#
+P=${0##*/}
+[ -z "$DISPLAY" ] && {
+ echo "${P}: not running X" >&2
+ exit 1
+}
+
+if [ -z "$TERM" ] || [ "$TERM" != "xterm" ]; then
+ echo "${P}: not running in an xterm" >&2
+ exit 1
+fi
+
+exec </dev/tty
+old=$(stty -g)
+stty raw -echo min 0 time ${1-10}
+echo -e "\033[21t\c" > /dev/tty
+IFS='' read -r a
+stty $old
+b=${a#???}
+echo "${b%??}"
+
+exit 0
diff --git a/examples/startup-files/apple/README b/examples/startup-files/apple/README
new file mode 100644
index 00000000..07005cb0
--- /dev/null
+++ b/examples/startup-files/apple/README
@@ -0,0 +1,24 @@
+This directory contains some useful bash files.
+
+In order to use this configuration:
+
+ echo "source ~/.bashrc" > ~/.profile
+ echo "source /usr/share/init/bash/rc" > ~/.bashrc
+ echo "source /usr/share/init/bash/login" > ~/.login
+
+In order to customize this setup:
+
+ mkdir ~/Library/init/bash
+
+and create the following files there as necessary:
+
+ aliases.mine - shell aliases
+ completions.mine - completions
+ environment.mine - environment
+ rc.mine - run commands
+ path - command search path
+
+See the corresponding file in /usr/share/init/bash for more information about the role of each file. You can easily extend or override the configuration provided by the default file. For example, you can add more aliases by adding the appropriate commands in aliases.mine.
+
+ -Fred
+ tritan@mit.edu
diff --git a/examples/startup-files/apple/aliases b/examples/startup-files/apple/aliases
new file mode 100644
index 00000000..d04821cf
--- /dev/null
+++ b/examples/startup-files/apple/aliases
@@ -0,0 +1,34 @@
+##
+# Bash aliases file
+#
+# Wilfredo Sanchez Jr. | tritan@mit.edu
+##
+
+##
+# Aliases
+##
+
+alias .='cwd'
+alias ..='cd ..'
+alias cd..='cd ..'
+alias cdwd='cd $(/bin/pwd)'
+alias cwd='echo $PWD'
+alias l='ls -lg'
+
+##
+# Functions
+##
+
+files () { find ${1} -type f -print ; }
+ff () { find . -name ${1} -print ; }
+ll () { ls -lag "$@" | more ; }
+word () { fgrep -i "$*" /usr/dict/web2 ; }
+wordcount () { cat "${1}" | tr -s ' .,;:?\!()[]"' '\012' | \
+ cat -n | tail -1 | awk '{print $1}' ; }
+
+##
+# Read user's aliases
+##
+if [ -r ${bash_initdir}/aliases.mine ]; then
+ source ${bash_initdir}/aliases.mine
+fi
diff --git a/examples/startup-files/apple/bash.defaults b/examples/startup-files/apple/bash.defaults
new file mode 100644
index 00000000..a80145be
--- /dev/null
+++ b/examples/startup-files/apple/bash.defaults
@@ -0,0 +1,22 @@
+##
+# Bash
+# User preferences file
+# Override these in rc.mine
+#
+# Wilfredo Sanchez Jr. | tritan@mit.edu
+# July 09, 1992
+#
+# MIT Project Athena
+##
+
+if [ -n "$PS1" ]; then
+
+ # Prompts
+ PS1='[\h:\w] \u\$ '
+ PS2=' -> '
+ #PS3=
+ #PS4=
+
+ set -o emacs
+
+fi
diff --git a/examples/startup-files/apple/environment b/examples/startup-files/apple/environment
new file mode 100644
index 00000000..fee218b8
--- /dev/null
+++ b/examples/startup-files/apple/environment
@@ -0,0 +1,24 @@
+##
+# Bourne Again Shell environment file
+# Global environment setup
+#
+# Wilfredo Sanchez Jr. | tritan@mit.edu
+# July 09, 1992
+#
+# MIT Project Athena
+#
+# ORIGINAL SOURCES: /usr/athena/lib/init/cshrc (ATHENA REL 7.3P)
+##
+
+export ENV_SET="YES" # avoid repeat
+
+# File creation mask
+umask 022 # all files created are -rw-r--r--
+
+##
+# Load user environment
+##
+
+if [ -f ${bash_initdir}/environment.mine ]; then
+ source ${bash_initdir}/environment.mine
+fi
diff --git a/examples/startup-files/apple/login b/examples/startup-files/apple/login
new file mode 100644
index 00000000..b91f787d
--- /dev/null
+++ b/examples/startup-files/apple/login
@@ -0,0 +1,15 @@
+##
+# Set path
+##
+
+export PATH="${HOME}/${MACHTYPE}/bin:${HOME}/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
+
+export MANPATH="${HOME}/man:/usr/local/share/man:/usr/share/man"
+
+##
+# Read user's login
+##
+
+if (-r ${bash_initdir}/login.mine) then
+ source ${bash_initdir}/login.mine
+fi
diff --git a/examples/startup-files/apple/logout b/examples/startup-files/apple/logout
new file mode 100644
index 00000000..812731c6
--- /dev/null
+++ b/examples/startup-files/apple/logout
@@ -0,0 +1,10 @@
+##
+# Destroy credentials
+##
+
+if [ -z "${TERM_PROGRAM}" ]; then
+ # Don't run these commands if the shell is launched by Terminal,
+ # even if it's a login shell.
+
+ if klist -s; then kdestroy; fi
+fi
diff --git a/examples/startup-files/apple/rc b/examples/startup-files/apple/rc
new file mode 100644
index 00000000..2451b9f8
--- /dev/null
+++ b/examples/startup-files/apple/rc
@@ -0,0 +1,63 @@
+##
+# Bourne Again Shell config file
+#
+# Wilfredo Sanchez Jr. | tritan@mit.edu
+# July 09, 1992
+#
+# MIT Project Athena
+#
+# ORIGINAL SOURCES: /usr/athena/lib/init/cshrc (ATHENA REL 7.3P)
+##
+
+ default_initdir=/usr/share/init
+default_bash_initdir=${default_initdir}/bash
+ user_initdir=~/Library/init
+ user_bash_initdir=${user_initdir}/bash
+
+if [ -r ${user_bash_initdir} ]; then
+ initdir=${user_initdir}
+ bash_initdir=${user_bash_initdir}
+else
+ initdir=${default_initdir}
+ bash_initdir=${default_bash_initdir}
+fi
+
+# SET UP HOST-DEPENDANT VARIABLES, ETC.
+
+host=$(echo $(hostname) | tr A-Z a-z)
+
+user=`whoami`
+
+export HOST=${host}
+export USER=${user}
+
+# User ID
+if [ -z "${uid}" ]; then uid=$(id | cut -d = -f 2 | cut -d \( -f 1); fi
+
+# SET COMMAND SEARCH PATH AND MAN PATH
+if [ -f ${bash_initdir}/path ]; then source ${bash_initdir}/path; fi
+
+# ENVIRONMENT SETUP
+
+if [ -n "${PS1}" ]; then interactive="YES"; fi
+
+if [ -z "${ENV_SET}" ]; then
+ if [ -f ${default_bash_initdir}/environment ]; then
+ #echo "Initializing environment..."
+ source ${default_bash_initdir}/environment
+ fi
+fi
+
+if [ -r ${default_bash_initdir}/bash.defaults ]; then
+ source ${default_bash_initdir}/bash.defaults
+fi
+
+# DEFAULT LOGIN SOURCES
+if [ -f ${bash_initdir}/rc.mine ]; then source ${bash_initdir}/rc.mine; fi
+
+if [ "${interactive}" = "YES" ]; then
+ # These aren't useful for non-interactive sessions
+ if [ -f ${default_bash_initdir}/aliases ]; then
+ source ${default_bash_initdir}/aliases
+ fi
+fi
diff --git a/execute_cmd.c b/execute_cmd.c
index f2a23928..fd32f2f3 100644
--- a/execute_cmd.c
+++ b/execute_cmd.c
@@ -6,7 +6,7 @@
Bash is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 1, or (at your option)
+ the Free Software Foundation; either version 2, or (at your option)
any later version.
Bash is distributed in the hope that it will be useful, but WITHOUT
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with Bash; see the file COPYING. If not, write to the Free
- Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#include "config.h"
#if !defined (__GNUC__) && !defined (HAVE_ALLOCA_H) && defined (_AIX)
@@ -44,19 +44,7 @@
# include <limits.h>
#endif
-/* Some systems require this, mostly for the definition of `struct timezone'.
- For example, Dynix/ptx has that definition in <time.h> rather than
- sys/time.h */
-#if defined (TIME_WITH_SYS_TIME)
-# include <sys/time.h>
-# include <time.h>
-#else
-# if defined (HAVE_SYS_TIME_H)
-# include <sys/time.h>
-# else
-# include <time.h>
-# endif
-#endif
+#include "posixtime.h"
#if defined (HAVE_SYS_RESOURCE_H) && !defined (RLIMTYPE)
# include <sys/resource.h>
@@ -145,6 +133,9 @@ static int execute_cond_command ();
#if defined (COMMAND_TIMING)
static int time_command ();
#endif
+#if defined (ARITH_FOR_COMMAND)
+static int execute_arith_for_command ();
+#endif
static int execute_case_command ();
static int execute_while_command (), execute_until_command ();
static int execute_while_or_until ();
@@ -158,6 +149,8 @@ static void execute_disk_command ();
static int execute_connection ();
static int execute_intern_function ();
+static int execute_in_subshell ();
+
/* The line number that the currently executing function starts on. */
static int function_line_number;
@@ -196,6 +189,9 @@ REDIRECT *exec_redirection_undo_list = (REDIRECT *)NULL;
environment. */
int subshell_environment;
+/* Currently-executing shell function. */
+SHELL_VAR *this_shell_function;
+
struct fd_bitmap *current_fds_to_close = (struct fd_bitmap *)NULL;
#define FD_BITMAP_DEFAULT_SIZE 32L
@@ -287,7 +283,10 @@ execute_command (command)
discard_unwind_frame ("execute-command");
#if defined (PROCESS_SUBSTITUTION)
- unlink_fifo_list ();
+ /* don't unlink fifos if we're in a shell function; wait until the function
+ returns. */
+ if (variable_context == 0)
+ unlink_fifo_list ();
#endif /* PROCESS_SUBSTITUTION */
return (result);
@@ -301,6 +300,9 @@ shell_control_structure (type)
switch (type)
{
case cm_for:
+#if defined (ARITH_FOR_COMMAND)
+ case cm_arith_for:
+#endif
#if defined (SELECT_COMMAND)
case cm_select:
#endif
@@ -443,8 +445,11 @@ execute_command_internal (command, asynchronous, pipe_in, pipe_out,
/* If a command was being explicitly run in a subshell, or if it is
a shell control-structure, and it has a pipe, then we do the command
in a subshell. */
+ if (command->type == cm_subshell && (command->flags & CMD_NO_FORK))
+ return (execute_in_subshell (command, asynchronous, pipe_in, pipe_out, fds_to_close));
- if ((command->flags & (CMD_WANT_SUBSHELL|CMD_FORCE_SUBSHELL)) ||
+ if (command->type == cm_subshell ||
+ (command->flags & (CMD_WANT_SUBSHELL|CMD_FORCE_SUBSHELL)) ||
(shell_control_structure (command->type) &&
(pipe_out != NO_PIPE || pipe_in != NO_PIPE || asynchronous)))
{
@@ -455,134 +460,8 @@ execute_command_internal (command, asynchronous, pipe_in, pipe_out,
paren_pid = make_child (savestring (make_command_string (command)),
asynchronous);
if (paren_pid == 0)
- {
- int user_subshell, return_code, function_value, should_redir_stdin;
-
- should_redir_stdin = (asynchronous && (command->flags & CMD_STDIN_REDIR) &&
- pipe_in == NO_PIPE &&
- stdin_redirects (command->redirects) == 0);
-
- user_subshell = (command->flags & CMD_WANT_SUBSHELL) != 0;
- command->flags &= ~(CMD_FORCE_SUBSHELL | CMD_WANT_SUBSHELL | CMD_INVERT_RETURN);
-
- /* If a command is asynchronous in a subshell (like ( foo ) & or
- the special case of an asynchronous GROUP command where the
- the subshell bit is turned on down in case cm_group: below),
- turn off `asynchronous', so that two subshells aren't spawned.
-
- This seems semantically correct to me. For example,
- ( foo ) & seems to say ``do the command `foo' in a subshell
- environment, but don't wait for that subshell to finish'',
- and "{ foo ; bar } &" seems to me to be like functions or
- builtins in the background, which executed in a subshell
- environment. I just don't see the need to fork two subshells. */
-
- /* Don't fork again, we are already in a subshell. A `doubly
- async' shell is not interactive, however. */
- if (asynchronous)
- {
-#if defined (JOB_CONTROL)
- /* If a construct like ( exec xxx yyy ) & is given while job
- control is active, we want to prevent exec from putting the
- subshell back into the original process group, carefully
- undoing all the work we just did in make_child. */
- original_pgrp = -1;
-#endif /* JOB_CONTROL */
- interactive_shell = 0;
- expand_aliases = 0;
- asynchronous = 0;
- }
-
- /* Subshells are neither login nor interactive. */
- login_shell = interactive = 0;
-
- subshell_environment = user_subshell ? SUBSHELL_PAREN : SUBSHELL_ASYNC;
-
- reset_terminating_signals (); /* in shell.c */
- /* Cancel traps, in trap.c. */
- restore_original_signals ();
- if (asynchronous)
- setup_async_signals ();
-
-#if defined (JOB_CONTROL)
- set_sigchld_handler ();
-#endif /* JOB_CONTROL */
-
- set_sigint_handler ();
-
-#if defined (JOB_CONTROL)
- /* Delete all traces that there were any jobs running. This is
- only for subshells. */
- without_job_control ();
-#endif /* JOB_CONTROL */
- do_piping (pipe_in, pipe_out);
-
- /* If this is a user subshell, set a flag if stdin was redirected.
- This is used later to decide whether to redirect fd 0 to
- /dev/null for async commands in the subshell. This adds more
- sh compatibility, but I'm not sure it's the right thing to do. */
- if (user_subshell)
- {
- stdin_redir = stdin_redirects (command->redirects);
- restore_default_signal (0);
- }
-
- if (fds_to_close)
- close_fd_bitmap (fds_to_close);
-
- /* If this is an asynchronous command (command &), we want to
- redirect the standard input from /dev/null in the absence of
- any specific redirection involving stdin. */
- if (should_redir_stdin && stdin_redir == 0)
- async_redirect_stdin ();
-
- /* Do redirections, then dispose of them before recursive call. */
- if (command->redirects)
- {
- if (do_redirections (command->redirects, 1, 0, 0) != 0)
- exit (EXECUTION_FAILURE);
-
- dispose_redirects (command->redirects);
- command->redirects = (REDIRECT *)NULL;
- }
-
- /* If this is a simple command, tell execute_disk_command that it
- might be able to get away without forking and simply exec.
- This means things like ( sleep 10 ) will only cause one fork.
- If we're timing the command, however, we cannot do this
- optimization. */
-#if 0
- if (user_subshell && command->type == cm_simple)
-#else
- if (user_subshell && command->type == cm_simple && (command->flags & CMD_TIME_PIPELINE) == 0)
-#endif
- {
- command->flags |= CMD_NO_FORK;
- command->value.Simple->flags |= CMD_NO_FORK;
- }
-
- /* If we're inside a function while executing this subshell, we
- need to handle a possible `return'. */
- function_value = 0;
- if (return_catch_flag)
- function_value = setjmp (return_catch);
-
- if (function_value)
- return_code = return_catch_value;
- else
- return_code = execute_command_internal
- (command, asynchronous, NO_PIPE, NO_PIPE, fds_to_close);
-
- /* If we were explicitly placed in a subshell with (), we need
- to do the `shell cleanup' things, such as running traps[0]. */
- if (user_subshell && signal_is_trapped (0))
- {
- last_command_exit_value = return_code;
- return_code = run_exit_trap ();
- }
-
- exit (return_code);
- }
+ exit (execute_in_subshell (command, asynchronous, pipe_in, pipe_out, fds_to_close));
+ /* NOTREACHED */
else
{
close_pipes (pipe_in, pipe_out);
@@ -606,11 +485,13 @@ execute_command_internal (command, asynchronous, pipe_in, pipe_out,
/* If we have to, invert the return value. */
if (invert)
- return ((last_command_exit_value == EXECUTION_SUCCESS)
- ? EXECUTION_FAILURE
- : EXECUTION_SUCCESS);
+ exec_result = ((last_command_exit_value == EXECUTION_SUCCESS)
+ ? EXECUTION_FAILURE
+ : EXECUTION_SUCCESS);
else
- return (last_command_exit_value);
+ exec_result = last_command_exit_value;
+
+ return (last_command_exit_value = exec_result);
}
else
{
@@ -748,7 +629,10 @@ execute_command_internal (command, asynchronous, pipe_in, pipe_out,
}
if (was_debug_trap)
- run_debug_trap ();
+ {
+ last_command_exit_value = exec_result;
+ run_debug_trap ();
+ }
if (ignore_return == 0 && invert == 0 &&
((posixly_correct && interactive == 0 && special_builtin_failed) ||
@@ -767,6 +651,14 @@ execute_command_internal (command, asynchronous, pipe_in, pipe_out,
exec_result = execute_for_command (command->value.For);
break;
+#if defined (ARITH_FOR_COMMAND)
+ case cm_arith_for:
+ if (ignore_return)
+ command->value.ArithFor->flags |= CMD_IGNORE_RETURN;
+ exec_result = execute_arith_for_command (command->value.ArithFor);
+ break;
+#endif
+
#if defined (SELECT_COMMAND)
case cm_select:
if (ignore_return)
@@ -899,77 +791,12 @@ execute_command_internal (command, asynchronous, pipe_in, pipe_out,
}
#if defined (COMMAND_TIMING)
-#if defined (HAVE_GETRUSAGE) && defined (HAVE_GETTIMEOFDAY)
-static struct timeval *
-difftimeval (d, t1, t2)
- struct timeval *d, *t1, *t2;
-{
- d->tv_sec = t2->tv_sec - t1->tv_sec;
- d->tv_usec = t2->tv_usec - t1->tv_usec;
- if (d->tv_usec < 0)
- {
- d->tv_usec += 1000000;
- d->tv_sec -= 1;
- if (d->tv_sec < 0) /* ??? -- BSD/OS does this */
- {
- d->tv_sec = 0;
- d->tv_usec = 0;
- }
- }
- return d;
-}
-
-static struct timeval *
-addtimeval (d, t1, t2)
- struct timeval *d, *t1, *t2;
-{
- d->tv_sec = t1->tv_sec + t2->tv_sec;
- d->tv_usec = t1->tv_usec + t2->tv_usec;
- if (d->tv_usec >= 1000000)
- {
- d->tv_usec -= 1000000;
- d->tv_sec += 1;
- }
- return d;
-}
-
-/* Do "cpu = ((user + sys) * 10000) / real;" with timevals.
- Barely-tested code from Deven T. Corzine <deven@ties.org>. */
-static int
-timeval_to_cpu (rt, ut, st)
- struct timeval *rt, *ut, *st; /* real, user, sys */
-{
- struct timeval t1, t2;
- register int i;
-
- addtimeval (&t1, ut, st);
- t2.tv_sec = rt->tv_sec;
- t2.tv_usec = rt->tv_usec;
-
- for (i = 0; i < 6; i++)
- {
- if ((t1.tv_sec > 99999999) || (t2.tv_sec > 99999999))
- break;
- t1.tv_sec *= 10;
- t1.tv_sec += t1.tv_usec / 100000;
- t1.tv_usec *= 10;
- t1.tv_usec %= 1000000;
- t2.tv_sec *= 10;
- t2.tv_sec += t2.tv_usec / 100000;
- t2.tv_usec *= 10;
- t2.tv_usec %= 1000000;
- }
- for (i = 0; i < 4; i++)
- {
- if (t1.tv_sec < 100000000)
- t1.tv_sec *= 10;
- else
- t2.tv_sec /= 10;
- }
- return ((t2.tv_sec == 0) ? 0 : t1.tv_sec / t2.tv_sec);
-}
-#endif /* HAVE_GETRUSAGE && HAVE_GETTIMEOFDAY */
+#if defined (HAVE_GETRUSAGE) && defined (HAVE_GETTIMEOFDAY)
+extern struct timeval *difftimeval();
+extern struct timeval *addtimeval();
+extern int timeval_to_cpu();
+#endif
#define POSIX_TIMEFORMAT "real %2R\nuser %2U\nsys %2S"
#define BASH_TIMEFORMAT "\nreal\t%3lR\nuser\t%3lU\nsys\t%3lS"
@@ -1229,6 +1056,146 @@ time_command (command, asynchronous, pipe_in, pipe_out, fds_to_close)
}
#endif /* COMMAND_TIMING */
+/* Execute a command that's supposed to be in a subshell. This must be
+ called after make_child and we must be running in the child process. */
+static int
+execute_in_subshell (command, asynchronous, pipe_in, pipe_out, fds_to_close)
+ COMMAND *command;
+ int asynchronous;
+ int pipe_in, pipe_out;
+ struct fd_bitmap *fds_to_close;
+{
+ int user_subshell, return_code, function_value, should_redir_stdin;
+ COMMAND *tcom;
+
+ should_redir_stdin = (asynchronous && (command->flags & CMD_STDIN_REDIR) &&
+ pipe_in == NO_PIPE &&
+ stdin_redirects (command->redirects) == 0);
+
+ user_subshell = command->type == cm_subshell || ((command->flags & CMD_WANT_SUBSHELL) != 0);
+ command->flags &= ~(CMD_FORCE_SUBSHELL | CMD_WANT_SUBSHELL | CMD_INVERT_RETURN);
+
+ /* If a command is asynchronous in a subshell (like ( foo ) & or
+ the special case of an asynchronous GROUP command where the
+ the subshell bit is turned on down in case cm_group: below),
+ turn off `asynchronous', so that two subshells aren't spawned.
+
+ This seems semantically correct to me. For example,
+ ( foo ) & seems to say ``do the command `foo' in a subshell
+ environment, but don't wait for that subshell to finish'',
+ and "{ foo ; bar ; } &" seems to me to be like functions or
+ builtins in the background, which executed in a subshell
+ environment. I just don't see the need to fork two subshells. */
+
+ /* Don't fork again, we are already in a subshell. A `doubly
+ async' shell is not interactive, however. */
+ if (asynchronous)
+ {
+#if defined (JOB_CONTROL)
+ /* If a construct like ( exec xxx yyy ) & is given while job
+ control is active, we want to prevent exec from putting the
+ subshell back into the original process group, carefully
+ undoing all the work we just did in make_child. */
+ original_pgrp = -1;
+#endif /* JOB_CONTROL */
+ interactive_shell = 0;
+ expand_aliases = 0;
+ asynchronous = 0;
+ }
+
+ /* Subshells are neither login nor interactive. */
+ login_shell = interactive = 0;
+
+ subshell_environment = user_subshell ? SUBSHELL_PAREN : SUBSHELL_ASYNC;
+
+ reset_terminating_signals (); /* in sig.c */
+ /* Cancel traps, in trap.c. */
+ restore_original_signals ();
+ if (asynchronous)
+ setup_async_signals ();
+
+#if defined (JOB_CONTROL)
+ set_sigchld_handler ();
+#endif /* JOB_CONTROL */
+
+ set_sigint_handler ();
+
+#if defined (JOB_CONTROL)
+ /* Delete all traces that there were any jobs running. This is
+ only for subshells. */
+ without_job_control ();
+#endif /* JOB_CONTROL */
+
+ if (fds_to_close)
+ close_fd_bitmap (fds_to_close);
+
+ do_piping (pipe_in, pipe_out);
+
+ /* If this is a user subshell, set a flag if stdin was redirected.
+ This is used later to decide whether to redirect fd 0 to
+ /dev/null for async commands in the subshell. This adds more
+ sh compatibility, but I'm not sure it's the right thing to do. */
+ if (user_subshell)
+ {
+ stdin_redir = stdin_redirects (command->redirects);
+ restore_default_signal (0);
+ }
+
+ /* If this is an asynchronous command (command &), we want to
+ redirect the standard input from /dev/null in the absence of
+ any specific redirection involving stdin. */
+ if (should_redir_stdin && stdin_redir == 0)
+ async_redirect_stdin ();
+
+ /* Do redirections, then dispose of them before recursive call. */
+ if (command->redirects)
+ {
+ if (do_redirections (command->redirects, 1, 0, 0) != 0)
+ exit (EXECUTION_FAILURE);
+
+ dispose_redirects (command->redirects);
+ command->redirects = (REDIRECT *)NULL;
+ }
+
+ tcom = (command->type == cm_subshell) ? command->value.Subshell->command : command;
+
+ /* If this is a simple command, tell execute_disk_command that it
+ might be able to get away without forking and simply exec.
+ This means things like ( sleep 10 ) will only cause one fork.
+ If we're timing the command, however, we cannot do this
+ optimization. */
+ if (user_subshell && (tcom->type == cm_simple || tcom->type == cm_subshell) &&
+ (tcom->flags & CMD_TIME_PIPELINE) == 0)
+ {
+ tcom->flags |= CMD_NO_FORK;
+ if (tcom->type == cm_simple)
+ tcom->value.Simple->flags |= CMD_NO_FORK;
+ }
+
+ /* If we're inside a function while executing this subshell, we
+ need to handle a possible `return'. */
+ function_value = 0;
+ if (return_catch_flag)
+ function_value = setjmp (return_catch);
+
+ if (function_value)
+ return_code = return_catch_value;
+ else
+ return_code = execute_command_internal
+ (tcom, asynchronous, NO_PIPE, NO_PIPE, fds_to_close);
+
+ /* If we were explicitly placed in a subshell with (), we need
+ to do the `shell cleanup' things, such as running traps[0]. */
+ if (user_subshell && signal_is_trapped (0))
+ {
+ last_command_exit_value = return_code;
+ return_code = run_exit_trap ();
+ }
+
+ return (return_code);
+ /* NOTREACHED */
+}
+
static int
execute_pipeline (command, asynchronous, pipe_in, pipe_out, fds_to_close)
COMMAND *command;
@@ -1489,24 +1456,13 @@ execute_connection (command, asynchronous, pipe_in, pipe_out, fds_to_close)
return exec_result;
}
-#if defined (JOB_CONTROL)
-# define REAP() \
- do \
- { \
- if (!interactive_shell) \
- reap_dead_jobs (); \
- } \
- while (0)
-#else /* !JOB_CONTROL */
-# define REAP() \
- do \
- { \
- if (!interactive_shell) \
- cleanup_dead_jobs (); \
- } \
- while (0)
-#endif /* !JOB_CONTROL */
-
+#define REAP() \
+ do \
+ { \
+ if (!interactive_shell) \
+ reap_dead_jobs (); \
+ } \
+ while (0)
/* Execute a FOR command. The syntax is: FOR word_desc IN word_list;
DO command; DONE */
@@ -1612,6 +1568,107 @@ execute_for_command (for_command)
return (retval);
}
+#if defined (ARITH_FOR_COMMAND)
+/* Execute an arithmetic for command. The syntax is
+
+ for (( init ; step ; test ))
+ do
+ body
+ done
+
+ The execution should be exactly equivalent to
+
+ eval \(\( init \)\)
+ while eval \(\( test \)\) ; do
+ body;
+ eval \(\( step \)\)
+ done
+*/
+static long
+eval_arith_for_expr (l, okp)
+ WORD_LIST *l;
+ int *okp;
+{
+ WORD_LIST *new;
+ long expresult;
+
+ new = expand_words_no_vars (l);
+ if (echo_command_at_execute)
+ xtrace_print_arith_cmd (new);
+ expresult = evalexp (new->word->word, okp);
+ dispose_words (new);
+ return (expresult);
+}
+
+static int
+execute_arith_for_command (arith_for_command)
+ ARITH_FOR_COM *arith_for_command;
+{
+ long expresult;
+ int expok, result, body_status;
+
+ body_status = EXECUTION_SUCCESS;
+ loop_level++;
+
+ if (arith_for_command->flags & CMD_IGNORE_RETURN)
+ arith_for_command->action->flags |= CMD_IGNORE_RETURN;
+
+ this_command_name = "(("; /* )) for expression error messages */
+
+ if (variable_context)
+ line_number = arith_for_command->line - function_line_number;
+
+ /* Evaluate the initialization expression. */
+ expresult = eval_arith_for_expr (arith_for_command->init, &expok);
+ if (expok == 0)
+ return (EXECUTION_FAILURE);
+
+ while (1)
+ {
+ /* Evaluate the test expression. */
+ expresult = eval_arith_for_expr (arith_for_command->test, &expok);
+ if (expok == 0)
+ {
+ body_status = EXECUTION_FAILURE;
+ break;
+ }
+ REAP ();
+ if (expresult == 0)
+ break;
+
+ /* Execute the body of the arithmetic for command. */
+ QUIT;
+ body_status = execute_command (arith_for_command->action);
+ QUIT;
+
+ /* Handle any `break' or `continue' commands executed by the body. */
+ if (breaking)
+ {
+ breaking--;
+ break;
+ }
+
+ if (continuing)
+ {
+ continuing--;
+ if (continuing)
+ break;
+ }
+
+ /* Evaluate the step expression. */
+ expresult = eval_arith_for_expr (arith_for_command->step, &expok);
+ if (expok == 0)
+ {
+ body_status = EXECUTION_FAILURE;
+ break;
+ }
+ }
+
+ loop_level--;
+ return (body_status);
+}
+#endif
+
#if defined (SELECT_COMMAND)
static int LINES, COLS, tabsize;
@@ -1863,6 +1920,13 @@ execute_select_command (select_command)
breaking--;
break;
}
+
+ if (continuing)
+ {
+ continuing--;
+ if (continuing)
+ break;
+ }
}
loop_level--;
@@ -2198,7 +2262,7 @@ bind_lastarg (arg)
if (arg == 0)
arg = "";
var = bind_variable ("_", arg);
- var->attributes &= ~att_exported;
+ VUNSETATTR (var, att_exported);
}
/* Execute a null command. Fork a subshell if the command uses pipes or is
@@ -2207,7 +2271,8 @@ bind_lastarg (arg)
static int
execute_null_command (redirects, pipe_in, pipe_out, async, old_last_command_subst_pid)
REDIRECT *redirects;
- int pipe_in, pipe_out, async, old_last_command_subst_pid;
+ int pipe_in, pipe_out, async;
+ pid_t old_last_command_subst_pid;
{
if (pipe_in != NO_PIPE || pipe_out != NO_PIPE || async)
{
@@ -2330,11 +2395,21 @@ execute_simple_command (simple_command, pipe_in, pipe_out, async, fds_to_close)
/* XXX memory leak if expand_words() error causes a jump_to_top_level */
command_line = savestring (the_printed_command);
+ /* Do this now, because execute_disk_command will do it anyway in the
+ vast majority of cases. */
+ maybe_make_export_env ();
+
if (make_child (command_line, async) == 0)
{
already_forked = 1;
simple_command->flags |= CMD_NO_FORK;
+ /* We need to do this before piping to handle some really
+ pathological cases where one of the pipe file descriptors
+ is < 2. */
+ if (fds_to_close)
+ close_fd_bitmap (fds_to_close);
+
do_piping (pipe_in, pipe_out);
pipe_in = pipe_out = -1;
@@ -2681,6 +2756,7 @@ execute_function (var, words, flags, fds_to_close, async, subshell)
int return_val, result;
COMMAND *tc, *fc;
char *debug_trap;
+ SHELL_VAR *old_shell_function;
tc = (COMMAND *)copy_command (function_cell (var));
if (tc && (flags & CMD_IGNORE_RETURN))
@@ -2695,9 +2771,13 @@ execute_function (var, words, flags, fds_to_close, async, subshell)
unwind_protect_int (return_catch_flag);
unwind_protect_jmp_buf (return_catch);
add_unwind_protect (dispose_command, (char *)tc);
+ unwind_protect_pointer (this_shell_function);
unwind_protect_int (loop_level);
}
+ this_shell_function = var;
+ make_funcname_visible (1);
+
debug_trap = (signal_is_trapped (DEBUG_TRAP) && signal_is_ignored (DEBUG_TRAP) == 0)
? trap_list[DEBUG_TRAP]
: (char *)NULL;
@@ -2761,9 +2841,34 @@ execute_function (var, words, flags, fds_to_close, async, subshell)
if (subshell == 0)
run_unwind_frame ("function_calling");
+ if (variable_context == 0 || this_shell_function == 0)
+ make_funcname_visible (0);
+
return (result);
}
+/* A convenience routine for use by other parts of the shell to execute
+ a particular shell function. */
+int
+execute_shell_function (var, words)
+ SHELL_VAR *var;
+ WORD_LIST *words;
+{
+ int ret;
+ struct fd_bitmap *bitmap;
+
+ bitmap = new_fd_bitmap (FD_BITMAP_DEFAULT_SIZE);
+ begin_unwind_frame ("execute-shell-function");
+ add_unwind_protect (dispose_fd_bitmap, (char *)bitmap);
+
+ ret = execute_function (var, words, 0, bitmap, 0, 0);
+
+ dispose_fd_bitmap (bitmap);
+ discard_unwind_frame ("execute-shell-function");
+
+ return ret;
+}
+
/* Execute a shell builtin or function in a subshell environment. This
routine does not return; it only calls exit(). If BUILTIN is non-null,
it points to a function to call to execute a shell builtin; otherwise
@@ -2782,13 +2887,16 @@ execute_subshell_builtin_or_function (words, redirects, builtin, var,
struct fd_bitmap *fds_to_close;
int flags;
{
- int result, r, jobs_hack;
-
- /* A subshell is neither a login shell nor interactive. */
- login_shell = interactive = 0;
+ int result, r;
+#if defined (JOB_CONTROL)
+ int jobs_hack;
jobs_hack = (builtin == jobs_builtin) &&
((subshell_environment & SUBSHELL_ASYNC) == 0 || pipe_out != NO_PIPE);
+#endif
+
+ /* A subshell is neither a login shell nor interactive. */
+ login_shell = interactive = 0;
subshell_environment = SUBSHELL_ASYNC;
@@ -2810,11 +2918,11 @@ execute_subshell_builtin_or_function (words, redirects, builtin, var,
set_sigint_handler ();
- do_piping (pipe_in, pipe_out);
-
if (fds_to_close)
close_fd_bitmap (fds_to_close);
+ do_piping (pipe_in, pipe_out);
+
if (do_redirections (redirects, 1, 0, 0) != 0)
exit (EXECUTION_FAILURE);
@@ -2955,7 +3063,7 @@ execute_disk_command (words, redirects, command_line, pipe_in, pipe_out,
{
char *pathname, *command, **args;
int nofork;
- int pid;
+ pid_t pid;
nofork = (cmdflags & CMD_NO_FORK); /* Don't fork, just exec, if no pipes */
pathname = words->word->word;
@@ -2978,7 +3086,7 @@ execute_disk_command (words, redirects, command_line, pipe_in, pipe_out,
put_command_name_into_env (command);
}
- /* We have to make the child before we check for the non-existance
+ /* We have to make the child before we check for the non-existence
of COMMAND, since we want the error messages to be redirected. */
/* If we can get away without forking and there are no pipes to deal with,
don't bother to fork, just directly exec the command. */
@@ -3014,6 +3122,14 @@ execute_disk_command (words, redirects, command_line, pipe_in, pipe_out,
setup_async_signals ();
}
+ /* This functionality is now provided by close-on-exec of the
+ file descriptors manipulated by redirection and piping.
+ Some file descriptors still need to be closed in all children
+ because of the way bash does pipes; fds_to_close is a
+ bitmap of all such file descriptors. */
+ if (fds_to_close)
+ close_fd_bitmap (fds_to_close);
+
do_piping (pipe_in, pipe_out);
if (async)
@@ -3024,14 +3140,6 @@ execute_disk_command (words, redirects, command_line, pipe_in, pipe_out,
subshell_environment = SUBSHELL_FORK;
- /* This functionality is now provided by close-on-exec of the
- file descriptors manipulated by redirection and piping.
- Some file descriptors still need to be closed in all children
- because of the way bash does pipes; fds_to_close is a
- bitmap of all such file descriptors. */
- if (fds_to_close)
- close_fd_bitmap (fds_to_close);
-
if (redirects && (do_redirections (redirects, 1, 0, 0) != 0))
{
#if defined (PROCESS_SUBSTITUTION)
@@ -3098,10 +3206,14 @@ execute_shell_script (sample, sample_len, command, args, env)
i++)
;
+#if 1
+ execname = substring ((char *)sample, start, i);
+#else
larry = i - start;
execname = xmalloc (1 + larry);
strncpy (execname, (char *)(sample + start), larry);
execname[larry] = '\0';
+#endif
size_increment = 1;
/* Now the argument, if any. */
@@ -3119,10 +3231,14 @@ execute_shell_script (sample, sample_len, command, args, env)
!whitespace (sample[i]) && sample[i] != '\n' && i < sample_len;
i++)
;
+#if 1
+ firstarg = substring ((char *)sample, start, i);
+#else
larry = i - start;
firstarg = xmalloc (1 + larry);
strncpy (firstarg, (char *)(sample + start), larry);
firstarg[larry] = '\0';
+#endif
size_increment = 2;
}
@@ -3363,9 +3479,6 @@ do_piping (pipe_in, pipe_out)
sys_error ("cannot duplicate fd %d to fd 0", pipe_in);
if (pipe_in > 0)
close (pipe_in);
-#ifdef __CYGWIN32__
- setmode (0, O_TEXT);
-#endif
}
if (pipe_out != NO_PIPE)
{
@@ -3375,18 +3488,11 @@ do_piping (pipe_in, pipe_out)
sys_error ("cannot duplicate fd %d to fd 1", pipe_out);
if (pipe_out == 0 || pipe_out > 1)
close (pipe_out);
-#ifdef __CYGWIN32__
- setmode (1, O_TEXT);
-#endif
}
else
{
if (dup2 (1, 2) < 0)
sys_error ("cannot duplicate fd 1 to fd 2");
-#ifdef __CYGWIN32__
- setmode (1, O_TEXT);
- setmode (2, O_TEXT);
-#endif
}
}
}
diff --git a/execute_cmd.h b/execute_cmd.h
index d2330342..f3048be1 100644
--- a/execute_cmd.h
+++ b/execute_cmd.h
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if !defined (_EXECUTE_CMD_H_)
#define _EXECUTE_CMD_H_
@@ -33,6 +33,8 @@ extern int shell_execve __P((char *, char **, char **));
extern void setup_async_signals __P((void));
extern void dispose_exec_redirects __P ((void));
+extern int execute_shell_function __P((SHELL_VAR *, WORD_LIST *));
+
#if defined (PROCESS_SUBSTITUTION)
extern void close_all_files __P((void));
#endif
diff --git a/expr.c b/expr.c
index 3b7f80e5..14d3aba5 100644
--- a/expr.c
+++ b/expr.c
@@ -6,7 +6,7 @@
Bash is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 1, or (at your option)
+ the Free Software Foundation; either version 2, or (at your option)
any later version.
Bash is distributed in the hope that it will be useful, but WITHOUT
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with Bash; see the file COPYING. If not, write to the Free
- Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
/*
All arithmetic is done as long integers with no checking for overflow
@@ -25,6 +25,8 @@
The following operators are handled, grouped into a set of levels in
order of decreasing precedence.
+ "id++", "id--" [post-increment and post-decrement]
+ "++id", "--id" [pre-increment and pre-decrement]
"-", "+" [(unary operators)]
"!", "~"
"**" [(exponentiation)]
@@ -75,6 +77,8 @@
# include <unistd.h>
#endif
+#include <ctype.h>
+
#include "shell.h"
/* Because of the $((...)) construct, expressions may include newlines.
@@ -104,6 +108,10 @@
#define OP_ASSIGN 11 /* op= expassign as in Posix.2 */
#define COND 12 /* exp1 ? exp2 : exp3 */
#define POWER 13 /* exp1**exp2 */
+#define PREINC 14 /* ++var */
+#define PREDEC 15 /* --var */
+#define POSTINC 16 /* var++ */
+#define POSTDEC 17 /* var-- */
#define EQ '='
#define GT '>'
#define LT '<'
@@ -121,6 +129,11 @@
#define BNOT '~' /* Bitwise NOT; Two's complement. */
#define QUES '?'
#define COL ':'
+#define COMMA ','
+
+/* This should be the function corresponding to the operator with the
+ highest precedence. */
+#define EXP_HIGHEST expcomma
static char *expression; /* The current expression */
static char *tp; /* token lexical position */
@@ -136,18 +149,25 @@ static procenv_t evalbuf;
static void readtok (); /* lexical analyzer */
static long subexpr (), expassign (), exp0 (), exp1 (), exp2 (), exp3 (),
exp4 (), exp5 (), expshift (), expland (), explor (),
- expband (), expbor (), expbxor (), expcond (), exppower ();
+ expband (), expbor (), expbxor (), expcond (), exppower (),
+ expcomma ();
static long strlong ();
static void evalerror ();
/* A structure defining a single expression context. */
typedef struct {
int curtok, lasttok;
- char *expression, *tp;
+ char *expression, *tp, *lasttp;
int tokval;
char *tokstr;
+ int noeval;
} EXPR_CONTEXT;
+typedef struct {
+ char *tokstr;
+ int tokval;
+} LVALUE;
+
/* Global var which contains the stack of expression contexts. */
static EXPR_CONTEXT **expr_stack;
static int expr_depth; /* Location in the stack. */
@@ -155,6 +175,28 @@ static int expr_stack_size; /* Number of slots already allocated. */
extern char *this_command_name;
+#define SAVETOK(X) \
+ do { \
+ (X)->curtok = curtok; \
+ (X)->lasttok = lasttok; \
+ (X)->tp = tp; \
+ (X)->lasttp = lasttp; \
+ (X)->tokval = tokval; \
+ (X)->tokstr = tokstr; \
+ (X)->noeval = noeval; \
+ } while (0)
+
+#define RESTORETOK(X) \
+ do { \
+ curtok = (X)->curtok; \
+ lasttok = (X)->lasttok; \
+ tp = (X)->tp; \
+ lasttp = (X)->lasttp; \
+ tokval = (X)->tokval; \
+ tokstr = (X)->tokstr; \
+ noeval = (X)->noeval; \
+ } while (0)
+
/* Push and save away the contents of the globals describing the
current expression context. */
static void
@@ -174,12 +216,9 @@ pushexp ()
context = (EXPR_CONTEXT *)xmalloc (sizeof (EXPR_CONTEXT));
- context->curtok = curtok;
- context->lasttok = lasttok;
context->expression = expression;
- context->tp = tp;
- context->tokval = tokval;
- context->tokstr = tokstr;
+ SAVETOK(context);
+
expr_stack[expr_depth++] = context;
}
@@ -194,12 +233,10 @@ popexp ()
evalerror ("recursion stack underflow");
context = expr_stack[--expr_depth];
- curtok = context->curtok;
- lasttok = context->lasttok;
+
expression = context->expression;
- tp = context->tp;
- tokval = context->tokval;
- tokstr = context->tokstr;
+ RESTORETOK (context);
+
free (context);
}
@@ -294,7 +331,7 @@ subexpr (expr)
readtok ();
- val = expassign ();
+ val = EXP_HIGHEST ();
if (curtok != 0)
evalerror ("syntax error in expression");
@@ -307,35 +344,21 @@ subexpr (expr)
return val;
}
-/* Bind/create a shell variable with the name LHS to the RHS.
- This creates or modifies a variable such that it is an integer.
-
- This should really be in variables.c, but it is here so that all of the
- expression evaluation stuff is localized. Since we don't want any
- recursive evaluation from bind_variable() (possible without this code,
- since bind_variable() calls the evaluator for variables with the integer
- attribute set), we temporarily turn off the integer attribute for each
- variable we set here, then turn it back on after binding as necessary. */
-
-void
-bind_int_variable (lhs, rhs)
- char *lhs, *rhs;
+static long
+expcomma ()
{
- register SHELL_VAR *v;
- int isint = 0;
+ register long value;
- v = find_variable (lhs);
- if (v)
+ value = expassign ();
+ while (curtok == COMMA)
{
- isint = integer_p (v);
- v->attributes &= ~att_integer;
+ readtok ();
+ value = expassign ();
}
- v = bind_variable (lhs, rhs);
- if (isint)
- v->attributes |= att_integer;
+ return value;
}
-
+
static long
expassign ()
{
@@ -404,7 +427,7 @@ expassign ()
rhs = itos (value);
if (noeval == 0)
- bind_int_variable (lhs, rhs);
+ (void)bind_int_variable (lhs, rhs);
free (rhs);
free (lhs);
FREE (tokstr);
@@ -435,7 +458,7 @@ expcond ()
#if 0
val1 = explor ();
#else
- val1 = expassign ();
+ val1 = EXP_HIGHEST ();
#endif
if (set_noeval)
noeval--;
@@ -706,6 +729,8 @@ exppower ()
val2 = exp1 ();
if (val2 == 0)
return (1L);
+ if (val2 < 0)
+ evalerror ("exponent less than 0");
for (c = 1; val2--; c *= val1)
;
val1 = c;
@@ -737,9 +762,31 @@ exp1 ()
static long
exp0 ()
{
- register long val = 0L;
+ register long val = 0L, v2;
+ char *vincdec;
+ int stok;
+
+ /* XXX - might need additional logic here to decide whether or not
+ pre-increment or pre-decrement is legal at this point. */
+ if (curtok == PREINC || curtok == PREDEC)
+ {
+ stok = lasttok = curtok;
+ readtok ();
+ if (curtok != STR)
+ /* readtok() catches this */
+ evalerror ("identifier expected after pre-increment or pre-decrement");
- if (curtok == MINUS)
+ v2 = tokval + ((stok == PREINC) ? 1 : -1);
+ vincdec = itos (v2);
+ if (noeval == 0)
+ (void)bind_int_variable (tokstr, vincdec);
+ free (vincdec);
+ val = v2;
+
+ curtok = NUM; /* make sure --x=7 is flagged as an error */
+ readtok ();
+ }
+ else if (curtok == MINUS)
{
readtok ();
val = - exp0 ();
@@ -752,7 +799,7 @@ exp0 ()
else if (curtok == LPAR)
{
readtok ();
- val = expassign ();
+ val = EXP_HIGHEST ();
if (curtok != RPAR)
evalerror ("missing `)'");
@@ -763,6 +810,19 @@ exp0 ()
else if ((curtok == NUM) || (curtok == STR))
{
val = tokval;
+ if (curtok == STR && (*tp == '+' || *tp == '-') && tp[1] == *tp &&
+ (tp[2] == '\0' || (isalnum (tp[2]) == 0)))
+ {
+ /* post-increment or post-decrement */
+ v2 = val + ((*tp == '+') ? 1 : -1);
+ vincdec = itos (v2);
+ if (noeval == 0)
+ (void)bind_int_variable (tokstr, vincdec);
+ free (vincdec);
+ tp += 2;
+ curtok = NUM; /* make sure x++=7 is flagged as an error */
+ }
+
readtok ();
}
else
@@ -802,9 +862,10 @@ readtok ()
if (legal_variable_starter (c))
{
- /* Semi-bogus ksh compatibility feature -- variable names
- not preceded with a dollar sign are shell variables. */
- char *value;
+ /* variable names not preceded with a dollar sign are shell variables. */
+ char *value, *savecp;
+ EXPR_CONTEXT ec;
+ int peektok;
while (legal_variable_char (c))
c = *cp++;
@@ -827,24 +888,41 @@ readtok ()
#endif /* ARRAY_VARS */
*cp = '\0';
-
FREE (tokstr);
tokstr = savestring (tp);
+ *cp = c;
+ SAVETOK (&ec);
+ tokstr = (char *)NULL; /* keep it from being freed */
+ tp = savecp = cp;
+ noeval = 1;
+ readtok ();
+ peektok = curtok;
+ if (peektok == STR) /* free new tokstr before old one is restored */
+ FREE (tokstr);
+ RESTORETOK (&ec);
+ cp = savecp;
+
+ /* The tests for PREINC and PREDEC aren't strictly correct, but they
+ preserve old behavior if a construct like --x=9 is given. */
+ if (lasttok == PREINC || lasttok == PREDEC || peektok != EQ)
+ {
#if defined (ARRAY_VARS)
- value = (e == ']') ? get_array_value (tokstr, 0) : get_string_value (tokstr);
+ value = (e == ']') ? get_array_value (tokstr, 0) : get_string_value (tokstr);
#else
- value = get_string_value (tokstr);
+ value = get_string_value (tokstr);
#endif
- tokval = (value && *value) ? subexpr (value) : 0;
+ tokval = (value && *value) ? subexpr (value) : 0;
#if defined (ARRAY_VARS)
- if (e == ']')
- FREE (value); /* get_array_value returns newly-allocated memory */
+ if (e == ']')
+ FREE (value); /* get_array_value returns newly-allocated memory */
#endif
+ }
+ else
+ tokval = 0;
- *cp = c;
lasttok = curtok;
curtok = STR;
}
@@ -900,6 +978,10 @@ readtok ()
c = LOR;
else if ((c == '*') && (c1 == '*'))
c = POWER;
+ else if ((c == '-') && (c1 == '-') && legal_variable_starter (*cp))
+ c = PREDEC;
+ else if ((c == '+') && (c1 == '+') && legal_variable_starter (*cp))
+ c = PREINC;
else if (c1 == EQ && member(c, "*/%+-&^|"))
{
assigntok = c; /* a OP= b */
diff --git a/externs.h b/externs.h
index 4d56cbe3..80d1c05b 100644
--- a/externs.h
+++ b/externs.h
@@ -17,7 +17,7 @@
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
/* Make sure that this is included *after* config.h! */
@@ -60,7 +60,6 @@ extern void get_current_user_info __P((void));
extern int reader_loop __P((void));
extern int parse_command __P((void));
extern int read_command __P((void));
-extern WORD_LIST *parse_string_to_word_list __P((char *, char *));
/* Functions from braces.c. */
#if defined (BRACE_EXPANSION)
@@ -68,8 +67,12 @@ extern char **brace_expand __P((char *));
#endif
/* Miscellaneous functions from parse.y */
-extern int yyparse ();
-extern void reset_parser ();
+extern int yyparse __P((void));
+extern void reset_parser __P((void));
+extern WORD_LIST *parse_string_to_word_list __P((char *, char *));
+
+extern int get_current_prompt_level __P((void));
+extern void set_current_prompt_level __P((int));
/* Functions from version.c. */
extern char *shell_version_string __P((void));
@@ -92,8 +95,9 @@ extern GENERIC_LIST *list_append ();
extern GENERIC_LIST *delete_element ();
/* Declarations for functions defined in stringlib.c */
-extern char *ansicstr __P((char *, int, int *, int *));
+extern char *ansicstr __P((char *, int, int, int *, int *));
extern int find_name_in_array __P((char *, char **));
+extern char **alloc_array __P((int));
extern int array_len __P((char **));
extern void free_array_members __P((char **));
extern void free_array __P((char **));
@@ -103,7 +107,10 @@ extern void sort_char_array __P((char **));
extern char **word_list_to_argv __P((WORD_LIST *, int, int, int *));
extern WORD_LIST *argv_to_word_list __P((char **, int, int));
+extern int find_string_in_alist __P((char *, STRING_INT_ALIST *, int));
+
extern char *strsub __P((char *, char *, char *, int));
+extern char *strcreplace __P((char *, int, char *, int));
extern void strip_leading __P((char *));
extern void strip_trailing __P((char *, int, int));
extern char *strindex __P((char *, char *));
@@ -161,4 +168,34 @@ extern long strtol __P((const char *, char **, int));
extern unsigned long strtoul __P((const char *, char **, int));
#endif
+/* declarations for functions defined in lib/sh/zread.c */
+extern int zread __P((int, char *, size_t));
+extern int zread1 __P((int, char *, size_t));
+extern int zreadc __P((int, char *));
+extern void zreset __P((void));
+extern void zsyncfd __P((int));
+
+/* declarations for functions defined in lib/sh/zwrite.c */
+extern int zwrite __P((int, unsigned char *, size_t));
+
+/* declarations for functions defined in lib/sh/netopen.c */
+extern int netopen __P((char *));
+
+/* declarations for functions defined in lib/sh/timeval.c. No prototypes
+ so we don't have to count on having a definition of struct timeval in
+ scope when this file is included. */
+extern void timeval_to_secs ();
+extern void print_timeval ();
+
+/* declarations for functions defined in lib/sh/clock.c */
+extern void clock_t_to_secs ();
+extern void print_clock_t ();
+
+/* declarations for functions defined in lib/sh/makepath.c */
+#define MP_DOTILDE 0x01
+#define MP_DOCWD 0x02
+#define MP_RMDOT 0x04
+
+extern char *sh_makepath __P((char *, char *, int));
+
#endif /* _EXTERNS_H_ */
diff --git a/filecntl.h b/filecntl.h
deleted file mode 100644
index cf5054de..00000000
--- a/filecntl.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/* filecntl.h - Definitions to set file descriptors to close-on-exec. */
-
-/* Copyright (C) 1993 Free Software Foundation, Inc.
-
- This file is part of GNU Bash, the Bourne Again SHell.
-
- Bash is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free
- Software Foundation; either version 2, or (at your option) any later
- version.
-
- Bash is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- for more details.
-
- You should have received a copy of the GNU General Public License along
- with Bash; see the file COPYING. If not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#if !defined (_FILECNTL_H_)
-#define _FILECNTL_H_
-
-#include <fcntl.h>
-
-/* Definitions to set file descriptors to close-on-exec, the Posix way. */
-#if !defined (FD_CLOEXEC)
-#define FD_CLOEXEC 1
-#endif
-
-#define FD_NCLOEXEC 0
-
-#define SET_CLOSE_ON_EXEC(fd) (fcntl ((fd), F_SETFD, FD_CLOEXEC))
-#define SET_OPEN_ON_EXEC(fd) (fcntl ((fd), F_SETFD, FD_NCLOEXEC))
-
-/* How to open a file in non-blocking mode, the Posix.1 way. */
-#if !defined (O_NONBLOCK)
-# if defined (O_NDELAY)
-# define O_NONBLOCK O_NDELAY
-# else
-# define O_NONBLOCK 0
-# endif
-#endif
-
-#endif /* ! _FILECNTL_H_ */
diff --git a/findcmd.c b/findcmd.c
index 837b392d..7d0bc72b 100644
--- a/findcmd.c
+++ b/findcmd.c
@@ -6,7 +6,7 @@
Bash is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 1, or (at your option)
+ the Free Software Foundation; either version 2, or (at your option)
any later version.
Bash is distributed in the hope that it will be useful, but WITHOUT
@@ -243,10 +243,10 @@ get_next_path_element (path_list, path_index_pointer)
path = extract_colon_unit (path_list, path_index_pointer);
- if (!path)
+ if (path == 0)
return (path);
- if (!*path)
+ if (*path == '\0')
{
free (path);
path = savestring (".");
@@ -338,7 +338,7 @@ user_command_matches (name, flags, state)
if (match_list == 0)
{
match_list_size = 5;
- match_list = (char **)xmalloc (match_list_size * sizeof(char *));
+ match_list = alloc_array (match_list_size);
}
/* Clear out the old match list. */
@@ -402,24 +402,6 @@ user_command_matches (name, flags, state)
return (match);
}
-/* Turn PATH, a directory, and NAME, a filename, into a full pathname.
- This allocates new memory and returns it. */
-static char *
-make_full_pathname (path, name, name_len)
- char *path, *name;
- int name_len;
-{
- char *full_path;
- int path_len;
-
- path_len = strlen (path);
- full_path = xmalloc (2 + path_len + name_len);
- strcpy (full_path, path);
- full_path[path_len] = '/';
- strcpy (full_path + path_len + 1, name);
- return (full_path);
-}
-
static char *
find_absolute_program (name, flags)
char *name;
@@ -458,7 +440,7 @@ find_in_path_element (name, path, flags, name_len, dotinfop)
if (dot_found_in_search == 0 && *xpath == '.')
dot_found_in_search = same_file (".", xpath, dotinfop, (struct stat *)NULL);
- full_path = make_full_pathname (xpath, name, name_len);
+ full_path = sh_makepath (xpath, name, 0);
status = file_status (full_path);
diff --git a/findcmd.h b/findcmd.h
index f01cb7de..45678122 100644
--- a/findcmd.h
+++ b/findcmd.h
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if !defined (_FINDCMD_H_)
#define _FINDCMD_H_
diff --git a/flags.c b/flags.c
index 19cd3b4e..9cb753a0 100644
--- a/flags.c
+++ b/flags.c
@@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 1, or (at your option) any later
+Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
/* Flags hacking. */
#include "config.h"
@@ -36,6 +36,9 @@ extern int set_job_control ();
extern char *shell_name;
#endif
+/* -c, -s invocation options -- not really flags, but they show up in $- */
+extern int want_pending_command, read_from_stdin;
+
/* **************************************************************** */
/* */
/* The Standard Sh Flags. */
@@ -219,14 +222,14 @@ change_flag (flag, on_or_off)
{
int *value, old_value;
- value = find_flag (flag);
-
#if defined (RESTRICTED_SHELL)
/* Don't allow "set +r" in a shell which is `restricted'. */
if (restricted && flag == 'r' && on_or_off == FLAG_OFF)
return (FLAG_ERROR);
#endif /* RESTRICTED_SHELL */
+ value = find_flag (flag);
+
if ((value == (int *)FLAG_UNKNOWN) || (on_or_off != FLAG_ON && on_or_off != FLAG_OFF))
return (FLAG_ERROR);
@@ -275,11 +278,16 @@ which_set_flags ()
char *temp;
int i, string_index;
- temp = xmalloc (1 + NUM_SHELL_FLAGS);
+ temp = xmalloc (1 + NUM_SHELL_FLAGS + read_from_stdin + want_pending_command);
for (i = string_index = 0; shell_flags[i].name; i++)
if (*(shell_flags[i].value))
temp[string_index++] = shell_flags[i].name;
+ if (want_pending_command)
+ temp[string_index++] = 'c';
+ if (read_from_stdin)
+ temp[string_index++] = 's';
+
temp[string_index] = '\0';
return (temp);
}
diff --git a/flags.h b/flags.h
index dbab8ac3..9c93b34d 100644
--- a/flags.h
+++ b/flags.h
@@ -17,7 +17,7 @@
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if !defined (_FLAGS_H_)
#define _FLAGS_H_
diff --git a/general.c b/general.c
index 5b978dcf..753a3569 100644
--- a/general.c
+++ b/general.c
@@ -1,7 +1,6 @@
/* general.c -- Stuff that is used by all files. */
-/* Copyright (C) 1987, 1988, 1989, 1990, 1991, 1992
- Free Software Foundation, Inc.
+/* Copyright (C) 1987-1999 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -17,7 +16,7 @@
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#include "config.h"
@@ -40,18 +39,6 @@
#include "shell.h"
#include <tilde/tilde.h>
-#if defined (TIME_WITH_SYS_TIME)
-# include <sys/time.h>
-# include <time.h>
-#else
-# if defined (HAVE_SYS_TIME_H)
-# include <sys/time.h>
-# else
-# include <time.h>
-# endif
-#endif
-
-#include <sys/times.h>
#include "maxpath.h"
#if !defined (errno)
@@ -133,98 +120,6 @@ print_rlimtype (n, addnl)
}
#endif /* RLIMTYPE */
-#if defined (HAVE_TIMEVAL)
-/* Convert a pointer to a struct timeval to seconds and thousandths of a
- second, returning the values in *SP and *SFP, respectively. This does
- rounding on the fractional part, not just truncation to three places. */
-void
-timeval_to_secs (tvp, sp, sfp)
- struct timeval *tvp;
- long *sp;
- int *sfp;
-{
- int rest;
-
- *sp = tvp->tv_sec;
-
- *sfp = tvp->tv_usec % 1000000; /* pretty much a no-op */
- rest = *sfp % 1000;
- *sfp = (*sfp * 1000) / 1000000;
- if (rest >= 500)
- *sfp += 1;
-
- /* Sanity check */
- if (*sfp >= 1000)
- {
- *sp += 1;
- *sfp -= 1000;
- }
-}
-
-/* Print the contents of a struct timeval * in a standard way to stdio
- stream FP. */
-void
-print_timeval (fp, tvp)
- FILE *fp;
- struct timeval *tvp;
-{
- int minutes, seconds_fraction;
- long seconds;
-
- timeval_to_secs (tvp, &seconds, &seconds_fraction);
-
- minutes = seconds / 60;
- seconds %= 60;
-
- fprintf (fp, "%0dm%0ld.%03ds", minutes, seconds, seconds_fraction);
-}
-#endif /* HAVE_TIMEVAL */
-
-#if defined (HAVE_TIMES)
-void
-clock_t_to_secs (t, sp, sfp)
- clock_t t;
- long *sp;
- int *sfp;
-{
- static long clk_tck = 0;
-
- if (clk_tck == 0)
- clk_tck = get_clk_tck ();
-
- *sfp = t % clk_tck;
- *sfp = (*sfp * 1000) / clk_tck;
-
- *sp = t / clk_tck;
-
- /* Sanity check */
- if (*sfp >= 1000)
- {
- *sp += 1;
- *sfp -= 1000;
- }
-}
-
-/* Print the time defined by a time_t (returned by the `times' and `time'
- system calls) in a standard way to stdion stream FP. This is scaled in
- terms of HZ, which is what is returned by the `times' call. */
-void
-print_time_in_hz (fp, t)
- FILE *fp;
- clock_t t;
-{
- int minutes, seconds_fraction;
- long seconds;
-
- clock_t_to_secs (t, &seconds, &seconds_fraction);
-
- minutes = seconds / 60;
- seconds %= 60;
-
- fprintf (fp, "%0dm%0ld.%03ds", minutes, seconds, seconds_fraction);
-}
-#endif /* HAVE_TIMES */
-
/* **************************************************************** */
/* */
/* Input Validation Functions */
@@ -338,27 +233,34 @@ check_identifier (word, check_word)
#endif /* O_NDELAY */
/* Make sure no-delay mode is not set on file descriptor FD. */
-void
+int
unset_nodelay_mode (fd)
int fd;
{
- int flags, set;
+ int flags, bflags;
if ((flags = fcntl (fd, F_GETFL, 0)) < 0)
- return;
+ return -1;
- set = 0;
+ bflags = 0;
/* This is defined to O_NDELAY in filecntl.h if O_NONBLOCK is not present
and O_NDELAY is defined. */
- if (flags & O_NONBLOCK)
+#ifdef O_NONBLOCK
+ bflags |= O_NONBLOCK;
+#endif
+
+#ifdef O_NDELAY
+ bflags |= O_NDELAY;
+#endif
+
+ if (flags & bflags)
{
- flags &= ~O_NONBLOCK;
- set++;
+ flags &= ~bflags;
+ return (fcntl (fd, F_SETFL, flags));
}
- if (set)
- fcntl (fd, F_SETFL, flags);
+ return 0;
}
/* There is a bug in the NeXT 2.1 rlogind that causes opens
@@ -670,32 +572,11 @@ make_absolute (string, dot_path)
char *string, *dot_path;
{
char *result;
- int result_len;
if (dot_path == 0 || *string == '/')
result = savestring (string);
else
- {
- if (dot_path[0])
- {
- result_len = strlen (dot_path);
- result = xmalloc (2 + result_len + strlen (string));
- strcpy (result, dot_path);
- if (result[result_len - 1] != '/')
- {
- result[result_len++] = '/';
- result[result_len] = '\0';
- }
- }
- else
- {
- result = xmalloc (3 + strlen (string));
- result[0] = '.'; result[1] = '/'; result[2] = '\0';
- result_len = 2;
- }
-
- strcpy (result + result_len, string);
- }
+ result = sh_makepath (dot_path, string, 0);
return (result);
}
@@ -753,37 +634,17 @@ char *
full_pathname (file)
char *file;
{
- char *disposer;
- char *current_dir;
- int dlen;
+ char *ret;
file = (*file == '~') ? bash_tilde_expand (file) : savestring (file);
if ((*file == '/') && absolute_pathname (file))
return (file);
- disposer = file;
+ ret = sh_makepath ((char *)NULL, file, (MP_DOCWD|MP_RMDOT));
+ free (file);
- /* XXX - this should probably be just PATH_MAX or PATH_MAX + 1 */
- current_dir = xmalloc (2 + PATH_MAX + strlen (file));
- if (getcwd (current_dir, PATH_MAX) == 0)
- {
- sys_error (bash_getcwd_errstr);
- free (disposer);
- free (current_dir);
- return ((char *)NULL);
- }
- dlen = strlen (current_dir);
- if (current_dir[0] == '/' && dlen > 1)
- current_dir[dlen++] = '/';
-
- /* Turn /foo/./bar into /foo/bar. */
- if (file[0] == '.' && file[1] == '/')
- file += 2;
-
- strcpy (current_dir + dlen, file);
- free (disposer);
- return (current_dir);
+ return (ret);
}
/* A slightly related function. Get the prettiest name of this
@@ -854,12 +715,7 @@ extract_colon_unit (string, p_index)
value[0] = '\0';
}
else
- {
- len = i - start;
- value = xmalloc (1 + len);
- strncpy (value, string + start, len);
- value [len] = '\0';
- }
+ value = substring (string, start, i);
return (value);
}
@@ -915,12 +771,12 @@ tilde_initialize ()
tilde_initialize () is called from within bashline_reinitialize (). */
if (times_called++ == 0)
{
- tilde_additional_prefixes = (char **)xmalloc (3 * sizeof (char *));
+ tilde_additional_prefixes = alloc_array (3);
tilde_additional_prefixes[0] = "=~";
tilde_additional_prefixes[1] = ":~";
tilde_additional_prefixes[2] = (char *)NULL;
- tilde_additional_suffixes = (char **)xmalloc (3 * sizeof (char *));
+ tilde_additional_suffixes = alloc_array (3);
tilde_additional_suffixes[0] = ":";
tilde_additional_suffixes[1] = "=~";
tilde_additional_suffixes[2] = (char *)NULL;
@@ -1081,7 +937,7 @@ get_group_list (ngp)
return (char **)NULL;
}
- group_vector = (char **)xmalloc (ngroups * sizeof (char *));
+ group_vector = alloc_array (ngroups);
for (i = 0; i < ngroups; i++)
{
nbuf = itos ((int)group_array[i]);
diff --git a/general.h b/general.h
index 2bbd0c07..3dfeee70 100644
--- a/general.h
+++ b/general.h
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if !defined (_GENERAL_H_)
#define _GENERAL_H_
@@ -133,7 +133,8 @@ typedef struct {
/* String comparisons that possibly save a function call each. */
#define STREQ(a, b) ((a)[0] == (b)[0] && strcmp(a, b) == 0)
-#define STREQN(a, b, n) ((a)[0] == (b)[0] && strncmp(a, b, n) == 0)
+#define STREQN(a, b, n) ((n == 0) ? (1) \
+ : ((a)[0] == (b)[0] && strncmp(a, b, n) == 0))
/* More convenience definitions that possibly save system or libc calls. */
#define STRLEN(s) (((s) && (s)[0]) ? ((s)[1] ? ((s)[2] ? strlen(s) : 2) : 1) : 0)
@@ -180,7 +181,7 @@ typedef char **CPPFunction ();
/* Declarations for functions defined in xmalloc.c */
extern char *xmalloc __P((size_t));
extern char *xrealloc __P((void *, size_t));
-extern void xfree __P((char *));
+extern void xfree __P((void *));
/* Declarations for functions defined in general.c */
extern void posix_initialize __P((int));
@@ -190,17 +191,12 @@ extern RLIMTYPE string_to_rlimtype __P((char *));
extern void print_rlimtype __P((RLIMTYPE, int));
#endif
-extern void timeval_to_secs ();
-extern void print_timeval ();
-extern void clock_t_to_secs ();
-extern void print_time_in_hz ();
-
extern int all_digits __P((char *));
extern int legal_number __P((char *, long *));
extern int legal_identifier __P((char *));
extern int check_identifier __P((WORD_DESC *, int));
-extern void unset_nodelay_mode __P((int));
+extern int unset_nodelay_mode __P((int));
extern void check_dev_tty __P((void));
extern int same_file (); /* too many problems with prototype */
extern int move_to_high_fd __P((int, int, int));
diff --git a/hashcmd.c b/hashcmd.c
index 5fa7b8b7..6f609776 100644
--- a/hashcmd.c
+++ b/hashcmd.c
@@ -7,7 +7,7 @@
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
- Software Foundation; either version 1, or (at your option) any later
+ Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -17,7 +17,7 @@
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#include <config.h>
diff --git a/hashcmd.h b/hashcmd.h
index aacd8e70..54692eae 100644
--- a/hashcmd.h
+++ b/hashcmd.h
@@ -16,8 +16,9 @@
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+#include "stdc.h"
#include "hashlib.h"
#define FILENAME_HASH_BUCKETS 107
@@ -34,8 +35,8 @@ typedef struct {
#define pathdata(x) ((PATH_DATA *)(x)->data)
-extern void initialize_filename_hashing ();
-extern void flush_hashed_filenames ();
-extern void remove_hashed_filename ();
-extern void remember_filename ();
-extern char *find_hashed_filename ();
+extern void initialize_filename_hashing __P((void));
+extern void flush_hashed_filenames __P((void));
+extern void remove_hashed_filename __P((char *));
+extern void remember_filename __P((char *, char *, int, int));
+extern char *find_hashed_filename __P((char *));
diff --git a/hashlib.c b/hashlib.c
index b9cf95ba..0cf33752 100644
--- a/hashlib.c
+++ b/hashlib.c
@@ -6,7 +6,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 1, or (at your option) any later
+Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -16,9 +16,9 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
-#include "config.h"
+#include <config.h>
#include "bashansi.h"
@@ -68,7 +68,7 @@ make_hash_table (buckets)
for STRING. TABLE is a pointer to a HASH_TABLE. */
/* A possibly better distribution may be obtained by initializing i to
- ~0UL and using i = (i * 33) + *string++ as the step */
+ ~0UL and using i = (i * 31) + *string++ as the step */
#define ALL_ONES (~((unsigned long) 0))
#define BITS(h, n) ((unsigned long)(h) & ~(ALL_ONES << (n)))
diff --git a/hashlib.h b/hashlib.h
index d7432bd0..d8cc793e 100644
--- a/hashlib.h
+++ b/hashlib.h
@@ -16,11 +16,13 @@
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if !defined (_HASHLIB_H_)
#define _HASHLIB_H_
+#include "stdc.h"
+
typedef struct bucket_contents {
struct bucket_contents *next; /* Link to next hashed key in this bucket. */
char *key; /* What we look up. */
@@ -34,14 +36,13 @@ typedef struct hash_table {
int nentries; /* How many entries does this table have. */
} HASH_TABLE;
-extern int hash_string ();
-extern HASH_TABLE *make_hash_table ();
-extern BUCKET_CONTENTS *find_hash_item ();
-extern BUCKET_CONTENTS *remove_hash_item ();
-extern BUCKET_CONTENTS *add_hash_item ();
-extern BUCKET_CONTENTS *get_hash_bucket ();
-extern void flush_hash_table ();
-extern void dispose_hash_table ();
+extern int hash_string __P((char *, HASH_TABLE *));
+extern HASH_TABLE *make_hash_table __P((int));
+extern BUCKET_CONTENTS *find_hash_item __P((char *, HASH_TABLE *));
+extern BUCKET_CONTENTS *remove_hash_item __P((char *, HASH_TABLE *));
+extern BUCKET_CONTENTS *add_hash_item __P((char *, HASH_TABLE *));
+extern void flush_hash_table __P((HASH_TABLE *, VFunction *));
+extern void dispose_hash_table __P((HASH_TABLE *));
/* Redefine the function as a macro for speed. */
#define get_hash_bucket(bucket, table) \
@@ -52,6 +53,8 @@ extern void dispose_hash_table ();
/* Default number of buckets in the hash table. */
#define DEFAULT_HASH_BUCKETS 53 /* was 107 */
+#define HASH_ENTRIES(ht) (ht)->nentries
+
#if !defined (NULL)
# if defined (__STDC__)
# define NULL ((void *) 0)
diff --git a/ansi_stdlib.h b/include/ansi_stdlib.h
index 52339da5..a720cb9b 100644
--- a/ansi_stdlib.h
+++ b/include/ansi_stdlib.h
@@ -18,7 +18,7 @@
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if !defined (_STDLIB_H_)
#define _STDLIB_H_ 1
diff --git a/lib/posixheaders/filecntl.h b/include/filecntl.h
index cf5054de..2304d5d0 100644
--- a/lib/posixheaders/filecntl.h
+++ b/include/filecntl.h
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if !defined (_FILECNTL_H_)
#define _FILECNTL_H_
diff --git a/maxpath.h b/include/maxpath.h
index be0db2f8..00e43f84 100644
--- a/maxpath.h
+++ b/include/maxpath.h
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if !defined (_MAXPATH_H_)
#define _MAXPATH_H_
diff --git a/memalloc.h b/include/memalloc.h
index c68961f3..a1a27069 100644
--- a/memalloc.h
+++ b/include/memalloc.h
@@ -17,7 +17,7 @@
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if !defined (_MEMALLOC_H_)
# define _MEMALLOC_H_
diff --git a/posixdir.h b/include/posixdir.h
index 7480a93d..98ced75b 100644
--- a/posixdir.h
+++ b/include/posixdir.h
@@ -6,7 +6,7 @@
Bash is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 1, or (at your option)
+ the Free Software Foundation; either version 2, or (at your option)
any later version.
Bash is distributed in the hope that it will be useful, but WITHOUT
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with Bash; see the file COPYING. If not, write to the Free
- Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
/* This file should be included instead of <dirent.h> or <sys/dir.h>. */
diff --git a/include/posixjmp.h b/include/posixjmp.h
new file mode 100644
index 00000000..b52aa003
--- /dev/null
+++ b/include/posixjmp.h
@@ -0,0 +1,40 @@
+/* posixjmp.h -- wrapper for setjmp.h with changes for POSIX systems. */
+
+/* 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 2, or (at your option)
+ any later version.
+
+ Bash is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
+ License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Bash; see the file COPYING. If not, write to the Free
+ Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+
+#ifndef _POSIXJMP_H_
+#define _POSIXJMP_H_
+
+#include <setjmp.h>
+
+/* This *must* be included *after* config.h */
+
+#if defined (HAVE_POSIX_SIGSETJMP)
+# define procenv_t sigjmp_buf
+# if !defined (__OPENNT)
+# undef setjmp
+# define setjmp(x) sigsetjmp((x), 1)
+# undef longjmp
+# define longjmp(x, n) siglongjmp((x), (n))
+# endif /* !__OPENNT */
+#else
+# define procenv_t jmp_buf
+#endif
+
+#endif /* _POSIXJMP_H_ */
diff --git a/lib/posixheaders/posixstat.h b/include/posixstat.h
index bfce8c04..c93b5288 100644
--- a/lib/posixheaders/posixstat.h
+++ b/include/posixstat.h
@@ -7,7 +7,7 @@
Bash is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 1, or (at your option)
+ the Free Software Foundation; either version 2, or (at your option)
any later version.
Bash is distributed in the hope that it will be useful, but WITHOUT
@@ -17,7 +17,7 @@
You should have received a copy of the GNU General Public License
along with Bash; see the file COPYING. If not, write to the Free
- Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
/* This file should be included instead of <sys/stat.h>.
It relies on the local sys/stat.h to work though. */
diff --git a/include/posixtime.h b/include/posixtime.h
new file mode 100644
index 00000000..b4c4c68d
--- /dev/null
+++ b/include/posixtime.h
@@ -0,0 +1,49 @@
+/* posixtime.h -- wrapper for time.h, sys/times.h mess. */
+
+/* Copyright (C) 1999 Free Software Foundation, Inc.
+
+ This file is part of GNU Bash, the Bourne Again SHell.
+
+ Bash is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ Bash is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
+ License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Bash; see the file COPYING. If not, write to the Free
+ Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+
+#ifndef _POSIXTIME_H_
+#define _POSIXTIME_H_
+
+/* include this after config.h */
+/* Some systems require this, mostly for the definition of `struct timezone'.
+ For example, Dynix/ptx has that definition in <time.h> rather than
+ sys/time.h */
+#if defined (TIME_WITH_SYS_TIME)
+# include <sys/time.h>
+# include <time.h>
+#else
+# if defined (HAVE_SYS_TIME_H)
+# include <sys/time.h>
+# else
+# include <time.h>
+# endif
+#endif
+
+#if !defined (HAVE_SYSCONF) || !defined (_SC_CLK_TCK)
+# if !defined (CLK_TCK)
+# if defined (HZ)
+# define CLK_TCK HZ
+# else
+# define CLK_TCK 60 /* 60HZ */
+# endif
+# endif /* !CLK_TCK */
+#endif /* !HAVE_SYSCONF && !_SC_CLK_TCK */
+
+#endif /* _POSIXTIME_H_ */
diff --git a/posixwait.h b/include/posixwait.h
index 65d6c144..a11d156c 100644
--- a/posixwait.h
+++ b/include/posixwait.h
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if !defined (_POSIXWAIT_H_)
# define _POSIXWAIT_H_
diff --git a/include/shtty.h b/include/shtty.h
new file mode 100644
index 00000000..9efd3e50
--- /dev/null
+++ b/include/shtty.h
@@ -0,0 +1,101 @@
+/* Copyright (C) 1999 Free Software Foundation, Inc.
+
+/* This file is part of GNU Bash, the Bourne Again SHell.
+
+ Bash is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free
+ Software Foundation; either version 2, or (at your option) any later
+ version.
+
+ Bash is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with Bash; see the file COPYING. If not, write to the Free Software
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+
+/*
+ * shtty.h -- include the correct system-dependent files to manipulate the
+ * tty
+ */
+
+#ifndef __SH_TTY_H_
+#define __SH_TTY_H_
+
+#include "stdc.h"
+
+#if defined (_POSIX_VERSION) && defined (HAVE_TERMIOS_H) && defined (HAVE_TCGETATTR) && !defined (TERMIOS_MISSING)
+# define TERMIOS_TTY_DRIVER
+#else
+# if defined (HAVE_TERMIO_H)
+# define TERMIO_TTY_DRIVER
+# else
+# define NEW_TTY_DRIVER
+# endif
+#endif
+
+/*
+ * The _POSIX_SOURCE define is to avoid multiple symbol definitions
+ * between sys/ioctl.h and termios.h. Ditto for the test against SunOS4
+ * and the undefining of several symbols.
+ */
+
+#ifdef TERMIOS_TTY_DRIVER
+# if (defined (SunOS4) || defined (SunOS5)) && !defined (_POSIX_SOURCE)
+# define _POSIX_SOURCE
+# endif
+# if defined (SunOS4)
+# undef ECHO
+# undef NOFLSH
+# undef TOSTOP
+# endif /* SunOS4 */
+# include <termios.h>
+# define TTYSTRUCT struct termios
+#else
+# ifdef TERMIO_TTY_DRIVER
+# include <termio.h>
+# define TTYSTRUCT struct termio
+# else /* NEW_TTY_DRIVER */
+# include <sgtty.h>
+# define TTYSTRUCT struct sgttyb
+# endif
+#endif
+
+/* Functions imported from lib/sh/shtty.c */
+
+/* Get and set terminal attributes for the file descriptor passed as
+ an argument. */
+extern int ttgetattr __P((int, TTYSTRUCT *));
+extern int ttsetattr __P((int, TTYSTRUCT *));
+
+/* Save and restore the terminal's attributes from static storage. */
+extern void ttsave __P((void));
+extern void ttrestore __P((void));
+
+/* Return the attributes corresponding to the file descriptor (0 or 1)
+ passed as an argument. */
+extern TTYSTRUCT *ttattr __P((int));
+
+/* These functions only operate on the passed TTYSTRUCT; they don't
+ actually change anything with the kernel's current tty settings. */
+extern int tt_setonechar __P((TTYSTRUCT *));
+extern int tt_setnoecho __P((TTYSTRUCT *));
+extern int tt_seteightbit __P((TTYSTRUCT *));
+extern int tt_setnocanon __P((TTYSTRUCT *));
+extern int tt_setcbreak __P((TTYSTRUCT *));
+
+/* These functions are all generally mutually exclusive. If you call
+ more than one (bracketed with calls to ttsave and ttrestore, of
+ course), the right thing will happen, but more system calls will be
+ executed than absolutely necessary. You can do all of this yourself
+ with the other functions; these are only conveniences. */
+extern int ttonechar __P((void));
+extern int ttnoecho __P((void));
+extern int tteightbit __P((void));
+extern int ttnocanon __P((void));
+
+extern int ttcbreak __P((void));
+
+#endif
diff --git a/stdc.h b/include/stdc.h
index f1590c6d..c216a697 100644
--- a/stdc.h
+++ b/include/stdc.h
@@ -7,7 +7,7 @@
Bash is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 1, or (at your option)
+ the Free Software Foundation; either version 2, or (at your option)
any later version.
Bash is distributed in the hope that it will be useful, but WITHOUT
@@ -17,7 +17,7 @@
You should have received a copy of the GNU General Public License
along with Bash; see the file COPYING. If not, write to the Free
- Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if !defined (_STDC_H_)
#define _STDC_H_
@@ -28,11 +28,16 @@
and traditional C compilers with something like this:
extern char *func __P((char *, char *, int)); */
-#if defined (__STDC__)
-
-# if !defined (__P)
+#if !defined (__P)
+# if defined (__STDC__) || defined (__GNUC__) || defined (__cplusplus)
# define __P(protos) protos
+# else
+# define __P(protos) ()
# endif
+#endif
+
+#if defined (__STDC__)
+
# define __STRING(x) #x
# if !defined (__GNUC__)
@@ -41,9 +46,6 @@
#else /* !__STDC__ */
-# if !defined (__P)
-# define __P(protos) ()
-# endif
# define __STRING(x) "x"
#if defined (__GNUC__) /* gcc with -traditional */
diff --git a/include/systimes.h b/include/systimes.h
new file mode 100644
index 00000000..fe969f94
--- /dev/null
+++ b/include/systimes.h
@@ -0,0 +1,55 @@
+/* Copyright (C) 1991, 1992, 1996 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+/*
+ * POSIX Standard: 4.5.2 Process Times <sys/times.h>
+ */
+
+/*
+ * If we don't have a standard system clock_t type, this must be included
+ * after config.h
+ */
+
+#ifndef _BASH_SYSTIMES_H
+#define _BASH_SYSTIMES_H 1
+
+#if defined (HAVE_SYS_TIMES_H)
+# include <sys/times.h>
+#else /* !HAVE_SYS_TIMES_H */
+
+#include <stdc.h>
+
+/* Structure describing CPU time used by a process and its children. */
+struct tms
+ {
+ clock_t tms_utime; /* User CPU time. */
+ clock_t tms_stime; /* System CPU time. */
+
+ clock_t tms_cutime; /* User CPU time of dead children. */
+ clock_t tms_cstime; /* System CPU time of dead children. */
+ };
+
+/* Store the CPU time used by this process and all its
+ dead descendents in BUFFER.
+ Return the elapsed real time from an arbitrary point in the
+ past (the bash emulation uses the epoch), or (clock_t) -1 for
+ errors. All times are in CLK_TCKths of a second. */
+extern clock_t times __P((struct tms *buffer));
+
+#endif /* !HAVE_SYS_TIMES_H */
+#endif /* _BASH_SYSTIMES_H */
diff --git a/unionwait.h b/include/unionwait.h
index eb795aca..ae7c7dfc 100644
--- a/unionwait.h
+++ b/include/unionwait.h
@@ -17,7 +17,7 @@
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#ifndef _UNIONWAIT_H
#define _UNIONWAIT_H
diff --git a/input.c b/input.c
index 6ca49a80..c352d2ff 100644
--- a/input.c
+++ b/input.c
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#include "config.h"
@@ -47,7 +47,6 @@ extern int errno;
/* Functions to handle reading input on systems that don't restart read(2)
if a signal is received. */
-#if !defined (HAVE_RESTARTABLE_SYSCALLS)
static unsigned char localbuf[128];
static int local_index, local_bufused;
@@ -86,13 +85,16 @@ ungetc_with_restart (c, stream)
return EOF;
return (localbuf[--local_index] = c);
}
-#endif /* !HAVE_RESTARTABLE_SYSCALLS */
#if defined (BUFFERED_INPUT)
/* A facility similar to stdio, but input-only. */
-#define MAX_INPUT_BUFFER_SIZE 8192
+#if defined (USING_BASH_MALLOC)
+# define MAX_INPUT_BUFFER_SIZE 8176
+#else
+# define MAX_INPUT_BUFFER_SIZE 8192
+#endif
#if !defined (SEEK_CUR)
# define SEEK_CUR 1
@@ -378,11 +380,7 @@ static int
b_fill_buffer (bp)
BUFFERED_STREAM *bp;
{
- do
- {
- bp->b_used = read (bp->b_fd, bp->b_buffer, bp->b_size);
- }
- while (bp->b_used < 0 && errno == EINTR);
+ bp->b_used = zread (bp->b_fd, bp->b_buffer, bp->b_size);
if (bp->b_used <= 0)
{
bp->b_buffer[0] = 0;
diff --git a/input.h b/input.h
index e3910b68..989f6ea9 100644
--- a/input.h
+++ b/input.h
@@ -15,7 +15,7 @@
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if !defined (_INPUT_H_)
#define _INPUT_H_
@@ -97,6 +97,9 @@ extern char *decode_prompt_string __P((char *));
extern void gather_here_documents __P((void));
extern void execute_prompt_command __P((char *));
+extern int *save_token_state __P((void));
+extern void restore_token_state __P((int *));
+
/* Functions from input.c */
extern int getc_with_restart ();
extern int ungetc_with_restart ();
diff --git a/jobs.c b/jobs.c
index b9ca743c..0419fdde 100644
--- a/jobs.c
+++ b/jobs.c
@@ -9,7 +9,7 @@
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
- Software Foundation; either version 1, or (at your option) any later
+ Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -19,7 +19,7 @@
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#include "config.h"
@@ -51,33 +51,12 @@
#endif
/* Need to include this up here for *_TTY_DRIVER definitions. */
-#include "bashtty.h"
+#include "shtty.h"
/* Define this if your output is getting swallowed. It's a no-op on
machines with the termio or termios tty drivers. */
/* #define DRAIN_OUTPUT */
-/* The _POSIX_SOURCE define is to avoid multiple symbol definitions
- between sys/ioctl.h and termios.h. Ditto for the test against SunOS4
- and the undefining of several symbols. */
-#if defined (TERMIOS_TTY_DRIVER)
-# if (defined (SunOS4) || defined (SunOS5)) && !defined (_POSIX_SOURCE)
-# define _POSIX_SOURCE
-# endif
-# if defined (SunOS4)
-# undef ECHO
-# undef NOFLSH
-# undef TOSTOP
-# endif /* SunOS4 */
-# include <termios.h>
-#else /* !TERMIOS_TTY_DRIVER */
-# if defined (TERMIO_TTY_DRIVER)
-# include <termio.h>
-# else
-# include <sgtty.h>
-# endif
-#endif /* !TERMIOS_TTY_DRIVER */
-
/* For the TIOCGPGRP and TIOCSPGRP ioctl parameters on HP-UX */
#if defined (hpux) && !defined (TERMIOS_TTY_DRIVER)
# include <bsdtty.h>
@@ -98,7 +77,6 @@
#include "shell.h"
#include "jobs.h"
#include "flags.h"
-#include "error.h"
#include "builtins/builtext.h"
#include "builtins/common.h"
@@ -165,6 +143,8 @@ extern int loop_level, breaking;
extern Function *this_shell_builtin;
extern char *shell_name, *this_command_name;
extern sigset_t top_level_mask;
+extern procenv_t wait_intr_buf;
+extern WORD_LIST *subst_assign_varlist;
#if defined (ARRAY_VARS)
static int *pstatuses; /* list of pipeline statuses */
@@ -239,6 +219,7 @@ static void notify_of_job_status (), cleanup_dead_jobs (), discard_pipeline ();
static void add_process (), set_current_job (), reset_current ();
static void print_pipeline ();
static void pretty_print_job ();
+static void mark_all_jobs_as_dead ();
static void mark_dead_jobs_as_notified ();
#if defined (PGRP_PIPE)
static void pipe_read (), pipe_close ();
@@ -1455,7 +1436,9 @@ last_pid (job)
/* Wait for a particular child of the shell to finish executing.
This low-level function prints an error message if PID is not
- a child of this shell. It returns -1 if it fails, or 0 if not. */
+ a child of this shell. It returns -1 if it fails, or 0 if not
+ (whatever wait_for returns). If the child is not found in the
+ jobs table, it returns 127. */
int
wait_for_single_pid (pid)
pid_t pid;
@@ -1491,11 +1474,11 @@ wait_for_single_pid (pid)
void
wait_for_background_pids ()
{
- register int i, count;
+ register int i, count, r, waited_for;
sigset_t set, oset;
pid_t pid;
- for (;;)
+ for (waited_for = 0;;)
{
BLOCK_CHILD (set, oset);
@@ -1519,7 +1502,15 @@ wait_for_background_pids ()
pid = last_pid (i);
UNBLOCK_CHILD (oset);
QUIT;
- wait_for_single_pid (pid);
+ errno = 0; /* XXX */
+ r = wait_for_single_pid (pid);
+ if (r == -1)
+ {
+ if (errno == ECHILD)
+ mark_all_jobs_as_dead ();
+ }
+ else
+ waited_for++;
break;
}
}
@@ -1553,11 +1544,24 @@ static sighandler
wait_sigint_handler (sig)
int sig;
{
+ SigHandler *sigint_handler;
+
if (interrupt_immediately ||
(this_shell_builtin && this_shell_builtin == wait_builtin))
{
last_command_exit_value = EXECUTION_FAILURE;
restore_sigint_handler ();
+ /* If we got a SIGINT while in `wait', and SIGINT is trapped, do
+ what POSIX.2 says (see builtins/wait.def for more info). */
+ if (this_shell_builtin && this_shell_builtin == wait_builtin &&
+ signal_is_trapped (SIGINT) &&
+ ((sigint_handler = trap_to_sighandler (SIGINT)) == trap_handler))
+ {
+ interrupt_immediately = 0;
+ trap_handler (SIGINT); /* set pending_traps[SIGINT] */
+ longjmp (wait_intr_buf, 1);
+ }
+
ADDINTERRUPT;
QUIT;
}
@@ -1584,17 +1588,21 @@ process_exit_status (status)
}
static int
-job_exit_status (job)
- int job;
+raw_job_exit_status (job)
{
register PROCESS *p;
for (p = jobs[job]->pipe; p->next != jobs[job]->pipe; p = p->next)
;
- return (process_exit_status (p->status));
+ return (p->status);
+}
+
+static int
+job_exit_status (job)
+ int job;
+{
+ return (process_exit_status (raw_job_exit_status (job)));
}
-/* Wait for pid (one of our children) to terminate, then
- return the termination state. */
#define FIND_CHILD(pid, child) \
do \
{ \
@@ -1610,15 +1618,19 @@ job_exit_status (job)
} \
while (0)
+/* Wait for pid (one of our children) to terminate, then
+ return the termination state. Returns 127 if PID is not found in
+ the jobs table. Returns -1 if waitchld() returns -1, indicating
+ that there are no unwaited-for child processes. */
int
wait_for (pid)
pid_t pid;
{
- int job, termination_state;
+ int job, termination_state, r, s;
register PROCESS *child;
sigset_t set, oset;
-#if 0
register PROCESS *p;
+#if 0
int job_state, any_stopped;
#endif
@@ -1701,12 +1713,17 @@ wait_for (pid)
sigaction (SIGCHLD, &act, &oact);
# endif
waiting_for_job = 1;
- waitchld (pid, 1);
+ r = waitchld (pid, 1);
# if defined (MUST_UNBLOCK_CHLD)
sigaction (SIGCHLD, &oact, (struct sigaction *)NULL);
sigprocmask (SIG_SETMASK, &chldset, (sigset_t *)NULL);
# endif
waiting_for_job = 0;
+ if (r == -1 && errno == ECHILD && this_shell_builtin == wait_builtin)
+ {
+ termination_state = -1;
+ goto wait_for_return;
+ }
#endif /* WAITPID_BROKEN */
}
@@ -1722,7 +1739,6 @@ wait_for (pid)
/* The exit state of the command is either the termination state of the
child, or the termination state of the job. If a job, the status
of the last child in the pipeline is the significant one. */
-
if (job != NO_JOB)
termination_state = job_exit_status (job);
else
@@ -1760,14 +1776,40 @@ if (job == NO_JOB)
{
if (interactive_shell && subshell_environment == 0)
{
- if (WIFSIGNALED (child->status) || WIFSTOPPED (child->status))
+ /* This used to use `child->status'. That's wrong, however, for
+ pipelines. `child' is the first process in the pipeline. It's
+ likely that the process we want to check for abnormal termination
+ or stopping is the last process in the pipeline, especially if
+ it's long-lived and the first process is short-lived. Since we
+ know we have a job here, we can check all the processes in this
+ job's pipeline and see if one of them stopped or terminated due
+ to a signal. We might want to change this later to just check
+ the last process in the pipeline. If no process exits due to a
+ signal, S is left as the status of the last job in the pipeline. */
+ p = jobs[job]->pipe;
+ do
+ {
+ s = p->status;
+ if (WIFSIGNALED(s) || WIFSTOPPED(s))
+ break;
+ p = p->next;
+ }
+ while (p != jobs[job]->pipe);
+
+ if (WIFSIGNALED (s) || WIFSTOPPED (s))
{
set_tty_state ();
+#if 0
/* If the foreground job was suspended with ^Z (SIGTSTP), and
- the user has requested it, get a new window size. */
- if (check_window_size && WIFSTOPPED (child->status) &&
- (WSTOPSIG (child->status) == SIGTSTP) &&
+ the user has requested it, get a possibly new window size. */
+ if (check_window_size && WIFSTOPPED (s) &&
+ (WSTOPSIG (s) == SIGTSTP) &&
job == current_job)
+#else
+ /* If the current job was stopped or killed by a signal, and
+ the user has requested it, get a possibly new window size */
+ if (check_window_size && job == current_job)
+#endif
get_new_window_size (0);
}
else
@@ -1778,8 +1820,7 @@ if (job == NO_JOB)
by SIGINT, then print a newline to compensate for the kernel
printing the ^C without a trailing newline. */
if (job_control && IS_JOBCONTROL (job) && IS_FOREGROUND (job) &&
- WIFSIGNALED (child->status) &&
- WTERMSIG (child->status) == SIGINT)
+ WIFSIGNALED (s) && WTERMSIG (s) == SIGINT)
{
/* If SIGINT is not trapped and the shell is in a for, while,
or until loop, act as if the shell received SIGINT as
@@ -1806,6 +1847,8 @@ if (job == NO_JOB)
}
}
+wait_for_return:
+
UNBLOCK_CHILD (oset);
/* Restore the original SIGINT signal handler before we return. */
@@ -1814,7 +1857,9 @@ if (job == NO_JOB)
return (termination_state);
}
-/* Wait for the last process in the pipeline for JOB. */
+/* Wait for the last process in the pipeline for JOB. Returns whatever
+ wait_for returns: the last process's termination state or -1 if there
+ are no unwaited-for child processes or an error occurs. */
int
wait_for_job (job)
int job;
@@ -2216,20 +2261,25 @@ static sighandler
sigchld_handler (sig)
int sig;
{
- int n;
+ int n, oerrno;
+ oerrno = errno;
REINSTALL_SIGCHLD_HANDLER;
sigchld++;
n = 0;
if (waiting_for_job == 0)
n = waitchld (-1, 0);
+ errno = oerrno;
SIGRETURN (n);
}
/* waitchld() reaps dead or stopped children. It's called by wait_for and
- flush_child, and runs until there aren't any children terminating any more.
+ sigchld_handler, and runs until there aren't any children terminating any
+ more.
If BLOCK is 1, this is to be a blocking wait for a single child, although
- an arriving SIGCHLD could cause the wait to be non-blocking. */
+ an arriving SIGCHLD could cause the wait to be non-blocking. It returns
+ the number of children reaped, or -1 if there are no unwaited-for child
+ processes. */
static int
waitchld (wpid, block)
pid_t wpid;
@@ -2258,8 +2308,19 @@ waitchld (wpid, block)
if it was non-zero before we called waitpid. */
if (sigchld > 0 && (waitpid_flags & WNOHANG))
sigchld--;
+
+ /* If waitpid returns -1 with errno == ECHILD, there are no more
+ unwaited-for child processes of this shell. */
+ if (pid < 0 && errno == ECHILD)
+ {
+ if (children_exited == 0)
+ return -1;
+ else
+ break;
+ }
- /* If waitpid returns 0, there are running children. */
+ /* If waitpid returns 0, there are running children. If it returns -1,
+ the only other error POSIX says it can return is EINTR. */
if (pid <= 0)
continue; /* jumps right to the test */
@@ -2425,13 +2486,15 @@ waitchld (wpid, block)
/* If a job was running and became stopped, then set the current
job. Otherwise, don't change a thing. */
if (call_set_current)
- if (last_stopped_job != NO_JOB)
- set_current_job (last_stopped_job);
- else
- reset_current ();
+ {
+ if (last_stopped_job != NO_JOB)
+ set_current_job (last_stopped_job);
+ else
+ reset_current ();
+ }
/* Call a SIGCHLD trap handler for each child that exits, if one is set. */
- if (job_control && signal_is_trapped (SIGCHLD) &&
+ if (job_control && signal_is_trapped (SIGCHLD) && children_exited &&
trap_list[SIGCHLD] != (char *)IGNORE_SIG)
{
char *trap_command;
@@ -2452,6 +2515,7 @@ waitchld (wpid, block)
unwind_protect_int (interrupt_immediately);
unwind_protect_int (jobs_list_frozen);
unwind_protect_pointer (the_pipeline);
+ unwind_protect_pointer (subst_assign_varlist);
/* We have to add the commands this way because they will be run
in reverse order of adding. We don't want maybe_set_sigchld_trap ()
@@ -2459,6 +2523,7 @@ waitchld (wpid, block)
add_unwind_protect ((Function *)xfree, trap_command);
add_unwind_protect ((Function *)maybe_set_sigchld_trap, trap_command);
+ subst_assign_varlist = (WORD_LIST *)NULL;
the_pipeline = (PROCESS *)NULL;
restore_default_signal (SIGCHLD);
jobs_list_frozen = 1;
@@ -2503,7 +2568,11 @@ notify_of_job_status ()
{
if (jobs[job] && IS_NOTIFIED (job) == 0)
{
+#if 0
s = jobs[job]->pipe->status;
+#else
+ s = raw_job_exit_status (job);
+#endif
termsig = WTERMSIG (s);
/* POSIX.2 says we have to hang onto the statuses of at most the
@@ -2960,6 +3029,38 @@ nohup_all_jobs (running_only)
UNBLOCK_CHILD (oset);
}
+int
+count_all_jobs ()
+{
+ int i, n;
+ sigset_t set, oset;
+
+ BLOCK_CHILD (set, oset);
+ for (i = n = 0; i < job_slots; i++)
+ if (jobs[i] && DEADJOB(i) == 0)
+ n++;
+ UNBLOCK_CHILD (oset);
+ return n;
+}
+
+static void
+mark_all_jobs_as_dead ()
+{
+ register int i;
+ sigset_t set, oset;
+
+ if (job_slots)
+ {
+ BLOCK_CHILD (set, oset);
+
+ for (i = 0; i < job_slots; i++)
+ if (jobs[i])
+ jobs[i]->state = JDEAD;
+
+ UNBLOCK_CHILD (oset);
+ }
+}
+
/* Mark all dead jobs as notified, so delete_job () cleans them out
of the job table properly. POSIX.2 says we need to save the
status of the last CHILD_MAX jobs, so we count the number of dead
@@ -3093,7 +3194,7 @@ pipe_read (pp)
if (pp[0] >= 0)
{
while (read (pp[0], &ch, 1) == -1 && errno == EINTR)
- continue;
+ ;
}
}
diff --git a/jobs.h b/jobs.h
index 7fd813a1..e1e4e401 100644
--- a/jobs.h
+++ b/jobs.h
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if !defined (_JOBS_H_)
# define _JOBS_H_
@@ -95,7 +95,7 @@ extern pid_t fork (), getpid (), getpgrp ();
#endif /* !HAVE_UNISTD_H */
/* Stuff from the jobs.c file. */
-extern pid_t original_pgrp, shell_pgrp, pipeline_pgrp;
+extern pid_t original_pgrp, shell_pgrp, pipeline_pgrp;
extern pid_t last_made_pid, last_asynchronous_pid;
extern int current_job, previous_job;
extern int asynchronous_notification;
@@ -115,6 +115,8 @@ extern void nohup_job __P((int));
extern void delete_all_jobs __P((int));
extern void nohup_all_jobs __P((int));
+extern int count_all_jobs __P((void));
+
extern void terminate_current_pipeline __P((void));
extern void terminate_stopped_jobs __P((void));
extern void hangup_all_jobs __P((void));
@@ -134,6 +136,7 @@ extern void list_stopped_jobs __P((int));
extern void list_running_jobs __P((int));
extern pid_t make_child __P((char *, int));
+
extern int get_tty_state __P((void));
extern int set_tty_state __P((void));
diff --git a/lib/glob/Makefile.in b/lib/glob/Makefile.in
index 0a596d16..234e8e11 100644
--- a/lib/glob/Makefile.in
+++ b/lib/glob/Makefile.in
@@ -3,6 +3,22 @@
# Makefile for the GNU Glob Library. #
# #
####################################################################
+#
+# Copyright (C) 1996 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
srcdir = @srcdir@
VPATH = .:@srcdir@
@@ -31,7 +47,9 @@ LDFLAGS = @LDFLAGS@ @LOCAL_LDFLAGS@
DEFS = @DEFS@
LOCAL_DEFS = @LOCAL_DEFS@
-INCLUDES = -I. -I../.. -I$(topdir) -I$(topdir)/lib
+BASHINCDIR = ${topdir}/include
+
+INCLUDES = -I. -I../.. -I$(topdir) -I$(BASHINCDIR) -I$(topdir)/lib
CCFLAGS = $(DEFS) $(LOCAL_DEFS) $(CPPFLAGS) ${INCLUDES} $(LOCAL_CFLAGS) $(CFLAGS)
@@ -107,8 +125,8 @@ fnmatch.o: fnmatch.h
fnmatch.o: $(BUILD_DIR)/config.h
glob.o: $(BUILD_DIR)/config.h
-glob.o: $(topdir)/bashtypes.h $(topdir)/ansi_stdlib.h $(topdir)/bashansi.h
-glob.o: $(topdir)/posixstat.h $(topdir)/memalloc.h
+glob.o: $(topdir)/bashtypes.h $(BASHINCDIR)/ansi_stdlib.h $(topdir)/bashansi.h
+glob.o: $(BASHINCDIR)/posixstat.h $(BASHINCDIR)/memalloc.h
glob.o: fnmatch.h
# Rules for deficient makes, like SunOS and Solaris
diff --git a/lib/glob/collsyms.h b/lib/glob/collsyms.h
index 4f90083c..7ef09068 100644
--- a/lib/glob/collsyms.h
+++ b/lib/glob/collsyms.h
@@ -17,7 +17,7 @@
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#ifndef _COLLSYMS_H_
# define _COLLSYSMS_H_
diff --git a/lib/glob/fnmatch.c b/lib/glob/fnmatch.c
index b032a690..823ebf08 100644
--- a/lib/glob/fnmatch.c
+++ b/lib/glob/fnmatch.c
@@ -17,9 +17,11 @@
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#include <config.h>
+
+#include <stdio.h> /* for debugging */
#include "fnmatch.h"
#include "collsyms.h"
@@ -66,8 +68,18 @@ static char *patscan ();
#define STREQN(a, b, n) ((a)[0] == (b)[0] && strncmp(a, b, n) == 0)
#endif
+/* We don't use strcoll(3) for range comparisons in bracket expressions,
+ even if we have it, since it can have unwanted side effects in locales
+ other than POSIX or US. For instance, in the de locale, [A-Z] matches
+ all characters. So, for ranges we use ASCII collation, and for
+ collating symbol equivalence we use strcoll(). The casts to int are
+ to handle tests that use unsigned chars. */
+
+#define rangecmp(c1, c2) ((int)(c1) - (int)(c2))
+
#if defined (HAVE_STRCOLL)
-static int rangecmp (c1, c2)
+/* Helper function for collating symbol equivalence. */
+static int rangecmp2 (c1, c2)
int c1, c2;
{
static char s1[2] = { ' ', '\0' };
@@ -89,14 +101,14 @@ static int rangecmp (c1, c2)
return (c1 - c2);
}
#else /* !HAVE_STRCOLL */
-# define rangecmp(c1, c2) ((c1) - (c2))
+# define rangecmp2(c1, c2) ((int)(c1) - (int)(c2))
#endif /* !HAVE_STRCOLL */
#if defined (HAVE_STRCOLL)
static int collequiv (c1, c2)
int c1, c2;
{
- return (rangecmp (c1, c2) == 0);
+ return (rangecmp2 (c1, c2) == 0);
}
#else
# define collequiv(c1, c2) ((c1) == (c2))
@@ -253,7 +265,7 @@ gmatch (string, se, pattern, pe, flags)
that's OK, since we can match 0 or more occurrences.
We need to skip the glob pattern and see if we
match the rest of the string. */
- newn = patscan (p, pe, 0);
+ newn = patscan (p + 1, pe, 0);
p = newn;
}
#endif
@@ -587,6 +599,8 @@ patscan (string, end, delim)
pnest = bnest = 0;
for (s = string; c = *s; s++)
{
+ if (s >= end)
+ return (s);
switch (c)
{
case '\0':
@@ -603,10 +617,15 @@ patscan (string, end, delim)
pnest++;
break;
case ')':
+#if 0
if (bnest == 0)
pnest--;
if (pnest <= 0)
return ++s;
+#else
+ if (bnest == 0 && pnest-- <= 0)
+ return ++s;
+#endif
break;
case '|':
if (bnest == 0 && pnest == 0 && delim == '|')
@@ -614,6 +633,7 @@ patscan (string, end, delim)
break;
}
}
+
return (char *)0;
}
@@ -658,16 +678,22 @@ extmatch (xc, s, se, p, pe, flags)
char *srest; /* pointer to rest of string */
int m1, m2;
+#if 0
+fprintf(stderr, "extmatch: xc = %c\n", xc);
+fprintf(stderr, "extmatch: s = %s; se = %s\n", s, se);
+fprintf(stderr, "extmatch: p = %s; pe = %s\n", p, pe);
+#endif
+
+ prest = patscan (p + (*p == '('), pe, 0); /* ) */
+ if (prest == 0)
+ /* If PREST is 0, we failed to scan a valid pattern. In this
+ case, we just want to compare the two as strings. */
+ return (strcompare (p - 1, pe, s, se));
+
switch (xc)
{
case '+': /* match one or more occurrences */
case '*': /* match zero or more occurrences */
- prest = patscan (p, pe, 0);
- if (prest == 0)
- /* If PREST is 0, we failed to scan a valid pattern. In this
- case, we just want to compare the two as strings. */
- return (strcompare (p - 1, pe, s, se));
-
/* If we can get away with no matches, don't even bother. Just
call gmatch on the rest of the pattern and return success if
it succeeds. */
@@ -701,10 +727,6 @@ extmatch (xc, s, se, p, pe, flags)
case '?': /* match zero or one of the patterns */
case '@': /* match exactly one of the patterns */
- prest = patscan (p, pe, 0);
- if (prest == 0)
- return (strcompare (p - 1, pe, s, se));
-
/* If we can get away with no matches, don't even bother. Just
call gmatch on the rest of the pattern and return success if
it succeeds. */
@@ -730,10 +752,6 @@ extmatch (xc, s, se, p, pe, flags)
return (FNM_NOMATCH);
case '!': /* match anything *except* one of the patterns */
- prest = patscan (p, pe, 0);
- if (prest == 0)
- return (strcompare (p - 1, pe, s, se));
-
for (srest = s; srest <= se; srest++)
{
m1 = 0;
diff --git a/lib/glob/fnmatch.h b/lib/glob/fnmatch.h
index 5e2cfb1e..c6908918 100644
--- a/lib/glob/fnmatch.h
+++ b/lib/glob/fnmatch.h
@@ -13,8 +13,8 @@ Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
-not, write to the Free Software Foundation, Inc., 675 Mass Ave,
-Cambridge, MA 02139, USA. */
+not, write to the Free Software Foundation, Inc.,
+59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#ifndef _FNMATCH_H
#define _FNMATCH_H 1
diff --git a/lib/glob/glob.c b/lib/glob/glob.c
index be4e9dc8..c2722745 100644
--- a/lib/glob/glob.c
+++ b/lib/glob/glob.c
@@ -3,7 +3,7 @@
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 1, or (at your option)
+ the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
@@ -13,7 +13,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
/* To whomever it may concern: I have never seen the code which most
Unix programs use to perform this function. I wrote this from scratch
@@ -67,7 +67,7 @@
# endif
#endif /* !HAVE_DIRENT_H */
-#if defined (_POSIX_SOURCE)
+#if defined (_POSIX_SOURCE) && !defined (STRUCT_DIRENT_HAS_D_INO)
/* Posix does not require that the d_ino field be present, and some
systems do not provide it. */
# define REAL_DIR_ENTRY(dp) 1
diff --git a/lib/glob/glob.h b/lib/glob/glob.h
index ac83f1ef..41ad726f 100644
--- a/lib/glob/glob.h
+++ b/lib/glob/glob.h
@@ -3,7 +3,7 @@
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 1, or (at your option)
+ the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
@@ -13,7 +13,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#ifndef _GLOB_H_
#define _GLOB_H_
diff --git a/lib/malloc/Makefile.in b/lib/malloc/Makefile.in
index 0778b338..9e8f022d 100644
--- a/lib/malloc/Makefile.in
+++ b/lib/malloc/Makefile.in
@@ -1,5 +1,21 @@
# Skeleton Makefile for the GNU malloc code
#
+#
+# Copyright (C) 1996 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
srcdir = @srcdir@
VPATH = .:@srcdir@
@@ -30,7 +46,9 @@ LDFLAGS = @LDFLAGS@
DEFS = @DEFS@
LOCAL_DEFS = @LOCAL_DEFS@
-INCLUDES = -I. -I../.. -I$(topdir) -I$(topdir)/lib
+BASHINCDIR = ${topdir}/include
+
+INCLUDES = -I. -I../.. -I$(topdir) -I$(BASHINCDIR) -I$(topdir)/lib
CCFLAGS = ${PROFILE_FLAGS} ${INCLUDES} $(DEFS) $(LOCAL_DEFS) $(LOCAL_CFLAGS) \
$(CFLAGS) $(MALLOC_CFLAGS) $(CPPFLAGS)
@@ -110,7 +128,7 @@ alloca.o: $(BUILD_DIR)/config.h
malloc.o: $(BUILD_DIR)/config.h $(topdir)/bashtypes.h getpagesize.h
nmalloc.o: $(BUILD_DIR)/config.h $(topdir)/bashtypes.h getpagesize.h
nmalloc2.o: $(BUILD_DIR)/config.h $(topdir)/bashtypes.h getpagesize.h
-xmalloc.o: $(BUILD_DIR)/config.h $(topdir)/ansi_stdlib.h
+xmalloc.o: $(BUILD_DIR)/config.h $(BASHINCDIR)/ansi_stdlib.h
gmalloc.o: $(BUILD_DIR)/config.h
# Rules for deficient makes, like SunOS and Solaris
diff --git a/lib/malloc/getpagesize.h b/lib/malloc/getpagesize.h
index 6085a5c5..0bc5ef91 100644
--- a/lib/malloc/getpagesize.h
+++ b/lib/malloc/getpagesize.h
@@ -13,7 +13,7 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
-Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if defined (HAVE_UNISTD_H)
# ifdef _MINIX
diff --git a/lib/malloc/gmalloc.c b/lib/malloc/gmalloc.c
index dd24146d..8441b0f9 100644
--- a/lib/malloc/gmalloc.c
+++ b/lib/malloc/gmalloc.c
@@ -16,8 +16,8 @@ Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; see the file COPYING.LIB. If
-ot, write to the Free Software Foundation, Inc., 59 Temple Place -
-Suite 330, Boston, MA 02111-1307, USA.
+ot, write to the Free Software Foundation, Inc.,
+59 Temple Place, Suite 330, Boston, MA 02111 USA.
The author may be reached (Email) at the address mike@ai.mit.edu,
or (US mail) as Mike Haertel c/o Free Software Foundation. */
@@ -141,7 +141,7 @@ struct mstats
struct hdr
{
size_t size; /* Exact size requested by user. */
- u_int32_t magic; /* Magic number to check header integrity. */
+ u_bits32_t magic; /* Magic number to check header integrity. */
};
#endif /* RCHECK */
diff --git a/lib/malloc/malloc.c b/lib/malloc/malloc.c
index e96dd27d..daa13716 100644
--- a/lib/malloc/malloc.c
+++ b/lib/malloc/malloc.c
@@ -4,7 +4,7 @@
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 1, or (at your option)
+ the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
@@ -14,7 +14,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
In other words, you are welcome to use, share and improve this program.
You are forbidden to forbid anyone else to use, share and improve
@@ -107,6 +107,15 @@ what you give them. Help stamp out software-hoarding! */
# endif /* HAVE_BCOPY */
#endif /* !__GNUC__ */
+/* Generic pointer type. */
+#ifndef PTR_T
+# if defined (__STDC__)
+# define PTR_T void *
+# else
+# define PTR_T char *
+# endif
+#endif
+
#if !defined (NULL)
# define NULL 0
#endif
@@ -139,9 +148,10 @@ extern char *sbrk ();
* (whether by morecore() or for alignment); TSBRK is the total number of
* bytes requested from the kernel with sbrk(). BYTESUSED is the total
* number of bytes consumed by blocks currently in use; BYTESFREE is the
- * total number of bytes currently on all of the free lists. NBSPLIT is
+ * total number of bytes currently on all of the free lists. TBSPLIT is
* the number of times a larger block was split to satisfy a smaller request.
- * NBCOALESCE is the number of times two adjacent smaller blocks off the free
+ * NSPLIT[i] is the number of times a block of size I was split.
+ * TBCOALESCE is the number of times two adjacent smaller blocks off the free
* list were combined to satisfy a larger request.
*/
struct _malstats {
@@ -154,11 +164,12 @@ struct _malstats {
int nrcopy;
int nrecurse;
int nsbrk;
- int32_t tsbrk;
- int32_t bytesused;
- int32_t bytesfree;
- int nbsplit;
- int nbcoalesce;
+ bits32_t tsbrk;
+ bits32_t bytesused;
+ bits32_t bytesfree;
+ int tbsplit;
+ int nsplit[NBUCKETS];
+ int tbcoalesce;
};
static struct _malstats _mstats;
@@ -167,13 +178,16 @@ static struct _malstats _mstats;
NFREE is the number of free blocks for this allocation size. NUSED
is the number of blocks in use. NMAL is the number of requests for
blocks of size BLOCKSIZE. NMORECORE is the number of times we had
- to call MORECORE to repopulate the free list for this bucket. */
+ to call MORECORE to repopulate the free list for this bucket. NSPLIT
+ is the number of times a block of this size was split to satisfy a
+ smaller request. */
struct bucket_stats {
- u_int32_t blocksize;
+ u_bits32_t blocksize;
int nfree;
int nused;
int nmal;
int nmorecore;
+ int nsplit;
};
#endif /* MALLOC_STATS */
@@ -189,8 +203,8 @@ union mhead {
char mi_alloc; /* ISALLOC or ISFREE */ /* 1 */
char mi_index; /* index in nextf[] */ /* 1 */
/* Remainder are valid only when block is allocated */
- u_int32_t mi_nbytes; /* # of bytes allocated */ /* 4 */
- unsigned short mi_magic2;/* should be == MAGIC2 */ /* 2 */
+ u_bits32_t mi_nbytes; /* # of bytes allocated */ /* 4 */
+ u_bits16_t mi_magic2;/* should be == MAGIC2 */ /* 2 */
} minfo;
};
#define mh_alloc minfo.mi_alloc
@@ -243,8 +257,8 @@ botch (s)
/* Minimum and maximum bucket indices for block splitting (and to bound
the search for a block to split). */
#define SPLIT_MIN 3
-#define SPLIT_MID 9
-#define SPLIT_MAX 12
+#define SPLIT_MID 11 /* XXX - was 9 */
+#define SPLIT_MAX 14 /* XXX - was 12 */
/* Minimum and maximum bucket indices for block coalescing. */
#define COMBINE_MIN 6
@@ -262,6 +276,7 @@ static char busy[NBUCKETS];
static int pagesz; /* system page size. */
static int pagebucket; /* bucket for requests a page in size */
+static int maxbuck; /* highest bucket receiving allocation request. */
#if 0
/* Coalesce two adjacent free blocks off the free list for size NU - 1,
@@ -305,7 +320,7 @@ bcoalesce (nu)
return; /* not adjacent */
#ifdef MALLOC_STATS
- _mstats.nbcoalesce++;
+ _mstats.tbcoalesce++;
#endif
/* Since they are adjacent, remove them from the free list */
@@ -328,12 +343,14 @@ bsplit (nu)
register int nu;
{
register union mhead *mp;
- int nbuck, nblks;
+ int nbuck, nblks, split_max;
unsigned long siz;
+ split_max = (maxbuck > SPLIT_MAX) ? maxbuck : SPLIT_MAX;
+
if (nu >= SPLIT_MID)
{
- for (nbuck = SPLIT_MAX; nbuck > nu; nbuck--)
+ for (nbuck = split_max; nbuck > nu; nbuck--)
{
if (busy[nbuck] || nextf[nbuck] == 0)
continue;
@@ -342,7 +359,7 @@ bsplit (nu)
}
else
{
- for (nbuck = nu + 1; nbuck <= SPLIT_MAX; nbuck++)
+ for (nbuck = nu + 1; nbuck <= split_max; nbuck++)
{
if (busy[nbuck] || nextf[nbuck] == 0)
continue;
@@ -350,14 +367,15 @@ bsplit (nu)
}
}
- if (nbuck > SPLIT_MAX || nbuck <= nu)
+ if (nbuck > split_max || nbuck <= nu)
return;
/* XXX might want to split only if nextf[nbuck] has >= 2 blocks free
and nbuck is below some threshold. */
#ifdef MALLOC_STATS
- _mstats.nbsplit++;
+ _mstats.tbsplit++;
+ _mstats.nsplit[nbuck]++;
#endif
/* Figure out how many blocks we'll get. */
@@ -406,7 +424,7 @@ morecore (nu) /* ask system for more memory */
siz = 1 << (nu + 3); /* size of desired block for nextf[nu] */
if (siz < 0)
- return; /* oops */
+ goto morecore_done; /* oops */
#ifdef MALLOC_STATS
_mstats.nmorecore[nu]++;
@@ -414,7 +432,11 @@ morecore (nu) /* ask system for more memory */
/* Try to split a larger block here, if we're within the range of sizes
to split. */
+#if 0
if (nu >= SPLIT_MIN && nu < SPLIT_MAX)
+#else
+ if (nu >= SPLIT_MIN)
+#endif
{
bsplit (nu);
if (nextf[nu] != 0)
@@ -463,7 +485,7 @@ morecore (nu) /* ask system for more memory */
/* Totally out of memory. */
if ((long)mp == -1)
- return;
+ goto morecore_done;
/* shouldn't happen, but just in case -- require 8-byte alignment */
if ((long)mp & 7)
@@ -515,10 +537,10 @@ zmemset (s, c, n)
static void
malloc_debug_dummy ()
{
- ;
+ write (1, "malloc_debug_dummy\n", 19);
}
-char *
+PTR_T
malloc (n) /* get a block */
size_t n;
{
@@ -578,7 +600,7 @@ malloc (n) /* get a block */
}
else
{
- register u_int32_t amt;
+ register u_bits32_t amt;
nunits = pagebucket;
amt = pagesz;
@@ -599,6 +621,9 @@ malloc (n) /* get a block */
while (busy[nunits]) nunits++;
busy[nunits] = 1;
+ if (nunits > maxbuck)
+ maxbuck = nunits;
+
/* If there are no blocks of the appropriate size, go get some */
if (nextf[nunits] == 0)
morecore (nunits);
@@ -636,18 +661,18 @@ malloc (n) /* get a block */
_mstats.tmalloc[nunits]++;
_mstats.nmal++;
#endif /* MALLOC_STATS */
- return (char *) (p + 1);
+ return (char *) (p + 1); /* XXX - should be cast to PTR_T? */
}
void
free (mem)
- char *mem;
+ PTR_T mem;
{
register union mhead *p;
register char *ap;
register int nunits;
- if ((ap = mem) == 0)
+ if ((ap = (char *)mem) == 0)
return;
p = (union mhead *) ap - 1;
@@ -680,6 +705,11 @@ free (mem)
ASSERT (nunits < NBUCKETS);
p->mh_alloc = ISFREE;
+#if 0
+ if (busy[nunits] == 1)
+ botch ("calling free %d while in malloc for %d", nunits, nunits);
+#endif
+
/* Protect against signal handlers calling malloc. */
busy[nunits] = 1;
/* Put this block on the free list. */
@@ -693,13 +723,13 @@ free (mem)
#endif /* MALLOC_STATS */
}
-char *
+PTR_T
realloc (mem, n)
- char *mem;
+ PTR_T mem;
register size_t n;
{
register union mhead *p;
- register u_int32_t tocopy;
+ register u_bits32_t tocopy;
register unsigned int nbytes;
register int nunits;
register char *m;
@@ -720,7 +750,7 @@ realloc (mem, n)
ASSERT (p->mh_alloc == ISALLOC);
ASSERT (p->mh_magic2 == MAGIC2);
- m = mem + (tocopy = p->mh_nbytes);
+ m = (char *)mem + (tocopy = p->mh_nbytes);
ASSERT (*m++ == MAGIC1); ASSERT (*m++ == MAGIC1);
ASSERT (*m++ == MAGIC1); ASSERT (*m == MAGIC1);
@@ -730,10 +760,10 @@ realloc (mem, n)
/* If ok, use the same block, just marking its size as changed. */
if (nbytes > (4 << nunits) && nbytes <= (8 << nunits))
{
- m = mem + tocopy;
+ m = (char *)mem + tocopy;
*m++ = 0; *m++ = 0; *m++ = 0; *m++ = 0;
p->mh_nbytes = n;
- m = mem + n;
+ m = (char *)mem + n;
*m++ = MAGIC1; *m++ = MAGIC1; *m++ = MAGIC1; *m++ = MAGIC1;
return mem;
}
@@ -752,7 +782,7 @@ realloc (mem, n)
return m;
}
-char *
+PTR_T
memalign (alignment, size)
unsigned int alignment;
size_t size;
@@ -782,11 +812,7 @@ memalign (alignment, size)
#if !defined (HPUX)
/* This runs into trouble with getpagesize on HPUX, and Multimax machines.
Patching out seems cleaner than the ugly fix needed. */
-#if defined (__STDC__)
-void *
-#else
-char *
-#endif
+PTR_T
valloc (size)
size_t size;
{
@@ -795,7 +821,7 @@ valloc (size)
#endif /* !HPUX */
#ifndef NO_CALLOC
-char *
+PTR_T
calloc (n, s)
size_t n, s;
{
@@ -811,7 +837,7 @@ calloc (n, s)
void
cfree (p)
- char *p;
+ PTR_T p;
{
free (p);
}
@@ -831,7 +857,7 @@ malloc_bucket_stats (size)
if (size < 0 || size >= NBUCKETS)
{
v.blocksize = 0;
- v.nused = v.nmal = 0;
+ v.nused = v.nmal = v.nmorecore = v.nsplit = 0;
return v;
}
@@ -839,6 +865,7 @@ malloc_bucket_stats (size)
v.nused = _mstats.nmalloc[size];
v.nmal = _mstats.tmalloc[size];
v.nmorecore = _mstats.nmorecore[size];
+ v.nsplit = _mstats.nsplit[size];
for (p = nextf[size]; p; p = CHAIN (p))
v.nfree++;
@@ -868,29 +895,60 @@ malloc_stats ()
return (result);
}
-void
-print_malloc_stats (s)
+static void
+_print_malloc_stats (s, fp)
char *s;
+ FILE *fp;
{
register int i;
int totused, totfree;
struct bucket_stats v;
- fprintf (stderr, "Memory allocation statistics: %s\n\tsize\tfree\tin use\ttotal\tmorecore\n", s ? s : "");
+ fprintf (fp, "Memory allocation statistics: %s\n\tsize\tfree\tin use\ttotal\tmorecore\tsplit\n", s ? s : "");
for (i = totused = totfree = 0; i < NBUCKETS; i++)
{
v = malloc_bucket_stats (i);
- fprintf (stderr, "%12lu\t%4d\t%6d\t%5d\t%8d\n", v.blocksize, v.nfree, v.nused, v.nmal, v.nmorecore);
+ fprintf (fp, "%12lu\t%4d\t%6d\t%5d\t%8d\t%5d\n", v.blocksize, v.nfree, v.nused, v.nmal, v.nmorecore, v.nsplit);
totfree += v.nfree * v.blocksize;
totused += v.nused * v.blocksize;
}
- fprintf (stderr, "\nTotal bytes in use: %d, total bytes free: %d\n",
+ fprintf (fp, "\nTotal bytes in use: %d, total bytes free: %d\n",
totused, totfree);
- fprintf (stderr, "Total mallocs: %d, total frees: %d, total reallocs: %d (%d copies)\n",
+ fprintf (fp, "Total mallocs: %d, total frees: %d, total reallocs: %d (%d copies)\n",
_mstats.nmal, _mstats.nfre, _mstats.nrealloc, _mstats.nrcopy);
- fprintf (stderr, "Total sbrks: %d, total bytes via sbrk: %d\n",
+ fprintf (fp, "Total sbrks: %d, total bytes via sbrk: %d\n",
_mstats.nsbrk, _mstats.tsbrk);
- fprintf (stderr, "Total blocks split: %d, total block coalesces: %d\n",
- _mstats.nbsplit, _mstats.nbcoalesce);
+ fprintf (fp, "Total blocks split: %d, total block coalesces: %d\n",
+ _mstats.tbsplit, _mstats.tbcoalesce);
+}
+
+void
+print_malloc_stats (s)
+{
+ _print_malloc_stats (s, stderr);
+}
+
+#define TRACEROOT "/var/tmp/maltrace/trace."
+extern char *inttostr ();
+
+void
+trace_malloc_stats (s)
+{
+ char ibuf[32], *ip;
+ char fname[64];
+ int p;
+ FILE *fp;
+
+ p = (int)getpid();
+ ip = inttostr(p, ibuf, sizeof(ibuf));
+ strcpy (fname, TRACEROOT);
+ strcat (fname, ip);
+ fp = fopen(fname, "w");
+ if (fp)
+ {
+ _print_malloc_stats (s, fp);
+ fflush(fp);
+ fclose(fp);
+ }
}
#endif /* MALLOC_STATS */
diff --git a/lib/malloc/ogmalloc.c b/lib/malloc/ogmalloc.c
index 8690b126..6b3600af 100644
--- a/lib/malloc/ogmalloc.c
+++ b/lib/malloc/ogmalloc.c
@@ -20,8 +20,8 @@ Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; see the file COPYING.LIB. If
-not, write to the Free Software Foundation, Inc., 675 Mass Ave,
-Cambridge, MA 02139, USA.
+not, write to the Free Software Foundation, Inc.,
+59 Temple Place, Suite 330, Boston, MA 02111 USA.
The author may be reached (Email) at the address mike@ai.mit.edu,
or (US mail) as Mike Haertel c/o Free Software Foundation. */
@@ -328,8 +328,8 @@ Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; see the file COPYING.LIB. If
-not, write to the Free Software Foundation, Inc., 675 Mass Ave,
-Cambridge, MA 02139, USA.
+not, write to the Free Software Foundation, Inc.,
+59 Temple Place, Suite 330, Boston, MA 02111 USA.
The author may be reached (Email) at the address mike@ai.mit.edu,
or (US mail) as Mike Haertel c/o Free Software Foundation. */
@@ -854,8 +854,8 @@ Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; see the file COPYING.LIB. If
-not, write to the Free Software Foundation, Inc., 675 Mass Ave,
-Cambridge, MA 02139, USA.
+not, write to the Free Software Foundation, Inc.,
+59 Temple Place, Suite 330, Boston, MA 02111 USA.
The author may be reached (Email) at the address mike@ai.mit.edu,
or (US mail) as Mike Haertel c/o Free Software Foundation. */
@@ -1163,8 +1163,8 @@ Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; see the file COPYING.LIB. If
-not, write to the Free Software Foundation, Inc., 675 Mass Ave,
-Cambridge, MA 02139, USA.
+not, write to the Free Software Foundation, Inc.,
+59 Temple Place, Suite 330, Boston, MA 02111 USA.
The author may be reached (Email) at the address mike@ai.mit.edu,
or (US mail) as Mike Haertel c/o Free Software Foundation. */
@@ -1404,8 +1404,8 @@ Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; see the file COPYING.LIB. If
-not, write to the Free Software Foundation, Inc., 675 Mass Ave,
-Cambridge, MA 02139, USA.
+not, write to the Free Software Foundation, Inc.,
+59 Temple Place, Suite 330, Boston, MA 02111 USA.
The author may be reached (Email) at the address mike@ai.mit.edu,
or (US mail) as Mike Haertel c/o Free Software Foundation. */
@@ -1444,7 +1444,7 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with the GNU C Library; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+the Free Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#ifndef _MALLOC_INTERNAL
#define _MALLOC_INTERNAL
@@ -1493,8 +1493,8 @@ Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; see the file COPYING.LIB. If
-not, write to the Free Software Foundation, Inc., 675 Mass Ave,
-Cambridge, MA 02139, USA. */
+not, write to the Free Software Foundation, Inc.,
+59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#ifndef _MALLOC_INTERNAL
#define _MALLOC_INTERNAL
diff --git a/lib/malloc/omalloc.c b/lib/malloc/omalloc.c
index a8b232a1..413faeb4 100644
--- a/lib/malloc/omalloc.c
+++ b/lib/malloc/omalloc.c
@@ -4,7 +4,7 @@
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 1, or (at your option)
+ the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
@@ -14,7 +14,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
In other words, you are welcome to use, share and improve this program.
You are forbidden to forbid anyone else to use, share and improve
diff --git a/lib/malloc/xmalloc.c b/lib/malloc/xmalloc.c
index 41606511..a495d77f 100644
--- a/lib/malloc/xmalloc.c
+++ b/lib/malloc/xmalloc.c
@@ -7,7 +7,7 @@
Readline is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
- Free Software Foundation; either version 1, or (at your option) any
+ Free Software Foundation; either version 2, or (at your option) any
later version.
Readline is distributed in the hope that it will be useful, but
@@ -17,7 +17,7 @@
You should have received a copy of the GNU General Public License
along with Readline; see the file COPYING. If not, write to the Free
- Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if defined (HAVE_CONFIG_H)
#include <config.h>
diff --git a/lib/posixheaders/ansi_stdlib.h b/lib/posixheaders/ansi_stdlib.h
deleted file mode 100644
index 52339da5..00000000
--- a/lib/posixheaders/ansi_stdlib.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/* ansi_stdlib.h -- An ANSI Standard stdlib.h. */
-/* A minimal stdlib.h containing extern declarations for those functions
- that bash uses. */
-
-/* Copyright (C) 1993 Free Software Foundation, Inc.
-
- This file is part of GNU Bash, the Bourne Again SHell.
-
- Bash is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free
- Software Foundation; either version 2, or (at your option) any later
- version.
-
- Bash is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- for more details.
-
- You should have received a copy of the GNU General Public License along
- with Bash; see the file COPYING. If not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#if !defined (_STDLIB_H_)
-#define _STDLIB_H_ 1
-
-/* String conversion functions. */
-extern int atoi ();
-extern long int atol ();
-
-/* Memory allocation functions. */
-extern char *malloc ();
-extern char *realloc ();
-extern void free ();
-
-/* Other miscellaneous functions. */
-extern void abort ();
-extern void exit ();
-extern char *getenv ();
-extern void qsort ();
-
-#endif /* _STDLIB_H */
diff --git a/lib/posixheaders/memalloc.h b/lib/posixheaders/memalloc.h
deleted file mode 100644
index c68961f3..00000000
--- a/lib/posixheaders/memalloc.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/* memalloc.h -- consolidate code for including alloca.h or malloc.h and
- defining alloca. */
-
-/* Copyright (C) 1993 Free Software Foundation, Inc.
-
- This file is part of GNU Bash, the Bourne Again SHell.
-
- Bash is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free
- Software Foundation; either version 2, or (at your option) any later
- version.
-
- Bash is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- for more details.
-
- You should have received a copy of the GNU General Public License along
- with Bash; see the file COPYING. If not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#if !defined (_MEMALLOC_H_)
-# define _MEMALLOC_H_
-
-#if defined (sparc) && defined (sun) && !defined (HAVE_ALLOCA_H)
-# define HAVE_ALLOCA_H
-#endif
-
-#if defined (__GNUC__) && !defined (HAVE_ALLOCA)
-# define HAVE_ALLOCA
-#endif
-
-#if defined (HAVE_ALLOCA_H) && !defined (HAVE_ALLOCA)
-# define HAVE_ALLOCA
-#endif /* HAVE_ALLOCA_H && !HAVE_ALLOCA */
-
-#if defined (__GNUC__) && !defined (C_ALLOCA)
-# undef alloca
-# define alloca __builtin_alloca
-#else /* !__GNUC__ || C_ALLOCA */
-# if defined (HAVE_ALLOCA_H) && !defined (C_ALLOCA)
-# if defined (IBMESA)
-# include <malloc.h>
-# else /* !IBMESA */
-# include <alloca.h>
-# endif /* !IBMESA */
-# else /* !HAVE_ALLOCA_H || C_ALLOCA */
-# if defined (__hpux) && defined (__STDC__) && !defined (alloca)
-extern void *alloca ();
-# else
-# if !defined (alloca)
-extern char *alloca ();
-# endif /* !alloca */
-# endif /* !__hpux || !__STDC__ && !alloca */
-# endif /* !HAVE_ALLOCA_H || C_ALLOCA */
-#endif /* !__GNUC__ || C_ALLOCA */
-
-#endif /* _MEMALLOC_H_ */
diff --git a/lib/posixheaders/posixdir.h b/lib/posixheaders/posixdir.h
deleted file mode 100644
index 7480a93d..00000000
--- a/lib/posixheaders/posixdir.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/* posixdir.h -- Posix directory reading includes and defines. */
-
-/* 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 1, or (at your option)
- any later version.
-
- Bash is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
- License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Bash; see the file COPYING. If not, write to the Free
- Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/* This file should be included instead of <dirent.h> or <sys/dir.h>. */
-
-#if !defined (_POSIXDIR_H_)
-#define _POSIXDIR_H_
-
-#if defined (HAVE_DIRENT_H)
-# include <dirent.h>
-# define D_NAMLEN(d) (strlen ((d)->d_name))
-#else
-# if defined (HAVE_SYS_NDIR_H)
-# include <sys/ndir.h>
-# endif
-# if defined (HAVE_SYS_DIR_H)
-# include <sys/dir.h>
-# endif
-# if defined (HAVE_NDIR_H)
-# include <ndir.h>
-# endif
-# if !defined (dirent)
-# define dirent direct
-# endif /* !dirent */
-# define D_NAMLEN(d) ((d)->d_namlen)
-#endif /* !HAVE_DIRENT_H */
-
-#if defined (STRUCT_DIRENT_HAS_D_INO) && !defined (STRUCT_DIRENT_HAS_D_FILENO)
-# define d_fileno d_ino
-#endif
-
-#endif /* !_POSIXDIR_H_ */
diff --git a/lib/posixheaders/posixjmp.h b/lib/posixheaders/posixjmp.h
deleted file mode 100644
index 1347cc07..00000000
--- a/lib/posixheaders/posixjmp.h
+++ /dev/null
@@ -1,22 +0,0 @@
-/* posixjmp.h -- wrapper for setjmp.h with changes for POSIX systems. */
-
-#ifndef _POSIXJMP_H_
-#define _POSIXJMP_H_
-
-#include <setjmp.h>
-
-/* This *must* be included *after* config.h */
-
-#if defined (HAVE_POSIX_SIGSETJMP)
-# define procenv_t sigjmp_buf
-# if !defined (__OPENNT)
-# undef setjmp
-# define setjmp(x) sigsetjmp((x), 1)
-# undef longjmp
-# define longjmp(x, n) siglongjmp((x), (n))
-# endif /* !__OPENNT */
-#else
-# define procenv_t jmp_buf
-#endif
-
-#endif /* _POSIXJMP_H_ */
diff --git a/lib/posixheaders/stdc.h b/lib/posixheaders/stdc.h
deleted file mode 100644
index f1590c6d..00000000
--- a/lib/posixheaders/stdc.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/* stdc.h -- macros to make source compile on both ANSI C and K&R C
- compilers. */
-
-/* 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 1, or (at your option)
- any later version.
-
- Bash is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
- License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Bash; see the file COPYING. If not, write to the Free
- Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#if !defined (_STDC_H_)
-#define _STDC_H_
-
-/* Adapted from BSD /usr/include/sys/cdefs.h. */
-
-/* A function can be defined using prototypes and compile on both ANSI C
- and traditional C compilers with something like this:
- extern char *func __P((char *, char *, int)); */
-
-#if defined (__STDC__)
-
-# if !defined (__P)
-# define __P(protos) protos
-# endif
-# define __STRING(x) #x
-
-# if !defined (__GNUC__)
-# define inline
-# endif
-
-#else /* !__STDC__ */
-
-# if !defined (__P)
-# define __P(protos) ()
-# endif
-# define __STRING(x) "x"
-
-#if defined (__GNUC__) /* gcc with -traditional */
-# if !defined (const)
-# define const __const
-# endif
-# if !defined (inline)
-# define inline __inline
-# endif
-# if !defined (signed)
-# define signed __signed
-# endif
-# if !defined (volatile)
-# define volatile __volatile
-# endif
-#else /* !__GNUC__ */
-# if !defined (const)
-# define const
-# endif
-# if !defined (inline)
-# define inline
-# endif
-# if !defined (signed)
-# define signed
-# endif
-# if !defined (volatile)
-# define volatile
-# endif
-#endif /* !__GNUC__ */
-
-#endif /* !__STDC__ */
-
-#endif /* !_STDC_H_ */
diff --git a/lib/readline/COPYING b/lib/readline/COPYING
index a43ea212..a4143997 100644
--- a/lib/readline/COPYING
+++ b/lib/readline/COPYING
@@ -2,7 +2,7 @@
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
- 675 Mass Ave, Cambridge, MA 02139, USA
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
diff --git a/lib/readline/Makefile.in b/lib/readline/Makefile.in
index c0439ae8..082410e1 100644
--- a/lib/readline/Makefile.in
+++ b/lib/readline/Makefile.in
@@ -4,6 +4,22 @@
# #
#############################################################################
+# Copyright (C) 1994 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
+
srcdir = @srcdir@
VPATH = .:@srcdir@
topdir = @top_srcdir@
@@ -61,7 +77,7 @@ CSOURCES = $(srcdir)/readline.c $(srcdir)/funmap.c $(srcdir)/keymaps.c \
# The header files for this library.
HSOURCES = readline.h rldefs.h chardefs.h keymaps.h history.h histlib.h \
posixstat.h posixdir.h posixjmp.h tilde.h rlconf.h rltty.h \
- ansi_stdlib.h rlstdc.h tcap.h
+ ansi_stdlib.h rlstdc.h tcap.h rlprivate.h rlshell.h
HISTOBJ = history.o histexpand.o histfile.o histsearch.o shell.o savestring.o
TILDEOBJ = tilde.o
@@ -179,6 +195,8 @@ macro.o: readline.h keymaps.h chardefs.h tilde.h
macro.o: history.h rlstdc.h
nls.o: ansi_stdlib.h
nls.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h
+nls.o: readline.h keymaps.h chardefs.h tilde.h
+nls.o: history.h rlstdc.h
parens.o: rlconf.h
parens.o: ${BUILD_DIR}/config.h
parens.o: readline.h keymaps.h chardefs.h tilde.h rlstdc.h
@@ -213,8 +231,55 @@ util.o: readline.h keymaps.h chardefs.h tilde.h rlstdc.h
vi_mode.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h
vi_mode.o: readline.h keymaps.h chardefs.h tilde.h
vi_mode.o: history.h ansi_stdlib.h rlstdc.h
-xmalloc.o: ${BUILD_DIR}/config.h
-xmalloc.o: ansi_stdlib.h
+xmalloc.o: ${BUILD_DIR}/config.h ansi_stdlib.h
+
+bind.o: rlshell.h
+histfile.o: rlshell.h
+nls.o: rlshell.h
+readline.o: rlshell.h
+shell.o: rlshell.h
+terminal.o: rlshell.h
+histexpand.o: rlshell.h
+
+bind.o: rlprivate.h
+callback.o: rlprivate.h
+complete.o: rlprivate.h
+display.o: rlprivate.h
+input.o: rlprivate.h
+isearch.o: rlprivate.h
+kill.o: rlprivate.h
+macro.o: rlprivate.h
+nls.o: rlprivate.h
+parens.o: rlprivate.h
+readline.o: rlprivate.h
+rltty.o: rlprivate.h
+search.o: rlprivate.h
+signals.o: rlprivate.h
+terminal.o: rlprivate.h
+undo.o: rlprivate.h
+util.o: rlprivate.h
+vi_mode.o: rlprivate.h
+
+bind.o: xmalloc.h
+complete.o: xmalloc.h
+display.o: xmalloc.h
+funmap.o: xmalloc.h
+histexpand.o: xmalloc.h
+histfile.o: xmalloc.h
+history.o: xmalloc.h
+input.o: xmalloc.h
+isearch.o: xmalloc.h
+keymaps.o: xmalloc.h
+kill.o: xmalloc.h
+macro.o: xmalloc.h
+readline.o: xmalloc.h
+savestring.o: xmalloc.h
+search.o: xmalloc.h
+shell.o: xmalloc.h
+tilde.o: xmalloc.h
+tilde.o: xmalloc.h
+util.o: xmalloc.h
+vi_mode.o: xmalloc.h
# Rules for deficient makes, like SunOS and Solaris
bind.o: bind.c
diff --git a/lib/readline/ansi_stdlib.h b/lib/readline/ansi_stdlib.h
index 52339da5..a720cb9b 100644
--- a/lib/readline/ansi_stdlib.h
+++ b/lib/readline/ansi_stdlib.h
@@ -18,7 +18,7 @@
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if !defined (_STDLIB_H_)
#define _STDLIB_H_ 1
diff --git a/lib/readline/bind.c b/lib/readline/bind.c
index f446dc8c..6a6424e9 100644
--- a/lib/readline/bind.c
+++ b/lib/readline/bind.c
@@ -7,7 +7,7 @@
The GNU Readline Library is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 1, or
+ as published by the Free Software Foundation; either version 2, or
(at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be
@@ -18,7 +18,7 @@
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
- 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
@@ -42,7 +42,6 @@
# include "ansi_stdlib.h"
#endif /* HAVE_STDLIB_H */
-#include <signal.h>
#include <errno.h>
#if !defined (errno)
@@ -58,61 +57,25 @@ extern int errno;
#include "readline.h"
#include "history.h"
+#include "rlprivate.h"
+#include "rlshell.h"
+#include "xmalloc.h"
+
#if !defined (strchr) && !defined (__STDC__)
extern char *strchr (), *strrchr ();
#endif /* !strchr && !__STDC__ */
-extern int _rl_horizontal_scroll_mode;
-extern int _rl_mark_modified_lines;
-extern int _rl_bell_preference;
-extern int _rl_meta_flag;
-extern int _rl_convert_meta_chars_to_ascii;
-extern int _rl_output_meta_chars;
-extern int _rl_complete_show_all;
-extern int _rl_complete_mark_directories;
-extern int _rl_print_completions_horizontally;
-extern int _rl_completion_case_fold;
-extern int _rl_enable_keypad;
-#if defined (PAREN_MATCHING)
-extern int rl_blink_matching_paren;
-#endif /* PAREN_MATCHING */
-#if defined (VISIBLE_STATS)
-extern int rl_visible_stats;
-#endif /* VISIBLE_STATS */
-extern int rl_complete_with_tilde_expansion;
-extern int rl_completion_query_items;
-extern int rl_inhibit_completion;
-extern char *_rl_comment_begin;
-extern unsigned char *_rl_isearch_terminators;
-
-extern int rl_explicit_arg;
-extern int rl_editing_mode;
-extern unsigned char _rl_parsing_conditionalized_out;
-extern Keymap _rl_keymap;
-
-extern char *possible_control_prefixes[], *possible_meta_prefixes[];
-
-/* Functions imported from funmap.c */
-extern char **rl_funmap_names ();
-extern int rl_add_funmap_entry ();
-
-/* Functions imported from util.c */
-extern char *_rl_strindex ();
-
-/* Functions imported from shell.c */
-extern char *get_env_value ();
-
/* Variables exported by this file. */
Keymap rl_binding_keymap;
-/* Forward declarations */
-void rl_set_keymap_from_edit_mode ();
+static int _rl_read_init_file __P((char *, int));
+static int glean_key_from_name __P((char *));
+static int substring_member_of_array __P((char *, char **));
-static int _rl_read_init_file ();
-static int glean_key_from_name ();
-static int substring_member_of_array ();
+static int currently_reading_init_file;
-extern char *xmalloc (), *xrealloc ();
+/* used only in this file */
+static int _rl_prefer_visible_bell = 1;
/* **************************************************************** */
/* */
@@ -677,9 +640,16 @@ _rl_read_file (filename, sizep)
return ((char *)NULL);
}
+#if 0
buffer[file_size] = '\0';
if (sizep)
*sizep = file_size;
+#else
+ buffer[i] = '\0';
+ if (sizep)
+ *sizep = i;
+#endif
+
return (buffer);
}
@@ -718,6 +688,11 @@ rl_read_init_file (filename)
if (*filename == 0)
filename = DEFAULT_INPUTRC;
+#if defined (__MSDOS__)
+ if (_rl_read_init_file (filename, 0) == 0)
+ return 0;
+ filename = "~/_inputrc";
+#endif
return (_rl_read_init_file (filename, 0));
}
@@ -746,6 +721,8 @@ _rl_read_init_file (filename, include_level)
last_readline_init_file = savestring (filename);
}
+ currently_reading_init_file = 1;
+
/* Loop over the lines in the file. Lines that start with `#' are
comments; all other lines are commands for readline initialization. */
current_readline_init_lineno = 1;
@@ -756,6 +733,12 @@ _rl_read_init_file (filename, include_level)
/* Find the end of this line. */
for (i = 0; line + i != end && line[i] != '\n'; i++);
+#if defined (__CYGWIN32__)
+ /* ``Be liberal in what you accept.'' */
+ if (line[i] == '\n' && line[i-1] == '\r')
+ line[i - 1] = '\0';
+#endif
+
/* Mark end of line. */
line[i] = '\0';
@@ -776,6 +759,7 @@ _rl_read_init_file (filename, include_level)
}
free (buffer);
+ currently_reading_init_file = 0;
return (0);
}
@@ -783,9 +767,11 @@ static void
_rl_init_file_error (msg)
char *msg;
{
- fprintf (stderr, "readline: %s: line %d: %s\n", current_readline_init_file,
- current_readline_init_lineno,
- msg);
+ if (currently_reading_init_file)
+ fprintf (stderr, "readline: %s: line %d: %s\n", current_readline_init_file,
+ current_readline_init_lineno, msg);
+ else
+ fprintf (stderr, "readline: %s\n", msg);
}
/* **************************************************************** */
@@ -1232,154 +1218,273 @@ rl_parse_and_bind (string)
have one of two values; either "On" or 1 for truth, or "Off" or 0 for
false. */
+#define V_SPECIAL 0x1
+
static struct {
char *name;
int *value;
+ int flags;
} boolean_varlist [] = {
-#if defined (PAREN_MATCHING)
- { "blink-matching-paren", &rl_blink_matching_paren },
-#endif
- { "completion-ignore-case", &_rl_completion_case_fold },
- { "convert-meta", &_rl_convert_meta_chars_to_ascii },
- { "disable-completion", &rl_inhibit_completion },
- { "enable-keypad", &_rl_enable_keypad },
- { "expand-tilde", &rl_complete_with_tilde_expansion },
- { "horizontal-scroll-mode", &_rl_horizontal_scroll_mode },
- { "input-meta", &_rl_meta_flag },
- { "mark-directories", &_rl_complete_mark_directories },
- { "mark-modified-lines", &_rl_mark_modified_lines },
- { "meta-flag", &_rl_meta_flag },
- { "output-meta", &_rl_output_meta_chars },
- { "print-completions-horizontally", &_rl_print_completions_horizontally },
- { "show-all-if-ambiguous", &_rl_complete_show_all },
+ { "blink-matching-paren", &rl_blink_matching_paren, V_SPECIAL },
+ { "completion-ignore-case", &_rl_completion_case_fold, 0 },
+ { "convert-meta", &_rl_convert_meta_chars_to_ascii, 0 },
+ { "disable-completion", &rl_inhibit_completion, 0 },
+ { "enable-keypad", &_rl_enable_keypad, 0 },
+ { "expand-tilde", &rl_complete_with_tilde_expansion, 0 },
+ { "horizontal-scroll-mode", &_rl_horizontal_scroll_mode, 0 },
+ { "input-meta", &_rl_meta_flag, 0 },
+ { "mark-directories", &_rl_complete_mark_directories, 0 },
+ { "mark-modified-lines", &_rl_mark_modified_lines, 0 },
+ { "meta-flag", &_rl_meta_flag, 0 },
+ { "output-meta", &_rl_output_meta_chars, 0 },
+ { "prefer-visible-bell", &_rl_prefer_visible_bell, V_SPECIAL },
+ { "print-completions-horizontally", &_rl_print_completions_horizontally, 0 },
+ { "show-all-if-ambiguous", &_rl_complete_show_all, 0 },
#if defined (VISIBLE_STATS)
- { "visible-stats", &rl_visible_stats },
+ { "visible-stats", &rl_visible_stats, 0 },
#endif /* VISIBLE_STATS */
{ (char *)NULL, (int *)NULL }
};
+static int
+find_boolean_var (name)
+ char *name;
+{
+ register int i;
+
+ for (i = 0; boolean_varlist[i].name; i++)
+ if (_rl_stricmp (name, boolean_varlist[i].name) == 0)
+ return i;
+ return -1;
+}
+
+/* Hooks for handling special boolean variables, where a
+ function needs to be called or another variable needs
+ to be changed when they're changed. */
+static void
+hack_special_boolean_var (i)
+ int i;
+{
+ char *name;
+
+ name = boolean_varlist[i].name;
+
+ if (_rl_stricmp (name, "blink-matching-paren") == 0)
+ _rl_enable_paren_matching (rl_blink_matching_paren);
+ else if (_rl_stricmp (name, "prefer-visible-bell") == 0)
+ {
+ if (_rl_prefer_visible_bell)
+ _rl_bell_preference = VISIBLE_BELL;
+ else
+ _rl_bell_preference = AUDIBLE_BELL;
+ }
+}
+
+/* These *must* correspond to the array indices for the appropriate
+ string variable. (Though they're not used right now.) */
+#define V_BELLSTYLE 0
+#define V_COMBEGIN 1
+#define V_EDITMODE 2
+#define V_ISRCHTERM 3
+#define V_KEYMAP 4
+
+#define V_STRING 1
+#define V_INT 2
+
+/* Forward declarations */
+static int sv_bell_style __P((char *));
+static int sv_combegin __P((char *));
+static int sv_compquery __P((char *));
+static int sv_editmode __P((char *));
+static int sv_isrchterm __P((char *));
+static int sv_keymap __P((char *));
+
+static struct {
+ char *name;
+ int flags;
+ Function *set_func;
+} string_varlist[] = {
+ { "bell-style", V_STRING, sv_bell_style },
+ { "comment-begin", V_STRING, sv_combegin },
+ { "completion-query-items", V_INT, sv_compquery },
+ { "editing-mode", V_STRING, sv_editmode },
+ { "isearch-terminators", V_STRING, sv_isrchterm },
+ { "keymap", V_STRING, sv_keymap },
+ { (char *)NULL, 0 }
+};
+
+static int
+find_string_var (name)
+ char *name;
+{
+ register int i;
+
+ for (i = 0; string_varlist[i].name; i++)
+ if (_rl_stricmp (name, string_varlist[i].name) == 0)
+ return i;
+ return -1;
+}
+
+/* A boolean value that can appear in a `set variable' command is true if
+ the value is null or empty, `on' (case-insenstive), or "1". Any other
+ values result in 0 (false). */
+static int
+bool_to_int (value)
+ char *value;
+{
+ return (value == 0 || *value == '\0' ||
+ (_rl_stricmp (value, "on") == 0) ||
+ (value[0] == '1' && value[1] == '\0'));
+}
+
int
rl_variable_bind (name, value)
char *name, *value;
{
register int i;
+ int v;
/* Check for simple variables first. */
- for (i = 0; boolean_varlist[i].name; i++)
+ i = find_boolean_var (name);
+ if (i >= 0)
{
- if (_rl_stricmp (name, boolean_varlist[i].name) == 0)
- {
- /* A variable is TRUE if the "value" is "on", "1" or "". */
- *boolean_varlist[i].value = *value == 0 ||
- _rl_stricmp (value, "on") == 0 ||
- (value[0] == '1' && value[1] == '\0');
- return 0;
- }
+ *boolean_varlist[i].value = bool_to_int (value);
+ if (boolean_varlist[i].flags & V_SPECIAL)
+ hack_special_boolean_var (i);
+ return 0;
}
- /* Not a boolean variable, so check for specials. */
+ i = find_string_var (name);
- /* Editing mode change? */
- if (_rl_stricmp (name, "editing-mode") == 0)
+ /* For the time being, unknown variable names or string names without a
+ handler function are simply ignored. */
+ if (i < 0 || string_varlist[i].set_func == 0)
+ return 0;
+
+ v = (*string_varlist[i].set_func) (value);
+ return v;
+}
+
+static int
+sv_editmode (value)
+ char *value;
+{
+ if (_rl_strnicmp (value, "vi", 2) == 0)
{
- if (_rl_strnicmp (value, "vi", 2) == 0)
- {
#if defined (VI_MODE)
- _rl_keymap = vi_insertion_keymap;
- rl_editing_mode = vi_mode;
+ _rl_keymap = vi_insertion_keymap;
+ rl_editing_mode = vi_mode;
#endif /* VI_MODE */
- }
- else if (_rl_strnicmp (value, "emacs", 5) == 0)
- {
- _rl_keymap = emacs_standard_keymap;
- rl_editing_mode = emacs_mode;
- }
+ return 0;
}
-
- /* Comment string change? */
- else if (_rl_stricmp (name, "comment-begin") == 0)
+ else if (_rl_strnicmp (value, "emacs", 5) == 0)
{
- if (*value)
- {
- if (_rl_comment_begin)
- free (_rl_comment_begin);
-
- _rl_comment_begin = savestring (value);
- }
+ _rl_keymap = emacs_standard_keymap;
+ rl_editing_mode = emacs_mode;
+ return 0;
}
- else if (_rl_stricmp (name, "completion-query-items") == 0)
+ return 1;
+}
+
+static int
+sv_combegin (value)
+ char *value;
+{
+ if (value && *value)
{
- int nval = 100;
- if (*value)
- {
- nval = atoi (value);
- if (nval < 0)
- nval = 0;
- }
- rl_completion_query_items = nval;
+ FREE (_rl_comment_begin);
+ _rl_comment_begin = savestring (value);
+ return 0;
}
- else if (_rl_stricmp (name, "keymap") == 0)
+ return 1;
+}
+
+static int
+sv_compquery (value)
+ char *value;
+{
+ int nval = 100;
+
+ if (value && *value)
{
- Keymap kmap;
- kmap = rl_get_keymap_by_name (value);
- if (kmap)
- rl_set_keymap (kmap);
+ nval = atoi (value);
+ if (nval < 0)
+ nval = 0;
}
- else if (_rl_stricmp (name, "bell-style") == 0)
+ rl_completion_query_items = nval;
+ return 0;
+}
+
+static int
+sv_keymap (value)
+ char *value;
+{
+ Keymap kmap;
+
+ kmap = rl_get_keymap_by_name (value);
+ if (kmap)
{
- if (!*value)
- _rl_bell_preference = AUDIBLE_BELL;
- else
- {
- if (_rl_stricmp (value, "none") == 0 || _rl_stricmp (value, "off") == 0)
- _rl_bell_preference = NO_BELL;
- else if (_rl_stricmp (value, "audible") == 0 || _rl_stricmp (value, "on") == 0)
- _rl_bell_preference = AUDIBLE_BELL;
- else if (_rl_stricmp (value, "visible") == 0)
- _rl_bell_preference = VISIBLE_BELL;
- }
+ rl_set_keymap (kmap);
+ return 0;
}
- else if (_rl_stricmp (name, "prefer-visible-bell") == 0)
+ return 1;
+}
+
+#define _SET_BELL(v) do { _rl_bell_preference = v; return 0; } while (0)
+
+static int
+sv_bell_style (value)
+ char *value;
+{
+ if (value == 0 || *value == '\0')
+ _SET_BELL (AUDIBLE_BELL);
+ else if (_rl_stricmp (value, "none") == 0 || _rl_stricmp (value, "off") == 0)
+ _SET_BELL (NO_BELL);
+ else if (_rl_stricmp (value, "audible") == 0 || _rl_stricmp (value, "on") == 0)
+ _SET_BELL (AUDIBLE_BELL);
+ else if (_rl_stricmp (value, "visible") == 0)
+ _SET_BELL (VISIBLE_BELL);
+ else
+ return 1;
+}
+#undef _SET_BELL
+
+static int
+sv_isrchterm (value)
+ char *value;
+{
+ int beg, end, delim;
+ char *v;
+
+ if (value == 0)
+ return 1;
+
+ /* Isolate the value and translate it into a character string. */
+ v = savestring (value);
+ FREE (_rl_isearch_terminators);
+ if (v[0] == '"' || v[0] == '\'')
{
- /* Backwards compatibility. */
- if (*value && (_rl_stricmp (value, "on") == 0 ||
- (*value == '1' && !value[1])))
- _rl_bell_preference = VISIBLE_BELL;
- else
- _rl_bell_preference = AUDIBLE_BELL;
+ delim = v[0];
+ for (beg = end = 1; v[end] && v[end] != delim; end++)
+ ;
}
- else if (_rl_stricmp (name, "isearch-terminators") == 0)
+ else
{
- /* Isolate the value and translate it into a character string. */
- int beg, end;
- char *v;
+ for (beg = end = 0; whitespace (v[end]) == 0; end++)
+ ;
+ }
- v = savestring (value);
- FREE (_rl_isearch_terminators);
- if (v[0] == '"' || v[0] == '\'')
- {
- int delim = v[0];
- for (beg = end = 1; v[end] && v[end] != delim; end++)
- ;
- }
- else
- {
- for (beg = end = 0; whitespace (v[end]) == 0; end++)
- ;
- }
+ v[end] = '\0';
- v[end] = '\0';
- /* The value starts at v + beg. Translate it into a character string. */
- _rl_isearch_terminators = (unsigned char *)xmalloc (2 * strlen (v) + 1);
- rl_translate_keyseq (v + beg, _rl_isearch_terminators, &end);
- _rl_isearch_terminators[end] = '\0';
- free (v);
- }
-
- /* For the time being, unknown variable names are simply ignored. */
+ /* The value starts at v + beg. Translate it into a character string. */
+ _rl_isearch_terminators = (unsigned char *)xmalloc (2 * strlen (v) + 1);
+ rl_translate_keyseq (v + beg, _rl_isearch_terminators, &end);
+ _rl_isearch_terminators[end] = '\0';
+
+ free (v);
return 0;
}
-
+
/* Return the character which matches NAME.
For example, `Space' returns ' '. */
diff --git a/lib/readline/callback.c b/lib/readline/callback.c
index 6915be48..11723569 100644
--- a/lib/readline/callback.c
+++ b/lib/readline/callback.c
@@ -7,7 +7,7 @@
The GNU Readline Library is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 1, or
+ as published by the Free Software Foundation; either version 2, or
(at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be
@@ -18,7 +18,7 @@
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
- 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
@@ -35,15 +35,7 @@
/* System-specific feature definitions and include files. */
#include "rldefs.h"
#include "readline.h"
-
-extern void readline_internal_setup ();
-extern char *readline_internal_teardown ();
-extern int readline_internal_char ();
-extern void _rl_init_line_state ();
-
-extern int _rl_meta_flag;
-extern char *rl_prompt;
-extern int rl_visible_prompt_length;
+#include "rlprivate.h"
/* **************************************************************** */
/* */
diff --git a/lib/readline/chardefs.h b/lib/readline/chardefs.h
index 3e9e2737..664c1e43 100644
--- a/lib/readline/chardefs.h
+++ b/lib/readline/chardefs.h
@@ -7,7 +7,7 @@
The GNU Readline Library is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 1, or
+ as published by the Free Software Foundation; either version 2, or
(at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be
@@ -18,7 +18,7 @@
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
- 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#ifndef _CHARDEFS_H_
#define _CHARDEFS_H_
diff --git a/lib/readline/complete.c b/lib/readline/complete.c
index 714a2bf4..fb48712a 100644
--- a/lib/readline/complete.c
+++ b/lib/readline/complete.c
@@ -7,7 +7,7 @@
The GNU Readline Library is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 1, or
+ as published by the Free Software Foundation; either version 2, or
(at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be
@@ -18,7 +18,7 @@
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
- 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
@@ -70,20 +70,14 @@ extern struct passwd *getpwent ();
/* Some standard library routines. */
#include "readline.h"
+#include "xmalloc.h"
+#include "rlprivate.h"
-extern char *tilde_expand ();
-extern char *rl_copy_text ();
-extern void _rl_abort_internal ();
-extern int _rl_qsort_string_compare ();
-extern void _rl_replace_text ();
-
-extern Function *rl_last_func;
-extern int rl_editing_mode;
-extern int screenwidth;
-
-extern void _rl_move_vert ();
-extern int _rl_vis_botlin;
-extern int rl_display_fixed;
+#ifdef __STDC__
+typedef int QSFUNC (const void *, const void *);
+#else
+typedef int QSFUNC ();
+#endif
/* If non-zero, then this is the address of a function to call when
completing a word would normally display the list of possible matches.
@@ -95,27 +89,25 @@ extern int rl_display_fixed;
VFunction *rl_completion_display_matches_hook = (VFunction *)NULL;
/* Forward declarations for functions defined and used in this file. */
-char *filename_completion_function ();
-char **completion_matches ();
+char *filename_completion_function __P((char *, int));
+char **completion_matches __P((char *, CPFunction *));
#if defined (VISIBLE_STATS)
# if !defined (X_OK)
# define X_OK 1
# endif
-static int stat_char ();
+static int stat_char __P((char *));
#endif
-static char *rl_quote_filename ();
-static char *rl_strpbrk ();
-
-static char **remove_duplicate_matches ();
-static void insert_match ();
-static int append_to_match ();
-static void insert_all_matches ();
-static void display_matches ();
-static int compute_lcd_of_matches ();
+static char *rl_quote_filename __P((char *, int, char *));
+static char *rl_strpbrk __P((char *, char *));
-extern char *xmalloc (), *xrealloc ();
+static char **remove_duplicate_matches __P((char **));
+static void insert_match __P((char *, int, int, char *));
+static int append_to_match __P((char *, int, int));
+static void insert_all_matches __P((char **, int, char *));
+static void display_matches __P((char **));
+static int compute_lcd_of_matches __P((char **, int, char *));
/* **************************************************************** */
/* */
@@ -136,7 +128,11 @@ int _rl_complete_mark_directories = 1;
int _rl_print_completions_horizontally;
/* Non-zero means that case is not significant in filename completion. */
+#if defined (__MSDOS__) && !defined (__DJGPP__)
+int _rl_completion_case_fold = 1;
+#else
int _rl_completion_case_fold;
+#endif
/* Global variables available to applications using readline. */
@@ -417,6 +413,10 @@ printable_part (pathname)
char *temp;
temp = rl_filename_completion_desired ? strrchr (pathname, '/') : (char *)NULL;
+#if defined (__MSDOS__)
+ if (rl_filename_completion_desired && temp == 0 && isalpha (pathname[0]) && pathname[1] == ':')
+ temp = pathname + 1;
+#endif
return (temp ? ++temp : pathname);
}
@@ -477,7 +477,12 @@ print_filename (to_print, full_pathname)
c = to_print[-1];
to_print[-1] = '\0';
- s = tilde_expand (full_pathname);
+ /* If setting the last slash in full_pathname to a NUL results in
+ full_pathname being the empty string, we are trying to complete
+ files in the root directory. If we pass a null string to the
+ bash directory completion hook, for example, it will expand it
+ to the current directory. We just want the `/'. */
+ s = tilde_expand (full_pathname && *full_pathname ? full_pathname : "/");
if (rl_directory_completion_hook)
(*rl_directory_completion_hook) (&s);
@@ -627,25 +632,31 @@ find_completion_word (fp, dp)
/* If there is an application-specific function to say whether or not
a character is quoted and we found a quote character, let that
function decide whether or not a character is a word break, even
- if it is found in rl_completer_word_break_characters. */
- if (rl_char_is_quoted_p)
- isbrk = (found_quote == 0 ||
- (*rl_char_is_quoted_p) (rl_line_buffer, rl_point) == 0) &&
- strchr (rl_completer_word_break_characters, scan) != 0;
- else
- isbrk = strchr (rl_completer_word_break_characters, scan) != 0;
-
- if (isbrk)
+ if it is found in rl_completer_word_break_characters. Don't bother
+ if we're at the end of the line, though. */
+ if (scan)
{
- /* If the character that caused the word break was a quoting
- character, then remember it as the delimiter. */
- if (rl_basic_quote_characters && strchr (rl_basic_quote_characters, scan) && (end - rl_point) > 1)
- delimiter = scan;
-
- /* If the character isn't needed to determine something special
- about what kind of completion to perform, then advance past it. */
- if (rl_special_prefixes == 0 || strchr (rl_special_prefixes, scan) == 0)
- rl_point++;
+ if (rl_char_is_quoted_p)
+ isbrk = (found_quote == 0 ||
+ (*rl_char_is_quoted_p) (rl_line_buffer, rl_point) == 0) &&
+ strchr (rl_completer_word_break_characters, scan) != 0;
+ else
+ isbrk = strchr (rl_completer_word_break_characters, scan) != 0;
+
+ if (isbrk)
+ {
+ /* If the character that caused the word break was a quoting
+ character, then remember it as the delimiter. */
+ if (rl_basic_quote_characters &&
+ strchr (rl_basic_quote_characters, scan) &&
+ (end - rl_point) > 1)
+ delimiter = scan;
+
+ /* If the character isn't needed to determine something special
+ about what kind of completion to perform, then advance past it. */
+ if (rl_special_prefixes == 0 || strchr (rl_special_prefixes, scan) == 0)
+ rl_point++;
+ }
}
if (fp)
@@ -715,7 +726,7 @@ remove_duplicate_matches (matches)
/* Sort the array without matches[0], since we need it to
stay in place no matter what. */
if (i)
- qsort (matches+1, i-1, sizeof (char *), _rl_qsort_string_compare);
+ qsort (matches+1, i-1, sizeof (char *), (QSFUNC *)_rl_qsort_string_compare);
/* Remember the lowest common denominator for it may be unique. */
lowest_common = savestring (matches[0]);
@@ -908,7 +919,7 @@ rl_display_match_list (matches, len, max)
/* Sort the items if they are not already sorted. */
if (rl_ignore_completion_duplicates == 0)
- qsort (matches + 1, len, sizeof (char *), _rl_qsort_string_compare);
+ qsort (matches + 1, len, sizeof (char *), (QSFUNC *)_rl_qsort_string_compare);
crlf ();
@@ -1407,9 +1418,9 @@ username_completion_function (text, state)
char *text;
int state;
{
-#if defined (__GO32__) || defined (__WIN32__) || defined (__OPENNT)
+#if defined (__WIN32__) || defined (__OPENNT)
return (char *)NULL;
-#else /* !__GO32__ */
+#else /* !__WIN32__ && !__OPENNT) */
static char *username = (char *)NULL;
static struct passwd *entry;
static int namelen, first_char, first_char_loc;
@@ -1452,7 +1463,7 @@ username_completion_function (text, state)
return (value);
}
-#endif /* !__GO32__ */
+#endif /* !__WIN32__ && !__OPENNT */
}
/* Okay, now we write the entry_function for filename completion. In the
@@ -1494,11 +1505,25 @@ filename_completion_function (text, state)
temp = strrchr (dirname, '/');
+#if defined (__MSDOS__)
+ /* special hack for //X/... */
+ if (dirname[0] == '/' && dirname[1] == '/' && isalpha (dirname[2]) && dirname[3] == '/')
+ temp = strrchr (dirname + 3, '/');
+#endif
+
if (temp)
{
strcpy (filename, ++temp);
*temp = '\0';
}
+#if defined (__MSDOS__)
+ /* searches from current directory on the drive */
+ else if (isalpha (dirname[0]) && dirname[1] == ':')
+ {
+ strcpy (filename, dirname + 2);
+ dirname[2] = '\0';
+ }
+#endif
else
{
dirname[0] = '.';
@@ -1660,11 +1685,7 @@ rl_menu_complete (count, ignore)
/* Clean up from previous call, if any. */
FREE (orig_text);
if (matches)
- {
- for (match_list_index = 0; matches[match_list_index]; match_list_index++)
- free (matches[match_list_index]);
- free (matches);
- }
+ free_match_list (matches);
match_list_index = match_list_size = 0;
matches = (char **)NULL;
diff --git a/lib/readline/display.c b/lib/readline/display.c
index 25aba64c..4487004a 100644
--- a/lib/readline/display.c
+++ b/lib/readline/display.c
@@ -7,7 +7,7 @@
The GNU Readline Library is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 1, or
+ as published by the Free Software Foundation; either version 2, or
(at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be
@@ -18,7 +18,7 @@
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
- 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
@@ -41,11 +41,6 @@
#include <stdio.h>
-#if defined (__GO32__)
-# include <go32.h>
-# include <pc.h>
-#endif /* __GO32__ */
-
/* System-specific feature definitions and include files. */
#include "rldefs.h"
@@ -56,48 +51,25 @@
#include "readline.h"
#include "history.h"
+#include "rlprivate.h"
+#include "xmalloc.h"
+
#if !defined (strchr) && !defined (__STDC__)
extern char *strchr (), *strrchr ();
#endif /* !strchr && !__STDC__ */
-/* Global and pseudo-global variables and functions
- imported from readline.c. */
-extern char *rl_prompt;
-extern int readline_echoing_p;
-
-extern int _rl_output_meta_chars;
-extern int _rl_horizontal_scroll_mode;
-extern int _rl_mark_modified_lines;
-extern int _rl_prefer_visible_bell;
-
-/* Variables and functions imported from terminal.c */
-extern void _rl_output_some_chars ();
-#ifdef _MINIX
-extern void _rl_output_character_function ();
-#else
-extern int _rl_output_character_function ();
+#if defined (HACK_TERMCAP_MOTION)
+extern char *term_forward_char;
#endif
-extern int _rl_backspace ();
-
-extern char *term_clreol, *term_clrpag;
-extern char *term_im, *term_ic, *term_ei, *term_DC;
-extern char *term_up, *term_dc, *term_cr, *term_IC;
-extern int screenheight, screenwidth, screenchars;
-extern int terminal_can_insert, _rl_term_autowrap;
-
-/* Pseudo-global functions (local to the readline library) exported
- by this file. */
-void _rl_move_cursor_relative (), _rl_output_some_chars ();
-void _rl_move_vert ();
-void _rl_clear_to_eol (), _rl_clear_screen ();
-static void update_line (), space_to_eol ();
-static void delete_chars (), insert_some_chars ();
-static void cr ();
+static void update_line __P((char *, char *, int, int, int, int));
+static void space_to_eol __P((int));
+static void delete_chars __P((int));
+static void insert_some_chars __P((char *, int));
+static void cr __P((void));
static int *inv_lbreaks, *vis_lbreaks;
-
-extern char *xmalloc (), *xrealloc ();
+static int inv_lbsize, vis_lbsize;
/* Heuristic used to decide whether it is faster to move from CUR to NEW
by backing up or outputting a carriage return and moving forward. */
@@ -190,7 +162,7 @@ static int visible_first_line_len;
/* Expand the prompt string S and return the number of visible
characters in *LP, if LP is not null. This is currently more-or-less
a placeholder for expansion. LIP, if non-null is a place to store the
- index of the last invisible character in ther eturned string. */
+ index of the last invisible character in the returned string. */
/* Current implementation:
\001 (^A) start non-visible characters
@@ -250,6 +222,18 @@ expand_prompt (pmt, lp, lip)
return ret;
}
+/* Just strip out RL_PROMPT_START_IGNORE and RL_PROMPT_END_IGNORE from
+ PMT and return the rest of PMT. */
+char *
+_rl_strip_prompt (pmt)
+ char *pmt;
+{
+ char *ret;
+
+ ret = expand_prompt (pmt, (int *)NULL, (int *)NULL);
+ return ret;
+}
+
/*
* Expand the prompt string into the various display components, if
* necessary.
@@ -307,6 +291,49 @@ rl_expand_prompt (prompt)
}
}
+/* Initialize the VISIBLE_LINE and INVISIBLE_LINE arrays, and their associated
+ arrays of line break markers. MINSIZE is the minimum size of VISIBLE_LINE
+ and INVISIBLE_LINE; if it is greater than LINE_SIZE, LINE_SIZE is
+ increased. If the lines have already been allocated, this ensures that
+ they can hold at least MINSIZE characters. */
+static void
+init_line_structures (minsize)
+ int minsize;
+{
+ register int n;
+
+ if (invisible_line == 0) /* initialize it */
+ {
+ if (line_size < minsize)
+ line_size = minsize;
+ visible_line = xmalloc (line_size);
+ invisible_line = xmalloc (line_size);
+ }
+ else if (line_size < minsize) /* ensure it can hold MINSIZE chars */
+ {
+ line_size *= 2;
+ if (line_size < minsize)
+ line_size = minsize;
+ visible_line = xrealloc (visible_line, line_size);
+ invisible_line = xrealloc (invisible_line, line_size);
+ }
+
+ for (n = minsize; n < line_size; n++)
+ {
+ visible_line[n] = 0;
+ invisible_line[n] = 1;
+ }
+
+ if (vis_lbreaks == 0)
+ {
+ /* should be enough. */
+ inv_lbsize = vis_lbsize = 256;
+ inv_lbreaks = (int *)xmalloc (inv_lbsize * sizeof (int));
+ vis_lbreaks = (int *)xmalloc (vis_lbsize * sizeof (int));
+ inv_lbreaks[0] = vis_lbreaks[0] = 0;
+ }
+}
+
/* Basic redisplay algorithm. */
void
rl_redisplay ()
@@ -325,19 +352,7 @@ rl_redisplay ()
if (invisible_line == 0)
{
- visible_line = xmalloc (line_size);
- invisible_line = xmalloc (line_size);
- for (in = 0; in < line_size; in++)
- {
- visible_line[in] = 0;
- invisible_line[in] = 1;
- }
-
- /* should be enough, but then again, this is just for testing. */
- inv_lbreaks = (int *)malloc (256 * sizeof (int));
- vis_lbreaks = (int *)malloc (256 * sizeof (int));
- inv_lbreaks[0] = vis_lbreaks[0] = 0;
-
+ init_line_structures (0);
rl_on_new_line ();
}
@@ -395,12 +410,13 @@ rl_redisplay ()
else
{
prompt_this_line++;
+ pmtlen = prompt_this_line - rl_display_prompt; /* temp var */
if (forced_display)
{
- _rl_output_some_chars (rl_display_prompt, prompt_this_line - rl_display_prompt);
+ _rl_output_some_chars (rl_display_prompt, pmtlen);
/* Make sure we are at column zero even after a newline,
regardless of the state of terminal output processing. */
- if (prompt_this_line[-2] != '\r')
+ if (pmtlen < 2 || prompt_this_line[-2] != '\r')
cr ();
}
}
@@ -419,11 +435,25 @@ rl_redisplay ()
wrap_offset = 0;
}
+#define CHECK_INV_LBREAKS() \
+ do { \
+ if (newlines >= (inv_lbsize - 2)) \
+ { \
+ inv_lbsize *= 2; \
+ inv_lbreaks = (int *)xrealloc (inv_lbreaks, inv_lbsize * sizeof (int)); \
+ } \
+ } while (0)
+
#define CHECK_LPOS() \
do { \
lpos++; \
if (lpos >= screenwidth) \
{ \
+ if (newlines >= (inv_lbsize - 2)) \
+ { \
+ inv_lbsize *= 2; \
+ inv_lbreaks = (int *)xrealloc (inv_lbreaks, inv_lbsize * sizeof (int)); \
+ } \
inv_lbreaks[++newlines] = out; \
lpos = 0; \
} \
@@ -437,14 +467,13 @@ rl_redisplay ()
contents of the command line? */
while (lpos >= screenwidth)
{
-#if 0
- temp = ((newlines + 1) * screenwidth) - ((newlines == 0) ? wrap_offset : 0);
-#else
/* XXX - possible fix from Darin Johnson <darin@acuson.com> for prompt
string with invisible characters that is longer than the screen
- width. */
+ width. XXX - this doesn't work right if invisible characters have
+ to be put on the second screen line -- it adds too much (the number
+ of invisible chars after the screenwidth). */
temp = ((newlines + 1) * screenwidth) + ((newlines == 0) ? wrap_offset : 0);
-#endif
+
inv_lbreaks[++newlines] = temp;
lpos -= screenwidth;
}
@@ -477,6 +506,7 @@ rl_redisplay ()
if (lpos + 4 >= screenwidth)
{
temp = screenwidth - lpos;
+ CHECK_INV_LBREAKS ();
inv_lbreaks[++newlines] = out + temp;
lpos = 4 - temp;
}
@@ -506,6 +536,7 @@ rl_redisplay ()
{
register int temp2;
temp2 = screenwidth - lpos;
+ CHECK_INV_LBREAKS ();
inv_lbreaks[++newlines] = out + temp2;
lpos = temp - temp2;
while (out < newout)
@@ -522,6 +553,7 @@ rl_redisplay ()
else if (c == '\n' && _rl_horizontal_scroll_mode == 0 && term_up && *term_up)
{
line[out++] = '\0'; /* XXX - sentinel */
+ CHECK_INV_LBREAKS ();
inv_lbreaks[++newlines] = out;
lpos = 0;
}
@@ -546,6 +578,7 @@ rl_redisplay ()
}
inv_botlin = lb_botlin = newlines;
+ CHECK_INV_LBREAKS ();
inv_lbreaks[newlines+1] = out;
cursor_linenum = lb_linenum;
@@ -651,8 +684,12 @@ rl_redisplay ()
if (cursor_linenum == 0 && wrap_offset > 0 && _rl_last_c_pos > 0 &&
_rl_last_c_pos <= last_invisible && local_prompt)
{
+#if defined (__MSDOS__)
+ putc ('\r', rl_outstream);
+#else
if (term_cr)
tputs (term_cr, 1, _rl_output_character_function);
+#endif
_rl_output_some_chars (local_prompt, nleft);
_rl_last_c_pos = nleft;
}
@@ -772,11 +809,17 @@ rl_redisplay ()
/* Swap visible and non-visible lines. */
{
char *temp = visible_line;
- int *itemp = vis_lbreaks;
+ int *itemp = vis_lbreaks, ntemp = vis_lbsize;
+
visible_line = invisible_line;
invisible_line = temp;
+
vis_lbreaks = inv_lbreaks;
inv_lbreaks = itemp;
+
+ vis_lbsize = inv_lbsize;
+ inv_lbsize = ntemp;
+
rl_display_fixed = 0;
/* If we are displaying on a single line, and last_lmargin is > 0, we
are not displaying any invisible characters, so set visible_wrap_offset
@@ -899,7 +942,11 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
term_cr && lendiff > visible_length && _rl_last_c_pos > 0 &&
od > lendiff && _rl_last_c_pos < last_invisible)
{
+#if defined (__MSDOS__)
+ putc ('\r', rl_outstream);
+#else
tputs (term_cr, 1, _rl_output_character_function);
+#endif
_rl_output_some_chars (local_prompt, lendiff);
_rl_last_c_pos = lendiff;
}
@@ -1029,6 +1076,58 @@ rl_on_new_line ()
return 0;
}
+/* Tell the update routines that we have moved onto a new line with the
+ prompt already displayed. Code originally from the version of readline
+ distributed with CLISP. */
+int
+rl_on_new_line_with_prompt ()
+{
+ int prompt_size, i, l, real_screenwidth, newlines;
+ char *prompt_last_line;
+
+ /* Initialize visible_line and invisible_line to ensure that they can hold
+ the already-displayed prompt. */
+ prompt_size = strlen (rl_prompt) + 1;
+ init_line_structures (prompt_size);
+
+ /* Make sure the line structures hold the already-displayed prompt for
+ redisplay. */
+ strcpy (visible_line, rl_prompt);
+ strcpy (invisible_line, rl_prompt);
+
+ /* If the prompt contains newlines, take the last tail. */
+ prompt_last_line = strrchr (rl_prompt, '\n');
+ if (!prompt_last_line)
+ prompt_last_line = rl_prompt;
+
+ l = strlen (prompt_last_line);
+ _rl_last_c_pos = l;
+
+ /* Dissect prompt_last_line into screen lines. Note that here we have
+ to use the real screenwidth. Readline's notion of screenwidth might be
+ one less, see terminal.c. */
+ real_screenwidth = screenwidth + (_rl_term_autowrap ? 0 : 1);
+ _rl_last_v_pos = l / real_screenwidth;
+ /* If the prompt length is a multiple of real_screenwidth, we don't know
+ whether the cursor is at the end of the last line, or already at the
+ beginning of the next line. Output a newline just to be safe. */
+ if (l > 0 && (l % real_screenwidth) == 0)
+ _rl_output_some_chars ("\n", 1);
+ last_lmargin = 0;
+
+ newlines = 0; i = 0;
+ while (i <= l)
+ {
+ _rl_vis_botlin = newlines;
+ vis_lbreaks[newlines++] = i;
+ i += real_screenwidth;
+ }
+ vis_lbreaks[newlines] = l;
+ visible_wrap_offset = 0;
+
+ return 0;
+}
+
/* Actually update the display, period. */
int
rl_forced_update_display ()
@@ -1086,8 +1185,6 @@ _rl_move_cursor_relative (new, data)
That kind of control is for people who don't know what the
data is underneath the cursor. */
#if defined (HACK_TERMCAP_MOTION)
- extern char *term_forward_char;
-
if (term_forward_char)
for (i = _rl_last_c_pos; i < new; i++)
tputs (term_forward_char, 1, _rl_output_character_function);
@@ -1114,20 +1211,15 @@ _rl_move_vert (to)
if (_rl_last_v_pos == to || to > screenheight)
return;
-#if defined (__GO32__)
- {
- int row, col;
-
- ScreenGetCursor (&row, &col);
- ScreenSetCursor ((row + to - _rl_last_v_pos), col);
- }
-#else /* !__GO32__ */
-
if ((delta = to - _rl_last_v_pos) > 0)
{
for (i = 0; i < delta; i++)
putc ('\n', rl_outstream);
+#if defined (__MSDOS__)
+ putc ('\r', rl_outstream);
+#else
tputs (term_cr, 1, _rl_output_character_function);
+#endif
_rl_last_c_pos = 0;
}
else
@@ -1136,7 +1228,7 @@ _rl_move_vert (to)
for (i = 0; i < -delta; i++)
tputs (term_up, 1, _rl_output_character_function);
}
-#endif /* !__GO32__ */
+
_rl_last_v_pos = to; /* Now TO is here */
}
@@ -1344,11 +1436,9 @@ void
_rl_clear_to_eol (count)
int count;
{
-#if !defined (__GO32__)
if (term_clreol)
tputs (term_clreol, 1, _rl_output_character_function);
else if (count)
-#endif /* !__GO32__ */
space_to_eol (count);
}
@@ -1369,11 +1459,9 @@ space_to_eol (count)
void
_rl_clear_screen ()
{
-#if !defined (__GO32__)
if (term_clrpag)
tputs (term_clrpag, 1, _rl_output_character_function);
else
-#endif /* !__GO32__ */
crlf ();
}
@@ -1383,20 +1471,6 @@ insert_some_chars (string, count)
char *string;
int count;
{
-#if defined (__GO32__)
- int row, col, width;
- char *row_start;
-
- ScreenGetCursor (&row, &col);
- width = ScreenCols ();
- row_start = ScreenPrimary + (row * width);
-
- memcpy (row_start + col + count, row_start + col, width - col - count);
-
- /* Place the text on the screen. */
- _rl_output_some_chars (string, count);
-#else /* !_GO32 */
-
/* If IC is defined, then we do not have to "enter" insert mode. */
if (term_IC)
{
@@ -1429,7 +1503,6 @@ insert_some_chars (string, count)
if (term_ei && *term_ei)
tputs (term_ei, 1, _rl_output_character_function);
}
-#endif /* !__GO32__ */
}
/* Delete COUNT characters from the display line. */
@@ -1437,18 +1510,6 @@ static void
delete_chars (count)
int count;
{
-#if defined (__GO32__)
- int row, col, width;
- char *row_start;
-
- ScreenGetCursor (&row, &col);
- width = ScreenCols ();
- row_start = ScreenPrimary + (row * width);
-
- memcpy (row_start + col, row_start + col + count, width - col - count);
- memset (row_start + width - count, 0, count * 2);
-#else /* !_GO32 */
-
if (count > screenwidth) /* XXX */
return;
@@ -1464,7 +1525,6 @@ delete_chars (count)
while (count--)
tputs (term_dc, 1, _rl_output_character_function);
}
-#endif /* !__GO32__ */
}
void
@@ -1486,7 +1546,11 @@ _rl_update_final ()
if (full_lines && _rl_term_autowrap && (VIS_LLEN(_rl_vis_botlin) == screenwidth))
{
char *last_line;
+#if 0
last_line = &visible_line[inv_lbreaks[_rl_vis_botlin]];
+#else
+ last_line = &visible_line[vis_lbreaks[_rl_vis_botlin]];
+#endif
_rl_move_cursor_relative (screenwidth - 1, last_line);
_rl_clear_to_eol (0);
putc (last_line[screenwidth - 1], rl_outstream);
@@ -1503,23 +1567,66 @@ cr ()
{
if (term_cr)
{
+#if defined (__MSDOS__)
+ putc ('\r', rl_outstream);
+#else
tputs (term_cr, 1, _rl_output_character_function);
+#endif
_rl_last_c_pos = 0;
}
}
+/* Redraw the last line of a multi-line prompt that may possibly contain
+ terminal escape sequences. Called with the cursor at column 0 of the
+ line to draw the prompt on. */
+static void
+redraw_prompt (t)
+ char *t;
+{
+ char *oldp, *oldl, *oldlprefix;
+ int oldlen, oldlast, oldplen;
+
+ /* Geez, I should make this a struct. */
+ oldp = rl_display_prompt;
+ oldl = local_prompt;
+ oldlprefix = local_prompt_prefix;
+ oldlen = visible_length;
+ oldplen = prefix_length;
+ oldlast = last_invisible;
+
+ rl_display_prompt = t;
+ local_prompt = expand_prompt (t, &visible_length, &last_invisible);
+ local_prompt_prefix = (char *)NULL;
+ rl_forced_update_display ();
+
+ rl_display_prompt = oldp;
+ local_prompt = oldl;
+ local_prompt_prefix = oldlprefix;
+ visible_length = oldlen;
+ prefix_length = oldplen;
+ last_invisible = oldlast;
+}
+
/* Redisplay the current line after a SIGWINCH is received. */
void
_rl_redisplay_after_sigwinch ()
{
- char *t, *oldp, *oldl, *oldlprefix;
+ char *t;
/* Clear the current line and put the cursor at column 0. Make sure
the right thing happens if we have wrapped to a new screen line. */
if (term_cr)
{
+#if defined (__MSDOS__)
+ putc ('\r', rl_outstream);
+#else
tputs (term_cr, 1, _rl_output_character_function);
+#endif
_rl_last_c_pos = 0;
+#if defined (__MSDOS__)
+ space_to_eol (screenwidth);
+ putc ('\r', rl_outstream);
+#else
if (term_clreol)
tputs (term_clreol, 1, _rl_output_character_function);
else
@@ -1527,6 +1634,7 @@ _rl_redisplay_after_sigwinch ()
space_to_eol (screenwidth);
tputs (term_cr, 1, _rl_output_character_function);
}
+#endif
if (_rl_last_v_pos > 0)
_rl_move_vert (0);
}
@@ -1536,17 +1644,7 @@ _rl_redisplay_after_sigwinch ()
/* Redraw only the last line of a multi-line prompt. */
t = strrchr (rl_display_prompt, '\n');
if (t)
- {
- oldp = rl_display_prompt;
- oldl = local_prompt;
- oldlprefix = local_prompt_prefix;
- rl_display_prompt = ++t;
- local_prompt = local_prompt_prefix = (char *)NULL;
- rl_forced_update_display ();
- rl_display_prompt = oldp;
- local_prompt = oldl;
- local_prompt_prefix = oldlprefix;
- }
+ redraw_prompt (++t);
else
rl_forced_update_display ();
}
@@ -1571,3 +1669,25 @@ _rl_erase_entire_line ()
cr ();
fflush (rl_outstream);
}
+
+/* return the `current display line' of the cursor -- the number of lines to
+ move up to get to the first screen line of the current readline line. */
+int
+_rl_current_display_line ()
+{
+ int ret, nleft;
+
+ /* Find out whether or not there might be invisible characters in the
+ editing buffer. */
+ if (rl_display_prompt == rl_prompt)
+ nleft = _rl_last_c_pos - screenwidth - rl_visible_prompt_length;
+ else
+ nleft = _rl_last_c_pos - screenwidth;
+
+ if (nleft > 0)
+ ret = 1 + nleft / screenwidth;
+ else
+ ret = 0;
+
+ return ret;
+}
diff --git a/lib/readline/doc/Makefile b/lib/readline/doc/Makefile
index b58ab566..42b578e1 100644
--- a/lib/readline/doc/Makefile
+++ b/lib/readline/doc/Makefile
@@ -1,7 +1,7 @@
-# Generated automatically from Makefile.in by configure.
+# Derived by hand from the generated readline-src/doc/Makefile
# This makefile for Readline library documentation is in -*- text -*- mode.
# Emacs likes it that way.
-top_srcdir = .
+topdir = .
srcdir = .
VPATH = .
@@ -9,25 +9,32 @@ prefix = /usr/local
infodir = ${prefix}/info
mandir = ${prefix}/man
-man3dir = $(mandir)/man3
+manpfx = man
+
+man1ext = 1
+man1dir = $(mandir)/$(manpfx)$(man1ext)
+man3ext = 3
+man3dir = $(mandir)/$(manpfx)$(man3ext)
SHELL = /bin/sh
RM = rm -f
+INSTALL = /usr/bin/install -c
+INSTALL_DATA = ${INSTALL} -m 644
+
+BUILD_DIR = .
TEXINPUTDIR = $(srcdir)
-MAKEINFO = makeinfo
+MAKEINFO = LANGUAGE= makeinfo
TEXI2DVI = $(srcdir)/texi2dvi
TEXI2HTML = $(srcdir)/texi2html
QUIETPS = #set this to -q to shut up dvips
-DVIPS = dvips -D 300 $(QUIETPS) -o $@ # tricky
-
-INSTALL = /usr/bin/install -c
-INSTALL_PROGRAM = ${INSTALL}
-INSTALL_DATA = ${INSTALL} -m 644
+PSDPI = 300 # I don't have any 600-dpi printers
+DVIPS = dvips -D ${PSDPI} $(QUIETPS) -o $@ # tricky
RLSRC = $(srcdir)/rlman.texinfo $(srcdir)/rluser.texinfo \
- $(srcdir)/rltech.texinfo $(srcdir)/manvers.texinfo
+ $(srcdir)/rltech.texinfo $(srcdir)/manvers.texinfo \
+ $(srcdir)/rluserman.texinfo
HISTSRC = $(srcdir)/hist.texinfo $(srcdir)/hsuser.texinfo \
$(srcdir)/hstech.texinfo $(srcdir)/manvers.texinfo
@@ -37,25 +44,19 @@ NROFF = groff -Tascii
# This should be a program that converts troff to postscript
GROFF = groff
-DVIOBJ = readline.dvi history.dvi
-INFOOBJ = readline.info history.info
-PSOBJ = readline.ps history.ps
-HTMLOBJ = readline.html history.html
-HTMLTOC = readline_toc.html history_toc.html
-TEXTOBJ = readline.0
+DVIOBJ = readline.dvi history.dvi rluserman.dvi
+INFOOBJ = readline.info history.info rluserman.info
+PSOBJ = readline.ps history.ps rluserman.ps
+HTMLOBJ = readline.html history.html rluserman.html
-INTERMEDIATE_OBJ = rlman.dvi hist.dvi
+INTERMEDIATE_OBJ = rlman.dvi hist.dvi rluserman.dvi
-CREATED_DOCS = $(DVIOBJ) $(INFOOBJ) $(PSOBJ) $(HTMLOBJ) $(HTMLTOC) $(TEXTOBJ)
+CREATED_DOCS = $(DVIOBJ) $(INFOOBJ) $(PSOBJ) $(HTMLOBJ)
-.SUFFIXES: .0 .3 .ps .txt .dvi
+.SUFFIXES: .ps .txt .dvi
-.3.0:
- $(RM) $@
- -${NROFF} -man $< > $@
-
-all: info dvi html ps #text
-nodvi: info html #text
+all: info dvi html ps
+nodvi: info html
readline.dvi: $(RLSRC)
TEXINPUTS=.:$(TEXINPUTDIR):$$TEXINPUTS $(TEXI2DVI) $(srcdir)/rlman.texinfo
@@ -64,6 +65,12 @@ readline.dvi: $(RLSRC)
readline.info: $(RLSRC)
$(MAKEINFO) --no-split -I $(TEXINPUTDIR) -o $@ $(srcdir)/rlman.texinfo
+rluserman.dvi: $(RLSRC)
+ TEXINPUTS=.:$(TEXINPUTDIR):$$TEXINPUTS $(TEXI2DVI) $(srcdir)/rluserman.texinfo
+
+rluserman.info: $(RLSRC)
+ $(MAKEINFO) --no-split -I $(TEXINPUTDIR) -o $@ $(srcdir)/rluserman.texinfo
+
history.dvi: ${HISTSRC}
TEXINPUTS=.:$(TEXINPUTDIR):$$TEXINPUTS $(TEXI2DVI) $(srcdir)/hist.texinfo
mv hist.dvi history.dvi
@@ -75,6 +82,10 @@ readline.ps: readline.dvi
$(RM) $@
$(DVIPS) readline.dvi
+rluserman.ps: rluserman.dvi
+ $(RM) $@
+ $(DVIPS) rluserman.dvi
+
history.ps: history.dvi
$(RM) $@
$(DVIPS) history.dvi
@@ -84,6 +95,9 @@ readline.html: ${RLSRC}
sed -e 's:rlman.html:readline.html:' rlman.html > readline.html
$(RM) rlman.html
+rluserman.html: ${RLSRC}
+ $(TEXI2HTML) -menu -monolithic -I $(TEXINPUTDIR) $(srcdir)/rluserman.texinfo
+
history.html: ${HISTSRC}
$(TEXI2HTML) -menu -monolithic -I $(TEXINPUTDIR) $(srcdir)/hist.texinfo
sed -e 's:hist.html:history.html:' hist.html > history.html
@@ -93,9 +107,6 @@ info: $(INFOOBJ)
dvi: $(DVIOBJ)
ps: $(PSOBJ)
html: $(HTMLOBJ)
-text: $(TEXTOBJ)
-
-readline.0: readline.3
clean:
$(RM) *.aux *.cp *.fn *.ky *.log *.pg *.toc *.tp *.vr *.cps *.pgs \
@@ -113,27 +124,7 @@ maintainer-clean: clean
$(RM) $(INTERMEDIATE_OBJ)
$(RM) Makefile
-installdirs: $(top_srcdir)/support/mkdirs
- -$(SHELL) $(top_srcdir)/support/mkdirs $(infodir) $(man3dir)
-
-install: installdirs
- if test -f readline.info; then \
- ${INSTALL_DATA} readline.info $(infodir)/readline.info; \
- else \
- ${INSTALL_DATA} $(srcdir)/readline.info $(infodir)/readline.info; \
- fi
- if test -f history.info; then \
- ${INSTALL_DATA} history.info $(infodir)/history.info; \
- else \
- ${INSTALL_DATA} $(srcdir)/history.info $(infodir)/history.info; \
- fi
- if $(SHELL) -c 'install-info --version' >/dev/null 2>&1; then \
- install-info --dir-file=$(infodir)/dir $(infodir)/readline.info ; \
- install-info --dir-file=$(infodir)/dir $(infodir)/history.info ; \
- else true; fi
- -${INSTALL_DATA} $(srcdir)/readline.3 $(man3dir)/readline.3
+install:
+ @echo "This documentation should not be installed."
uninstall:
- $(RM) $(infodir)/readline.info
- $(RM) $(infodir)/history.info
- $(RM) $(man3dir)/readline.3
diff --git a/lib/readline/doc/hist.texinfo b/lib/readline/doc/hist.texinfo
index 31a0ba0a..8a9c9413 100644
--- a/lib/readline/doc/hist.texinfo
+++ b/lib/readline/doc/hist.texinfo
@@ -55,8 +55,8 @@ provides a consistent user interface for recalling lines of previously
typed input.
Published by the Free Software Foundation @*
-675 Massachusetts Avenue, @*
-Cambridge, MA 02139 USA
+59 Temple Place, Suite 330, @*
+Boston, MA 02111 USA
Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice
diff --git a/lib/readline/doc/hstech.texinfo b/lib/readline/doc/hstech.texinfo
index 54100908..12fff2c9 100644
--- a/lib/readline/doc/hstech.texinfo
+++ b/lib/readline/doc/hstech.texinfo
@@ -66,6 +66,13 @@ If the programmer desires, he can use the Readline library, which
includes some history manipulation by default, and has the added
advantage of command line editing.
+Before declaring any functions using any functionality the History
+library provides in other code, an application writer should include
+the file @code{<readline/history.h>} in any file that uses the
+History library's features. It supplies extern declarations for all
+of the library's public functions and variables, and declares all of
+the public data structures.
+
@node History Storage
@section History Storage
@@ -334,7 +341,7 @@ if expansions did take place;
@item -1
if there was an error in expansion;
@item 2
-if the returned line should only be displayed, but not executed,
+if the returned line should be displayed, but not executed,
as with the @code{:p} modifier (@pxref{Modifiers}).
@end table
diff --git a/lib/readline/doc/hsuser.texinfo b/lib/readline/doc/hsuser.texinfo
index 76cb63b1..5f75f5df 100644
--- a/lib/readline/doc/hsuser.texinfo
+++ b/lib/readline/doc/hsuser.texinfo
@@ -1,7 +1,7 @@
@ignore
This file documents the user interface to the GNU History library.
-Copyright (C) 1988, 1991, 1996 Free Software Foundation, Inc.
+Copyright (C) 1988-1999 Free Software Foundation, Inc.
Authored by Brian Fox and Chet Ramey.
Permission is granted to make and distribute verbatim copies of this manual
@@ -26,11 +26,16 @@ into another language, under the above conditions for modified versions.
@node Using History Interactively
@chapter Using History Interactively
+@ifclear BashFeatures
+@defcodeindex bt
+@end ifclear
+
@ifset BashFeatures
-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.
+This chapter describes how to use the @sc{gnu} History Library
+interactively, from a user's standpoint.
+It should be considered a user's guide.
+For information on using the @sc{gnu} History Library in other programs,
+see the @sc{gnu} Readline Library Manual.
@end ifset
@ifclear BashFeatures
This chapter describes how to use the GNU History Library interactively,
@@ -63,20 +68,25 @@ information on using the GNU History Library in your own programs,
When the @samp{-o history} option to the @code{set} builtin
is enabled (@pxref{The Set Builtin}),
the shell provides access to the @var{command history},
-the list of commands previously typed. The text of the last
-@code{HISTSIZE}
-commands (default 500) is saved in a history list. The shell
-stores each command in the history list prior to parameter and
-variable expansion
+the list of commands previously typed.
+The value of the @code{HISTSIZE} shell variable is used as the
+number of commands to save in a history list.
+The text of the last @code{$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
@code{HISTIGNORE} and @code{HISTCONTROL}.
+
When the shell starts up, the history is initialized from the
file named by the @code{HISTFILE} variable (default @file{~/.bash_history}).
-@code{HISTFILE} is truncated, if necessary, to contain no more than
-the number of lines specified by the value of the @code{HISTFILESIZE}
-variable. When an interactive shell exits, the last
-@code{HISTSIZE} lines are copied from the history list to @code{HISTFILE}.
+The file named by the value of @code{HISTFILE} is truncated, if
+necessary, to contain no more than the number of lines specified by
+the value of the @code{HISTFILESIZE} variable.
+When an interactive shell exits, the last
+@code{$HISTSIZE} lines are copied from the history list to the file
+named by @code{$HISTFILE}.
If the @code{histappend} shell option is set (@pxref{Bash Builtins}),
the lines are appended to the history file,
otherwise the history file is overwritten.
@@ -88,11 +98,11 @@ lines. If @code{HISTFILESIZE} is not set, no truncation is performed.
The builtin command @code{fc} may be used to list or edit and re-execute
a portion of the history list.
-The @code{history} builtin can be used to display or modify the history
+The @code{history} builtin may be used to display or modify the history
list and manipulate the history file.
-When using the command-line editing, search commands
+When using command-line editing, search commands
are available in each editing mode that provide access to the
-history list.
+history list (@pxref{Commands For History}).
The shell allows control over which commands are saved on the history
list. The @code{HISTCONTROL} and @code{HISTIGNORE}
@@ -105,13 +115,14 @@ semicolons where necessary to preserve syntactic correctness.
The @code{lithist}
shell option causes the shell to save the command with embedded newlines
instead of semicolons.
+The @code{shopt} builtin is used to set these options.
@xref{Bash Builtins}, for a description of @code{shopt}.
@node Bash History Builtins
@section Bash History Builtins
@cindex history builtins
-Bash provides two builtin commands that allow you to manipulate the
+Bash provides two builtin commands which manipulate the
history list and history file.
@table @code
@@ -151,23 +162,27 @@ and typing @samp{r} re-executes the last command (@pxref{Aliases}).
@item history
@btindex history
@example
-history [-c] [@var{n}]
+history [@var{n}]
+history -c
+history -d @var{offset}
history [-anrw] [@var{filename}]
history -ps @var{arg}
@end example
-Display the history list with line numbers. Lines prefixed with
-with a @samp{*} have been modified. An argument of @var{n} says
-to list only the last @var{n} lines. Options, if supplied, have
-the following meanings:
+With no options, display the history list with line numbers.
+Lines prefixed with with a @samp{*} have been modified.
+An argument of @var{n} lists only the last @var{n} lines.
+Options, if supplied, have the following meanings:
@table @code
-@item -w
-Write out the current history to the history file.
+@item -c
+Clear the history list. This may be combined
+with the other options to replace the history list completely.
-@item -r
-Read the current history file and append its contents to
-the history list.
+@item -d @var{offset}
+Delete the history entry at position @var{offset}.
+@var{offset} should be specified as it appears when the history is
+displayed.
@item -a
Append the new
@@ -179,20 +194,24 @@ 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.
-@item -c
-Clear the history list. This may be combined
-with the other options to replace the history list completely.
+@item -r
+Read the current history file and append its contents to
+the history list.
-@item -s
-The @var{arg}s are added to the end of
-the history list as a single entry.
+@item -w
+Write out the current history to the history file.
@item -p
Perform history substitution on the @var{arg}s and display the result
on the standard output, without storing the results in the history list.
+
+@item -s
+The @var{arg}s are added to the end of
+the history list as a single entry.
+
@end table
-When the @samp{-w}, @samp{-r}, @samp{-a}, or @samp{-n} option is
+When any of the @samp{-w}, @samp{-r}, @samp{-a}, or @samp{-n} options is
used, if @var{filename}
is given, then it is used as the history file. If not, then
the value of the @code{HISTFILE} variable is used.
@@ -309,6 +328,26 @@ may be omitted if the word designator begins with a @samp{^}, @samp{$},
of the line, with the first word being denoted by 0 (zero). Words are
inserted into the current line separated by single spaces.
+@need 0.75
+For example,
+
+@table @code
+@item !!
+designates the preceding command. When you type this, the preceding
+command is repeated in toto.
+
+@item !!:$
+designates the last argument of the preceding command. This may be
+shortened to @code{!$}.
+
+@item !fi:2
+designates the second argument of the most recent command starting with
+the letters @code{fi}.
+@end table
+
+@need 0.75
+Here are the word designators:
+
@table @code
@item 0 (zero)
diff --git a/lib/readline/doc/manvers.texinfo b/lib/readline/doc/manvers.texinfo
index 63924e38..3122b6c6 100644
--- a/lib/readline/doc/manvers.texinfo
+++ b/lib/readline/doc/manvers.texinfo
@@ -1,6 +1,6 @@
-@set EDITION 4.0
-@set VERSION 4.0
-@set UPDATED 31 December 1998
-@set UPDATE-MONTH December 1998
+@set EDITION 4.1
+@set VERSION 4.1
+@set UPDATED 2000 January 19
+@set UPDATE-MONTH January 2000
-@set LASTCHANGE Thu Dec 31 10:17:05 EST 1998
+@set LASTCHANGE Wed Jan 19 12:16:30 EST 2000
diff --git a/lib/readline/doc/rlman.texinfo b/lib/readline/doc/rlman.texinfo
index 41bafbf5..759f0eb3 100644
--- a/lib/readline/doc/rlman.texinfo
+++ b/lib/readline/doc/rlman.texinfo
@@ -55,8 +55,8 @@ in the consistency of user interface across discrete programs that need
to provide a command line interface.
Published by the Free Software Foundation @*
-675 Massachusetts Avenue, @*
-Cambridge, MA 02139 USA
+59 Temple Place, Suite 330, @*
+Boston, MA 02111 USA
Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice
diff --git a/lib/readline/doc/rltech.texinfo b/lib/readline/doc/rltech.texinfo
index ea8d7f8c..51c340a9 100644
--- a/lib/readline/doc/rltech.texinfo
+++ b/lib/readline/doc/rltech.texinfo
@@ -167,6 +167,13 @@ programs. This section describes the various functions and variables
defined within the Readline library which allow a user program to add
customized functionality to Readline.
+Before declaring any functions that customize Readline's behavior, or
+using any functionality Readline provides in other code, an
+application writer should include the file @code{<readline/readline.h>}
+in any file that uses Readline's features. Since some of the definitions
+in @code{readline.h} use the @code{stdio} library, the file
+@code{<stdio.h>} should be included before @code{readline.h}.
+
@menu
* The Function Type:: C declarations to make code readable.
* Function Writing:: Variables and calling conventions.
@@ -241,7 +248,9 @@ These variables are available to function writers.
@deftypevar {char *} rl_line_buffer
This is the line gathered so far. You are welcome to modify the
-contents of the line, but see @ref{Allowing Undoing}.
+contents of the line, but see @ref{Allowing Undoing}. The
+function @code{rl_extend_line_buffer} is available to increase
+the memory allocated to @code{rl_line_buffer}.
@end deftypevar
@deftypevar int rl_point
@@ -282,6 +291,16 @@ The prompt Readline uses. This is set from the argument to
@code{readline ()}, and should not be assigned to directly.
@end deftypevar
+@deftypevar int rl_already_prompted
+If an application wishes to display the prompt itself, rather than have
+Readline do it the first time @code{readline()} is called, it should set
+this variable to a non-zero value after displaying the prompt.
+The prompt must also be passed as the argument to @code{readline()} so
+the redisplay functions can update the display properly.
+The calling application is responsible for managing the value; Readline
+never sets it.
+@end deftypevar
+
@deftypevar {char *} rl_library_version
The version number of this revision of the library.
@end deftypevar
@@ -447,6 +466,13 @@ several internal keymaps: @code{emacs_standard_keymap},
@code{emacs_standard_keymap} is the default, and the examples in
this manual assume that.
+Since @code{readline} installs a set of default key bindings the first
+time it is called, there is always the danger that a custom binding
+installed before the first call to @code{readline} will be overridden.
+An alternate mechanism is to install custom key bindings in an
+initialization function assigned to the @code{rl_startup_hook} variable
+(@pxref{Readline Variables}).
+
These functions manage key bindings.
@deftypefun int rl_bind_key (int key, Function *function)
@@ -534,6 +560,12 @@ the list is formatted in such a way that it can be made part of an
Print the names of all bindable Readline functions to @code{rl_outstream}.
@end deftypefun
+@deftypefun {char **} rl_funmap_names ()
+Return a NULL terminated array of known function names. The array is
+sorted. The array itself is allocated, but not the strings inside. You
+should free () the array when you done, but not the pointrs.
+@end deftypefun
+
@node Allowing Undoing
@subsection Allowing Undoing
@@ -615,10 +647,19 @@ Readline thinks the screen display is correct.
@end deftypefun
@deftypefun int rl_on_new_line ()
-Tell the update routines that we have moved onto a new (empty) line,
+Tell the update functions that we have moved onto a new (empty) line,
usually after ouputting a newline.
@end deftypefun
+@deftypefun int rl_on_new_line_with_prompt ()
+Tell the update functions that we have moved onto a new line, with
+@var{rl_prompt} already displayed.
+This could be used by applications that want to output the prompt string
+themselves, but still need Readline to know the prompt string length for
+redisplay.
+It should be used after setting @var{rl_already_prompted}.
+@end deftypefun
+
@deftypefun int rl_reset_line_state ()
Reset the display state to a clean state and redisplay the current line
starting on a new line.
@@ -688,7 +729,7 @@ before Readline attempts to read characters from the terminal with
@code{rl_read_key ()}.
@end deftypefun
-@deftypefun rl_extend_line_buffer (int len)
+@deftypefun int rl_extend_line_buffer (int len)
Ensure that @code{rl_line_buffer} has enough space to hold @var{len}
characters, possibly reallocating it if necessary.
@end deftypefun
@@ -700,6 +741,8 @@ Initialize or re-initialize Readline's internal state.
@deftypefun int rl_reset_terminal (char *terminal_name)
Reinitialize Readline's idea of the terminal settings using
@var{terminal_name} as the terminal type (e.g., @code{vt100}).
+If @var{terminal_name} is NULL, the value of the @code{TERM}
+environment variable is used.
@end deftypefun
@deftypefun int alphabetic (int c)
@@ -1106,7 +1149,7 @@ for subsequent calls.
@deftypevar {Function *} rl_completion_entry_function
A pointer to the generator function for @code{completion_matches ()}.
-@code{NULL} means to use @code{filename_entry_function ()}, the default
+@code{NULL} means to use @code{filename_completion_function ()}, the default
filename completer.
@end deftypevar
diff --git a/lib/readline/doc/rluser.texinfo b/lib/readline/doc/rluser.texinfo
index 755f7ca3..9f088ff3 100644
--- a/lib/readline/doc/rluser.texinfo
+++ b/lib/readline/doc/rluser.texinfo
@@ -7,10 +7,10 @@
This file documents the end user interface to the GNU command line
editing features. It is to be an appendix to manuals for programs which
use these features. There is a document entitled "readline.texinfo"
-which contains both end-user and programmer documentation for the GNU
-Readline Library.
+which contains both end-user and programmer documentation for the
+GNU Readline Library.
-Copyright (C) 1988, 1991, 1993, 1996 Free Software Foundation, Inc.
+Copyright (C) 1988-1999 Free Software Foundation, Inc.
Authored by Brian Fox and Chet Ramey.
@@ -36,11 +36,19 @@ into another language, under the above conditions for modified versions.
@comment If you are including this manual as an appendix, then set the
@comment variable readline-appendix.
+@ifclear BashFeatures
+@defcodeindex bt
+@end ifclear
+
@node Command Line Editing
@chapter Command Line Editing
-This chapter describes the basic features of the @sc{GNU}
+This chapter describes the basic features of the @sc{gnu}
command line editing interface.
+@ifset BashFeatures
+Command line editing is provided by the Readline library, which is
+used by several different programs, including Bash.
+@end ifset
@menu
* Introduction and Notation:: Notation used in this text.
@@ -50,6 +58,12 @@ command line editing interface.
available for binding
* Readline vi Mode:: A short description of how to make Readline
behave like the vi editor.
+@ifset BashFeatures
+* 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.
+@end ifset
@end menu
@node Introduction and Notation
@@ -63,9 +77,19 @@ produced when the @key{k} key is pressed while the Control key
is depressed.
The text @key{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{k}
-key is pressed. If you do not have a meta key, the identical keystroke
-can be generated by typing @key{ESC} @i{first}, and then typing @key{k}.
+produced when the Meta key (if you have one) is depressed, and the @key{k}
+key is pressed.
+The Meta key is labeled @key{ALT} on many keyboards.
+On keyboards with two keys labeled @key{ALT} (usually to either side of
+the space bar), the @key{ALT} on the left side is generally set to
+work as a Meta key.
+The @key{ALT} 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{ALT} key, or another key working as
+a Meta key, the identical keystroke can be generated by typing @key{ESC}
+@i{first}, and then typing @key{k}.
Either process is known as @dfn{metafying} the @key{k} key.
The text @key{M-C-k} is read as `Meta-Control-k' and describes the
@@ -75,6 +99,10 @@ In addition, several keys have their own names. Specifically,
@key{DEL}, @key{ESC}, @key{LFD}, @key{SPC}, @key{RET}, and @key{TAB} all
stand for themselves when seen in this text, or in an init file
(@pxref{Readline Init File}).
+If your keyboard lacks a @key{LFD} key, typing @key{C-j} will
+produce the desired character.
+The @key{RET} key may be labeled @key{Return} or @key{Enter} on
+some keyboards.
@node Readline Interaction
@section Readline Interaction
@@ -110,8 +138,8 @@ 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 miss typing a character that you wanted to type, and
-not notice your error until you have typed several other characters. In
+Sometimes you may mistype a character, and
+not notice the error until you have typed several other characters. In
that case, you can type @key{C-b} to move the cursor to the left, and then
correct your mistake. Afterwards, you can move the cursor to the right
with @key{C-f}.
@@ -120,7 +148,7 @@ 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 basic bare
+blank space created by the removal of the text. A list of the bare
essentials for editing the text of an input line follows.
@table @asis
@@ -128,22 +156,28 @@ essentials for editing the text of an input line follows.
Move back one character.
@item @key{C-f}
Move forward one character.
-@item @key{DEL}
+@item @key{DEL} or @key{Backspace}
Delete the character to the left of the cursor.
@item @key{C-d}
Delete the character underneath the cursor.
@item @w{Printing characters}
Insert the character into the line at the cursor.
-@item @key{C-_}
+@item @key{C-_} or @key{C-x C-u}
Undo the last editing command. You can undo all the way back to an
empty line.
@end table
+@noindent
+(Depending on your configuration, the @key{Backspace} key be set to
+delete the character to the left of the cursor and the @key{DEL} key set
+to delete the character underneath the cursor, like @key{C-d}, rather
+than the character to the left of the cursor.)
+
@node Readline Movement Commands
@subsection Readline Movement Commands
-The above table describes the most basic possible keystrokes that you need
+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 @key{C-b}, @key{C-f},
@key{C-d}, and @key{DEL}. Here are some commands for moving more rapidly
@@ -175,6 +209,8 @@ operate on characters while meta keystrokes operate on words.
@dfn{Killing} text means to delete the text from the line, but to save
it away for later use, usually by @dfn{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.
@@ -194,12 +230,14 @@ Here is the list of commands for killing text.
Kill the text from the current cursor position to the end of the line.
@item M-d
-Kill from the cursor to the end of the current word, or if between
+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 @key{M-f}.
@item M-DEL
-Kill from the cursor the start of the previous word, or if between
+Kill from the cursor the start of the previous word, or, if between
words, to the start of the previous word.
+Word boundaries are the same as those used by @key{M-b}.
@item C-w
Kill from the cursor to the previous whitespace. This is different than
@@ -231,7 +269,7 @@ start of the line, you might type @samp{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 (@key{-}), then the sign of the argument will be negative. Once
+sign (@samp{-}), 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 @key{C-d} command an argument of 10, you could type @samp{M-1 0 C-d}.
@@ -252,15 +290,18 @@ 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 @var{isearch-terminators} variable
+To search backward in the history for a particular string, type
+@key{C-r}. Typing @key{C-s} searches forward through the history.
+The characters present in the value of the @code{isearch-terminators} variable
are used to terminate an incremental search.
If that variable has not been assigned a value, the @key{ESC} and
@key{C-J} characters will terminate an incremental search.
@key{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 @key{C-s} or
-@key{C-r} as appropriate.
+
+To find other matching entries in the history list, type @key{C-r} or
+@key{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
@@ -276,11 +317,11 @@ typed by the user or be part of the contents of the current line.
@section Readline Init File
@cindex initialization file, readline
-Although the Readline library comes with a set of @code{emacs}-like
+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 @dfn{inputrc} file in his home directory.
+commands in an @dfn{inputrc} file, conventionally in his home directory.
The name of this
@ifset BashFeatures
file is taken from the value of the shell variable @code{INPUTRC}. If
@@ -326,6 +367,11 @@ change from the default Emacs-like key binding to use
set editing-mode vi
@end example
+@ifset BashFeatures
+The @w{@code{bind -V}} command lists the current Readline variable names
+and values. @xref{Bash Builtins}.
+@end ifset
+
A great deal of run-time behavior is changeable with the following
variables.
@@ -363,7 +409,7 @@ them; otherwise, they are simply listed. The default limit is
@vindex convert-meta
If set to @samp{on}, Readline will convert characters with the
eighth bit set to an ASCII key sequence by stripping the eighth
-bit and prepending an @key{ESC} character, converting them to a
+bit and prefixing an @key{ESC} character, converting them to a
meta-prefixed key sequence. The default value is @samp{on}.
@item disable-completion
@@ -469,7 +515,7 @@ completions. The default is @samp{off}.
@item Key Bindings
The syntax for controlling key bindings in the init file is
-simple. First you have to know the name of the command that you
+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.
@@ -480,6 +526,12 @@ command on a line in the init file. The name of the key
can be expressed in different ways, depending on which is most
comfortable for you.
+@ifset BashFeatures
+The @w{@code{bind -p}} command displays Readline function names and
+bindings in a format that can put directly into an initialization file.
+@xref{Bash Builtins}.
+@end ifset
+
@table @asis
@item @w{@var{keyname}: @var{function-name} or @var{macro}}
@var{keyname} is the name of a key spelled out in English. For example:
@@ -497,7 +549,7 @@ expressed on the right hand side (that is, to insert the text
@item @w{"@var{keyseq}": @var{function-name} or @var{macro}}
@var{keyseq} differs from @var{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
+the key sequence in double quotes. Some @sc{gnu} Emacs style key
escapes can be used, as in the following example, but the
special character names are not recognized.
@@ -515,7 +567,7 @@ the text @samp{Function Key 1}.
@end table
-The following GNU Emacs style escape sequences are available when
+The following @sc{gnu} Emacs style escape sequences are available when
specifying key sequences:
@table @code
@@ -528,12 +580,12 @@ an escape character
@item @kbd{\\}
backslash
@item @kbd{\"}
-@key{"}
+@key{"}, a double quotation mark
@item @kbd{\'}
-@key{'}
+@key{'}, a single quote or apostrophe
@end table
-In addition to the GNU Emacs style escape sequences, a second
+In addition to the @sc{gnu} Emacs style escape sequences, a second
set of backslash escapes is available:
@table @code
@@ -554,10 +606,10 @@ horizontal tab
@item \v
vertical tab
@item \@var{nnn}
-the character whose ASCII code is the octal value @var{nnn}
+the character whose @code{ASCII} code is the octal value @var{nnn}
(one to three digits)
@item \x@var{nnn}
-the character whose ASCII code is the hexadecimal value @var{nnn}
+the character whose @code{ASCII} code is the hexadecimal value @var{nnn}
(one to three digits)
@end table
@@ -762,6 +814,17 @@ $endif
This section describes Readline commands that may be bound to key
sequences.
+@ifset BashFeatures
+You can list your key bindings by executing
+@w{@code{bind -P}} or, for a more terse format, suitable for an
+@var{inputrc} file, @w{@code{bind -p}}. (@xref{Bash Builtins}.)
+@end ifset
+
+Command names without an accompanying key sequence are unbound by default.
+In the following descriptions, @var{point} refers to the current cursor
+position, and @var{mark} refers to a cursor position saved by the
+@code{set-mark} command.
+The text between the point and mark is referred to as the @var{region}.
@node Commands For Moving
@subsection Commands For Moving
@@ -783,7 +846,7 @@ Move forward to the end of the next word. Words are composed of
letters and digits.
@item backward-word (M-b)
-Move back to the start of this, or the previous, word. Words are
+Move back to the start of the current or previous word. Words are
composed of letters and digits.
@item clear-screen (C-l)
@@ -846,9 +909,9 @@ for a string supplied by the user.
@item history-search-forward ()
Search forward through the history for the string of characters
-between the start of the current line and the current cursor
-position (the @var{point}). This is a non-incremental search. By
-default, this command is unbound.
+between the start of the current line and the point.
+This is a non-incremental search.
+By default, this command is unbound.
@item history-search-backward ()
Search backward through the history for the string of characters
@@ -908,11 +971,11 @@ 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 don't work.
+Negative arguments have no effect.
@item transpose-words (M-t)
-Drag the word behind the cursor past the word in front of the cursor
-moving the cursor over that word as well.
+Drag the word before point past the word after point,
+moving point past that word as well.
@item upcase-word (M-u)
Uppercase the current (or following) word. With a negative argument,
@@ -934,38 +997,36 @@ capitalize the previous word, but do not move the cursor.
@ftable @code
@item kill-line (C-k)
-Kill the text from the current cursor position to the end of the line.
+Kill the text from point to the end of the line.
@item backward-kill-line (C-x Rubout)
Kill backward to the beginning of the line.
@item unix-line-discard (C-u)
Kill backward from the cursor to the beginning of the current line.
-The killed text is saved on the kill-ring.
@item kill-whole-line ()
-Kill all characters on the current line, no matter where the
-cursor is. By default, this is unbound.
+Kill all characters on the current line, no matter point is.
+By default, this is unbound.
@item kill-word (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 @code{forward-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 @code{forward-word}.
@item backward-kill-word (M-DEL)
-Kill the word behind the cursor. Word boundaries are the same
-as @code{backward-word}.
+Kill the word behind point.
+Word boundaries are the same as @code{backward-word}.
@item unix-word-rubout (C-w)
-Kill the word behind the cursor, using white space as a word
-boundary. The killed text is saved on the kill-ring.
+Kill the word behind point, using white space as a word boundary.
+The killed text is saved on the kill-ring.
@item delete-horizontal-space ()
Delete all spaces and tabs around point. By default, this is unbound.
@item kill-region ()
-Kill the text between the point and the @emph{mark} (saved
-cursor position). This text is referred to as the @var{region}.
+Kill the text in the current region.
By default, this command is unbound.
@item copy-region-as-kill ()
@@ -1109,7 +1170,7 @@ the text against lines from the history list for possible
completion matches.
@item complete-into-braces (M-@{)
-Perform filename completion and return the list of possible completions
+Perform filename completion and insert the list of possible completions
enclosed within braces so the list is available to the shell
(@pxref{Brace Expansion}).
@@ -1138,7 +1199,7 @@ in the macro appear as if typed at the keyboard.
@ftable @code
@item re-read-init-file (C-x C-r)
-Read in the contents of the inputrc file, and incorporate
+Read in the contents of the @var{inputrc} file, and incorporate
any bindings or variable assignments found there.
@item abort (C-g)
@@ -1192,7 +1253,8 @@ The value of the @code{comment-begin}
variable is inserted at the beginning of the current line,
and the line is accepted as if a newline had been typed.
@ifset BashFeatures
-This makes the current line a shell comment.
+The default value of @code{comment-begin} causes this command
+to make the current line a shell comment.
@end ifset
@item dump-functions ()
@@ -1285,3 +1347,283 @@ switches you into `command' mode, where you can edit the text of the
line with the standard @code{vi} movement keys, move to previous
history lines with @samp{k} and subsequent lines with @samp{j}, and
so forth.
+
+@ifset BashFeatures
+@node Programmable Completion
+@section Programmable Completion
+@cindex programmable completion
+
+When word completion is attempted for an argument to a command for
+which a completion specification (a @var{compspec}) has been defined
+using the @code{complete} builtin (@pxref{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 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.
+
+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 (@pxref{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 @samp{-f} or @samp{-d} option is used for filename or
+directory name completion, the shell variable @code{FIGNORE} is
+used to filter the matches.
+@xref{Bash Variables}, for a description of @code{FIGNORE}.
+
+Any completions specified by a filename expansion pattern to the
+@samp{-G} option are generated next.
+The words generated by the pattern need not match the word being completed.
+The @code{GLOBIGNORE} shell variable is not used to filter the matches,
+but the @code{FIGNORE} shell variable is used.
+
+Next, the string specified as the argument to the @samp{-W} option
+is considered.
+The string is first split using the characters in the @code{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, arithmetic expansion, and pathname expansion,
+as described above (@pxref{Shell Expansions}).
+The results are split using the rules described above
+(@pxref{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 @samp{-F} and @samp{-C} options is invoked.
+When the command or function is invoked, the @code{COMP_LINE} and
+@code{COMP_POINT} variables are assigned values as described above
+(@pxref{Bash Variables}).
+If a shell function is being invoked, the @code{COMP_WORDS} and
+@code{COMP_CWORD} variables are also set.
+When the function or command is invoked, the first argument is the
+name of the command whose arguments are being completed, the
+second argument is the word being completed, and the third argument
+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 @samp{-F} is invoked first.
+The function may use any of the shell facilities, including the
+@code{compgen} builtin described below
+(@pxref{Programmable Completion Builtins}), to generate the matches.
+It must put the possible completions in the @code{COMPREPLY} array
+variable.
+
+Next, any command specified with the @samp{-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 @samp{-X} option is applied to the list.
+The filter is a pattern as used for pathname expansion; a @samp{&}
+in the pattern is replaced with the text of the word being completed.
+A literal @samp{&} 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 @samp{!} negates the pattern; in this case any completion
+not matching the pattern will be removed.
+
+Finally, any prefix and suffix specified with the @samp{-P} and @samp{-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 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.
+
+@node Programmable Completion Builtins
+@section Programmable Completion Builtins
+@cindex completion builtins
+
+Two builtin commands are available to manipulate the programmable completion
+facilities.
+
+@table @code
+@item compgen
+@btindex compgen
+@example
+@code{compgen [@var{option}] [@var{word}]}
+@end example
+
+Generate possible completion matches for @var{word} according to
+the @var{option}s, which may be any option accepted by the
+@code{complete}
+builtin with the exception of @samp{-p} and @samp{-r}, and write
+the matches to the standard output.
+When using the @samp{-F} or @samp{-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 @var{word} is specified, only those completions matching @var{word}
+will be displayed.
+
+The return value is true unless an invalid option is supplied, or no
+matches were generated.
+
+@item complete
+@btindex complete
+@example
+@code{complete [-abcdefjkvu] [-A @var{action}] [-G @var{globpat}] [-W @var{wordlist}]
+[-P @var{prefix}] [-S @var{suffix}] [-X @var{filterpat}] [-F @var{function}]
+[-C @var{command}] @var{name} [@var{name} @dots{}]}
+@code{complete -pr [@var{name} @dots{}]}
+@end example
+
+Specify how arguments to each @var{name} should be completed.
+If the @samp{-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 @samp{-r} option removes a completion specification for
+each @var{name}, or, if no @var{name}s are supplied, all
+completion specifications.
+
+The process of applying these completion specifications when word completion
+is attempted is described above (@pxref{Programmable Completion}).
+
+Other options, if specified, have the following meanings.
+The arguments to the @samp{-G}, @samp{-W}, and @samp{-X} options
+(and, if necessary, the @samp{-P} and @samp{-S} options)
+should be quoted to protect them from expansion before the
+@code{complete} builtin is invoked.
+
+@table @code
+@item -A @var{action}
+The @var{action} may be one of the following to generate a list of possible
+completions:
+
+@table @code
+@item alias
+Alias names. May also be specified as @samp{-a}.
+
+@item arrayvar
+Array variable names.
+
+@item binding
+Readline key binding names (@pxref{Bindable Readline Commands}).
+
+@item builtin
+Names of shell builtin commands. May also be specified as @samp{-b}.
+
+@item command
+Command names. May also be specified as @samp{-c}.
+
+@item directory
+Directory names. May also be specified as @samp{-d}.
+
+@item disabled
+Names of disabled shell builtins.
+
+@item enabled
+Names of enabled shell builtins.
+
+@item export
+Names of exported shell variables. May also be specified as @samp{-e}.
+
+@item file
+File names. May also be specified as @samp{-f}.
+
+@item function
+Names of shell functions.
+
+@item helptopic
+Help topics as accepted by the @code{help} builtin (@pxref{Bash Builtins}).
+
+@item hostname
+Hostnames, as taken from the file specified by the
+@code{HOSTFILE} shell variable (@pxref{Bash Variables}).
+
+@item job
+Job names, if job control is active. May also be specified as @samp{-j}.
+
+@item keyword
+Shell reserved words. May also be specified as @samp{-k}.
+
+@item running
+Names of running jobs, if job control is active.
+
+@item setopt
+Valid arguments for the @samp{-o} option to the @code{set} builtin
+(@pxref{The Set Builtin}).
+
+@item shopt
+Shell option names as accepted by the @code{shopt} builtin
+(@pxref{Bash Builtins}).
+
+@item signal
+Signal names.
+
+@item stopped
+Names of stopped jobs, if job control is active.
+
+@item user
+User names. May also be specified as @samp{-u}.
+
+@item variable
+Names of all shell variables. May also be specified as @samp{-v}.
+@end table
+
+@item -G @var{globpat}
+The filename expansion pattern @var{globpat} is expanded to generate
+the possible completions.
+
+@item -W @var{wordlist}
+The @var{wordlist} is split using the characters in the
+@code{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.
+
+@item -C @var{command}
+@var{command} is executed in a subshell environment, and its output is
+used as the possible completions.
+
+@item -F @var{function}
+The shell function @var{function} is executed in the current shell
+environment.
+When it finishes, the possible completions are retrieved from the value
+of the @code{COMPREPLY} array variable.
+
+@item -X @var{filterpat}
+@var{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
+@var{filterpat} is removed from the list.
+A leading @samp{!} in @var{filterpat} negates the pattern; in this
+case, any completion not matching @var{filterpat} is removed.
+
+@item -P @var{prefix}
+@var{prefix} is added at the beginning of each possible completion
+after all other options have been applied.
+
+@item -S @var{suffix}
+@var{suffix} is appended to each possible completion
+after all other options have been applied.
+@end table
+
+The return value is true unless an invalid option is supplied, an option
+other than @samp{-p} or @samp{-r} is supplied without a @var{name}
+argument, an attempt is made to remove a completion specification for
+a @var{name} for which no specification exists, or
+an error occurs adding a completion specification.
+
+@end table
+@end ifset
diff --git a/lib/readline/doc/rluserman.texinfo b/lib/readline/doc/rluserman.texinfo
new file mode 100644
index 00000000..e6a3dcde
--- /dev/null
+++ b/lib/readline/doc/rluserman.texinfo
@@ -0,0 +1,94 @@
+\input texinfo @c -*-texinfo-*-
+@comment %**start of header (This is for running Texinfo on a region.)
+@setfilename rluserman.info
+@settitle GNU Readline Library
+@comment %**end of header (This is for running Texinfo on a region.)
+@setchapternewpage odd
+
+@include manvers.texinfo
+
+@ifinfo
+@dircategory Libraries
+@direntry
+* Readline: (readline). The GNU readline library API
+@end direntry
+
+This document describes the end user interface of the GNU Readline Library,
+a utility which aids in the consistency of user interface across discrete
+programs that need to provide a command line interface.
+
+Copyright (C) 1988-1999 Free Software Foundation, Inc.
+
+Permission is granted to make and distribute verbatim copies of
+this manual provided the copyright notice and this permission notice
+pare preserved on all copies.
+
+@ignore
+Permission is granted to process this file through TeX and print the
+results, provided the printed document carries copying permission
+notice identical to this one except for the removal of this paragraph
+(this paragraph not being relevant to the printed manual).
+@end ignore
+
+Permission is granted to copy and distribute modified versions of this
+manual under the conditions for verbatim copying, provided that the entire
+resulting derived work is distributed under the terms of a permission
+notice identical to this one.
+
+Permission is granted to copy and distribute translations of this manual
+into another language, under the above conditions for modified versions,
+except that this permission notice may be stated in a translation approved
+by the Free Software Foundation.
+@end ifinfo
+
+@titlepage
+@title GNU Readline Library User Interface
+@subtitle Edition @value{EDITION}, for @code{Readline Library} Version @value{VERSION}.
+@subtitle @value{UPDATE-MONTH}
+@author Brian Fox, Free Software Foundation
+@author Chet Ramey, Case Western Reserve University
+
+@page
+This document describes the end user interface of the GNU Readline Library,
+a utility which aids in the consistency of user interface across discrete
+programs that need to provide a command line interface.
+
+Published by the Free Software Foundation @*
+59 Temple Place, Suite 330, @*
+Boston, MA 02111 USA
+
+Permission is granted to make and distribute verbatim copies of
+this manual provided the copyright notice and this permission notice
+are preserved on all copies.
+
+Permission is granted to copy and distribute modified versions of this
+manual under the conditions for verbatim copying, provided that the entire
+resulting derived work is distributed under the terms of a permission
+notice identical to this one.
+
+Permission is granted to copy and distribute translations of this manual
+into another language, under the above conditions for modified versions,
+except that this permission notice may be stated in a translation approved
+by the Free Software Foundation.
+
+@vskip 0pt plus 1filll
+Copyright @copyright{} 1988-1999 Free Software Foundation, Inc.
+@end titlepage
+
+@ifinfo
+@node Top
+@top GNU Readline Library
+
+This document describes the end user interface of the GNU Readline Library,
+a utility which aids in the consistency of user interface across discrete
+programs that need to provide a command line interface.
+
+@menu
+* Command Line Editing:: GNU Readline User's Manual.
+@end menu
+@end ifinfo
+
+@include rluser.texinfo
+
+@contents
+@bye
diff --git a/lib/readline/emacs_keymap.c b/lib/readline/emacs_keymap.c
index 4ba38584..daba213b 100644
--- a/lib/readline/emacs_keymap.c
+++ b/lib/readline/emacs_keymap.c
@@ -7,7 +7,7 @@
The GNU Readline Library is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 1, or
+ as published by the Free Software Foundation; either version 2, or
(at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be
@@ -18,7 +18,7 @@
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
- 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if !defined (BUFSIZ)
#include <stdio.h>
@@ -76,11 +76,7 @@ KEYMAP_ENTRY_ARRAY emacs_standard_keymap = {
{ ISFUNC, rl_insert }, /* & */
{ ISFUNC, rl_insert }, /* ' */
{ ISFUNC, rl_insert }, /* ( */
-#if defined (PAREN_MATCHING)
- { ISFUNC, rl_insert_close }, /* ) */
-#else
{ ISFUNC, rl_insert }, /* ) */
-#endif /* !PAREN_MATCHING */
{ ISFUNC, rl_insert }, /* * */
{ ISFUNC, rl_insert }, /* + */
{ ISFUNC, rl_insert }, /* , */
@@ -140,11 +136,7 @@ KEYMAP_ENTRY_ARRAY emacs_standard_keymap = {
/* Some more punctuation. */
{ ISFUNC, rl_insert }, /* [ */
{ ISFUNC, rl_insert }, /* \ */
-#if defined (PAREN_MATCHING)
- { ISFUNC, rl_insert_close }, /* ] */
-#else
{ ISFUNC, rl_insert }, /* ] */
-#endif /* !PAREN_MATCHING */
{ ISFUNC, rl_insert }, /* ^ */
{ ISFUNC, rl_insert }, /* _ */
{ ISFUNC, rl_insert }, /* ` */
@@ -180,11 +172,7 @@ KEYMAP_ENTRY_ARRAY emacs_standard_keymap = {
/* Final punctuation. */
{ ISFUNC, rl_insert }, /* { */
{ ISFUNC, rl_insert }, /* | */
-#if defined (PAREN_MATCHING)
- { ISFUNC, rl_insert_close }, /* } */
-#else
{ ISFUNC, rl_insert }, /* } */
-#endif /* !PAREN_MATCHING */
{ ISFUNC, rl_insert }, /* ~ */
{ ISFUNC, rl_rubout }, /* RUBOUT */
diff --git a/lib/readline/examples/Makefile b/lib/readline/examples/Makefile
index d72a15d2..d8df38c8 100644
--- a/lib/readline/examples/Makefile
+++ b/lib/readline/examples/Makefile
@@ -1,7 +1,23 @@
# This is the Makefile for the examples subdirectory of readline. -*- text -*-
#
+# Copyright (C) 1994 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
+
EXECUTABLES = fileman rltest rl
-CFLAGS = -g -I../.. -I..
+CFLAGS = -g -I../.. -I.. -DREADLINE_LIBRARY
LDFLAGS = -g -L..
.c.o:
diff --git a/lib/readline/examples/excallback.c b/lib/readline/examples/excallback.c
new file mode 100644
index 00000000..ca03fc3d
--- /dev/null
+++ b/lib/readline/examples/excallback.c
@@ -0,0 +1,186 @@
+/*
+From: Jeff Solomon <jsolomon@stanford.edu>
+Date: Fri, 9 Apr 1999 10:13:27 -0700 (PDT)
+To: chet@po.cwru.edu
+Subject: new readline example
+Message-ID: <14094.12094.527305.199695@mrclean.Stanford.EDU>
+
+Chet,
+
+I've been using readline 4.0. Specifically, I've been using the perl
+version Term::ReadLine::Gnu. It works great.
+
+Anyway, I've been playing around the alternate interface and I wanted
+to contribute a little C program, callback.c, to you that you could
+use as an example of the alternate interface in the /examples
+directory of the readline distribution.
+
+My example shows how, using the alternate interface, you can
+interactively change the prompt (which is very nice imo). Also, I
+point out that you must roll your own terminal setting when using the
+alternate interface because readline depreps (using your parlance) the
+terminal while in the user callback. I try to demostrate what I mean
+with an example. I've included the program below.
+
+To compile, I just put the program in the examples directory and made
+the appropriate changes to the EXECUTABLES and OBJECTS line and added
+an additional target 'callback'.
+
+I compiled on my Sun Solaris2.6 box using Sun's cc.
+
+Let me know what you think.
+
+Jeff
+*/
+
+#if defined (HAVE_CONFIG_H)
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <sys/types.h>
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#include <termios.h> /* xxx - should make this more general */
+
+#ifdef READLINE_LIBRARY
+# include "readline.h"
+#else
+# include <readline/readline.h>
+#endif
+
+/* This little examples demonstrates the alternate interface to using readline.
+ * In the alternate interface, the user maintains control over program flow and
+ * only calls readline when STDIN is readable. Using the alternate interface,
+ * you can do anything else while still using readline (like talking to a
+ * network or another program) without blocking.
+ *
+ * Specifically, this program highlights two importants features of the
+ * alternate interface. The first is the ability to interactively change the
+ * prompt, which can't be done using the regular interface since rl_prompt is
+ * read-only.
+ *
+ * The second feature really highlights a subtle point when using the alternate
+ * interface. That is, readline will not alter the terminal when inside your
+ * callback handler. So let's so, your callback executes a user command that
+ * takes a non-trivial amount of time to complete (seconds). While your
+ * executing the command, the user continues to type keystrokes and expects them
+ * to be re-echoed on the new prompt when it returns. Unfortunately, the default
+ * terminal configuration doesn't do this. After the prompt returns, the user
+ * must hit one additional keystroke and then will see all of his previous
+ * keystrokes. To illustrate this, compile and run this program. Type "sleep" at
+ * the prompt and then type "bar" before the prompt returns (you have 3
+ * seconds). Notice how "bar" is re-echoed on the prompt after the prompt
+ * returns? This is what you expect to happen. Now comment out the 4 lines below
+ * the line that says COMMENT LINE BELOW. Recompile and rerun the program and do
+ * the same thing. When the prompt returns, you should not see "bar". Now type
+ * "f", see how "barf" magically appears? This behavior is un-expected and not
+ * desired.
+ */
+
+void process_line(char *line);
+int change_prompt(void);
+char *get_prompt(void);
+
+int prompt = 1;
+char prompt_buf[40], line_buf[256];
+tcflag_t old_lflag;
+cc_t old_vtime;
+struct termios term;
+
+int
+main()
+{
+ fd_set fds;
+
+ /* Adjust the terminal slightly before the handler is installed. Disable
+ * canonical mode processing and set the input character time flag to be
+ * non-blocking.
+ */
+ if( tcgetattr(STDIN_FILENO, &term) < 0 ) {
+ perror("tcgetattr");
+ exit(1);
+ }
+ old_lflag = term.c_lflag;
+ old_vtime = term.c_cc[VTIME];
+ term.c_lflag &= ~ICANON;
+ term.c_cc[VTIME] = 1;
+ /* COMMENT LINE BELOW - see above */
+ if( tcsetattr(STDIN_FILENO, TCSANOW, &term) < 0 ) {
+ perror("tcsetattr");
+ exit(1);
+ }
+
+ rl_add_defun("change-prompt", change_prompt, CTRL('t'));
+ rl_callback_handler_install(get_prompt(), process_line);
+
+ while(1) {
+ FD_ZERO(&fds);
+ FD_SET(fileno(stdin), &fds);
+
+ if( select(FD_SETSIZE, &fds, NULL, NULL, NULL) < 0) {
+ perror("select");
+ exit(1);
+ }
+
+ if( FD_ISSET(fileno(stdin), &fds) ) {
+ rl_callback_read_char();
+ }
+ }
+}
+
+void
+process_line(char *line)
+{
+ if( line == NULL ) {
+ fprintf(stderr, "\n", line);
+
+ /* reset the old terminal setting before exiting */
+ term.c_lflag = old_lflag;
+ term.c_cc[VTIME] = old_vtime;
+ if( tcsetattr(STDIN_FILENO, TCSANOW, &term) < 0 ) {
+ perror("tcsetattr");
+ exit(1);
+ }
+ exit(0);
+ }
+
+ if( strcmp(line, "sleep") == 0 ) {
+ sleep(3);
+ } else {
+ fprintf(stderr, "|%s|\n", line);
+ }
+}
+
+int
+change_prompt(void)
+{
+ /* toggle the prompt variable */
+ prompt = !prompt;
+
+ /* save away the current contents of the line */
+ strcpy(line_buf, rl_line_buffer);
+
+ /* install a new handler which will change the prompt and erase the current line */
+ rl_callback_handler_install(get_prompt(), process_line);
+
+ /* insert the old text on the new line */
+ rl_insert_text(line_buf);
+
+ /* redraw the current line - this is an undocumented function. It invokes the
+ * redraw-current-line command.
+ */
+ rl_refresh_line(0, 0);
+}
+
+char *
+get_prompt(void)
+{
+ /* The prompts can even be different lengths! */
+ sprintf(prompt_buf, "%s",
+ prompt ? "Hit ctrl-t to toggle prompt> " : "Pretty cool huh?> ");
+ return prompt_buf;
+}
diff --git a/lib/readline/examples/fileman.c b/lib/readline/examples/fileman.c
index 0702a5ba..dc29a401 100644
--- a/lib/readline/examples/fileman.c
+++ b/lib/readline/examples/fileman.c
@@ -1,22 +1,22 @@
/* fileman.c -- A tiny application which demonstrates how to use the
GNU Readline library. This application interactively allows users
to manipulate files and their modes. */
-/*
- * Remove the next line if you're compiling this against an installed
- * libreadline.a
- */
-#define READLINE_LIBRARY
#ifdef HAVE_CONFIG_H
-#include <config.h>
+# include <config.h>
#endif
#include <sys/types.h>
#ifdef HAVE_SYS_FILE_H
-#include <sys/file.h>
+# include <sys/file.h>
#endif
#include <sys/stat.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+
+#include <fcntl.h>
#include <stdio.h>
#include <errno.h>
@@ -26,6 +26,10 @@
# include <strings.h>
#endif /* !HAVE_STRING_H */
+#ifdef HAVE_STDLIB_H
+# include <stdlib.h>
+#endif
+
#ifdef READLINE_LIBRARY
# include "readline.h"
# include "history.h"
@@ -34,7 +38,6 @@
# include <readline/history.h>
#endif
-extern char *getwd ();
extern char *xmalloc ();
/* The names of functions that actually do the manipulation. */
@@ -300,7 +303,12 @@ com_view (arg)
if (!valid_argument ("view", arg))
return 1;
+#if defined (__MSDOS__)
+ /* more.com doesn't grok slashes in pathnames */
+ sprintf (syscom, "less %s", arg);
+#else
sprintf (syscom, "more %s", arg);
+#endif
return (system (syscom));
}
@@ -406,7 +414,7 @@ com_pwd (ignore)
{
char dir[1024], *s;
- s = getwd (dir);
+ s = getcwd (dir, sizeof(dir) - 1);
if (s == 0)
{
printf ("Error getting pwd: %s\n", dir);
diff --git a/lib/readline/examples/rl.c b/lib/readline/examples/rl.c
index 17a63434..2d1d17e6 100644
--- a/lib/readline/examples/rl.c
+++ b/lib/readline/examples/rl.c
@@ -2,15 +2,9 @@
* rl - command-line interface to read a line from the standard input
* (or another fd) using readline.
*
- * usage: rl [-p prompt] [-u unit] [-d default]
+ * usage: rl [-p prompt] [-u unit] [-d default] [-n nchars]
*/
-/*
- * Remove the next line if you're compiling this against an installed
- * libreadline.a
- */
-#define READLINE_LIBRARY
-
#if defined (HAVE_CONFIG_H)
# include <config.h>
#endif
@@ -18,8 +12,14 @@
#include <stdio.h>
#include <sys/types.h>
#include "posixstat.h"
-#include "readline.h"
-#include "history.h"
+
+#if defined (READLINE_LIBRARY)
+# include "readline.h"
+# include "history.h"
+#else
+# include <readline/readline.h>
+# include <readline/history.h>
+#endif
extern int optind;
extern char *optarg;
@@ -40,22 +40,24 @@ set_deftext ()
deftext = (char *)NULL;
rl_startup_hook = (Function *)NULL;
}
+ return 0;
}
static void
usage()
{
- fprintf (stderr, "%s: usage: %s [-p prompt] [-u unit] [-d default]\n",
+ fprintf (stderr, "%s: usage: %s [-p prompt] [-u unit] [-d default] [-n nchars]\n",
progname, progname);
}
+int
main (argc, argv)
int argc;
char **argv;
{
char *temp, *prompt;
struct stat sb;
- int opt, fd;
+ int opt, fd, nch;
FILE *ifp;
progname = strrchr(argv[0], '/');
@@ -66,10 +68,10 @@ main (argc, argv)
/* defaults */
prompt = "readline$ ";
- fd = 0;
+ fd = nch = 0;
deftext = (char *)0;
- while ((opt = getopt(argc, argv, "p:u:d:")) != EOF)
+ while ((opt = getopt(argc, argv, "p:u:d:n:")) != EOF)
{
switch (opt)
{
@@ -87,6 +89,14 @@ main (argc, argv)
case 'd':
deftext = optarg;
break;
+ case 'n':
+ nch = atoi(optarg);
+ if (nch < 0)
+ {
+ fprintf (stderr, "%s: bad value for -n: `%s'\n", progname, optarg);
+ exit (2);
+ }
+ break;
default:
usage ();
exit (2);
@@ -107,6 +117,9 @@ main (argc, argv)
if (deftext && *deftext)
rl_startup_hook = set_deftext;
+ if (nch > 0)
+ rl_num_chars_to_read = nch;
+
temp = readline (prompt);
/* Test for EOF. */
diff --git a/lib/readline/examples/rltest.c b/lib/readline/examples/rltest.c
index 453f8ec2..6250f900 100644
--- a/lib/readline/examples/rltest.c
+++ b/lib/readline/examples/rltest.c
@@ -4,20 +4,20 @@
/* */
/* **************************************************************** */
-/*
- * Remove the next line if you're compiling this against an installed
- * libreadline.a
- */
-#define READLINE_LIBRARY
-
#if defined (HAVE_CONFIG_H)
#include <config.h>
#endif
#include <stdio.h>
#include <sys/types.h>
-#include "readline.h"
-#include "history.h"
+
+#ifdef READLINE_LIBRARY
+# include "readline.h"
+# include "history.h"
+#else
+# include <readline/readline.h>
+# include <readline/history.h>
+#endif
extern HIST_ENTRY **history_list ();
diff --git a/lib/readline/funmap.c b/lib/readline/funmap.c
index f6b86286..1f7ba871 100644
--- a/lib/readline/funmap.c
+++ b/lib/readline/funmap.c
@@ -7,7 +7,7 @@
The GNU Readline Library is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 1, or
+ as published by the Free Software Foundation; either version 2, or
(at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be
@@ -18,15 +18,13 @@
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
- 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
# include <config.h>
#endif
-extern char *xmalloc (), *xrealloc ();
-
#if !defined (BUFSIZ)
#include <stdio.h>
#endif /* BUFSIZ */
@@ -40,6 +38,14 @@ extern char *xmalloc (), *xrealloc ();
#include "rlconf.h"
#include "readline.h"
+#include "xmalloc.h"
+
+#ifdef __STDC__
+typedef int QSFUNC (const void *, const void *);
+#else
+typedef int QSFUNC ();
+#endif
+
extern int _rl_qsort_string_compare ();
FUNMAP **funmap;
@@ -240,7 +246,7 @@ rl_funmap_names ()
result[result_index + 1] = (char *)NULL;
}
- qsort (result, result_index, sizeof (char *), _rl_qsort_string_compare);
+ qsort (result, result_index, sizeof (char *), (QSFUNC *)_rl_qsort_string_compare);
return (result);
}
diff --git a/lib/readline/histexpand.c b/lib/readline/histexpand.c
index 392e6d38..78da3e58 100644
--- a/lib/readline/histexpand.c
+++ b/lib/readline/histexpand.c
@@ -7,7 +7,7 @@
The Library is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 1, or (at your option)
+ the Free Software Foundation; either version 2, or (at your option)
any later version.
The Library is distributed in the hope that it will be useful, but
@@ -18,7 +18,7 @@
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
- 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#define READLINE_LIBRARY
@@ -50,6 +50,9 @@
#include "history.h"
#include "histlib.h"
+#include "rlshell.h"
+#include "xmalloc.h"
+
#define HISTORY_WORD_DELIMITERS " \t\n;&()|<>"
#define HISTORY_QUOTE_CHARACTERS "\"'`"
@@ -60,15 +63,10 @@ static char *subst_rhs;
static int subst_lhs_len;
static int subst_rhs_len;
-static char *get_history_word_specifier ();
-static char *history_find_word ();
-
-extern int history_offset;
-
-extern char *single_quote ();
-static char *quote_breaks ();
+static char *get_history_word_specifier __P((char *, char *, int *));
+static char *history_find_word __P((char *, int));
-extern char *xmalloc (), *xrealloc ();
+static char *quote_breaks __P((char *));
/* Variables exported by this file. */
/* The character that represents the start of a history expansion
diff --git a/lib/readline/histfile.c b/lib/readline/histfile.c
index 3325b7fc..b908e226 100644
--- a/lib/readline/histfile.c
+++ b/lib/readline/histfile.c
@@ -7,7 +7,7 @@
The Library is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 1, or (at your option)
+ the Free Software Foundation; either version 2, or (at your option)
any later version.
The Library is distributed in the hope that it will be useful, but
@@ -18,7 +18,7 @@
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
- 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
/* The goal is to make the implementation transparent, so that you
don't have to know what data types are used, just what functions
@@ -35,7 +35,7 @@
#ifndef _MINIX
# include <sys/file.h>
#endif
-#include <sys/stat.h>
+#include "posixstat.h"
#include <fcntl.h>
#if defined (HAVE_STDLIB_H)
@@ -54,15 +54,19 @@
# include <strings.h>
#endif /* !HAVE_STRING_H */
-#if defined (__EMX__)
+
+/* If we're compiling for __EMX__ (OS/2) or __CYGWIN__ (cygwin32 environment
+ on win 95/98/nt), we want to open files with O_BINARY mode so that there
+ is no \n -> \r\n conversion performed. On other systems, we don't want to
+ mess around with O_BINARY at all, so we ensure that it's defined to 0. */
+#if defined (__EMX__) || defined (__CYGWIN__)
# ifndef O_BINARY
# define O_BINARY 0
# endif
-#else /* !__EMX__ */
- /* If we're not compiling for __EMX__, we don't want this at all. Ever. */
+#else /* !__EMX__ && !__CYGWIN__ */
# undef O_BINARY
# define O_BINARY 0
-#endif /* !__EMX__ */
+#endif /* !__EMX__ && !__CYGWIN__ */
#include <errno.h>
#if !defined (errno)
@@ -72,10 +76,8 @@ extern int errno;
#include "history.h"
#include "histlib.h"
-/* Functions imported from shell.c */
-extern char *get_env_value ();
-
-extern char *xmalloc (), *xrealloc ();
+#include "rlshell.h"
+#include "xmalloc.h"
/* Return the string that should be used in the place of this
filename. This only matters when you don't specify the
@@ -105,7 +107,11 @@ history_filename (filename)
return_val = xmalloc (2 + home_len + 8); /* strlen(".history") == 8 */
strcpy (return_val, home);
return_val[home_len] = '/';
+#if defined (__MSDOS__)
+ strcpy (return_val + home_len + 1, "_history");
+#else
strcpy (return_val + home_len + 1, ".history");
+#endif
return (return_val);
}
@@ -132,7 +138,7 @@ read_history_range (filename, from, to)
{
register int line_start, line_end;
char *input, *buffer;
- int file, current_line;
+ int file, current_line, chars_read;
struct stat finfo;
size_t file_size;
@@ -155,11 +161,9 @@ read_history_range (filename, from, to)
}
buffer = xmalloc (file_size + 1);
-#if 0
- if (read (file, buffer, file_size) != file_size)
-#else
- if (read (file, buffer, file_size) < 0)
-#endif
+
+ chars_read = read (file, buffer, file_size);
+ if (chars_read < 0)
{
error_and_exit:
if (file >= 0)
@@ -175,15 +179,15 @@ read_history_range (filename, from, to)
/* Set TO to larger than end of file if negative. */
if (to < 0)
- to = file_size;
+ to = chars_read;
/* Start at beginning of file, work to end. */
line_start = line_end = current_line = 0;
/* Skip lines until we are at FROM. */
- while (line_start < file_size && current_line < from)
+ while (line_start < chars_read && current_line < from)
{
- for (line_end = line_start; line_end < file_size; line_end++)
+ for (line_end = line_start; line_end < chars_read; line_end++)
if (buffer[line_end] == '\n')
{
current_line++;
@@ -194,7 +198,7 @@ read_history_range (filename, from, to)
}
/* If there are lines left to gobble, then gobble them now. */
- for (line_end = line_start; line_end < file_size; line_end++)
+ for (line_end = line_start; line_end < chars_read; line_end++)
if (buffer[line_end] == '\n')
{
buffer[line_end] = '\0';
@@ -236,6 +240,10 @@ history_truncate_file (fname, lines)
if (file == -1 || fstat (file, &finfo) == -1)
goto truncate_exit;
+ /* Don't try to truncate non-regular files. */
+ if (S_ISREG(finfo.st_mode) == 0)
+ goto truncate_exit;
+
file_size = (size_t)finfo.st_size;
/* check for overflow on very large files */
@@ -279,11 +287,11 @@ history_truncate_file (fname, lines)
truncate to. */
if (i && ((file = open (filename, O_WRONLY|O_TRUNC|O_BINARY, 0600)) != -1))
{
- write (file, buffer + i, file_size - i);
+ write (file, buffer + i, chars_read - i);
#if defined (__BEOS__)
/* BeOS ignores O_TRUNC. */
- ftruncate (file, file_size - i);
+ ftruncate (file, chars_read - i);
#endif
close (file);
diff --git a/lib/readline/histlib.h b/lib/readline/histlib.h
index 422cf597..88a34d10 100644
--- a/lib/readline/histlib.h
+++ b/lib/readline/histlib.h
@@ -6,7 +6,7 @@
The Library is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 1, or (at your option)
+ the Free Software Foundation; either version 2, or (at your option)
any later version.
The Library is distributed in the hope that it will be useful, but
@@ -17,7 +17,7 @@
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
- 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if !defined (_HISTLIB_H_)
#define _HISTLIB_H_
@@ -31,8 +31,11 @@ typedef char *CPFunction ();
typedef char **CPPFunction ();
#endif /* _FUNCTION_DEF */
+#if !defined (STREQ)
#define STREQ(a, b) (((a)[0] == (b)[0]) && (strcmp ((a), (b)) == 0))
-#define STREQN(a, b, n) (((a)[0] == (b)[0]) && (strncmp ((a), (b), (n)) == 0))
+#define STREQN(a, b, n) (((n) == 0) ? (1) \
+ : ((a)[0] == (b)[0]) && (strncmp ((a), (b), (n)) == 0))
+#endif
#ifndef savestring
# ifndef strcpy
@@ -79,4 +82,7 @@ extern char *strchr ();
#define HISTORY_APPEND 0
#define HISTORY_OVERWRITE 1
+/* Some variable definitions shared across history source files. */
+extern int history_offset;
+
#endif /* !_HISTLIB_H_ */
diff --git a/lib/readline/history.c b/lib/readline/history.c
index d56ffacc..400f18bc 100644
--- a/lib/readline/history.c
+++ b/lib/readline/history.c
@@ -7,7 +7,7 @@
The Library is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 1, or (at your option)
+ the Free Software Foundation; either version 2, or (at your option)
any later version.
The Library is distributed in the hope that it will be useful, but
@@ -18,7 +18,7 @@
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
- 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
/* The goal is to make the implementation transparent, so that you
don't have to know what data types are used, just what functions
@@ -53,7 +53,7 @@
#include "history.h"
#include "histlib.h"
-extern char *xmalloc (), *xrealloc ();
+#include "xmalloc.h"
/* The number of slots to increase the_history by. */
#define DEFAULT_HISTORY_GROW_SIZE 50
diff --git a/lib/readline/history.h b/lib/readline/history.h
index 8ecce726..5210deb3 100644
--- a/lib/readline/history.h
+++ b/lib/readline/history.h
@@ -6,7 +6,7 @@
The Library is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 1, or (at your option)
+ the Free Software Foundation; either version 2, or (at your option)
any later version.
The Library is distributed in the hope that it will be useful, but
@@ -17,7 +17,7 @@
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
- 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#ifndef _HISTORY_H_
#define _HISTORY_H_
@@ -119,7 +119,7 @@ extern int where_history __P((void));
/* Return the history entry at the current position, as determined by
history_offset. If there is no entry there, return a NULL pointer. */
-HIST_ENTRY *current_history __P((void));
+extern HIST_ENTRY *current_history __P((void));
/* Return the history entry which is logically at OFFSET in the history
array. OFFSET is relative to history_base. */
@@ -132,7 +132,7 @@ extern int history_total_bytes __P((void));
/* Moving around the history list. */
/* Set the position in the history list to POS. */
-int history_set_pos __P((int));
+extern int history_set_pos __P((int));
/* Back up history_offset to the previous history entry, and return
a pointer to that entry. If there is no previous entry, return
@@ -187,7 +187,7 @@ extern int write_history __P((char *));
/* Append NELEMENT entries to FILENAME. The entries appended are from
the end of the list minus NELEMENTs up to the end of the list. */
-int append_history __P((int, char *));
+extern int append_history __P((int, char *));
/* Truncate the history file, leaving only the last NLINES lines. */
extern int history_truncate_file __P((char *, int));
diff --git a/lib/readline/histsearch.c b/lib/readline/histsearch.c
index 7e98e950..8d153b63 100644
--- a/lib/readline/histsearch.c
+++ b/lib/readline/histsearch.c
@@ -7,7 +7,7 @@
The Library is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 1, or (at your option)
+ the Free Software Foundation; either version 2, or (at your option)
any later version.
The Library is distributed in the hope that it will be useful, but
@@ -18,7 +18,7 @@
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
- 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#define READLINE_LIBRARY
@@ -47,9 +47,6 @@
#include "history.h"
#include "histlib.h"
-/* Variables imported from other history library files. */
-extern int history_offset;
-
/* The list of alternate characters that can delimit a history search
string. */
char *history_search_delimiter_chars = (char *)NULL;
diff --git a/lib/readline/input.c b/lib/readline/input.c
index 3b48483d..64a55c6f 100644
--- a/lib/readline/input.c
+++ b/lib/readline/input.c
@@ -18,7 +18,7 @@
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
- 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
@@ -67,39 +67,15 @@ extern int errno;
/* Some standard library routines. */
#include "readline.h"
+#include "rlprivate.h"
+#include "rlshell.h"
+#include "xmalloc.h"
+
/* What kind of non-blocking I/O do we have? */
#if !defined (O_NDELAY) && defined (O_NONBLOCK)
# define O_NDELAY O_NONBLOCK /* Posix style */
#endif
-/* Functions imported from other files in the library. */
-extern char *xmalloc (), *xrealloc ();
-
-/* Variables and functions from macro.c. */
-extern void _rl_add_macro_char ();
-extern void _rl_with_macro_input ();
-extern int _rl_next_macro_key ();
-extern int _rl_defining_kbd_macro;
-
-#if defined (VI_MODE)
-extern void _rl_vi_set_last ();
-extern int _rl_vi_textmod_command ();
-#endif /* VI_MODE */
-
-extern FILE *rl_instream, *rl_outstream;
-extern Function *rl_last_func;
-extern int rl_key_sequence_length;
-extern int rl_pending_input;
-extern int rl_editing_mode;
-
-extern Keymap _rl_keymap;
-
-extern int _rl_convert_meta_chars_to_ascii;
-
-#if defined (__GO32__)
-# include <pc.h>
-#endif /* __GO32__ */
-
/* Non-null means it is a pointer to a function to run while waiting for
character input. */
Function *rl_event_hook = (Function *)NULL;
@@ -176,17 +152,6 @@ rl_unget_char (key)
static void
rl_gather_tyi ()
{
-#if defined (__GO32__)
- char input;
-
- if (isatty (0) && kbhit () && ibuffer_space ())
- {
- int i;
- i = (*rl_getc_function) (rl_instream);
- rl_stuff_char (i);
- }
-#else /* !__GO32__ */
-
int tty;
register int tem, result;
int chars_avail;
@@ -255,7 +220,6 @@ rl_gather_tyi ()
if (chars_avail)
rl_stuff_char (input);
}
-#endif /* !__GO32__ */
}
/* Is there input available to be read on the readline input file
@@ -394,14 +358,9 @@ int
rl_getc (stream)
FILE *stream;
{
- int result, flags;
+ int result;
unsigned char c;
-#if defined (__GO32__)
- if (isatty (0))
- return (getkey () & 0x7F);
-#endif /* __GO32__ */
-
while (1)
{
result = read (fileno (stream), &c, sizeof (unsigned char));
@@ -420,40 +379,31 @@ rl_getc (stream)
#endif
#if defined (EWOULDBLOCK)
- if (errno == EWOULDBLOCK)
+# define X_EWOULDBLOCK EWOULDBLOCK
+#else
+# define X_EWOULDBLOCK -99
+#endif
+
+#if defined (EAGAIN)
+# define X_EAGAIN EAGAIN
+#else
+# define X_EAGAIN -99
+#endif
+
+ if (errno == X_EWOULDBLOCK || errno == X_EAGAIN)
{
- if ((flags = fcntl (fileno (stream), F_GETFL, 0)) < 0)
+ if (unset_nodelay_mode (fileno (stream)) < 0)
return (EOF);
- if (flags & O_NDELAY)
- {
- flags &= ~O_NDELAY;
- fcntl (fileno (stream), F_SETFL, flags);
- continue;
- }
continue;
}
-#endif /* EWOULDBLOCK */
-#if defined (_POSIX_VERSION) && defined (EAGAIN) && defined (O_NONBLOCK)
- if (errno == EAGAIN)
- {
- if ((flags = fcntl (fileno (stream), F_GETFL, 0)) < 0)
- return (EOF);
- if (flags & O_NONBLOCK)
- {
- flags &= ~O_NONBLOCK;
- fcntl (fileno (stream), F_SETFL, flags);
- continue;
- }
- }
-#endif /* _POSIX_VERSION && EAGAIN && O_NONBLOCK */
+#undef X_EWOULDBLOCK
+#undef X_EAGAIN
-#if !defined (__GO32__)
/* If the error that we received was SIGINT, then try again,
this is simply an interrupted system call to read ().
Otherwise, some error ocurred, also signifying EOF. */
if (errno != EINTR)
return (EOF);
-#endif /* !__GO32__ */
}
}
diff --git a/lib/readline/isearch.c b/lib/readline/isearch.c
index 67279e18..952c10dd 100644
--- a/lib/readline/isearch.c
+++ b/lib/readline/isearch.c
@@ -12,7 +12,7 @@
The Library is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 1, or (at your option)
+ the Free Software Foundation; either version 2, or (at your option)
any later version.
The Library is distributed in the hope that it will be useful, but
@@ -23,7 +23,7 @@
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
- 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
@@ -48,24 +48,17 @@
#include "readline.h"
#include "history.h"
+#include "rlprivate.h"
+#include "xmalloc.h"
+
/* Variables exported to other files in the readline library. */
unsigned char *_rl_isearch_terminators = (unsigned char *)NULL;
/* Variables imported from other files in the readline library. */
-extern Keymap _rl_keymap;
extern HIST_ENTRY *saved_line_for_history;
-extern int rl_line_buffer_len;
-extern int rl_point, rl_end;
-extern char *rl_line_buffer;
-
-extern int rl_execute_next ();
-extern void rl_extend_line_buffer ();
-
-extern int _rl_input_available ();
-
-extern char *xmalloc (), *xrealloc ();
-static int rl_search_history ();
+/* Forward declarations */
+static int rl_search_history __P((int, int));
/* Last line found by the current incremental search, so we don't `find'
identical lines many times in a row. */
diff --git a/lib/readline/keymaps.c b/lib/readline/keymaps.c
index c73666bf..8fb7de3b 100644
--- a/lib/readline/keymaps.c
+++ b/lib/readline/keymaps.c
@@ -7,7 +7,7 @@
Readline is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
- Free Software Foundation; either version 1, or (at your option) any
+ Free Software Foundation; either version 2, or (at your option) any
later version.
Readline is distributed in the hope that it will be useful, but
@@ -17,7 +17,7 @@
You should have received a copy of the GNU General Public License
along with Readline; see the file COPYING. If not, write to the Free
- Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
@@ -30,18 +30,18 @@
# include "ansi_stdlib.h"
#endif /* HAVE_STDLIB_H */
+#include <stdio.h> /* for FILE * definition for readline.h */
+
+#include "readline.h"
#include "rlconf.h"
-#include "keymaps.h"
+
#include "emacs_keymap.c"
#if defined (VI_MODE)
#include "vi_keymap.c"
#endif
-extern int rl_do_lowercase_version ();
-extern int rl_rubout (), rl_insert ();
-
-extern char *xmalloc (), *xrealloc ();
+#include "xmalloc.h"
/* **************************************************************** */
/* */
diff --git a/lib/readline/keymaps.h b/lib/readline/keymaps.h
index 5dff46f5..3a504fb0 100644
--- a/lib/readline/keymaps.h
+++ b/lib/readline/keymaps.h
@@ -7,7 +7,7 @@
The GNU Readline Library is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 1, or
+ as published by the Free Software Foundation; either version 2, or
(at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be
@@ -18,11 +18,15 @@
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
- 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#ifndef _KEYMAPS_H_
#define _KEYMAPS_H_
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#if defined (READLINE_LIBRARY)
# include "rlstdc.h"
# include "chardefs.h"
@@ -97,4 +101,8 @@ extern Keymap rl_get_keymap __P((void));
/* Set the current keymap to MAP. */
extern void rl_set_keymap __P((Keymap));
+#ifdef __cplusplus
+}
+#endif
+
#endif /* _KEYMAPS_H_ */
diff --git a/lib/readline/kill.c b/lib/readline/kill.c
index 0b4714fa..c3241bda 100644
--- a/lib/readline/kill.c
+++ b/lib/readline/kill.c
@@ -7,7 +7,7 @@
The GNU Readline Library is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 1, or
+ as published by the Free Software Foundation; either version 2, or
(at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be
@@ -18,7 +18,7 @@
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
- 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
@@ -46,17 +46,8 @@
#include "readline.h"
#include "history.h"
-extern int _rl_last_command_was_kill;
-extern int rl_editing_mode;
-extern int rl_explicit_arg;
-extern Function *rl_last_func;
-
-extern void _rl_init_argument ();
-extern int _rl_set_mark_at_pos ();
-extern void _rl_fix_point ();
-extern void _rl_abort_internal ();
-
-extern char *xmalloc (), *xrealloc ();
+#include "rlprivate.h"
+#include "xmalloc.h"
/* **************************************************************** */
/* */
@@ -385,10 +376,12 @@ int
rl_kill_region (count, ignore)
int count, ignore;
{
- int r;
+ int r, npoint;
+ npoint = (rl_point < rl_mark) ? rl_point : rl_mark;
r = region_kill_internal (1);
_rl_fix_point (1);
+ rl_point = npoint;
return r;
}
@@ -503,7 +496,9 @@ rl_yank_nth_arg_internal (count, ignore, history_skip)
{
register HIST_ENTRY *entry;
char *arg;
- int i;
+ int i, pos;
+
+ pos = where_history ();
if (history_skip)
{
@@ -512,16 +507,10 @@ rl_yank_nth_arg_internal (count, ignore, history_skip)
}
entry = previous_history ();
- if (entry)
- {
- if (history_skip)
- {
- for (i = 0; i < history_skip; i++)
- next_history ();
- }
- next_history ();
- }
- else
+
+ history_set_pos (pos);
+
+ if (entry == 0)
{
ding ();
return -1;
diff --git a/lib/readline/macro.c b/lib/readline/macro.c
index f3c442b4..5a44852f 100644
--- a/lib/readline/macro.c
+++ b/lib/readline/macro.c
@@ -7,7 +7,7 @@
The GNU Readline Library is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 1, or
+ as published by the Free Software Foundation; either version 2, or
(at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be
@@ -18,7 +18,7 @@
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
- 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
@@ -46,19 +46,10 @@
#include "readline.h"
#include "history.h"
-#define SWAP(s, e) do { int t; t = s; s = e; e = t; } while (0)
-
-/* Forward definitions. */
-void _rl_push_executing_macro (), _rl_pop_executing_macro ();
-void _rl_add_macro_char ();
-
-/* Extern declarations. */
-extern int rl_explicit_arg;
-extern int rl_key_sequence_length;
+#include "rlprivate.h"
+#include "xmalloc.h"
-extern void _rl_abort_internal ();
-
-extern char *xmalloc (), *xrealloc ();
+#define SWAP(s, e) do { int t; t = s; s = e; e = t; } while (0)
/* **************************************************************** */
/* */
diff --git a/lib/readline/nls.c b/lib/readline/nls.c
index f2d413d5..67bed8a6 100644
--- a/lib/readline/nls.c
+++ b/lib/readline/nls.c
@@ -7,7 +7,7 @@
The GNU Readline Library is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 1, or
+ as published by the Free Software Foundation; either version 2, or
(at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be
@@ -18,7 +18,7 @@
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
- 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
@@ -27,6 +27,8 @@
#include <sys/types.h>
+#include <stdio.h>
+
#if defined (HAVE_UNISTD_H)
# include <unistd.h>
#endif /* HAVE_UNISTD_H */
@@ -44,13 +46,9 @@
#include <ctype.h>
#include "rldefs.h"
-
-extern int _rl_convert_meta_chars_to_ascii;
-extern int _rl_output_meta_chars;
-extern int _rl_meta_flag;
-
-/* Functions imported from shell.c */
-extern char *get_env_value ();
+#include "readline.h"
+#include "rlshell.h"
+#include "rlprivate.h"
#if !defined (HAVE_SETLOCALE)
/* A list of legal values for the LANG or LC_CTYPE environment variables.
@@ -70,12 +68,11 @@ static char *legal_lang_values[] =
"iso88599",
"iso885910",
"koi8r",
- "koi8-r",
0
};
-static char *normalize_codeset ();
-static char *find_codeset ();
+static char *normalize_codeset __P((char *));
+static char *find_codeset __P((char *, size_t *));
#endif /* !HAVE_SETLOCALE */
/* Check for LC_ALL, LC_CTYPE, and LANG and use the first with a value
diff --git a/lib/readline/parens.c b/lib/readline/parens.c
index a500c0af..b6de529f 100644
--- a/lib/readline/parens.c
+++ b/lib/readline/parens.c
@@ -7,7 +7,7 @@
The GNU Readline Library is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 1, or
+ as published by the Free Software Foundation; either version 2, or
(at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be
@@ -18,23 +18,11 @@
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
- 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#define READLINE_LIBRARY
#include "rlconf.h"
-#if !defined (PAREN_MATCHING)
-extern int rl_insert ();
-
-int
-rl_insert_close (count, invoking_key)
- int count, invoking_key;
-{
- return (rl_insert (count, invoking_key));
-}
-
-#else /* PAREN_MATCHING */
-
#if defined (HAVE_CONFIG_H)
# include <config.h>
#endif
@@ -64,8 +52,9 @@ extern char *strchr (), *strrchr ();
#endif /* !strchr && !__STDC__ */
#include "readline.h"
+#include "rlprivate.h"
-extern int rl_explicit_arg;
+static int find_matching_open __P((char *, int, int));
/* Non-zero means try to blink the matching open parenthesis when the
close parenthesis is inserted. */
@@ -75,7 +64,25 @@ int rl_blink_matching_paren = 1;
int rl_blink_matching_paren = 0;
#endif /* !HAVE_SELECT */
-static int find_matching_open ();
+/* Change emacs_standard_keymap to have bindings for paren matching when
+ ON_OR_OFF is 1, change them back to self_insert when ON_OR_OFF == 0. */
+void
+_rl_enable_paren_matching (on_or_off)
+ int on_or_off;
+{
+ if (on_or_off)
+ { /* ([{ */
+ rl_bind_key_in_map (')', rl_insert_close, emacs_standard_keymap);
+ rl_bind_key_in_map (']', rl_insert_close, emacs_standard_keymap);
+ rl_bind_key_in_map ('}', rl_insert_close, emacs_standard_keymap);
+ }
+ else
+ { /* ([{ */
+ rl_bind_key_in_map (')', rl_insert, emacs_standard_keymap);
+ rl_bind_key_in_map (']', rl_insert, emacs_standard_keymap);
+ rl_bind_key_in_map ('}', rl_insert, emacs_standard_keymap);
+ }
+}
int
rl_insert_close (count, invoking_key)
@@ -152,5 +159,3 @@ find_matching_open (string, from, closer)
}
return (i);
}
-
-#endif /* PAREN_MATCHING */
diff --git a/lib/readline/posixdir.h b/lib/readline/posixdir.h
index 7480a93d..98ced75b 100644
--- a/lib/readline/posixdir.h
+++ b/lib/readline/posixdir.h
@@ -6,7 +6,7 @@
Bash is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 1, or (at your option)
+ the Free Software Foundation; either version 2, or (at your option)
any later version.
Bash is distributed in the hope that it will be useful, but WITHOUT
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with Bash; see the file COPYING. If not, write to the Free
- Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
/* This file should be included instead of <dirent.h> or <sys/dir.h>. */
diff --git a/lib/readline/posixjmp.h b/lib/readline/posixjmp.h
index 1347cc07..b52aa003 100644
--- a/lib/readline/posixjmp.h
+++ b/lib/readline/posixjmp.h
@@ -1,5 +1,23 @@
/* posixjmp.h -- wrapper for setjmp.h with changes for POSIX systems. */
+/* 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 2, or (at your option)
+ any later version.
+
+ Bash is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
+ License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Bash; see the file COPYING. If not, write to the Free
+ Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+
#ifndef _POSIXJMP_H_
#define _POSIXJMP_H_
diff --git a/lib/readline/posixstat.h b/lib/readline/posixstat.h
index bfce8c04..c93b5288 100644
--- a/lib/readline/posixstat.h
+++ b/lib/readline/posixstat.h
@@ -7,7 +7,7 @@
Bash is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 1, or (at your option)
+ the Free Software Foundation; either version 2, or (at your option)
any later version.
Bash is distributed in the hope that it will be useful, but WITHOUT
@@ -17,7 +17,7 @@
You should have received a copy of the GNU General Public License
along with Bash; see the file COPYING. If not, write to the Free
- Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
/* This file should be included instead of <sys/stat.h>.
It relies on the local sys/stat.h to work though. */
diff --git a/lib/readline/readline.c b/lib/readline/readline.c
index 622811fc..2c6aef68 100644
--- a/lib/readline/readline.c
+++ b/lib/readline/readline.c
@@ -8,7 +8,7 @@
The GNU Readline Library is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 1, or
+ as published by the Free Software Foundation; either version 2, or
(at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be
@@ -19,7 +19,7 @@
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
- 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
@@ -47,7 +47,6 @@
# include <locale.h>
#endif
-#include <signal.h>
#include <stdio.h>
#include "posixjmp.h"
@@ -63,117 +62,27 @@
#include "readline.h"
#include "history.h"
+#include "rlprivate.h"
+#include "rlshell.h"
+#include "xmalloc.h"
+
#ifndef RL_LIBRARY_VERSION
-# define RL_LIBRARY_VERSION "4.0"
+# define RL_LIBRARY_VERSION "4.1"
#endif
/* Evaluates its arguments multiple times. */
#define SWAP(s, e) do { int t; t = s; s = e; e = t; } while (0)
-/* NOTE: Functions and variables prefixed with `_rl_' are
- pseudo-global: they are global so they can be shared
- between files in the readline library, but are not intended
- to be visible to readline callers. */
-
-/* Variables and functions imported from terminal.c */
-extern int _rl_init_terminal_io ();
-extern void _rl_enable_meta_key ();
-#ifdef _MINIX
-extern void _rl_output_character_function ();
-#else
-extern int _rl_output_character_function ();
-#endif
-
-extern int _rl_enable_meta;
-extern int _rl_term_autowrap;
-extern int screenwidth, screenheight, screenchars;
-
-/* Variables and functions imported from rltty.c. */
-extern void rl_prep_terminal (), rl_deprep_terminal ();
-extern void rltty_set_default_bindings ();
-
-/* Functions imported from util.c. */
-extern void _rl_abort_internal ();
-extern void rl_extend_line_buffer ();
-extern int alphabetic ();
-
-/* Functions imported from bind.c. */
-extern void _rl_bind_if_unbound ();
-
-/* Functions imported from input.c. */
-extern int _rl_any_typein ();
-extern void _rl_insert_typein ();
-extern int rl_read_key ();
-
-/* Functions imported from nls.c */
-extern int _rl_init_eightbit ();
-
-/* Functions imported from shell.c */
-extern char *get_env_value ();
-
-/* External redisplay functions and variables from display.c */
-extern void _rl_move_vert ();
-extern void _rl_update_final ();
-extern void _rl_clear_to_eol ();
-extern void _rl_clear_screen ();
-extern void _rl_erase_entire_line ();
-
-extern void _rl_erase_at_end_of_line ();
-extern void _rl_move_cursor_relative ();
-
-extern int _rl_vis_botlin;
-extern int _rl_last_c_pos;
-extern int _rl_horizontal_scroll_mode;
-extern int rl_display_fixed;
-extern int _rl_suppress_redisplay;
-extern char *rl_display_prompt;
-
-/* Variables imported from complete.c. */
-extern char *rl_completer_word_break_characters;
-extern char *rl_basic_word_break_characters;
-extern int rl_completion_query_items;
-extern int rl_complete_with_tilde_expansion;
-
-/* Variables and functions from macro.c. */
-extern void _rl_add_macro_char ();
-extern void _rl_with_macro_input ();
-extern int _rl_next_macro_key ();
-extern int _rl_defining_kbd_macro;
-
-#if defined (VI_MODE)
-/* Functions imported from vi_mode.c. */
-extern void _rl_vi_set_last ();
-extern void _rl_vi_reset_last ();
-extern void _rl_vi_done_inserting ();
-extern int _rl_vi_textmod_command ();
-extern void _rl_vi_initialize_line ();
-#endif /* VI_MODE */
-
-extern UNDO_LIST *rl_undo_list;
-extern int _rl_doing_an_undo;
-
/* Forward declarations used in this file. */
-void _rl_free_history_entry ();
+void _rl_free_history_entry __P((HIST_ENTRY *));
-int _rl_dispatch ();
-int _rl_init_argument ();
+static char *readline_internal __P((void));
+static void readline_initialize_everything __P((void));
+static void start_using_history __P((void));
+static void bind_arrow_keys __P((void));
+static int rl_change_case __P((int, int));
-static char *readline_internal ();
-static void readline_initialize_everything ();
-static void start_using_history ();
-static void bind_arrow_keys ();
-
-#if !defined (__GO32__)
-static void readline_default_bindings ();
-#endif /* !__GO32__ */
-
-#if defined (__GO32__)
-# include <go32.h>
-# include <pc.h>
-# undef HANDLE_SIGNALS
-#endif /* __GO32__ */
-
-extern char *xmalloc (), *xrealloc ();
+static void readline_default_bindings __P((void));
/* **************************************************************** */
/* */
@@ -183,6 +92,8 @@ extern char *xmalloc (), *xrealloc ();
char *rl_library_version = RL_LIBRARY_VERSION;
+int rl_gnu_readline_p = 1;
+
/* A pointer to the keymap that is currently in use.
By default, it is the standard emacs keymap. */
Keymap _rl_keymap = emacs_standard_keymap;
@@ -245,6 +156,10 @@ int readline_echoing_p = 1;
char *rl_prompt;
int rl_visible_prompt_length = 0;
+/* Set to non-zero by calling application if it has already printed rl_prompt
+ and does not want readline to do it the first time. */
+int rl_already_prompted = 0;
+
/* The number of characters read in order to type this complete command. */
int rl_key_sequence_length = 0;
@@ -290,6 +205,10 @@ Keymap rl_executing_keymap;
/* Non-zero means to erase entire line, including prompt, on empty input lines. */
int rl_erase_empty_line = 0;
+/* Non-zero means to read only this many characters rather than up to a
+ character bound to accept-line. */
+int rl_num_chars_to_read;
+
/* Line buffer and maintenence. */
char *rl_line_buffer = (char *)NULL;
int rl_line_buffer_len = 0;
@@ -369,6 +288,8 @@ readline (prompt)
STATIC_CALLBACK void
readline_internal_setup ()
{
+ char *nprompt;
+
_rl_in_stream = rl_instream;
_rl_out_stream = rl_outstream;
@@ -377,15 +298,20 @@ readline_internal_setup ()
if (readline_echoing_p == 0)
{
- if (rl_prompt)
+ if (rl_prompt && rl_already_prompted == 0)
{
- fprintf (_rl_out_stream, "%s", rl_prompt);
+ nprompt = _rl_strip_prompt (rl_prompt);
+ fprintf (_rl_out_stream, "%s", nprompt);
fflush (_rl_out_stream);
+ free (nprompt);
}
}
else
{
- rl_on_new_line ();
+ if (rl_prompt && rl_already_prompted)
+ rl_on_new_line_with_prompt ();
+ else
+ rl_on_new_line ();
(*rl_redisplay_function) ();
#if defined (VI_MODE)
if (rl_editing_mode == vi_mode)
@@ -477,7 +403,7 @@ readline_internal_charloop ()
}
lastc = c;
- _rl_dispatch (c, _rl_keymap);
+ _rl_dispatch ((unsigned char)c, _rl_keymap);
/* If there was no change in _rl_last_command_was_kill, then no kill
has taken place. Note that if input is pending we are reading
@@ -492,6 +418,12 @@ readline_internal_charloop ()
rl_vi_check ();
#endif /* VI_MODE */
+ if (rl_num_chars_to_read && rl_end >= rl_num_chars_to_read)
+ {
+ (*rl_redisplay_function) ();
+ rl_newline (1, '\n');
+ }
+
if (rl_done == 0)
(*rl_redisplay_function) ();
@@ -689,6 +621,7 @@ rl_initialize ()
return 0;
}
+#if 0
#if defined (__EMX__)
static void
_emx_build_environ ()
@@ -712,15 +645,18 @@ _emx_build_environ ()
*tp = 0;
}
#endif /* __EMX__ */
+#endif
/* Initialize the entire state of the world. */
static void
readline_initialize_everything ()
{
+#if 0
#if defined (__EMX__)
if (environ == 0)
_emx_build_environ ();
#endif
+#endif
/* Find out if we are running in Emacs. */
running_in_emacs = get_env_value ("EMACS") != (char *)0;
@@ -745,10 +681,8 @@ readline_initialize_everything ()
/* Initialize the terminal interface. */
_rl_init_terminal_io ((char *)NULL);
-#if !defined (__GO32__)
/* Bind tty characters to readline functions. */
readline_default_bindings ();
-#endif /* !__GO32__ */
/* Initialize the function names. */
rl_initialize_funmap ();
@@ -797,6 +731,17 @@ bind_arrow_keys_internal ()
{
Function *f;
+#if defined (__MSDOS__)
+ f = rl_function_of_keyseq ("\033[0A", _rl_keymap, (int *)NULL);
+ if (!f || f == rl_do_lowercase_version)
+ {
+ _rl_bind_if_unbound ("\033[0A", rl_get_previous_history);
+ _rl_bind_if_unbound ("\033[0B", rl_backward);
+ _rl_bind_if_unbound ("\033[0C", rl_forward);
+ _rl_bind_if_unbound ("\033[0D", rl_get_next_history);
+ }
+#endif
+
f = rl_function_of_keyseq ("\033[A", _rl_keymap, (int *)NULL);
if (!f || f == rl_do_lowercase_version)
{
@@ -1121,6 +1066,10 @@ rl_forward (count, key)
else
rl_point = end;
}
+
+ if (rl_end < 0)
+ rl_end = 0;
+
return 0;
}
@@ -1255,35 +1204,14 @@ int
rl_refresh_line (ignore1, ignore2)
int ignore1, ignore2;
{
- int curr_line, nleft;
+ int curr_line;
- /* Find out whether or not there might be invisible characters in the
- editing buffer. */
- if (rl_display_prompt == rl_prompt)
- nleft = _rl_last_c_pos - screenwidth - rl_visible_prompt_length;
- else
- nleft = _rl_last_c_pos - screenwidth;
-
- if (nleft > 0)
- curr_line = 1 + nleft / screenwidth;
- else
- curr_line = 0;
+ curr_line = _rl_current_display_line ();
_rl_move_vert (curr_line);
_rl_move_cursor_relative (0, the_line); /* XXX is this right */
-#if defined (__GO32__)
- {
- int row, col, width, row_start;
-
- ScreenGetCursor (&row, &col);
- width = ScreenCols ();
- row_start = ScreenPrimary + (row * width);
- memset (row_start + col, 0, (width - col) * 2);
- }
-#else /* !__GO32__ */
_rl_clear_to_eol (0); /* arg of 0 means to not use spaces */
-#endif /* !__GO32__ */
rl_forced_update_display ();
rl_display_fixed = 1;
@@ -1421,7 +1349,14 @@ rl_quoted_insert (count, key)
{
int c;
+#if defined (HANDLE_SIGNALS)
+ _rl_disable_tty_signals ();
+#endif
c = rl_read_key ();
+#if defined (HANDLE_SIGNALS)
+ _rl_restore_tty_signals ();
+#endif
+
return (rl_insert (count, c));
}
@@ -1615,8 +1550,6 @@ rl_insert_comment (count, key)
#define DownCase 2
#define CapCase 3
-static int rl_change_case ();
-
/* Uppercase the word at point. */
int
rl_upcase_word (count, key)
diff --git a/lib/readline/readline.h b/lib/readline/readline.h
index dba1a0fd..97c62fd1 100644
--- a/lib/readline/readline.h
+++ b/lib/readline/readline.h
@@ -7,7 +7,7 @@
The GNU Readline Library is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 1, or
+ as published by the Free Software Foundation; either version 2, or
(at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be
@@ -18,7 +18,7 @@
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
- 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if !defined (_READLINE_H_)
#define _READLINE_H_
@@ -192,7 +192,7 @@ extern int rl_noninc_reverse_search __P((int, int));
extern int rl_noninc_forward_search_again __P((int, int));
extern int rl_noninc_reverse_search_again __P((int, int));
-/* Not available unless readline is compiled -DPAREN_MATCHING. */
+/* Bindable command used when inserting a matching close character. */
extern int rl_insert_close __P((int, int));
/* Not available unless READLINE_CALLBACKS is defined. */
@@ -331,11 +331,12 @@ extern int rl_modifying __P((int, int));
/* Functions for redisplay. */
extern void rl_redisplay __P((void));
extern int rl_on_new_line __P((void));
+extern int rl_on_new_line_with_prompt __P((void));
extern int rl_forced_update_display __P((void));
extern int rl_clear_message __P((void));
extern int rl_reset_line_state __P((void));
-#if defined (__STDC__) && defined (USE_VARARGS) && defined (PREFER_STDARG)
+#if (defined (__STDC__) || defined (__cplusplus)) && defined (USE_VARARGS) && defined (PREFER_STDARG)
extern int rl_message (const char *, ...);
#else
extern int rl_message ();
@@ -405,6 +406,9 @@ extern char *filename_completion_function __P((char *, int));
/* The version of this incarnation of the readline library. */
extern char *rl_library_version;
+/* True if this is real GNU readline. */
+extern int rl_gnu_readline_p;
+
/* The name of the calling program. You should initialize this to
whatever was in argv[0]. It is used when parsing conditionals. */
extern char *rl_readline_name;
@@ -468,6 +472,15 @@ extern Keymap rl_binding_keymap;
rl_newline. */
extern int rl_erase_empty_line;
+/* If non-zero, the application has already printed the prompt (rl_prompt)
+ before calling readline, so readline should not output it the first time
+ redisplay is done. */
+extern int rl_already_prompted;
+
+/* A non-zero value means to read only this many characters rather than
+ up to a character bound to accept-line. */
+extern int rl_num_chars_to_read;
+
/* Variables to control readline signal handling. */
/* If non-zero, readline will install its own signal handlers for
SIGINT, SIGTERM, SIGQUIT, SIGALRM, SIGTSTP, SIGTTIN, and SIGTTOU. */
@@ -611,7 +624,7 @@ extern int rl_inhibit_completion;
#define MULT_MATCH 2
#if !defined (savestring)
-extern char *savestring (); /* XXX backwards compatibility */
+extern char *savestring __P((char *)); /* XXX backwards compatibility */
#endif
#ifdef __cplusplus
diff --git a/lib/readline/rlconf.h b/lib/readline/rlconf.h
index 1356fd87..d2ab7040 100644
--- a/lib/readline/rlconf.h
+++ b/lib/readline/rlconf.h
@@ -8,7 +8,7 @@
The Library is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 1, or (at your option)
+ the Free Software Foundation; either version 2, or (at your option)
any later version.
The Library is distributed in the hope that it will be useful, but
@@ -19,7 +19,7 @@
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
- 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if !defined (_RLCONF_H_)
#define _RLCONF_H_
@@ -30,10 +30,6 @@
/* Define this to get an indication of file type when listing completions. */
#define VISIBLE_STATS
-/* If defined, readline shows opening parens and braces when closing
- paren or brace entered. */
-/* #define PAREN_MATCHING */
-
/* This definition is needed by readline.c, rltty.c, and signals.c. */
/* If on, then readline handles signals in a way that doesn't screw. */
#define HANDLE_SIGNALS
diff --git a/lib/readline/rldefs.h b/lib/readline/rldefs.h
index d4aced43..e504d9b1 100644
--- a/lib/readline/rldefs.h
+++ b/lib/readline/rldefs.h
@@ -10,7 +10,7 @@
The Library is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 1, or (at your option)
+ the Free Software Foundation; either version 2, or (at your option)
any later version.
The Library is distributed in the hope that it will be useful, but
@@ -21,7 +21,7 @@
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
- 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if !defined (_RLDEFS_H_)
#define _RLDEFS_H_
@@ -122,7 +122,8 @@ extern char *xmalloc ();
#if !defined (STREQ)
#define STREQ(a, b) (((a)[0] == (b)[0]) && (strcmp ((a), (b)) == 0))
-#define STREQN(a, b, n) (((a)[0] == (b)[0]) && (strncmp ((a), (b), (n)) == 0))
+#define STREQN(a, b, n) (((n) == 0) ? (1) \
+ : ((a)[0] == (b)[0]) && (strncmp ((a), (b), (n)) == 0))
#endif
#if !defined (FREE)
diff --git a/lib/readline/rlprivate.h b/lib/readline/rlprivate.h
new file mode 100644
index 00000000..c05230e3
--- /dev/null
+++ b/lib/readline/rlprivate.h
@@ -0,0 +1,271 @@
+/* rlprivate.h -- functions and variables global to the readline library,
+ but not intended for use by applications. */
+
+/* Copyright (C) 1999 Free Software Foundation, Inc.
+
+ This file is part of the GNU Readline Library, a library for
+ reading lines of text with interactive input and history editing.
+
+ The GNU Readline Library is free software; you can redistribute it
+ and/or modify it under the terms of the GNU General Public License
+ as published by the Free Software Foundation; either version 2, or
+ (at your option) any later version.
+
+ The GNU Readline Library is distributed in the hope that it will be
+ useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+ of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ The GNU General Public License is often shipped with GNU software, and
+ is generally kept in a file called COPYING or LICENSE. If you do not
+ have a copy of the license, write to the Free Software Foundation,
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+
+#if !defined (_RL_PRIVATE_H_)
+#define _RL_PRIVATE_H_
+
+#include "rlconf.h" /* for VISIBLE_STATS */
+#include "rlstdc.h"
+#include "posixjmp.h" /* defines procenv_t */
+
+/*************************************************************************
+ * *
+ * Global functions undocumented in texinfo manual and not in readline.h *
+ * *
+ *************************************************************************/
+
+/* terminal.c */
+extern char *rl_get_termcap __P((char *));
+
+/*************************************************************************
+ * *
+ * Global variables undocumented in texinfo manual and not in readline.h *
+ * *
+ *************************************************************************/
+
+/* complete.c */
+extern int rl_complete_with_tilde_expansion;
+#if defined (VISIBLE_STATS)
+extern int rl_visible_stats;
+#endif /* VISIBLE_STATS */
+
+/* readline.c */
+extern int rl_line_buffer_len;
+extern int rl_numeric_arg;
+extern int rl_arg_sign;
+extern int rl_explicit_arg;
+extern int rl_editing_mode;
+extern int rl_visible_prompt_length;
+extern Function *rl_last_func;
+extern int readline_echoing_p;
+extern int rl_key_sequence_length;
+
+/* display.c */
+extern int rl_display_fixed;
+
+/* parens.c */
+extern int rl_blink_matching_paren;
+
+/*************************************************************************
+ * *
+ * Global functions and variables unsed and undocumented *
+ * *
+ *************************************************************************/
+
+/* bind.c */
+extern char *rl_untranslate_keyseq __P((int));
+
+/* kill.c */
+extern int rl_set_retained_kills __P((int));
+
+/* readline.c */
+extern int rl_discard_argument __P((void));
+
+/* rltty.c */
+extern int rl_stop_output __P((int, int));
+
+/* terminal.c */
+extern void _rl_set_screen_size __P((int, int));
+
+/* undo.c */
+extern int _rl_fix_last_undo_of_type __P((int, int, int));
+
+/* util.c */
+extern char *_rl_savestring __P((char *));
+
+/*************************************************************************
+ * *
+ * Functions and variables private to the readline library *
+ * *
+ *************************************************************************/
+
+/* NOTE: Functions and variables prefixed with `_rl_' are
+ pseudo-global: they are global so they can be shared
+ between files in the readline library, but are not intended
+ to be visible to readline callers. */
+
+/*************************************************************************
+ * Undocumented private functions *
+ *************************************************************************/
+
+#if defined(READLINE_CALLBACKS)
+
+/* readline.c */
+extern void readline_internal_setup __P((void));
+extern char *readline_internal_teardown __P((int));
+extern int readline_internal_char __P((void));
+
+#endif /* READLINE_CALLBACKS */
+
+/* bind.c */
+extern void _rl_bind_if_unbound __P((char *, Function *));
+
+/* display.c */
+extern char *_rl_strip_prompt __P((char *));
+extern void _rl_move_cursor_relative __P((int, char *));
+extern void _rl_move_vert __P((int));
+extern void _rl_save_prompt __P((void));
+extern void _rl_restore_prompt __P((void));
+extern char *_rl_make_prompt_for_search __P((int));
+extern void _rl_erase_at_end_of_line __P((int));
+extern void _rl_clear_to_eol __P((int));
+extern void _rl_clear_screen __P((void));
+extern void _rl_update_final __P((void));
+extern void _rl_redisplay_after_sigwinch __P((void));
+extern void _rl_clean_up_for_exit __P((void));
+extern void _rl_erase_entire_line __P((void));
+extern int _rl_currentb_display_line __P((void));
+
+/* input.c */
+extern int _rl_any_typein __P((void));
+extern int _rl_input_available __P((void));
+extern void _rl_insert_typein __P((int));
+
+/* macro.c */
+extern void _rl_with_macro_input __P((char *));
+extern int _rl_next_macro_key __P((void));
+extern void _rl_push_executing_macro __P((void));
+extern void _rl_pop_executing_macro __P((void));
+extern void _rl_add_macro_char __P((int));
+extern void _rl_kill_kbd_macro __P((void));
+
+/* nls.c */
+extern int _rl_init_eightbit __P((void));
+
+/* parens.c */
+extern void _rl_enable_paren_matching __P((int));
+
+/* readline.c */
+extern void _rl_init_line_state __P((void));
+extern void _rl_set_the_line __P((void));
+extern int _rl_dispatch __P((int, Keymap));
+extern int _rl_init_argument __P((void));
+extern void _rl_fix_point __P((int));
+extern void _rl_replace_text __P((char *, int, int));
+extern int _rl_char_search_internal __P((int, int, int));
+extern int _rl_set_mark_at_pos __P((int));
+
+/* rltty.c */
+extern int _rl_disable_tty_signals __P((void));
+extern int _rl_restore_tty_signals __P((void));
+
+/* terminal.c */
+extern void _rl_get_screen_size __P((int, int));
+extern int _rl_init_terminal_io __P((char *));
+#ifdef _MINIX
+extern void _rl_output_character_function __P((int));
+#else
+extern int _rl_output_character_function __P((int));
+#endif
+extern void _rl_output_some_chars __P((char *, int));
+extern int _rl_backspace __P((int));
+extern void _rl_enable_meta_key __P((void));
+extern void _rl_control_keypad __P((int));
+
+/* util.c */
+extern int alphabetic __P((int));
+extern int _rl_abort_internal __P((void));
+extern char *_rl_strindex __P((char *, char *));
+extern int _rl_qsort_string_compare __P((char **, char **));
+extern int (_rl_uppercase_p) __P((int));
+extern int (_rl_lowercase_p) __P((int));
+extern int (_rl_pure_alphabetic) __P((int));
+extern int (_rl_digit_p) __P((int));
+extern int (_rl_to_lower) __P((int));
+extern int (_rl_to_upper) __P((int));
+extern int (_rl_digit_value) __P((int));
+
+/* vi_mode.c */
+extern void _rl_vi_initialize_line __P((void));
+extern void _rl_vi_reset_last __P((void));
+extern void _rl_vi_set_last __P((int, int, int));
+extern int _rl_vi_textmod_command __P((int));
+extern void _rl_vi_done_inserting __P((void));
+
+/*************************************************************************
+ * Undocumented private variables *
+ *************************************************************************/
+
+/* complete.c */
+extern int _rl_complete_show_all;
+extern int _rl_complete_mark_directories;
+extern int _rl_print_completions_horizontally;
+extern int _rl_completion_case_fold;
+
+/* display.c */
+extern int _rl_vis_botlin;
+extern int _rl_last_c_pos;
+extern int _rl_suppress_redisplay;
+extern char *rl_display_prompt;
+
+/* funmap.c */
+extern char *possible_control_prefixes[];
+extern char *possible_meta_prefixes[];
+
+/* isearch.c */
+extern unsigned char *_rl_isearch_terminators;
+
+/* macro.c */
+extern int _rl_defining_kbd_macro;
+extern char *_rl_executing_macro;
+
+/* readline.c */
+extern int _rl_horizontal_scroll_mode;
+extern int _rl_mark_modified_lines;
+extern int _rl_bell_preference;
+extern int _rl_meta_flag;
+extern int _rl_convert_meta_chars_to_ascii;
+extern int _rl_output_meta_chars;
+extern char *_rl_comment_begin;
+extern unsigned char _rl_parsing_conditionalized_out;
+extern Keymap _rl_keymap;
+extern FILE *_rl_in_stream;
+extern FILE *_rl_out_stream;
+extern int _rl_last_command_was_kill;
+extern int _rl_eof_char;
+extern procenv_t readline_top_level;
+
+/* terminal.c */
+extern int _rl_enable_keypad;
+extern int _rl_enable_meta;
+extern char *term_clreol;
+extern char *term_clrpag;
+extern char *term_im;
+extern char *term_ic;
+extern char *term_ei;
+extern char *term_DC;
+extern char *term_up;
+extern char *term_dc;
+extern char *term_cr;
+extern char *term_IC;
+extern int screenheight;
+extern int screenwidth;
+extern int screenchars;
+extern int terminal_can_insert;
+extern int _rl_term_autowrap;
+
+/* undo.c */
+extern int _rl_doing_an_undo;
+extern int _rl_undo_group_level;
+
+#endif /* _RL_PRIVATE_H_ */
diff --git a/lib/readline/rlshell.h b/lib/readline/rlshell.h
new file mode 100644
index 00000000..7a4e6996
--- /dev/null
+++ b/lib/readline/rlshell.h
@@ -0,0 +1,34 @@
+/* rlshell.h -- utility functions normally provided by bash. */
+
+/* Copyright (C) 1999 Free Software Foundation, Inc.
+
+ This file is part of the GNU Readline Library, a library for
+ reading lines of text with interactive input and history editing.
+
+ The GNU Readline Library is free software; you can redistribute it
+ and/or modify it under the terms of the GNU General Public License
+ as published by the Free Software Foundation; either version 2, or
+ (at your option) any later version.
+
+ The GNU Readline Library is distributed in the hope that it will be
+ useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+ of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ The GNU General Public License is often shipped with GNU software, and
+ is generally kept in a file called COPYING or LICENSE. If you do not
+ have a copy of the license, write to the Free Software Foundation,
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+
+#if !defined (_RL_SHELL_H_)
+#define _RL_SHELL_H_
+
+#include "rlstdc.h"
+
+extern char *single_quote __P((char *));
+extern void set_lines_and_columns __P((int, int));
+extern char *get_env_value __P((char *));
+extern char *get_home_dir __P((void));
+extern int unset_nodelay_mode __P((int));
+
+#endif /* _RL_SHELL_H_ */
diff --git a/lib/readline/rlstdc.h b/lib/readline/rlstdc.h
index f1590c6d..dac8e986 100644
--- a/lib/readline/rlstdc.h
+++ b/lib/readline/rlstdc.h
@@ -7,7 +7,7 @@
Bash is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 1, or (at your option)
+ the Free Software Foundation; either version 2, or (at your option)
any later version.
Bash is distributed in the hope that it will be useful, but WITHOUT
@@ -17,10 +17,10 @@
You should have received a copy of the GNU General Public License
along with Bash; see the file COPYING. If not, write to the Free
- Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
-#if !defined (_STDC_H_)
-#define _STDC_H_
+#if !defined (_RL_STDC_H_)
+#define _RL_STDC_H_
/* Adapted from BSD /usr/include/sys/cdefs.h. */
@@ -28,52 +28,12 @@
and traditional C compilers with something like this:
extern char *func __P((char *, char *, int)); */
-#if defined (__STDC__)
-
-# if !defined (__P)
+#if !defined (__P)
+# if defined (__STDC__) || defined (__GNUC__) || defined (__cplusplus)
# define __P(protos) protos
-# endif
-# define __STRING(x) #x
-
-# if !defined (__GNUC__)
-# define inline
-# endif
-
-#else /* !__STDC__ */
-
-# if !defined (__P)
+# else
# define __P(protos) ()
# endif
-# define __STRING(x) "x"
-
-#if defined (__GNUC__) /* gcc with -traditional */
-# if !defined (const)
-# define const __const
-# endif
-# if !defined (inline)
-# define inline __inline
-# endif
-# if !defined (signed)
-# define signed __signed
-# endif
-# if !defined (volatile)
-# define volatile __volatile
-# endif
-#else /* !__GNUC__ */
-# if !defined (const)
-# define const
-# endif
-# if !defined (inline)
-# define inline
-# endif
-# if !defined (signed)
-# define signed
-# endif
-# if !defined (volatile)
-# define volatile
-# endif
-#endif /* !__GNUC__ */
-
-#endif /* !__STDC__ */
+#endif
-#endif /* !_STDC_H_ */
+#endif /* !_RL_STDC_H_ */
diff --git a/lib/readline/rltty.c b/lib/readline/rltty.c
index a5ef938b..b868b697 100644
--- a/lib/readline/rltty.c
+++ b/lib/readline/rltty.c
@@ -8,7 +8,7 @@
The GNU Readline Library is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 1, or
+ as published by the Free Software Foundation; either version 2, or
(at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be
@@ -19,7 +19,7 @@
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
- 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
@@ -43,26 +43,12 @@
#include "rltty.h"
#include "readline.h"
+#include "rlprivate.h"
#if !defined (errno)
extern int errno;
#endif /* !errno */
-extern int readline_echoing_p;
-extern int _rl_eof_char;
-
-extern int _rl_enable_keypad, _rl_enable_meta;
-
-extern void _rl_control_keypad ();
-
-#if defined (__GO32__)
-# include <pc.h>
-# undef HANDLE_SIGNALS
-#endif /* __GO32__ */
-
-/* Indirect functions to allow apps control over terminal management. */
-extern void rl_prep_terminal (), rl_deprep_terminal ();
-
VFunction *rl_prep_term_function = rl_prep_terminal;
VFunction *rl_deprep_term_function = rl_deprep_terminal;
@@ -104,6 +90,7 @@ block_sigint ()
# endif /* HAVE_USG_SIGHOLD */
# endif /* !HAVE_BSD_SIGNALS */
#endif /* !HAVE_POSIX_SIGNALS */
+
sigint_blocked = 1;
}
@@ -111,7 +98,7 @@ block_sigint ()
static void
release_sigint ()
{
- if (!sigint_blocked)
+ if (sigint_blocked == 0)
return;
#if defined (HAVE_POSIX_SIGNALS)
@@ -138,25 +125,27 @@ release_sigint ()
/* Non-zero means that the terminal is in a prepped state. */
static int terminal_prepped;
+static _RL_TTY_CHARS _rl_tty_chars, _rl_last_tty_chars;
+
/* If non-zero, means that this process has called tcflow(fd, TCOOFF)
and output is suspended. */
#if defined (__ksr1__)
static int ksrflow;
#endif
-#if defined (TIOCGWINSZ)
/* Dummy call to force a backgrounded readline to stop before it tries
to get the tty settings. */
static void
set_winsize (tty)
int tty;
{
+#if defined (TIOCGWINSZ)
struct winsize w;
if (ioctl (tty, TIOCGWINSZ, &w) == 0)
(void) ioctl (tty, TIOCSWINSZ, &w);
-}
#endif /* TIOCGWINSZ */
+}
#if defined (NEW_TTY_DRIVER)
@@ -184,6 +173,42 @@ struct bsdtty {
static TIOTYPE otio;
+static void
+save_tty_chars (tiop)
+ TIOTYPE *tiop;
+{
+ _rl_last_tty_chars = _rl_tty_chars;
+
+ if (tiop->flags & SGTTY_SET)
+ {
+ _rl_tty_chars.t_erase = tiop->sgttyb.sg_erase;
+ _rl_tty_chars.t_kill = tiop->sgttyb.sg_kill;
+ }
+
+ if (tiop->flags & TCHARS_SET)
+ {
+ _rl_tty_chars.t_intr = tiop->tchars.t_intrc;
+ _rl_tty_chars.t_quit = tiop->tchars.t_quitc;
+ _rl_tty_chars.t_start = tiop->tchars.t_startc;
+ _rl_tty_chars.t_stop = tiop->tchars.t_stopc
+ _rl_tty_chars.t_eof = tiop->tchars.t_eofc;
+ _rl_tty_chars.t_eol = '\n';
+ _rl_tty_chars.t_eol2 = tiop->tchars.t_brkc;
+ }
+
+ if (tiop->flags & LTCHARS_SET)
+ {
+ _rl_tty_chars.t_susp = tiop->ltchars.t_suspc;
+ _rl_tty_chars.t_dsusp = tiop->ltchars.t_dsuspc;
+ _rl_tty_chars.t_reprint = tiop->ltchars.t_rprntc;
+ _rl_tty_chars.t_flush = tiop->ltchars.t_flushc;
+ _rl_tty_chars.t_werase = tiop->ltchars.t_werasc;
+ _rl_tty_chars.t_lnext = tiop->ltchars.t_lnextc;
+ }
+
+ _rl_tty_chars.t_status = -1;
+}
+
static int
get_tty_settings (tty, tiop)
int tty;
@@ -258,7 +283,6 @@ prepare_terminal_settings (meta_flag, otio, tiop)
int meta_flag;
TIOTYPE otio, *tiop;
{
-#if !defined (__GO32__)
readline_echoing_p = (otio.sgttyb.sg_flags & ECHO);
/* Copy the original settings to the structure we're going to use for
@@ -324,7 +348,6 @@ prepare_terminal_settings (meta_flag, otio, tiop)
tiop->ltchars.t_dsuspc = -1; /* C-y */
tiop->ltchars.t_lnextc = -1; /* C-v */
#endif /* TIOCGLTC */
-#endif /* !__GO32__ */
}
#else /* !defined (NEW_TTY_DRIVER) */
@@ -362,11 +385,58 @@ static TIOTYPE otio;
#endif
static void
+save_tty_chars (tiop)
+ TIOTYPE *tiop;
+{
+ _rl_last_tty_chars = _rl_tty_chars;
+
+ _rl_tty_chars.t_eof = tiop->c_cc[VEOF];
+ _rl_tty_chars.t_eol = tiop->c_cc[VEOL];
+#ifdef VEOL2
+ _rl_tty_chars.t_eol2 = tiop->c_cc[VEOL2];
+#endif
+ _rl_tty_chars.t_erase = tiop->c_cc[VERASE];
+#ifdef VWERASE
+ _rl_tty_chars.t_werase = tiop->c_cc[VWERASE];
+#endif
+ _rl_tty_chars.t_kill = tiop->c_cc[VKILL];
+#ifdef VREPRINT
+ _rl_tty_chars.t_reprint = tiop->c_cc[VREPRINT];
+#endif
+ _rl_tty_chars.t_intr = tiop->c_cc[VINTR];
+ _rl_tty_chars.t_quit = tiop->c_cc[VQUIT];
+#ifdef VSUSP
+ _rl_tty_chars.t_susp = tiop->c_cc[VSUSP];
+#endif
+#ifdef VDSUSP
+ _rl_tty_chars.t_dsusp = tiop->c_cc[VDSUSP];
+#endif
+#ifdef VSTART
+ _rl_tty_chars.t_start = tiop->c_cc[VSTART];
+#endif
+#ifdef VSTOP
+ _rl_tty_chars.t_stop = tiop->c_cc[VSTOP];
+#endif
+#ifdef VLNEXT
+ _rl_tty_chars.t_lnext = tiop->c_cc[VLNEXT];
+#endif
+#ifdef VDISCARD
+ _rl_tty_chars.t_flush = tiop->c_cc[VDISCARD];
+#endif
+#ifdef VSTATUS
+ _rl_tty_chars.t_status = tiop->c_cc[VSTATUS];
+#endif
+}
+
+#if defined (_AIX) || defined (_AIX41)
+/* Currently this is only used on AIX */
+static void
rltty_warning (msg)
char *msg;
{
fprintf (stderr, "readline: warning: %s\n", msg);
}
+#endif
#if defined (_AIX)
void
@@ -382,14 +452,12 @@ TIOTYPE *tp;
#endif
static int
-get_tty_settings (tty, tiop)
+_get_tty_settings (tty, tiop)
int tty;
TIOTYPE *tiop;
{
int ioctl_ret;
- set_winsize (tty);
-
while (1)
{
ioctl_ret = GETATTR (tty, tiop);
@@ -413,6 +481,19 @@ get_tty_settings (tty, tiop)
break;
}
+ return 0;
+}
+
+static int
+get_tty_settings (tty, tiop)
+ int tty;
+ TIOTYPE *tiop;
+{
+ set_winsize (tty);
+
+ if (_get_tty_settings (tty, tiop) < 0)
+ return -1;
+
#if defined (_AIX)
setopost(tiop);
#endif
@@ -421,7 +502,7 @@ get_tty_settings (tty, tiop)
}
static int
-set_tty_settings (tty, tiop)
+_set_tty_settings (tty, tiop)
int tty;
TIOTYPE *tiop;
{
@@ -431,7 +512,17 @@ set_tty_settings (tty, tiop)
return -1;
errno = 0;
}
+ return 0;
+}
+static int
+set_tty_settings (tty, tiop)
+ int tty;
+ TIOTYPE *tiop;
+{
+ if (_set_tty_settings (tty, tiop) < 0)
+ return -1;
+
#if 0
#if defined (TERMIOS_TTY_DRIVER)
@@ -448,7 +539,7 @@ set_tty_settings (tty, tiop)
ioctl (tty, TCXONC, 1); /* Simulate a ^Q. */
#endif /* !TERMIOS_TTY_DRIVER */
-#endif
+#endif /* 0 */
return 0;
}
@@ -520,7 +611,6 @@ void
rl_prep_terminal (meta_flag)
int meta_flag;
{
-#if !defined (__GO32__)
int tty;
TIOTYPE tio;
@@ -540,6 +630,8 @@ rl_prep_terminal (meta_flag)
otio = tio;
+ save_tty_chars (&otio);
+
prepare_terminal_settings (meta_flag, otio, &tio);
if (set_tty_settings (tty, &tio) < 0)
@@ -555,14 +647,12 @@ rl_prep_terminal (meta_flag)
terminal_prepped = 1;
release_sigint ();
-#endif /* !__GO32__ */
}
/* Restore the terminal's normal settings and modes. */
void
rl_deprep_terminal ()
{
-#if !defined (__GO32__)
int tty;
if (!terminal_prepped)
@@ -587,7 +677,6 @@ rl_deprep_terminal ()
terminal_prepped = 0;
release_sigint ();
-#endif /* !__GO32__ */
}
/* **************************************************************** */
@@ -725,3 +814,54 @@ rltty_set_default_bindings (kmap)
}
#endif /* !NEW_TTY_DRIVER */
}
+
+#if defined (HANDLE_SIGNALS)
+
+#if defined (NEW_TTY_DRIVER)
+int
+_rl_disable_tty_signals ()
+{
+ return 0;
+}
+
+int
+_rl_restore_tty_signals ()
+{
+ return 0;
+}
+#else
+
+static TIOTYPE sigstty, nosigstty;
+static int tty_sigs_disabled = 0;
+
+int
+_rl_disable_tty_signals ()
+{
+ if (tty_sigs_disabled)
+ return 0;
+
+ if (_get_tty_settings (fileno (rl_instream), &sigstty) < 0)
+ return -1;
+
+ nosigstty = sigstty;
+
+ nosigstty.c_lflag &= ~ISIG;
+
+ if (_set_tty_settings (fileno (rl_instream), &nosigstty) < 0)
+ return (_set_tty_settings (fileno (rl_instream), &sigstty));
+
+ tty_sigs_disabled = 1;
+ return 0;
+}
+
+int
+_rl_restore_tty_signals ()
+{
+ if (tty_sigs_disabled == 0)
+ return 0;
+
+ return (_set_tty_settings (fileno (rl_instream), &sigstty));
+}
+#endif /* !NEW_TTY_DRIVER */
+
+#endif /* HANDLE_SIGNALS */
diff --git a/lib/readline/rltty.h b/lib/readline/rltty.h
index fe783463..029a3fbc 100644
--- a/lib/readline/rltty.h
+++ b/lib/readline/rltty.h
@@ -8,7 +8,7 @@
The Library is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 1, or (at your option)
+ the Free Software Foundation; either version 2, or (at your option)
any later version.
The Library is distributed in the hope that it will be useful, but
@@ -19,10 +19,10 @@
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
- 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if !defined (_RLTTY_H_)
-#define _RLTTY_H
+#define _RLTTY_H_
/* Posix systems use termios and the Posix signal functions. */
#if defined (TERMIOS_TTY_DRIVER)
@@ -60,4 +60,23 @@
# endif /* !_SVR4_DISABLE */
#endif /* !NEW_TTY_DRIVER && !_POSIX_VDISABLE */
+typedef struct _rl_tty_chars {
+ char t_eof;
+ char t_eol;
+ char t_eol2;
+ char t_erase;
+ char t_werase;
+ char t_kill;
+ char t_reprint;
+ char t_intr;
+ char t_quit;
+ char t_susp;
+ char t_dsusp;
+ char t_start;
+ char t_stop;
+ char t_lnext;
+ char t_flush;
+ char t_status;
+} _RL_TTY_CHARS;
+
#endif /* _RLTTY_H_ */
diff --git a/lib/readline/rlwinsize.h b/lib/readline/rlwinsize.h
index 92b3de17..7838154d 100644
--- a/lib/readline/rlwinsize.h
+++ b/lib/readline/rlwinsize.h
@@ -9,7 +9,7 @@
The Library is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 1, or (at your option)
+ the Free Software Foundation; either version 2, or (at your option)
any later version.
The Library is distributed in the hope that it will be useful, but
@@ -20,7 +20,7 @@
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
- 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if !defined (_RLWINSIZE_H_)
#define _RLWINSIZE_H_
@@ -55,4 +55,3 @@
#endif /* _RL_WINSIZE_H */
-
diff --git a/lib/readline/savestring.c b/lib/readline/savestring.c
index 3f53a87b..485890ea 100644
--- a/lib/readline/savestring.c
+++ b/lib/readline/savestring.c
@@ -7,7 +7,7 @@
The GNU Readline Library is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 1, or
+ as published by the Free Software Foundation; either version 2, or
(at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be
@@ -18,7 +18,7 @@
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
- 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
extern char *strcpy ();
extern char *xmalloc ();
diff --git a/lib/readline/search.c b/lib/readline/search.c
index 6c76e1a1..112f8072 100644
--- a/lib/readline/search.c
+++ b/lib/readline/search.c
@@ -8,7 +8,7 @@
The Library is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 1, or (at your option)
+ the Free Software Foundation; either version 2, or (at your option)
any later version.
The Library is distributed in the hope that it will be useful, but
@@ -19,7 +19,7 @@
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
- 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
@@ -43,30 +43,51 @@
#include "readline.h"
#include "history.h"
+#include "rlprivate.h"
+#include "xmalloc.h"
+
#ifdef abs
# undef abs
#endif
#define abs(x) (((x) >= 0) ? (x) : -(x))
-extern char *xmalloc (), *xrealloc ();
-
-/* Variables imported from readline.c */
-extern int rl_point, rl_end, rl_line_buffer_len;
-extern int rl_editing_mode;
-extern char *rl_prompt;
-extern char *rl_line_buffer;
extern HIST_ENTRY *saved_line_for_history;
-extern Function *rl_last_func;
/* Functions imported from the rest of the library. */
-extern int _rl_free_history_entry ();
-extern char *_rl_make_prompt_for_search ();
-extern void rl_extend_line_buffer ();
+extern int _rl_free_history_entry __P((HIST_ENTRY *));
static char *noninc_search_string = (char *) NULL;
static int noninc_history_pos;
+
static char *prev_line_found = (char *) NULL;
+static int rl_history_search_len;
+static int rl_history_search_pos;
+static char *history_search_string;
+static int history_string_size;
+
+/* Make the data from the history entry ENTRY be the contents of the
+ current line. This doesn't do anything with rl_point; the caller
+ must set it. */
+static void
+make_history_line_current (entry)
+ HIST_ENTRY *entry;
+{
+ int line_len;
+
+ line_len = strlen (entry->line);
+ if (line_len >= rl_line_buffer_len)
+ rl_extend_line_buffer (line_len);
+ strcpy (rl_line_buffer, entry->line);
+
+ rl_undo_list = (UNDO_LIST *)entry->data;
+ rl_end = line_len;
+
+ if (saved_line_for_history)
+ _rl_free_history_entry (saved_line_for_history);
+ saved_line_for_history = (HIST_ENTRY *)NULL;
+}
+
/* Search the history list for STRING starting at absolute history position
POS. If STRING begins with `^', the search must match STRING at the
beginning of a history line, otherwise a full substring match is performed
@@ -102,7 +123,7 @@ noninc_dosearch (string, dir)
char *string;
int dir;
{
- int oldpos, pos, line_len;
+ int oldpos, pos;
HIST_ENTRY *entry;
if (string == 0 || *string == '\0' || noninc_history_pos < 0)
@@ -132,19 +153,10 @@ noninc_dosearch (string, dir)
#endif
history_set_pos (oldpos);
- line_len = strlen (entry->line);
- if (line_len >= rl_line_buffer_len)
- rl_extend_line_buffer (line_len);
- strcpy (rl_line_buffer, entry->line);
+ make_history_line_current (entry);
- rl_undo_list = (UNDO_LIST *)entry->data;
- rl_end = strlen (rl_line_buffer);
rl_point = 0;
rl_clear_message ();
-
- if (saved_line_for_history)
- _rl_free_history_entry (saved_line_for_history);
- saved_line_for_history = (HIST_ENTRY *)NULL;
}
/* Search non-interactively through the history list. DIR < 0 means to
@@ -235,8 +247,7 @@ noninc_search (dir, pchar)
{
/* We want to start the search from the current history position. */
noninc_history_pos = where_history ();
- if (noninc_search_string)
- free (noninc_search_string);
+ FREE (noninc_search_string);
noninc_search_string = savestring (rl_line_buffer);
}
@@ -295,59 +306,84 @@ rl_noninc_reverse_search_again (count, key)
}
static int
-rl_history_search_internal (count, direction)
- int count, direction;
+rl_history_search_internal (count, dir)
+ int count, dir;
{
- HIST_ENTRY *temp, *old_temp;
- int line_len;
+ HIST_ENTRY *temp;
+ int ret, oldpos;
maybe_save_line ();
+ temp = (HIST_ENTRY *)NULL;
- temp = old_temp = (HIST_ENTRY *)NULL;
+ /* Search COUNT times through the history for a line whose prefix
+ matches history_search_string. When this loop finishes, TEMP,
+ if non-null, is the history line to copy into the line buffer. */
while (count)
{
- temp = (direction < 0) ? previous_history () : next_history ();
- if (temp == 0)
- break;
- /* On an empty prefix, make this the same as previous-history. */
- if (rl_point == 0)
- {
- count--;
- continue;
- }
- if (STREQN (rl_line_buffer, temp->line, rl_point))
- {
- /* Don't find multiple instances of the same line. */
- if (prev_line_found && STREQ (prev_line_found, temp->line))
- continue;
- if (direction < 0)
- old_temp = temp;
- prev_line_found = temp->line;
- count--;
- }
+ ret = noninc_search_from_pos (history_search_string, rl_history_search_pos + dir, dir);
+ if (ret == -1)
+ break;
+
+ /* Get the history entry we found. */
+ rl_history_search_pos = ret;
+ oldpos = where_history ();
+ history_set_pos (rl_history_search_pos);
+ temp = current_history ();
+ history_set_pos (oldpos);
+
+ /* Don't find multiple instances of the same line. */
+ if (prev_line_found && STREQ (prev_line_found, temp->line))
+ continue;
+ prev_line_found = temp->line;
+ count--;
}
+ /* If we didn't find anything at all, return. */
if (temp == 0)
{
- if (direction < 0 && old_temp)
- temp = old_temp;
- else
- {
- maybe_unsave_line ();
- ding ();
- return 1;
- }
+ maybe_unsave_line ();
+ ding ();
+ /* If you don't want the saved history line (last match) to show up
+ in the line buffer after the search fails, change the #if 0 to
+ #if 1 */
+#if 0
+ if (rl_point > rl_history_search_len)
+ {
+ rl_point = rl_end = rl_history_search_len;
+ rl_line_buffer[rl_end] = '\0';
+ }
+#else
+ rl_point = rl_history_search_len; /* maybe_unsave_line changes it */
+#endif
+ return 1;
}
- line_len = strlen (temp->line);
- if (line_len >= rl_line_buffer_len)
- rl_extend_line_buffer (line_len);
- strcpy (rl_line_buffer, temp->line);
- rl_undo_list = (UNDO_LIST *)temp->data;
- rl_end = line_len;
+ /* Copy the line we found into the current line buffer. */
+ make_history_line_current (temp);
+
+ rl_point = rl_history_search_len;
return 0;
}
+static void
+rl_history_search_reinit ()
+{
+ rl_history_search_pos = where_history ();
+ rl_history_search_len = rl_point;
+ prev_line_found = (char *)NULL;
+ if (rl_point)
+ {
+ if (rl_history_search_len >= history_string_size - 2)
+ {
+ history_string_size = rl_history_search_len + 2;
+ history_search_string = xrealloc (history_search_string, history_string_size);
+ }
+ history_search_string[0] = '^';
+ strncpy (history_search_string + 1, rl_line_buffer, rl_point);
+ history_search_string[rl_point + 1] = '\0';
+ }
+}
+
/* Search forward in the history for the string of characters
from the start of the line to rl_point. This is a non-incremental
search. */
@@ -357,8 +393,13 @@ rl_history_search_forward (count, ignore)
{
if (count == 0)
return (0);
- if (rl_last_func != rl_history_search_forward)
- prev_line_found = (char *)NULL;
+
+ if (rl_last_func != rl_history_search_forward &&
+ rl_last_func != rl_history_search_backward)
+ rl_history_search_reinit ();
+
+ if (rl_history_search_len == 0)
+ return (rl_get_next_history (count, ignore));
return (rl_history_search_internal (abs (count), (count > 0) ? 1 : -1));
}
@@ -371,7 +412,12 @@ rl_history_search_backward (count, ignore)
{
if (count == 0)
return (0);
- if (rl_last_func != rl_history_search_backward)
- prev_line_found = (char *)NULL;
+
+ if (rl_last_func != rl_history_search_forward &&
+ rl_last_func != rl_history_search_backward)
+ rl_history_search_reinit ();
+
+ if (rl_history_search_len == 0)
+ return (rl_get_previous_history (count, ignore));
return (rl_history_search_internal (abs (count), (count > 0) ? -1 : 1));
}
diff --git a/lib/readline/shell.c b/lib/readline/shell.c
index 091ec08f..3daef69b 100644
--- a/lib/readline/shell.c
+++ b/lib/readline/shell.c
@@ -8,7 +8,7 @@
The GNU Readline Library is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 1, or
+ as published by the Free Software Foundation; either version 2, or
(at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be
@@ -19,7 +19,7 @@
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
- 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
@@ -44,13 +44,21 @@
# include <strings.h>
#endif /* !HAVE_STRING_H */
+#include <fcntl.h>
#include <pwd.h>
+#include <stdio.h>
+
+#include "rlshell.h"
+#include "xmalloc.h"
+
#if !defined (HAVE_GETPW_DECLS)
extern struct passwd *getpwuid ();
#endif /* !HAVE_GETPW_DECLS */
-extern char *xmalloc ();
+#ifndef NULL
+# define NULL 0
+#endif
/* All of these functions are resolved from bash if we are linking readline
as part of bash. */
@@ -63,7 +71,7 @@ single_quote (string)
register int c;
char *result, *r, *s;
- result = (char *)xmalloc (3 + (3 * strlen (string)));
+ result = (char *)xmalloc (3 + (4 * strlen (string)));
r = result;
*r++ = '\'';
@@ -131,3 +139,37 @@ get_home_dir ()
home_dir = entry->pw_dir;
return (home_dir);
}
+
+#if !defined (O_NDELAY)
+# if defined (FNDELAY)
+# define O_NDELAY FNDELAY
+# endif
+#endif
+
+int
+unset_nodelay_mode (fd)
+ int fd;
+{
+ int flags, bflags;
+
+ if ((flags = fcntl (fd, F_GETFL, 0)) < 0)
+ return -1;
+
+ bflags = 0;
+
+#ifdef O_NONBLOCK
+ bflags |= O_NONBLOCK;
+#endif
+
+#ifdef O_NDELAY
+ bflags |= O_NDELAY;
+#endif
+
+ if (flags & bflags)
+ {
+ flags &= ~bflags;
+ return (fcntl (fd, F_SETFL, flags));
+ }
+
+ return 0;
+}
diff --git a/lib/readline/signals.c b/lib/readline/signals.c
index 3a34432f..861019d3 100644
--- a/lib/readline/signals.c
+++ b/lib/readline/signals.c
@@ -7,7 +7,7 @@
The GNU Readline Library is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 1, or
+ as published by the Free Software Foundation; either version 2, or
(at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be
@@ -18,7 +18,7 @@
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
- 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
@@ -40,15 +40,13 @@
# include <sys/ioctl.h>
#endif /* GWINSZ_IN_SYS_IOCTL */
-#if defined (__GO32__)
-# undef HANDLE_SIGNALS
-#endif /* __GO32__ */
-
#if defined (HANDLE_SIGNALS)
/* Some standard library routines. */
#include "readline.h"
#include "history.h"
+#include "rlprivate.h"
+
#if !defined (RETSIGTYPE)
# if defined (VOID_SIGHANDLER)
# define RETSIGTYPE void
@@ -67,19 +65,15 @@
to say SigHandler *foo = signal (SIGKILL, SIG_IGN); */
typedef RETSIGTYPE SigHandler ();
-extern int readline_echoing_p;
-extern int rl_pending_input;
-extern int _rl_meta_flag;
-
-extern void free_undo_list ();
-extern void _rl_get_screen_size ();
-extern void _rl_redisplay_after_sigwinch ();
-extern void _rl_clean_up_for_exit ();
-extern void _rl_kill_kbd_macro ();
-extern void _rl_init_argument ();
-extern void rl_deprep_terminal (), rl_prep_terminal ();
+#if defined (HAVE_POSIX_SIGNALS)
+typedef struct sigaction sighandler_cxt;
+# define rl_sigaction(s, nh, oh) sigaction(s, nh, oh)
+#else
+typedef struct { SigHandler *sa_handler; int sa_mask, sa_flags; } sighandler_cxt;
+# define sigemptyset(m)
+#endif /* !HAVE_POSIX_SIGNALS */
-static SigHandler *rl_set_sighandler ();
+static SigHandler *rl_set_sighandler __P((int, SigHandler *, sighandler_cxt *));
/* Exported variables for use by applications. */
@@ -101,14 +95,6 @@ static int sigwinch_set_flag;
/* */
/* **************************************************************** */
-#if defined (HAVE_POSIX_SIGNALS)
-typedef struct sigaction sighandler_cxt;
-# define rl_sigaction(s, nh, oh) sigaction(s, nh, oh)
-#else
-typedef struct { SigHandler *sa_handler; int sa_mask, sa_flags; } sighandler_cxt;
-# define sigemptyset(m)
-#endif /* !HAVE_POSIX_SIGNALS */
-
static sighandler_cxt old_int, old_term, old_alrm, old_quit;
#if defined (SIGTSTP)
static sighandler_cxt old_tstp, old_ttou, old_ttin;
@@ -165,6 +151,10 @@ rl_signal_handler (sig)
# endif /* HAVE_BSD_SIGNALS */
#endif /* !HAVE_POSIX_SIGNALS */
+#if defined (__EMX__)
+ signal (sig, SIG_ACK);
+#endif
+
kill (getpid (), sig);
/* Let the signal that we just sent through. */
@@ -232,6 +222,7 @@ rl_set_sighandler (sig, handler, ohandler)
SigHandler *handler;
sighandler_cxt *ohandler;
{
+ sighandler_cxt old_handler;
#if defined (HAVE_POSIX_SIGNALS)
struct sigaction act;
@@ -239,10 +230,17 @@ rl_set_sighandler (sig, handler, ohandler)
act.sa_flags = 0;
sigemptyset (&act.sa_mask);
sigemptyset (&ohandler->sa_mask);
- sigaction (sig, &act, ohandler);
+ sigaction (sig, &act, &old_handler);
#else
- ohandler->sa_handler = (SigHandler *)signal (sig, handler);
+ old_handler.sa_handler = (SigHandler *)signal (sig, handler);
#endif /* !HAVE_POSIX_SIGNALS */
+
+ /* XXX -- assume we have memcpy */
+ /* If rl_set_signals is called twice in a row, don't set the old handler to
+ rl_signal_handler, because that would cause infinite recursion. */
+ if (handler != rl_signal_handler || old_handler.sa_handler != rl_signal_handler)
+ memcpy (ohandler, &old_handler, sizeof (sighandler_cxt));
+
return (ohandler->sa_handler);
}
diff --git a/lib/readline/tcap.h b/lib/readline/tcap.h
index acb2d76a..58ab894d 100644
--- a/lib/readline/tcap.h
+++ b/lib/readline/tcap.h
@@ -8,7 +8,7 @@
The Library is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 1, or (at your option)
+ the Free Software Foundation; either version 2, or (at your option)
any later version.
The Library is distributed in the hope that it will be useful, but
@@ -19,7 +19,7 @@
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
- 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if !defined (_RLTCAP_H_)
#define _RLTCAP_H_
diff --git a/lib/readline/terminal.c b/lib/readline/terminal.c
index c22ec517..20ad126e 100644
--- a/lib/readline/terminal.c
+++ b/lib/readline/terminal.c
@@ -7,7 +7,7 @@
The GNU Readline Library is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 1, or
+ as published by the Free Software Foundation; either version 2, or
(at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be
@@ -18,7 +18,7 @@
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
- 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
@@ -46,9 +46,7 @@
# include <locale.h>
#endif
-#include <signal.h>
#include <stdio.h>
-#include <setjmp.h>
/* System-specific feature definitions and include files. */
#include "rldefs.h"
@@ -64,18 +62,8 @@
#include "readline.h"
#include "history.h"
-/* Variables and functions imported from readline.c */
-extern FILE *_rl_in_stream, *_rl_out_stream;
-extern int readline_echoing_p;
-extern int _rl_bell_preference;
-extern Keymap _rl_keymap;
-
-/* Functions imported from bind.c */
-extern void _rl_bind_if_unbound ();
-
-/* Functions imported from shell.c */
-extern void set_lines_and_columns ();
-extern char *get_env_value ();
+#include "rlprivate.h"
+#include "rlshell.h"
/* **************************************************************** */
/* */
@@ -149,6 +137,22 @@ int _rl_enable_keypad;
/* Non-zero means the user wants to enable a meta key. */
int _rl_enable_meta = 1;
+#if defined (__EMX__)
+static void
+_emx_get_screensize (swp, shp)
+ int *swp, *shp;
+{
+ int sz[2];
+
+ _scrsize (sz);
+
+ if (swp)
+ *swp = sz[0];
+ if (shp)
+ *shp = sz[1];
+}
+#endif
+
/* Get readline's idea of the screen size. TTY is a file descriptor open
to the terminal. If IGNORE_ENV is true, we do not pay attention to the
values of $LINES and $COLUMNS. The tests for TERM_STRING_BUFFER being
@@ -161,9 +165,6 @@ _rl_get_screen_size (tty, ignore_env)
#if defined (TIOCGWINSZ)
struct winsize window_size;
#endif /* TIOCGWINSZ */
-#if defined (__EMX__)
- int sz[2];
-#endif
#if defined (TIOCGWINSZ)
if (ioctl (tty, TIOCGWINSZ, &window_size) == 0)
@@ -174,9 +175,7 @@ _rl_get_screen_size (tty, ignore_env)
#endif /* TIOCGWINSZ */
#if defined (__EMX__)
- _scrsize (sz);
- screenwidth = sz[0];
- screenheight = sz[1];
+ _emx_get_screensize (&screenwidth, &screenheight);
#endif
/* Environment variable COLUMNS overrides setting of "co" if IGNORE_ENV
@@ -186,8 +185,10 @@ _rl_get_screen_size (tty, ignore_env)
if (ignore_env == 0 && (ss = get_env_value ("COLUMNS")))
screenwidth = atoi (ss);
+#if !defined (__DJGPP__)
if (screenwidth <= 0 && term_string_buffer)
screenwidth = tgetnum ("co");
+#endif
}
/* Environment variable LINES overrides setting of "li" if IGNORE_ENV
@@ -197,8 +198,10 @@ _rl_get_screen_size (tty, ignore_env)
if (ignore_env == 0 && (ss = get_env_value ("LINES")))
screenheight = atoi (ss);
+#if !defined (__DJGPP__)
if (screenheight <= 0 && term_string_buffer)
screenheight = tgetnum ("li");
+#endif
}
/* If all else fails, default to 80x24 terminal. */
@@ -213,7 +216,7 @@ _rl_get_screen_size (tty, ignore_env)
do a pair of putenv () or setenv () calls. */
set_lines_and_columns (screenheight, screenwidth);
- if (!_rl_term_autowrap)
+ if (_rl_term_autowrap == 0)
screenwidth--;
screenchars = screenwidth * screenheight;
@@ -251,32 +254,32 @@ struct _tc_string {
search algorithm to something smarter. */
static struct _tc_string tc_strings[] =
{
- "DC", &term_DC,
- "IC", &term_IC,
- "ce", &term_clreol,
- "cl", &term_clrpag,
- "cr", &term_cr,
- "dc", &term_dc,
- "ei", &term_ei,
- "ic", &term_ic,
- "im", &term_im,
- "kd", &term_kd,
- "kh", &term_kh, /* home */
- "kH", &term_kH, /* end */
- "kl", &term_kl,
- "kr", &term_kr,
- "ku", &term_ku,
- "ks", &term_ks,
- "ke", &term_ke,
- "le", &term_backspace,
- "mm", &term_mm,
- "mo", &term_mo,
+ { "DC", &term_DC },
+ { "IC", &term_IC },
+ { "ce", &term_clreol },
+ { "cl", &term_clrpag },
+ { "cr", &term_cr },
+ { "dc", &term_dc },
+ { "ei", &term_ei },
+ { "ic", &term_ic },
+ { "im", &term_im },
+ { "kd", &term_kd },
+ { "kh", &term_kh }, /* home */
+ { "kH", &term_kH }, /* end */
+ { "kl", &term_kl },
+ { "kr", &term_kr },
+ { "ku", &term_ku },
+ { "ks", &term_ks },
+ { "ke", &term_ke },
+ { "le", &term_backspace },
+ { "mm", &term_mm },
+ { "mo", &term_mo },
#if defined (HACK_TERMCAP_MOTION)
- "nd", &term_forward_char,
+ { "nd", &term_forward_char },
#endif
- "pc", &term_pc,
- "up", &term_up,
- "vb", &visible_bell,
+ { "pc", &term_pc },
+ { "up", &term_up },
+ { "vb", &visible_bell },
};
#define NUM_TC_STRINGS (sizeof (tc_strings) / sizeof (struct _tc_string))
@@ -287,72 +290,96 @@ static void
get_term_capabilities (bp)
char **bp;
{
+#if !defined (__DJGPP__) /* XXX - doesn't DJGPP have a termcap library? */
register int i;
for (i = 0; i < NUM_TC_STRINGS; i++)
*(tc_strings[i].tc_value) = tgetstr (tc_strings[i].tc_var, bp);
+#endif
tcap_initialized = 1;
}
+#define CUSTOM_REDISPLAY_FUNC() (rl_redisplay_function != rl_redisplay)
+#define CUSTOM_INPUT_FUNC() (rl_getc_function != rl_getc)
+
int
_rl_init_terminal_io (terminal_name)
char *terminal_name;
{
-#if defined (__GO32__)
- screenwidth = ScreenCols ();
- screenheight = ScreenRows ();
- screenchars = screenwidth * screenheight;
- term_cr = "\r";
- term_im = term_ei = term_ic = term_IC = (char *)NULL;
- term_up = term_dc = term_DC = visible_bell = (char *)NULL;
-
- /* Does the __GO32__ have a meta key? I don't know. */
- term_has_meta = 0;
- term_mm = term_mo = (char *)NULL;
-
- /* It probably has arrow keys, but I don't know what they are. */
- term_ku = term_kd = term_kr = term_kl = (char *)NULL;
-
-#if defined (HACK_TERMCAP_MOTION)
- term_forward_char = (char *)NULL;
-#endif /* HACK_TERMCAP_MOTION */
- terminal_can_insert = _rl_term_autowrap = 0;
- return;
-#else /* !__GO32__ */
-
char *term, *buffer;
- int tty;
+ int tty, tgetent_ret;
Keymap xkeymap;
term = terminal_name ? terminal_name : get_env_value ("TERM");
+ term_clrpag = term_cr = term_clreol = (char *)NULL;
+ tty = rl_instream ? fileno (rl_instream) : 0;
+ screenwidth = screenheight = 0;
- if (term_string_buffer == 0)
- term_string_buffer = xmalloc (2032);
+ if (term == 0)
+ term = "dumb";
- if (term_buffer == 0)
- term_buffer = xmalloc (4080);
+ /* I've separated this out for later work on not calling tgetent at all
+ if the calling application has supplied a custom redisplay function,
+ (and possibly if the application has supplied a custom input function). */
+ if (CUSTOM_REDISPLAY_FUNC())
+ {
+ tgetent_ret = -1;
+ }
+ else
+ {
+ if (term_string_buffer == 0)
+ term_string_buffer = xmalloc(2032);
- buffer = term_string_buffer;
+ if (term_buffer == 0)
+ term_buffer = xmalloc(4080);
- term_clrpag = term_cr = term_clreol = (char *)NULL;
+ buffer = term_string_buffer;
- if (term == 0)
- term = "dumb";
+ tgetent_ret = tgetent (term_buffer, term);
+ }
- if (tgetent (term_buffer, term) <= 0)
+ if (tgetent_ret <= 0)
{
+ FREE (term_string_buffer);
+ FREE (term_buffer);
+ buffer = term_buffer = term_string_buffer = (char *)NULL;
+
dumb_term = 1;
- screenwidth = 79;
- screenheight = 24;
- screenchars = 79 * 24;
+ _rl_term_autowrap = 0; /* used by _rl_get_screen_size */
+
+#if defined (__EMX__)
+ _emx_get_screensize (&screenwidth, &screenheight);
+ screenwidth--;
+#else /* !__EMX__ */
+ _rl_get_screen_size (tty, 0);
+#endif /* !__EMX__ */
+
+ /* Defaults. */
+ if (screenwidth <= 0 || screenheight <= 0)
+ {
+ screenwidth = 79;
+ screenheight = 24;
+ }
+
+ /* Everything below here is used by the redisplay code (tputs). */
+ screenchars = screenwidth * screenheight;
term_cr = "\r";
term_im = term_ei = term_ic = term_IC = (char *)NULL;
term_up = term_dc = term_DC = visible_bell = (char *)NULL;
term_ku = term_kd = term_kl = term_kr = (char *)NULL;
+ term_mm = term_mo = (char *)NULL;
#if defined (HACK_TERMCAP_MOTION)
term_forward_char = (char *)NULL;
#endif
- terminal_can_insert = 0;
+ terminal_can_insert = term_has_meta = 0;
+
+ /* Reasonable defaults for tgoto(). Readline currently only uses
+ tgoto if term_IC or term_DC is defined, but just in case we
+ change that later... */
+ PC = '\0';
+ BC = term_backspace = "\b";
+ UP = term_up;
+
return 0;
}
@@ -367,10 +394,6 @@ _rl_init_terminal_io (terminal_name)
if (!term_cr)
term_cr = "\r";
- tty = rl_instream ? fileno (rl_instream) : 0;
-
- screenwidth = screenheight = 0;
-
_rl_term_autowrap = tgetflag ("am") && tgetflag ("xn");
_rl_get_screen_size (tty, 0);
@@ -413,7 +436,6 @@ _rl_init_terminal_io (terminal_name)
_rl_keymap = xkeymap;
-#endif /* !__GO32__ */
return 0;
}
@@ -459,6 +481,7 @@ _rl_output_character_function (c)
return putc (c, _rl_out_stream);
}
#endif /* !_MINIX */
+
/* Write COUNT characters from STRING to the output stream. */
void
_rl_output_some_chars (string, count)
@@ -475,12 +498,10 @@ _rl_backspace (count)
{
register int i;
-#if !defined (__GO32__)
if (term_backspace)
for (i = 0; i < count; i++)
tputs (term_backspace, 1, _rl_output_character_function);
else
-#endif /* !__GO32__ */
for (i = 0; i < count; i++)
putc ('\b', _rl_out_stream);
return 0;
@@ -504,7 +525,6 @@ ding ()
{
if (readline_echoing_p)
{
-#if !defined (__GO32__)
switch (_rl_bell_preference)
{
case NO_BELL:
@@ -522,10 +542,6 @@ ding ()
fflush (stderr);
break;
}
-#else /* __GO32__ */
- fprintf (stderr, "\007");
- fflush (stderr);
-#endif /* __GO32__ */
return (0);
}
return (-1);
@@ -540,16 +556,20 @@ ding ()
void
_rl_enable_meta_key ()
{
+#if !defined (__DJGPP__)
if (term_has_meta && term_mm)
tputs (term_mm, 1, _rl_output_character_function);
+#endif
}
void
_rl_control_keypad (on)
int on;
{
+#if !defined (__DJGPP__)
if (on && term_ks)
tputs (term_ks, 1, _rl_output_character_function);
else if (!on && term_ke)
tputs (term_ke, 1, _rl_output_character_function);
+#endif
}
diff --git a/lib/readline/tilde.c b/lib/readline/tilde.c
index d1853bd6..777b6559 100644
--- a/lib/readline/tilde.c
+++ b/lib/readline/tilde.c
@@ -7,7 +7,7 @@
Readline is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
- Free Software Foundation; either version 1, or (at your option) any
+ Free Software Foundation; either version 2, or (at your option) any
later version.
Readline is distributed in the hope that it will be useful, but
@@ -17,7 +17,7 @@
You should have received a copy of the GNU General Public License
along with Readline; see the file COPYING. If not, write to the Free
- Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if defined (HAVE_CONFIG_H)
# include <config.h>
@@ -47,12 +47,22 @@
#include "tilde.h"
+#if defined (TEST) || defined (STATIC_MALLOC)
+static char *xmalloc (), *xrealloc ();
+#else
+# if defined __STDC__
+extern char *xmalloc (int);
+extern char *xrealloc (void *, int);
+# else
+extern char *xmalloc (), *xrealloc ();
+# endif /* !__STDC__ */
+#endif /* TEST || STATIC_MALLOC */
+
#if !defined (HAVE_GETPW_DECLS)
extern struct passwd *getpwuid (), *getpwnam ();
#endif /* !HAVE_GETPW_DECLS */
#if !defined (savestring)
-extern char *xmalloc ();
# ifndef strcpy
extern char *strcpy ();
# endif
@@ -67,17 +77,11 @@ extern char *strcpy ();
# endif /* !__STDC__ */
#endif /* !NULL */
-#if defined (TEST) || defined (STATIC_MALLOC)
-static char *xmalloc (), *xrealloc ();
-#else
-extern char *xmalloc (), *xrealloc ();
-#endif /* TEST || STATIC_MALLOC */
-
/* If being compiled as part of bash, these will be satisfied from
variables.o. If being compiled as part of readline, they will
be satisfied from shell.o. */
-extern char *get_home_dir ();
-extern char *get_env_value ();
+extern char *get_home_dir __P((void));
+extern char *get_env_value __P((char *));
/* The default value of tilde_additional_prefixes. This is set to
whitespace preceding a tilde so that simple programs which do not
@@ -122,7 +126,9 @@ tilde_find_prefix (string, len)
int *len;
{
register int i, j, string_len;
- register char **prefixes = tilde_additional_prefixes;
+ register char **prefixes;
+
+ prefixes = tilde_additional_prefixes;
string_len = strlen (string);
*len = 0;
@@ -161,7 +167,11 @@ tilde_find_suffix (string)
for (i = 0; i < string_len; i++)
{
+#if defined (__MSDOS__)
+ if (string[i] == '/' || string[i] == '\\' /* || !string[i] */)
+#else
if (string[i] == '/' /* || !string[i] */)
+#endif
break;
for (j = 0; suffixes && suffixes[j]; j++)
@@ -225,11 +235,18 @@ tilde_expand (string)
free (tilde_word);
len = strlen (expansion);
- if ((result_index + len + 1) > result_size)
- result = xrealloc (result, 1 + (result_size += (len + 20)));
+#ifdef __CYGWIN32__
+ /* Fix for Cygwin to prevent ~user/xxx from expanding to //xxx when
+ $HOME for `user' is /. On cygwin, // denotes a network drive. */
+ if (len > 1 || *expansion != '/' || *string != '/')
+#endif
+ {
+ if ((result_index + len + 1) > result_size)
+ result = xrealloc (result, 1 + (result_size += (len + 20)));
- strcpy (result + result_index, expansion);
- result_index += len;
+ strcpy (result + result_index, expansion);
+ result_index += len;
+ }
free (expansion);
}
@@ -250,7 +267,11 @@ isolate_tilde_prefix (fname, lenp)
int i;
ret = xmalloc (strlen (fname));
+#if defined (__MSDOS__)
+ for (i = 1; fname[i] && fname[i] != '/' && fname[i] != '\\'; i++)
+#else
for (i = 1; fname[i] && fname[i] != '/'; i++)
+#endif
ret[i - 1] = fname[i];
ret[i - 1] = '\0';
if (lenp)
@@ -271,7 +292,7 @@ glue_prefix_and_suffix (prefix, suffix, suffind)
plen = (prefix && *prefix) ? strlen (prefix) : 0;
slen = strlen (suffix + suffind);
ret = xmalloc (plen + slen + 1);
- if (prefix && *prefix)
+ if (plen)
strcpy (ret, prefix);
strcpy (ret + plen, suffix + suffind);
return ret;
diff --git a/lib/readline/tilde.h b/lib/readline/tilde.h
index 634b9544..7783fd61 100644
--- a/lib/readline/tilde.h
+++ b/lib/readline/tilde.h
@@ -8,7 +8,7 @@
The Library is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 1, or (at your option)
+ the Free Software Foundation; either version 2, or (at your option)
any later version.
The Library is distributed in the hope that it will be useful, but
@@ -19,11 +19,27 @@
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
- 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if !defined (_TILDE_H_)
# define _TILDE_H_
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* A function can be defined using prototypes and compile on both ANSI C
+ and traditional C compilers with something like this:
+ extern char *func __P((char *, char *, int)); */
+
+#if !defined (__P)
+# if defined (__STDC__) || defined (__GNUC__) || defined (__cplusplus)
+# define __P(protos) protos
+# else
+# define __P(protos) ()
+# endif
+#endif
+
/* Function pointers can be declared as (Function *)foo. */
#if !defined (_FUNCTION_DEF)
# define _FUNCTION_DEF
@@ -56,10 +72,14 @@ extern char **tilde_additional_prefixes;
extern char **tilde_additional_suffixes;
/* Return a new string which is the result of tilde expanding STRING. */
-extern char *tilde_expand ();
+extern char *tilde_expand __P((char *));
/* Do the work of tilde expansion on FILENAME. FILENAME starts with a
tilde. If there is no expansion, call tilde_expansion_failure_hook. */
-extern char *tilde_expand_word ();
+extern char *tilde_expand_word __P((char *));
+
+#ifdef __cplusplus
+}
+#endif
#endif /* _TILDE_H_ */
diff --git a/lib/readline/undo.c b/lib/readline/undo.c
index 28ebcc85..f7f30d17 100644
--- a/lib/readline/undo.c
+++ b/lib/readline/undo.c
@@ -8,7 +8,7 @@
The GNU Readline Library is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 1, or
+ as published by the Free Software Foundation; either version 2, or
(at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be
@@ -19,7 +19,7 @@
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
- 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
@@ -47,6 +47,8 @@
#include "readline.h"
#include "history.h"
+#include "rlprivate.h"
+
#define SWAP(s, e) do { int t; t = s; s = e; e = t; } while (0)
/* Non-zero tells rl_delete_text and rl_insert_text to not add to
diff --git a/lib/readline/util.c b/lib/readline/util.c
index 1dc3b664..be9e0a98 100644
--- a/lib/readline/util.c
+++ b/lib/readline/util.c
@@ -7,7 +7,7 @@
The GNU Readline Library is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 1, or
+ as published by the Free Software Foundation; either version 2, or
(at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be
@@ -18,7 +18,7 @@
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
- 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
@@ -52,24 +52,10 @@
/* Some standard library routines. */
#include "readline.h"
-#define SWAP(s, e) do { int t; t = s; s = e; e = t; } while (0)
-
-/* Pseudo-globals imported from readline.c */
-extern int readline_echoing_p;
-extern procenv_t readline_top_level;
-extern int rl_line_buffer_len;
-extern Function *rl_last_func;
-
-extern int _rl_defining_kbd_macro;
-extern char *_rl_executing_macro;
+#include "rlprivate.h"
+#include "xmalloc.h"
-/* Pseudo-global functions imported from other library files. */
-extern void _rl_replace_text ();
-extern void _rl_pop_executing_macro ();
-extern void _rl_set_the_line ();
-extern void _rl_init_argument ();
-
-extern char *xmalloc (), *xrealloc ();
+#define SWAP(s, e) do { int t; t = s; s = e; e = t; } while (0)
/* **************************************************************** */
/* */
diff --git a/lib/readline/vi_keymap.c b/lib/readline/vi_keymap.c
index 14929a31..cf6724ce 100644
--- a/lib/readline/vi_keymap.c
+++ b/lib/readline/vi_keymap.c
@@ -7,7 +7,7 @@
The GNU Readline Library is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 1, or
+ as published by the Free Software Foundation; either version 2, or
(at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be
@@ -18,7 +18,7 @@
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
- 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if !defined (BUFSIZ)
#include <stdio.h>
diff --git a/lib/readline/vi_mode.c b/lib/readline/vi_mode.c
index d4868bf3..be7f9496 100644
--- a/lib/readline/vi_mode.c
+++ b/lib/readline/vi_mode.c
@@ -8,7 +8,7 @@
The GNU Readline Library is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 1, or
+ as published by the Free Software Foundation; either version 2, or
(at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be
@@ -19,7 +19,7 @@
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
- 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#define READLINE_LIBRARY
/* **************************************************************** */
@@ -54,6 +54,9 @@
#include "readline.h"
#include "history.h"
+#include "rlprivate.h"
+#include "xmalloc.h"
+
#ifndef _rl_digit_p
#define _rl_digit_p(c) ((c) >= '0' && (c) <= '9')
#endif
@@ -74,26 +77,6 @@
#define exchange(x, y) do {int temp = x; x = y; y = temp;} while (0)
#endif
-extern char *xmalloc (), *xrealloc ();
-
-/* Variables imported from readline.c */
-extern int rl_point, rl_end, rl_mark;
-extern FILE *rl_instream;
-extern int rl_line_buffer_len, rl_explicit_arg, rl_numeric_arg;
-extern Keymap _rl_keymap;
-extern char *rl_prompt;
-extern char *rl_line_buffer;
-extern int rl_arg_sign;
-
-extern int _rl_doing_an_undo;
-extern int _rl_undo_group_level;
-
-extern void _rl_dispatch ();
-extern int _rl_char_search_internal ();
-
-extern void rl_extend_line_buffer ();
-extern int rl_vi_check ();
-
/* Non-zero means enter insertion mode. */
static int _rl_vi_doing_insert;
@@ -131,7 +114,7 @@ static char *vi_textmod = "_*\\AaIiCcDdPpYyRrSsXx~";
/* Arrays for the saved marks. */
static int vi_mark_chars[27];
-static int rl_digit_loop1 ();
+static int rl_digit_loop1 __P((void));
void
_rl_vi_initialize_line ()
@@ -1043,7 +1026,7 @@ rl_vi_char_search (count, key)
if (vi_redoing)
target = _rl_vi_last_search_char;
else
- _rl_vi_last_search_char = target = rl_getc (rl_instream);
+ _rl_vi_last_search_char = target = (*rl_getc_function) (rl_instream);
switch (key)
{
@@ -1159,7 +1142,7 @@ rl_vi_change_char (count, key)
if (vi_redoing)
c = _rl_vi_last_replacement;
else
- _rl_vi_last_replacement = c = rl_getc (rl_instream);
+ _rl_vi_last_replacement = c = (*rl_getc_function) (rl_instream);
if (c == '\033' || c == CTRL ('C'))
return -1;
diff --git a/lib/readline/xmalloc.c b/lib/readline/xmalloc.c
index 41606511..c0d06403 100644
--- a/lib/readline/xmalloc.c
+++ b/lib/readline/xmalloc.c
@@ -7,7 +7,7 @@
Readline is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
- Free Software Foundation; either version 1, or (at your option) any
+ Free Software Foundation; either version 2, or (at your option) any
later version.
Readline is distributed in the hope that it will be useful, but
@@ -17,7 +17,8 @@
You should have received a copy of the GNU General Public License
along with Readline; see the file COPYING. If not, write to the Free
- Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
#include <config.h>
@@ -31,7 +32,7 @@
# include "ansi_stdlib.h"
#endif /* HAVE_STDLIB_H */
-static void memory_error_and_abort ();
+#include "xmalloc.h"
/* **************************************************************** */
/* */
@@ -39,6 +40,14 @@ static void memory_error_and_abort ();
/* */
/* **************************************************************** */
+static void
+memory_error_and_abort (fname)
+ char *fname;
+{
+ fprintf (stderr, "%s: out of virtual memory\n", fname);
+ exit (2);
+}
+
/* Return a pointer to free()able block of memory large enough
to hold BYTES number of bytes. If the memory cannot be allocated,
print an error message and abort. */
@@ -56,7 +65,7 @@ xmalloc (bytes)
char *
xrealloc (pointer, bytes)
- char *pointer;
+ PTR_T pointer;
int bytes;
{
char *temp;
@@ -68,19 +77,11 @@ xrealloc (pointer, bytes)
return (temp);
}
-static void
-memory_error_and_abort (fname)
- char *fname;
-{
- fprintf (stderr, "%s: out of virtual memory\n", fname);
- exit (2);
-}
-
/* Use this as the function to call when adding unwind protects so we
don't need to know what free() returns. */
void
xfree (string)
- char *string;
+ PTR_T string;
{
if (string)
free (string);
diff --git a/lib/readline/xmalloc.h b/lib/readline/xmalloc.h
new file mode 100644
index 00000000..bdf251b0
--- /dev/null
+++ b/lib/readline/xmalloc.h
@@ -0,0 +1,46 @@
+/* xmalloc.h -- memory allocation that aborts on errors. */
+
+/* Copyright (C) 1999 Free Software Foundation, Inc.
+
+ This file is part of the GNU Readline Library, a library for
+ reading lines of text with interactive input and history editing.
+
+ The GNU Readline Library is free software; you can redistribute it
+ and/or modify it under the terms of the GNU General Public License
+ as published by the Free Software Foundation; either version 2, or
+ (at your option) any later version.
+
+ The GNU Readline Library is distributed in the hope that it will be
+ useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+ of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ The GNU General Public License is often shipped with GNU software, and
+ is generally kept in a file called COPYING or LICENSE. If you do not
+ have a copy of the license, write to the Free Software Foundation,
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+
+#if !defined (_XMALLOC_H_)
+#define _XMALLOC_H_
+
+#if defined (READLINE_LIBRARY)
+# include "rlstdc.h"
+#else
+# include <readline/rlstdc.h>
+#endif
+
+#ifndef PTR_T
+
+#ifdef __STDC__
+# define PTR_T void *
+#else
+# define PTR_T char *
+#endif
+
+#endif /* !PTR_T */
+
+extern char *xmalloc __P((int));
+extern char *xrealloc __P((void *, int));
+extern void xfree __P((void *));
+
+#endif /* _XMALLOC_H_ */
diff --git a/lib/sh/Makefile.in b/lib/sh/Makefile.in
index 439595c1..789c5448 100644
--- a/lib/sh/Makefile.in
+++ b/lib/sh/Makefile.in
@@ -1,13 +1,29 @@
#
# Makefile for the Bash library
#
+#
+# Copyright (C) 1998 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
srcdir = @srcdir@
VPATH = .:@srcdir@
topdir = @top_srcdir@
BUILD_DIR = @BUILD_DIR@
-POSIX_INC = ${topdir}/lib/posixheaders
+BASHINCDIR = ${topdir}/include
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -33,7 +49,7 @@ PROFILE_FLAGS = @PROFILE_FLAGS@
DEFS = @DEFS@
LOCAL_DEFS = @LOCAL_DEFS@
-INCLUDES = -I. -I../.. -I$(topdir) -I$(topdir)/lib -I$(POSIX_INC) -I$(srcdir)
+INCLUDES = -I. -I../.. -I$(topdir) -I$(topdir)/lib -I$(BASHINCDIR) -I$(srcdir)
CCFLAGS = ${PROFILE_FLAGS} ${INCLUDES} $(DEFS) $(LOCAL_DEFS) $(LOCAL_CFLAGS) \
$(CFLAGS) $(CPPFLAGS)
@@ -45,17 +61,19 @@ CCFLAGS = ${PROFILE_FLAGS} ${INCLUDES} $(DEFS) $(LOCAL_DEFS) $(LOCAL_CFLAGS) \
LIBRARY_NAME = libsh.a
# The C code source files for this library.
-CSOURCES = clktck.c getcwd.c getenv.c oslib.c setlinebuf.c \
+CSOURCES = clktck.c clock.c getcwd.c getenv.c oslib.c setlinebuf.c \
strcasecmp.c strerror.c strtod.c strtol.c strtoul.c \
- vprint.c itos.c rename.c
+ vprint.c itos.c rename.c zread.c zwrite.c shtty.c \
+ inet_aton.c netopen.c strpbrk.c timeval.c makepath.c
# The header files for this library.
HSOURCES =
# The object files contained in $(LIBRARY_NAME)
-OBJECTS = clktck.o getcwd.o getenv.o oslib.o setlinebuf.o \
+OBJECTS = clktck.o clock.o getcwd.o getenv.o oslib.o setlinebuf.o \
strcasecmp.o strerror.o strtod.o strtol.o strtoul.o \
- vprint.o itos.o rename.o
+ vprint.o itos.o rename.o zread.o zwrite.o shtty.o \
+ inet_aton.o netopen.o strpbrk.o timeval.o makepath.o
SUPPORT = Makefile
@@ -85,87 +103,124 @@ mostlyclean: clean
# rules for losing makes, like SunOS
clktck.o: clktck.c
+clock.o: clock.c
getcwd.o: getcwd.c
getenv.o: getenv.c
+inet_aton.o: inet_aton.c
itos.o: itos.c
+netopen.o: netopen.c
oslib.o: oslib.c
rename.o: rename.c
setlinebuf.o: setlinebuf.c
+shquote.o: shquote.c
+shtty.o: shtty.c
strcasecmp.o: strcasecmp.c
strerror.o: strerror.c
+strpbrk.o: strpbrk.c
strtod.o: strtod.c
strtol.o: strtol.c
strtoul.o: strtoul.c
+times.o: times.c
+timeval.o: timeval.c
vprint.o: vprint.c
+zread.o: zread.c
+zwrite.o: zwrite.c
# all files in the library depend on config.h
clktck.o: ${BUILD_DIR}/config.h
+clock.o: ${BUILD_DIR}/config.h
getcwd.o: ${BUILD_DIR}/config.h
getenv.o: ${BUILD_DIR}/config.h
+inet_aton.o: ${BUILD_DIR}/config.h
itos.o: ${BUILD_DIR}/config.h
+netopen.o: ${BUILD_DIR}/config.h
oslib.o: ${BUILD_DIR}/config.h
rename.o: ${BUILD_DIR}/config.h
setlinebuf.o: ${BUILD_DIR}/config.h
+shquote.o: ${BUILD_DIR}/config.h
+shtty.o: ${BUILD_DIR}/config.h
strcasecmp.o: ${BUILD_DIR}/config.h
strerror.o: ${BUILD_DIR}/config.h
+strpbrk.o: ${BUILD_DIR}/config.h
strtod.o: ${BUILD_DIR}/config.h
strtol.o: ${BUILD_DIR}/config.h
strtoul.o: ${BUILD_DIR}/config.h
+times.o: ${BUILD_DIR}/config.h
+timeval.o: ${BUILD_DIR}/config.h
vprint.o: ${BUILD_DIR}/config.h
+zread.o: ${BUILD_DIR}/config.h
+zwrite.o: ${BUILD_DIR}/config.h
clktck.o: ${topdir}/bashtypes.h
-getcwd.o: ${topdir}/bashtypes.h ${topdir}/bashansi.h ${topdir}/maxpath.h
-getcwd.o: ${POSIX_INC}/posixstat.h ${POSIX_INC}/posixdir.h
-getcwd.o: ${POSIX_INC}/memalloc.h ${POSIX_INC}/ansi_stdlib.h
+getcwd.o: ${topdir}/bashtypes.h ${topdir}/bashansi.h ${BASHINCDIR}/maxpath.h
+getcwd.o: ${BASHINCDIR}/posixstat.h ${BASHINCDIR}/posixdir.h
+getcwd.o: ${BASHINCDIR}/memalloc.h ${BASHINCDIR}/ansi_stdlib.h
-getenv.o: ${topdir}/bashansi.h ${topdir}/ansi_stdlib.h
-getenv.o: ${topdir}/shell.h ${topdir}/bashjmp.h ${topdir}/posixjmp.h
-getenv.o: ${topdir}/command.h ${topdir}/stdc.h ${topdir}/error.h
+getenv.o: ${topdir}/bashansi.h ${BASHINCDIR}/ansi_stdlib.h
+getenv.o: ${topdir}/shell.h ${topdir}/bashjmp.h ${BASHINCDIR}/posixjmp.h
+getenv.o: ${topdir}/command.h ${BASHINCDIR}/stdc.h ${topdir}/error.h
getenv.o: ${topdir}/general.h ${topdir}/bashtypes.h ${topdir}/variables.h
getenv.o: ${topdir}/array.h ${topdir}/hashlib.h ${topdir}/quit.h
getenv.o: ${topdir}/unwind_prot.h ${topdir}/dispose_cmd.h
getenv.o: ${topdir}/make_cmd.h ${topdir}/subst.h ${topdir}/sig.h
getenv.o: ${topdir}/pathnames.h ${topdir}/externs.h
-itos.o: ${topdir}/bashansi.h ${topdir}/ansi_stdlib.h
-itos.o: ${topdir}/shell.h ${topdir}/bashjmp.h ${topdir}/posixjmp.h
-itos.o: ${topdir}/command.h ${topdir}/stdc.h ${topdir}/error.h
+inet_aton.o: ${topdir}/bashansi.h ${BASHINCDIR}/ansi_stdlib.h
+inet_aton.o: ${BASHINCDIR}/stdc.h
+
+itos.o: ${topdir}/bashansi.h ${BASHINCDIR}/ansi_stdlib.h
+itos.o: ${topdir}/shell.h ${topdir}/bashjmp.h ${BASHINCDIR}/posixjmp.h
+itos.o: ${topdir}/command.h ${BASHINCDIR}/stdc.h ${topdir}/error.h
itos.o: ${topdir}/general.h ${topdir}/bashtypes.h ${topdir}/variables.h
itos.o: ${topdir}/array.h ${topdir}/hashlib.h ${topdir}/quit.h
itos.o: ${topdir}/unwind_prot.h ${topdir}/dispose_cmd.h
itos.o: ${topdir}/make_cmd.h ${topdir}/subst.h ${topdir}/sig.h
itos.o: ${topdir}/pathnames.h ${topdir}/externs.h
-oslib.o: ${topdir}/bashtypes.h ${topdir}/bashansi.h ${topdir}/maxpath.h
-oslib.o: ${topdir}/shell.h ${topdir}/bashjmp.h ${topdir}/posixjmp.h
-oslib.o: ${topdir}/command.h ${topdir}/stdc.h ${topdir}/error.h
+netopen.o: ${topdir}/bashansi.h ${BASHINCDIR}/ansi_stdlib.h
+
+oslib.o: ${topdir}/bashtypes.h ${topdir}/bashansi.h ${BASHINCDIR}/maxpath.h
+oslib.o: ${topdir}/shell.h ${topdir}/bashjmp.h ${BASHINCDIR}/posixjmp.h
+oslib.o: ${topdir}/command.h ${BASHINCDIR}/stdc.h ${topdir}/error.h
oslib.o: ${topdir}/general.h ${topdir}/bashtypes.h ${topdir}/variables.h
oslib.o: ${topdir}/array.h ${topdir}/hashlib.h ${topdir}/quit.h
oslib.o: ${topdir}/unwind_prot.h ${topdir}/dispose_cmd.h
oslib.o: ${topdir}/make_cmd.h ${topdir}/subst.h ${topdir}/sig.h
oslib.o: ${topdir}/pathnames.h ${topdir}/externs.h
-oslib.o: ${POSIX_INC}/posixstat.h ${POSIX_INC}/filecntl.h
-oslib.o: ${POSIX_INC}/ansi_stdlib.h
+oslib.o: ${BASHINCDIR}/posixstat.h ${BASHINCDIR}/filecntl.h
+oslib.o: ${BASHINCDIR}/ansi_stdlib.h
-rename.o: ${topdir}/bashtypes.h ${topdir}/stdc.h
+rename.o: ${topdir}/bashtypes.h ${BASHINCDIR}/stdc.h
-strcasecmp.o: ${topdir}/stdc.h ${topdir}/bashansi.h ${topdir}/ansi_stdlib.h
+shtty.o: ${BASHINCDIR}/shtty.h
+shtty.o: ${BASHINCDIR}/stdc.h
+
+strcasecmp.o: ${BASHINCDIR}/stdc.h ${topdir}/bashansi.h ${BASHINCDIR}/ansi_stdlib.h
strerror.o: ${topdir}/bashtypes.h
-strerror.o: ${topdir}/shell.h ${topdir}/bashjmp.h ${topdir}/posixjmp.h
-strerror.o: ${topdir}/command.h ${topdir}/stdc.h ${topdir}/error.h
+strerror.o: ${topdir}/shell.h ${topdir}/bashjmp.h ${BASHINCDIR}/posixjmp.h
+strerror.o: ${topdir}/command.h ${BASHINCDIR}/stdc.h ${topdir}/error.h
strerror.o: ${topdir}/general.h ${topdir}/bashtypes.h ${topdir}/variables.h
strerror.o: ${topdir}/array.h ${topdir}/hashlib.h ${topdir}/quit.h
strerror.o: ${topdir}/unwind_prot.h ${topdir}/dispose_cmd.h
strerror.o: ${topdir}/make_cmd.h ${topdir}/subst.h ${topdir}/sig.h
strerror.o: ${topdir}/pathnames.h ${topdir}/externs.h
+strpbrk.o: ${BASHINCDIR}/stdc.h
+
strtod.o: ${topdir}/bashansi.h
-strtod.o: ${POSIX_INC}/ansi_stdlib.h
+strtod.o: ${BASHINCDIR}/ansi_stdlib.h
strtol.o: ${topdir}/bashansi.h
-strtol.o: ${POSIX_INC}/ansi_stdlib.h
+strtol.o: ${BASHINCDIR}/ansi_stdlib.h
strtoul.o: ${topdir}/bashansi.h
-strtoul.o: ${POSIX_INC}/ansi_stdlib.h
+strtoul.o: ${BASHINCDIR}/ansi_stdlib.h
+
+times.o: ${BASHINCDIR}/systimes.h
+times.o: ${BASHINCDIR}/posixtime.h
+
+timeval.o: ${BASHINCDIR}/posixtime.h
+
+clock.o: ${BASHINCDIR}/posixtime.h
diff --git a/lib/sh/clock.c b/lib/sh/clock.c
new file mode 100644
index 00000000..9a91e384
--- /dev/null
+++ b/lib/sh/clock.c
@@ -0,0 +1,78 @@
+/* clock.c - operations on struct tms and clock_t's */
+
+/* Copyright (C) 1999 Free Software Foundation, Inc.
+
+ This file is part of GNU Bash, the Bourne Again SHell.
+
+ Bash is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free
+ Software Foundation; either version 2, or (at your option) any later
+ version.
+
+ Bash is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with Bash; see the file COPYING. If not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA */
+
+#include <config.h>
+
+#if defined (HAVE_TIMES)
+
+#include <sys/types.h>
+#include <posixtime.h>
+
+#if defined (HAVE_SYS_TIMES_H)
+# include <sys/times.h>
+#endif
+
+#include <stdio.h>
+
+void
+clock_t_to_secs (t, sp, sfp)
+ clock_t t;
+ long *sp;
+ int *sfp;
+{
+ static long clk_tck = -1;
+
+ if (clk_tck == -1)
+ clk_tck = get_clk_tck ();
+
+ *sfp = t % clk_tck;
+ *sfp = (*sfp * 1000) / clk_tck;
+
+ *sp = t / clk_tck;
+
+ /* Sanity check */
+ if (*sfp >= 1000)
+ {
+ *sp += 1;
+ *sfp -= 1000;
+ }
+}
+
+/* Print the time defined by a clock_t (returned by the `times' and `time'
+ system calls) in a standard way to stdio stream FP. This is scaled in
+ terms of the value of CLK_TCK, which is what is returned by the
+ `times' call. */
+void
+print_clock_t (fp, t)
+ FILE *fp;
+ clock_t t;
+{
+ int minutes, seconds_fraction;
+ long seconds;
+
+ clock_t_to_secs (t, &seconds, &seconds_fraction);
+
+ minutes = seconds / 60;
+ seconds %= 60;
+
+ fprintf (fp, "%0dm%0ld.%03ds", minutes, seconds, seconds_fraction);
+}
+#endif /* HAVE_TIMES */
+
diff --git a/lib/sh/getcwd.c b/lib/sh/getcwd.c
index 9a8b31f7..d39655d8 100644
--- a/lib/sh/getcwd.c
+++ b/lib/sh/getcwd.c
@@ -15,8 +15,8 @@
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
- not, write to the Free Software Foundation, Inc., 675 Mass Ave,
- Cambridge, MA 02139, USA. */
+ not, write to the Free Software Foundation, Inc.,
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#include <config.h>
@@ -64,6 +64,10 @@ extern int errno;
# define lstat stat
#endif
+#if !defined (NULL)
+# define NULL 0
+#endif
+
/* Get the pathname of the current working directory,
and put it in SIZE bytes of BUF. Returns NULL if the
directory couldn't be determined or SIZE was too small.
@@ -138,14 +142,14 @@ getcwd (buf, size)
char *new;
if (dotlist == dots)
{
- new = malloc (dotsize * 2 + 1);
+ new = (char *)malloc (dotsize * 2 + 1);
if (new == NULL)
goto lose;
memcpy (new, dots, dotsize);
}
else
{
- new = realloc ((PTR) dotlist, dotsize * 2 + 1);
+ new = (char *)realloc ((PTR) dotlist, dotsize * 2 + 1);
if (new == NULL)
goto lose;
}
@@ -222,13 +226,13 @@ getcwd (buf, size)
if (pathbuf == path)
{
- new = malloc (pathsize * 2);
+ new = (char *)malloc (pathsize * 2);
if (!new)
goto lose;
}
else
{
- new = realloc ((PTR) pathbuf, (pathsize * 2));
+ new = (char *)realloc ((PTR) pathbuf, (pathsize * 2));
if (!new)
goto lose;
pathp = new + space;
diff --git a/lib/sh/getenv.c b/lib/sh/getenv.c
index 63536154..3d81ee4c 100644
--- a/lib/sh/getenv.c
+++ b/lib/sh/getenv.c
@@ -56,7 +56,7 @@ getenv (name)
{
FREE (last_tempenv_value);
- last_tempenv_value = savestring (value_cell (var));
+ last_tempenv_value = value_cell (var) ? savestring (value_cell (var)) : (char *)NULL;
dispose_variable (var);
return (last_tempenv_value);
}
diff --git a/lib/sh/inet_aton.c b/lib/sh/inet_aton.c
new file mode 100644
index 00000000..28cd9790
--- /dev/null
+++ b/lib/sh/inet_aton.c
@@ -0,0 +1,205 @@
+/* Snagged from GNU C library, version 2.0.3. */
+
+/*
+ * ++Copyright++ 1983, 1990, 1993
+ * -
+ * Copyright (c) 1983, 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * -
+ * Portions Copyright (c) 1993 by Digital Equipment Corporation.
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies, and that
+ * the name of Digital Equipment Corporation not be used in advertising or
+ * publicity pertaining to distribution of the document or software without
+ * specific, written prior permission.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
+ * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ * -
+ * --Copyright--
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)inet_addr.c 8.1 (Berkeley) 6/17/93";
+static char rcsid[] = "$Id: inet_addr.c,v 1.5 1996/08/14 03:48:37 drepper Exp $";
+#endif /* LIBC_SCCS and not lint */
+
+#include <config.h>
+
+#if !defined (HAVE_INET_ATON) && defined (HAVE_NETWORK) && defined (HAVE_NETINET_IN_H) && defined (HAVE_ARPA_INET_H)
+
+#include <sys/types.h>
+#include <sys/param.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+
+#include <bashansi.h>
+#include <ctype.h>
+#include <stdc.h>
+
+#ifndef INADDR_NONE
+# define INADDR_NONE 0xffffffff
+#endif
+
+/* these are compatibility routines, not needed on recent BSD releases */
+
+#if 0
+/* Not used, not needed. */
+/*
+ * Ascii internet address interpretation routine.
+ * The value returned is in network order.
+ */
+u_long
+inet_addr(cp)
+ register const char *cp;
+{
+ struct in_addr val;
+
+ if (inet_aton(cp, &val))
+ return (val.s_addr);
+ return (INADDR_NONE);
+}
+#endif
+
+/*
+ * Check whether "cp" is a valid ascii representation
+ * of an Internet address and convert to a binary address.
+ * Returns 1 if the address is valid, 0 if not.
+ * This replaces inet_addr, the return value from which
+ * cannot distinguish between failure and a local broadcast address.
+ */
+int
+inet_aton(cp, addr)
+ register const char *cp;
+ struct in_addr *addr;
+{
+ register u_bits32_t val;
+ register int base, n;
+ register char c;
+ u_int parts[4];
+ register u_int *pp = parts;
+
+ c = *cp;
+ for (;;) {
+ /*
+ * Collect number up to ``.''.
+ * Values are specified as for C:
+ * 0x=hex, 0=octal, isdigit=decimal.
+ */
+ if (!isdigit(c))
+ return (0);
+ val = 0; base = 10;
+ if (c == '0') {
+ c = *++cp;
+ if (c == 'x' || c == 'X')
+ base = 16, c = *++cp;
+ else
+ base = 8;
+ }
+ for (;;) {
+ if (isascii(c) && isdigit(c)) {
+ val = (val * base) + (c - '0');
+ c = *++cp;
+ } else if (base == 16 && isascii(c) && isxdigit(c)) {
+ val = (val << 4) |
+ (c + 10 - (islower(c) ? 'a' : 'A'));
+ c = *++cp;
+ } else
+ break;
+ }
+ if (c == '.') {
+ /*
+ * Internet format:
+ * a.b.c.d
+ * a.b.c (with c treated as 16 bits)
+ * a.b (with b treated as 24 bits)
+ */
+ if (pp >= parts + 3)
+ return (0);
+ *pp++ = val;
+ c = *++cp;
+ } else
+ break;
+ }
+ /*
+ * Check for trailing characters.
+ */
+ if (c != '\0' && (!isascii(c) || !isspace(c)))
+ return (0);
+ /*
+ * Concoct the address according to
+ * the number of parts specified.
+ */
+ n = pp - parts + 1;
+ switch (n) {
+
+ case 0:
+ return (0); /* initial nondigit */
+
+ case 1: /* a -- 32 bits */
+ break;
+
+ case 2: /* a.b -- 8.24 bits */
+ if (val > 0xffffff)
+ return (0);
+ val |= parts[0] << 24;
+ break;
+
+ case 3: /* a.b.c -- 8.8.16 bits */
+ if (val > 0xffff)
+ return (0);
+ val |= (parts[0] << 24) | (parts[1] << 16);
+ break;
+
+ case 4: /* a.b.c.d -- 8.8.8.8 bits */
+ if (val > 0xff)
+ return (0);
+ val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8);
+ break;
+ }
+ if (addr)
+ addr->s_addr = htonl(val);
+ return (1);
+}
+
+#endif /* !HAVE_INET_ATON */
diff --git a/lib/sh/itos.c b/lib/sh/itos.c
index 5105cb72..dee78832 100644
--- a/lib/sh/itos.c
+++ b/lib/sh/itos.c
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#include <config.h>
diff --git a/lib/sh/makepath.c b/lib/sh/makepath.c
new file mode 100644
index 00000000..dfc12108
--- /dev/null
+++ b/lib/sh/makepath.c
@@ -0,0 +1,116 @@
+/* makepath.c - glue PATH and DIR together into a full pathname. */
+
+/* Copyright (C) 1987, 1989, 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 2, or (at your option) any later
+ version.
+
+ Bash is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with Bash; see the file COPYING. If not, write to the Free Software
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+
+#include <config.h>
+
+#if defined (HAVE_UNISTD_H)
+# ifdef _MINIX
+# include <sys/types.h>
+# endif
+# include <unistd.h>
+#endif
+
+#include "bashansi.h"
+#include "shell.h"
+
+#include <tilde/tilde.h>
+
+#ifndef NULL
+# define NULL 0
+#endif
+
+/* MAKE SURE THESE AGREE WITH ../../externs.h. */
+
+#ifndef MP_DOTILDE
+# define MP_DOTILDE 0x01
+# define MP_DOCWD 0x02
+# define MP_RMDOT 0x04
+#endif
+
+extern char *get_working_directory __P((char *));
+
+/* Take PATH, an element from, e.g., $CDPATH, and DIR, a directory name,
+ and paste them together into PATH/DIR. Tilde expansion is performed on
+ PATH if (flags & MP_DOTILDE) is non-zero. If PATH is NULL or the empty
+ string, it is converted to the current directory. A full pathname is
+ used if (flags & MP_DOCWD) is non-zero, otherwise `./' is used. If
+ (flags & MP_RMDOT) is non-zero, any `./' is removed from the beginning
+ of DIR. */
+
+#define MAKEDOT() \
+ do { \
+ xpath = xmalloc (2); \
+ xpath[0] = '.'; \
+ xpath[1] = '\0'; \
+ pathlen = 1; \
+ } while (0)
+
+char *
+sh_makepath (path, dir, flags)
+ char *path, *dir;
+ int flags;
+{
+ int dirlen, pathlen;
+ char *ret, *xpath;
+
+ if (path == 0 || *path == '\0')
+ {
+ if (flags & MP_DOCWD)
+ {
+ xpath = get_working_directory ("sh_makepath");
+ if (xpath == 0)
+ {
+ ret = get_string_value ("PWD");
+ if (ret)
+ xpath = savestring (ret);
+ }
+ if (xpath == 0)
+ MAKEDOT();
+ else
+ pathlen = strlen (xpath);
+ }
+ else
+ MAKEDOT();
+ }
+ else
+ {
+ xpath = ((flags & MP_DOTILDE) && *path == '~') ? bash_tilde_expand (path) : path;
+ pathlen = strlen (xpath);
+ }
+
+ dirlen = strlen (dir);
+ if ((flags & MP_RMDOT) && dir[0] == '.' && dir[1] == '/')
+ {
+ dir += 2;
+ dirlen -= 2;
+ }
+
+ ret = xmalloc (2 + dirlen + pathlen);
+ strcpy (ret, xpath);
+ if (xpath[pathlen - 1] != '/')
+ {
+ ret[pathlen++] = '/';
+ ret[pathlen] = '\0';
+ }
+ strcpy (ret + pathlen, dir);
+ if (xpath != path)
+ free (xpath);
+ return (ret);
+}
diff --git a/lib/sh/netopen.c b/lib/sh/netopen.c
new file mode 100644
index 00000000..789a9b39
--- /dev/null
+++ b/lib/sh/netopen.c
@@ -0,0 +1,228 @@
+/*
+ * netopen.c -- functions to make tcp/udp connections
+ *
+ * Chet Ramey
+ * chet@ins.CWRU.Edu
+ */
+
+/* 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 2, or (at your option)
+ any later version.
+
+ Bash is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
+ License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Bash; see the file COPYING. If not, write to the Free
+ Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+
+#include <config.h>
+
+#if defined (HAVE_NETWORK)
+
+#include <stdio.h>
+#include <sys/types.h>
+
+#if defined (HAVE_SYS_SOCKET_H)
+# include <sys/socket.h>
+#endif
+
+#if defined (HAVE_NETINET_IN_H)
+# include <netinet/in.h>
+#endif
+
+#if defined (HAVE_NETDB_H)
+# include <netdb.h>
+#endif
+
+#if defined (HAVE_ARPA_INET_H)
+# include <arpa/inet.h>
+#endif
+
+#include <bashansi.h>
+#include <ctype.h>
+#include <errno.h>
+
+#ifndef errno
+extern int errno;
+#endif
+
+#if !defined (HAVE_INET_ATON)
+extern int inet_aton ();
+#endif
+
+extern char *xmalloc ();
+
+/* Stuff the internet address corresponding to HOST into AP, in network
+ byte order. Return 1 on success, 0 on failure. */
+
+static int
+_getaddr (host, ap)
+ char *host;
+ struct in_addr *ap;
+{
+ struct hostent *h;
+ int r;
+
+ r = 0;
+ if (isdigit (host[0]))
+ {
+ /* If the first character is a digit, guess that it's an
+ Internet address and return immediately if inet_aton succeeds. */
+ r = inet_aton (host, ap);
+ if (r)
+ return r;
+ }
+#if !defined (HAVE_GETHOSTBYNAME)
+ return 0;
+#else
+ h = gethostbyname (host);
+ if (h && h->h_addr)
+ {
+ bcopy(h->h_addr, (char *)ap, h->h_length);
+ return 1;
+ }
+#endif
+ return 0;
+
+}
+
+/* Return 1 if SERV is a valid port number and stuff the converted value into
+ PP in network byte order. */
+static int
+_getserv (serv, pp)
+ char *serv;
+ unsigned short *pp;
+{
+ long l;
+ unsigned short s;
+
+ if (legal_number (serv, &l))
+ {
+ if (l > 65535)
+ return 0;
+ s = (unsigned short)(l & 0xFFFF);
+ s = htons (s);
+ if (pp)
+ *pp = s;
+ return 1;
+ }
+ else
+ return 0;
+}
+
+static int
+_netopen(host, serv, typ)
+ char *host, *serv;
+ int typ;
+{
+ struct in_addr ina;
+ struct sockaddr_in sin;
+ unsigned short p;
+ int s;
+ char **cp;
+
+ if (_getaddr(host, &ina) == 0)
+ {
+ internal_error ("%s: host unknown", host);
+ return -1;
+ }
+
+ if (_getserv(serv, &p) == 0)
+ {
+ internal_error("%s: invalid service", serv);
+ return -1;
+ }
+
+ bzero ((char *)&sin, sizeof(sin));
+ sin.sin_family = AF_INET;
+ sin.sin_port = p;
+ sin.sin_addr = ina;
+
+ s = socket(AF_INET, (typ == 't') ? SOCK_STREAM : SOCK_DGRAM, 0);
+ if (s < 0)
+ {
+ sys_error ("socket");
+ return (-1);
+ }
+
+ if (connect (s, (struct sockaddr *)&sin, sizeof (sin)) < 0)
+ {
+ sys_error("connect");
+ close(s);
+ return (-1);
+ }
+
+ return(s);
+}
+
+/*
+ * Open a TCP or UDP connection given a path like `/dev/tcp/host/port' to
+ * host `host' on port `port' and return the connected socket.
+ */
+int
+netopen (path)
+ char *path;
+{
+ char *np, *s, *t;
+ int fd;
+
+ np = xmalloc (strlen (path) + 1);
+ strcpy (np, path);
+
+ s = np + 9;
+ t = strchr (s, '/');
+ if (t == 0)
+ {
+ internal_error ("%s: bad network path specification", path);
+ return -1;
+ }
+ *t++ = '\0';
+ fd = _netopen (s, t, path[5]);
+ free (np);
+
+ return fd;
+}
+
+#if 0
+/*
+ * Open a TCP connection to host `host' on the port defined for service
+ * `serv' and return the connected socket.
+ */
+int
+tcpopen (host, serv)
+ char *host, *serv;
+{
+ return (_netopen (host, serv, 't'));
+}
+
+/*
+ * Open a UDP connection to host `host' on the port defined for service
+ * `serv' and return the connected socket.
+ */
+int
+udpopen (host, serv)
+ char *host, *serv;
+{
+ return _netopen (host, serv, 'u');
+}
+#endif
+
+#else /* !HAVE_NETWORK */
+
+int
+netopen (path)
+ char *path;
+{
+ internal_error ("network operations not supported");
+ return -1;
+}
+
+#endif /* !HAVE_NETWORK */
diff --git a/lib/sh/rename.c b/lib/sh/rename.c
index 799cb697..cc128566 100644
--- a/lib/sh/rename.c
+++ b/lib/sh/rename.c
@@ -2,6 +2,24 @@
* rename - rename a file
*/
+/* Copyright (C) 1999 Free Software Foundation, Inc.
+
+ This file is part of GNU Bash, the Bourne Again SHell.
+
+ Bash is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ Bash is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
+ License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Bash; see the file COPYING. If not, write to the Free
+ Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+
#include <config.h>
#if !defined (HAVE_RENAME)
diff --git a/lib/sh/setlinebuf.c b/lib/sh/setlinebuf.c
index 05f95793..fb097de4 100644
--- a/lib/sh/setlinebuf.c
+++ b/lib/sh/setlinebuf.c
@@ -20,22 +20,44 @@
#include <config.h>
-#if !defined (HAVE_SETLINEBUF)
-
#include <stdio.h>
+extern char *xmalloc();
+
+#if defined (USING_BASH_MALLOC)
+# define LBUF_BUFSIZE 1008
+#else
+# define LBUF_BUFSIZE BUFSIZ
+#endif
+
/* Cause STREAM to buffer lines as opposed to characters or blocks. */
int
-setlinebuf (stream)
+sh_setlinebuf (stream)
FILE *stream;
{
-#if defined (_IOLBF)
+ char *local_linebuf;
+
+#if !defined (HAVE_SETLINEBUF) && !defined (HAVE_SETVBUF)
+ return (0);
+#endif
+
+#if defined (USING_BASH_MALLOC)
+ local_linebuf = xmalloc (LBUF_BUFSIZE);
+#else
+ local_linebuf = (char *)NULL;
+#endif
+
+#if defined (HAVE_SETVBUF)
+
# if defined (SETVBUF_REVERSED)
- setvbuf (stream, _IOLBF, (char *)NULL, BUFSIZ);
+ return (setvbuf (stream, _IOLBF, local_linebuf, LBUF_BUFSIZE));
# else /* !SETVBUF_REVERSED */
- setvbuf (stream, (char *)NULL, _IOLBF, BUFSIZ);
+ return (setvbuf (stream, local_linebuf, _IOLBF, LBUF_BUFSIZE));
# endif /* !SETVBUF_REVERSED */
-#endif /* _IOLBF */
+# else /* !HAVE_SETVBUF */
+
+ setlinebuf (stream));
return (0);
+
+#endif /* !HAVE_SETVBUF */
}
-#endif /* !HAVE_SETLINEBUF */
diff --git a/lib/sh/shquote.c b/lib/sh/shquote.c
new file mode 100644
index 00000000..ab8009da
--- /dev/null
+++ b/lib/sh/shquote.c
@@ -0,0 +1,217 @@
+/* Copyright (C) 1999 Free Software Foundation, Inc.
+
+ This file is part of GNU Bash, the Bourne Again SHell.
+
+ Bash is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free
+ Software Foundation; either version 2, or (at your option) any later
+ version.
+
+ Bash is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with Bash; see the file COPYING. If not, write to the Free Software
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+
+#include <config.h>
+
+#if defined (HAVE_UNISTD_H)
+# ifdef _MINIX
+# include <sys/types.h>
+# endif
+# include <unistd.h>
+#endif
+
+#include <stdio.h>
+
+#if !defined(slashify_in_quotes)
+# define slashify_in_quotes "\\`$\"\n"
+#endif
+
+extern char *xmalloc ();
+
+/* **************************************************************** */
+/* */
+/* Functions for quoting strings to be re-read as input */
+/* */
+/* **************************************************************** */
+
+/* Return a new string which is the single-quoted version of STRING.
+ Used by alias and trap, among others. */
+char *
+single_quote (string)
+ char *string;
+{
+ register int c;
+ char *result, *r, *s;
+
+ result = xmalloc (3 + (4 * strlen (string)));
+ r = result;
+ *r++ = '\'';
+
+ for (s = string; s && (c = *s); s++)
+ {
+ *r++ = c;
+
+ if (c == '\'')
+ {
+ *r++ = '\\'; /* insert escaped single quote */
+ *r++ = '\'';
+ *r++ = '\''; /* start new quoted string */
+ }
+ }
+
+ *r++ = '\'';
+ *r = '\0';
+
+ return (result);
+}
+
+/* Quote STRING using double quotes. Return a new string. */
+char *
+double_quote (string)
+ char *string;
+{
+ register int c;
+ char *result, *r, *s;
+
+ result = xmalloc (3 + (2 * strlen (string)));
+ r = result;
+ *r++ = '"';
+
+ for (s = string; s && (c = *s); s++)
+ {
+ switch (c)
+ {
+ case '"':
+ case '$':
+ case '`':
+ case '\\':
+ case '\n': /* XXX */
+ *r++ = '\\';
+ default:
+ *r++ = c;
+ break;
+ }
+ }
+
+ *r++ = '"';
+ *r = '\0';
+
+ return (result);
+}
+
+/* Remove backslashes that are quoting characters that are special between
+ double quotes. Return a new string. */
+char *
+un_double_quote (string)
+ char *string;
+{
+ register int c, pass_next;
+ char *result, *r, *s;
+
+ r = result = xmalloc (strlen (string) + 1);
+
+ for (pass_next = 0, s = string; s && (c = *s); s++)
+ {
+ if (pass_next)
+ {
+ *r++ = c;
+ pass_next = 0;
+ continue;
+ }
+ if (c == '\\' && strchr (slashify_in_quotes, s[1]))
+ {
+ pass_next = 1;
+ continue;
+ }
+ *r++ = c;
+ }
+
+ *r = '\0';
+ return result;
+}
+
+/* Quote special characters in STRING using backslashes. Return a new
+ string. */
+char *
+backslash_quote (string)
+ char *string;
+{
+ int c;
+ char *result, *r, *s;
+
+ result = xmalloc (2 * strlen (string) + 1);
+
+ for (r = result, s = string; s && (c = *s); s++)
+ {
+ switch (c)
+ {
+ case ' ': case '\t': case '\n': /* IFS white space */
+ case '\'': case '"': case '\\': /* quoting chars */
+ case '|': case '&': case ';': /* shell metacharacters */
+ case '(': case ')': case '<': case '>':
+ case '!': case '{': case '}': /* reserved words */
+ case '*': case '[': case '?': case ']': /* globbing chars */
+ case '^':
+ case '$': case '`': /* expansion chars */
+ *r++ = '\\';
+ *r++ = c;
+ break;
+#if 0
+ case '~': /* tilde expansion */
+ if (s == string || s[-1] == '=' || s[-1] == ':')
+ *r++ = '\\';
+ *r++ = c;
+ break;
+#endif
+ case '#': /* comment char */
+ if (s == string)
+ *r++ = '\\';
+ /* FALLTHROUGH */
+ default:
+ *r++ = c;
+ break;
+ }
+ }
+
+ *r = '\0';
+ return (result);
+}
+
+int
+contains_shell_metas (string)
+ char *string;
+{
+ char *s;
+
+ for (s = string; s && *s; s++)
+ {
+ switch (*s)
+ {
+ case ' ': case '\t': case '\n': /* IFS white space */
+ case '\'': case '"': case '\\': /* quoting chars */
+ case '|': case '&': case ';': /* shell metacharacters */
+ case '(': case ')': case '<': case '>':
+ case '!': case '{': case '}': /* reserved words */
+ case '*': case '[': case '?': case ']': /* globbing chars */
+ case '^':
+ case '$': case '`': /* expansion chars */
+ return (1);
+ case '~': /* tilde expansion */
+ if (s == string || s[-1] == '=' || s[-1] == ':')
+ return (1);
+ case '#':
+ if (s == string) /* comment char */
+ return (1);
+ /* FALLTHROUGH */
+ default:
+ break;
+ }
+ }
+
+ return (0);
+}
diff --git a/lib/sh/shtty.c b/lib/sh/shtty.c
new file mode 100644
index 00000000..15cc82f8
--- /dev/null
+++ b/lib/sh/shtty.c
@@ -0,0 +1,284 @@
+/* Copyright (C) 1999 Free Software Foundation, Inc.
+
+ This file is part of GNU Bash, the Bourne Again SHell.
+
+ Bash is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free
+ Software Foundation; either version 2, or (at your option) any later
+ version.
+
+ Bash is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with Bash; see the file COPYING. If not, write to the Free Software
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+
+/*
+ * shtty.c -- abstract interface to the terminal, focusing on capabilities.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+
+#include <shtty.h>
+
+static TTYSTRUCT ttin, ttout;
+static int ttsaved = 0;
+
+int
+ttgetattr(fd, ttp)
+int fd;
+TTYSTRUCT *ttp;
+{
+#ifdef TERMIOS_TTY_DRIVER
+ return tcgetattr(fd, ttp);
+#else
+# ifdef TERMIO_TTY_DRIVER
+ return ioctl(fd, TCGETA, ttp);
+# else
+ return ioctl(fd, TIOCGETP, ttp);
+# endif
+#endif
+}
+
+int
+ttsetattr(fd, ttp)
+int fd;
+TTYSTRUCT *ttp;
+{
+#ifdef TERMIOS_TTY_DRIVER
+ return tcsetattr(fd, TCSADRAIN, ttp);
+#else
+# ifdef TERMIO_TTY_DRIVER
+ return ioctl(fd, TCSETAW, ttp);
+# else
+ return ioctl(fd, TIOCSETN, ttp);
+# endif
+#endif
+}
+
+void
+ttsave()
+{
+ if (ttsaved)
+ return;
+ ttgetattr (0, &ttin);
+ ttgetattr (1, &ttout);
+ ttsaved = 1;
+}
+
+void
+ttrestore()
+{
+ if (ttsaved == 0)
+ return;
+ ttsetattr (0, &ttin);
+ ttsetattr (1, &ttout);
+ ttsaved = 0;
+}
+
+/* Retrieve the attributes associated with tty fd FD. */
+TTYSTRUCT *
+ttattr (fd)
+ int fd;
+{
+ if (ttsaved == 0)
+ return ((TTYSTRUCT *)0);
+ if (fd == 0)
+ return &ttin;
+ else if (fd == 1)
+ return &ttout;
+ else
+ return ((TTYSTRUCT *)0);
+}
+
+/*
+ * Change attributes in ttp so that when it is installed using
+ * ttsetattr, the terminal will be in one-char-at-a-time mode.
+ */
+int
+tt_setonechar(ttp)
+ TTYSTRUCT *ttp;
+{
+#if defined (TERMIOS_TTY_DRIVER) || defined (TERMIO_TTY_DRIVER)
+
+ /* XXX - might not want this -- it disables erase and kill processing. */
+ ttp->c_lflag &= ~ICANON;
+
+ ttp->c_lflag |= ISIG;
+# ifdef IEXTEN
+ ttp->c_lflag |= IEXTEN;
+# endif
+
+ ttp->c_iflag |= ICRNL; /* make sure we get CR->NL on input */
+ ttp->c_iflag &= ~INLCR; /* but no NL->CR */
+
+# ifdef OPOST
+ ttp->c_oflag |= OPOST;
+# endif
+# ifdef ONLCR
+ ttp->c_oflag |= ONLCR;
+# endif
+# ifdef OCRNL
+ ttp->c_oflag &= ~OCRNL;
+# endif
+# ifdef ONOCR
+ ttp->c_oflag &= ~ONOCR;
+# endif
+# ifdef ONLRET
+ ttp->c_oflag &= ~ONLRET;
+# endif
+
+ ttp->c_cc[VMIN] = 1;
+ ttp->c_cc[VTIME] = 0;
+
+#else
+
+ ttp->sg_flags |= CBREAK;
+
+#endif
+
+ return 0;
+}
+
+/* Set the terminal into one-character-at-a-time mode */
+int
+ttonechar ()
+{
+ TTYSTRUCT tt;
+
+ if (ttsaved == 0)
+ return -1;
+ tt = ttin;
+ if (tt_setonechar(&tt) < 0)
+ return -1;
+ return (ttsetattr (0, &tt));
+}
+
+/*
+ * Change attributes in ttp so that when it is installed using
+ * ttsetattr, the terminal will be in no-echo mode.
+ */
+int
+tt_setnoecho(ttp)
+ TTYSTRUCT *ttp;
+{
+#if defined (TERMIOS_TTY_DRIVER) || defined (TERMIO_TTY_DRIVER)
+ ttp->c_lflag &= ~(ECHO|ECHOK|ECHONL);
+#else
+ ttp->sg_flags &= ~ECHO;
+#endif
+
+ return 0;
+}
+
+/* Set the terminal into no-echo mode */
+int
+ttnoecho ()
+{
+ TTYSTRUCT tt;
+
+ if (ttsaved == 0)
+ return -1;
+ tt = ttin;
+ if (tt_setnoecho (&tt) < 0)
+ return -1;
+ return (ttsetattr (0, &tt));
+}
+
+/*
+ * Change attributes in ttp so that when it is installed using
+ * ttsetattr, the terminal will be in eight-bit mode (pass8).
+ */
+int
+tt_seteightbit (ttp)
+ TTYSTRUCT *ttp;
+{
+#if defined (TERMIOS_TTY_DRIVER) || defined (TERMIO_TTY_DRIVER)
+ ttp->c_iflag &= ~ISTRIP;
+ ttp->c_cflag |= CS8;
+ ttp->c_cflag &= ~PARENB;
+#else
+ ttp->sg_flags |= ANYP;
+#endif
+
+ return 0;
+}
+
+/* Set the terminal into eight-bit mode */
+int
+tteightbit ()
+{
+ TTYSTRUCT tt;
+
+ if (ttsaved == 0)
+ return -1;
+ tt = ttin;
+ if (tt_seteightbit (&tt) < 0)
+ return -1;
+ return (ttsetattr (0, &tt));
+}
+
+/*
+ * Change attributes in ttp so that when it is installed using
+ * ttsetattr, the terminal will be in non-canonical input mode.
+ */
+int
+tt_setnocanon (ttp)
+ TTYSTRUCT *ttp;
+{
+#if defined (TERMIOS_TTY_DRIVER) || defined (TERMIO_TTY_DRIVER)
+ ttp->c_lflag &= ~ICANON;
+#endif
+
+ return 0;
+}
+
+/* Set the terminal into non-canonical mode */
+int
+ttnocanon ()
+{
+ TTYSTRUCT tt;
+
+ if (ttsaved == 0)
+ return -1;
+ tt = ttin;
+ if (tt_setnocanon (&tt) < 0)
+ return -1;
+ return (ttsetattr (0, &tt));
+}
+
+/*
+ * Change attributes in ttp so that when it is installed using
+ * ttsetattr, the terminal will be in cbreak, no-echo mode.
+ */
+int
+tt_setcbreak(ttp)
+ TTYSTRUCT *ttp;
+{
+ if (tt_setonechar (ttp) < 0)
+ return -1;
+ return (tt_setnoecho (ttp));
+}
+
+/* Set the terminal into cbreak (no-echo, one-character-at-a-time) mode */
+int
+ttcbreak ()
+{
+ TTYSTRUCT tt;
+
+ if (ttsaved == 0)
+ return -1;
+ tt = ttin;
+ if (tt_setcbreak (&tt) < 0)
+ return -1;
+ return (ttsetattr (0, &tt));
+}
diff --git a/lib/sh/strpbrk.c b/lib/sh/strpbrk.c
new file mode 100644
index 00000000..3c493a88
--- /dev/null
+++ b/lib/sh/strpbrk.c
@@ -0,0 +1,44 @@
+/* Copyright (C) 1991, 1994 Free Software Foundation, Inc.
+ NOTE: The canonical source of this file is maintained with the GNU C Library.
+ Bugs can be reported to bug-glibc@prep.ai.mit.edu.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the
+ Free Software Foundation; either version 2, or (at your option) any
+ later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#if !defined (HAVE_STRPBRK)
+
+#include <stdc.h>
+
+/* Find the first ocurrence in S of any character in ACCEPT. */
+char *
+strpbrk (s, accept)
+ register const char *s;
+ register const char *accept;
+{
+ while (*s != '\0')
+ {
+ const char *a = accept;
+ while (*a != '\0')
+ if (*a++ == *s)
+ return (char *) s;
+ ++s;
+ }
+
+ return 0;
+}
+#endif
diff --git a/lib/sh/times.c b/lib/sh/times.c
new file mode 100644
index 00000000..240aafe1
--- /dev/null
+++ b/lib/sh/times.c
@@ -0,0 +1,77 @@
+/* times.c - times(3) library function */
+
+/* Copyright (C) 1999 Free Software Foundation, Inc.
+
+ This file is part of GNU Bash, the Bourne Again SHell.
+
+ Bash is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free
+ Software Foundation; either version 2, or (at your option) any later
+ version.
+
+ Bash is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with Bash; see the file COPYING. If not, write to the Free Software
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+
+#include <config.h>
+
+#if !defined (HAVE_TIMES)
+
+#include <sys/types.h>
+#include <posixtime.h>
+#include <systimes.h>
+
+#if defined (HAVE_SYS_RESOURCE_H) && defined (HAVE_GETRUSAGE)
+# include <sys/resource.h>
+#endif /* HAVE_SYS_RESOURCE_H && HAVE_GETRUSAGE */
+
+extern long get_clk_tck();
+
+#define CONVTCK(r) (r.tv_sec * clk_tck + r.tv_usec / (1000000 / clk_tck))
+
+clock_t
+times(tms)
+ struct tms *tms;
+{
+ clock_t rv;
+ static long clk_tck = -1;
+
+#if defined (HAVE_GETRUSAGE)
+ struct timeval tv;
+ struct rusage ru;
+
+ if (clk_tck == -1)
+ clk_tck = get_clk_tck();
+
+ if (getrusage(RUSAGE_SELF, &ru) < 0)
+ return ((clock_t)-1);
+ tms->tms_utime = CONVTCK(ru.ru_utime);
+ tms->tms_stime = CONVTCK(ru.ru_stime);
+
+ if (getrusage(RUSAGE_CHILDREN, &ru) < 0)
+ return ((clock_t)-1);
+ tms->tms_cutime = CONVTCK(ru.ru_utime);
+ tms->tms_cstime = CONVTCK(ru.ru_stime);
+
+ if (gettimeofday(&tv, (struct timezone *) 0) < 0)
+ return ((clock_t)-1);
+ rv = (clock_t)(CONVTCK(tv));
+#else /* !HAVE_GETRUSAGE */
+ if (clk_tck == -1)
+ clk_tck = get_clk_tck();
+
+ /* We can't do anything. */
+ tms->tms_utime = tms->tms_stime = (clock_t)0;
+ tms->tms_cutime = tms->tms_cstime = (clock_t)0;
+
+ rv = (clock_t)time((time_t *)0) * clk_tck;
+# endif /* HAVE_GETRUSAGE */
+
+ return rv;
+}
+#endif /* !HAVE_TIMES */
diff --git a/lib/sh/timeval.c b/lib/sh/timeval.c
new file mode 100644
index 00000000..809d411f
--- /dev/null
+++ b/lib/sh/timeval.c
@@ -0,0 +1,144 @@
+/* timeval.c - functions to perform operations on struct timevals */
+
+/* Copyright (C) 1999 Free Software Foundation, Inc.
+
+ This file is part of GNU Bash, the Bourne Again SHell.
+
+ Bash is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free
+ Software Foundation; either version 2, or (at your option) any later
+ version.
+
+ Bash is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with Bash; see the file COPYING. If not, write to the Free Software
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+
+#include <config.h>
+
+#if defined (HAVE_TIMEVAL)
+
+#include <sys/types.h>
+#include <posixtime.h>
+
+#include <stdio.h>
+
+struct timeval *
+difftimeval (d, t1, t2)
+ struct timeval *d, *t1, *t2;
+{
+ d->tv_sec = t2->tv_sec - t1->tv_sec;
+ d->tv_usec = t2->tv_usec - t1->tv_usec;
+ if (d->tv_usec < 0)
+ {
+ d->tv_usec += 1000000;
+ d->tv_sec -= 1;
+ if (d->tv_sec < 0) /* ??? -- BSD/OS does this */
+ {
+ d->tv_sec = 0;
+ d->tv_usec = 0;
+ }
+ }
+ return d;
+}
+
+struct timeval *
+addtimeval (d, t1, t2)
+ struct timeval *d, *t1, *t2;
+{
+ d->tv_sec = t1->tv_sec + t2->tv_sec;
+ d->tv_usec = t1->tv_usec + t2->tv_usec;
+ if (d->tv_usec >= 1000000)
+ {
+ d->tv_usec -= 1000000;
+ d->tv_sec += 1;
+ }
+ return d;
+}
+
+/* Do "cpu = ((user + sys) * 10000) / real;" with timevals.
+ Barely-tested code from Deven T. Corzine <deven@ties.org>. */
+int
+timeval_to_cpu (rt, ut, st)
+ struct timeval *rt, *ut, *st; /* real, user, sys */
+{
+ struct timeval t1, t2;
+ register int i;
+
+ addtimeval (&t1, ut, st);
+ t2.tv_sec = rt->tv_sec;
+ t2.tv_usec = rt->tv_usec;
+
+ for (i = 0; i < 6; i++)
+ {
+ if ((t1.tv_sec > 99999999) || (t2.tv_sec > 99999999))
+ break;
+ t1.tv_sec *= 10;
+ t1.tv_sec += t1.tv_usec / 100000;
+ t1.tv_usec *= 10;
+ t1.tv_usec %= 1000000;
+ t2.tv_sec *= 10;
+ t2.tv_sec += t2.tv_usec / 100000;
+ t2.tv_usec *= 10;
+ t2.tv_usec %= 1000000;
+ }
+ for (i = 0; i < 4; i++)
+ {
+ if (t1.tv_sec < 100000000)
+ t1.tv_sec *= 10;
+ else
+ t2.tv_sec /= 10;
+ }
+
+ return ((t2.tv_sec == 0) ? 0 : t1.tv_sec / t2.tv_sec);
+}
+
+/* Convert a pointer to a struct timeval to seconds and thousandths of a
+ second, returning the values in *SP and *SFP, respectively. This does
+ rounding on the fractional part, not just truncation to three places. */
+void
+timeval_to_secs (tvp, sp, sfp)
+ struct timeval *tvp;
+ long *sp;
+ int *sfp;
+{
+ int rest;
+
+ *sp = tvp->tv_sec;
+
+ *sfp = tvp->tv_usec % 1000000; /* pretty much a no-op */
+ rest = *sfp % 1000;
+ *sfp = (*sfp * 1000) / 1000000;
+ if (rest >= 500)
+ *sfp += 1;
+
+ /* Sanity check */
+ if (*sfp >= 1000)
+ {
+ *sp += 1;
+ *sfp -= 1000;
+ }
+}
+
+/* Print the contents of a struct timeval * in a standard way to stdio
+ stream FP. */
+void
+print_timeval (fp, tvp)
+ FILE *fp;
+ struct timeval *tvp;
+{
+ int minutes, seconds_fraction;
+ long seconds;
+
+ timeval_to_secs (tvp, &seconds, &seconds_fraction);
+
+ minutes = seconds / 60;
+ seconds %= 60;
+
+ fprintf (fp, "%0dm%0ld.%03ds", minutes, seconds, seconds_fraction);
+}
+#endif /* HAVE_TIMEVAL */
diff --git a/lib/sh/vprint.c b/lib/sh/vprint.c
index 63ea3bf7..929bdbce 100644
--- a/lib/sh/vprint.c
+++ b/lib/sh/vprint.c
@@ -6,7 +6,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 1, or (at your option) any later
+Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -16,7 +16,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#include <config.h>
diff --git a/lib/sh/zread.c b/lib/sh/zread.c
new file mode 100644
index 00000000..0b23b38d
--- /dev/null
+++ b/lib/sh/zread.c
@@ -0,0 +1,127 @@
+/* Copyright (C) 1999 Free Software Foundation, Inc.
+
+ This file is part of GNU Bash, the Bourne Again SHell.
+
+ Bash is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free
+ Software Foundation; either version 2, or (at your option) any later
+ version.
+
+ Bash is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with Bash; see the file COPYING. If not, write to the Free Software
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+
+#include <config.h>
+
+#include <sys/types.h>
+
+#if defined (HAVE_UNISTD_H)
+# include <unistd.h>
+#endif
+
+#include <errno.h>
+
+#if !defined (errno)
+extern int errno;
+#endif
+
+#ifndef SEEK_CUR
+# define SEEK_CUR 1
+#endif
+
+/* Read LEN bytes from FD into BUF. Retry the read on EINTR. Any other
+ error causes the loop to break. */
+int
+zread (fd, buf, len)
+ int fd;
+ char *buf;
+ size_t len;
+{
+ int r;
+
+ while ((r = read (fd, buf, len)) < 0 && errno == EINTR)
+ ;
+ return r;
+}
+
+/* Read LEN bytes from FD into BUF. Retry the read on EINTR, up to three
+ interrupts. Any other error causes the loop to break. */
+
+#ifdef NUM_INTR
+# undef NUM_INTR
+#endif
+#define NUM_INTR 3
+
+int
+zread1 (fd, buf, len)
+ int fd;
+ char *buf;
+ size_t len;
+{
+ int r, nintr;
+
+ for (nintr = 0; ; )
+ {
+ r = read (fd, buf, len);
+ if (r >= 0)
+ return r;
+ if (r == -1 && errno == EINTR)
+ {
+ if (++nintr > NUM_INTR)
+ return -1;
+ continue;
+ }
+ return r;
+ }
+}
+
+/* Read one character from FD and return it in CP. Return values are as
+ in read(2). This does some local buffering to avoid many one-character
+ calls to read(2), like those the `read' builtin performs. */
+
+static unsigned char lbuf[128];
+static int lind, lused;
+
+int
+zreadc (fd, cp)
+ int fd;
+ char *cp;
+{
+ int r;
+
+ if (lind == lused || lused == 0)
+ {
+ lused = zread (fd, lbuf, sizeof (lbuf));
+ lind = 0;
+ if (lused <= 0)
+ return (lused);
+ }
+ if (cp)
+ *cp = (char)lbuf[lind++];
+ return 1;
+}
+
+void
+zreset ()
+{
+ lind = lused = 0;
+}
+
+/* Sync the seek pointer for FD so that the kernel's idea of the last char
+ read is the last char returned by zreadc. */
+void
+zsyncfd (fd)
+ int fd;
+{
+ int off;
+
+ off = lused - lind;
+ if (off > 0)
+ lseek (fd, -off, SEEK_CUR);
+ lused = lind = 0;
+}
diff --git a/lib/sh/zwrite.c b/lib/sh/zwrite.c
new file mode 100644
index 00000000..25550f8f
--- /dev/null
+++ b/lib/sh/zwrite.c
@@ -0,0 +1,61 @@
+/* Copyright (C) 1999 Free Software Foundation, Inc.
+
+ This file is part of GNU Bash, the Bourne Again SHell.
+
+ Bash is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free
+ Software Foundation; either version 2, or (at your option) any later
+ version.
+
+ Bash is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with Bash; see the file COPYING. If not, write to the Free Software
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+
+#include <config.h>
+
+#include <sys/types.h>
+
+#if defined (HAVE_UNISTD_H)
+# include <unistd.h>
+#endif
+
+#include <errno.h>
+
+#if !defined (errno)
+extern int errno;
+#endif
+
+/* Write NB bytes from BUF to file descriptor FD, retrying the write if
+ it is interrupted. We retry three times if we get a zero-length
+ write. Any other signal causes this function to return prematurely. */
+int
+zwrite (fd, buf, nb)
+ int fd;
+ unsigned char *buf;
+ size_t nb;
+{
+ int n, i, nt;
+
+ for (n = nb, nt = 0;;)
+ {
+ i = write (fd, buf, n);
+ if (i > 0)
+ {
+ n -= i;
+ if (n <= 0)
+ return nb;
+ }
+ else if (i == 0)
+ {
+ if (++nt > 3)
+ return (nb - n);
+ }
+ else if (errno != EINTR)
+ return -1;
+ }
+}
diff --git a/lib/termcap/Makefile.in b/lib/termcap/Makefile.in
index d5d33bc0..1ed2c275 100644
--- a/lib/termcap/Makefile.in
+++ b/lib/termcap/Makefile.in
@@ -4,6 +4,22 @@
# #
####################################################################
+# Copyright (C) 1996 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
+
srcdir = @srcdir@
VPATH = .:@srcdir@
topdir = @top_srcdir@
@@ -29,7 +45,7 @@ LDFLAGS = @LDFLAGS@
DEFS = @DEFS@
-INCLUDES = -I. -I../.. -I$(topdir) -I$(topdir)/lib
+INCLUDES = -I. -I../.. -I$(topdir) -I$(topdir)/lib -I$(srcdir)
CCFLAGS = $(CFLAGS) $(DEFS) $(CPPFLAGS) ${INCLUDES}
@@ -59,7 +75,10 @@ install:
clean:
$(RM) *.o *.a *.log *.cp *.tp *.vr *.fn *.aux *.pg *.toc
-mostlyclean distclean maintainer-clean: clean
+mostlyclean: clean
+
+distclean maintainer-clean: clean
+ $(RM) Makefile
$(DESTDIR)/libtermcap.a: libtermcap.a
${INSTALL_DATA} -c -m 644 libtermcap.a $@
diff --git a/lib/termcap/grot/COPYING b/lib/termcap/grot/COPYING
index a43ea212..2b940a41 100644
--- a/lib/termcap/grot/COPYING
+++ b/lib/termcap/grot/COPYING
@@ -2,10 +2,18 @@
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
- 675 Mass Ave, Cambridge, MA 02139, USA
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
+The Free Software Foundation has exempted Bash from the requirement of
+Paragraph 2c of the General Public License. This is to say, there is
+no requirement for Bash to print a notice when it is started
+interactively in the usual way. We made this exception because users
+and standards expect shells not to print such messages. This
+exception applies to any program that serves as a shell and that is
+based primarily on Bash as opposed to other GNU software.
+
Preamble
The licenses for most software are designed to take away your
@@ -305,7 +313,7 @@ the "copyright" line and a pointer to where the full notice is found.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
Also add information on how to contact you by electronic and paper mail.
diff --git a/lib/termcap/grot/Makefile.in b/lib/termcap/grot/Makefile.in
index 66e5d02f..e6f06ae6 100644
--- a/lib/termcap/grot/Makefile.in
+++ b/lib/termcap/grot/Makefile.in
@@ -13,7 +13,7 @@
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
#### Start of system configuration section. ####
diff --git a/lib/termcap/grot/termcap.texi b/lib/termcap/grot/termcap.texi
index 7a6cd565..eab49e88 100644
--- a/lib/termcap/grot/termcap.texi
+++ b/lib/termcap/grot/termcap.texi
@@ -61,7 +61,7 @@ by the Foundation.
Copyright @copyright{} 1988 Free Software Foundation, Inc.
Published by the Free Software Foundation
-(675 Mass Ave, Cambridge MA 02139).
+(59 Temple Place, Suite 330, Boston, MA 02111 USA).
Printed copies are available for $10 each.
Permission is granted to make and distribute verbatim copies of
@@ -3615,4 +3615,3 @@ Flag: Teleray 1061; several strange characteristics.
@contents
@bye
-
diff --git a/lib/termcap/ltcap.h b/lib/termcap/ltcap.h
new file mode 100644
index 00000000..507481f0
--- /dev/null
+++ b/lib/termcap/ltcap.h
@@ -0,0 +1,29 @@
+/* Local declarations for termcap library.
+ Copyright (C) 1999 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+
+#ifndef _LTCAP_H_
+#define _LTCAP_H_ 1
+
+#if !defined (__APPLE__)
+# define __private_extern__
+#endif
+
+#ifndef MAX_TGETENT_BUFSIZ
+# define MAX_TGETENT_BUFSIZ 2048
+#endif
+
+#endif /* _LTCAP_H_ */
diff --git a/lib/termcap/termcap.c b/lib/termcap/termcap.c
index eb690c9f..eaf94713 100644
--- a/lib/termcap/termcap.c
+++ b/lib/termcap/termcap.c
@@ -12,8 +12,8 @@ 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; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+along with this program; see the file COPYING. If not, write to the
+Free Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
/* Emacs config.h may rename various library functions such as malloc. */
#ifdef HAVE_CONFIG_H
@@ -27,6 +27,14 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#include <fcntl.h>
+#ifdef HAVE_STDLIB_H
+# include <stdlib.h>
+#else
+extern char *getenv ();
+extern char *malloc ();
+extern char *realloc ();
+#endif
+
#else /* not HAVE_CONFIG_H */
#ifdef STDC_HEADERS
@@ -77,6 +85,8 @@ int bufsize = 128;
#endif
#endif
+#include "ltcap.h"
+
#ifndef TERMCAP_FILE
#define TERMCAP_FILE "/etc/termcap"
#endif
@@ -137,6 +147,7 @@ find_capability (bp, cap)
return NULL;
}
+__private_extern__
int
tgetnum (cap)
char *cap;
@@ -147,6 +158,7 @@ tgetnum (cap)
return atoi (ptr);
}
+__private_extern__
int
tgetflag (cap)
char *cap;
@@ -160,6 +172,7 @@ tgetflag (cap)
to store the string. That pointer is advanced over the space used.
If AREA is null, space is allocated with `malloc'. */
+__private_extern__
char *
tgetstr (cap, area)
char *cap;
@@ -264,7 +277,7 @@ tgetst1 (ptr, area)
short ospeed;
/* If OSPEED is 0, we use this as the actual baud rate. */
int tputs_baud_rate;
-char PC;
+__private_extern__ char PC = '\0';
/* Actual baud rate if positive;
- baud rate / 100 if negative. */
@@ -280,6 +293,7 @@ static int speeds[] =
#endif /* not VMS */
};
+__private_extern__
void
tputs (str, nlines, outfun)
register char *str;
@@ -299,8 +313,10 @@ tputs (str, nlines, outfun)
#else
if (ospeed == 0)
speed = tputs_baud_rate;
- else
+ else if (ospeed > 0 && ospeed < (sizeof speeds / sizeof speeds[0]))
speed = speeds[ospeed];
+ else
+ speed = 0;
#endif
if (!str)
@@ -393,7 +409,8 @@ static int
valid_filename_p (fn)
char *fn;
{
- return *fn == '/' || fn[1] == ':';
+ return *fn == '\\' || *fn == '/' ||
+ (*fn >= 'A' && *fn <= 'z' && fn[1] == ':');
}
#else
#define valid_filename_p(fn) (*(fn) == '/')
@@ -412,6 +429,7 @@ valid_filename_p (fn)
0 if the data base is accessible but the type NAME is not defined
in it, and some other value otherwise. */
+__private_extern__
int
tgetent (bp, name)
char *bp, *name;
@@ -452,12 +470,14 @@ tgetent (bp, name)
termcap_name = getenv ("TERMCAP");
if (termcap_name && *termcap_name == '\0')
termcap_name = NULL;
+#if 0
#if defined (MSDOS) && !defined (TEST)
if (termcap_name && (*termcap_name == '\\'
|| *termcap_name == '/'
|| termcap_name[1] == ':'))
dostounix_filename(termcap_name);
#endif
+#endif
filep = termcap_name && valid_filename_p (termcap_name);
diff --git a/lib/termcap/termcap.h b/lib/termcap/termcap.h
index b19fb0a1..40c2e298 100644
--- a/lib/termcap/termcap.h
+++ b/lib/termcap/termcap.h
@@ -13,7 +13,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#ifndef _TERMCAP_H
#define _TERMCAP_H 1
diff --git a/lib/termcap/tparam.c b/lib/termcap/tparam.c
index 24702899..1c83f045 100644
--- a/lib/termcap/tparam.c
+++ b/lib/termcap/tparam.c
@@ -12,12 +12,21 @@ 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; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+along with this program; see the file COPYING. If not, write to the
+Free Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
/* Emacs config.h may rename various library functions such as malloc. */
#ifdef HAVE_CONFIG_H
#include <config.h>
+
+#ifdef HAVE_STDLIB_H
+# include <stdlib.h>
+#else
+extern char *getenv ();
+extern char *malloc ();
+extern char *realloc ();
+#endif
+
#else /* not HAVE_CONFIG_H */
#if defined(HAVE_STRING_H) || defined(STDC_HEADERS)
@@ -34,6 +43,8 @@ char *realloc ();
#endif /* not HAVE_CONFIG_H */
+#include "ltcap.h"
+
#ifndef NULL
#define NULL (char *) 0
#endif
@@ -101,11 +112,12 @@ tparam (string, outstring, len, arg0, arg1, arg2, arg3)
return tparam1 (string, outstring, len, NULL, NULL, arg);
}
-char *BC;
-char *UP;
+__private_extern__ char *BC;
+__private_extern__ char *UP;
static char tgoto_buf[50];
+__private_extern__
char *
tgoto (cm, hpos, vpos)
char *cm;
diff --git a/lib/termcap/version.c b/lib/termcap/version.c
index f5623a27..be7d9e75 100644
--- a/lib/termcap/version.c
+++ b/lib/termcap/version.c
@@ -1,2 +1,2 @@
/* Make the library identifiable with the RCS ident command. */
-static char *version_string = "\n$Version: GNU termcap 1.3 $\n";
+static char *termcap_version_string = "\n$Version: GNU termcap 1.3 $\n";
diff --git a/lib/tilde/Makefile.in b/lib/tilde/Makefile.in
index 55b8d5ac..35543b5a 100644
--- a/lib/tilde/Makefile.in
+++ b/lib/tilde/Makefile.in
@@ -4,6 +4,22 @@
# #
####################################################################
+# Copyright (C) 1996 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
+
srcdir = @srcdir@
VPATH = .:@srcdir@
topdir = @top_srcdir@
@@ -31,7 +47,9 @@ LDFLAGS = @LDFLAGS@ @LOCAL_LDFLAGS@
DEFS = @DEFS@
LOCAL_DEFS = @LOCAL_DEFS@
-INCLUDES = -I. -I../.. -I$(topdir) -I$(topdir)/lib
+BASHINCDIR = ${topdir}/include
+
+INCLUDES = -I. -I../.. -I$(topdir) -I${BASHINCDIR} -I$(topdir)/lib
CCFLAGS = $(DEFS) $(LOCAL_DEFS) $(CPPFLAGS) ${INCLUDES} $(LOCAL_CFLAGS) $(CFLAGS)
@@ -99,7 +117,7 @@ mostlyclean: clean
# #
######################################################################
-tilde.o: tilde.h $(topdir)/ansi_stdlib.h
+tilde.o: tilde.h $(BASHINCDIR)/ansi_stdlib.h
tilde.o: $(BUILD_DIR)/config.h
# Rules for deficient makes, like SunOS and Solaris
diff --git a/lib/tilde/shell.c b/lib/tilde/shell.c
index 91b1aafa..a45af2d4 100644
--- a/lib/tilde/shell.c
+++ b/lib/tilde/shell.c
@@ -7,7 +7,7 @@
The GNU Tilde Library is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 1, or
+ as published by the Free Software Foundation; either version 2, or
(at your option) any later version.
The GNU Tilde Library is distributed in the hope that it will be
@@ -18,7 +18,7 @@
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
- 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if defined (HAVE_CONFIG_H)
# include <config.h>
diff --git a/lib/tilde/tilde.c b/lib/tilde/tilde.c
index d1853bd6..777b6559 100644
--- a/lib/tilde/tilde.c
+++ b/lib/tilde/tilde.c
@@ -7,7 +7,7 @@
Readline is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
- Free Software Foundation; either version 1, or (at your option) any
+ Free Software Foundation; either version 2, or (at your option) any
later version.
Readline is distributed in the hope that it will be useful, but
@@ -17,7 +17,7 @@
You should have received a copy of the GNU General Public License
along with Readline; see the file COPYING. If not, write to the Free
- Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if defined (HAVE_CONFIG_H)
# include <config.h>
@@ -47,12 +47,22 @@
#include "tilde.h"
+#if defined (TEST) || defined (STATIC_MALLOC)
+static char *xmalloc (), *xrealloc ();
+#else
+# if defined __STDC__
+extern char *xmalloc (int);
+extern char *xrealloc (void *, int);
+# else
+extern char *xmalloc (), *xrealloc ();
+# endif /* !__STDC__ */
+#endif /* TEST || STATIC_MALLOC */
+
#if !defined (HAVE_GETPW_DECLS)
extern struct passwd *getpwuid (), *getpwnam ();
#endif /* !HAVE_GETPW_DECLS */
#if !defined (savestring)
-extern char *xmalloc ();
# ifndef strcpy
extern char *strcpy ();
# endif
@@ -67,17 +77,11 @@ extern char *strcpy ();
# endif /* !__STDC__ */
#endif /* !NULL */
-#if defined (TEST) || defined (STATIC_MALLOC)
-static char *xmalloc (), *xrealloc ();
-#else
-extern char *xmalloc (), *xrealloc ();
-#endif /* TEST || STATIC_MALLOC */
-
/* If being compiled as part of bash, these will be satisfied from
variables.o. If being compiled as part of readline, they will
be satisfied from shell.o. */
-extern char *get_home_dir ();
-extern char *get_env_value ();
+extern char *get_home_dir __P((void));
+extern char *get_env_value __P((char *));
/* The default value of tilde_additional_prefixes. This is set to
whitespace preceding a tilde so that simple programs which do not
@@ -122,7 +126,9 @@ tilde_find_prefix (string, len)
int *len;
{
register int i, j, string_len;
- register char **prefixes = tilde_additional_prefixes;
+ register char **prefixes;
+
+ prefixes = tilde_additional_prefixes;
string_len = strlen (string);
*len = 0;
@@ -161,7 +167,11 @@ tilde_find_suffix (string)
for (i = 0; i < string_len; i++)
{
+#if defined (__MSDOS__)
+ if (string[i] == '/' || string[i] == '\\' /* || !string[i] */)
+#else
if (string[i] == '/' /* || !string[i] */)
+#endif
break;
for (j = 0; suffixes && suffixes[j]; j++)
@@ -225,11 +235,18 @@ tilde_expand (string)
free (tilde_word);
len = strlen (expansion);
- if ((result_index + len + 1) > result_size)
- result = xrealloc (result, 1 + (result_size += (len + 20)));
+#ifdef __CYGWIN32__
+ /* Fix for Cygwin to prevent ~user/xxx from expanding to //xxx when
+ $HOME for `user' is /. On cygwin, // denotes a network drive. */
+ if (len > 1 || *expansion != '/' || *string != '/')
+#endif
+ {
+ if ((result_index + len + 1) > result_size)
+ result = xrealloc (result, 1 + (result_size += (len + 20)));
- strcpy (result + result_index, expansion);
- result_index += len;
+ strcpy (result + result_index, expansion);
+ result_index += len;
+ }
free (expansion);
}
@@ -250,7 +267,11 @@ isolate_tilde_prefix (fname, lenp)
int i;
ret = xmalloc (strlen (fname));
+#if defined (__MSDOS__)
+ for (i = 1; fname[i] && fname[i] != '/' && fname[i] != '\\'; i++)
+#else
for (i = 1; fname[i] && fname[i] != '/'; i++)
+#endif
ret[i - 1] = fname[i];
ret[i - 1] = '\0';
if (lenp)
@@ -271,7 +292,7 @@ glue_prefix_and_suffix (prefix, suffix, suffind)
plen = (prefix && *prefix) ? strlen (prefix) : 0;
slen = strlen (suffix + suffind);
ret = xmalloc (plen + slen + 1);
- if (prefix && *prefix)
+ if (plen)
strcpy (ret, prefix);
strcpy (ret + plen, suffix + suffind);
return ret;
diff --git a/lib/tilde/tilde.h b/lib/tilde/tilde.h
index 634b9544..7783fd61 100644
--- a/lib/tilde/tilde.h
+++ b/lib/tilde/tilde.h
@@ -8,7 +8,7 @@
The Library is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 1, or (at your option)
+ the Free Software Foundation; either version 2, or (at your option)
any later version.
The Library is distributed in the hope that it will be useful, but
@@ -19,11 +19,27 @@
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
- 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if !defined (_TILDE_H_)
# define _TILDE_H_
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* A function can be defined using prototypes and compile on both ANSI C
+ and traditional C compilers with something like this:
+ extern char *func __P((char *, char *, int)); */
+
+#if !defined (__P)
+# if defined (__STDC__) || defined (__GNUC__) || defined (__cplusplus)
+# define __P(protos) protos
+# else
+# define __P(protos) ()
+# endif
+#endif
+
/* Function pointers can be declared as (Function *)foo. */
#if !defined (_FUNCTION_DEF)
# define _FUNCTION_DEF
@@ -56,10 +72,14 @@ extern char **tilde_additional_prefixes;
extern char **tilde_additional_suffixes;
/* Return a new string which is the result of tilde expanding STRING. */
-extern char *tilde_expand ();
+extern char *tilde_expand __P((char *));
/* Do the work of tilde expansion on FILENAME. FILENAME starts with a
tilde. If there is no expansion, call tilde_expansion_failure_hook. */
-extern char *tilde_expand_word ();
+extern char *tilde_expand_word __P((char *));
+
+#ifdef __cplusplus
+}
+#endif
#endif /* _TILDE_H_ */
diff --git a/list.c b/list.c
index 7385f4cf..2f075c0e 100644
--- a/list.c
+++ b/list.c
@@ -17,7 +17,7 @@
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#include "config.h"
diff --git a/locale.c b/locale.c
index 24c30c78..fba962cc 100644
--- a/locale.c
+++ b/locale.c
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#include "config.h"
@@ -81,6 +81,12 @@ set_default_locale_vars ()
setlocale (LC_MESSAGES, lc_all);
# endif /* LC_MESSAGES */
+# if defined (LC_NUMERIC)
+ val = get_string_value ("LC_NUMERIC");
+ if (val == 0 && lc_all && *lc_all)
+ setlocale (LC_NUMERIC, lc_all);
+# endif /* LC_NUMERIC */
+
#endif /* HAVE_SETLOCALE */
val = get_string_value ("TEXTDOMAIN");
@@ -136,7 +142,7 @@ set_locale_var (var, value)
lc_all[0] = '\0';
}
#if defined (HAVE_SETLOCALE)
- return (setlocale (LC_ALL, value) != 0);
+ return (setlocale (LC_ALL, lc_all) != 0);
#else
return (1);
#endif
@@ -146,22 +152,29 @@ set_locale_var (var, value)
else if (var[3] == 'C' && var[4] == 'T') /* LC_CTYPE */
{
if (lc_all == 0 || *lc_all == '\0')
- return (setlocale (LC_CTYPE, value) != 0);
+ return (setlocale (LC_CTYPE, value ? value : "") != 0);
}
else if (var[3] == 'C' && var[4] == 'O') /* LC_COLLATE */
{
# if defined (LC_COLLATE)
if (lc_all == 0 || *lc_all == '\0')
- return (setlocale (LC_COLLATE, value) != 0);
+ return (setlocale (LC_COLLATE, value ? value : "") != 0);
# endif /* LC_COLLATE */
}
else if (var[3] == 'M' && var[4] == 'E') /* LC_MESSAGES */
{
# if defined (LC_MESSAGES)
if (lc_all == 0 || *lc_all == '\0')
- return (setlocale (LC_MESSAGES, value) != 0);
+ return (setlocale (LC_MESSAGES, value ? value : "") != 0);
# endif /* LC_MESSAGES */
}
+ else if (var[3] = 'N' && var[4] == 'U') /* LC_NUMERIC */
+ {
+# if defined (LC_NUMERIC)
+ if (lc_all == 0 || *lc_all == '\0')
+ return (setlocale (LC_NUMERIC, value ? value : "") != 0);
+# endif /* LC_NUMERIC */
+ }
#endif /* HAVE_SETLOCALE */
return (0);
diff --git a/mailcheck.c b/mailcheck.c
index 46a59213..a4d36701 100644
--- a/mailcheck.c
+++ b/mailcheck.c
@@ -6,7 +6,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 1, or (at your option) any later
+Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -16,7 +16,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#include "config.h"
diff --git a/mailcheck.h b/mailcheck.h
index 9c4032f5..1c6f24ff 100644
--- a/mailcheck.h
+++ b/mailcheck.h
@@ -6,7 +6,7 @@
Bash is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 1, or (at your option)
+ the Free Software Foundation; either version 2, or (at your option)
any later version.
Bash is distributed in the hope that it will be useful, but WITHOUT
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with Bash; see the file COPYING. If not, write to the Free
- Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if !defined (_MAILCHECK_H_)
#define _MAILCHECK_H_
diff --git a/make_cmd.c b/make_cmd.c
index 654895f7..867484ff 100644
--- a/make_cmd.c
+++ b/make_cmd.c
@@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 1, or (at your option) any later
+Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#include "config.h"
@@ -48,6 +48,8 @@ Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
extern int line_number, current_command_line_count;
extern int disallow_filename_globbing;
+extern int last_command_exit_value;
+
WORD_DESC *
make_bare_word (string)
@@ -203,9 +205,101 @@ make_select_command (name, map_list, action)
{
#if defined (SELECT_COMMAND)
return (make_for_or_select (cm_select, name, map_list, action));
+#else
+ last_command_exit_value = 2;
+ return ((COMMAND *)NULL);
#endif
}
+#if defined (ARITH_FOR_COMMAND)
+static WORD_LIST *
+make_arith_for_expr (s)
+ char *s;
+{
+ WORD_LIST *result;
+ WORD_DESC *w;
+
+ if (s == 0 || *s == '\0')
+ return ((WORD_LIST *)NULL);
+ w = make_word (s);
+ result = make_word_list (w, (WORD_LIST *)NULL);
+ return result;
+}
+#endif
+
+COMMAND *
+make_arith_for_command (exprs, action, lineno)
+ WORD_LIST *exprs;
+ COMMAND *action;
+ int lineno;
+{
+#if defined (ARITH_FOR_COMMAND)
+ ARITH_FOR_COM *temp;
+ WORD_LIST *init, *test, *step;
+ char *s, *t, *start;
+ int nsemi, l;
+
+ init = test = step = (WORD_LIST *)NULL;
+ /* Parse the string into the three component sub-expressions. */
+ start = t = s = exprs->word->word;
+ for (nsemi = 0; ;)
+ {
+ /* skip whitespace at the start of each sub-expression. */
+ while (whitespace (*s))
+ s++;
+ start = s;
+ /* skip to the semicolon or EOS */
+ while (*s && *s != ';')
+ s++;
+
+ t = (s > start) ? substring (start, 0, s - start) : (char *)NULL;
+
+ nsemi++;
+ switch (nsemi)
+ {
+ case 1:
+ init = make_arith_for_expr (t);
+ break;
+ case 2:
+ test = make_arith_for_expr (t);
+ break;
+ case 3:
+ step = make_arith_for_expr (t);
+ break;
+ }
+
+ FREE (t);
+ if (*s == '\0')
+ break;
+ s++; /* skip over semicolon */
+ }
+
+ if (nsemi != 3)
+ {
+ if (nsemi < 3)
+ parser_error (lineno, "syntax error: arithmetic expression required");
+ else
+ parser_error (lineno, "syntax error: `;' unexpected");
+ parser_error (lineno, "syntax error: `((%s))'", exprs->word->word);
+ last_command_exit_value = 2;
+ return ((COMMAND *)NULL);
+ }
+
+ temp = (ARITH_FOR_COM *)xmalloc (sizeof (ARITH_FOR_COM));
+ temp->flags = 0;
+ temp->line = lineno;
+ temp->init = init ? init : make_arith_for_expr ("1");
+ temp->test = test ? test : make_arith_for_expr ("1");
+ temp->step = step ? step : make_arith_for_expr ("1");
+ temp->action = action;
+
+ return (make_command (cm_arith_for, (SIMPLE_COM *)temp));
+#else
+ last_command_exit_value = 2;
+ return ((COMMAND *)NULL);
+#endif /* ARITH_FOR_COMMAND */
+}
+
COMMAND *
make_group_command (command)
COMMAND *command;
@@ -308,6 +402,7 @@ make_arith_command (exp)
return (command);
#else
+ last_command_exit_value = 2;
return ((COMMAND *)NULL);
#endif
}
@@ -350,6 +445,7 @@ make_cond_command (cond_node)
return (command);
#else
+ last_command_exit_value = 2;
return ((COMMAND *)NULL);
#endif
}
@@ -588,6 +684,18 @@ make_function_def (name, command, lineno, lstart)
return (make_command (cm_function_def, (SIMPLE_COM *)temp));
}
+COMMAND *
+make_subshell_command (command)
+ COMMAND *command;
+{
+ SUBSHELL_COM *temp;
+
+ temp = (SUBSHELL_COM *)xmalloc (sizeof (SUBSHELL_COM));
+ temp->command = command;
+ temp->flags = CMD_WANT_SUBSHELL;
+ return (make_command (cm_subshell, (SIMPLE_COM *)temp));
+}
+
/* Reverse the word list and redirection list in the simple command
has just been parsed. It seems simpler to do this here the one
time then by any other method that I can think of. */
diff --git a/make_cmd.h b/make_cmd.h
index 06931049..e8ea919c 100644
--- a/make_cmd.h
+++ b/make_cmd.h
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if !defined (_MAKE_CMD_H_)
#define _MAKE_CMD_H_
@@ -55,6 +55,10 @@ extern COND_COM *make_cond_node __P((int, WORD_DESC *, COND_COM *, COND_COM *));
extern COMMAND *make_cond_command __P((COND_COM *));
#endif
+extern COMMAND *make_arith_for_command __P((WORD_LIST *, COMMAND *, int));
+
+extern COMMAND *make_subshell_command __P((COMMAND *));
+
extern COMMAND *connect_async_list __P((COMMAND *, COMMAND *, int));
#endif /* !_MAKE_CMD_H */
diff --git a/nojobs.c b/nojobs.c
index e1116845..ce426061 100644
--- a/nojobs.c
+++ b/nojobs.c
@@ -9,7 +9,7 @@
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
- Software Foundation; either version 1, or (at your option) any later
+ Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -19,7 +19,7 @@
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#include "config.h"
@@ -34,29 +34,12 @@
#include <signal.h>
#include <errno.h>
-#include "bashjmp.h"
-
-#include "command.h"
-#include "general.h"
-#include "jobs.h"
-#include "externs.h"
-#include "sig.h"
-#include "error.h"
-#include "bashtty.h"
-
#if defined (BUFFERED_INPUT)
# include "input.h"
#endif
-#if defined (TERMIOS_TTY_DRIVER)
-# include <termios.h>
-#else
-# if defined (TERMIO_TTY_DRIVER)
-# include <termio.h>
-# else
-# include <sgtty.h>
-# endif /* !TERMIO_TTY_DRIVER */
-#endif /* TERMIOS_TTY_DRIVER */
+/* Need to include this up here for *_TTY_DRIVER definitions. */
+#include "shtty.h"
#if !defined (STRUCT_WINSIZE_IN_SYS_IOCTL)
/* For struct winsize on SCO */
@@ -69,13 +52,22 @@
# endif /* HAVE_SYS_PTEM_H && TIOCGWINSZ && SIGWINCH */
#endif /* !STRUCT_WINSIZE_IN_SYS_IOCTL */
+#include "shell.h"
+#include "jobs.h"
+
+#include "builtins/builtext.h" /* for wait_builtin */
+
+#if !defined (CHILD_MAX)
+# define CHILD_MAX 32
+#endif
+
#if defined (_POSIX_VERSION) || !defined (HAVE_KILLPG)
# define killpg(pg, sig) kill(-(pg),(sig))
#endif /* USG || _POSIX_VERSION */
#if !defined (HAVE_SIGINTERRUPT)
# define siginterrupt(sig, code)
-#endif /* USG */
+#endif /* !HAVE_SIGINTERRUPT */
#if defined (HAVE_WAITPID)
# define WAITPID(pid, statusp, options) waitpid (pid, statusp, options)
@@ -92,14 +84,17 @@ extern int errno;
#if defined (READLINE)
extern void _rl_set_screen_size ();
-#endif
+#endif
extern int interactive, interactive_shell, login_shell;
extern int subshell_environment;
extern int last_command_exit_value;
+extern int interrupt_immediately;
+extern Function *this_shell_builtin;
#if defined (HAVE_POSIX_SIGNALS)
extern sigset_t top_level_mask;
#endif
+extern procenv_t wait_intr_buf;
pid_t last_made_pid = NO_PID;
pid_t last_asynchronous_pid = NO_PID;
@@ -118,15 +113,26 @@ int check_window_size;
static void reap_zombie_children ();
#endif
+static int wait_sigint_received;
+
+/* STATUS and FLAGS are only valid if pid != NO_PID
+ STATUS is only valid if (flags & PROC_RUNNING) == 0 */
struct proc_status {
pid_t pid;
int status; /* Exit status of PID or 128 + fatal signal number */
+ int flags;
};
+/* Values for proc_status.flags */
+#define PROC_RUNNING 0x01
+#define PROC_NOTIFIED 0x02
+#define PROC_ASYNC 0x04
+
static struct proc_status *pid_list = (struct proc_status *)NULL;
static int pid_list_size;
-#define PROC_BAD -1
+/* Return values from find_status_by_pid */
+#define PROC_BAD -1
#define PROC_STILL_ALIVE -2
/* Allocate new, or grow existing PID_LIST. */
@@ -188,9 +194,21 @@ find_status_by_pid (pid)
i = find_index_by_pid (pid);
if (i == NO_PID)
return (PROC_BAD);
+ if (pid_list[i].flags & PROC_RUNNING)
+ return (PROC_STILL_ALIVE);
return (pid_list[i].status);
}
+static int
+process_exit_status (status)
+ WAIT status;
+{
+ if (WIFSIGNALED (status))
+ return (128 + WTERMSIG (status));
+ else
+ return (WEXITSTATUS (status));
+}
+
/* Give PID the status value STATUS in the PID_LIST array. */
static void
set_pid_status (pid, status)
@@ -203,23 +221,96 @@ set_pid_status (pid, status)
if (slot == NO_PID)
return;
- if (WIFSIGNALED (status))
- pid_list[slot].status = 128 + WTERMSIG (status);
- else
- pid_list[slot].status = WEXITSTATUS (status);
+ pid_list[slot].status = process_exit_status (status);
+ pid_list[slot].flags &= ~PROC_RUNNING;
+ /* If it's not a background process, mark it as notified so it gets
+ cleaned up. */
+ if ((pid_list[slot].flags & PROC_ASYNC) == 0)
+ pid_list[slot].flags |= PROC_NOTIFIED;
+}
+
+/* Give PID the flags FLAGS in the PID_LIST array. */
+static void
+set_pid_flags (pid, flags)
+ pid_t pid;
+ int flags;
+{
+ int slot;
+
+ slot = find_index_by_pid (pid);
+ if (slot == NO_PID)
+ return;
+
+ pid_list[slot].flags |= flags;
+}
+
+/* Unset FLAGS for PID in the pid list */
+static void
+unset_pid_flags (pid, flags)
+ pid_t pid;
+ int flags;
+{
+ int slot;
+
+ slot = find_index_by_pid (pid);
+ if (slot == NO_PID)
+ return;
+
+ pid_list[slot].flags &= ~flags;
}
static void
-add_pid (pid)
+add_pid (pid, async)
pid_t pid;
+ int async;
{
int slot;
slot = find_proc_slot ();
+
pid_list[slot].pid = pid;
- pid_list[slot].status = PROC_STILL_ALIVE;
+ pid_list[slot].status = -1;
+ pid_list[slot].flags = PROC_RUNNING;
+ if (async)
+ pid_list[slot].flags |= PROC_ASYNC;
+}
+
+static void
+mark_dead_jobs_as_notified (force)
+ int force;
+{
+ register int i, ndead;
+
+ /* first, count the number of non-running async jobs if FORCE == 0 */
+ for (i = ndead = 0; force == 0 && i < pid_list_size; i++)
+ {
+ if (pid_list[i].pid == NO_PID)
+ continue;
+ if (((pid_list[i].flags & PROC_RUNNING) == 0) &&
+ (pid_list[i].flags & PROC_ASYNC))
+ ndead++;
+ }
+
+ if (force == 0 && ndead <= CHILD_MAX)
+ return;
+
+ /* If FORCE == 0, we just mark as many non-running async jobs as notified
+ to bring us under the CHILD_MAX limit. */
+ for (i = 0; i < pid_list_size; i++)
+ {
+ if (pid_list[i].pid == NO_PID)
+ continue;
+ if (((pid_list[i].flags & PROC_RUNNING) == 0) &&
+ pid_list[i].pid != last_asynchronous_pid)
+ {
+ pid_list[i].flags |= PROC_NOTIFIED;
+ if (force == 0 && (pid_list[i].flags & PROC_ASYNC) && --ndead <= CHILD_MAX)
+ break;
+ }
+ }
}
+/* Remove all dead, notified jobs from the pid_list. */
int
cleanup_dead_jobs ()
{
@@ -230,8 +321,20 @@ cleanup_dead_jobs ()
#endif
for (i = 0; i < pid_list_size; i++)
- if (pid_list[i].status != PROC_STILL_ALIVE)
- pid_list[i].pid = NO_PID;
+ {
+ if ((pid_list[i].flags & PROC_RUNNING) == 0 &&
+ (pid_list[i].flags & PROC_NOTIFIED))
+ pid_list[i].pid = NO_PID;
+ }
+
+ return 0;
+}
+
+void
+reap_dead_jobs ()
+{
+ mark_dead_jobs_as_notified (0);
+ cleanup_dead_jobs ();
}
/* Initialize the job control mechanism, and set up the tty stuff. */
@@ -408,7 +511,7 @@ make_child (command, async_p)
if (async_p)
last_asynchronous_pid = pid;
- add_pid (pid);
+ add_pid (pid, async_p);
}
return (pid);
}
@@ -433,7 +536,8 @@ default_tty_job_signals ()
#endif
}
-/* Wait for a single pid (PID) and return its exit status. */
+/* Wait for a single pid (PID) and return its exit status. Called by
+ the wait builtin. */
wait_for_single_pid (pid)
pid_t pid;
{
@@ -469,16 +573,16 @@ wait_for_single_pid (pid)
}
set_pid_status (got_pid, status);
+ set_pid_flags (got_pid, PROC_NOTIFIED);
+
siginterrupt (SIGINT, 0);
QUIT;
- if (WIFSIGNALED (status))
- return (128 + WTERMSIG (status));
- else
- return (WEXITSTATUS (status));
+ return (process_exit_status (status));
}
-/* Wait for all of the shell's children to exit. */
+/* Wait for all of the shell's children to exit. Called by the `wait'
+ builtin. */
void
wait_for_background_pids ()
{
@@ -504,6 +608,23 @@ wait_for_background_pids ()
siginterrupt (SIGINT, 0);
QUIT;
+
+ mark_dead_jobs_as_notified (1);
+ cleanup_dead_jobs ();
+}
+
+/* Make OLD_SIGINT_HANDLER the SIGINT signal handler. */
+#define INVALID_SIGNAL_HANDLER (SigHandler *)wait_for_background_pids
+static SigHandler *old_sigint_handler = INVALID_SIGNAL_HANDLER;
+
+static void
+restore_sigint_handler ()
+{
+ if (old_sigint_handler != INVALID_SIGNAL_HANDLER)
+ {
+ set_signal_handler (SIGINT, old_sigint_handler);
+ old_sigint_handler = INVALID_SIGNAL_HANDLER;
+ }
}
/* Handle SIGINT while we are waiting for children in a script to exit.
@@ -513,11 +634,28 @@ static sighandler
wait_sigint_handler (sig)
int sig;
{
+ SigHandler *sigint_handler;
+
+ /* If we got a SIGINT while in `wait', and SIGINT is trapped, do
+ what POSIX.2 says (see builtins/wait.def for more info). */
+ if (this_shell_builtin && this_shell_builtin == wait_builtin &&
+ signal_is_trapped (SIGINT) &&
+ ((sigint_handler = trap_to_sighandler (SIGINT)) == trap_handler))
+ {
+ last_command_exit_value = EXECUTION_FAILURE;
+ restore_sigint_handler ();
+ interrupt_immediately = 0;
+ trap_handler (SIGINT); /* set pending_traps[SIGINT] */
+ longjmp (wait_intr_buf, 1);
+ }
+
#if 0
/* Run a trap handler if one has been defined. */
maybe_call_trap_handler (sig);
#endif
+ wait_sigint_received = 1;
+
SIGRETURN (0);
}
@@ -530,7 +668,6 @@ wait_for (pid)
int return_val, pstatus;
pid_t got_pid;
WAIT status;
- SigHandler *old_sigint_handler;
pstatus = find_status_by_pid (pid);
@@ -542,7 +679,8 @@ wait_for (pid)
/* If we are running a script, ignore SIGINT while we're waiting for
a child to exit. The loop below does some of this, but not all. */
- if (!interactive_shell)
+ wait_sigint_received = 0;
+ if (interactive_shell == 0)
old_sigint_handler = set_signal_handler (SIGINT, wait_sigint_handler);
while ((got_pid = WAITPID (-1, &status, 0)) != pid) /* XXX was pid now -1 */
@@ -571,22 +709,29 @@ wait_for (pid)
if (interactive_shell == 0)
{
- set_signal_handler (SIGINT, old_sigint_handler);
+ SigHandler *temp_handler;
+
+ temp_handler = old_sigint_handler;
+ restore_sigint_handler ();
+
/* If the job exited because of SIGINT, make sure the shell acts as if
it had received one also. */
if (WIFSIGNALED (status) && (WTERMSIG (status) == SIGINT))
{
+
if (maybe_call_trap_handler (SIGINT) == 0)
- (*old_sigint_handler) (SIGINT);
+ {
+ if (temp_handler == SIG_DFL)
+ termination_unwind_protect (SIGINT);
+ else if (temp_handler != INVALID_SIGNAL_HANDLER && temp_handler != SIG_IGN)
+ (*temp_handler) (SIGINT);
+ }
}
}
/* Default return value. */
/* ``a full 8 bits of status is returned'' */
- if (WIFSIGNALED (status))
- return_val = 128 + WTERMSIG (status);
- else
- return_val = WEXITSTATUS (status);
+ return_val = process_exit_status (status);
#if !defined (DONT_REPORT_SIGPIPE)
if ((WIFSTOPPED (status) == 0) && WIFSIGNALED (status) &&
@@ -624,24 +769,11 @@ kill_pid (pid, signal, group)
{
int result;
- if (group)
- result = killpg (pid, signal);
- else
- result = kill (pid, signal);
-
+ result = group ? killpg (pid, signal) : kill (pid, signal);
return (result);
}
-#if defined (TERMIOS_TTY_DRIVER)
-static struct termios shell_tty_info;
-#else /* !TERMIOS_TTY_DRIVER */
-# if defined (TERMIO_TTY_DRIVER)
-static struct termio shell_tty_info;
-# else
-static struct sgttyb shell_tty_info;
-# endif /* !TERMIO_TTY_DRIVER */
-#endif /* !TERMIOS_TTY_DRIVER */
-
+static TTYSTRUCT shell_tty_info;
static int got_tty_state;
/* Fill the contents of shell_tty_info with the current tty info. */
@@ -652,15 +784,7 @@ get_tty_state ()
tty = input_tty ();
if (tty != -1)
{
-#if defined (TERMIOS_TTY_DRIVER)
- tcgetattr (tty, &shell_tty_info);
-#else
-# if defined (TERMIO_TTY_DRIVER)
- ioctl (tty, TCGETA, &shell_tty_info);
-# else
- ioctl (tty, TIOCGETP, &shell_tty_info);
-# endif
-#endif
+ ttgetattr (tty, &shell_tty_info);
got_tty_state = 1;
if (check_window_size)
get_new_window_size (0);
@@ -678,16 +802,7 @@ set_tty_state ()
{
if (got_tty_state == 0)
return 0;
-
-#if defined (TERMIOS_TTY_DRIVER)
- tcsetattr (tty, TCSADRAIN, &shell_tty_info);
-#else
-# if defined (TERMIO_TTY_DRIVER)
- ioctl (tty, TCSETAW, &shell_tty_info); /* Wait for output, no flush */
-# else
- ioctl (tty, TIOCSETN, &shell_tty_info);
-# endif
-#endif
+ ttsetattr (tty, &shell_tty_info);
}
return 0;
}
@@ -735,3 +850,9 @@ void
unfreeze_jobs_list ()
{
}
+
+int
+count_all_jobs ()
+{
+ return 0;
+}
diff --git a/parse.y b/parse.y
index 24f709c5..3c37c73e 100644
--- a/parse.y
+++ b/parse.y
@@ -6,7 +6,7 @@
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
- Software Foundation; either version 1, or (at your option) any later
+ Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License along
with Bash; see the file LICENSE. If not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
%{
#include "config.h"
@@ -100,6 +100,7 @@ extern Function *last_shell_builtin, *this_shell_builtin;
extern int bash_input_fd_changed;
#endif
+extern int errno;
/* **************************************************************** */
/* */
/* "Forward" declarations */
@@ -177,6 +178,9 @@ static int function_dstart;
/* The line number in a script on which a function body starts. */
static int function_bstart;
+/* The line number in a script at which an arithmetic for command starts. */
+static int arith_for_lineno;
+
static REDIRECTEE redir;
%}
@@ -196,12 +200,12 @@ static REDIRECTEE redir;
third group are recognized only under special circumstances. */
%token IF THEN ELSE ELIF FI CASE ESAC FOR SELECT WHILE UNTIL DO DONE FUNCTION
%token COND_START COND_END COND_ERROR
-%token IN BANG TIME TIMEOPT
+%token IN BANG TIME TIMEOPT
/* More general tokens. yylex () knows how to make these. */
%token <word> WORD ASSIGNMENT_WORD
%token <number> NUMBER
-%token <word_list> ARITH_CMD
+%token <word_list> ARITH_CMD ARITH_FOR_EXPRS
%token <command> COND_CMD
%token AND_AND OR_OR GREATER_GREATER LESS_LESS LESS_AND
%token GREATER_AND SEMI_SEMI LESS_LESS_MINUS AND_GREATER LESS_GREATER
@@ -215,6 +219,7 @@ static REDIRECTEE redir;
%type <command> for_command select_command case_command group_command
%type <command> arith_command
%type <command> cond_command
+%type <command> arith_for_command
%type <command> function_def if_command elif_clause subshell
%type <redirect> redirection redirection_list
%type <element> simple_command_element
@@ -462,6 +467,14 @@ command: simple_command
be attached to the function and performed when
the function is executed, not as part of the
function definition command. */
+ /* XXX - I don't think it matters, but we might
+ want to change this in the future to avoid
+ problems differentiating between a function
+ definition with a redirection and a function
+ definition containing a single command with a
+ redirection. The two are semantically equivalent,
+ though -- the only difference is in how the
+ command printing code displays the redirections. */
if (tc->type == cm_function_def)
{
tc = tc->value.Function_def->command;
@@ -501,6 +514,8 @@ shell_command: for_command
{ $$ = $1; }
| cond_command
{ $$ = $1; }
+ | arith_for_command
+ { $$ = $1; }
| function_def
{ $$ = $1; }
;
@@ -519,6 +534,11 @@ for_command: FOR WORD newline_list DO compound_list DONE
{ $$ = make_for_command ($2, REVERSE_LIST ($5, WORD_LIST *), $9); }
;
+arith_for_command: FOR ARITH_FOR_EXPRS list_terminator newline_list DO compound_list DONE
+ { $$ = make_arith_for_command ($2, $6, arith_for_lineno); }
+ | FOR ARITH_FOR_EXPRS list_terminator newline_list '{' compound_list '}'
+ { $$ = make_arith_for_command ($2, $6, arith_for_lineno); }
+ ;
select_command: SELECT WORD newline_list DO list DONE
{
$$ = make_select_command ($2, add_string_to_list ("\"$@\"", (WORD_LIST *)NULL), $5);
@@ -565,7 +585,10 @@ function_def: WORD '(' ')' newline_list group_command
;
subshell: '(' compound_list ')'
- { $2->flags |= CMD_WANT_SUBSHELL; $$ = $2; }
+ {
+ $$ = make_subshell_command ($2);
+ $$->flags |= CMD_WANT_SUBSHELL;
+ }
;
if_command: IF compound_list THEN compound_list FI
@@ -744,7 +767,7 @@ pipeline_command: pipeline
}
| timespec BANG pipeline
{
- $3->flags |= $1;
+ $3->flags |= $1|CMD_INVERT_RETURN;
$$ = $3;
}
| BANG timespec pipeline
@@ -779,6 +802,7 @@ timespec: TIME
#define PST_CASESTMT 0x080 /* parsing a case statement */
#define PST_CONDCMD 0x100 /* parsing a [[...]] command */
#define PST_CONDEXPR 0x200 /* parsing the guts of [[...]] */
+#define PST_ARITHFOR 0x400 /* parsing an arithmetic for command */
/* Initial size to allocate for tokens, and the
amount to grow them by. */
@@ -1068,20 +1092,21 @@ with_input_from_string (string, name)
/* */
/* **************************************************************** */
+/* These two functions used to test the value of the HAVE_RESTARTABLE_SYSCALLS
+ define, and just use getc/ungetc if it was defined, but since bash
+ installs its signal handlers without the SA_RESTART flag, some signals
+ (like SIGCHLD, SIGWINCH, etc.) received during a read(2) will not cause
+ the read to be restarted. We need to restart it ourselves. */
+
static int
yy_stream_get ()
{
- int result = EOF;
+ int result;
+ result = EOF;
if (bash_input.location.file)
- {
-#if !defined (HAVE_RESTARTABLE_SYSCALLS)
- result = getc_with_restart (bash_input.location.file);
-#else /* HAVE_RESTARTABLE_SYSCALLS */
- result = getc (bash_input.location.file);
- result = (feof (bash_input.location.file)) ? EOF : (unsigned char)result;
-#endif /* HAVE_RESTARTABLE_SYSCALLS */
- }
+ result = getc_with_restart (bash_input.location.file);
+
return (result);
}
@@ -1089,11 +1114,7 @@ static int
yy_stream_unget (c)
int c;
{
-#if !defined (HAVE_RESTARTABLE_SYSCALLS)
return (ungetc_with_restart (c, bash_input.location.file));
-#else /* HAVE_RESTARTABLE_SYSCALLS */
- return (ungetc (c, bash_input.location.file));
-#endif /* HAVE_RESTARTABLE_SYSCALLS */
}
void
@@ -1209,6 +1230,30 @@ stream_on_stack (type)
return 0;
}
+/* Save the current token state and return it in a malloced array. */
+int *
+save_token_state ()
+{
+ int *ret;
+
+ ret = (int *)xmalloc (3 * sizeof (int));
+ ret[0] = last_read_token;
+ ret[1] = token_before_that;
+ ret[2] = two_tokens_ago;
+ return ret;
+}
+
+void
+restore_token_state (ts)
+ int *ts;
+{
+ if (ts == 0)
+ return;
+ last_read_token = ts[0];
+ token_before_that = ts[1];
+ two_tokens_ago = ts[2];
+}
+
/*
* This is used to inhibit alias expansion and reserved word recognition
* inside case statement pattern lists. A `case statement pattern list' is:
@@ -2204,8 +2249,36 @@ read_token (command)
case '|':
return (OR_OR);
-#if defined (DPAREN_ARITHMETIC)
+#if defined (DPAREN_ARITHMETIC) || defined (ARITH_FOR_COMMAND)
case '(': /* ) */
+# if defined (ARITH_FOR_COMMAND)
+ if (last_read_token == FOR)
+ {
+ int cmdtyp, len;
+ char *wval, *wv2;
+ WORD_DESC *wd;
+
+ arith_for_lineno = line_number;
+ cmdtyp = parse_arith_cmd (&wval);
+ if (cmdtyp == 1)
+ {
+ /* parse_arith_cmd adds quotes at the beginning and end
+ of the string it returns; we need to take those out. */
+ len = strlen (wval);
+ wv2 = xmalloc (len);
+ strncpy (wv2, wval + 1, len - 2);
+ wv2[len - 2] = '\0';
+ wd = make_word (wv2);
+ yylval.word_list = make_word_list (wd, (WORD_LIST *)NULL);
+ free (wval);
+ free (wv2);
+ return (ARITH_FOR_EXPRS);
+ }
+ else
+ return -1; /* ERROR */
+ }
+# endif
+# if defined (DPAREN_ARITHMETIC)
if (reserved_word_acceptable (last_read_token))
{
int cmdtyp, sline;
@@ -2233,6 +2306,7 @@ read_token (command)
return -1;
}
break;
+# endif
#endif
}
}
@@ -2302,6 +2376,7 @@ read_token (command)
correct error values if it reads EOF. */
#define P_FIRSTCLOSE 0x01
+#define P_ALLOWESC 0x02
static char matched_pair_error;
static char *
@@ -2324,7 +2399,7 @@ parse_matched_pair (qc, open, close, lenp, flags)
start_lineno = line_number;
while (count)
{
- ch = shell_getc (qc != '\'' && pass_next_character == 0);
+ ch = shell_getc ((qc != '\'' || (flags & P_ALLOWESC)) && pass_next_character == 0);
if (ch == EOF)
{
free (ret);
@@ -2362,6 +2437,11 @@ parse_matched_pair (qc, open, close, lenp, flags)
}
else if (ch == close) /* ending delimiter */
count--;
+#if 1
+ /* handle nested ${...} specially. */
+ else if (open != close && was_dollar && open == '{' && ch == open) /* } */
+ count++;
+#endif
else if (((flags & P_FIRSTCLOSE) == 0) && ch == open) /* nested begin */
count++;
@@ -2370,7 +2450,11 @@ parse_matched_pair (qc, open, close, lenp, flags)
ret[retind++] = ch;
if (open == '\'') /* '' inside grouping construct */
- continue;
+ {
+ if ((flags & P_ALLOWESC) && ch == '\\')
+ pass_next_character++;
+ continue;
+ }
if (ch == '\\') /* backslashes */
pass_next_character++;
@@ -2449,7 +2533,7 @@ parse_matched_pair (qc, open, close, lenp, flags)
return ret;
}
-#if defined (DPAREN_ARITHMETIC)
+#if defined (DPAREN_ARITHMETIC) || defined (ARITH_FOR_COMMAND)
/* We've seen a `(('. Look for the matching `))'. If we get it, return 1.
If not, assume it's a nested subshell for backwards compatibility and
return 0. In any case, put the characters we've consumed into a locally-
@@ -2473,7 +2557,7 @@ parse_arith_cmd (ep)
if ((c = shell_getc (0)) != ')')
rval = 0;
- token = xmalloc(ttoklen + 4);
+ token = xmalloc (ttoklen + 4);
/* (( ... )) -> "..." */
token[0] = (rval == 1) ? '"' : '(';
@@ -2493,7 +2577,7 @@ parse_arith_cmd (ep)
FREE (ttok);
return rval;
}
-#endif /* DPAREN_ARITHMETIC */
+#endif /* DPAREN_ARITHMETIC || ARITH_FOR_COMMAND */
#if defined (COND_COMMAND)
static COND_COM *cond_term ();
@@ -2604,7 +2688,7 @@ cond_term ()
(void)cond_skip_newlines ();
}
- else /* left argument to binary operator */
+ else if (tok == WORD) /* left argument to binary operator */
{
/* lhs */
tleft = make_cond_node (COND_TERM, yylval.word, (COND_COM *)NULL, (COND_COM *)NULL);
@@ -2649,6 +2733,14 @@ cond_term ()
(void)cond_skip_newlines ();
}
+ else
+ {
+ if (tok < 256)
+ parser_error (line_number, "unexpected token `%c' in conditional command", tok);
+ else
+ parser_error (line_number, "unexpected token %d in conditional command", tok);
+ COND_RETURN_ERROR ();
+ }
return (term);
}
@@ -2809,7 +2901,7 @@ read_token_word (character)
the command-oriented-history code. This way newlines
appearing in the $(...) string get added to the
history literally rather than causing a possibly-
- incorrect `;' to be added. */
+ incorrect `;' to be added. ) */
push_delimiter (dstack, peek_char);
ttok = parse_matched_pair (cd, '(', ')', &ttoklen, 0);
pop_delimiter (dstack);
@@ -2836,21 +2928,46 @@ read_token_word (character)
int first_line;
first_line = line_number;
- ttok = parse_matched_pair (peek_char, peek_char, peek_char, &ttoklen, 0);
+ push_delimiter (dstack, peek_char);
+ ttok = parse_matched_pair (peek_char, peek_char, peek_char,
+ &ttoklen,
+ (peek_char == '\'') ? P_ALLOWESC : 0);
+ pop_delimiter (dstack);
if (ttok == &matched_pair_error)
return -1;
if (peek_char == '\'')
- ttrans = ansiexpand (ttok, 0, ttoklen - 1, &ttranslen);
+ {
+ ttrans = ansiexpand (ttok, 0, ttoklen - 1, &ttranslen);
+ free (ttok);
+ /* Insert the single quotes and correctly quote any
+ embedded single quotes (allowed because P_ALLOWESC was
+ passed to parse_matched_pair). */
+ ttok = single_quote (ttrans);
+ free (ttrans);
+ ttrans = ttok;
+ ttranslen = strlen (ttrans);
+ }
else
- ttrans = localeexpand (ttok, 0, ttoklen - 1, first_line, &ttranslen);
- free (ttok);
+ {
+ /* Try to locale-expand the converted string. */
+ ttrans = localeexpand (ttok, 0, ttoklen - 1, first_line, &ttranslen);
+ free (ttok);
+
+ /* Add the double quotes back */
+ ttok = xmalloc (ttranslen + 3);
+ ttok[0] = '"';
+ strcpy (ttok + 1, ttrans);
+ ttok[ttranslen + 1] = '"';
+ ttok[ttranslen += 2] = '\0';
+ free (ttrans);
+ ttrans = ttok;
+ }
+
RESIZE_MALLOCED_BUFFER (token, token_index, ttranslen + 2,
token_buffer_size,
TOKEN_DEFAULT_GROW_SIZE);
- token[token_index++] = peek_char;
strcpy (token + token_index, ttrans);
token_index += ttranslen;
- token[token_index++] = peek_char;
FREE (ttrans);
quoted = 1;
all_digits = 0;
@@ -3036,7 +3153,7 @@ ansiexpand (string, start, end, lenp)
if (*temp)
{
- t = ansicstr (temp, tlen, (int *)NULL, lenp);
+ t = ansicstr (temp, tlen, 0, (int *)NULL, lenp);
free (temp);
return (t);
}
@@ -3048,6 +3165,52 @@ ansiexpand (string, start, end, lenp)
}
}
+/* Change a bash string into a string suitable for inclusion in a `po' file.
+ This backslash-escapes `"' and `\' and changes newlines into \\\n"\n". */
+static char *
+mk_msgstr (string, foundnlp)
+ char *string;
+ int *foundnlp;
+{
+ register int c, len;
+ char *result, *r, *s;
+
+ for (len = 0, s = string; s && *s; s++)
+ {
+ len++;
+ if (*s == '"' || *s == '\\')
+ len++;
+ else if (*s == '\n')
+ len += 5;
+ }
+
+ r = result = xmalloc (len + 3);
+ *r++ = '"';
+
+ for (s = string; s && (c = *s); s++)
+ {
+ if (c == '\n') /* <NL> -> \n"<NL>" */
+ {
+ *r++ = '\\';
+ *r++ = 'n';
+ *r++ = '"';
+ *r++ = '\n';
+ *r++ = '"';
+ if (foundnlp)
+ *foundnlp = 1;
+ continue;
+ }
+ if (c == '"' || c == '\\')
+ *r++ = '\\';
+ *r++ = c;
+ }
+
+ *r++ = '"';
+ *r++ = '\0';
+
+ return result;
+}
+
/* $"..." -- Translate the portion of STRING between START and END
according to current locale using gettext (if available) and return
the result. The caller will take care of leaving the quotes intact.
@@ -3060,22 +3223,35 @@ localeexpand (string, start, end, lineno, lenp)
char *string;
int start, end, lineno, *lenp;
{
- int len, tlen;
- char *temp, *t;
+ int len, tlen, foundnl;
+ char *temp, *t, *t2;
temp = xmalloc (end - start + 1);
for (tlen = 0, len = start; len < end; )
temp[tlen++] = string[len++];
temp[tlen] = '\0';
- /* If we're just dumping translatable strings, don't do anything. */
+ /* If we're just dumping translatable strings, don't do anything with the
+ string itself, but if we're dumping in `po' file format, convert it into a form more palatable to gettext(3)
+ and friends by quoting `"' and `\' with backslashes and converting <NL>
+ into `\n"<NL>"'. If we find a newline in TEMP, we first output a
+ `msgid ""' line and then the translated string; otherwise we output the
+ `msgid' and translated string all on one line. */
if (dump_translatable_strings)
{
if (dump_po_strings)
- printf ("#: %s:%d\nmsgid \"%s\"\nmsgstr \"\"\n",
- (bash_input.name ? bash_input.name : "stdin"), lineno, temp);
+ {
+ foundnl = 0;
+ t = mk_msgstr (temp, &foundnl);
+ t2 = foundnl ? "\"\"\n" : "";
+
+ printf ("#: %s:%d\nmsgid %s%s\nmsgstr \"\"\n",
+ (bash_input.name ? bash_input.name : "stdin"), lineno, t2, t);
+ free (t);
+ }
else
printf ("\"%s\"\n", temp);
+
if (lenp)
*lenp = tlen;
return (temp);
@@ -3211,6 +3387,17 @@ history_delimiting_chars ()
else if (token_before_that == WORD && two_tokens_ago == FUNCTION)
return " "; /* function def using `function name' without `()' */
+ else if (token_before_that == WORD && two_tokens_ago == FOR)
+ {
+ /* Tricky. `for i\nin ...' should not have a semicolon, but
+ `for i\ndo ...' should. We do what we can. */
+ for (i = shell_input_line_index; whitespace(shell_input_line[i]); i++)
+ ;
+ if (shell_input_line[i] && shell_input_line[i] == 'i' && shell_input_line[i+1] == 'n')
+ return " ";
+ return ";";
+ }
+
for (i = 0; no_semi_successors[i]; i++)
{
if (token_before_that == no_semi_successors[i])
@@ -3264,6 +3451,20 @@ prompt_again ()
}
}
+int
+get_current_prompt_level ()
+{
+ return ((current_prompt_string && current_prompt_string == ps2_prompt) ? 2 : 1);
+}
+
+void
+set_current_prompt_level (x)
+ int x;
+{
+ prompt_string_pointer = (x == 2) ? &ps2_prompt : &ps1_prompt;
+ current_prompt_string = *prompt_string_pointer;
+}
+
static void
print_prompt ()
{
@@ -3279,6 +3480,8 @@ print_prompt ()
\d the date in Day Mon Date format
\h the hostname up to the first `.'
\H the hostname
+ \j the number of active jobs
+ \l the basename of the shell's tty device name
\n CRLF
\s the name of the shell
\t the time in 24-hour hh:mm:ss format
@@ -3479,7 +3682,14 @@ decode_prompt_string (string)
/* If we're going to be expanding the prompt string later,
quote the directory name. */
if (promptvars || posixly_correct)
+#if 0
temp = backslash_quote (t_string);
+#else
+ /* Make sure that expand_prompt_string is called with a
+ second argument of Q_DOUBLE_QUOTE if we use this
+ function here. */
+ temp = backslash_quote_for_double_quotes (t_string);
+#endif
else
temp = savestring (t_string);
@@ -3487,6 +3697,8 @@ decode_prompt_string (string)
}
case 'u':
+ if (current_user.user_name == 0)
+ get_current_user_info ();
temp = savestring (current_user.user_name);
goto add_string;
@@ -3517,6 +3729,20 @@ decode_prompt_string (string)
*t = '\0';
goto add_string;
+ case 'j':
+ temp = itos (count_all_jobs ());
+ goto add_string;
+
+ case 'l':
+#if defined (HAVE_TTYNAME)
+ temp = (char *)ttyname (fileno (stdin));
+ t = temp ? base_pathname (temp) : "tty";
+ temp = savestring (t);
+#else
+ temp = savestring ("tty");
+#endif /* !HAVE_TTYNAME */
+ goto add_string;
+
#if defined (READLINE)
case '[':
case ']':
@@ -3578,7 +3804,11 @@ decode_prompt_string (string)
the prompt string. */
if (promptvars || posixly_correct)
{
+#if 0
list = expand_string_unsplit (result, Q_DOUBLE_QUOTES);
+#else
+ list = expand_prompt_string (result, Q_DOUBLE_QUOTES);
+#endif
free (result);
result = string_list (list);
dispose_words (list);
@@ -3653,11 +3883,7 @@ report_syntax_error (message)
if (token_end || (i == 0 && token_end == 0))
{
if (token_end)
- {
- msg = xmalloc (1 + (token_end - i));
- strncpy (msg, t + i, token_end - i);
- msg[token_end - i] = '\0';
- }
+ msg = substring (t, i, token_end);
else /* one-character token */
{
msg2[0] = t[i];
@@ -3761,3 +3987,73 @@ handle_eof_input_unit ()
EOF_Reached = 1;
}
}
+
+static WORD_LIST parse_string_error;
+
+/* Take a string and run it through the shell parser, returning the
+ resultant word list. Used by compound array assignment. */
+WORD_LIST *
+parse_string_to_word_list (s, whom)
+ char *s, *whom;
+{
+ WORD_LIST *wl;
+ int tok, orig_line_number, orig_input_terminator;
+#if defined (HISTORY)
+ int old_remember_on_history, old_history_expansion_inhibited;
+#endif
+
+#if defined (HISTORY)
+ old_remember_on_history = remember_on_history;
+# if defined (BANG_HISTORY)
+ old_history_expansion_inhibited = history_expansion_inhibited;
+# endif
+ bash_history_disable ();
+#endif
+
+ orig_line_number = line_number;
+ orig_input_terminator = shell_input_line_terminator;
+
+ push_stream (1);
+ last_read_token = '\n';
+
+ with_input_from_string (s, whom);
+ wl = (WORD_LIST *)NULL;
+ while ((tok = read_token (READ)) != yacc_EOF)
+ {
+ if (tok == '\n' && *bash_input.location.string == '\0')
+ break;
+ if (tok != WORD && tok != ASSIGNMENT_WORD)
+ {
+ line_number = orig_line_number + line_number - 1;
+ yyerror (); /* does the right thing */
+ if (wl)
+ dispose_words (wl);
+ wl = &parse_string_error;
+ break;
+ }
+ wl = make_word_list (yylval.word, wl);
+ }
+
+ last_read_token = '\n';
+ pop_stream ();
+
+#if defined (HISTORY)
+ remember_on_history = old_remember_on_history;
+# if defined (BANG_HISTORY)
+ history_expansion_inhibited = old_history_expansion_inhibited;
+# endif /* BANG_HISTORY */
+#endif /* HISTORY */
+
+ shell_input_line_terminator = orig_input_terminator;
+
+ if (wl == &parse_string_error)
+ {
+ last_command_exit_value = EXECUTION_FAILURE;
+ if (interactive_shell == 0 && posixly_correct)
+ jump_to_top_level (FORCE_EOF);
+ else
+ jump_to_top_level (DISCARD);
+ }
+
+ return (REVERSE_LIST (wl, WORD_LIST *));
+}
diff --git a/parser-built b/parser-built
index affe1206..03e9ce0f 100644
--- a/parser-built
+++ b/parser-built
@@ -32,19 +32,20 @@ typedef union {
#define ASSIGNMENT_WORD 280
#define NUMBER 281
#define ARITH_CMD 282
-#define COND_CMD 283
-#define AND_AND 284
-#define OR_OR 285
-#define GREATER_GREATER 286
-#define LESS_LESS 287
-#define LESS_AND 288
-#define GREATER_AND 289
-#define SEMI_SEMI 290
-#define LESS_LESS_MINUS 291
-#define AND_GREATER 292
-#define LESS_GREATER 293
-#define GREATER_BAR 294
-#define yacc_EOF 295
+#define ARITH_FOR_EXPRS 283
+#define COND_CMD 284
+#define AND_AND 285
+#define OR_OR 286
+#define GREATER_GREATER 287
+#define LESS_LESS 288
+#define LESS_AND 289
+#define GREATER_AND 290
+#define SEMI_SEMI 291
+#define LESS_LESS_MINUS 292
+#define AND_GREATER 293
+#define LESS_GREATER 294
+#define GREATER_BAR 295
+#define yacc_EOF 296
extern YYSTYPE yylval;
diff --git a/parser.h b/parser.h
index c2644816..626651cc 100644
--- a/parser.h
+++ b/parser.h
@@ -1,5 +1,24 @@
/* parser.h -- Everything you wanted to know about the parser, but were
afraid to ask. */
+
+/* Copyright (C) 1995 Free Software Foundation, Inc.
+
+ This file is part of GNU Bash, the Bourne Again SHell.
+
+ Bash is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free
+ Software Foundation; either version 2, or (at your option) any later
+ version.
+
+ Bash is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with Bash; see the file COPYING. If not, write to the Free Software
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+
#if !defined (_PARSER_H_)
# define _PARSER_H_
diff --git a/pathexp.c b/pathexp.c
index 3c02effc..6f0f5472 100644
--- a/pathexp.c
+++ b/pathexp.c
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#include "config.h"
@@ -196,7 +196,22 @@ shell_glob_filename (pathname)
else if (i != 0) /* other error codes not in POSIX.2 */
filenames.gl_pathv = (char **)NULL;
- return (filenames.gl_pathv);
+ results = filenames.gl_pathv;
+
+ if (results && ((GLOB_FAILED (results)) == 0))
+ {
+ if (should_ignore_glob_matches ())
+ ignore_glob_matches (results);
+ if (results && results[0])
+ sort_char_array (results);
+ else
+ {
+ FREE (results);
+ results = (char **)NULL;
+ }
+ }
+
+ return (results);
#else /* !USE_POSIX_GLOB_LIBRARY */
@@ -298,7 +313,7 @@ ignore_globbed_names (names, name_func)
for (i = 0; names[i]; i++)
;
- newnames = (char **)xmalloc ((i + 1) * sizeof (char *));
+ newnames = alloc_array (i + 1);
for (n = i = 0; names[i]; i++)
{
diff --git a/pathexp.h b/pathexp.h
index 7ddd17ac..92906548 100644
--- a/pathexp.h
+++ b/pathexp.h
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if !defined (_PATHEXP_H_)
#define _PATHEXP_H_
diff --git a/pathnames.h b/pathnames.h
index 2800118a..27817afa 100644
--- a/pathnames.h
+++ b/pathnames.h
@@ -6,7 +6,7 @@
Bash is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 1, or (at your option)
+ the Free Software Foundation; either version 2, or (at your option)
any later version.
Bash is distributed in the hope that it will be useful, but WITHOUT
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with Bash; see the file COPYING. If not, write to the Free
- Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if !defined (_PATHNAMES_H_)
#define _PATHNAMES_H_
diff --git a/pcomplete.c b/pcomplete.c
new file mode 100644
index 00000000..a1fc0454
--- /dev/null
+++ b/pcomplete.c
@@ -0,0 +1,1461 @@
+/* pcomplete.c - functions to generate lists of matches for programmable
+ completion. */
+
+/* Copyright (C) 1999 Free Software Foundation, Inc.
+
+ This file is part of GNU Bash, the Bourne Again SHell.
+
+ Bash is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free
+ Software Foundation; either version 2, or (at your option) any later
+ version.
+
+ Bash is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with Bash; see the file COPYING. If not, write to the Free Software
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+
+#include <config.h>
+
+#if defined (PROGRAMMABLE_COMPLETION)
+
+#include "bashtypes.h"
+#include "posixstat.h"
+
+#if defined (HAVE_UNISTD_H)
+# include <unistd.h>
+#endif
+
+#include <signal.h>
+
+#if defined (PREFER_STDARG)
+# include <stdarg.h>
+#else
+# if defined (PREFER_VARARGS)
+# include <varargs.h>
+# endif
+#endif
+
+#include <stdio.h>
+#include "bashansi.h"
+
+#include "shell.h"
+#include "pcomplete.h"
+#include "alias.h"
+#include "bashline.h"
+#include "pathexp.h"
+
+#if defined (JOB_CONTROL)
+# include "jobs.h"
+#endif
+
+#if !defined (NSIG)
+# include "trap.h"
+#endif
+
+#include "builtins.h"
+#include "builtins/common.h"
+
+#include <glob/glob.h>
+#include <glob/fnmatch.h>
+
+#include <readline/rlconf.h>
+#include <readline/readline.h>
+#include <readline/history.h>
+
+#ifdef STRDUP
+# undef STRDUP
+#endif
+#define STRDUP(x) ((x) ? savestring (x) : (char *)NULL)
+
+typedef SHELL_VAR **SVFUNC ();
+
+#ifndef HAVE_STRPBRK
+extern char *strpbrk __P((char *, char *));
+#endif
+
+extern int rl_filename_completion_desired;
+extern int array_needs_making;
+extern STRING_INT_ALIST word_token_alist[];
+extern char *signal_names[];
+
+static int it_init_aliases ();
+static int it_init_arrayvars ();
+static int it_init_bindings ();
+static int it_init_builtins ();
+static int it_init_disabled ();
+static int it_init_enabled ();
+static int it_init_exported ();
+static int it_init_functions ();
+static int it_init_hostnames ();
+static int it_init_jobs ();
+static int it_init_running ();
+static int it_init_stopped ();
+static int it_init_keywords ();
+static int it_init_signals ();
+static int it_init_variables ();
+static int it_init_setopts ();
+static int it_init_shopts ();
+
+static int progcomp_debug = 0;
+
+int prog_completion_enabled = 1;
+
+/* These are used to manage the arrays of strings for possible completions. */
+ITEMLIST it_aliases = { 0, it_init_aliases, (STRINGLIST *)0 };
+ITEMLIST it_arrayvars = { LIST_DYNAMIC, it_init_arrayvars, (STRINGLIST *)0 };
+ITEMLIST it_bindings = { 0, it_init_bindings, (STRINGLIST *)0 };
+ITEMLIST it_builtins = { 0, it_init_builtins, (STRINGLIST *)0 };
+ITEMLIST it_commands = { LIST_DYNAMIC }; /* unused */
+ITEMLIST it_directories = { LIST_DYNAMIC }; /* unused */
+ITEMLIST it_disabled = { 0, it_init_disabled, (STRINGLIST *)0 };
+ITEMLIST it_enabled = { 0, it_init_enabled, (STRINGLIST *)0 };
+ITEMLIST it_exports = { LIST_DYNAMIC, it_init_exported, (STRINGLIST *)0 };
+ITEMLIST it_files = { LIST_DYNAMIC }; /* unused */
+ITEMLIST it_functions = { 0, it_init_functions, (STRINGLIST *)0 };
+ITEMLIST it_hostnames = { LIST_DYNAMIC, it_init_hostnames, (STRINGLIST *)0 };
+ITEMLIST it_jobs = { LIST_DYNAMIC, it_init_jobs, (STRINGLIST *)0 };;
+ITEMLIST it_keywords = { 0, it_init_keywords, (STRINGLIST *)0 };
+ITEMLIST it_running = { LIST_DYNAMIC, it_init_running, (STRINGLIST *)0 };
+ITEMLIST it_setopts = { 0, it_init_setopts, (STRINGLIST *)0 };
+ITEMLIST it_shopts = { 0, it_init_shopts, (STRINGLIST *)0 };
+ITEMLIST it_signals = { 0, it_init_signals, (STRINGLIST *)0 };
+ITEMLIST it_stopped = { LIST_DYNAMIC, it_init_stopped, (STRINGLIST *)0 };
+ITEMLIST it_users = { LIST_DYNAMIC }; /* unused */
+ITEMLIST it_variables = { LIST_DYNAMIC, it_init_variables, (STRINGLIST *)0 };
+
+/* Debugging code */
+#if !defined (USE_VARARGS)
+static void
+debug_printf (format, arg1, arg2, arg3, arg4, arg5)
+ char *format;
+{
+ if (progcomp_debug == 0)
+ return;
+
+ fprintf (stdout, format, arg1, arg2, arg3, arg4, arg5);
+ fprintf (stdout, "\n");
+ rl_on_new_line ();
+}
+#else
+static void
+#if defined (PREFER_STDARG)
+debug_printf (const char *format, ...)
+#else
+debug_printf (format, va_alist)
+ const char *format;
+ va_dcl
+#endif
+{
+ va_list args;
+
+ if (progcomp_debug == 0)
+ return;
+
+#if defined (PREFER_STDARG)
+ va_start (args, format);
+#else
+ va_start (args);
+#endif
+
+ fprintf (stdout, "DEBUG: ");
+ vfprintf (stdout, format, args);
+ fprintf (stdout, "\n");
+
+ rl_on_new_line ();
+
+ va_end (args);
+}
+#endif /* USE_VARARGS */
+
+/* Functions to manage the item lists */
+
+void
+set_itemlist_dirty (it)
+ ITEMLIST *it;
+{
+ it->flags |= LIST_DIRTY;
+}
+
+void
+initialize_itemlist (itp)
+ ITEMLIST *itp;
+{
+ (*itp->list_getter) (itp);
+ itp->flags |= LIST_INITIALIZED;
+ itp->flags &= ~LIST_DIRTY;
+}
+
+void
+clean_itemlist (itp)
+ ITEMLIST *itp;
+{
+ STRINGLIST *sl;
+
+ sl = itp->slist;
+ if (sl)
+ {
+ if ((itp->flags & (LIST_DONTFREEMEMBERS|LIST_DONTFREE)) == 0)
+ free_array_members (sl->list);
+ if ((itp->flags & LIST_DONTFREE) == 0)
+ free (sl->list);
+ free (sl);
+ }
+ itp->slist = (STRINGLIST *)NULL;
+ itp->flags &= ~(LIST_DONTFREE|LIST_DONTFREEMEMBERS|LIST_INITIALIZED|LIST_DIRTY);
+}
+
+/* Functions to manage the string lists -- lists of matches. These should
+ really be moved to a separate file. */
+
+/* Allocate a new STRINGLIST, with room for N strings. */
+STRINGLIST *
+alloc_stringlist (n)
+ int n;
+{
+ STRINGLIST *ret;
+ register int i;
+
+ ret = (STRINGLIST *)xmalloc (sizeof (STRINGLIST));
+ if (n)
+ {
+ ret->list = alloc_array (n+1);
+ ret->list_size = n;
+ for (i = 0; i < n; i++)
+ ret->list[i] = (char *)NULL;
+ }
+ else
+ {
+ ret->list = (char **)NULL;
+ ret->list_size = 0;
+ }
+ ret->list_len = 0;
+ return ret;
+}
+
+STRINGLIST *
+realloc_stringlist (sl, n)
+ STRINGLIST *sl;
+ int n;
+{
+ register int i;
+
+ if (n > sl->list_size)
+ {
+ sl->list = (char **)xrealloc (sl->list, (n+1) * sizeof (char *));
+ for (i = sl->list_size; i <= n; i++)
+ sl->list[i] = (char *)NULL;
+ sl->list_size = n;
+ }
+ return sl;
+}
+
+void
+free_stringlist (sl)
+ STRINGLIST *sl;
+{
+ if (sl == 0)
+ return;
+ if (sl->list)
+ free_array (sl->list);
+ free (sl);
+}
+
+STRINGLIST *
+copy_stringlist (sl)
+ STRINGLIST *sl;
+{
+ STRINGLIST *new;
+ register int i;
+
+ new = alloc_stringlist (sl->list_size);
+ /* I'd like to use copy_array, but that doesn't copy everything. */
+ if (sl->list)
+ {
+ for (i = 0; i < sl->list_size; i++)
+ new->list[i] = STRDUP (sl->list[i]);
+ }
+ new->list_size = sl->list_size;
+ new->list_len = sl->list_len;
+ /* just being careful */
+ if (new->list)
+ new->list[new->list_len] = (char *)NULL;
+ return new;
+}
+
+/* Return a new STRINGLIST with everything from M1 and M2. */
+
+STRINGLIST *
+merge_stringlists (m1, m2)
+ STRINGLIST *m1, *m2;
+{
+ STRINGLIST *sl;
+ int i, n, l1, l2;
+
+ l1 = m1 ? m1->list_len : 0;
+ l2 = m2 ? m2->list_len : 0;
+
+ sl = alloc_stringlist (l1 + l2 + 1);
+ for (i = n = 0; i < l1; i++, n++)
+ sl->list[n] = STRDUP (m1->list[i]);
+ for (i = 0; i < l2; i++, n++)
+ sl->list[n] = STRDUP (m2->list[i]);
+ sl->list_len = n;
+ sl->list[n] = (char *)NULL;
+}
+
+/* Make STRINGLIST M1 contain everything in M1 and M2. */
+STRINGLIST *
+append_stringlist (m1, m2)
+ STRINGLIST *m1, *m2;
+{
+ register int i, n, len1, len2;
+
+ if (m1 == 0)
+ {
+ m1 = copy_stringlist (m2);
+ return m1;
+ }
+
+ len1 = m1->list_len;
+ len2 = m2 ? m2->list_len : 0;
+
+ if (len2)
+ {
+ m1 = realloc_stringlist (m1, len1 + len2 + 1);
+ for (i = 0, n = len1; i < len2; i++, n++)
+ m1->list[n] = STRDUP (m2->list[i]);
+ m1->list[n] = (char *)NULL;
+ m1->list_len = n;
+ }
+
+ return m1;
+}
+
+static int
+shouldexp_filterpat (s)
+ char *s;
+{
+ register char *p;
+
+ for (p = s; p && *p; p++)
+ {
+ if (*p == '\\')
+ p++;
+ else if (*p == '&')
+ return 1;
+ }
+ return 0;
+}
+
+/* Replace any instance of `&' in PAT with TEXT. Backslash may be used to
+ quote a `&' and inhibit substitution. Returns a new string. This just
+ calls stringlib.c:strcreplace(). */
+static char *
+preproc_filterpat (pat, text)
+ char *pat;
+ char *text;
+{
+ char *ret;
+
+ ret = strcreplace (pat, '&', text, 1);
+ return ret;
+}
+
+/* Remove any match of FILTERPAT from SL. A `&' in FILTERPAT is replaced by
+ TEXT. A leading `!' in FILTERPAT negates the pattern; in this case
+ any member of SL->list that does *not* match will be removed. This returns
+ a new STRINGLIST with the matching members of SL *copied*. Any
+ non-matching members of SL->list are *freed*. */
+STRINGLIST *
+filter_stringlist (sl, filterpat, text)
+ STRINGLIST *sl;
+ char *filterpat, *text;
+{
+ int i, m, not;
+ STRINGLIST *ret;
+ char *npat, *t;
+
+ if (sl == 0 || sl->list == 0 || sl->list_len == 0)
+ return sl;
+
+ npat = shouldexp_filterpat (filterpat) ? preproc_filterpat (filterpat, text) : filterpat;
+
+ not = (npat[0] == '!');
+ t = not ? npat + 1 : npat;
+
+ ret = alloc_stringlist (sl->list_size);
+ for (i = 0; i < sl->list_len; i++)
+ {
+ m = fnmatch (t, sl->list[i], FNMATCH_EXTFLAG);
+ if ((not && m == FNM_NOMATCH) || (not == 0 && m != FNM_NOMATCH))
+ free (sl->list[i]);
+ else
+ ret->list[ret->list_len++] = sl->list[i];
+ }
+
+ ret->list[ret->list_len] = (char *)NULL;
+ if (npat != filterpat)
+ free (npat);
+
+ return ret;
+}
+
+STRINGLIST *
+prefix_suffix_stringlist (sl, prefix, suffix)
+ STRINGLIST *sl;
+ char *prefix, *suffix;
+{
+ int plen, slen, tlen, llen, i;
+ char *t;
+
+ if (sl == 0 || sl->list == 0 || sl->list_len == 0)
+ return sl;
+
+ plen = STRLEN (prefix);
+ slen = STRLEN (suffix);
+
+ if (plen == 0 && slen == 0)
+ return (sl);
+
+ for (i = 0; i < sl->list_len; i++)
+ {
+ llen = STRLEN (sl->list[i]);
+ tlen = plen + llen + slen + 1;
+ t = xmalloc (tlen + 1);
+ if (plen)
+ strcpy (t, prefix);
+ strcpy (t + plen, sl->list[i]);
+ if (slen)
+ strcpy (t + plen + llen, suffix);
+ free (sl->list[i]);
+ sl->list[i] = t;
+ }
+
+ return (sl);
+}
+
+void
+print_stringlist (sl, prefix)
+ STRINGLIST *sl;
+ char *prefix;
+{
+ register int i;
+
+ if (sl == 0)
+ return;
+ for (i = 0; i < sl->list_len; i++)
+ printf ("%s%s\n", prefix ? prefix : "", sl->list[i]);
+}
+
+/* Turn an array of strings returned by completion_matches into a STRINGLIST.
+ This understands how completion_matches sets matches[0] (the lcd of the
+ strings in the list, unless it's the only match). */
+STRINGLIST *
+completions_to_stringlist (matches)
+ char **matches;
+{
+ STRINGLIST *sl;
+ int mlen, i, n;
+
+ mlen = (matches == 0) ? 0 : array_len (matches);
+ sl = alloc_stringlist (mlen + 1);
+
+ if (matches == 0 || matches[0] == 0)
+ return sl;
+
+ if (matches[1] == 0)
+ {
+ sl->list[0] = STRDUP (matches[0]);
+ sl->list[sl->list_len = 1] = (char *)NULL;
+ return sl;
+ }
+
+ for (i = 1, n = 0; i < mlen; i++, n++)
+ sl->list[n] = STRDUP (matches[i]);
+ sl->list_len = n;
+ sl->list[n] = (char *)NULL;
+
+ return sl;
+}
+
+/* Functions to manage the various ITEMLISTs that we populate internally.
+ The caller is responsible for setting ITP->flags correctly. */
+
+static int
+it_init_aliases (itp)
+ ITEMLIST *itp;
+{
+#ifdef ALIAS
+ alias_t **aliases;
+ register int i, n;
+ STRINGLIST *sl;
+
+ aliases = all_aliases ();
+ if (aliases == 0)
+ {
+ itp->slist = (STRINGLIST *)NULL;
+ return 0;
+ }
+ for (n = 0; aliases[n]; n++)
+ ;
+ sl = alloc_stringlist (n+1);
+ for (i = 0; i < n; i++)
+ sl->list[i] = STRDUP (aliases[i]->name);
+ sl->list[n] = (char *)NULL;
+ sl->list_size = sl->list_len = n;
+ itp->slist = sl;
+#else
+ itp->slist = (STRINGLIST *)NULL;
+#endif
+ return 1;
+}
+
+static void
+init_itemlist_from_varlist (itp, svfunc)
+ ITEMLIST *itp;
+ SVFUNC *svfunc;
+{
+ SHELL_VAR **vlist;
+ STRINGLIST *sl;
+ register int i, n;
+
+ vlist = (*svfunc) ();
+ for (n = 0; vlist[n]; n++)
+ ;
+ sl = alloc_stringlist (n+1);
+ for (i = 0; i < n; i++)
+ sl->list[i] = savestring (vlist[i]->name);
+ sl->list[sl->list_len = n] = (char *)NULL;
+ itp->slist = sl;
+}
+
+static int
+it_init_arrayvars (itp)
+ ITEMLIST *itp;
+{
+#if defined (ARRAY_VARS)
+ init_itemlist_from_varlist (itp, all_array_variables);
+ return 1;
+#else
+ return 0;
+#endif
+}
+
+static int
+it_init_bindings (itp)
+ ITEMLIST *itp;
+{
+ char **blist;
+ STRINGLIST *sl;
+
+ /* rl_funmap_names allocates blist, but not its members */
+ blist = rl_funmap_names ();
+ sl = alloc_stringlist (0);
+ sl->list = blist;
+ sl->list_size = 0;
+ sl->list_len = array_len (sl->list);
+ itp->flags |= LIST_DONTFREEMEMBERS;
+ itp->slist = sl;
+
+ return 0;
+}
+
+static int
+it_init_builtins (itp)
+ ITEMLIST *itp;
+{
+ STRINGLIST *sl;
+ char **list;
+ register int i, n;
+
+ sl = alloc_stringlist (num_shell_builtins);
+ for (i = n = 0; i < num_shell_builtins; i++)
+ if (shell_builtins[i].function)
+ sl->list[n++] = shell_builtins[i].name;
+ sl->list[sl->list_len = n] = (char *)NULL;
+ itp->flags |= LIST_DONTFREEMEMBERS;
+ itp->slist = sl;
+ return 0;
+}
+
+static int
+it_init_enabled (itp)
+ ITEMLIST *itp;
+{
+ STRINGLIST *sl;
+ char **list;
+ register int i, n;
+
+ sl = alloc_stringlist (num_shell_builtins);
+ for (i = n = 0; i < num_shell_builtins; i++)
+ {
+ if (shell_builtins[i].function && (shell_builtins[i].flags & BUILTIN_ENABLED))
+ sl->list[n++] = shell_builtins[i].name;
+ }
+ sl->list[sl->list_len = n] = (char *)NULL;
+ itp->flags |= LIST_DONTFREEMEMBERS;
+ itp->slist = sl;
+ return 0;
+}
+
+static int
+it_init_disabled (itp)
+ ITEMLIST *itp;
+{
+ STRINGLIST *sl;
+ char **list;
+ register int i, n;
+
+ sl = alloc_stringlist (num_shell_builtins);
+ for (i = n = 0; i < num_shell_builtins; i++)
+ {
+ if (shell_builtins[i].function && ((shell_builtins[i].flags & BUILTIN_ENABLED) == 0))
+ sl->list[n++] = shell_builtins[i].name;
+ }
+ sl->list[sl->list_len = n] = (char *)NULL;
+ itp->flags |= LIST_DONTFREEMEMBERS;
+ itp->slist = sl;
+ return 0;
+}
+
+static int
+it_init_exported (itp)
+ ITEMLIST *itp;
+{
+ init_itemlist_from_varlist (itp, all_exported_variables);
+ return 0;
+}
+
+static int
+it_init_functions (itp)
+ ITEMLIST *itp;
+{
+ init_itemlist_from_varlist (itp, all_visible_functions);
+ return 0;
+}
+
+static int
+it_init_hostnames (itp)
+ ITEMLIST *itp;
+{
+ STRINGLIST *sl;
+
+ sl = alloc_stringlist (0);
+ sl->list = get_hostname_list ();
+ sl->list_len = sl->list ? array_len (sl->list) : 0;
+ sl->list_size = sl->list_len;
+ itp->slist = sl;
+ itp->flags |= LIST_DONTFREEMEMBERS|LIST_DONTFREE;
+ return 0;
+}
+
+static int
+it_init_joblist (itp, jstate)
+ ITEMLIST *itp;
+ int jstate;
+{
+#if defined (JOB_CONTROL)
+ STRINGLIST *sl;
+ register int i, n;
+ register PROCESS *p;
+ char *s, *t;
+ JOB_STATE js;
+
+ if (jstate == 0)
+ js = JRUNNING;
+ else if (jstate == 1)
+ js = JSTOPPED;
+
+ sl = alloc_stringlist (job_slots);
+ for (i = job_slots - 1; i >= 0; i--)
+ {
+ if (jobs[i] == 0)
+ continue;
+ p = jobs[i]->pipe;
+ if (jstate == -1 || JOBSTATE(i) == js)
+ {
+ s = savestring (p->command);
+ t = strpbrk (s, " \t\n");
+ if (t)
+ *t = '\0';
+ sl->list[sl->list_len++] = s;
+ }
+ }
+ itp->slist = sl;
+#else
+ itp->slist = (STRINGLIST *)NULL;
+#endif
+ return 0;
+}
+
+static int
+it_init_jobs (itp)
+ ITEMLIST *itp;
+{
+ return (it_init_joblist (itp, -1));
+}
+
+static int
+it_init_running (itp)
+ ITEMLIST *itp;
+{
+ return (it_init_joblist (itp, 0));
+}
+
+static int
+it_init_stopped (itp)
+ ITEMLIST *itp;
+{
+ return (it_init_joblist (itp, 1));
+}
+
+static int
+it_init_keywords (itp)
+ ITEMLIST *itp;
+{
+ STRINGLIST *sl;
+ register int i, n;
+
+ for (n = 0; word_token_alist[n].word; n++)
+ ;
+ sl = alloc_stringlist (n);
+ for (i = 0; i < n; i++)
+ sl->list[i] = word_token_alist[i].word;
+ sl->list[sl->list_len = i] = (char *)NULL;
+ itp->flags |= LIST_DONTFREEMEMBERS;
+ itp->slist = sl;
+ return 0;
+}
+
+static int
+it_init_signals (itp)
+ ITEMLIST *itp;
+{
+ STRINGLIST *sl;
+
+ sl = alloc_stringlist (0);
+ sl->list = signal_names;
+ sl->list_len = array_len (sl->list);
+ itp->flags |= LIST_DONTFREE;
+ itp->slist = sl;
+ return 0;
+}
+
+static int
+it_init_variables (itp)
+ ITEMLIST *itp;
+{
+ init_itemlist_from_varlist (itp, all_visible_variables);
+ return 0;
+}
+
+static int
+it_init_setopts (itp)
+ ITEMLIST *itp;
+{
+ STRINGLIST *sl;
+
+ sl = alloc_stringlist (0);
+ sl->list = get_minus_o_opts ();
+ sl->list_len = array_len (sl->list);
+ itp->slist = sl;
+ itp->flags |= LIST_DONTFREEMEMBERS;
+ return 0;
+}
+
+static int
+it_init_shopts (itp)
+ ITEMLIST *itp;
+{
+ STRINGLIST *sl;
+
+ sl = alloc_stringlist (0);
+ sl->list = get_shopt_options ();
+ sl->list_len = array_len (sl->list);
+ itp->slist = sl;
+ itp->flags |= LIST_DONTFREEMEMBERS;
+ return 0;
+}
+
+/* Generate a list of all matches for TEXT using the STRINGLIST in itp->slist
+ as the list of possibilities. If the itemlist has been marked dirty or
+ it should be regenerated every time, destroy the old STRINGLIST and make a
+ new one before trying the match. */
+static STRINGLIST *
+gen_matches_from_itemlist (itp, text)
+ ITEMLIST *itp;
+ char *text;
+{
+ STRINGLIST *ret, *sl;
+ int tlen, i, n;
+
+ if ((itp->flags & (LIST_DIRTY|LIST_DYNAMIC)) ||
+ (itp->flags & LIST_INITIALIZED) == 0)
+ {
+ if (itp->flags & (LIST_DIRTY | LIST_DYNAMIC))
+ clean_itemlist (itp);
+ if ((itp->flags & LIST_INITIALIZED) == 0)
+ initialize_itemlist (itp);
+ }
+ ret = alloc_stringlist (itp->slist->list_len+1);
+ sl = itp->slist;
+ tlen = STRLEN (text);
+ for (i = n = 0; i < sl->list_len; i++)
+ {
+ if (tlen == 0 || STREQN (sl->list[i], text, tlen))
+ ret->list[n++] = STRDUP (sl->list[i]);
+ }
+ ret->list[ret->list_len = n] = (char *)NULL;
+ return ret;
+}
+
+/* A wrapper for filename_completion_function that dequotes the filename
+ before attempting completions. */
+static char *
+pcomp_filename_completion_function (text, state)
+ char *text;
+ int state;
+{
+ static char *dfn; /* dequoted filename */
+ int qc;
+
+ if (state == 0)
+ {
+ FREE (dfn);
+ /* remove backslashes quoting special characters in filenames. */
+ if (rl_filename_dequoting_function)
+ {
+ qc = (text[0] == '"' || text[0] == '\'') ? text[0] : 0;
+ dfn = (*rl_filename_dequoting_function) (text, qc);
+ }
+ else
+ dfn = savestring (text);
+ }
+
+ return (filename_completion_function (dfn, state));
+}
+
+#define GEN_COMPS(bmap, flag, it, text, glist, tlist) \
+ do { \
+ if (bmap & flag) \
+ { \
+ tlist = gen_matches_from_itemlist (it, text); \
+ glist = append_stringlist (glist, tlist); \
+ free_stringlist (tlist); \
+ } \
+ } while (0)
+
+#define GEN_XCOMPS(bmap, flag, text, func, cmatches, glist, tlist) \
+ do { \
+ if (bmap & flag) \
+ { \
+ cmatches = completion_matches (text, func); \
+ tlist = completions_to_stringlist (cmatches); \
+ glist = append_stringlist (glist, tlist); \
+ free_array (cmatches); \
+ free_stringlist (tlist); \
+ } \
+ } while (0)
+
+/* Functions to generate lists of matches from the actions member of CS. */
+
+static STRINGLIST *
+gen_action_completions (cs, text)
+ COMPSPEC *cs;
+ char *text;
+{
+ STRINGLIST *ret, *tmatches;
+ char **cmatches; /* from completion_matches ... */
+ unsigned long flags;
+
+ ret = tmatches = (STRINGLIST *)NULL;
+ flags = cs->actions;
+
+ GEN_COMPS (flags, CA_ALIAS, &it_aliases, text, ret, tmatches);
+ GEN_COMPS (flags, CA_ARRAYVAR, &it_arrayvars, text, ret, tmatches);
+ GEN_COMPS (flags, CA_BINDING, &it_bindings, text, ret, tmatches);
+ GEN_COMPS (flags, CA_BUILTIN, &it_builtins, text, ret, tmatches);
+ GEN_COMPS (flags, CA_DISABLED, &it_disabled, text, ret, tmatches);
+ GEN_COMPS (flags, CA_ENABLED, &it_enabled, text, ret, tmatches);
+ GEN_COMPS (flags, CA_EXPORT, &it_exports, text, ret, tmatches);
+ GEN_COMPS (flags, CA_FUNCTION, &it_functions, text, ret, tmatches);
+ GEN_COMPS (flags, CA_HOSTNAME, &it_hostnames, text, ret, tmatches);
+ GEN_COMPS (flags, CA_JOB, &it_jobs, text, ret, tmatches);
+ GEN_COMPS (flags, CA_KEYWORD, &it_keywords, text, ret, tmatches);
+ GEN_COMPS (flags, CA_RUNNING, &it_running, text, ret, tmatches);
+ GEN_COMPS (flags, CA_SETOPT, &it_setopts, text, ret, tmatches);
+ GEN_COMPS (flags, CA_SHOPT, &it_shopts, text, ret, tmatches);
+ GEN_COMPS (flags, CA_SIGNAL, &it_signals, text, ret, tmatches);
+ GEN_COMPS (flags, CA_STOPPED, &it_stopped, text, ret, tmatches);
+ GEN_COMPS (flags, CA_VARIABLE, &it_variables, text, ret, tmatches);
+
+ GEN_XCOMPS(flags, CA_COMMAND, text, command_word_completion_function, cmatches, ret, tmatches);
+ GEN_XCOMPS(flags, CA_FILE, text, pcomp_filename_completion_function, cmatches, ret, tmatches);
+ GEN_XCOMPS(flags, CA_USER, text, username_completion_function, cmatches, ret, tmatches);
+
+ /* And lastly, the special case for directories */
+ if (flags & CA_DIRECTORY)
+ {
+ cmatches = bash_directory_completion_matches (text);
+ tmatches = completions_to_stringlist (cmatches);
+ ret = append_stringlist (ret, tmatches);
+ free_array (cmatches);
+ free_stringlist (tmatches);
+ }
+
+ return ret;
+}
+
+/* Generate a list of matches for CS->globpat. Unresolved: should this use
+ TEXT as a match prefix, or just go without? Currently, the code does not
+ use TEXT, just globs CS->globpat and returns the results. If we do decide
+ to use TEXT, we should call quote_string_for_globbing before the call to
+ glob_filename. */
+static STRINGLIST *
+gen_globpat_matches (cs, text)
+ COMPSPEC *cs;
+ char *text;
+{
+ STRINGLIST *sl;
+ char *t;
+
+ sl = alloc_stringlist (0);
+ sl->list = glob_filename (cs->globpat);
+ if (GLOB_FAILED (sl->list))
+ sl->list = (char **)NULL;
+ if (sl->list)
+ sl->list_len = sl->list_size = array_len (sl->list);
+ return sl;
+}
+
+/* Perform the shell word expansions on CS->words and return the results.
+ Again, this ignores TEXT. */
+static STRINGLIST *
+gen_wordlist_matches (cs, text)
+ COMPSPEC *cs;
+ char *text;
+{
+ WORD_LIST *l, *l2;
+ STRINGLIST *sl;
+ int nw, tlen;
+
+ if (cs->words == 0 || cs->words[0] == '\0')
+ return ((STRINGLIST *)NULL);
+
+ /* This used to be a simple expand_string(cs->words, 0), but that won't
+ do -- there's no way to split a simple list into individual words
+ that way, since the shell semantics say that word splitting is done
+ only on the results of expansion. */
+ l = split_at_delims (cs->words, strlen (cs->words), (char *)NULL, -1, (int *)NULL, (int *)NULL);
+ if (l == 0)
+ return ((STRINGLIST *)NULL);
+ /* This will jump back to the top level if the expansion fails... */
+ l2 = expand_words_shellexp (l);
+ dispose_words (l);
+
+ nw = list_length (l2);
+ sl = alloc_stringlist (nw + 1);
+ tlen = STRLEN (text);
+
+ for (nw = 0, l = l2; l; l = l->next)
+ {
+ if (tlen == 0 || STREQN (l->word->word, text, tlen))
+ sl->list[nw++] = STRDUP (l->word->word);
+ }
+ sl->list[sl->list_len = nw] = (char *)NULL;
+
+ return sl;
+}
+
+#ifdef ARRAY_VARS
+
+static SHELL_VAR *
+bind_comp_words (lwords)
+ WORD_LIST *lwords;
+{
+ SHELL_VAR *v;
+
+ v = find_variable ("COMP_WORDS");
+ if (v == 0)
+ v = make_new_array_variable ("COMP_WORDS");
+ if (readonly_p (v))
+ VUNSETATTR (v, att_readonly);
+ if (array_p (v) == 0)
+ v = convert_var_to_array (v);
+ v = assign_array_var_from_word_list (v, lwords);
+ return v;
+}
+#endif /* ARRAY_VARS */
+
+static void
+bind_compfunc_variables (line, ind, lwords, cw, exported)
+ char *line;
+ int ind;
+ WORD_LIST *lwords;
+ int cw, exported;
+{
+ char ibuf[32];
+ char *value;
+ SHELL_VAR *v;
+
+ /* Set the variables that the function expects while it executes. Maybe
+ these should be in the function environment (temporary_env). */
+ v = bind_variable ("COMP_LINE", line);
+ if (v && exported)
+ VSETATTR(v, att_exported);
+
+ value = inttostr (ind, ibuf, 32);
+ v = bind_int_variable ("COMP_POINT", value);
+ if (v && exported)
+ VSETATTR(v, att_exported);
+
+ /* Since array variables can't be exported, we don't bother making the
+ array of words. */
+ if (exported == 0)
+ {
+#ifdef ARRAY_VARS
+ v = bind_comp_words (lwords);
+ value = inttostr (cw, ibuf, 32);
+ bind_int_variable ("COMP_CWORD", value);
+#endif
+ }
+ else
+ array_needs_making = 1;
+}
+
+static void
+unbind_compfunc_variables (exported)
+ int exported;
+{
+ makunbound ("COMP_LINE", shell_variables);
+ makunbound ("COMP_POINT", shell_variables);
+#ifdef ARRAY_VARS
+ makunbound ("COMP_WORDS", shell_variables);
+ makunbound ("COMP_CWORD", shell_variables);
+#endif
+ if (exported)
+ array_needs_making = 1;
+}
+
+/* Build the list of words to pass to a function or external command
+ as arguments. When the function or command is invoked,
+
+ $0 == function or command being invoked
+ $1 == command name
+ $2 = word to be completed (possibly null)
+ $3 = previous word
+
+ Functions can access all of the words in the current command line
+ with the COMP_WORDS array. External commands cannot. */
+
+static WORD_LIST *
+build_arg_list (cmd, text, lwords, ind)
+ char *cmd;
+ char *text;
+ WORD_LIST *lwords;
+ int ind;
+{
+ WORD_LIST *ret, *cl, *l;
+ WORD_DESC *w;
+ int i;
+
+ ret = (WORD_LIST *)NULL;
+ w = make_word (cmd);
+ ret = make_word_list (w, (WORD_LIST *)NULL);
+
+ w = (lwords && lwords->word) ? copy_word (lwords->word) : make_word ("");
+ cl = ret->next = make_word_list (w, (WORD_LIST *)NULL);
+
+ w = make_word (text);
+ cl->next = make_word_list (w, (WORD_LIST *)NULL);
+ cl = cl->next;
+
+ /* Search lwords for current word */
+ for (l = lwords, i = 1; l && i < ind-1; l = l->next, i++)
+ ;
+ w = (l && l->word) ? copy_word (l->word) : make_word ("");
+ cl->next = make_word_list (w, (WORD_LIST *)NULL);
+
+ return ret;
+}
+
+/* Build a command string with
+ $0 == cs->funcname (function to execute for completion list)
+ $1 == command name (command being completed)
+ $2 = word to be completed (possibly null)
+ $3 = previous word
+ and run in the current shell. The function should put its completion
+ list into the array variable COMPREPLY. We build a STRINGLIST
+ from the results and return it.
+
+ Since the shell function should return its list of matches in an array
+ variable, this does nothing if arrays are not compiled into the shell. */
+
+static STRINGLIST *
+gen_shell_function_matches (cs, text, line, ind, lwords, nw, cw)
+ COMPSPEC *cs;
+ char *text, *line;
+ int ind;
+ WORD_LIST *lwords;
+ int nw, cw;
+{
+ char *funcname;
+ STRINGLIST *sl;
+ SHELL_VAR *f, *v;
+ WORD_LIST *cmdlist;
+ int fval;
+#if defined (ARRAY_VARS)
+ ARRAY *a;
+#endif
+
+ funcname = cs->funcname;
+ f = find_function (funcname);
+ if (f == 0)
+ {
+ fprintf (stderr, "gen_shell_function_matches: function `%s' not found\n", funcname);
+ ding ();
+ rl_on_new_line ();
+ return ((STRINGLIST *)NULL);
+ }
+
+#if !defined (ARRAY_VARS)
+ return ((STRINGLIST *)NULL);
+#else
+
+ /* We pass cw - 1 because command_line_to_word_list returns indices that are
+ 1-based, while bash arrays are 0-based. */
+ bind_compfunc_variables (line, ind, lwords, cw - 1, 0);
+
+ cmdlist = build_arg_list (funcname, text, lwords, cw);
+
+ fval = execute_shell_function (f, cmdlist);
+
+ /* Now clean up and destroy everything. */
+ dispose_words (cmdlist);
+ unbind_compfunc_variables (0);
+
+ /* The list of completions is returned in the array variable COMPREPLY. */
+ v = find_variable ("COMPREPLY");
+ if (v == 0)
+ return ((STRINGLIST *)NULL);
+ if (array_p (v) == 0)
+ v = convert_var_to_array (v);
+
+ a = array_cell (v);
+ if (a == 0 || array_empty (a))
+ sl = (STRINGLIST *)NULL;
+ else
+ {
+ /* XXX - should we filter the list of completions so only those matching
+ TEXT are returned? Right now, we do not. */
+ sl = alloc_stringlist (0);
+ sl->list = array_to_argv (a);
+ sl->list_len = sl->list_size = array_num_elements (a);
+ }
+
+ /* XXX - should we unbind COMPREPLY here? */
+ makunbound ("COMPREPLY", shell_variables);
+
+ return (sl);
+#endif
+}
+
+/* Build a command string with
+ $0 == cs->command (command to execute for completion list)
+ $1 == command name (command being completed)
+ $2 = word to be completed (possibly null)
+ $3 = previous word
+ and run in with command substitution. Parse the results, one word
+ per line, with backslashes allowed to escape newlines. Build a
+ STRINGLIST from the results and return it. */
+
+static STRINGLIST *
+gen_command_matches (cs, text, line, ind, lwords, nw, cw)
+ COMPSPEC *cs;
+ char *text, *line;
+ int ind;
+ WORD_LIST *lwords;
+ int nw, cw;
+{
+ char *csbuf, *cscmd, *t;
+ int cmdlen, cmdsize, n, ws, we;
+ WORD_LIST *cmdlist, *cl;
+ STRINGLIST *sl;
+
+ bind_compfunc_variables (line, ind, lwords, cw, 1);
+ cmdlist = build_arg_list (cs->command, text, lwords, cw);
+
+ /* Estimate the size needed for the buffer. */
+ n = strlen (cs->command);
+ cmdsize = n + 1;
+ for (cl = cmdlist->next; cl; cl = cl->next)
+ cmdsize += STRLEN (cl->word->word) + 3;
+ cmdsize += 2;
+
+ /* allocate the string for the command and fill it in. */
+ cscmd = xmalloc (cmdsize + 1);
+
+ strcpy (cscmd, cs->command); /* $0 */
+ cmdlen = n;
+ cscmd[cmdlen++] = ' ';
+ for (cl = cmdlist->next; cl; cl = cl->next) /* $1, $2, $3, ... */
+ {
+ t = single_quote (cl->word->word ? cl->word->word : "");
+ n = strlen (t);
+ RESIZE_MALLOCED_BUFFER (cscmd, cmdlen, n + 2, cmdsize, 64);
+ strcpy (cscmd + cmdlen, t);
+ cmdlen += n;
+ if (cl->next)
+ cscmd[cmdlen++] = ' ';
+ free (t);
+ }
+ cscmd[cmdlen] = '\0';
+
+ csbuf = command_substitute (cscmd, 0);
+
+ /* Now clean up and destroy everything. */
+ dispose_words (cmdlist);
+ free (cscmd);
+ unbind_compfunc_variables (1);
+
+ if (csbuf == 0 || *csbuf == '\0')
+ {
+ FREE (csbuf);
+ return ((STRINGLIST *)NULL);
+ }
+
+ /* Now break CSBUF up at newlines, with backslash allowed to escape a
+ newline, and put the individual words into a STRINGLIST. */
+ sl = alloc_stringlist (16);
+ for (ws = 0; csbuf[ws]; )
+ {
+ we = ws;
+ while (csbuf[we] && csbuf[we] != '\n')
+ {
+ if (csbuf[we] == '\\' && csbuf[we+1] == '\n')
+ we++;
+ we++;
+ }
+ t = substring (csbuf, ws, we);
+ if (sl->list_len >= sl->list_size - 1)
+ realloc_stringlist (sl, sl->list_size + 16);
+ sl->list[sl->list_len++] = t;
+ while (csbuf[we] == '\n') we++;
+ ws = we;
+ }
+ sl->list[sl->list_len] = (char *)NULL;
+
+ free (csbuf);
+ return (sl);
+}
+
+static WORD_LIST *
+command_line_to_word_list (line, llen, sentinel, nwp, cwp)
+ char *line;
+ int llen, sentinel, *nwp, *cwp;
+{
+ WORD_LIST *ret;
+ char *delims;
+
+ delims = "()<>;&| \t\n"; /* shell metacharacters break words */
+ ret = split_at_delims (line, llen, delims, sentinel, nwp, cwp);
+ return (ret);
+}
+
+/* Evaluate COMPSPEC *cs and return all matches for WORD. */
+
+STRINGLIST *
+gen_compspec_completions (cs, cmd, word, start, end)
+ COMPSPEC *cs;
+ char *cmd;
+ char *word;
+ int start, end;
+{
+ STRINGLIST *ret, *tmatches;
+ char *line, *lword;
+ int llen, nw, cw;
+ WORD_LIST *lwords;
+
+ debug_printf ("programmable_completions (%s, %s, %d, %d)", cmd, word, start, end);
+ debug_printf ("programmable_completions: %s -> 0x%x", cmd, (int)cs);
+ ret = gen_action_completions (cs, word);
+ if (ret && progcomp_debug)
+ {
+ debug_printf ("gen_action_completions (0x%x, %s) -->", (int)cs, word);
+ print_stringlist (ret, "\t");
+ rl_on_new_line ();
+ }
+
+ /* Now we start generating completions based on the other members of CS. */
+ if (cs->globpat)
+ {
+ tmatches = gen_globpat_matches (cs, word);
+ if (tmatches)
+ {
+ if (progcomp_debug)
+ {
+ debug_printf ("gen_globpat_matches (0x%x, %s) -->", (int)cs, word);
+ print_stringlist (tmatches, "\t");
+ rl_on_new_line ();
+ }
+ ret = append_stringlist (ret, tmatches);
+ free_stringlist (tmatches);
+ rl_filename_completion_desired = 1;
+ }
+ }
+
+ if (cs->words)
+ {
+ tmatches = gen_wordlist_matches (cs, word);
+ if (tmatches)
+ {
+ if (progcomp_debug)
+ {
+ debug_printf ("gen_wordlist_matches (0x%x, %s) -->", (int)cs, word);
+ print_stringlist (tmatches, "\t");
+ rl_on_new_line ();
+ }
+ ret = append_stringlist (ret, tmatches);
+ free_stringlist (tmatches);
+ }
+ }
+
+ lwords = (WORD_LIST *)NULL;
+ line = (char *)NULL;
+ if (cs->command || cs->funcname)
+ {
+ /* If we have a command or function to execute, we need to first break
+ the command line into individual words, find the number of words,
+ and find the word in the list containing the word to be completed. */
+ line = substring (rl_line_buffer, start, end);
+ llen = end - start;
+
+ debug_printf ("command_line_to_word_list (%s, %d, %d, 0x%x, 0x%x)",
+ line, llen, rl_point - start, &nw, &cw);
+ lwords = command_line_to_word_list (line, llen, rl_point - start, &nw, &cw);
+ if (lwords == 0 && llen > 0)
+ debug_printf ("ERROR: command_line_to_word_list returns NULL");
+ else if (progcomp_debug)
+ {
+ debug_printf ("command_line_to_word_list -->");
+ printf ("\t");
+ print_word_list (lwords, "!");
+ printf ("\n");
+ fflush(stdout);
+ rl_on_new_line ();
+ }
+ }
+
+ if (cs->funcname)
+ {
+ tmatches = gen_shell_function_matches (cs, word, line, rl_point - start, lwords, nw, cw);
+ if (tmatches)
+ {
+ if (progcomp_debug)
+ {
+ debug_printf ("gen_shell_function_matches (0x%x, %s, 0x%x, %d, %d) -->", (int)cs, word, lwords, nw, cw);
+ print_stringlist (tmatches, "\t");
+ rl_on_new_line ();
+ }
+ ret = append_stringlist (ret, tmatches);
+ free_stringlist (tmatches);
+ }
+ }
+
+ if (cs->command)
+ {
+ tmatches = gen_command_matches (cs, word, line, rl_point - start, lwords, nw, cw);
+ if (tmatches)
+ {
+ if (progcomp_debug)
+ {
+ debug_printf ("gen_command_matches (0x%x, %s, 0x%x, %d, %d) -->", (int)cs, word, lwords, nw, cw);
+ print_stringlist (tmatches, "\t");
+ rl_on_new_line ();
+ }
+ ret = append_stringlist (ret, tmatches);
+ free_stringlist (tmatches);
+ }
+ }
+
+ if (cs->command || cs->funcname)
+ {
+ if (lwords)
+ dispose_words (lwords);
+ FREE (line);
+ }
+
+ if (cs->filterpat)
+ {
+ tmatches = filter_stringlist (ret, cs->filterpat, word);
+ if (progcomp_debug)
+ {
+ debug_printf ("filter_stringlist (0x%x, %s, %s) -->", ret, cs->filterpat, word);
+ print_stringlist (tmatches, "\t");
+ rl_on_new_line ();
+ }
+ if (ret && ret != tmatches)
+ {
+ FREE (ret->list);
+ free (ret);
+ }
+ ret = tmatches;
+ }
+
+ if (cs->prefix || cs->suffix)
+ ret = prefix_suffix_stringlist (ret, cs->prefix, cs->suffix);
+
+ return (ret);
+}
+
+/* The driver function for the programmable completion code. Returns a list
+ of matches for WORD, which is an argument to command CMD. START and END
+ bound the command currently being completed in rl_line_buffer. */
+char **
+programmable_completions (cmd, word, start, end, foundp)
+ char *cmd, *word;
+ int start, end, *foundp;
+{
+ COMPSPEC *cs;
+ STRINGLIST *ret;
+ char **rmatches, *t;
+
+ /* We look at the basename of CMD if the full command does not have
+ an associated COMPSPEC. */
+ cs = find_compspec (cmd);
+ if (cs == 0)
+ {
+ t = strrchr (cmd, '/');
+ if (t)
+ cs = find_compspec (++t);
+ }
+ if (cs == 0)
+ {
+ if (foundp)
+ *foundp = 0;
+ return ((char **)NULL);
+ }
+
+ /* Signal the caller that we found a COMPSPEC for this command. */
+ if (foundp)
+ *foundp = 1;
+
+ ret = gen_compspec_completions (cs, cmd, word, start, end);
+
+ if (ret)
+ {
+ rmatches = ret->list;
+ free (ret);
+ }
+ else
+ rmatches = (char **)NULL;
+
+ return (rmatches);
+}
+
+#endif /* PROGRAMMABLE_COMPLETION */
diff --git a/pcomplete.h b/pcomplete.h
new file mode 100644
index 00000000..607b5d03
--- /dev/null
+++ b/pcomplete.h
@@ -0,0 +1,146 @@
+/* pcomplete.h - structure definitions and other stuff for programmable
+ completion. */
+
+/* Copyright (C) 1999 Free Software Foundation, Inc.
+
+ This file is part of GNU Bash, the Bourne Again SHell.
+
+ Bash is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free
+ Software Foundation; either version 2, or (at your option) any later
+ version.
+
+ Bash is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with Bash; see the file COPYING. If not, write to the Free Software
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+
+#if !defined (_PCOMPLETE_H_)
+# define _PCOMPLETE_H_
+
+#include "stdc.h"
+#include "hashlib.h"
+
+typedef struct compspec {
+ int refcount;
+ unsigned long actions;
+ char *globpat;
+ char *words;
+ char *prefix;
+ char *suffix;
+ char *funcname;
+ char *command;
+ char *filterpat;
+} COMPSPEC;
+
+/* Values for COMPSPEC actions. These are things the shell knows how to
+ build internally. */
+#define CA_ALIAS (1<<0)
+#define CA_ARRAYVAR (1<<1)
+#define CA_BINDING (1<<2)
+#define CA_BUILTIN (1<<3)
+#define CA_COMMAND (1<<4)
+#define CA_DIRECTORY (1<<5)
+#define CA_DISABLED (1<<6)
+#define CA_ENABLED (1<<7)
+#define CA_EXPORT (1<<8)
+#define CA_FILE (1<<9)
+#define CA_FUNCTION (1<<10)
+#define CA_HELPTOPIC (1<<11)
+#define CA_HOSTNAME (1<<12)
+#define CA_JOB (1<<13)
+#define CA_KEYWORD (1<<14)
+#define CA_RUNNING (1<<15)
+#define CA_SETOPT (1<<16)
+#define CA_SHOPT (1<<17)
+#define CA_SIGNAL (1<<18)
+#define CA_STOPPED (1<<19)
+#define CA_USER (1<<20)
+#define CA_VARIABLE (1<<21)
+
+/* This is a general-purpose argv-style array struct that should be used
+ elsewhere. */
+typedef struct _list_of_strings {
+ char **list;
+ int list_size;
+ int list_len;
+} STRINGLIST;
+
+/* List of items is used by the code that implements the programmable
+ completions. */
+typedef struct _list_of_items {
+ int flags;
+ Function *list_getter; /* function to call to get the list */
+
+ STRINGLIST *slist;
+
+ /* These may or may not be used. */
+ STRINGLIST *genlist; /* for handing to the completion code one item at a time */
+ int genindex; /* index of item last handed to completion code */
+
+} ITEMLIST;
+
+/* Values for ITEMLIST -> flags */
+#define LIST_DYNAMIC 0x001
+#define LIST_DIRTY 0x002
+#define LIST_INITIALIZED 0x004
+#define LIST_MUSTSORT 0x008
+#define LIST_DONTFREE 0x010
+#define LIST_DONTFREEMEMBERS 0x020
+
+extern HASH_TABLE *prog_completes;
+extern int prog_completion_enabled;
+
+/* Not all of these are used yet. */
+extern ITEMLIST it_aliases;
+extern ITEMLIST it_arrayvars;
+extern ITEMLIST it_bindings;
+extern ITEMLIST it_builtins;
+extern ITEMLIST it_commands;
+extern ITEMLIST it_directories;
+extern ITEMLIST it_disabled;
+extern ITEMLIST it_enabled;
+extern ITEMLIST it_exports;
+extern ITEMLIST it_files;
+extern ITEMLIST it_functions;
+extern ITEMLIST it_hostnames;
+extern ITEMLIST it_jobs;
+extern ITEMLIST it_keywords;
+extern ITEMLIST it_running;
+extern ITEMLIST it_setopts;
+extern ITEMLIST it_shopts;
+extern ITEMLIST it_signals;
+extern ITEMLIST it_stopped;
+extern ITEMLIST it_users;
+extern ITEMLIST it_variables;
+
+/* Functions from pcomplib.c */
+
+extern COMPSPEC *alloc_compspec __P((void));
+extern void free_compspec __P((COMPSPEC *));
+
+extern COMPSPEC *copy_compspec __P((COMPSPEC *));
+
+extern void initialize_progcomp __P((void));
+extern void clear_progcomps __P((void));
+
+extern int remove_progcomp __P((char *));
+extern int add_progcomp __P((char *, COMPSPEC *));
+
+extern int num_progcomps __P((void));
+
+extern COMPSPEC *find_compspec __P((char *));
+
+extern void print_all_compspecs __P((VFunction *));
+
+/* Functions from pcomplete.c */
+extern void set_itemlist_dirty __P((ITEMLIST *));
+
+extern STRINGLIST *gen_compspec_completions __P((COMPSPEC *, char *, char *, int, int));
+extern char **programmable_completions __P((char *, char *, int, int, int *));
+
+#endif /* _PCOMPLETE_H_ */
diff --git a/pcomplib.c b/pcomplib.c
new file mode 100644
index 00000000..133c6f40
--- /dev/null
+++ b/pcomplib.c
@@ -0,0 +1,231 @@
+/* pcomplib.c - library functions for programmable completion. */
+
+/* Copyright (C) 1999 Free Software Foundation, Inc.
+
+ This file is part of GNU Bash, the Bourne Again SHell.
+
+ Bash is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free
+ Software Foundation; either version 2, or (at your option) any later
+ version.
+
+ Bash is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with Bash; see the file COPYING. If not, write to the Free Software
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+
+#include <config.h>
+
+#if defined (PROGRAMMABLE_COMPLETION)
+
+#include "bashansi.h"
+#include <stdio.h>
+
+#if defined (HAVE_UNISTD_H)
+# ifdef _MINIX
+# include <sys/types.h>
+# endif
+# include <unistd.h>
+#endif
+
+#include "shell.h"
+#include "pcomplete.h"
+
+#define COMPLETE_HASH_BUCKETS 29 /* for testing */
+
+#define STRDUP(x) ((x) ? savestring (x) : (char *)NULL)
+
+HASH_TABLE *prog_completes = (HASH_TABLE *)NULL;
+
+static int progcomp_initialized = 0;
+
+COMPSPEC *
+alloc_compspec ()
+{
+ COMPSPEC *ret;
+
+ ret = (COMPSPEC *)xmalloc (sizeof (COMPSPEC));
+ ret->refcount = 0;
+
+ ret->actions = (unsigned long)0;
+
+ ret->globpat = (char *)NULL;
+ ret->words = (char *)NULL;
+ ret->prefix = (char *)NULL;
+ ret->suffix = (char *)NULL;
+ ret->funcname = (char *)NULL;
+ ret->command = (char *)NULL;
+ ret->filterpat = (char *)NULL;
+
+ return ret;
+}
+
+void
+free_compspec (cs)
+ COMPSPEC *cs;
+{
+ cs->refcount--;
+ if (cs->refcount == 0)
+ {
+ FREE (cs->globpat);
+ FREE (cs->words);
+ FREE (cs->prefix);
+ FREE (cs->suffix);
+ FREE (cs->funcname);
+ FREE (cs->command);
+ FREE (cs->filterpat);
+
+ free (cs);
+ }
+}
+
+COMPSPEC *
+copy_compspec (cs)
+ COMPSPEC *cs;
+{
+ COMPSPEC *new;
+
+ new = (COMPSPEC *)xmalloc (sizeof (COMPSPEC));
+
+ new->refcount = cs->refcount;
+ new->actions = cs->actions;
+
+ new->globpat = STRDUP (cs->globpat);
+ new->words = STRDUP (cs->words);
+ new->prefix = STRDUP (cs->prefix);
+ new->suffix = STRDUP (cs->suffix);
+ new->funcname = STRDUP (cs->funcname);
+ new->command = STRDUP (cs->command);
+ new->filterpat = STRDUP (cs->filterpat);
+
+ return new;
+}
+
+void
+initialize_progcomp ()
+{
+ if (progcomp_initialized == 0)
+ {
+ prog_completes = make_hash_table (COMPLETE_HASH_BUCKETS);
+ progcomp_initialized = 1;
+ }
+}
+
+int
+num_progcomps ()
+{
+ if (progcomp_initialized == 0 || prog_completes == 0)
+ return (0);
+ return (prog_completes->nentries);
+}
+
+static void
+free_progcomp (data)
+ char *data;
+{
+ COMPSPEC *cs;
+
+ cs = (COMPSPEC *)data;
+ free_compspec (cs);
+}
+
+void
+clear_progcomps ()
+{
+ if (prog_completes)
+ flush_hash_table (prog_completes, free_progcomp);
+}
+
+int
+remove_progcomp (cmd)
+ char *cmd;
+{
+ register BUCKET_CONTENTS *item;
+
+ if (prog_completes == 0)
+ return 1;
+
+ item = remove_hash_item (cmd, prog_completes);
+ if (item)
+ {
+ free_progcomp (item->data);
+ free (item->key);
+ free (item);
+ return (1);
+ }
+ return (0);
+}
+
+int
+add_progcomp (cmd, cs)
+ char *cmd;
+ COMPSPEC *cs;
+{
+ register BUCKET_CONTENTS *item;
+
+ if (progcomp_initialized == 0 || prog_completes == 0)
+ initialize_progcomp ();
+
+ if (cs == NULL)
+ programming_error ("add_progcomp: %s: NULL COMPSPEC", cmd);
+
+ item = add_hash_item (cmd, prog_completes);
+ if (item->data)
+ free_progcomp (item->data);
+ else
+ item->key = savestring (cmd);
+ item->data = (char *)cs;
+ cs->refcount++;
+ return 1;
+}
+
+COMPSPEC *
+find_compspec (cmd)
+ char *cmd;
+{
+ register BUCKET_CONTENTS *item;
+ COMPSPEC *cs;
+
+ if (prog_completes == 0)
+ return ((COMPSPEC *)NULL);
+
+ item = find_hash_item (cmd, prog_completes);
+
+ if (item == NULL)
+ return ((COMPSPEC *)NULL);
+
+ cs = (COMPSPEC *)item->data;
+
+ return (cs);
+}
+
+void
+print_all_compspecs (pfunc)
+ VFunction *pfunc;
+{
+ BUCKET_CONTENTS *item_list;
+ int bucket;
+ COMPSPEC *cs;
+
+ if (prog_completes == 0 || pfunc == 0)
+ return;
+
+ for (bucket = 0; bucket < prog_completes->nbuckets; bucket++)
+ {
+ item_list = get_hash_bucket (bucket, prog_completes);
+ if (item_list == 0)
+ continue;
+
+ for ( ; item_list; item_list = item_list->next)
+ {
+ cs = (COMPSPEC *)item_list->data;
+ (*pfunc) (item_list->key, cs);
+ }
+ }
+}
+
+#endif /* PROGRAMMABLE_COMPLETION */
diff --git a/posixjmp.h b/posixjmp.h
deleted file mode 100644
index 1347cc07..00000000
--- a/posixjmp.h
+++ /dev/null
@@ -1,22 +0,0 @@
-/* posixjmp.h -- wrapper for setjmp.h with changes for POSIX systems. */
-
-#ifndef _POSIXJMP_H_
-#define _POSIXJMP_H_
-
-#include <setjmp.h>
-
-/* This *must* be included *after* config.h */
-
-#if defined (HAVE_POSIX_SIGSETJMP)
-# define procenv_t sigjmp_buf
-# if !defined (__OPENNT)
-# undef setjmp
-# define setjmp(x) sigsetjmp((x), 1)
-# undef longjmp
-# define longjmp(x, n) siglongjmp((x), (n))
-# endif /* !__OPENNT */
-#else
-# define procenv_t jmp_buf
-#endif
-
-#endif /* _POSIXJMP_H_ */
diff --git a/posixstat.h b/posixstat.h
deleted file mode 100644
index bfce8c04..00000000
--- a/posixstat.h
+++ /dev/null
@@ -1,142 +0,0 @@
-/* posixstat.h -- Posix stat(2) definitions for systems that
- don't have them. */
-
-/* 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 1, or (at your option)
- any later version.
-
- Bash is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
- License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Bash; see the file COPYING. If not, write to the Free
- Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/* This file should be included instead of <sys/stat.h>.
- It relies on the local sys/stat.h to work though. */
-#if !defined (_POSIXSTAT_H_)
-#define _POSIXSTAT_H_
-
-#include <sys/stat.h>
-
-#if defined (STAT_MACROS_BROKEN)
-# undef S_ISBLK
-# undef S_ISCHR
-# undef S_ISDIR
-# undef S_ISFIFO
-# undef S_ISREG
-# undef S_ISLNK
-#endif /* STAT_MACROS_BROKEN */
-
-/* These are guaranteed to work only on isc386 */
-#if !defined (S_IFDIR) && !defined (S_ISDIR)
-# define S_IFDIR 0040000
-#endif /* !S_IFDIR && !S_ISDIR */
-#if !defined (S_IFMT)
-# define S_IFMT 0170000
-#endif /* !S_IFMT */
-
-/* Posix 1003.1 5.6.1.1 <sys/stat.h> file types */
-
-/* Some Posix-wannabe systems define _S_IF* macros instead of S_IF*, but
- do not provide the S_IS* macros that Posix requires. */
-
-#if defined (_S_IFMT) && !defined (S_IFMT)
-#define S_IFMT _S_IFMT
-#endif
-#if defined (_S_IFIFO) && !defined (S_IFIFO)
-#define S_IFIFO _S_IFIFO
-#endif
-#if defined (_S_IFCHR) && !defined (S_IFCHR)
-#define S_IFCHR _S_IFCHR
-#endif
-#if defined (_S_IFDIR) && !defined (S_IFDIR)
-#define S_IFDIR _S_IFDIR
-#endif
-#if defined (_S_IFBLK) && !defined (S_IFBLK)
-#define S_IFBLK _S_IFBLK
-#endif
-#if defined (_S_IFREG) && !defined (S_IFREG)
-#define S_IFREG _S_IFREG
-#endif
-#if defined (_S_IFLNK) && !defined (S_IFLNK)
-#define S_IFLNK _S_IFLNK
-#endif
-#if defined (_S_IFSOCK) && !defined (S_IFSOCK)
-#define S_IFSOCK _S_IFSOCK
-#endif
-
-/* Test for each symbol individually and define the ones necessary (some
- systems claiming Posix compatibility define some but not all). */
-
-#if defined (S_IFBLK) && !defined (S_ISBLK)
-#define S_ISBLK(m) (((m)&S_IFMT) == S_IFBLK) /* block device */
-#endif
-
-#if defined (S_IFCHR) && !defined (S_ISCHR)
-#define S_ISCHR(m) (((m)&S_IFMT) == S_IFCHR) /* character device */
-#endif
-
-#if defined (S_IFDIR) && !defined (S_ISDIR)
-#define S_ISDIR(m) (((m)&S_IFMT) == S_IFDIR) /* directory */
-#endif
-
-#if defined (S_IFREG) && !defined (S_ISREG)
-#define S_ISREG(m) (((m)&S_IFMT) == S_IFREG) /* file */
-#endif
-
-#if defined (S_IFIFO) && !defined (S_ISFIFO)
-#define S_ISFIFO(m) (((m)&S_IFMT) == S_IFIFO) /* fifo - named pipe */
-#endif
-
-#if defined (S_IFLNK) && !defined (S_ISLNK)
-#define S_ISLNK(m) (((m)&S_IFMT) == S_IFLNK) /* symbolic link */
-#endif
-
-#if defined (S_IFSOCK) && !defined (S_ISSOCK)
-#define S_ISSOCK(m) (((m)&S_IFMT) == S_IFSOCK) /* socket */
-#endif
-
-/*
- * POSIX 1003.1 5.6.1.2 <sys/stat.h> File Modes
- */
-
-#if !defined (S_IRWXU)
-# if !defined (S_IREAD)
-# define S_IREAD 00400
-# define S_IWRITE 00200
-# define S_IEXEC 00100
-# endif /* S_IREAD */
-
-# if !defined (S_IRUSR)
-# define S_IRUSR S_IREAD /* read, owner */
-# define S_IWUSR S_IWRITE /* write, owner */
-# define S_IXUSR S_IEXEC /* execute, owner */
-
-# define S_IRGRP (S_IREAD >> 3) /* read, group */
-# define S_IWGRP (S_IWRITE >> 3) /* write, group */
-# define S_IXGRP (S_IEXEC >> 3) /* execute, group */
-
-# define S_IROTH (S_IREAD >> 6) /* read, other */
-# define S_IWOTH (S_IWRITE >> 6) /* write, other */
-# define S_IXOTH (S_IEXEC >> 6) /* execute, other */
-# endif /* !S_IRUSR */
-
-# define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR)
-# define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP)
-# define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH)
-#endif /* !S_IRWXU */
-
-/* These are non-standard, but are used in builtins.c$symbolic_umask() */
-#define S_IRUGO (S_IRUSR | S_IRGRP | S_IROTH)
-#define S_IWUGO (S_IWUSR | S_IWGRP | S_IWOTH)
-#define S_IXUGO (S_IXUSR | S_IXGRP | S_IXOTH)
-
-#endif /* _POSIXSTAT_H_ */
diff --git a/print_cmd.c b/print_cmd.c
index 47247015..51cebf12 100644
--- a/print_cmd.c
+++ b/print_cmd.c
@@ -5,7 +5,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 1, or (at your option) any later
+Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -15,7 +15,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#include "config.h"
@@ -84,6 +84,9 @@ static void print_arith_command ();
static void print_cond_node ();
static void print_cond_command ();
#endif
+#if defined (ARITH_FOR_COMMAND)
+static void print_arith_for_command ();
+#endif
#define PRINTED_COMMAND_INITIAL_SIZE 64
#define PRINTED_COMMAND_GROW_SIZE 128
@@ -137,9 +140,6 @@ make_command_string_internal (command)
else
indent (indentation);
- if (command->flags & CMD_WANT_SUBSHELL)
- cprintf ("( ");
-
if (command->flags & CMD_TIME_PIPELINE)
{
cprintf ("time ");
@@ -156,6 +156,12 @@ make_command_string_internal (command)
print_for_command (command->value.For);
break;
+#if defined (ARITH_FOR_COMMAND)
+ case cm_arith_for:
+ print_arith_for_command (command->value.ArithFor);
+ break;
+#endif
+
#if defined (SELECT_COMMAND)
case cm_select:
print_select_command (command->value.Select);
@@ -259,13 +265,18 @@ make_command_string_internal (command)
print_group_command (command->value.Group);
break;
+ case cm_subshell:
+ cprintf ("( ");
+ skip_this_indent++;
+ make_command_string_internal (command->value.Subshell->command);
+ cprintf (" )");
+ break;
+
default:
command_error ("print_command", CMDERR_BADTYPE, command->type, 0);
break;
}
- if (command->flags & CMD_WANT_SUBSHELL)
- cprintf (" )");
if (command->redirects)
{
@@ -344,6 +355,27 @@ print_for_command (for_command)
newline ("done");
}
+#if defined (ARITH_FOR_COMMAND)
+static void
+print_arith_for_command (arith_for_command)
+ ARITH_FOR_COM *arith_for_command;
+{
+ cprintf ("for (( ");
+ command_print_word_list (arith_for_command->init, " ");
+ cprintf (" ; ");
+ command_print_word_list (arith_for_command->test, " ");
+ cprintf (" ; ");
+ command_print_word_list (arith_for_command->step, " ");
+ cprintf (" ))");
+ newline ("do\n");
+ indentation += indentation_amount;
+ make_command_string_internal (arith_for_command->action);
+ semicolon ();
+ indentation -= indentation_amount;
+ newline ("done");
+}
+#endif /* ARITH_FOR_COMMAND */
+
#if defined (SELECT_COMMAND)
static void
print_select_command (select_command)
@@ -492,6 +524,7 @@ print_arith_command (arith_command)
command_print_word_list (arith_command->exp, " ");
cprintf (" ))");
}
+#endif
#if defined (COND_COMMAND)
static void
@@ -586,6 +619,7 @@ xtrace_print_cond_term (type, invert, op, arg1, arg2)
}
#endif /* COND_COMMAND */
+#if defined (DPAREN_ARITHMETIC) || defined (ARITH_FOR_COMMAND)
/* A function to print the words of an arithmetic command when set -x is on. */
void
xtrace_print_arith_cmd (list)
@@ -768,6 +802,9 @@ static void
print_function_def (func)
FUNCTION_DEF *func;
{
+ COMMAND *cmdcopy;
+ REDIRECT *func_redirects;
+
cprintf ("function %s () \n", func->name->word);
add_unwind_protect (reset_locals, 0);
@@ -777,15 +814,31 @@ print_function_def (func)
inside_function_def++;
indentation += indentation_amount;
- make_command_string_internal (func->command->type == cm_group
- ? func->command->value.Group->command
- : func->command);
+ func_redirects = (REDIRECT *)NULL;
+ cmdcopy = copy_command (func->command);
+ if (cmdcopy->type == cm_group)
+ {
+ func_redirects = cmdcopy->value.Group->command->redirects;
+ cmdcopy->value.Group->command->redirects = (REDIRECT *)NULL;
+ }
+ make_command_string_internal (cmdcopy->type == cm_group
+ ? cmdcopy->value.Group->command
+ : cmdcopy);
remove_unwind_protect ();
indentation -= indentation_amount;
inside_function_def--;
- newline ("}");
+ if (func_redirects)
+ { /* { */
+ newline ("} ");
+ print_redirection_list (func_redirects);
+ cmdcopy->value.Group->command->redirects = func_redirects;
+ }
+ else
+ newline ("}");
+
+ dispose_command (cmdcopy);
}
/* Return the string representation of the named function.
@@ -801,6 +854,8 @@ named_function_string (name, command, multi_line)
{
char *result;
int old_indent, old_amount;
+ COMMAND *cmdcopy;
+ REDIRECT *func_redirects;
old_indent = indentation;
old_amount = indentation_amount;
@@ -826,15 +881,31 @@ named_function_string (name, command, multi_line)
cprintf (multi_line ? "{ \n" : "{ ");
- make_command_string_internal (command->type == cm_group
- ? command->value.Group->command
- : command);
+ cmdcopy = copy_command (command);
+ /* Take any redirections specified in the function definition (which should
+ apply to the function as a whole) and save them for printing later. */
+ func_redirects = (REDIRECT *)NULL;
+ if (cmdcopy->type == cm_group)
+ {
+ func_redirects = cmdcopy->value.Group->command->redirects;
+ cmdcopy->value.Group->command->redirects = (REDIRECT *)NULL;
+ }
+ make_command_string_internal (cmdcopy->type == cm_group
+ ? cmdcopy->value.Group->command
+ : cmdcopy);
indentation = old_indent;
indentation_amount = old_amount;
inside_function_def--;
- newline ("}");
+ if (func_redirects)
+ { /* { */
+ newline ("} ");
+ print_redirection_list (func_redirects);
+ cmdcopy->value.Group->command->redirects = func_redirects;
+ }
+ else
+ newline ("}");
result = the_printed_command;
@@ -854,6 +925,8 @@ named_function_string (name, command, multi_line)
#endif
}
+ dispose_command (cmdcopy);
+
return (result);
}
@@ -1068,14 +1141,11 @@ the_printed_command_resize (length)
{
int new;
new = command_string_index + length + 1;
-#if 1
+
/* Round up to the next multiple of PRINTED_COMMAND_GROW_SIZE. */
new = (new + PRINTED_COMMAND_GROW_SIZE - 1) & ~(PRINTED_COMMAND_GROW_SIZE - 1);
-#else
- new = new + 2 * PRINTED_COMMAND_GROW_SIZE - 1;
- new -= new % PRINTED_COMMAND_GROW_SIZE;
-#endif
the_printed_command_size = new;
+
the_printed_command = xrealloc (the_printed_command, the_printed_command_size);
}
}
diff --git a/quit.h b/quit.h
index a524efca..4821c276 100644
--- a/quit.h
+++ b/quit.h
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if !defined (_QUIT_H_)
#define _QUIT_H_
diff --git a/redir.c b/redir.c
index f01d4141..e3dd3d54 100644
--- a/redir.c
+++ b/redir.c
@@ -6,7 +6,7 @@
Bash is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 1, or (at your option)
+ the Free Software Foundation; either version 2, or (at your option)
any later version.
Bash is distributed in the hope that it will be useful, but WITHOUT
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with Bash; see the file COPYING. If not, write to the Free
- Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#include "config.h"
#if !defined (__GNUC__) && !defined (HAVE_ALLOCA_H) && defined (_AIX)
@@ -64,6 +64,7 @@ static void add_exec_redirect ();
static int add_undo_redirect ();
static int do_redirection_internal ();
static int expandable_redirection_filename ();
+static int stdin_redirection ();
/* Spare redirector used when translating [N]>&WORD or [N]<&WORD to a new
redirection and when creating the redirection undo list. */
@@ -79,14 +80,18 @@ redirection_error (temp, error)
int error;
{
char *filename;
+ int oflags;
if (expandable_redirection_filename (temp))
{
- if (posixly_correct && !interactive_shell)
- disallow_filename_globbing++;
+ if (posixly_correct && interactive_shell == 0)
+ {
+ oflags = temp->redirectee.filename->flags;
+ temp->redirectee.filename->flags |= W_NOGLOB;
+ }
filename = redirection_expand (temp->redirectee.filename);
- if (posixly_correct && !interactive_shell)
- disallow_filename_globbing--;
+ if (posixly_correct && interactive_shell == 0)
+ temp->redirectee.filename->flags = oflags;
if (filename == 0)
filename = savestring (temp->redirectee.filename->word);
if (filename == 0)
@@ -195,8 +200,13 @@ redirection_expand (word)
{
char *result;
WORD_LIST *tlist1, *tlist2;
+ WORD_DESC *w;
+
+ w = copy_word (word);
+ if (posixly_correct)
+ w->flags |= W_NOSPLIT;
- tlist1 = make_word_list (copy_word (word), (WORD_LIST *)NULL);
+ tlist1 = make_word_list (w, (WORD_LIST *)NULL);
tlist2 = expand_words_no_vars (tlist1);
dispose_words (tlist1);
@@ -293,7 +303,7 @@ here_document_to_fd (redirectee)
WORD_DESC *redirectee;
{
char filename[24];
- int r, fd;
+ int r, fd, fd2;
static int fnum = 0;
do
@@ -315,44 +325,122 @@ here_document_to_fd (redirectee)
if (redirectee->word)
r = write_here_document (fd, redirectee);
- close (fd);
if (r)
{
+ close (fd);
unlink (filename);
errno = r;
return (-1);
}
- /* XXX - this is raceable */
+ /* In an attempt to avoid races, we close the first fd only after opening
+ the second. */
/* Make the document really temporary. Also make it the input. */
- fd = open (filename, O_RDONLY, 0600);
+ fd2 = open (filename, O_RDONLY, 0600);
- if (fd < 0)
+ if (fd2 < 0)
{
r = errno;
unlink (filename);
+ close (fd);
errno = r;
return -1;
}
+ close (fd);
if (unlink (filename) < 0)
{
r = errno;
- close (fd);
+ close (fd2);
errno = r;
return (-1);
}
- return (fd);
+ return (fd2);
}
+#define RF_DEVFD 1
+#define RF_DEVSTDERR 2
+#define RF_DEVSTDIN 3
+#define RF_DEVSTDOUT 4
+#define RF_DEVTCP 5
+#define RF_DEVUDP 6
+
+/* A list of pattern/value pairs for filenames that the redirection
+ code handles specially. */
+static STRING_INT_ALIST _redir_special_filenames[] = {
+#if !defined (HAVE_DEV_FD)
+ { "/dev/fd/[0-9]*", RF_DEVFD },
+#endif
+#if !defined (HAVE_DEV_STDIN)
+ { "/dev/stderr", RF_DEVSTDERR },
+ { "/dev/stdin", RF_DEVSTDIN },
+ { "/dev/stdout", RF_DEVSTDOUT },
+#endif
+#if defined (NETWORK_REDIRECTIONS)
+ { "/dev/tcp/*/*", RF_DEVTCP },
+ { "/dev/udp/*/*", RF_DEVUDP },
+#endif
+ { (char *)NULL, -1 }
+};
+
+static int
+redir_special_open (spec, filename, flags, mode, ri)
+ int spec;
+ char *filename;
+ int flags, mode;
+ enum r_instruction ri;
+{
+ int fd;
+ long lfd;
+
+ fd = -1;
+ switch (spec)
+ {
+#if !defined (HAVE_DEV_FD)
+ case RF_DEVFD:
+ if (legal_number, filename+8, &lfd)
+ fd = fcntl ((int)lfd, F_DUPFD, 10);
+ else
+ fd = AMBIGUOUS_REDIRECT;
+ break;
+#endif
+
+#if !defined (HAVE_DEV_STDIN)
+ case RF_DEVSTDIN:
+ fd = fcntl (0, F_DUPFD, 10);
+ break;
+ case RF_DEVSTDOUT:
+ fd = fcntl (1, F_DUPFD, 10);
+ break;
+ case RF_DEVSTDERR:
+ fd = fcntl (2, F_DUPFD, 10);
+ break;
+#endif
+
+#if defined (NETWORK_REDIRECTIONS)
+ case RF_DEVTCP:
+ case RF_DEVUDP:
+#if defined (HAVE_NETWORK)
+ fd = netopen (filename);
+#else
+ internal_warning ("/dev/(tcp|udp)/host/port not supported without networking");
+ fd = open (filename, flags, mode);
+#endif
+ break;
+#endif /* NETWORK_REDIRECTIONS */
+ }
+
+ return fd;
+}
+
/* Open FILENAME with FLAGS in noclobber mode, hopefully avoiding most
race conditions and avoiding the problem where the file is replaced
between the stat(2) and open(2). */
static int
-noclobber_open (filename, flags, ri)
+noclobber_open (filename, flags, mode, ri)
char *filename;
- int flags;
+ int flags, mode;
enum r_instruction ri;
{
int r, fd;
@@ -372,10 +460,10 @@ noclobber_open (filename, flags, ri)
flags &= ~O_TRUNC;
if (r != 0)
{
- fd = open (filename, flags|O_EXCL, 0666);
+ fd = open (filename, flags|O_EXCL, mode);
return ((fd < 0 && errno == EEXIST) ? NOCLOBBER_REDIRECT : fd);
}
- fd = open (filename, flags, 0666);
+ fd = open (filename, flags, mode);
/* If the open failed, return the file descriptor right away. */
if (fd < 0)
@@ -401,6 +489,38 @@ noclobber_open (filename, flags, ri)
return (NOCLOBBER_REDIRECT);
}
+static int
+redir_open (filename, flags, mode, ri)
+ char *filename;
+ int flags, mode;
+ enum r_instruction ri;
+{
+ int fd, r;
+
+ r = find_string_in_alist (filename, _redir_special_filenames, 1);
+ if (r >= 0)
+ return (redir_special_open (r, filename, flags, mode, ri));
+
+ /* If we are in noclobber mode, you are not allowed to overwrite
+ existing files. Check before opening. */
+ if (noclobber && OUTPUT_REDIRECT (ri))
+ {
+ fd = noclobber_open (filename, flags, mode, ri);
+ if (fd == NOCLOBBER_REDIRECT)
+ return (NOCLOBBER_REDIRECT);
+ }
+ else
+ {
+ fd = open (filename, flags, mode);
+#if defined (AFS)
+ if ((fd < 0) && (errno == EACCES))
+ fd = open (filename, flags & ~O_CREAT, mode);
+#endif /* AFS */
+ }
+
+ return fd;
+}
+
/* Do the specific redirection requested. Returns errno or one of the
special redirection errors (*_REDIRECT) in case of error, 0 on success.
If FOR_REAL is zero, then just do whatever is neccessary to produce the
@@ -413,7 +533,7 @@ do_redirection_internal (redirect, for_real, remembering, set_clexec)
int for_real, remembering, set_clexec;
{
WORD_DESC *redirectee;
- int redir_fd, fd, redirector, r;
+ int redir_fd, fd, redirector, r, oflags;
char *redirectee_word;
enum r_instruction ri;
REDIRECT *new_redirect;
@@ -506,11 +626,14 @@ do_redirection_internal (redirect, for_real, remembering, set_clexec)
case r_err_and_out: /* command &>filename */
case r_input_output:
case r_output_force:
- if (posixly_correct && !interactive_shell)
- disallow_filename_globbing++;
+ if (posixly_correct && interactive_shell == 0)
+ {
+ oflags = redirectee->flags;
+ redirectee->flags |= W_NOGLOB;
+ }
redirectee_word = redirection_expand (redirectee);
- if (posixly_correct && !interactive_shell)
- disallow_filename_globbing--;
+ if (posixly_correct && interactive_shell == 0)
+ redirectee->flags = oflags;
if (redirectee_word == 0)
return (AMBIGUOUS_REDIRECT);
@@ -523,27 +646,12 @@ do_redirection_internal (redirect, for_real, remembering, set_clexec)
}
#endif /* RESTRICTED_SHELL */
- /* If we are in noclobber mode, you are not allowed to overwrite
- existing files. Check before opening. */
- if (noclobber && OUTPUT_REDIRECT (ri))
- {
- fd = noclobber_open (redirectee_word, redirect->flags, ri);
- if (fd == NOCLOBBER_REDIRECT)
- {
- free (redirectee_word);
- return (NOCLOBBER_REDIRECT);
- }
- }
- else
- {
- fd = open (redirectee_word, redirect->flags, 0666);
-#if defined (AFS)
- if ((fd < 0) && (errno == EACCES))
- fd = open (redirectee_word, redirect->flags & ~O_CREAT, 0666);
-#endif /* AFS */
- }
+ fd = redir_open (redirectee_word, redirect->flags, 0666, ri);
free (redirectee_word);
+ if (fd == NOCLOBBER_REDIRECT)
+ return (fd);
+
if (fd < 0)
return (errno);
@@ -650,10 +758,11 @@ do_redirection_internal (redirect, for_real, remembering, set_clexec)
SET_CLOSE_ON_EXEC (redirector);
}
+ if (fd != redirector)
#if defined (BUFFERED_INPUT)
- close_buffered_fd (fd);
+ close_buffered_fd (fd);
#else
- close (fd);
+ close (fd);
#endif
}
break;
@@ -672,6 +781,7 @@ do_redirection_internal (redirect, for_real, remembering, set_clexec)
#if defined (BUFFERED_INPUT)
check_bash_input (redirector);
#endif
+
/* This is correct. 2>&1 means dup2 (1, 2); */
if (dup2 (redir_fd, redirector) < 0)
return (errno);
@@ -791,6 +901,36 @@ add_exec_redirect (dummy_redirect)
exec_redirection_undo_list = dummy_redirect;
}
+/* Return 1 if the redirection specified by RI and REDIRECTOR alters the
+ standard input. */
+static int
+stdin_redirection (ri, redirector)
+ enum r_instruction ri;
+ int redirector;
+{
+ switch (ri)
+ {
+ case r_input_direction:
+ case r_inputa_direction:
+ case r_input_output:
+ case r_reading_until:
+ case r_deblank_reading_until:
+ return (1);
+ case r_duplicating_input:
+ case r_duplicating_input_word:
+ case r_close_this:
+ return (redirector == 0);
+ case r_output_direction:
+ case r_appending_to:
+ case r_duplicating_output:
+ case r_err_and_out:
+ case r_output_force:
+ case r_duplicating_output_word:
+ return (0);
+ }
+ return (0);
+}
+
/* Return non-zero if any of the redirections in REDIRS alter the standard
input. */
int
@@ -801,28 +941,6 @@ stdin_redirects (redirs)
int n;
for (n = 0, rp = redirs; rp; rp = rp->next)
- switch (rp->instruction)
- {
- case r_input_direction:
- case r_inputa_direction:
- case r_input_output:
- case r_reading_until:
- case r_deblank_reading_until:
- n++;
- break;
- case r_duplicating_input:
- case r_duplicating_input_word:
- case r_close_this:
- n += (rp->redirector == 0);
- break;
- case r_output_direction:
- case r_appending_to:
- case r_duplicating_output:
- case r_err_and_out:
- case r_output_force:
- case r_duplicating_output_word:
- break;
- }
-
+ n += stdin_redirection (rp->instruction, rp->redirector);
return n;
}
diff --git a/redir.h b/redir.h
index c0cdf73c..7b450022 100644
--- a/redir.h
+++ b/redir.h
@@ -1,4 +1,4 @@
-/* findcmd.h - functions from findcmd.c. */
+/* redir.h - functions from redir.c. */
/* Copyright (C) 1997 Free Software Foundation, Inc.
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if !defined (_REDIR_H_)
#define _REDIR_H_
diff --git a/shell.c b/shell.c
index d41aea03..4cb95e01 100644
--- a/shell.c
+++ b/shell.c
@@ -1,30 +1,22 @@
-/* shell.c -- GNU's idea of the POSIX shell specification.
+/* shell.c -- GNU's idea of the POSIX shell specification. */
- This file is part of Bash, the Bourne Again SHell. Bash is free
- software; no one can prevent you from reading the source code, or
- giving it to someone else. This file is copyrighted under the GNU
- General Public License, which can be found in the file called
- COPYING.
+/* Copyright (C) 1987,1991 Free Software Foundation, Inc.
- Copyright (C) 1988, 1991 Free Software Foundation, Inc.
+ This file is part of GNU Bash, the Bourne Again SHell.
- This file is part of GNU Bash.
+ Bash is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
Bash is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY. No author or distributor accepts responsibility to
- anyone for the consequences of using it or for whether it serves
- any particular purpose or works at all, unless he says so in
- writing. Refer to the GNU Emacs General Public License for full
- details.
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
+ License for more details.
- Everyone is granted permission to copy, modify and redistribute
- Bash, but only under the conditions described in the GNU General
- Public License. A copy of this license is supposed to have been
- given to you along with GNU Emacs so you can know your rights and
- responsibilities. It should be in a file named COPYING.
-
- Among other things, the copyright notice and this notice must be
- preserved on all copies.
+ You should have received a copy of the GNU General Public License
+ along with Bash; see the file COPYING. If not, write to the Free
+ Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
Birthdate:
Sunday, January 10th, 1988.
@@ -91,6 +83,7 @@ extern char **environ; /* used if no third argument to main() */
extern char *dist_version, *release_status;
extern int patch_level, build_version;
+extern int shell_level;
extern int subshell_environment;
extern int last_command_exit_value;
extern int line_number;
@@ -238,8 +231,10 @@ char **subshell_envp;
int default_buffered_input = -1;
#endif
-static int read_from_stdin; /* -s flag supplied */
-static int want_pending_command; /* -c flag supplied */
+/* The following two variables are not static so they can show up in $-. */
+int read_from_stdin; /* -s flag supplied */
+int want_pending_command; /* -c flag supplied */
+
static char *local_pending_command;
static FILE *default_input;
@@ -795,6 +790,15 @@ exit_shell (s)
exit (s);
}
+/* A wrapper for exit that (optionally) can do other things, like malloc
+ statistics tracing. */
+void
+sh_exit (s)
+ int s;
+{
+ exit (s);
+}
+
/* Source the bash startup files. If POSIXLY_CORRECT is non-zero, we obey
the Posix.2 startup file rules: $ENV is expanded, and if the file it
names exists, that file is sourced. The Posix.2 rules are in effect
@@ -851,27 +855,17 @@ run_startup_files ()
int old_job_control;
#endif
int sourced_login, run_by_ssh;
- SHELL_VAR *sshvar;
/* get the rshd/sshd case out of the way first. */
if (interactive_shell == 0 && no_rc == 0 && login_shell == 0 &&
act_like_sh == 0 && local_pending_command)
{
- /* Find out if we were invoked by ssh. If so, set RUN_BY_SSH to 1. */
- sshvar = find_variable ("SSH_CLIENT");
- if (sshvar)
- {
- run_by_ssh = 1;
- /* Now that we've tested the variable, we need to unexport it. */
- sshvar->attributes &= ~att_exported;
- array_needs_making = 1;
- }
- else
- run_by_ssh = 0;
+ run_by_ssh = find_variable ("SSH_CLIENT") != (SHELL_VAR *)0;
+ run_by_ssh |= find_variable ("SSH2_CLIENT") != (SHELL_VAR *)0;
/* If we were run by sshd or we think we were run by rshd, execute
- ~/.bashrc. */
- if (run_by_ssh || isnetconn (fileno (stdin)))
+ ~/.bashrc if we are a top-level shell. */
+ if ((run_by_ssh || isnetconn (fileno (stdin))) && shell_level < 2)
{
#ifdef SYS_BASHRC
# if defined (__OPENNT)
@@ -892,7 +886,15 @@ run_startup_files ()
sourced_login = 0;
- if (login_shell < 0 && posixly_correct == 0) /* --login flag and not posix */
+ /* A shell begun with the --login flag that is not in posix mode runs
+ the login shell startup files, no matter whether or not it is
+ interactive. If NON_INTERACTIVE_LOGIN_SHELLS is defined, run the
+ startup files if argv[0][0] == '-' as well. */
+#if defined (NON_INTERACTIVE_LOGIN_SHELLS)
+ if (login_shell && posixly_correct == 0)
+#else
+ if (login_shell < 0 && posixly_correct == 0)
+#endif
{
/* We don't execute .bashrc for login shells. */
no_rc++;
@@ -955,7 +957,7 @@ run_startup_files ()
maybe_execute_file (_prefixInstallPath(SYS_BASHRC, NULL, 0), 1);
# else
maybe_execute_file (SYS_BASHRC, 1);
-# endif`
+# endif
#endif
maybe_execute_file (bashrc_file, 1);
}
@@ -1256,6 +1258,11 @@ open_shell_script (script_name)
lseek (fd, 0L, 0);
}
+ /* Open the script. But try to move the file descriptor to a randomly
+ large one, in the hopes that any descriptors used by the script will
+ not match with ours. */
+ fd = move_to_high_fd (fd, 0, -1);
+
#if defined (BUFFERED_INPUT)
default_buffered_input = fd;
# if 0
@@ -1268,11 +1275,6 @@ open_shell_script (script_name)
# endif
SET_CLOSE_ON_EXEC (default_buffered_input);
#else /* !BUFFERED_INPUT */
- /* Open the script. But try to move the file descriptor to a randomly
- large one, in the hopes that any descriptors used by the script will
- not match with ours. */
- fd = move_to_high_fd (fd, 0, -1);
-
default_input = fdopen (fd, "r");
if (default_input == 0)
@@ -1454,8 +1456,8 @@ shell_initialize ()
/* Line buffer output for stderr and stdout. */
if (shell_initialized == 0)
{
- setlinebuf (stderr);
- setlinebuf (stdout);
+ sh_setlinebuf (stderr);
+ sh_setlinebuf (stdout);
}
/* Sort the array of shell builtins so that the binary search in
diff --git a/shell.h b/shell.h
index 681c64dc..bf8a7bec 100644
--- a/shell.h
+++ b/shell.h
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#include "config.h"
diff --git a/sig.c b/sig.c
index aad83f87..41b637b2 100644
--- a/sig.c
+++ b/sig.c
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#include "config.h"
@@ -172,9 +172,11 @@ static struct termsig terminating_signals[] = {
SIGVTALRM, NULL_HANDLER,
#endif
+#if 0
#ifdef SIGPROF
SIGPROF, NULL_HANDLER,
#endif
+#endif
#ifdef SIGLOST
SIGLOST, NULL_HANDLER,
@@ -272,7 +274,9 @@ initialize_shell_signals ()
to child processes. Children will never block SIGCHLD, though. */
sigemptyset (&top_level_mask);
sigprocmask (SIG_BLOCK, (sigset_t *)NULL, &top_level_mask);
+# if defined (SIGCHLD)
sigdelset (&top_level_mask, SIGCHLD);
+# endif
#endif /* JOB_CONTROL || HAVE_POSIX_SIGNALS */
/* And, some signals that are specifically ignored by the shell. */
diff --git a/sig.h b/sig.h
index ab72a923..47d7395c 100644
--- a/sig.h
+++ b/sig.h
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
/* Make sure that this is included *after* config.h! */
diff --git a/siglist.c b/siglist.c
index 0206f57f..65496af4 100644
--- a/siglist.c
+++ b/siglist.c
@@ -6,7 +6,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 1, or (at your option) any later
+Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -16,7 +16,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#include "config.h"
diff --git a/siglist.h b/siglist.h
index 6fad8dad..da20b1d9 100644
--- a/siglist.h
+++ b/siglist.h
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if !defined (_SIGLIST_H_)
#define _SIGLIST_H_
diff --git a/stringlib.c b/stringlib.c
index 3c541656..471c8fac 100644
--- a/stringlib.c
+++ b/stringlib.c
@@ -17,7 +17,7 @@
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#include "config.h"
@@ -32,6 +32,11 @@
#include <ctype.h>
#include "shell.h"
+#include "pathexp.h"
+
+#if defined (EXTENDED_GLOB)
+# include <glob/fnmatch.h>
+#endif
#ifndef to_upper
# define to_upper(c) (islower(c) ? toupper(c) : (c))
@@ -51,11 +56,14 @@
/* Convert STRING by expanding the escape sequences specified by the
ANSI C standard. If SAWC is non-null, 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. */
+ returning. LEN is the length of STRING. FOR_ECHO is a flag that
+ means, if non-zero, that we're translating a string for `echo -e',
+ and therefore should not treat a single quote as a character that
+ may be escaped with a backslash. */
char *
-ansicstr (string, len, sawc, rlen)
+ansicstr (string, len, for_echo, sawc, rlen)
char *string;
- int len, *sawc, *rlen;
+ int len, for_echo, *sawc, *rlen;
{
int c, temp;
char *ret, *r, *s;
@@ -103,7 +111,10 @@ ansicstr (string, len, sawc, rlen)
}
break;
case '\\':
+ break;
case '\'':
+ if (for_echo)
+ *r++ = '\\';
break;
case 'c':
if (sawc)
@@ -148,6 +159,14 @@ find_name_in_array (name, array)
}
#endif
+/* Allocate an array of strings with room for N members. */
+char **
+alloc_array (n)
+ int n;
+{
+ return ((char **)xmalloc ((n) * sizeof (char *)));
+}
+
/* Return the length of ARRAY, a NULL terminated array of char *. */
int
array_len (array)
@@ -290,6 +309,32 @@ argv_to_word_list (array, copy, starting_index)
return (REVERSE_LIST(list, WORD_LIST *));
}
+/* Find STRING in ALIST, a list of string key/int value pairs. If FLAGS
+ is 1, STRING is treated as a pattern and matched using fnmatch. */
+int
+find_string_in_alist (string, alist, flags)
+ char *string;
+ STRING_INT_ALIST *alist;
+ int flags;
+{
+ register int i;
+ int r;
+
+ for (i = r = 0; alist[i].word; i++)
+ {
+#if defined (EXTENDED_GLOB)
+ if (flags)
+ r = fnmatch (alist[i].word, string, FNM_EXTMATCH) != FNM_NOMATCH;
+ else
+#endif
+ r = STREQ (string, alist[i].word);
+
+ if (r)
+ return (alist[i].token);
+ }
+ return -1;
+}
+
/* **************************************************************** */
/* */
/* String Management Functions */
@@ -331,6 +376,62 @@ strsub (string, pat, rep, global)
return (temp);
}
+/* Replace all instances of C in STRING with TEXT. TEXT may be empty or
+ NULL. If DO_GLOB is non-zero, we quote the replacement text for
+ globbing. Backslash may be used to quote C. */
+char *
+strcreplace (string, c, text, do_glob)
+ char *string;
+ int c;
+ char *text;
+ int do_glob;
+{
+ char *ret, *p, *r, *t;
+ int len, rlen, ind, tlen;
+
+ len = STRLEN (text);
+ rlen = len + strlen (string) + 2;
+ ret = xmalloc (rlen);
+
+ for (p = string, r = ret; p && *p; )
+ {
+ if (*p == c)
+ {
+ if (len)
+ {
+ ind = r - ret;
+ if (do_glob && (glob_pattern_p (text) || strchr (text, '\\')))
+ {
+ t = quote_globbing_chars (text);
+ tlen = strlen (t);
+ RESIZE_MALLOCED_BUFFER (ret, ind, tlen, rlen, rlen);
+ r = ret + ind; /* in case reallocated */
+ strcpy (r, t);
+ r += tlen;
+ free (t);
+ }
+ else
+ {
+ RESIZE_MALLOCED_BUFFER (ret, ind, len, rlen, rlen);
+ r = ret + ind; /* in case reallocated */
+ strcpy (r, text);
+ r += len;
+ }
+ }
+ p++;
+ continue;
+ }
+
+ if (*p == '\\' && p[1] == '&')
+ p++;
+
+ *r++ = *p++;
+ }
+ *r = '\0';
+
+ return ret;
+}
+
#ifdef INCLUDE_UNUSED
/* Remove all leading whitespace from STRING. This includes
newlines. STRING should be terminated with a zero. */
diff --git a/subst.c b/subst.c
index 5e0eb870..d5786751 100644
--- a/subst.c
+++ b/subst.c
@@ -1,6 +1,9 @@
/* subst.c -- The part of the shell that does parameter, command, and
globbing substitutions. */
+/* ``Have a little faith, there's magic in the night. You ain't a
+ beauty, but, hey, you're alright.'' */
+
/* Copyright (C) 1987,1989 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -17,7 +20,7 @@
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#include "config.h"
@@ -77,6 +80,12 @@ extern int errno;
#define LPAREN '('
#define RPAREN ')'
+/* Evaluates to 1 if this is one of the shell's special variables. */
+#define SPECIAL_VAR(name, wi) \
+ ((digit (*name) && all_digits (name)) || \
+ (name[1] == '\0' && member (*name, "#-?$!@*")) || \
+ (wi && name[2] == '\0' && member (name[1], "#?@*")))
+
/* Process ID of the last command executed within command substitution. */
pid_t last_command_subst_pid = NO_PID;
pid_t current_command_subst_pid = NO_PID;
@@ -84,6 +93,7 @@ pid_t current_command_subst_pid = NO_PID;
/* Extern functions and variables from different files. */
extern int last_command_exit_value, interactive, interactive_shell;
extern int subshell_environment, startup_state;
+extern int return_catch_flag, return_catch_value;
extern int dollar_dollar_pid;
extern int posixly_correct;
extern char *this_command_name;
@@ -106,6 +116,15 @@ static WORD_LIST expand_word_error, expand_word_fatal;
static char expand_param_error, expand_param_fatal;
static int doing_completion = 0;
+static int doing_prompt_expansion = 0;
+
+/* Used to hold a list of variable assignments preceding a command. Global
+ so the SIGCHLD handler in jobs.c can unwind-protect it when it runs a
+ SIGCHLD trap. */
+WORD_LIST *subst_assign_varlist = (WORD_LIST *)NULL;
+/* A WORD_LIST of words to be expanded by expand_word_list_internal,
+ without any leading variable assignments. */
+static WORD_LIST *garglist = (WORD_LIST *)NULL;
static char *make_quoted_char ();
static void remove_quoted_nulls ();
@@ -387,10 +406,8 @@ string_extract (string, sindex, charlist, varname)
else if (MEMBER (c, charlist))
break;
}
- c = i - *sindex;
- temp = xmalloc (1 + c);
- strncpy (temp, string + *sindex, c);
- temp[c] = '\0';
+
+ temp = substring (string, *sindex, i);
*sindex = i;
return (temp);
}
@@ -601,10 +618,7 @@ string_extract_single_quoted (string, sindex)
for (i = *sindex; string[i] && string[i] != '\''; i++)
;
- j = i - *sindex;
- t = xmalloc (1 + j);
- strncpy (t, string + *sindex, j);
- t[j] = '\0';
+ t = substring (string, *sindex, i);
if (string[i])
i++;
@@ -628,7 +642,7 @@ skip_single_quoted (string, sind)
}
/* Just like string_extract, but doesn't hack backslashes or any of
- that other stuff. Obeys quoting. Used to do splitting on $IFS. */
+ that other stuff. Obeys CTLESC quoting. Used to do splitting on $IFS. */
static char *
string_extract_verbatim (string, sindex, charlist)
char *string, *charlist;
@@ -657,10 +671,7 @@ string_extract_verbatim (string, sindex, charlist)
break;
}
- c = i - *sindex;
- temp = xmalloc (1 + c);
- strncpy (temp, string + *sindex, c);
- temp[c] = '\0';
+ temp = substring (string, *sindex, i);
*sindex = i;
return (temp);
@@ -832,7 +843,11 @@ extract_delimited_string (string, sindex, opener, alt_opener, closer)
i++; /* move past this character, which was not special. */
}
+#if 0
if (c == 0 && nesting_level)
+#else
+ if (c == 0 && nesting_level && doing_completion == 0)
+#endif
{
report_error ("bad substitution: no `%s' in %s", closer, string);
jump_to_top_level (DISCARD);
@@ -939,10 +954,7 @@ extract_dollar_brace_string (string, sindex, quoted)
jump_to_top_level (DISCARD);
}
- l = i - *sindex;
- result = xmalloc (1 + l);
- strncpy (result, string + *sindex, l);
- result[l] = '\0';
+ result = substring (string, *sindex, i);
*sindex = i;
return (result);
@@ -1069,6 +1081,201 @@ unclosed_pair (string, eindex, openstr)
}
return (openc);
}
+
+/* Skip characters in STRING until we find a character in DELIMS, and return
+ the index of that character. START is the index into string at which we
+ begin. This is similar in spirit to strpbrk, but it returns an index into
+ STRING and takes a starting index. This little piece of code knows quite
+ a lot of shell syntax. It's very similar to skip_double_quoted and other
+ functions of that ilk. */
+int
+skip_to_delim (string, start, delims)
+ char *string;
+ int start;
+ char *delims;
+{
+ int i, pass_next, backq, si;
+ char *temp;
+
+ doing_completion = 1;
+ for (i = start, pass_next = backq = 0; string[i]; i++)
+ {
+ if (pass_next)
+ {
+ pass_next = 0;
+ if (string[i] == 0)
+ CQ_RETURN(i);
+ continue;
+ }
+ else if (string[i] == '\\')
+ {
+ pass_next = 1;
+ continue;
+ }
+ else if (backq)
+ {
+ if (string[i] == '`')
+ backq = 0;
+ continue;
+ }
+ else if (string[i] == '`')
+ {
+ backq = 1;
+ continue;
+ }
+ else if (string[i] == '\'' || string[i] == '"')
+ {
+ i = (string[i] == '\'') ? skip_single_quoted (string, ++i)
+ : skip_double_quoted (string, ++i);
+ i--; /* the skip functions increment past the closing quote. */
+ }
+ else if (string[i] == '$' && (string[i+1] == LPAREN || string[i+1] == LBRACE))
+ {
+ si = i + 2;
+ if (string[si] == '\0')
+ break;
+ if (string[i+1] == LPAREN)
+ temp = extract_delimited_string (string, &si, "$(", "(", ")"); /* ) */
+ else
+ temp = extract_dollar_brace_string (string, &si, 0);
+ i = si;
+ free (temp);
+ continue;
+ }
+ else if (member (string[i], delims))
+ break;
+ }
+ CQ_RETURN(i);
+}
+
+/* Split STRING (length SLEN) at DELIMS, and return a WORD_LIST with the
+ individual words. If DELIMS is NULL, the current value of $IFS is used
+ to split the string. SENTINEL is an index to look for. NWP, if non-NULL
+ gets the number of words in the returned list. CWP, if non-NULL, gets
+ the index of the word containing SENTINEL. Non-whitespace chars in
+ DELIMS delimit separate fields. */
+WORD_LIST *
+split_at_delims (string, slen, delims, sentinel, nwp, cwp)
+ char *string;
+ int slen;
+ char *delims;
+ int sentinel;
+ int *nwp, *cwp;
+{
+ int ts, te, i, nw, cw, peekc;
+ char *token, *s, *d, *d2;
+ WORD_LIST *ret, *tl;
+
+ if (string == 0 || *string == '\0')
+ {
+ if (nwp)
+ *nwp = 0;
+ if (cwp)
+ *cwp = 0;
+ return ((WORD_LIST *)NULL);
+ }
+
+ d = (delims == 0) ? getifs () : delims;
+
+ /* Make d2 the non-whitespace characters in delims */
+ d2 = 0;
+ if (delims)
+ {
+ d2 = xmalloc (strlen (delims) + 1);
+ for (i = ts = 0; delims[i]; i++)
+ {
+ if (whitespace(delims[i]) == 0)
+ d2[ts++] = delims[i];
+ }
+ d2[ts] = '\0';
+ }
+
+ ret = (WORD_LIST *)NULL;
+
+ for (i = 0; member (string[i], d) && whitespace(string[i]); i++)
+ ;
+ if (string[i] == '\0')
+ return (ret);
+
+ ts = i;
+ nw = 0;
+ cw = -1;
+ while (1)
+ {
+ te = skip_to_delim (string, ts, d);
+
+ /* If we have a non-whitespace delimiter character, use it to make a
+ separate field. This is just about what $IFS splitting does and
+ is closer to the behavior of the shell parser. */
+ if (ts == te && member(string[ts], d2))
+ {
+ te = ts + 1;
+ while (member(string[te], d2))
+ te++;
+ }
+
+ token = substring (string, ts, te);
+
+ ret = add_string_to_list (token, ret);
+ free (token);
+ nw++;
+
+ if (sentinel >= ts && sentinel <= te)
+ cw = nw;
+
+ /* If the cursor is at whitespace just before word start, set the
+ sentinel word to the current word. */
+ if (cwp && cw == -1 && sentinel == ts-1)
+ cw = nw;
+
+ /* If the cursor is at whitespace between two words, make a new, empty
+ word, add it before (well, after, since the list is in reverse order)
+ the word we just added, and set the current word to that one. */
+ if (cwp && cw == -1 && sentinel < ts)
+ {
+ tl = (WORD_LIST *)xmalloc (sizeof (WORD_LIST));
+ tl->word = make_word ("");
+ tl->next = ret->next;
+ ret->next = tl;
+ cw = nw;
+ nw++;
+ }
+
+ if (string[te] == 0)
+ break;
+
+ i = te + member(string[te], d);
+ while (member (string[i], d) && whitespace(string[i]))
+ i++;
+
+ if (string[i])
+ ts = i;
+ else
+ break;
+ }
+
+ /* Special case for SENTINEL at the end of STRING. If we haven't found
+ the word containing SENTINEL yet, and the index we're looking for is at
+ the end of STRING, add an additional null argument and set the current
+ word pointer to that. */
+ if (cwp && cw == -1 && sentinel >= slen)
+ {
+ if (whitespace (string[sentinel - 1]))
+ {
+ token = "";
+ ret = add_string_to_list (token, ret);
+ nw++;
+ }
+ cw = nw;
+ }
+
+ if (nwp)
+ *nwp = nw;
+ if (cwp)
+ *cwp = cw;
+
+ return (REVERSE_LIST (ret, WORD_LIST *));
+}
#endif /* READLINE */
#if 0
@@ -1084,9 +1291,7 @@ assignment_name (string)
offset = assignment (string);
if (offset == 0)
return (char *)NULL;
- temp = xmalloc (offset + 1);
- strncpy (temp, string, offset);
- temp[offset] = '\0';
+ temp = substring (string, 0, offset);
return (temp);
}
#endif
@@ -1288,11 +1493,7 @@ list_string (string, separators, quoted)
/* If we have something, then add it regardless. However,
perform quoted null character removal on the current word. */
remove_quoted_nulls (current_word);
-#if 0
- result = make_word_list (make_word (current_word), result);
-#else
result = add_string_to_list (current_word, result);
-#endif
if (quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT))
result->word->flags |= W_QUOTED;
}
@@ -1406,7 +1607,10 @@ strip_trailing_ifs_whitespace (string, separators, saw_escape)
return string;
}
-#if defined (ARRAY_VARS)
+#if 0
+/* UNUSED */
+/* Split STRING into words at whitespace. Obeys shell-style quoting with
+ backslashes, single and double quotes. */
WORD_LIST *
list_string_with_quotes (string)
char *string;
@@ -1439,15 +1643,8 @@ list_string_with_quotes (string)
{
/* We have found the end of a token. Make a word out of it and
add it to the word list. */
- len = i - tokstart;
- token = xmalloc (len + 1);
- strncpy (token, s + tokstart, len);
- token[len] = '\0';
-#if 0
- list = make_word_list (make_word (token), list);
-#else
+ token = substring (s, tokstart, i);
list = add_string_to_list (token, list);
-#endif
free (token);
while (spctabnl (s[i]))
i++;
@@ -1461,7 +1658,7 @@ list_string_with_quotes (string)
}
return (REVERSE_LIST (list, WORD_LIST *));
}
-#endif /* ARRAY_VARS */
+#endif
/********************************************************/
/* */
@@ -1591,10 +1788,10 @@ do_assignment_internal (string, expand)
stupidly_hack_special_variables (name);
if (entry)
- entry->attributes &= ~att_invisible;
+ VUNSETATTR (entry, att_invisible);
/* Return 1 if the assignment seems to have been performed correctly. */
- ASSIGN_RETURN (entry ? ((entry->attributes & att_readonly) == 0) : 0);
+ ASSIGN_RETURN (entry ? (readonly_p (entry) == 0) : 0);
}
/* Perform the assignment statement in STRING, and expand the
@@ -1700,6 +1897,10 @@ pos_params (string, start, end, quoted)
char *ret;
int i;
+ /* see if we can short-circuit. if start == end, we want 0 parameters. */
+ if (start == end)
+ return ((char *)NULL);
+
save = params = list_rest_of_args ();
if (save == 0)
return ((char *)NULL);
@@ -1719,7 +1920,8 @@ pos_params (string, start, end, quoted)
ret = (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) ? string_list_dollar_star (h) : string_list (h);
else
ret = string_list ((quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) ? quote_list (h) : h);
- t->next = params;
+ if (t != params)
+ t->next = params;
dispose_words (save);
return (ret);
@@ -1873,17 +2075,16 @@ call_expand_word_internal (w, q, i, c, e)
WORD_LIST *result;
result = expand_word_internal (w, q, i, c, e);
- if (result == &expand_word_error)
+ if (result == &expand_word_error || result == &expand_word_fatal)
{
/* By convention, each time this error is returned, w->word has
- already been freed. */
+ already been freed (it sometimes may not be in the fatal case,
+ but that doesn't result in a memory leak because we're going
+ to exit in most cases). */
w->word = (char *)NULL;
- jump_to_top_level (DISCARD);
+ jump_to_top_level ((result == &expand_word_error) ? DISCARD : FORCE_EOF);
/* NOTREACHED */
}
- else if (result == &expand_word_fatal)
- jump_to_top_level (FORCE_EOF);
- /* NOTREACHED */
else
return (result);
}
@@ -1932,6 +2133,42 @@ expand_string_unsplit (string, quoted)
return (value);
}
+
+/* Expand one of the PS? prompt strings. This is a sort of combination of
+ expand_string_unsplit and expand_string_internal, but returns the
+ passed string when an error occurs. Might want to trap other calls
+ to jump_to_top_level here so we don't endlessly loop. */
+WORD_LIST *
+expand_prompt_string (string, quoted)
+ char *string;
+ int quoted;
+{
+ WORD_LIST *value;
+ WORD_DESC td;
+
+ if (string == 0 || *string == 0)
+ return ((WORD_LIST *)NULL);
+
+ bzero ((char *)&td, sizeof (td));
+ td.word = savestring (string);
+ doing_prompt_expansion = 1;
+ value = expand_word_internal (&td, quoted, 0, (int *)NULL, (int *)NULL);
+ doing_prompt_expansion = 0;
+ if (value == &expand_word_error || value == &expand_word_fatal)
+ {
+ value = make_word_list (make_bare_word (string), (WORD_LIST *)NULL);
+ return value;
+ }
+ FREE (td.word);
+ if (value)
+ {
+ if (value->word)
+ remove_quoted_nulls (value->word->word);
+ dequote_list (value);
+ }
+ return (value);
+}
+
/* Expand STRING just as if you were expanding a word, but do not dequote
the resultant WORD_LIST. This is called only from within this file,
and is used to correctly preserve quoted characters when expanding
@@ -2079,7 +2316,8 @@ list_quote_escapes (list)
return list;
}
-#ifdef INCLUDE_UNUSED
+#if 0
+/* UNUSED */
static char *
dequote_escapes (string)
char *string;
@@ -2119,6 +2357,7 @@ dequote_list (list)
return list;
}
+/* Return a new string with the quoted representation of character C. */
static char *
make_quoted_char (c)
int c;
@@ -2843,10 +3082,14 @@ static char *
make_dev_fd_filename (fd)
int fd;
{
- char *ret;
+ char *ret, intbuf[16], *p;
ret = xmalloc (sizeof (DEV_FD_PREFIX) + 4);
- sprintf (ret, "%s%d", DEV_FD_PREFIX, fd);
+
+ strcpy (ret, DEV_FD_PREFIX);
+ p = inttostr (fd, intbuf, sizeof (intbuf));
+ strcpy (ret + sizeof (DEV_FD_PREFIX) - 1, p);
+
add_fifo_list (fd);
return (ret);
}
@@ -2982,6 +3225,14 @@ process_substitute (string, open_for_read_in_child)
open_for_read_in_child ? "reading" : "writing");
exit (127);
}
+ if (open_for_read_in_child)
+ {
+ if (unset_nodelay_mode (fd) < 0)
+ {
+ sys_error ("cannout reset nodelay mode for fd %d", fd);
+ exit (127);
+ }
+ }
#else /* HAVE_DEV_FD */
fd = child_pipe_fd;
#endif /* HAVE_DEV_FD */
@@ -3046,8 +3297,7 @@ read_comsub (fd, quoted)
break;
if (--bufn <= 0)
{
- while ((bufn = read (fd, buf, sizeof(buf))) < 0 && errno == EINTR)
- ;
+ bufn = zread (fd, buf, sizeof (buf));
if (bufn <= 0)
break;
bufp = buf;
@@ -3100,14 +3350,14 @@ read_comsub (fd, quoted)
/* Perform command substitution on STRING. This returns a string,
possibly quoted. */
-static char *
+char *
command_substitute (string, quoted)
char *string;
int quoted;
{
pid_t pid, old_pid, old_pipeline_pgrp;
char *istring;
- int result, fildes[2];
+ int result, fildes[2], function_value;
istring = (char *)NULL;
@@ -3122,6 +3372,18 @@ command_substitute (string, quoted)
jump_to_top_level (EXITPROG);
}
+ /* We're making the assumption here that the command substitution will
+ eventually run a command from the file system. Since we'll run
+ maybe_make_export_env in this subshell before executing that command,
+ the parent shell and any other shells it starts will have to remake
+ the environment. If we make it before we fork, other shells won't
+ have to. Don't bother if we have any temporary variable assignments,
+ though, because the export environment will be remade after this
+ command completes anyway, but do it if all the words to be expanded
+ are variable assignments. */
+ if (subst_assign_varlist == 0 || garglist == 0)
+ maybe_make_export_env (); /* XXX */
+
/* Pipe the output of executing STRING into the current shell. */
if (pipe (fildes) < 0)
{
@@ -3162,9 +3424,11 @@ command_substitute (string, quoted)
if (pid == 0)
{
set_sigint_handler (); /* XXX */
+#if 0
#if defined (JOB_CONTROL)
set_job_control (0);
#endif
+#endif
if (dup2 (fildes[1], 1) < 0)
{
sys_error ("command_substitute: cannot duplicate pipe as fd 1");
@@ -3203,10 +3467,20 @@ command_substitute (string, quoted)
so we don't go back up to main (). */
result = setjmp (top_level);
+ /* If we're running a command substitution inside a shell function,
+ trap `return' so we don't return from the function in the subshell
+ and go off to never-never land. */
+ if (result == 0 && return_catch_flag)
+ function_value = setjmp (return_catch);
+ else
+ function_value = 0;
+
if (result == EXITPROG)
exit (last_command_exit_value);
else if (result)
exit (EXECUTION_FAILURE);
+ else if (function_value)
+ exit (return_catch_value);
else
exit (parse_and_execute (string, "command substitution", SEVAL_NOHIST));
}
@@ -3568,7 +3842,11 @@ parameter_brace_expand_indir (name, var_is_special, quoted)
t = parameter_brace_expand_word (name, var_is_special, quoted);
if (t == 0)
return (t);
+#if 0
temp = parameter_brace_expand_word (t, t[0] == '@' && t[1] == '\0', quoted);
+#else
+ temp = parameter_brace_expand_word (t, SPECIAL_VAR(t, 0), quoted);
+#endif
free (t);
return temp;
}
@@ -3782,7 +4060,7 @@ verify_substring_values (value, substr, vtype, e1p, e2p)
char *value, *substr;
int vtype, *e1p, *e2p;
{
- char *t, *temp1;
+ char *t, *temp1, *temp2;
int len, expok;
#if defined (ARRAY_VARS)
ARRAY *a;
@@ -3823,7 +4101,9 @@ verify_substring_values (value, substr, vtype, e1p, e2p)
if (t)
{
t++;
- temp1 = maybe_expand_string (t, Q_DOUBLE_QUOTES, expand_string);
+ temp2 = savestring (t);
+ temp1 = maybe_expand_string (temp2, Q_DOUBLE_QUOTES, expand_string);
+ free (temp2);
t[-1] = ':';
*e2p = evalexp (temp1, &expok);
free (temp1);
@@ -3978,7 +4258,9 @@ pat_subst (string, pat, rep, mflags)
replen = STRLEN (rep);
l = strlen (string);
ret = xmalloc (replen + l + 2);
- if (mtype == MATCH_BEG)
+ if (replen == 0)
+ strcpy (ret, string);
+ else if (mtype == MATCH_BEG)
{
strcpy (ret, rep);
strcpy (ret + replen, string);
@@ -4071,7 +4353,7 @@ parameter_brace_patsub (varname, value, patsub, quoted)
int quoted;
{
int vtype, mflags;
- char *val, *temp, *pat, *rep, *p;
+ char *val, *temp, *pat, *rep, *p, *lpatsub;
SHELL_VAR *v;
if (value == 0)
@@ -4089,11 +4371,14 @@ parameter_brace_patsub (varname, value, patsub, quoted)
mflags |= MATCH_GLOBREP;
patsub++;
}
+ /* Malloc this because maybe_expand_string or one of the expansion functions
+ in its call chain may free it on a substitution error. */
+ lpatsub = savestring (patsub);
if (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES))
mflags |= MATCH_QUOTED;
- if (rep = quoted_strchr (patsub, '/', ST_BACKSL))
+ if (rep = quoted_strchr (lpatsub, '/', ST_BACKSL))
*rep++ = '\0';
else
rep = (char *)NULL;
@@ -4105,10 +4390,11 @@ parameter_brace_patsub (varname, value, patsub, quoted)
and process substitution. Also perform quote removal. Do not
perform word splitting or filename generation. */
#if 0
- pat = maybe_expand_string (patsub, quoted, expand_string_unsplit);
+ pat = maybe_expand_string (lpatsub, quoted, expand_string_unsplit);
#else
- pat = maybe_expand_string (patsub, (quoted & ~Q_DOUBLE_QUOTES), expand_string_unsplit);
+ pat = maybe_expand_string (lpatsub, (quoted & ~Q_DOUBLE_QUOTES), expand_string_unsplit);
#endif
+
if (rep)
{
if ((mflags & MATCH_QUOTED) == 0)
@@ -4156,6 +4442,7 @@ parameter_brace_patsub (varname, value, patsub, quoted)
FREE (pat);
FREE (rep);
+ free (lpatsub);
return temp;
}
@@ -4265,9 +4552,7 @@ parameter_brace_expand (string, indexp, quoted, quoted_dollar_atp, contains_doll
/* Determine the value of this variable. */
/* Check for special variables, directly referenced. */
- if ((digit (*name) && all_digits (name)) ||
- (name[1] == '\0' && member (*name, "#-?$!@*")) ||
- (want_indir && name[2] == '\0' && member (name[1], "#?@*")))
+ if (SPECIAL_VAR (name, want_indir))
var_is_special++;
/* Check for special expansion things, like the length of a parameter */
@@ -4301,6 +4586,27 @@ parameter_brace_expand (string, indexp, quoted, quoted_dollar_atp, contains_doll
*contains_dollar_at = 1;
}
+ /* Process ${PREFIX*} expansion. */
+ if (want_indir && string[sindex - 1] == RBRACE &&
+ (string[sindex - 2] == '*' || string[sindex - 2] == '@') &&
+ legal_variable_starter (name[1]))
+ {
+ char **x;
+ WORD_LIST *xlist;
+
+ temp1 = savestring (name + 1);
+ number = strlen (temp1);
+ temp1[number - 1] = '\0';
+ x = all_variables_matching_prefix (temp1);
+ xlist = argv_to_word_list (x, 1, 0);
+ temp = string_list_dollar_star (xlist, quoted);
+ free (x);
+ free (xlist);
+ free (temp1);
+ *indexp = sindex;
+ return (temp);
+ }
+
/* Make sure that NAME is valid before trying to go on. */
if (valid_brace_expansion_word (want_indir ? name + 1 : name,
var_is_special) == 0)
@@ -4428,6 +4734,15 @@ parameter_brace_expand (string, indexp, quoted, quoted_dollar_atp, contains_doll
{
/* We don't want the value of the named variable for
anything, just the value of the right hand side. */
+
+ /* XXX -- if we're double-quoted and the named variable is "$@",
+ we want to turn off any special handling of "$@" -- we're not
+ using it, so whatever is on the rhs applies. */
+ if ((quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) && quoted_dollar_atp)
+ *quoted_dollar_atp = 0;
+ if (contains_dollar_at)
+ *contains_dollar_at = 0;
+
if (c == '+')
{
FREE (temp);
@@ -4629,7 +4944,7 @@ param_expand (string, sindex, quoted, expanded_something,
return (temp);
/* XXX */
- /* quoted nulls should be removed if there is anything else
+ /* Quoted nulls should be removed if there is anything else
in the string. */
/* Note that we saw the quoted null so we can add one back at
the end of this function if there are no other characters
@@ -4702,7 +5017,7 @@ comsub:
/* Do POSIX.2d9-style arithmetic substitution. This will probably go
away in a future bash release. */
case '[':
- /* We have to extract the contents of this arithmetic substitution. */
+ /* Extract the contents of this arithmetic substitution. */
t_index = zindex + 1;
temp = extract_arithmetic_subst (string, &t_index);
zindex = t_index;
@@ -4852,6 +5167,7 @@ expand_word_internal (word, quoted, isexp, contains_dollar_at, expanded_somethin
int t_index; /* For calls to string_extract_xxx. */
char ifscmap[256];
+ char twochars[2];
istring = xmalloc (istring_size = DEFAULT_INITIAL_ARRAY_SIZE);
istring[istring_index = 0] = '\0';
@@ -4877,7 +5193,7 @@ expand_word_internal (word, quoted, isexp, contains_dollar_at, expanded_somethin
${abc:-G { I } K } as one word when it should be three. */
if (*temp1 != ' ' && *temp1 != '\t' && *temp1 != '\n')
#endif
- ifscmap[*temp1] = 1;
+ ifscmap[(unsigned char)*temp1] = 1;
/* Begin the expansion. */
@@ -4917,7 +5233,7 @@ add_string:
{
if (string[++sindex] != LPAREN || (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) || posixly_correct)
{
- sindex--;
+ sindex--; /* add_character: label increments sindex */
goto add_character;
}
else
@@ -4992,16 +5308,31 @@ add_string:
if ((quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) && member (c, temp1) == 0)
{
- temp = xmalloc (3);
- temp[0] = '\\'; temp[1] = c; temp[2] = '\0';
+ twochars[0] = '\\';
+ twochars[1] = c;
+ }
+ else if (c == 0)
+ {
+ c = CTLNUL;
+ sindex--; /* add_character: label increments sindex */
+ goto add_character;
}
else
- /* This character is quoted, so add it in quoted mode. */
- temp = make_quoted_char (c);
+ {
+ twochars[0] = CTLESC;
+ twochars[1] = c;
+ }
- if (c)
- sindex++;
- goto add_string;
+ sindex++;
+add_twochars:
+ /* BEFORE jumping here, we need to increment sindex if appropriate */
+ RESIZE_MALLOCED_BUFFER (istring, istring_index, 2, istring_size,
+ DEFAULT_ARRAY_SIZE);
+ istring[istring_index++] = twochars[0];
+ istring[istring_index++] = twochars[1];
+ istring[istring_index] = '\0';
+
+ break;
case '"':
if (quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT|Q_NOQUOTE))
@@ -5127,15 +5458,16 @@ add_string:
temp1 = temp;
temp = quote_string (temp);
free (temp1);
+ goto add_string;
}
else
{
/* Add NULL arg. */
- temp = xmalloc (2);
- temp[0] = CTLNUL;
- temp[1] = '\0';
+ c = CTLNUL;
+ sindex--; /* add_character: label increments sindex */
+ goto add_character;
}
- goto add_string;
+
/* break; */
case '\'':
@@ -5165,15 +5497,35 @@ add_string:
if (temp == 0 && (quoted_state == PARTIALLY_QUOTED))
continue;
- goto add_quoted_string;
+ /* If we have a quoted null expansion, add a quoted NULL to istring. */
+ if (temp == 0)
+ {
+ c = CTLNUL;
+ sindex--; /* add_character: label increments sindex */
+ goto add_character;
+ }
+ else
+ goto add_quoted_string;
+
/* break; */
default:
/* This is the fix for " $@ " */
if ((quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) || (isexp == 0 && ifscmap[c]))
{
- temp = make_quoted_char (c);
- goto dollar_add_string;
+ if (string[sindex]) /* from old goto dollar_add_string */
+ sindex++;
+ if (c == 0)
+ {
+ c = CTLNUL;
+ goto add_character;
+ }
+ else
+ {
+ twochars[0] = CTLESC;
+ twochars[1] = c;
+ goto add_twochars;
+ }
}
add_character:
@@ -5457,12 +5809,10 @@ word_list_split (list)
#define PREPEND_LIST(nlist, elist) \
do { nlist->next = elist; elist = nlist; } while (0)
-static WORD_LIST *varlist = (WORD_LIST *)NULL;
-
/* Separate out any initial variable assignments from TLIST. If set -k has
been executed, remove all assignment statements from TLIST. Initial
variable assignments and other environment assignments are placed
- on VARLIST. */
+ on SUBST_ASSIGN_VARLIST. */
static WORD_LIST *
separate_out_assignments (tlist)
WORD_LIST *tlist;
@@ -5472,10 +5822,10 @@ separate_out_assignments (tlist)
if (!tlist)
return ((WORD_LIST *)NULL);
- if (varlist)
- dispose_words (varlist); /* Clean up after previous error */
+ if (subst_assign_varlist)
+ dispose_words (subst_assign_varlist); /* Clean up after previous error */
- varlist = (WORD_LIST *)NULL;
+ subst_assign_varlist = (WORD_LIST *)NULL;
vp = lp = tlist;
/* Separate out variable assignments at the start of the command.
@@ -5490,12 +5840,12 @@ separate_out_assignments (tlist)
lp = lp->next;
}
- /* If lp != tlist, we have some initial assignment statements. */
- /* We make VARLIST point to the list of assignment words and
- TLIST point to the remaining words. */
+ /* If lp != tlist, we have some initial assignment statements.
+ We make SUBST_ASSIGN_VARLIST point to the list of assignment
+ words and TLIST point to the remaining words. */
if (lp != tlist)
{
- varlist = tlist;
+ subst_assign_varlist = tlist;
/* ASSERT(vp->next == lp); */
vp->next = (WORD_LIST *)NULL; /* terminate variable list */
tlist = lp; /* remainder of word list */
@@ -5511,7 +5861,8 @@ separate_out_assignments (tlist)
/* ASSERT((tlist->word->flags & W_ASSIGNMENT) == 0); */
/* If the -k option is in effect, we need to go through the remaining
- words, separate out the assignment words, and place them on VARLIST. */
+ words, separate out the assignment words, and place them on
+ SUBST_ASSIGN_VARLIST. */
if (place_keywords_in_env)
{
WORD_LIST *tp; /* tp == running pointer into tlist */
@@ -5526,9 +5877,9 @@ separate_out_assignments (tlist)
if (lp->word->flags & W_ASSIGNMENT)
{
/* Found an assignment statement, add this word to end of
- varlist (vp). */
- if (!varlist)
- varlist = vp = lp;
+ subst_assign_varlist (vp). */
+ if (!subst_assign_varlist)
+ subst_assign_varlist = vp = lp;
else
{
vp->next = lp;
@@ -5642,7 +5993,7 @@ glob_expand_word_list (tlist, eflags)
if (GLOB_FAILED (glob_array))
{
- glob_array = (char **) xmalloc (sizeof (char *));
+ glob_array = (char **)xmalloc (sizeof (char *));
glob_array[0] = (char *)NULL;
}
@@ -5865,18 +6216,17 @@ expand_word_list_internal (list, eflags)
if (list == 0)
return ((WORD_LIST *)NULL);
- new_list = copy_word_list (list);
-
+ garglist = new_list = copy_word_list (list);
if (eflags & WEXP_VARASSIGN)
{
- new_list = separate_out_assignments (new_list);
+ garglist = new_list = separate_out_assignments (new_list);
if (new_list == 0)
{
- if (varlist)
+ if (subst_assign_varlist)
{
/* All the words were variable assignments, so they are placed
into the shell's environment. */
- for (temp_list = varlist; temp_list; temp_list = temp_list->next)
+ for (temp_list = subst_assign_varlist; temp_list; temp_list = temp_list->next)
{
this_command_name = (char *)NULL; /* no arithmetic errors */
tint = do_assignment (temp_list->word->word);
@@ -5888,8 +6238,8 @@ expand_word_list_internal (list, eflags)
jump_to_top_level (FORCE_EOF);
}
}
- dispose_words (varlist);
- varlist = (WORD_LIST *)NULL;
+ dispose_words (subst_assign_varlist);
+ subst_assign_varlist = (WORD_LIST *)NULL;
}
return ((WORD_LIST *)NULL);
}
@@ -5922,7 +6272,7 @@ expand_word_list_internal (list, eflags)
new_list = dequote_list (new_list);
}
- if ((eflags & WEXP_VARASSIGN) && varlist)
+ if ((eflags & WEXP_VARASSIGN) && subst_assign_varlist)
{
Function *assign_func;
@@ -5931,7 +6281,7 @@ expand_word_list_internal (list, eflags)
environment. */
assign_func = new_list ? assign_in_env : do_assignment;
- for (temp_list = varlist; temp_list; temp_list = temp_list->next)
+ for (temp_list = subst_assign_varlist; temp_list; temp_list = temp_list->next)
{
this_command_name = (char *)NULL;
tint = (*assign_func) (temp_list->word->word);
@@ -5945,8 +6295,8 @@ expand_word_list_internal (list, eflags)
}
}
- dispose_words (varlist);
- varlist = (WORD_LIST *)NULL;
+ dispose_words (subst_assign_varlist);
+ subst_assign_varlist = (WORD_LIST *)NULL;
}
#if 0
diff --git a/subst.h b/subst.h
index b3f7ab21..76df855f 100644
--- a/subst.h
+++ b/subst.h
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if !defined (_SUBST_H_)
#define _SUBST_H_
@@ -108,6 +108,9 @@ extern int number_of_args __P((void));
takes care of quote removal. */
extern WORD_LIST *expand_string_unsplit __P((char *, int));
+/* Expand a prompt string. */
+extern WORD_LIST *expand_prompt_string __P((char *, int));
+
/* Expand STRING just as if you were expanding a word. This also returns
a list of words. Note that filename globbing is *NOT* done for word
or string expansion, just when the shell is expanding a command. This
@@ -167,16 +170,18 @@ extern WORD_LIST *expand_words_no_vars __P((WORD_LIST *));
command substitution, arithmetic expansion, and word splitting. */
extern WORD_LIST *expand_words_shellexp __P((WORD_LIST *));
+extern char *command_substitute __P((char *, int));
extern char *pat_subst __P((char *, char *, char *, int));
extern void unlink_fifo_list __P((void));
+extern WORD_LIST *list_string_with_quotes __P((char *));
+
#if defined (ARRAY_VARS)
extern int array_expand_index __P((char *, int));
extern int valid_array_reference __P((char *));
extern char *get_array_value __P((char *, int));
extern SHELL_VAR *array_variable_part __P((char *, char **, int *));
-extern WORD_LIST *list_string_with_quotes __P((char *));
extern char *extract_array_assignment_list __P((char *, int *));
#endif
@@ -185,6 +190,13 @@ extern char *remove_backslashes __P((char *));
extern char *cond_expand_word __P((WORD_DESC *, int));
#endif
+#if defined (READLINE)
+extern int char_is_quoted __P((char *, int));
+extern int unclosed_pair __P((char *, int, char *));
+extern int skip_to_delim __P((char *, int, char *));
+extern WORD_LIST *split_at_delims __P((char *, int, char *, int, int *, int *));
+#endif
+
/* How to determine the quoted state of the character C. */
#define QUOTED_CHAR(c) ((c) == CTLESC)
diff --git a/support/Makefile.in b/support/Makefile.in
index 6c9e9abd..c7e41120 100644
--- a/support/Makefile.in
+++ b/support/Makefile.in
@@ -8,6 +8,22 @@
#
# Currently only man2html is built
#
+#
+# Copyright (C) 1998 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
#
# Boilerplate
@@ -21,6 +37,8 @@ RM = rm -f
SHELL = @MAKE_SHELL@
CC = @CC@
+EXEEXT = @EXEEXT@
+
#
# Compiler options:
#
@@ -47,9 +65,9 @@ OBJ1 = man2html.o
$(RM) $@
$(CC) -c $(CCFLAGS) $<
-all: man2html
+all: man2html$(EXEEXT)
-man2html: $(OBJ1)
+man2html$(EXEEXT): $(OBJ1)
$(CC) $(CCFLAGS) $(OBJ1) -o $@ ${LIBS}
clean:
diff --git a/support/SYMLINKS b/support/SYMLINKS
index 93bde6fb..119acbdc 100644
--- a/support/SYMLINKS
+++ b/support/SYMLINKS
@@ -6,19 +6,12 @@
lib/readline/tilde.c ../tilde/tilde.c
lib/readline/tilde.h ../tilde/tilde.h
#
-lib/readline/ansi_stdlib.h ../posixheaders/ansi_stdlib.h
-lib/readline/posixdir.h ../posixheaders/posixdir.h
-lib/readline/posixjmp.h ../posixheaders/posixjmp.h
-lib/readline/posixstat.h ../posixheaders/posixstat.h
-lib/readline/rlstdc.h ../posixheaders/stdc.h
-lib/readline/xmalloc.c ../malloc/xmalloc.c
+lib/readline/ansi_stdlib.h ../../include/ansi_stdlib.h
+lib/readline/posixdir.h ../../include/posixdir.h
+lib/readline/posixjmp.h ../../include/posixjmp.h
+lib/readline/posixstat.h ../../include/posixstat.h
+#lib/readline/rlstdc.h ../../include/stdc.h
+#lib/readline/xmalloc.c ../malloc/xmalloc.c
#
-#lib/tilde/memalloc.h ../posixheaders/memalloc.h
+#lib/tilde/memalloc.h ../../include/memalloc.h
#
-ansi_stdlib.h lib/posixheaders/ansi_stdlib.h
-filecntl.h lib/posixheaders/filecntl.h
-memalloc.h lib/posixheaders/memalloc.h
-posixdir.h lib/posixheaders/posixdir.h
-posixjmp.h lib/posixheaders/posixjmp.h
-posixstat.h lib/posixheaders/posixstat.h
-stdc.h lib/posixheaders/stdc.h
diff --git a/support/bashbug.sh b/support/bashbug.sh
index 06fb93d2..cab105de 100644
--- a/support/bashbug.sh
+++ b/support/bashbug.sh
@@ -22,6 +22,46 @@ PATH=/bin:/usr/bin:/usr/local/bin:$PATH
export PATH
TEMP=/tmp/bbug.$$
+USAGE="Usage: $0 [--help] [--version] [bug-report-email-address]"
+VERSTR="GNU bashbug, version ${RELEASE}.${PATCHLEVEL}-${RELSTATUS}"
+
+do_help= do_version=
+
+while [ $# -gt 0 ]; do
+ case "$1" in
+ --help) shift ; do_help=y ;;
+ --version) shift ; do_version=y ;;
+ --) shift ; break ;;
+ -*) echo "bashbug: ${1}: invalid option" >&2
+ echo "$USAGE" >& 2
+ exit 2 ;;
+ *) break ;;
+ esac
+done
+
+if [ -n "$do_version" ]; then
+ echo "${VERSTR}"
+ exit 0
+fi
+
+if [ -n "$do_help" ]; then
+ echo "${VERSTR}"
+ echo "${USAGE}"
+ echo
+ cat << HERE_EOF
+Bashbug is used to send mail to the Bash maintainers
+for when Bash doesn't behave like you'd like, or expect.
+
+Bashbug will start up your editor (as defined by the shell's
+EDITOR environment variable) with a preformatted bug report
+template for you to fill in. The report will be mailed to the
+bash maintainers by default. See the manual for details.
+
+If you invoke bashbug by accident, just quit your editor without
+saving any changes to the template, and no bug report will be sent.
+HERE_EOF
+ exit 0
+fi
# Figure out how to echo a string without a trailing newline
N=`echo 'hi there\c'`
@@ -33,12 +73,13 @@ esac
BASHTESTERS="bash-testers@po.cwru.edu"
case "$RELSTATUS" in
-alpha*|beta*) BUGBASH=chet@po.cwru.edu ;;
-*) BUGBASH=bug-bash@gnu.org ;;
+alpha*|beta*|devel*) BUGBASH=chet@po.cwru.edu ;;
+*) BUGBASH=bug-bash@gnu.org ;;
esac
case "$RELSTATUS" in
-alpha*|beta*) echo "$0: This is a testing release. Would you like your bug report"
+alpha*|beta*|devel*)
+ echo "$0: This is a testing release. Would you like your bug report"
echo "$0: to be sent to the bash-testers mailing list?"
echo $n "$0: Send to bash-testers? $c"
read ans
@@ -49,7 +90,31 @@ esac
BUGADDR="${1-$BUGBASH}"
-: ${EDITOR=emacs}
+if [ -z "$DEFEDITOR" ] && [ -z "$EDITOR" ]; then
+ if [ -x /usr/local/bin/ce ]; then
+ DEFEDITOR=ce
+ elif [ -x /usr/local/bin/emacs ]; then
+ DEFEDITOR=emacs
+ elif [ -x /usr/contrib/bin/emacs ]; then
+ DEFEDITOR=emacs
+ elif [ -x /usr/bin/emacs ]; then
+ DEFEDITOR=emacs
+ elif [ -x /usr/bin/xemacs ]; then
+ DEFEDITOR=xemacs
+ elif [ -x /usr/contrib/bin/jove ]; then
+ DEFEDITOR=jove
+ elif [ -x /usr/local/bin/jove ]; then
+ DEFEDITOR=jove
+ elif [ -x /usr/bin/vi ]; then
+ DEFEDITOR=vi
+ else
+ echo "$0: No default editor found: attempting to use vi" >&2
+ DEFEDITOR=vi
+ fi
+fi
+
+
+: ${EDITOR=$DEFEDITOR}
: ${USER=${LOGNAME-`whoami`}}
@@ -63,10 +128,13 @@ fi
if [ -f /usr/lib/sendmail ] ; then
RMAIL="/usr/lib/sendmail"
+ SMARGS="-i -t"
elif [ -f /usr/sbin/sendmail ] ; then
RMAIL="/usr/sbin/sendmail"
+ SMARGS="-i -t"
else
RMAIL=rmail
+ SMARGS="$BUGADDR"
fi
# this is raceable
@@ -135,7 +203,7 @@ case "$ans" in
[Nn]*) exit 0 ;;
esac
-${RMAIL} $BUGADDR < $TEMP || {
+${RMAIL} $SMARGS < $TEMP || {
cat $TEMP >> $HOME/dead.bashbug
echo "$0: mail failed: report saved in $HOME/dead.bashbug" >&2
}
diff --git a/support/config.guess b/support/config.guess
index 66a24282..ad5983e7 100755
--- a/support/config.guess
+++ b/support/config.guess
@@ -35,6 +35,19 @@
# (but try to keep the structure clean).
#
+# Use $HOST_CC if defined. $CC may point to a cross-compiler
+if test x"$CC_FOR_BUILD" = x; then
+ if test x"$HOST_CC" != x; then
+ CC_FOR_BUILD="$HOST_CC"
+ else
+ if test x"$CC" != x; then
+ CC_FOR_BUILD="$CC"
+ else
+ CC_FOR_BUILD=cc
+ fi
+ fi
+fi
+
# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
# (ghazi@noc.rutgers.edu 8/24/94.)
if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
@@ -57,7 +70,8 @@ esac
REL_LEVEL=`expr "$UNAME_RELEASE" : '[^0-9]*[0-9]*.\([0-9]*\)'` # 1
REL_SUBLEVEL=`expr "$UNAME_RELEASE" : '[^0-9]*[0-9]*.[0-9]*.\([0-9]*\)'` # 2
-trap 'rm -f dummy.c dummy.o dummy; exit 1' 1 2 15
+dummy=dummy-$$
+trap 'rm -f $dummy.c $dummy.o $dummy; exit 1' 1 2 15
# Some versions of i386 SVR4.2 make `uname' equivalent to `uname -n', which
# is contrary to all other versions of uname
@@ -81,9 +95,6 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
i?86:OpenBSD:*:*)
echo ${UNAME_MACHINE}-pc-openbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
exit 0 ;;
- i?86:FreeBSD:*:*)
- echo ${UNAME_MACHINE}-pc-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
- exit 0 ;;
sparc:NetBSD:*:*)
echo sparc-unknown-netbsd${UNAME_RELEASE}
exit 0 ;;
@@ -151,17 +162,11 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
*:QNX:*:42*)
echo i386-qssl-qnx`echo ${UNAME_VERSION}`
exit 0 ;;
- BeBox:BeOS:*:*)
- echo powerpc-be-beos
- exit 0 ;;
- BeMac:BeOS:*:*)
- echo powerpc-apple-beos
- exit 0 ;;
- BePC:BeOS:*:*)
- echo i586-pc-beos
+ Alpha*:Windows:NT:*:SP*)
+ echo alpha-pc-opennt
exit 0 ;;
- SX-4:SUPER-UX:*:*)
- echo sx4-nec-superux${UNAME_RELEASE}
+ *:Windows:NT:*:SP*)
+ echo intel-pc-opennt
exit 0 ;;
# end cases added for Bash
alpha:OSF1:*:*)
@@ -172,7 +177,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
# A Tn.n version is a released field test version.
# A Xn.n version is an unreleased experimental baselevel.
# 1.2 uses "1.2" for uname -r.
- cat <<EOF >dummy.s
+ cat <<EOF >$dummy.s
.globl main
.ent main
main:
@@ -189,9 +194,9 @@ main:
ret \$31,(\$26),1
.end main
EOF
- ${CC-cc} dummy.s -o dummy 2>/dev/null
+ $CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null
if test "$?" = 0 ; then
- ./dummy
+ ./$dummy
case "$?" in
7)
UNAME_MACHINE="alpha"
@@ -210,9 +215,15 @@ EOF
;;
esac
fi
- rm -f dummy.s dummy
- echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr [[A-Z]] [[a-z]]`
- exit 0 ;;
+ rm -f $dummy.s $dummy
+ echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+ exit 0 ;;
+ Alpha\ *:Windows_NT*:*)
+ # How do we know it's Interix rather than the generic POSIX subsystem?
+ # Should we change UNAME_MACHINE based on the output of uname instead
+ # of the specific Alpha model?
+ echo alpha-pc-interix
+ exit 0 ;;
21064:Windows_NT:50:3)
echo alpha-dec-winnt3.5
exit 0 ;;
@@ -255,7 +266,7 @@ EOF
SR2?01:HI-UX/MPP:*:*)
echo hppa1.1-hitachi-hiuxmpp
exit 0;;
- Pyramid*:OSx*:*:*|MIS*:OSx*:*:*)
+ Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
# akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
if test "`(/bin/universe) 2>/dev/null`" = att ; then
echo pyramid-pyramid-sysv3
@@ -263,9 +274,12 @@ EOF
echo pyramid-pyramid-bsd
fi
exit 0 ;;
- NILE:*:*:dcosx)
+ NILE:*:*:*:dcosx)
echo pyramid-pyramid-svr4
exit 0 ;;
+ sun4H:SunOS:5.*:*)
+ echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit 0 ;;
sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
exit 0 ;;
@@ -287,7 +301,7 @@ EOF
# Japanese Language versions have a version number like `4.1.3-JL'.
echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
exit 0 ;;
- sun3*:SunOS:*:*|sun:SunOS:*:*)
+ sun3*:SunOS:*:*)
echo m68k-sun-sunos${UNAME_RELEASE}
exit 0 ;;
sun*:*:4.2BSD:*)
@@ -309,19 +323,45 @@ EOF
echo m68k-atari-netbsd${UNAME_RELEASE}
exit 0 ;;
atari*:OpenBSD:*:*)
- echo m68k-atari-openbsd${UNAME_RELEASE}
+ echo m68k-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
+ # The situation for MiNT is a little confusing. The machine name
+ # can be virtually everything (everything which is not
+ # "atarist" or "atariste" at least should have a processor
+ # > m68000). The system name ranges from "MiNT" over "FreeMiNT"
+ # to the lowercase version "mint" (or "freemint"). Finally
+ # the system name "TOS" denotes a system which is actually not
+ # MiNT. But MiNT is downward compatible to TOS, so this should
+ # be no problem.
+ atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
+ echo m68k-atari-mint${UNAME_RELEASE}
+ exit 0 ;;
+ atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
+ echo m68k-atari-mint${UNAME_RELEASE}
+ exit 0 ;;
+ *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
+ echo m68k-atari-mint${UNAME_RELEASE}
+ exit 0 ;;
+ milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
+ echo m68k-milan-mint${UNAME_RELEASE}
+ exit 0 ;;
+ hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
+ echo m68k-hades-mint${UNAME_RELEASE}
+ exit 0 ;;
+ *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
+ echo m68k-unknown-mint${UNAME_RELEASE}
+ exit 0 ;;
sun3*:NetBSD:*:*)
echo m68k-sun-netbsd${UNAME_RELEASE}
exit 0 ;;
sun3*:OpenBSD:*:*)
- echo m68k-sun-openbsd${UNAME_RELEASE}
+ echo m68k-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
mac68k:NetBSD:*:*)
echo m68k-apple-netbsd${UNAME_RELEASE}
exit 0 ;;
mac68k:OpenBSD:*:*)
- echo m68k-apple-openbsd${UNAME_RELEASE}
+ echo m68k-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
mvme68k:OpenBSD:*:*)
echo m68k-unknown-openbsd${UNAME_RELEASE}
@@ -329,15 +369,15 @@ EOF
mvme88k:OpenBSD:*:*)
echo m88k-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
- Power?Macintosh:Rhapsody:*:*)
- echo powerpc-apple-rhapsody${UNAME_RELEASE}
- exit 0 ;;
- *:Rhapsody:*:*)
- echo ${UNAME_MACHINE}-unknown-rhapsody${UNAME_RELEASE}
- exit 0 ;;
+ *:"Mac OS":*:*)
+ echo `uname -p`-apple-macos${UNAME_RELEASE}
+ exit 0 ;;
powerpc:machten:*:*)
echo powerpc-apple-machten${UNAME_RELEASE}
exit 0 ;;
+ macppc:NetBSD:*:*)
+ echo powerpc-apple-netbsd${UNAME_RELEASE}
+ exit 0 ;;
RISC*:Mach:*:*)
echo mips-dec-mach_bsd4.3
exit 0 ;;
@@ -347,12 +387,16 @@ EOF
VAX*:ULTRIX*:*:*)
echo vax-dec-ultrix${UNAME_RELEASE}
exit 0 ;;
- 2020:CLIX:*:*)
+ 2020:CLIX:*:* | 2430:CLIX:*:*)
echo clipper-intergraph-clix${UNAME_RELEASE}
exit 0 ;;
mips:*:*:UMIPS | mips:*:*:RISCos)
- sed 's/^ //' << EOF >dummy.c
- int main (argc, argv) int argc; char **argv; {
+ sed 's/^ //' << EOF >$dummy.c
+#ifdef __cplusplus
+ int main (int argc, char *argv[]) {
+#else
+ int main (argc, argv) int argc; char *argv[]; {
+#endif
#if defined (host_mips) && defined (MIPSEB)
#if defined (SYSTYPE_SYSV)
printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0);
@@ -367,10 +411,10 @@ EOF
exit (-1);
}
EOF
- ${CC-cc} dummy.c -o dummy \
- && ./dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \
- && rm dummy.c dummy && exit 0
- rm -f dummy.c dummy
+ $CC_FOR_BUILD $dummy.c -o $dummy \
+ && ./$dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \
+ && rm $dummy.c $dummy && exit 0
+ rm -f $dummy.c $dummy
echo mips-mips-riscos${UNAME_RELEASE}
exit 0 ;;
Night_Hawk:Power_UNIX:*:*)
@@ -389,13 +433,14 @@ EOF
# DG/UX returns AViiON for all architectures
UNAME_PROCESSOR=`/usr/bin/uname -p`
if [ $UNAME_PROCESSOR = mc88100 -o $UNAME_PROCESSOR = mc88110 ] ; then
- if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx \
+ if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx \
-o ${TARGET_BINARY_INTERFACE}x = x ] ; then
echo m88k-dg-dgux${UNAME_RELEASE}
- else
+ else
echo m88k-dg-dguxbcs${UNAME_RELEASE}
- fi
- else echo i586-dg-dgux${UNAME_RELEASE}
+ fi
+ else
+ echo i586-dg-dgux${UNAME_RELEASE}
fi
exit 0 ;;
M88*:DolphinOS:*:*) # DolphinOS (SVR3)
@@ -422,7 +467,7 @@ EOF
exit 0 ;;
*:AIX:2:3)
if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
- sed 's/^ //' << EOF >dummy.c
+ sed 's/^ //' << EOF >$dummy.c
#include <sys/systemcfg.h>
main()
@@ -433,8 +478,8 @@ EOF
exit(0);
}
EOF
- ${CC-cc} dummy.c -o dummy && ./dummy && rm dummy.c dummy && exit 0
- rm -f dummy.c dummy
+ $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm $dummy.c $dummy && exit 0
+ rm -f $dummy.c $dummy
echo rs6000-ibm-aix3.2.5
elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
echo rs6000-ibm-aix3.2.4
@@ -443,7 +488,8 @@ EOF
fi
exit 0 ;;
*:AIX:*:4)
- if /usr/sbin/lsattr -EHl proc0 | grep POWER >/dev/null 2>&1; then
+ IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | head -1 | awk '{ print $1 }'`
+ if /usr/sbin/lsattr -EHl ${IBM_CPU_ID} | grep POWER >/dev/null 2>&1; then
IBM_ARCH=rs6000
else
IBM_ARCH=powerpc
@@ -484,17 +530,46 @@ EOF
case "${UNAME_MACHINE}" in
9000/31? ) HP_ARCH=m68000 ;;
9000/[34]?? ) HP_ARCH=m68k ;;
- 9000/78? | 9000/80[24] | 9000/8[67]1 | 9000/8[78]9 | 9000/893 )
- HP_ARCH=hppa2.0 ;;
- 9000/7?? | 9000/8?[13679] | 9000/892 )
- HP_ARCH=hppa1.1 ;;
- 9000/[68]?? ) HP_ARCH=hppa1.0 ;;
+ 9000/[678][0-9][0-9])
+ sed 's/^ //' << EOF >$dummy.c
+ #include <stdlib.h>
+ #include <unistd.h>
+
+ int main ()
+ {
+ #if defined(_SC_KERNEL_BITS)
+ long bits = sysconf(_SC_KERNEL_BITS);
+ #endif
+ long cpu = sysconf (_SC_CPU_VERSION);
+
+ switch (cpu)
+ {
+ case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
+ case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
+ case CPU_PA_RISC2_0:
+ #if defined(_SC_KERNEL_BITS)
+ switch (bits)
+ {
+ case 64: puts ("hppa2.0w"); break;
+ case 32: puts ("hppa2.0n"); break;
+ default: puts ("hppa2.0"); break;
+ } break;
+ #else /* !defined(_SC_KERNEL_BITS) */
+ puts ("hppa2.0"); break;
+ #endif
+ default: puts ("hppa1.0"); break;
+ }
+ exit (0);
+ }
+EOF
+ ($CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null ) && HP_ARCH=`./$dummy`
+ rm -f $dummy.c $dummy
esac
HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
echo ${HP_ARCH}-hp-hpux${HPUX_REV}
exit 0 ;;
3050*:HI-UX:*:*)
- sed 's/^ //' << EOF >dummy.c
+ sed 's/^ //' << EOF >$dummy.c
#include <unistd.h>
int
main ()
@@ -519,8 +594,8 @@ EOF
exit (0);
}
EOF
- ${CC-cc} dummy.c -o dummy && ./dummy && rm dummy.c dummy && exit 0
- rm -f dummy.c dummy
+ $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm $dummy.c $dummy && exit 0
+ rm -f $dummy.c $dummy
echo unknown-hitachi-hiuxwe2
exit 0 ;;
9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
@@ -529,6 +604,9 @@ EOF
9000/8??:4.3bsd:*:*)
echo hppa1.0-hp-bsd
exit 0 ;;
+ *9??*:MPE/iX:*:*)
+ echo hppa1.0-hp-mpeix
+ exit 0 ;;
hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
echo hppa1.1-hp-osf
exit 0 ;;
@@ -537,14 +615,17 @@ EOF
exit 0 ;;
i?86:OSF1:*:*)
if [ -x /usr/sbin/sysversion ] ; then
- echo ${UNAME_MACHINE}-pc-osf1mk
+ echo ${UNAME_MACHINE}-unknown-osf1mk
else
- echo ${UNAME_MACHINE}-pc-osf1
+ echo ${UNAME_MACHINE}-unknown-osf1
fi
exit 0 ;;
parisc*:Lites*:*:*)
echo hppa1.1-hp-lites
exit 0 ;;
+ hppa*:OpenBSD:*:*)
+ echo hppa-unknown-openbsd
+ exit 0 ;;
C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
echo c1-convex-bsd
exit 0 ;;
@@ -577,11 +658,14 @@ EOF
CRAY*TS:*:*:*)
echo t90-cray-unicos${UNAME_RELEASE}
exit 0 ;;
+ CRAY*T3E:*:*:*)
+ echo alpha-cray-unicosmk${UNAME_RELEASE}
+ exit 0 ;;
CRAY-2:*:*:*)
echo cray2-cray-unicos
exit 0 ;;
F300:UNIX_System_V:*:*)
- FUJITSU_SYS=`uname -p | tr [A-Z] [a-z] | sed -e 's/\///'`
+ FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
echo "f300-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
exit 0 ;;
@@ -591,14 +675,26 @@ EOF
hp3[0-9][05]:NetBSD:*:*)
echo m68k-hp-netbsd${UNAME_RELEASE}
exit 0 ;;
- hp3[0-9][05]:OpenBSD:*:*)
- echo m68k-hp-openbsd${UNAME_RELEASE}
- exit 0 ;;
- i?86:BSD/386:*:* | *:BSD/OS:*:*)
+ hp300:OpenBSD:*:*)
+ echo m68k-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ i?86:BSD/386:*:* | i?86:BSD/OS:*:*)
echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
exit 0 ;;
+ sparc*:BSD/OS:*:*)
+ echo sparc-unknown-bsdi${UNAME_RELEASE}
+ exit 0 ;;
+ *:BSD/OS:*:*)
+ echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
+ exit 0 ;;
*:FreeBSD:*:*)
- echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
+ if test -x /usr/bin/objformat; then
+ if test "elf" = "`/usr/bin/objformat`"; then
+ echo ${UNAME_MACHINE}-unknown-freebsdelf`echo ${UNAME_RELEASE}|sed -e 's/[-_].*//'`
+ exit 0
+ fi
+ fi
+ echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-=(].*//'`
exit 0 ;;
*:NetBSD:*:*)
echo ${UNAME_MACHINE}-unknown-netbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
@@ -607,14 +703,23 @@ EOF
echo ${UNAME_MACHINE}-unknown-openbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
exit 0 ;;
i*:CYGWIN*:*)
- echo i386-pc-cygwin32
+ echo ${UNAME_MACHINE}-pc-cygwin32
exit 0 ;;
i*:MINGW*:*)
- echo i386-pc-mingw32
+ echo ${UNAME_MACHINE}-pc-mingw32
exit 0 ;;
+ i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
+ # How do we know it's Interix rather than the generic POSIX subsystem?
+ # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
+ # UNAME_MACHINE based on the output of uname instead of i386?
+ echo i386-pc-interix
+ exit 0 ;;
+ i*:UWIN*:*)
+ echo ${UNAME_MACHINE}-pc-uwin
+ exit 0 ;;
p*:CYGWIN*:*)
- echo powerpcle-unknown-cygwin32
- exit 0 ;;
+ echo powerpcle-unknown-cygwin
+ exit 0 ;;
prep*:SunOS:5.*:*)
echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
exit 0 ;;
@@ -622,9 +727,17 @@ EOF
echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
exit 0 ;;
*:Linux:*:*)
+ # uname on the ARM produces all sorts of strangeness, and we need to
+ # filter it out.
+ case "$UNAME_MACHINE" in
+ armv*) UNAME_MACHINE=$UNAME_MACHINE ;;
+ arm* | sa110*) UNAME_MACHINE="arm" ;;
+ esac
+
# The BFD linker knows what the default object file format is, so
- # first see if it will tell us.
- ld_help_string=`ld --help 2>&1`
+ # first see if it will tell us. cd to the root directory to prevent
+ # problems with other programs or directories called `ld' in the path.
+ ld_help_string=`cd /; ld --help 2>&1`
ld_supported_emulations=`echo $ld_help_string \
| sed -ne '/supported emulations:/!d
s/[ ][ ]*/ /g
@@ -632,15 +745,46 @@ EOF
s/ .*//
p'`
case "$ld_supported_emulations" in
+ *ia64) echo "${UNAME_MACHINE}-unknown-linux" ; exit 0 ;;
i?86linux) echo "${UNAME_MACHINE}-pc-linux-gnuaout" ; exit 0 ;;
i?86coff) echo "${UNAME_MACHINE}-pc-linux-gnucoff" ; exit 0 ;;
sparclinux) echo "${UNAME_MACHINE}-unknown-linux-gnuaout" ; exit 0 ;;
+ armlinux) echo "${UNAME_MACHINE}-unknown-linux-gnuaout" ; exit 0 ;;
m68klinux) echo "${UNAME_MACHINE}-unknown-linux-gnuaout" ; exit 0 ;;
- elf32ppc) echo "powerpc-unknown-linux-gnu" ; exit 0 ;;
- esac
+ elf32ppc | elf32ppclinux)
+ # Determine Lib Version
+ cat >$dummy.c <<EOF
+#include <features.h>
+#if defined(__GLIBC__)
+extern char __libc_version[];
+extern char __libc_release[];
+#endif
+main(argc, argv)
+ int argc;
+ char *argv[];
+{
+#if defined(__GLIBC__)
+ printf("%s %s\n", __libc_version, __libc_release);
+#else
+ printf("unkown\n");
+#endif
+ return 0;
+}
+EOF
+ LIBC=""
+ $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null
+ if test "$?" = 0 ; then
+ ./$dummy | grep 1\.99 > /dev/null
+ if test "$?" = 0 ; then
+ LIBC="libc1"
+ fi
+ fi
+ rm -f $dummy.c $dummy
+ echo powerpc-unknown-linux-gnu${LIBC} ; exit 0 ;;
+ esac
if test "${UNAME_MACHINE}" = "alpha" ; then
- sed 's/^ //' <<EOF >dummy.s
+ sed 's/^ //' <<EOF >$dummy.s
.globl main
.ent main
main:
@@ -658,9 +802,9 @@ EOF
.end main
EOF
LIBC=""
- ${CC-cc} dummy.s -o dummy 2>/dev/null
+ $CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null
if test "$?" = 0 ; then
- ./dummy
+ ./$dummy
case "$?" in
7)
UNAME_MACHINE="alpha"
@@ -679,20 +823,21 @@ EOF
;;
esac
- objdump --private-headers dummy | \
+ objdump --private-headers $dummy | \
grep ld.so.1 > /dev/null
if test "$?" = 0 ; then
LIBC="libc1"
fi
fi
- rm -f dummy.s dummy
+ rm -f $dummy.s $dummy
echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} ; exit 0
elif test "${UNAME_MACHINE}" = "mips" ; then
- cat >dummy.c <<EOF
-main(argc, argv)
- int argc;
- char *argv[];
-{
+ cat >$dummy.c <<EOF
+#ifdef __cplusplus
+int main (int argc, char *argv[]) {
+#else
+int main (argc, argv) int argc; char *argv[]; {
+#endif
#ifdef __MIPSEB__
printf ("%s-unknown-linux-gnu\n", argv[1]);
#endif
@@ -702,8 +847,8 @@ main(argc, argv)
return 0;
}
EOF
- ${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy "${UNAME_MACHINE}" && rm dummy.c dummy && exit 0
- rm -f dummy.c dummy
+ $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm $dummy.c $dummy && exit 0
+ rm -f $dummy.c $dummy
else
# Either a pre-BFD a.out linker (linux-gnuoldld)
# or one that does not give us useful --help.
@@ -722,12 +867,13 @@ EOF
;;
esac
# Determine whether the default compiler is a.out or elf
- cat >dummy.c <<EOF
+ cat >$dummy.c <<EOF
#include <features.h>
-main(argc, argv)
- int argc;
- char *argv[];
-{
+#ifdef __cplusplus
+ int main (int argc, char *argv[]) {
+#else
+ int main (argc, argv) int argc; char *argv[]; {
+#endif
#ifdef __ELF__
# ifdef __GLIBC__
# if __GLIBC__ >= 2
@@ -744,8 +890,8 @@ main(argc, argv)
return 0;
}
EOF
- ${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy "${UNAME_MACHINE}" && rm dummy.c dummy && exit 0
- rm -f dummy.c dummy
+ ${CC-cc} $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm $dummy.c $dummy && exit 0
+ rm -f $dummy.c $dummy
fi ;;
# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. earlier versions
# are messed up and put the nodename in both sysname and nodename.
@@ -754,9 +900,9 @@ EOF
exit 0 ;;
# added by chet for bash based on usenet posting from <hops@sco.com> and
# documentation on SCO's web site -- UnixWare 7 (SVR5)
- i?86:UnixWare:5*:*)
- echo ${UNAME_MACHINE}-pc-sysv5uw${UNAME_VERSION}
- exit 0 ;;
+# i?86:UnixWare:5*:*)
+# echo ${UNAME_MACHINE}-pc-sysv5uw${UNAME_VERSION}
+# exit 0 ;;
i?86:UNIX_SV:4.2MP:2.*)
# Unixware is an offshoot of SVR4, but it has its own version
# number series starting with 2...
@@ -772,6 +918,14 @@ EOF
echo ${UNAME_MACHINE}-pc-sysv${UNAME_RELEASE}
fi
exit 0 ;;
+ i?86:*:5:7*)
+ UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')`
+ (/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486
+ (/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) && UNAME_MACHINE=i586
+ (/bin/uname -X|egrep '^Machine.*Pent.*II' >/dev/null) && UNAME_MACHINE=i686
+ (/bin/uname -X|egrep '^Machine.*Pentium Pro' >/dev/null) && UNAME_MACHINE=i585
+ echo ${UNAME_MACHINE}-${UNAME_SYSTEM}${UNAME_VERSION}-sysv${UNAME_RELEASE}
+ exit 0 ;;
i?86:*:3.2:*)
if test -f /usr/options/cb.name; then
UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
@@ -781,6 +935,10 @@ EOF
(/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486
(/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \
&& UNAME_MACHINE=i586
+ (/bin/uname -X|egrep '^Machine.*Pent ?II' >/dev/null) \
+ && UNAME_MACHINE=i686
+ (/bin/uname -X|egrep '^Machine.*Pentium Pro' >/dev/null) \
+ && UNAME_MACHINE=i686
echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
else
echo ${UNAME_MACHINE}-pc-sysv32
@@ -827,7 +985,7 @@ EOF
m68*:LynxOS:2.*:*)
echo m68k-unknown-lynxos${UNAME_RELEASE}
exit 0 ;;
- i?86:LynxOS:2.*:*)
+ i?86:LynxOS:2.*:* | i?86:LynxOS:3.[01]*:*)
echo i386-pc-lynxos${UNAME_RELEASE}
exit 0 ;;
TSUNAMI:LynxOS:2.*:*)
@@ -872,23 +1030,40 @@ EOF
news*:NEWS-OS:*:6*)
echo mips-sony-newsos6
exit 0 ;;
- R3000:*System_V*:*:* | R4000:UNIX_SYSV:*:*)
+ R3000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
if [ -d /usr/nec ]; then
echo mips-nec-sysv${UNAME_RELEASE}
else
echo mips-unknown-sysv${UNAME_RELEASE}
fi
exit 0 ;;
- PENTIUM:CPunix:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
- # says <Richard.M.Bartel@ccMail.Census.GOV>
- echo i586-unisys-sysv4
+ BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only.
+ echo powerpc-apple-beos
+ exit 0 ;;
+ BeMac:BeOS:*:*)
+ echo powerpc-apple-beos
+ exit 0 ;;
+ BePC:BeOS:*:*)
+ echo i586-pc-beos
+ exit 0 ;;
+ SX-4:SUPER-UX:*:*)
+ echo sx4-nec-superux${UNAME_RELEASE}
+ exit 0 ;;
+ SX-5:SUPER-UX:*:*)
+ echo sx5-nec-superux${UNAME_RELEASE}
+ exit 0 ;;
+ Power*:Rhapsody:*:*)
+ echo powerpc-apple-rhapsody${UNAME_RELEASE}
+ exit 0 ;;
+ *:Rhapsody:*:*)
+ echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
exit 0 ;;
esac
#echo '(No uname command or uname output not recognized.)' 1>&2
#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
-cat >dummy.c <<EOF
+cat >$dummy.c <<EOF
#ifdef _SEQUENT_
# include <sys/types.h>
# include <sys/utsname.h>
@@ -930,7 +1105,10 @@ main ()
#endif
int version;
version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
- printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
+ if (version < 4)
+ printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
+ else
+ printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
exit (0);
#endif
@@ -1097,8 +1275,8 @@ main ()
}
EOF
-${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy && rm dummy.c dummy && exit 0
-rm -f dummy.c dummy
+${CC-cc} $dummy.c -o $dummy 2>/dev/null && ./$dummy && rm $dummy.c $dummy && exit 0
+rm -f $dummy.c $dummy
# Apollos put the system type in the environment.
diff --git a/support/config.sub b/support/config.sub
index c1ec2df8..7d0c026d 100755
--- a/support/config.sub
+++ b/support/config.sub
@@ -98,6 +98,16 @@ case $os in
os=
basic_machine=$1
;;
+ -sim | -cisco | -oki | -wec | -winbond)
+ os=
+ basic_machine=$1
+ ;;
+ -scout)
+ ;;
+ -wrs)
+ os=vxworks
+ basic_machine=$1
+ ;;
-hiux*)
os=-hiuxwe2
;;
@@ -121,6 +131,9 @@ case $os in
os=-sco3.2v2
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
+ -udk*)
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
-isc)
os=-isc2.2
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
@@ -149,19 +162,27 @@ esac
case $basic_machine in
# Recognize the basic CPU types without company name.
# Some are omitted here because they have special meanings below.
- tahoe | i860 | m68k | m68000 | m88k | ns32k | arm \
- | arme[lb] | pyramid \
- | tron | a29k | 580 | i960 | h8300 | hppa | hppa1.0 | hppa1.1 \
- | hppa2.0 | alpha | we32k | ns16k | clipper | i370 | sh \
- | powerpc | powerpcle | 1750a | dsp16xx | mips64 | mipsel \
- | pdp11 | mips64el | mips64orion | mips64orionel \
- | sparc | sparclet | sparclite | sparc64)
+ tahoe | i860 | ia64 | m32r | m68k | m68000 | m88k | ns32k | arc | arm \
+ | arme[lb] | pyramid | mn10200 | mn10300 | tron | a29k \
+ | 580 | i960 | h8300 \
+ | hppa | hppa1.0 | hppa1.1 | hppa2.0 | hppa2.0w | hppa2.0n \
+ | alpha | alphaev[4-7] | alphaev56 | alphapca5[67] \
+ | we32k | ns16k | clipper | i370 | sh | powerpc | powerpcle \
+ | 1750a | dsp16xx | pdp11 | mips16 | mips64 | mipsel | mips64el \
+ | mips64orion | mips64orionel | mipstx39 | mipstx39el \
+ | mips64vr4300 | mips64vr4300el | mips64vr4100 | mips64vr4100el \
+ | mips64vr5000 | miprs64vr5000el | mcore \
+ | sparc | sparclet | sparclite | sparc64 | sparcv9 | v850 | c4x \
+ | thumb | d10v)
basic_machine=$basic_machine-unknown
;;
+ m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | z8k | v70 | h8500 | w65)
+ ;;
+
# We use `pc' rather than `unknown'
# because (1) that's what they normally are, and
# (2) the word "unknown" tends to confuse beginning users.
- i[3456]86)
+ i[34567]86)
basic_machine=$basic_machine-pc
;;
# Object if more than one company name word.
@@ -170,30 +191,53 @@ case $basic_machine in
exit 1
;;
# Recognize the basic CPU types with company name.
- vax-* | tahoe-* | i[3456]86-* | i860-* | m68k-* | m68000-* | m88k-* \
- | sparc-* | ns32k-* | fx80-* | arm-* | c[123]* \
- | mips-* | pyramid-* | tron-* | a29k-* | romp-* | rs6000-* | power-* \
- | none-* | 580-* | cray2-* | h8300-* | i960-* | xmp-* | ymp-* \
- | hppa-* | hppa1.0-* | hppa1.1-* | hppa2.0-* \
- | alpha-* | alphaev5-* | alphaev56-* | alphapca56-* | alphaev6-* \
- | we32k-* | cydra-* | ns16k-* \
- | pn-* | np1-* | xps100-* | clipper-* | orion-* | sparclite-* \
- | pdp11-* | sh-* | powerpc-* | powerpcle-* | sparc64-* | mips64-* | mipsel-* \
- | mips64el-* | mips64orion-* | mips64orionel-* | f301-* \
- | butterfly-bbn* \
- | cadmus-* | ews*-nec | ibmrt-ibm* | masscomp-masscomp \
+ # FIXME: clean up the formatting here.
+ vax-* | tahoe-* | i[34567]86-* | i860-* | ia64-* | m32r-* | m68k-* | m68000-* \
+ | m88k-* | sparc-* | ns32k-* | fx80-* | arc-* | arm-* | c[123]* \
+ | mips-* | pyramid-* | tron-* | a29k-* | romp-* | rs6000-* \
+ | power-* | none-* | 580-* | cray2-* | h8300-* | h8500-* | i960-* \
+ | xmp-* | ymp-* \
+ | hppa-* | hppa1.0-* | hppa1.1-* | hppa2.0-* | hppa2.0w-* | hppa2.0n-* \
+ | alpha-* | alphaev[4-7]-* | alphaev56-* | alphapca5[67]-* \
+ | we32k-* | cydra-* | ns16k-* | pn-* | np1-* | xps100-* \
+ | clipper-* | orion-* \
+ | sparclite-* | pdp11-* | sh-* | powerpc-* | powerpcle-* \
+ | sparc64-* | sparcv9-* | sparc86x-* | mips16-* | mips64-* | mipsel-* \
+ | mips64el-* | mips64orion-* | mips64orionel-* \
+ | mips64vr4100-* | mips64vr4100el-* | mips64vr4300-* | mips64vr4300el-* \
+ | mipstx39-* | mipstx39el-* | mcore-* \
+ | f301-* | armv*-* | t3e-* \
+ | m88110-* | m680[01234]0-* | m683?2-* | m68360-* | z8k-* | d10v-* \
+ | thumb-* | v850-* | d30v-* | tic30-* | c30-* )
+ ;;
+ # BEGIN cases added for Bash
+ butterfly-bbn* | cadmus-* | ews*-nec | ibmrt-ibm* | masscomp-masscomp \
| tandem-* | symmetric-* | drs6000-icl | *-*ardent | gould-gould \
| concurrent-* | ksr1-* | esa-ibm | fxc-alliant | *370-amdahl \
- | *-convex | sx4*-nec)
+ | *-convex | sx[45]*-nec )
;;
+ # END cases added for Bash
+
# Recognize the various machine names and aliases which stand
# for a CPU type and a company and sometimes even an OS.
+ 386bsd)
+ basic_machine=i386-unknown
+ os=-bsd
+ ;;
3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
basic_machine=m68000-att
;;
3b*)
basic_machine=we32k-att
;;
+ a29khif)
+ basic_machine=a29k-amd
+ os=-udi
+ ;;
+ adobe68k)
+ basic_machine=m68010-adobe
+ os=-scout
+ ;;
alliant | fx80)
basic_machine=fx80-alliant
;;
@@ -212,13 +256,9 @@ case $basic_machine in
# basic_machine=m68k-cbm
basic_machine=m68k-unknown
;;
- amigaos)
- basic_machine=m68k-unknown
- os=-amigaos
- ;;
- amigados)
+ amigaos | amigados)
basic_machine=m68k-cbm
- os=-amigados
+ os=-amigaos
;;
amigaunix | amix)
basic_machine=m68k-cbm
@@ -228,6 +268,10 @@ case $basic_machine in
basic_machine=m68k-apollo
os=-sysv
;;
+ apollo68bsd)
+ basic_machine=m68k-apollo
+ os=-bsd
+ ;;
aux)
basic_machine=m68k-apple
os=-aux
@@ -307,6 +351,10 @@ case $basic_machine in
encore | umax | mmax | multimax)
basic_machine=ns32k-encore
;;
+ es1800 | OSE68k | ose68k | ose | OSE)
+ basic_machine=m68k-ericsson
+ os=-ose
+ ;;
fx2800)
basic_machine=i860-alliant
;;
@@ -325,6 +373,14 @@ case $basic_machine in
basic_machine=h8300-hitachi
os=-hms
;;
+ h8300xray)
+ basic_machine=h8300-hitachi
+ os=-xray
+ ;;
+ h8500hms)
+ basic_machine=h8500-hitachi
+ os=-hms
+ ;;
harris)
basic_machine=m88k-harris
os=-sysv3
@@ -340,13 +396,30 @@ case $basic_machine in
basic_machine=m68k-hp
os=-hpux
;;
+ hp3k9[0-9][0-9] | hp9[0-9][0-9])
+ basic_machine=hppa1.0-hp
+ ;;
hp9k2[0-9][0-9] | hp9k31[0-9])
basic_machine=m68000-hp
;;
hp9k3[2-9][0-9])
basic_machine=m68k-hp
;;
- hp9k7[0-9][0-9] | hp7[0-9][0-9] | hp9k8[0-9]7 | hp8[0-9]7)
+ hp9k6[0-9][0-9] | hp6[0-9][0-9])
+ basic_machine=hppa1.0-hp
+ ;;
+ hp9k7[0-79][0-9] | hp7[0-79][0-9])
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k78[0-9] | hp78[0-9])
+ # FIXME: really hppa2.0-hp
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
+ # FIXME: really hppa2.0-hp
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k8[0-9][13679] | hp8[0-9][13679])
basic_machine=hppa1.1-hp
;;
hp9k8[0-9][0-9] | hp8[0-9][0-9])
@@ -355,6 +428,14 @@ case $basic_machine in
hppa-next)
os=-nextstep3
;;
+ hppaosf)
+ basic_machine=hppa1.1-hp
+ os=-osf
+ ;;
+ hppro)
+ basic_machine=hppa1.1-hp
+ os=-proelf
+ ;;
ibm032-*)
basic_machine=ibmrt-ibm
;;
@@ -363,22 +444,38 @@ case $basic_machine in
os=-mvs
;;
# I'm not sure what "Sysv32" means. Should this be sysv3.2?
- i[3456]86v32)
+ i[34567]86v32)
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
os=-sysv32
;;
- i[3456]86v4*)
+ i[34567]86v4*)
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
os=-sysv4
;;
- i[3456]86v)
+ i[34567]86v)
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
os=-sysv
;;
- i[3456]86sol2)
+ i[34567]86sol2)
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
os=-solaris2
;;
+ i386mach)
+ basic_machine=i386-mach
+ os=-mach
+ ;;
+ i386-vsta | vsta)
+ basic_machine=i386-unknown
+ os=-vsta
+ ;;
+ i386-go32 | go32)
+ basic_machine=i386-unknown
+ os=-go32
+ ;;
+ i386-mingw32 | mingw32)
+ basic_machine=i386-unknown
+ os=-mingw32
+ ;;
iris | iris4d)
basic_machine=mips-sgi
case $os in
@@ -410,13 +507,17 @@ case $basic_machine in
miniframe)
basic_machine=m68000-convergent
;;
+ *mint | *MiNT)
+ basic_machine=m68k-atari
+ os=-mint
+ ;;
mipsel*-linux*)
basic_machine=mipsel-unknown
- os=-linux
+ os=-linux-gnu
;;
mips*-linux*)
basic_machine=mips-unknown
- os=-linux
+ os=-linux-gnu
;;
mips3*-*)
basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
@@ -424,10 +525,26 @@ case $basic_machine in
mips3*)
basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
;;
+ monitor)
+ basic_machine=m68k-rom68k
+ os=-coff
+ ;;
+ msdos)
+ basic_machine=i386-unknown
+ os=-msdos
+ ;;
ncr3000)
basic_machine=i486-ncr
os=-sysv4
;;
+ netbsd386)
+ basic_machine=i386-unknown
+ os=-netbsd
+ ;;
+ netwinder)
+ basic_machine=armv4l-corel
+ os=-linux
+ ;;
news | news700 | news800 | news900)
basic_machine=m68k-sony
os=-newsos
@@ -440,6 +557,10 @@ case $basic_machine in
basic_machine=mips-sony
os=-newsos
;;
+ necv70)
+ basic_machine=v70-nec
+ os=-sysv
+ ;;
next | m*-next )
basic_machine=m68k-next
case $os in
@@ -465,6 +586,10 @@ case $basic_machine in
basic_machine=i960-intel
os=-nindy
;;
+ mon960)
+ basic_machine=i960-intel
+ os=-mon960
+ ;;
np1)
basic_machine=np1-gould
;;
@@ -476,6 +601,18 @@ case $basic_machine in
basic_machine=i386-pc
os=-sco3.2v4
;;
+ op50n-* | op60c-*)
+ basic_machine=hppa1.1-oki
+ os=-proelf
+ ;;
+ OSE68000 | ose68000)
+ basic_machine=m68000-ericsson
+ os=-ose
+ ;;
+ os68k)
+ basic_machine=m68k-none
+ os=-os68k
+ ;;
pa-hitachi)
basic_machine=hppa1.1-hitachi
os=-hiuxwe2
@@ -490,28 +627,26 @@ case $basic_machine in
pbb)
basic_machine=m68k-tti
;;
- pc532 | pc532-*)
+ pc532 | pc532-*)
basic_machine=ns32k-pc532
;;
- pentium | p5)
+ pentium | p5 | k5 | k6 | nexen)
basic_machine=i586-intel
;;
- pentiumpro | p6)
- basic_machine=i686-intel
+ pentiumpro | p6 | 6x86)
+ basic_machine=i686-pc
+ ;;
+ pentiumii | pentium2)
+ basic_machine=i786-pc
;;
- pentium-* | p5-*)
+ pentium-* | p5-* | k5-* | k6-* | nexen-*)
basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
- pentiumpro-* | p6-*)
+ pentiumpro-* | p6-* | 6x86*)
basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
- k5)
- # We don't have specific support for AMD's K5 yet, so just call it a Pentium
- basic_machine=i586-amd
- ;;
- nexen)
- # We don't have specific support for Nexgen yet, so just call it a Pentium
- basic_machine=i586-nexgen
+ pentiumii-* | pentium2-*)
+ basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
pn)
basic_machine=pn-gould
@@ -519,24 +654,32 @@ case $basic_machine in
power) basic_machine=rs6000-ibm
;;
ppc) basic_machine=powerpc-unknown
- ;;
+ ;;
ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
ppcle | powerpclittle | ppc-le | powerpc-little)
basic_machine=powerpcle-unknown
- ;;
+ ;;
ppcle-* | powerpclittle-*)
basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
ps2)
basic_machine=i386-ibm
;;
+ rom68k)
+ basic_machine=m68k-rom68k
+ os=-coff
+ ;;
rm[46]00)
basic_machine=mips-siemens
;;
rtpc | rtpc-*)
basic_machine=romp-ibm
;;
+ sa29200)
+ basic_machine=a29k-amd
+ os=-udi
+ ;;
sequent)
basic_machine=i386-sequent
;;
@@ -544,6 +687,10 @@ case $basic_machine in
basic_machine=sh-hitachi
os=-hms
;;
+ sparclite-wrs)
+ basic_machine=sparclite-wrs
+ os=-vxworks
+ ;;
sps7)
basic_machine=m68k-bull
os=-sysv2
@@ -551,6 +698,13 @@ case $basic_machine in
spur)
basic_machine=spur-unknown
;;
+ st2000)
+ basic_machine=m68k-tandem
+ ;;
+ stratus)
+ basic_machine=i860-stratus
+ os=-sysv4
+ ;;
sun2)
basic_machine=m68000-sun
;;
@@ -595,6 +749,16 @@ case $basic_machine in
basic_machine=i386-sequent
os=-dynix
;;
+ t3e)
+ basic_machine=t3e-cray
+ os=-unicos
+ ;;
+ tx39)
+ basic_machine=mipstx39-unknown
+ ;;
+ tx39el)
+ basic_machine=mipstx39el-unknown
+ ;;
tower | tower-32)
basic_machine=m68k-ncr
;;
@@ -614,6 +778,10 @@ case $basic_machine in
basic_machine=i386-pc
os=-sysv5uw7
;;
+ v810 | necv810)
+ basic_machine=v810-nec
+ os=-none
+ ;;
vaxv)
basic_machine=vax-dec
os=-sysv
@@ -637,13 +805,25 @@ case $basic_machine in
basic_machine=a29k-wrs
os=-vxworks
;;
+ w65*)
+ basic_machine=w65-wdc
+ os=-none
+ ;;
+ w89k-*)
+ basic_machine=hppa1.1-winbond
+ os=-proelf
+ ;;
xmp)
basic_machine=xmp-cray
os=-unicos
;;
- xps | xps100)
+ xps | xps100)
basic_machine=xps100-honeywell
;;
+ z8k-*-coff)
+ basic_machine=z8k-unknown
+ os=-sim
+ ;;
none)
basic_machine=none-none
os=-none
@@ -651,8 +831,17 @@ case $basic_machine in
# Here we handle the default manufacturer of certain CPU types. It is in
# some cases the only manufacturer, in others, it is the most popular.
+ w89k)
+ basic_machine=hppa1.1-winbond
+ ;;
+ op50n)
+ basic_machine=hppa1.1-oki
+ ;;
+ op60c)
+ basic_machine=hppa1.1-oki
+ ;;
mips)
- if test "x$os" = "x-linux" ; then
+ if test "x$os" = "x-linux-gnu" ; then
basic_machine=mips-unknown
else
basic_machine=mips-mips
@@ -673,10 +862,10 @@ case $basic_machine in
we32k)
basic_machine=we32k-att
;;
- sparc)
+ sparc | sparcv9)
basic_machine=sparc-sun
;;
- cydra)
+ cydra)
basic_machine=cydra-cydrome
;;
orion)
@@ -685,6 +874,16 @@ case $basic_machine in
orion105)
basic_machine=clipper-highlevel
;;
+ mac | mpw | mac-mpw)
+ basic_machine=m68k-apple
+ ;;
+ pmac | pmac-mpw)
+ basic_machine=powerpc-apple
+ ;;
+ c4x*)
+ basic_machine=c4x-none
+ os=-coff
+ ;;
*)
echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
exit 1
@@ -717,7 +916,7 @@ case $os in
-solaris)
os=-solaris2
;;
- svr4*)
+ -svr4*)
os=-sysv4
;;
-unixware | -uw | -unixware2* | -uw2*)
@@ -726,6 +925,9 @@ case $os in
-unixware7* | -uw7*)
os=-sysv5uw7
;;
+ -unixware*)
+ os=-sysv4.2uw
+ ;;
-gnu/linux*)
os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
;;
@@ -736,18 +938,31 @@ case $os in
-gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
| -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\
| -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \
- | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* | -aos* \
+ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
+ | -aos* \
| -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
| -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
| -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \
- | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* \
+ | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
| -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
| -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
| -cygwin32* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
- | -linux-gnu* | -uxpv* | -qnx* | -powerux* | -beos* | -rhapsody* \
- | -superux* )
+ | -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \
+ | -interix* | -uwin* | -rhapsody* | -openstep* | -oskit*)
# Remember, each alternative MUST END IN *, to match a version number.
;;
+ # BEGIN CASES ADDED FOR Bash
+ -qnx* | -powerux* | -superux* )
+ ;;
+ # END CASES ADDED FOR Bash
+ -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
+ | -windows* | -osx | -abug | -netware* | -os9* | -beos* \
+ | -macos* | -mpw* | -magic* | -mon960* | -lnews*)
+ ;;
+ -mac*)
+ os=`echo $os | sed -e 's|mac|macos|'`
+ ;;
+
-linux*)
os=`echo $os | sed -e 's|linux|linux-gnu|'`
;;
@@ -772,11 +987,14 @@ case $os in
-acis*)
os=-aos
;;
+ -386bsd)
+ os=-bsd
+ ;;
-ctix* | -uts*)
os=-sysv
;;
-ns2 )
- os=-nextstep2
+ os=-nextstep2
;;
# Preserve the version number of sinix5.
-sinix5.*)
@@ -806,9 +1024,18 @@ case $os in
# This must come after -sysvr[45].
-sysv*)
;;
+ -ose*)
+ os=-ose
+ ;;
+ -es1800*)
+ os=-ose
+ ;;
-xenix)
os=-xenix
;;
+ -*mint | -*MiNT)
+ os=-mint
+ ;;
-none)
;;
*)
@@ -837,7 +1064,7 @@ case $basic_machine in
arm*-semi)
os=-aout
;;
- pdp11-*)
+ pdp11-*)
os=-none
;;
*-dec | vax-*)
@@ -855,6 +1082,15 @@ case $basic_machine in
# default.
# os=-sunos4
;;
+ m68*-cisco)
+ os=-aout
+ ;;
+ mips*-cisco)
+ os=-elf
+ ;;
+ mips*-*)
+ os=-elf
+ ;;
*-tti) # must be before sparc entry or we get the wrong os.
os=-sysv3
;;
@@ -867,6 +1103,15 @@ case $basic_machine in
*-ibm)
os=-aix
;;
+ *-wec)
+ os=-proelf
+ ;;
+ *-winbond)
+ os=-proelf
+ ;;
+ *-oki)
+ os=-proelf
+ ;;
*-hp)
os=-hpux
;;
@@ -909,19 +1154,19 @@ case $basic_machine in
*-next)
os=-nextstep3
;;
- *-gould)
+ *-gould)
os=-sysv
;;
- *-highlevel)
+ *-highlevel)
os=-bsd
;;
*-encore)
os=-bsd
;;
- *-sgi)
+ *-sgi)
os=-irix
;;
- *-siemens)
+ *-siemens)
os=-sysv4
;;
*-masscomp)
@@ -930,6 +1175,18 @@ case $basic_machine in
f301-fujitsu)
os=-uxpv
;;
+ *-rom68k)
+ os=-coff
+ ;;
+ *-*bug)
+ os=-coff
+ ;;
+ *-apple)
+ os=-macos
+ ;;
+ *-atari*)
+ os=-mint
+ ;;
*)
os=-none
;;
@@ -954,6 +1211,9 @@ case $basic_machine in
-aix*)
vendor=ibm
;;
+ -beos*)
+ vendor=be
+ ;;
-hpux*)
vendor=hp
;;
@@ -984,6 +1244,15 @@ case $basic_machine in
-aux*)
vendor=apple
;;
+ -hms*)
+ vendor=hitachi
+ ;;
+ -mpw* | -macos*)
+ vendor=apple
+ ;;
+ -*mint | -*MiNT)
+ vendor=atari
+ ;;
esac
basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
;;
diff --git a/support/mksignames.c b/support/mksignames.c
index 634263ed..cfc3508d 100644
--- a/support/mksignames.c
+++ b/support/mksignames.c
@@ -7,7 +7,7 @@
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
- Software Foundation; either version 1, or (at your option) any later
+ Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -17,7 +17,7 @@
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#include <stdio.h>
#include <sys/types.h>
@@ -36,10 +36,18 @@ char *signal_names[2 * NSIG];
char *progname;
+#if defined (SIGRTMAX) || defined (SIGRTMIN)
+# define RTLEN 14
+# define RTLIM 256
+#endif
+
void
initialize_signames ()
{
register int i;
+#if defined (SIGRTMAX) || defined (SIGRTMIN)
+ int rtmin, rtmax, rtcnt;
+#endif
for (i = 1; i < sizeof(signal_names)/sizeof(signal_names[0]); i++)
signal_names[i] = (char *)NULL;
@@ -49,6 +57,57 @@ initialize_signames ()
/* Place signal names which can be aliases for more common signal
names first. This allows (for example) SIGABRT to overwrite SIGLOST. */
+
+ /* POSIX 1003.1b-1993 real time signals, but take care of incomplete
+ implementations. Acoording to the standard, both, SIGRTMIN and
+ SIGRTMAX must be defined, SIGRTMIN must be stricly less than
+ SIGRTMAX, and the difference must be at least 7, that is, there
+ must be at least eight distinct real time signals. */
+
+ /* The generated signal names are SIGRTMIN, SIGRTMIN+1, ...,
+ SIGRTMIN+x, SIGRTMAX-x, ..., SIGRTMAX-1, SIGRTMAX. If the number
+ of RT signals is odd, there is an extra SIGRTMIN+(x+1).
+ These names are the ones used by ksh and /usr/xpg4/bin/sh on SunOS5. */
+
+#if defined (SIGRTMIN)
+ rtmin = SIGRTMIN;
+ signal_names[rtmin] = "SIGRTMIN";
+#endif
+
+#if defined (SIGRTMAX)
+ rtmax = SIGRTMAX;
+ signal_names[rtmax] = "SIGRTMAX";
+#endif
+
+#if defined (SIGRTMAX) && defined (SIGRTMIN)
+ if (rtmax > rtmin)
+ {
+ rtcnt = (rtmax - rtmin - 1) / 2;
+ /* croak if there are too many RT signals */
+ if (rtcnt >= RTLIM/2)
+ {
+ rtcnt = RTLIM/2-1;
+ fprintf(stderr, "%s: error: more than %i real time signals, fix `%s'\n",
+ progname, RTLIM, progname);
+ }
+
+ for (i = 1; i <= rtcnt; i++)
+ {
+ signal_names[rtmin+i] = (char *)malloc(RTLEN);
+ sprintf (signal_names[rtmin+i], "SIGRTMIN+%d", i);
+ signal_names[rtmax-i] = (char *)malloc(RTLEN);
+ sprintf (signal_names[rtmax-i], "SIGRTMAX-%d", i);
+ }
+
+ if (rtcnt < RTLIM/2-1 && rtcnt != (rtmax-rtmin)/2)
+ {
+ /* Need an extra RTMIN signal */
+ signal_names[rtmin+rtcnt+1] = (char *)malloc(RTLEN);
+ sprintf (signal_names[rtmin+rtcnt+1], "SIGRTMIN+%d", rtcnt+1);
+ }
+ }
+#endif /* SIGRTMIN && SIGRTMAX */
+
/* AIX */
#if defined (SIGLOST) /* resource lost (eg, record-lock lost) */
signal_names[SIGLOST] = "SIGLOST";
diff --git a/support/mkversion.sh b/support/mkversion.sh
index 6adbe4c3..c6682924 100755
--- a/support/mkversion.sh
+++ b/support/mkversion.sh
@@ -6,7 +6,7 @@
# otherwise everything is echoed to the standard output.
PROGNAME=`basename $0`
-USAGE="$PROGNAME [-b] -d version -p patchlevel [-s status]"
+USAGE="$PROGNAME [-b] -d version -p patchlevel [-s status] [-o outfile]"
while [ $# -gt 0 ]; do
case "$1" in
@@ -65,8 +65,27 @@ fi
echo "/* Version control for the shell. This file gets changed when you say"
echo " \`make version.h' to the Makefile. It is created by mkversion. */"
-# Output the distribution version
-float_dist=`echo $dist_version | awk '{printf "%.2f\n", $1}'`
+# Output the distribution version. Single numbers are converted to x.00.
+# Any characters other than digits and `.' are invalid.
+case "$dist_version" in
+*[!0-9.]*) echo "mkversion.sh: ${dist_version}: bad distribution version" >&2
+ exit 1 ;;
+*.*) ;;
+*) dist_version=${dist_version}.00 ;;
+esac
+
+dist_major=`echo $dist_version | sed 's:\..*$::'`
+[ -z "${dist_major}" ] && dist_major=0
+
+dist_minor=`echo $dist_version | sed 's:^.*\.::'`
+case "$dist_minor" in
+"") dist_minor=00 ;;
+?) dist_minor=0${dist_minor} ;;
+*) ;;
+esac
+
+#float_dist=`echo $dist_version | awk '{printf "%.2f\n", $1}'`
+float_dist=${dist_major}.${dist_minor}
echo
echo "/* The distribution version number of this shell. */"
diff --git a/support/rlvers.sh b/support/rlvers.sh
index 12abeda9..ea85afa4 100755
--- a/support/rlvers.sh
+++ b/support/rlvers.sh
@@ -5,17 +5,19 @@
#
PROGNAME=`basename $0`
-
-trap 'rm -f /tmp/rlvers /tmp/rlvers.?' 0 1 2 3 6 15
+TDIR=/tmp/rlvers
# defaults
CC=cc
RL_LIBDIR=/usr/local/lib
+TERMCAP_LIB="-ltermcap"
+
while [ $# -gt 0 ]; do
case "$1" in
-C) shift ; CC="$1"; shift ;;
-L) shift ; RL_LIBDIR="$1" ; shift ;;
+ -T) shift ; TERMCAP_LIB="$1" ; shift ;;
-v) shift ; verbose=y ;;
--) shift ; break ;;
*) echo "${PROGNAME}: usage: $PROGNAME [-C compiler] [-L libdir] [-v]" >&2 ; exit 2;;
@@ -41,7 +43,17 @@ if [ -n "$verbose" ]; then
echo "${PROGNAME}: attempting program compilation"
fi
-cat > /tmp/rlvers.c << EOF
+# make $TDIR mode 0700
+mkdir $TDIR || {
+ echo "${PROGNAME}: ${TDIR}: file exists" >&2
+ echo 0
+ exit 1
+}
+chmod 700 $TDIR
+
+trap 'rm -f $TDIR/rlvers $TDIR/rlvers.? ; rmdir $TDIR' 0 1 2 3 6 15
+
+cat > $TDIR/rlvers.c << EOF
#include <stdio.h>
extern char *rl_library_version;
@@ -52,9 +64,9 @@ main()
}
EOF
-if eval ${CC} -L${RL_LIBDIR} -o /tmp/rlvers /tmp/rlvers.c -lreadline -ltermcap -lcurses;
+if eval ${CC} -L${RL_LIBDIR} -o $TDIR/rlvers $TDIR/rlvers.c -lreadline ${TERMCAP_LIB};
then
- v=`/tmp/rlvers`
+ v=`$TDIR/rlvers`
else
if [ -n "$verbose" ] ; then
echo "${PROGNAME}: compilation failed: status $?"
diff --git a/support/shobj-conf b/support/shobj-conf
index cbd3d1b4..6649c700 100755
--- a/support/shobj-conf
+++ b/support/shobj-conf
@@ -62,9 +62,9 @@ sunos4*)
sunos5*-gcc*|solaris2*-gcc*)
SHOBJ_CFLAGS=-fpic
SHOBJ_LD='${CC}'
- SHOBJ_LDFLAGS='-shared -Wl,-i'
+ SHOBJ_LDFLAGS='-shared -Wl,-i -Wl,-h,$@'
- SHLIB_XLDFLAGS='-R $(libdir)'
+# SHLIB_XLDFLAGS='-R $(libdir)'
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
;;
@@ -73,7 +73,7 @@ sunos5*|solaris2*)
SHOBJ_LD=/usr/ccs/bin/ld
SHOBJ_LDFLAGS='-G -dy -z text -i -h $@'
- SHLIB_XLDFLAGS='-R $(libdir)'
+# SHLIB_XLDFLAGS='-R $(libdir)'
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
;;
@@ -86,13 +86,32 @@ freebsd2* | netbsd* | openbsd*)
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)$(SHLIB_MINOR)'
;;
+# FreeBSD-3.x can have either a.out or ELF object files
+#freebsd3*)
+# SHOBJ_CFLAGS=-fpic
+# SHOBJ_LD='${CC}'
+# SHOBJ_LDFLAGS='-shared'
+#
+# SHLIB_XLDFLAGS='-R$(libdir)'
+# SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)$(SHLIB_MINOR)'
+# ;;
+
+# FreeBSD-3.x ELF
freebsd3*)
SHOBJ_CFLAGS=-fpic
SHOBJ_LD='${CC}'
- SHOBJ_LDFLAGS='-shared'
- SHLIB_XLDFLAGS='-R$(libdir)'
- SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)$(SHLIB_MINOR)'
+ if [ -x /usr/bin/objformat ] && [ "`/usr/bin/objformat`" = "elf" ]; then
+ SHOBJ_LDFLAGS='-shared -Wl,-soname,$@'
+
+ SHLIB_XLDFLAGS='-Wl,-rpath,$(libdir)'
+ SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
+ else
+ SHOBJ_LDFLAGS='-shared'
+
+ SHLIB_XLDFLAGS='-R$(libdir)'
+ SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)$(SHLIB_MINOR)'
+ fi
;;
linux*)
@@ -142,6 +161,15 @@ bsdi4*)
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)$(SHLIB_MINOR)'
;;
+osf*-gcc*)
+ # Fix to use gcc linker driver from bfischer@TechFak.Uni-Bielefeld.DE
+ SHOBJ_LD='${CC}'
+ SHOBJ_LDFLAGS='-shared -Wl,-soname,$@'
+
+ SHLIB_XLDFLAGS='-rpath $(libdir)'
+ SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
+ ;;
+
osf*)
SHOBJ_LD=ld
SHOBJ_LDFLAGS='-shared -soname $@ -expect_unresolved "*"'
@@ -187,7 +215,9 @@ irix[56]*-gcc*)
irix[56]*)
SHOBJ_CFLAGS='-K PIC'
SHOBJ_LD=ld
- SHOBJ_LDFLAGS='-call_shared -hidden_symbol -no_unresolved -soname $@'
+# SHOBJ_LDFLAGS='-call_shared -hidden_symbol -no_unresolved -soname $@'
+# Change from David Kaelbling <drk@sgi.com>
+ SHOBJ_LDFLAGS='-shared -no_unresolved -soname $@'
SHLIB_XLDFLAGS='-rpath $(libdir)'
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
@@ -305,6 +335,12 @@ dgux*)
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
;;
+
+msdos*)
+ SHOBJ_STATUS=unsupported
+ SHLIB_STATUS=unsupported
+ ;;
+
#
# Rely on correct gcc configuration for everything else
#
diff --git a/test.c b/test.c
index 93e44263..2d81eb52 100644
--- a/test.c
+++ b/test.c
@@ -18,7 +18,7 @@
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
/* Define PATTERN_MATCHING to get the csh-like =~ and !~ pattern-matching
binary operators. */
@@ -200,6 +200,19 @@ test_stat (path, finfo)
return (stat (pbuf, finfo));
#endif /* !HAVE_DEV_FD */
}
+#if !defined (HAVE_DEV_STDIN)
+ else if (STREQN (path, "/dev/std", 8))
+ {
+ if (STREQ (path+8, "in"))
+ return (fstat (0, finfo));
+ else if (STREQ (path+8, "out"))
+ return (fstat (1, finfo));
+ else if (STREQ (path+8, "err"))
+ return (fstat (2, finfo));
+ else
+ return (stat (path, finfo));
+ }
+#endif /* !HAVE_DEV_STDIN */
return (stat (path, finfo));
}
diff --git a/tests/arith-for.right b/tests/arith-for.right
new file mode 100644
index 00000000..f5b43e09
--- /dev/null
+++ b/tests/arith-for.right
@@ -0,0 +1,72 @@
+0
+1
+2
+0
+1
+2
+0
+1
+2
+0
+2
+4
+fx is a function
+fx ()
+{
+ i=0;
+ for (( 1 ; i < 3 ; i++ ))
+ do
+ echo $i;
+ done;
+ for (( i=0 ; 1 ; i++ ))
+ do
+ if (( " i >= 3 " )); then
+ break;
+ fi;
+ echo $i;
+ done;
+ for (( i=0 ; i<3 ; 1 ))
+ do
+ echo $i;
+ (( " i++ " ));
+ done;
+ i=0;
+ for (( 1 ; 1 ; 1 ))
+ do
+ if (( " i > 2 " )); then
+ break;
+ fi;
+ echo $i;
+ (( " i++ " ));
+ done;
+ i=0;
+ for (( 1 ; 1 ; 1 ))
+ do
+ if (( " i > 2 " )); then
+ break;
+ fi;
+ echo $i;
+ (( " i++ " ));
+ done
+}
+0
+1
+2
+0
+1
+2
+0
+1
+2
+0
+1
+2
+0
+1
+2
+./arith-for.tests: line 77: syntax error: arithmetic expression required
+./arith-for.tests: line 77: syntax error: `(( i=0; "i < 3" ))'
+2
+./arith-for.tests: line 83: syntax error: `;' unexpected
+./arith-for.tests: line 83: syntax error: `(( i=0; i < 3; i++; 7 ))'
+2
diff --git a/tests/arith-for.tests b/tests/arith-for.tests
new file mode 100644
index 00000000..1d6da80d
--- /dev/null
+++ b/tests/arith-for.tests
@@ -0,0 +1,87 @@
+fx()
+{
+i=0
+for (( ; i < 3; i++ ))
+do
+ echo $i
+done
+
+for (( i=0; ; i++ ))
+do
+ if (( i >= 3 )); then
+ break;
+ fi
+ echo $i
+done
+
+for (( i=0; i<3; ))
+do
+ echo $i
+ (( i++ ))
+done
+
+i=0
+for (( ; ; ))
+do
+ if (( i > 2 )); then
+ break;
+ fi
+ echo $i;
+ (( i++ ))
+done
+
+i=0
+for ((;;))
+do
+ if (( i > 2 )); then
+ break;
+ fi
+ echo $i;
+ (( i++ ))
+done
+}
+
+for (( i=0; "i < 3" ; i++ ))
+do
+ echo $i
+done
+
+i=0
+for (( ; "i < 3"; i++ ))
+do
+ echo $i
+done
+
+for (( i=0; ; i++ ))
+do
+ if (( i >= 3 )); then
+ break;
+ fi
+ echo $i
+done
+
+for ((i = 0; ;i++ ))
+do
+ echo $i
+ if (( i < 3 )); then
+ (( i++ ))
+ continue;
+ fi
+ break
+done
+
+type fx
+fx
+
+# errors
+for (( i=0; "i < 3" ))
+do
+ echo $i
+done
+echo $?
+
+for (( i=0; i < 3; i++; 7 ))
+do
+ echo $i
+done
+echo $?
diff --git a/tests/arith.right b/tests/arith.right
index c94da8b3..d70ad783 100644
--- a/tests/arith.right
+++ b/tests/arith.right
@@ -120,3 +120,27 @@ ok
131072
2147483647
1
+4
+4
+5
+5
+4
+3
+3
+4
+4
+7
+./arith.tests: 7-- : syntax error: operand expected (error token is " ")
+./arith.tests: --x=7 : attempted assignment to non-variable (error token is "=7 ")
+./arith.tests: ++x=7 : attempted assignment to non-variable (error token is "=7 ")
+./arith.tests: x++=7 : attempted assignment to non-variable (error token is "=7 ")
+./arith.tests: x--=7 : attempted assignment to non-variable (error token is "=7 ")
+4
+7
+-7
+7
+7
+8 12
+./arith.tests: ((: x=9 y=41 : syntax error in expression (error token is "y=41 ")
+./arith.tests: a b: syntax error in expression (error token is "b")
+./arith.tests: ((: a b: syntax error in expression (error token is "b")
diff --git a/tests/arith.tests b/tests/arith.tests
index d37e77f7..913efbe0 100644
--- a/tests/arith.tests
+++ b/tests/arith.tests
@@ -220,3 +220,50 @@ echo $(( 2**(16-1)))
echo $(( 2**16*2 ))
echo $(( 2**31-1))
echo $(( 2**0 ))
+
+# {pre,post}-{inc,dec}rement and associated errors
+
+x=4
+
+echo $x
+echo $(( x++ ))
+echo $x
+echo $(( x-- ))
+echo $x
+
+echo $(( --x ))
+echo $x
+
+echo $(( ++x ))
+echo $x
+
+echo $(( ++7 ))
+echo $(( 7-- ))
+
+echo $(( --x=7 ))
+echo $(( ++x=7 ))
+
+echo $(( x++=7 ))
+echo $(( x--=7 ))
+
+echo $x
+
+echo $(( +7 ))
+echo $(( -7 ))
+
+echo $(( ++7 ))
+echo $(( --7 ))
+
+x=4
+y=7
+
+(( x=8 , y=12 ))
+
+echo $x $y
+
+# should be an error
+(( x=9 y=41 ))
+
+# These are errors
+echo $((a b))
+((a b))
diff --git a/tests/array.right b/tests/array.right
index 65fb3c9f..2d3c179e 100644
--- a/tests/array.right
+++ b/tests/array.right
@@ -1,3 +1,6 @@
+./array.tests: array assign: line 10: syntax error near unexpected token `&'
+./array.tests: array assign: line 10: `first & second'
+1
abcde
abcde
abcde bdef
@@ -101,3 +104,17 @@ grep [ 123 ] *
length = 3
value = new1 new2 new3
./array.tests: narray: unbound variable
+
+a b c d e f g
+for case if then else
+<> < > !
+12 14 16 18 20
+4414758999202
+./array.tests: array assign: line 257: syntax error near unexpected token `for'
+./array.tests: array assign: line 257: `a b c for case if then else'
+./array.tests: array assign: line 259: syntax error near unexpected token `for'
+./array.tests: array assign: line 259: `for case if then else'
+./array.tests: array assign: line 261: syntax error near unexpected token `<>'
+./array.tests: array assign: line 261: ` <> < > ! '
+./array.tests: array assign: line 262: syntax error near unexpected token `[1]=<>'
+./array.tests: array assign: line 262: ` [1]=<> [2]=< [3]=> [4]=! '
diff --git a/tests/array.tests b/tests/array.tests
index 6e56d5a9..6f23486d 100644
--- a/tests/array.tests
+++ b/tests/array.tests
@@ -6,6 +6,11 @@ set +a
# The calls to egrep -v are to filter out builtin array variables that are
# automatically set and possibly contain values that vary.
+# this should be an error
+test=(first & second)
+echo $?
+unset test
+
# make sure declare -a converts an existing variable to an array
unset a
a=abcde
@@ -220,3 +225,38 @@ echo "value = ${barray[*]}"
# make sure the array code behaves correctly with respect to unset variables
set -u
( echo ${#narray[4]} )
+
+# some old bugs and ksh93 compatibility tests
+set +u
+cd /tmp
+
+touch 1=bar
+foo=([10]="bar")
+echo ${foo[0]}
+rm 1=bar
+
+foo=(a b c d e f g)
+echo ${foo[@]}
+
+# quoted reserved words are ok
+foo=(\for \case \if \then \else)
+echo ${foo[@]}
+
+# quoted metacharacters are ok
+foo=( [1]='<>' [2]='<' [3]='>' [4]='!' )
+echo ${foo[@]}
+
+# numbers are just words when not in a redirection context
+foo=( 12 14 16 18 20 )
+echo ${foo[@]}
+
+foo=( 4414758999202 )
+echo ${foo[@]}
+
+# errors
+foo=(a b c for case if then else)
+
+foo=(for case if then else)
+
+metas=( <> < > ! )
+metas=( [1]=<> [2]=< [3]=> [4]=! )
diff --git a/tests/builtins.right b/tests/builtins.right
index 5ed2b15f..03a509c8 100644
--- a/tests/builtins.right
+++ b/tests/builtins.right
@@ -124,4 +124,9 @@ ok
ok
./builtins.tests: kill: bad signal number: 4096
1
+a\n\n\nb
+a
+
+
+b
./builtins.tests: exit: bad non-numeric arg `status'
diff --git a/tests/builtins.tests b/tests/builtins.tests
index 9073ed55..979a4de0 100644
--- a/tests/builtins.tests
+++ b/tests/builtins.tests
@@ -183,7 +183,7 @@ echo "$@"
echo "$@"
# test out cd and $CDPATH
-${THIS_SH} ./builtins.sub1
+${THIS_SH} ./builtins1.sub
# test behavior of `.' when given a non-existant file argument
${THIS_SH} ./source5.sub
@@ -253,6 +253,9 @@ kill -l 4096
# kill -l NAME should return the signal number
kill -l ${sigone/SIG/}
+# test behavior of shopt xpg_echo
+${THIS_SH} ./builtins2.sub
+
# this must be last -- it is a fatal error
exit status
diff --git a/tests/builtins.sub1 b/tests/builtins1.sub
index 5b797113..5b797113 100644
--- a/tests/builtins.sub1
+++ b/tests/builtins1.sub
diff --git a/tests/builtins2.sub b/tests/builtins2.sub
new file mode 100644
index 00000000..e4cb32ae
--- /dev/null
+++ b/tests/builtins2.sub
@@ -0,0 +1,10 @@
+# test behavior of shopt xpg_echo
+
+USG_ECHO=off
+shopt -q xpg_echo && USG_ECHO=on
+
+shopt -u xpg_echo
+echo 'a\n\n\nb'
+
+shopt -s xpg_echo
+echo 'a\n\n\nb'
diff --git a/tests/cprint.right b/tests/cprint.right
index 6b711b8c..d8d4d282 100644
--- a/tests/cprint.right
+++ b/tests/cprint.right
@@ -55,8 +55,8 @@ tf2 ()
{
( {
time -p echo a | cat - >/dev/null
- } ) 2>&1
-}
+ } )
+} 2>&1
cprint.tests is a regular file
cprint.tests is not a directory
a
diff --git a/tests/errors.right b/tests/errors.right
index 4c49ec92..039b2bf2 100644
--- a/tests/errors.right
+++ b/tests/errors.right
@@ -48,6 +48,7 @@ hash: usage: hash [-r] [-p pathname] [name ...]
./errors.tests: umask: bad symbolic mode operator: :
./errors.tests: umask: illegal option: -i
umask: usage: umask [-p] [-S] [mode]
+./errors.tests: umask: bad character in symbolic mode: u
./errors.tests: VAR: readonly variable
./errors.tests: declare: VAR: readonly variable
./errors.tests: declare: VAR: readonly variable
@@ -71,8 +72,7 @@ source: usage: source filename
./errors.tests: enable: sh: not a shell builtin
./errors.tests: enable: bash: not a shell builtin
./errors.tests: shopt: cannot set and unset shell options simultaneously
-./errors.tests: read: illegal option: -t
-read: usage: read [-r] [-p prompt] [-a array] [-e] [name ...]
+./errors.tests: read: var: invalid timeout specification
./errors.tests: read: `/bin/sh': not a valid identifier
./errors.tests: VAR: readonly variable
./errors.tests: readonly: illegal option: -x
diff --git a/tests/errors.tests b/tests/errors.tests
index ec0c31c2..9311a5dd 100644
--- a/tests/errors.tests
+++ b/tests/errors.tests
@@ -140,6 +140,14 @@ umask -S u:rwx,g:rwx,o:rx >/dev/null # 002
# at some point, this may mean `invert', but for now it is an error
umask -i
+# bad assignments shouldn't change the umask
+mask=$(umask)
+umask g=u
+mask2=$(umask)
+if [ "$mask" != "$mask2" ]; then
+ echo "umask errors change process umask"
+fi
+
# assignment to a readonly variable in environment
VAR=4
readonly VAR
@@ -183,7 +191,7 @@ enable sh bash
# try to set and unset shell options simultaneously
shopt -s -u checkhash
-# someday, this may give `read' a timeout, but for now it is an error
+# this is an error -- bad timeout spec
read -t var < /dev/null
# try to read into an invalid identifier
diff --git a/tests/execscript b/tests/execscript
index 0a13d72f..ed38c8ee 100644
--- a/tests/execscript
+++ b/tests/execscript
@@ -79,3 +79,6 @@ ${THIS_SH} ./exec4.sub
# try exec'ing a command that cannot be found in $PATH
${THIS_SH} ./exec5.sub
+
+# this was a bug in bash versions before bash-2.04
+${THIS_SH} -c 'cat </dev/null | cat >/dev/null' >&-
diff --git a/tests/extglob.tests b/tests/extglob.tests
index a815bab3..b1295c07 100644
--- a/tests/extglob.tests
+++ b/tests/extglob.tests
@@ -329,6 +329,7 @@ rm -rf $TESTDIR
mkdir $TESTDIR
builtin cd $TESTDIR
+LC_COLLATE=C # have to set this; it affects the sorting
touch a.b a,b a:b a-b a\;b a\ b a_b
echo a[^[:alnum:]]b
diff --git a/tests/extglob2.right b/tests/extglob2.right
new file mode 100644
index 00000000..f8a09dfb
--- /dev/null
+++ b/tests/extglob2.right
@@ -0,0 +1,70 @@
+0: [[ fofo = *(f*(o)) ]]
+0: [[ ffo = *(f*(o)) ]]
+0: [[ foooofo = *(f*(o)) ]]
+0: [[ foooofof = *(f*(o)) ]]
+0: [[ fooofoofofooo = *(f*(o)) ]]
+1: [[ foooofof = *(f+(o)) ]]
+1: [[ xfoooofof = *(f*(o)) ]]
+1: [[ foooofofx = *(f*(o)) ]]
+0: [[ ofxoofxo = *(*(of*(o)x)o) ]]
+1: [[ ofooofoofofooo = *(f*(o)) ]]
+0: [[ foooxfooxfoxfooox = *(f*(o)x) ]]
+1: [[ foooxfooxofoxfooox = *(f*(o)x) ]]
+0: [[ foooxfooxfxfooox = *(f*(o)x) ]]
+0: [[ ofxoofxo = *(*(of*(o)x)o) ]]
+0: [[ ofoooxoofxo = *(*(of*(o)x)o) ]]
+0: [[ ofoooxoofxoofoooxoofxo = *(*(of*(o)x)o) ]]
+0: [[ ofoooxoofxoofoooxoofxoo = *(*(of*(o)x)o) ]]
+1: [[ ofoooxoofxoofoooxoofxofo = *(*(of*(o)x)o) ]]
+0: [[ ofoooxoofxoofoooxoofxooofxofxo = *(*(of*(o)x)o) ]]
+0: [[ aac = *(@(a))a@(c) ]]
+0: [[ ac = *(@(a))a@(c) ]]
+1: [[ c = *(@(a))a@(c) ]]
+0: [[ aaac = *(@(a))a@(c) ]]
+1: [[ baaac = *(@(a))a@(c) ]]
+0: [[ abcd = ?@(a|b)*@(c)d ]]
+0: [[ abcd = @(ab|a*@(b))*(c)d ]]
+0: [[ acd = @(ab|a*(b))*(c)d ]]
+0: [[ abbcd = @(ab|a*(b))*(c)d ]]
+0: [[ effgz = @(b+(c)d|e*(f)g?|?(h)i@(j|k)) ]]
+0: [[ efgz = @(b+(c)d|e*(f)g?|?(h)i@(j|k)) ]]
+0: [[ egz = @(b+(c)d|e*(f)g?|?(h)i@(j|k)) ]]
+0: [[ egzefffgzbcdij = *(b+(c)d|e*(f)g?|?(h)i@(j|k)) ]]
+1: [[ egz = @(b+(c)d|e+(f)g?|?(h)i@(j|k)) ]]
+0: [[ ofoofo = *(of+(o)) ]]
+0: [[ oxfoxoxfox = *(oxf+(ox)) ]]
+1: [[ oxfoxfox = *(oxf+(ox)) ]]
+0: [[ ofoofo = *(of+(o)|f) ]]
+0: [[ foofoofo = @(foo|f|fo)*(f|of+(o)) ]]
+0: [[ oofooofo = *(of|oof+(o)) ]]
+0: [[ fffooofoooooffoofffooofff = *(*(f)*(o)) ]]
+0: [[ fofoofoofofoo = *(fo|foo) ]]
+0: [[ foo = !(x) ]]
+0: [[ foo = !(x)* ]]
+1: [[ foo = !(foo) ]]
+0: [[ foo = !(foo)* ]]
+0: [[ foobar = !(foo) ]]
+0: [[ foobar = !(foo)* ]]
+0: [[ moo.cow = !(*.*).!(*.*) ]]
+1: [[ mad.moo.cow = !(*.*).!(*.*) ]]
+1: [[ mucca.pazza = mu!(*(c))?.pa!(*(z))? ]]
+0: [[ fff = !(f) ]]
+0: [[ fff = *(!(f)) ]]
+0: [[ fff = +(!(f)) ]]
+0: [[ ooo = !(f) ]]
+0: [[ ooo = *(!(f)) ]]
+0: [[ ooo = +(!(f)) ]]
+0: [[ foo = !(f) ]]
+0: [[ foo = *(!(f)) ]]
+0: [[ foo = +(!(f)) ]]
+1: [[ f = !(f) ]]
+1: [[ f = *(!(f)) ]]
+1: [[ f = +(!(f)) ]]
+0: [[ foot = @(!(z*)|*x) ]]
+1: [[ zoot = @(!(z*)|*x) ]]
+0: [[ foox = @(!(z*)|*x) ]]
+0: [[ zoox = @(!(z*)|*x) ]]
+0: [[ foo = *(!(foo)) ]]
+1: [[ foob = !(foo)b* ]]
+0: [[ foobb = !(foo)b* ]]
+0 tests failed.
diff --git a/tests/extglob2.tests b/tests/extglob2.tests
new file mode 100755
index 00000000..f35c3e8b
--- /dev/null
+++ b/tests/extglob2.tests
@@ -0,0 +1,90 @@
+#
+# More ksh-like extended globbing tests, cribbed from zsh-3.1.5
+#
+shopt -s extglob
+
+failed=0
+while read res str pat; do
+ [[ $res = '#' ]] && continue
+ [[ $str = ${pat} ]]
+ ts=$?
+ [[ $1 = -q ]] || echo "$ts: [[ $str = $pat ]]"
+ if [[ ( $ts -gt 0 && $res = t) || ($ts -eq 0 && $res = f) ]]; then
+ echo "Test failed: [[ $str = $pat ]]"
+ (( failed += 1 ))
+ fi
+done <<EOT
+t fofo *(f*(o))
+t ffo *(f*(o))
+t foooofo *(f*(o))
+t foooofof *(f*(o))
+t fooofoofofooo *(f*(o))
+f foooofof *(f+(o))
+f xfoooofof *(f*(o))
+f foooofofx *(f*(o))
+t ofxoofxo *(*(of*(o)x)o)
+f ofooofoofofooo *(f*(o))
+t foooxfooxfoxfooox *(f*(o)x)
+f foooxfooxofoxfooox *(f*(o)x)
+t foooxfooxfxfooox *(f*(o)x)
+t ofxoofxo *(*(of*(o)x)o)
+t ofoooxoofxo *(*(of*(o)x)o)
+t ofoooxoofxoofoooxoofxo *(*(of*(o)x)o)
+t ofoooxoofxoofoooxoofxoo *(*(of*(o)x)o)
+f ofoooxoofxoofoooxoofxofo *(*(of*(o)x)o)
+t ofoooxoofxoofoooxoofxooofxofxo *(*(of*(o)x)o)
+t aac *(@(a))a@(c)
+t ac *(@(a))a@(c)
+f c *(@(a))a@(c)
+t aaac *(@(a))a@(c)
+f baaac *(@(a))a@(c)
+t abcd ?@(a|b)*@(c)d
+t abcd @(ab|a*@(b))*(c)d
+t acd @(ab|a*(b))*(c)d
+t abbcd @(ab|a*(b))*(c)d
+t effgz @(b+(c)d|e*(f)g?|?(h)i@(j|k))
+t efgz @(b+(c)d|e*(f)g?|?(h)i@(j|k))
+t egz @(b+(c)d|e*(f)g?|?(h)i@(j|k))
+t egzefffgzbcdij *(b+(c)d|e*(f)g?|?(h)i@(j|k))
+f egz @(b+(c)d|e+(f)g?|?(h)i@(j|k))
+t ofoofo *(of+(o))
+t oxfoxoxfox *(oxf+(ox))
+f oxfoxfox *(oxf+(ox))
+t ofoofo *(of+(o)|f)
+# The following is supposed to match only as fo+ofo+ofo
+t foofoofo @(foo|f|fo)*(f|of+(o))
+t oofooofo *(of|oof+(o))
+t fffooofoooooffoofffooofff *(*(f)*(o))
+# The following tests backtracking in alternation matches
+t fofoofoofofoo *(fo|foo)
+# Exclusion
+t foo !(x)
+t foo !(x)*
+f foo !(foo)
+t foo !(foo)*
+t foobar !(foo)
+t foobar !(foo)*
+t moo.cow !(*.*).!(*.*)
+f mad.moo.cow !(*.*).!(*.*)
+f mucca.pazza mu!(*(c))?.pa!(*(z))?
+t fff !(f)
+t fff *(!(f))
+t fff +(!(f))
+t ooo !(f)
+t ooo *(!(f))
+t ooo +(!(f))
+t foo !(f)
+t foo *(!(f))
+t foo +(!(f))
+f f !(f)
+f f *(!(f))
+f f +(!(f))
+t foot @(!(z*)|*x)
+f zoot @(!(z*)|*x)
+t foox @(!(z*)|*x)
+t zoox @(!(z*)|*x)
+t foo *(!(foo))
+f foob !(foo)b*
+t foobb !(foo)b*
+EOT
+echo "$failed tests failed."
diff --git a/tests/func.right b/tests/func.right
index fcdfe92d..39803951 100644
--- a/tests/func.right
+++ b/tests/func.right
@@ -26,3 +26,95 @@ f1 ()
echo $status;
return $status
}
+before: try to assign to FUNCNAME
+outside: FUNCNAME =
+before: FUNCNAME = func
+FUNCNAME = func2
+after: FUNCNAME = func
+outside2: FUNCNAME =
+function
+zf is a function
+zf ()
+{
+ echo this is zf
+}
+f is a function
+f ()
+{
+ echo f-x;
+ echo f-y
+} 1>&2
+subshell
+f is a function
+f ()
+{
+ echo f-x;
+ echo f-y
+} 1>&2
+f2 is a function
+f2 ()
+{
+ echo f2-a;
+ function f3 ()
+ {
+ echo f3-a;
+ echo f3-b
+ } 1>&2;
+ f3
+}
+subshell
+f2 is a function
+f2 ()
+{
+ echo f2-a;
+ function f3 ()
+ {
+ echo f3-a;
+ echo f3-b
+ } 1>&2;
+ f3
+}
+f4 is a function
+f4 ()
+{
+ echo f4-a;
+ function f5 ()
+ {
+ echo f5-a;
+ echo f5-b
+ } 1>&2;
+ f5
+} 2>&1
+subshell
+f4 is a function
+f4 ()
+{
+ echo f4-a;
+ function f5 ()
+ {
+ echo f5-a;
+ echo f5-b
+ } 1>&2;
+ f5
+} 2>&1
+testgrp is a function
+testgrp ()
+{
+ echo testgrp-a;
+ {
+ echo tg-x;
+ echo tg-y
+ } 1>&2;
+ echo testgrp-b
+}
+subshell
+testgrp is a function
+testgrp ()
+{
+ echo testgrp-a;
+ {
+ echo tg-x;
+ echo tg-y
+ } 1>&2;
+ echo testgrp-b
+}
diff --git a/tests/func.tests b/tests/func.tests
index 8abf4ce0..ed3d355c 100644
--- a/tests/func.tests
+++ b/tests/func.tests
@@ -117,3 +117,37 @@ declare -f f1 # should print the definition, too
# no functions should be exported, right?
declare -xF
declare -xf
+
+# FUNCNAME tests
+func2()
+{
+ echo FUNCNAME = $FUNCNAME
+}
+
+func()
+{
+ echo before: FUNCNAME = $FUNCNAME
+ func2
+ echo after: FUNCNAME = $FUNCNAME
+}
+
+echo before: try to assign to FUNCNAME
+FUCNAME=7
+
+echo outside: FUNCNAME = $FUNCNAME
+func
+echo outside2: FUNCNAME = $FUNCNAME
+
+# test exported functions (and cached exportstr)
+zf()
+{
+ echo this is zf
+}
+export -f zf
+
+${THIS_SH} -c 'type -t zf'
+${THIS_SH} -c 'type zf'
+
+${THIS_SH} ./func1.sub
+
+exit 0
diff --git a/tests/func1.sub b/tests/func1.sub
new file mode 100644
index 00000000..345645fd
--- /dev/null
+++ b/tests/func1.sub
@@ -0,0 +1,55 @@
+#
+# Test that redirections attached to shell functions are printed correctly.
+# This was a bug in all bash versions before bash-2.04.
+#
+f()
+{
+ echo f-x
+ echo f-y
+} >&2
+
+type f
+export -f f
+${THIS_SH} -c 'echo subshell; type f'
+
+f2()
+{
+ echo f2-a
+ f3()
+ {
+ echo f3-a
+ echo f3-b
+ } >&2
+ f3
+}
+
+type f2
+
+export -f f2
+${THIS_SH} -c 'echo subshell; type f2'
+
+f4()
+{
+ echo f4-a
+ f5()
+ {
+ echo f5-a
+ echo f5-b
+ } >&2
+ f5
+} 2>&1
+
+type f4
+export -f f4
+${THIS_SH} -c 'echo subshell; type f4'
+
+testgrp()
+{
+ echo testgrp-a
+ { echo tg-x; echo tg-y; } >&2
+ echo testgrp-b
+}
+type testgrp
+
+export -f testgrp
+${THIS_SH} -c 'echo subshell; type testgrp'
diff --git a/tests/history.right b/tests/history.right
index 7110223f..deb6b862 100644
--- a/tests/history.right
+++ b/tests/history.right
@@ -1,5 +1,5 @@
./history.tests: history: illegal option: -x
-history: usage: history [-c] [n] or history -awrn [filename] or history -ps arg [arg...]
+history: usage: history [-c] [-d offset] [n] or history -awrn [filename] or history -ps arg [arg...]
./history.tests: history: cannot use more than one of -anrw
./history.tests: fc: illegal option: -v
fc: usage: fc [-e ename] [-nlr] [first] [last] or fc -s [pat=rep] [cmd]
diff --git a/tests/invert.right b/tests/invert.right
new file mode 100644
index 00000000..5a9239aa
--- /dev/null
+++ b/tests/invert.right
@@ -0,0 +1,10 @@
+1
+1
+1
+0
+0
+1
+0
+1
+0
+1
diff --git a/tests/invert.tests b/tests/invert.tests
new file mode 100644
index 00000000..8393d95a
--- /dev/null
+++ b/tests/invert.tests
@@ -0,0 +1,19 @@
+# tests of return value inversion
+# placeholder for future expansion
+
+# user subshells (...) did this wrong in bash versions before 2.04
+
+! ( echo hello | grep h >/dev/null 2>&1 ); echo $?
+! echo hello | grep h >/dev/null 2>&1 ; echo $?
+
+! true ; echo $?
+! false; echo $?
+
+! (false) ; echo $?
+! (true); echo $?
+
+! true | false ; echo $?
+! false | true ; echo $?
+
+! (true | false) ; echo $?
+! (false | true) ; echo $?
diff --git a/tests/jobs.right b/tests/jobs.right
index 830c3973..9a10c35c 100644
--- a/tests/jobs.right
+++ b/tests/jobs.right
@@ -1,5 +1,21 @@
./jobs2.sub: fg: job %1 started without job control
fg: 1
+Waiting for job 0
+job 0 returns 0
+Waiting for job 1
+job 1 returns 0
+Waiting for job 2
+job 2 returns 0
+Waiting for job 3
+job 3 returns 0
+Waiting for job 4
+job 4 returns 0
+Waiting for job 5
+job 5 returns 0
+Waiting for job 6
+job 6 returns 0
+Waiting for job 7
+job 7 returns 0
0
./jobs.tests: wait: job control not enabled
./jobs.tests: fg: no job control
diff --git a/tests/jobs.tests b/tests/jobs.tests
index 26adfe09..d54c1e94 100644
--- a/tests/jobs.tests
+++ b/tests/jobs.tests
@@ -4,6 +4,10 @@ ${THIS_SH} ./jobs1.sub
# test out fg/bg failure in a subshell
${THIS_SH} ./jobs2.sub
+# test out behavior of waiting for background pids -- bug in versions
+# before 2.03
+${THIS_SH} ./jobs3.sub
+
jobs
echo $?
diff --git a/tests/jobs3.sub b/tests/jobs3.sub
new file mode 100644
index 00000000..6efd58b0
--- /dev/null
+++ b/tests/jobs3.sub
@@ -0,0 +1,26 @@
+#! /bin/bash
+NJOB=8
+i=0
+
+while [ $i -lt $NJOB ]
+do
+ /bin/sh -c "sleep 4; exit 0" &
+ rv=$?
+ pid=$!
+ eval bg_pid_$i=$pid
+# echo $$: Job $i: pid is $pid rv=$rv
+ i=$((i + 1))
+done
+
+
+
+i=0
+while [ $i -lt $NJOB ]
+do
+ eval wpid=\$bg_pid_$i
+ echo Waiting for job $i #'('pid $wpid')'
+ wait $wpid
+ rv=$?
+ echo job $i returns $rv
+ i=$((i + 1))
+done
diff --git a/tests/misc/dev-tcp.tests b/tests/misc/dev-tcp.tests
new file mode 100644
index 00000000..0f3a2281
--- /dev/null
+++ b/tests/misc/dev-tcp.tests
@@ -0,0 +1,16 @@
+exec 9<>/dev/tcp/129.22.8.162/25
+
+read banner <&9
+echo "$banner"
+
+echo quit >&9
+
+read msg <&9
+echo "$msg"
+
+exec 9<&-
+
+# nifty date command that queries the date/time server
+cat < /dev/tcp/129.22.8.102/13
+
+exit 0
diff --git a/tests/misc/read-nchars.tests b/tests/misc/read-nchars.tests
new file mode 100644
index 00000000..40b1f982
--- /dev/null
+++ b/tests/misc/read-nchars.tests
@@ -0,0 +1,11 @@
+# interactive
+
+# from tty
+read -n 3 -p 'enter three chars: ' xyz
+echo
+echo $xyz
+
+# using readline
+read -p 'enter 3 chars: ' -e -n 3 abc
+# readline outputs a newline for us, so we don't need the extra echo
+echo $abc
diff --git a/tests/misc/wait-bg.tests b/tests/misc/wait-bg.tests
new file mode 100644
index 00000000..95c98b08
--- /dev/null
+++ b/tests/misc/wait-bg.tests
@@ -0,0 +1,25 @@
+#! /bin/bash
+
+i=0
+while [ $i -lt $1 ]
+do
+ /bin/sh -c "sleep 4; exit 0" &
+ rv=$?
+ pid=$!
+ eval bg_pid_$i=$pid
+ echo $$: Job $i: pid is $pid rv=$rv
+ i=$((i + 1))
+done
+
+
+
+i=0
+while [ $i -lt $1 ]
+do
+ eval wpid=\$bg_pid_$i
+ echo Waiting for job $i '('pid $wpid')'
+ wait $wpid
+ rv=$?
+ echo Return value is $rv
+ i=$((i + 1))
+done
diff --git a/tests/more-exp.right b/tests/more-exp.right
index e57ce2ad..c7e1af57 100644
--- a/tests/more-exp.right
+++ b/tests/more-exp.right
@@ -202,3 +202,7 @@ argv[3] = <}>
argv[1] = <hi>
argv[2] = <K>
argv[3] = <}>
+argv[1] = <xxx>
+argv[2] = <yyy>
+1
+argv[1] = <>
diff --git a/tests/more-exp.tests b/tests/more-exp.tests
index d3f4b6f2..a562ae8d 100644
--- a/tests/more-exp.tests
+++ b/tests/more-exp.tests
@@ -453,6 +453,10 @@ recho + "$@"
expect '<+>'
recho +"$@"
+# variants of nested curly braces inside ${...} expressions
+
+# IFS is not the standard one
+
expect '<G { I>' '<K>' '<}>'
recho ${gik:-G { I } K }
@@ -460,3 +464,21 @@ abc=hi
expect '<hi>' '<K>' '<}>'
recho ${abc:-G { I } K }
+
+# reset IFS to the default
+IFS='
+'
+
+# nested ${...} inside ${...} are handled specially
+unset XXX FOO BAR
+expect '<xxx>' '<yyy>'
+XXX=xxx
+FOO=${BAR:-${XXX} yyy}
+recho $FOO
+
+# this was a bug in versions of bash prior to bash-2.04-release
+set -- ''
+expect 1
+echo $#
+expect '<>'
+recho "${@:-}"
diff --git a/tests/new-exp.right b/tests/new-exp.right
index 7f013dec..c2dc10bf 100644
--- a/tests/new-exp.right
+++ b/tests/new-exp.right
@@ -148,6 +148,12 @@ argv[4] = <mnop>
argv[5] = <qrst>
argv[6] = <uvwyyy>
+This
+string
+has
+multiple
+lines.
+This-string-has-multiple-lines.
this is a test of proc subst
this is test 2
./new-exp2.sub: /tmp/bashtmp.x*: No such file or directory
@@ -228,6 +234,10 @@ argv[1] = <e*docrine>
argv[1] = <e*docri*e>
argv[1] = <endocrine>
argv[1] = <endocrine>
+argv[1] = <endocrine>
+argv[1] = <endocrine>
+argv[1] = <endocrine>
+argv[1] = <endocrine>
argv[1] = </usr/bin>
argv[2] = </bin>
argv[3] = </usr/local/bin>
@@ -390,4 +400,38 @@ argv[1] = <5>
argv[1] = <#>
argv[1] = <#>
argv[1] = <>
+argv[1] = <_QUANTITY>
+argv[2] = <_QUART>
+argv[3] = <_QUEST>
+argv[4] = <_QUILL>
+argv[5] = <_QUOTA>
+argv[6] = <_QUOTE>
+argv[1] = <_QUANTITY>
+argv[2] = <_QUART>
+argv[3] = <_QUEST>
+argv[4] = <_QUILL>
+argv[5] = <_QUOTA>
+argv[6] = <_QUOTE>
+argv[1] = <_QUANTITY-_QUART-_QUEST-_QUILL-_QUOTA-_QUOTE>
+./new-exp3.sub: ${!_Q* }: bad substitution
+./new-exp3.sub: ${!1*}: bad substitution
+./new-exp3.sub: ${!@*}: bad substitution
+./new-exp.tests: ${$(($#-1))}: bad substitution
+argv[1] = <a>
+argv[2] = <b>
+argv[3] = <c>
+argv[4] = <d>
+argv[5] = <e>
+argv[6] = <f>
+argv[7] = <g>
+argv[1] = <a>
+argv[2] = <b>
+argv[3] = <c>
+argv[4] = <d>
+argv[5] = <e>
+argv[1] = <a>
+argv[1] = <a>
+argv[2] = <b>
+argv[1] = <>
+./new-exp.tests: $(($# - 2)): substring expression < 0
./new-exp.tests: ABXD: parameter unset
diff --git a/tests/new-exp.tests b/tests/new-exp.tests
index f2d50d83..683fa46a 100644
--- a/tests/new-exp.tests
+++ b/tests/new-exp.tests
@@ -227,6 +227,15 @@ recho ${@//%x*/yyy}
expect a newline
echo $abmcde
+# sneaky way to replace a newline in a variable value with something else
+AVAR=$'This\nstring\nhas\nmultiple\nlines.'
+echo "${AVAR}"
+
+eval BVAR=\"\${AVAR//$'\n'/-}\"
+echo "$BVAR"
+
+unset AVAR BVAR
+
# run process substitution tests in a subshell so that syntax errors
# caused by a shell not implementing process substitution (e.g., one
# built on a NeXT) will not cause the whole test to exit prematurely
@@ -402,6 +411,11 @@ recho ${xxx//$yyy/*}
recho ${xxx/$zzz/*}
recho ${xxx//$zzz/*}
+recho ${xxx//%${zzz}/}
+recho ${xxx//%${zzz}}
+recho ${xxx//#${zzz}/}
+recho ${xxx//#${zzz}}
+
# another case that caused a core dump in bash-2.0
XPATH=/usr/bin:/bin:/usr/local/bin:/usr/gnu/bin::/usr/bin/X11:/sbin:/usr/sbin
@@ -455,6 +469,32 @@ recho "${RECEIVED:$((${#RECEIVED}-1)):1}"
RECEIVED=""
recho "${RECEIVED:$((${#RECEIVED}-1)):1}"
+# tests of new prefix expansion ${!prefix*}
+${THIS_SH} ./new-exp3.sub
+
+# these caused errors and core dumps in versions before bash-2.04
+c=""
+echo ${c//${$(($#-1))}/x/}
+
+set a b c d e f g
+recho "$@"
+
+set -- ${@:1:$(($# - 2))}
+recho "$@"
+
+set a b
+recho ${@:1:$(($# - 2))}
+
+recho ${@:1:0}
+recho ${@:1:1}
+recho ${@:1:2}
+
+recho "${*:1:0}"
+
+# this is an error -- negative expression
+set a
+recho ${@:1:$(($# - 2))}
+
# this must be last!
expect $0: 'ABXD: parameter unset'
recho ${ABXD:?"parameter unset"}
diff --git a/tests/new-exp3.sub b/tests/new-exp3.sub
new file mode 100644
index 00000000..3107ef14
--- /dev/null
+++ b/tests/new-exp3.sub
@@ -0,0 +1,26 @@
+:
+# Set up some dummy variables beginning with _Q
+_QUANTITY=
+_QUOTA=
+_QUOTE=
+_QUILL=
+_QUEST=
+_QUART=
+
+recho ${!_Q*}
+
+IFS="-$IFS"
+
+recho ${!_Q*}
+recho "${!_Q*}"
+
+recho ${!_Y*}
+
+recho "${!_Q* }"
+
+IFS=$' \t\n'
+
+set a b c d e f g h i j k l m n o p
+recho ${!1*}
+
+recho ${!@*}
diff --git a/tests/nquote.right b/tests/nquote.right
index 9651f311..35bf1919 100644
--- a/tests/nquote.right
+++ b/tests/nquote.right
@@ -1,4 +1,5 @@
argv[1] = <^J^J^J>
+argv[1] = <++^J++>
argv[1] = <>
argv[1] = <^J^I >
argv[1] = <abc>
@@ -15,3 +16,7 @@ argv[1] = <hello, $"world">
argv[1] = <$hello, chet>
argv[1] = <hello, chet>
ok
+'abcd'
+'abcd'
+\'abcd\'
+\'abcd\'
diff --git a/tests/nquote.tests b/tests/nquote.tests
index 6ce89079..05709f45 100644
--- a/tests/nquote.tests
+++ b/tests/nquote.tests
@@ -6,6 +6,11 @@ expect()
expect '<^J^J^J>'
recho $'\n\n\n'
+expect '<++^J++>'
+f=$'\n'
+recho "++$f++"
+unset f
+
z1=$''
expect '<>'
recho "$z1"
@@ -61,3 +66,15 @@ case "$z" in
$'\v\f\a\b') echo ok;;
*) echo bad;;
esac
+
+# Dave Korn says this should be allowed and echo 'abcd'
+echo $'\'abcd\''
+
+# printf translates \' to ' ...
+printf "\'abcd\'\n"
+
+# but echo -e doesn't
+echo -e "\'abcd\'"
+echo -e "\\'abcd\\'"
+
+
diff --git a/tests/printf.right b/tests/printf.right
index ac1bce45..53b79b08 100644
--- a/tests/printf.right
+++ b/tests/printf.right
Binary files differ
diff --git a/tests/printf.tests b/tests/printf.tests
index 9b47d9e8..5654ea48 100644
--- a/tests/printf.tests
+++ b/tests/printf.tests
@@ -1,4 +1,5 @@
LC_ALL=C
+LC_NUMERIC=C
# these should output error messages -- the format is required
printf
@@ -22,6 +23,11 @@ printf "no newline " ; printf "now newline\n"
# %% -> %
printf "%%\n"
+# this was a bug caused by pre-processing the string for backslash escapes
+# before doing the `%' format processing -- all versions before bash-2.04
+printf "\045" ; echo
+printf "\045d\n"
+
# simple character output
printf "%c\n" ABCD
@@ -83,6 +89,12 @@ printf -- "--%b--\n"
# of the format string
printf -- "--%b--\n" '4.2\c5.4\n'; printf "\n"
+# unrecognized escape sequences should by displayed unchanged
+printf -- "--%b--\n" '4\.2'
+
+# a bare \ should not be processed as an escape sequence
+printf -- "--%b--\n" '\'
+
# make sure extra arguments are ignored if the format string doesn't
# actually use them
printf "\n" 4.4 BSD
@@ -158,6 +170,23 @@ printf -- "--%6.4b--\n" abcdefghijklmnopqrstuvwxyz
printf -- "--%12.10s--\n" abcdefghijklmnopqrstuvwxyz
printf -- "--%12.10b--\n" abcdefghijklmnopqrstuvwxyz
+# tests for translating \' to ' and \\ to \
+# printf translates \' to ' in the format string...
+printf "\'abcd\'\n"
+
+# but not when the %b format specification is used
+printf "%b\n" \\\'abcd\\\'
+
+# but both translate \\ to \
+printf '\\abcd\\\n'
+printf "%b\n" '\\abcd\\'
+
+# this was reported as a bug in bash-2.03
+# these three lines should all echo `26'
+printf "%d\n" 0x1a
+printf "%d\n" 032
+printf "%d\n" 26
+
# error messages
# this should be an overflow, but error messages vary between systems
diff --git a/tests/read.right b/tests/read.right
index 32ce2630..b9eeffba 100644
--- a/tests/read.right
+++ b/tests/read.right
@@ -29,3 +29,19 @@ argv[1] = < foo>
argv[1] = <foo>
argv[1] = <foo>
argv[1] = < foo>
+a = abcdefg
+a = xyz
+a = -xyz 123-
+a = abc
+1
+4
+1
+4
+./read2.sub: read: -3: invalid timeout specification
+1
+4
+abcde
+./read3.sub: read: -1: invalid number specification
+abc
+ab
+#
diff --git a/tests/read.tests b/tests/read.tests
index 83ef028a..f974324c 100644
--- a/tests/read.tests
+++ b/tests/read.tests
@@ -78,3 +78,12 @@ echo " foo" | { IFS=$' \n' ; read line; recho "$line"; }
echo " foo" | { IFS=$' \t\n' ; read line; recho "$line"; }
echo " foo" | { IFS=$':' ; read line; recho "$line"; }
+
+# test read -d delim behavior
+${THIS_SH} ./read1.sub
+
+# test read -t timeout behavior
+${THIS_SH} ./read2.sub
+
+# test read -n nchars behavior
+${THIS_SH} ./read3.sub
diff --git a/tests/read1.sub b/tests/read1.sub
new file mode 100644
index 00000000..2a36449b
--- /dev/null
+++ b/tests/read1.sub
@@ -0,0 +1,23 @@
+a=7
+echo 'abcdefg|xyz' | {
+ read -d '|' a
+ echo a = "${a-unset}"
+}
+
+echo xyz 123 | {
+ read -d ' ' a
+ echo a = "${a-unset}"
+}
+
+echo xyz 123 | {
+ read -d $'\n' a
+ echo a = -"${a-unset}"-
+}
+
+a=44
+echo abcd | {
+ read -d d a
+ echo a = $a
+}
+
+exit 0
diff --git a/tests/read2.sub b/tests/read2.sub
new file mode 100644
index 00000000..1e632c35
--- /dev/null
+++ b/tests/read2.sub
@@ -0,0 +1,22 @@
+a=4
+
+read -t 2 a
+echo $?
+
+echo $a
+
+sleep 5 | read -t 1 a
+echo $?
+
+echo $a
+
+read -t -3 a
+echo $?
+
+echo $a
+
+# the above should all time out
+echo abcde | {
+ read -t 2 a
+ echo $a
+}
diff --git a/tests/read3.sub b/tests/read3.sub
new file mode 100644
index 00000000..22088cbf
--- /dev/null
+++ b/tests/read3.sub
@@ -0,0 +1,19 @@
+# non-interactive
+
+# error
+read -n -1
+
+# from pipe -- should work, but doesn't change tty attributes
+echo abcdefg | {
+ read -n 3 xyz
+ echo $xyz
+}
+
+# fewer chars than specified
+echo ab | {
+ read -n 3 xyz
+ echo $xyz
+}
+
+read -n 1 < $0
+echo "$REPLY"
diff --git a/tests/redir.tests b/tests/redir.tests
index 4e58754d..3e6e8766 100644
--- a/tests/redir.tests
+++ b/tests/redir.tests
@@ -140,6 +140,11 @@ cd
EOF
echo $l2
+# These should not echo anything -- bug in versions before 2.04
+( ( echo hello 1>&3 ) 3>&1 ) >/dev/null 2>&1
+
+( ( echo hello 1>&3 ) 3>&1 ) >/dev/null 2>&1 | cat
+
# in posix mode, non-interactive shells are not allowed to perform
# filename expansion on input redirections, even if they expand to
# a single filename
diff --git a/tests/run-all b/tests/run-all
index 8a959a14..d3f3a0e9 100644
--- a/tests/run-all
+++ b/tests/run-all
@@ -13,12 +13,14 @@ export THIS_SH
${THIS_SH} ./version
+rm -f /tmp/xx
+
echo Any output from any test, unless otherwise noted, indicates a possible anomaly
for x in run-*
do
case $x in
- $0|run-minimal) ;;
+ $0|run-minimal|run-gprof) ;;
*.orig|*~) ;;
*) echo $x ; sh $x ;;
esac
diff --git a/tests/run-arith-for b/tests/run-arith-for
new file mode 100644
index 00000000..1d130752
--- /dev/null
+++ b/tests/run-arith-for
@@ -0,0 +1,2 @@
+${THIS_SH} ./arith-for.tests > /tmp/xx 2>&1
+diff /tmp/xx arith-for.right && rm -f /tmp/xx
diff --git a/tests/run-extglob2 b/tests/run-extglob2
new file mode 100644
index 00000000..0a6f728e
--- /dev/null
+++ b/tests/run-extglob2
@@ -0,0 +1,4 @@
+PATH=$PATH:`pwd`
+export PATH
+${THIS_SH} ./extglob2.tests | grep -v '^expect' > /tmp/xx
+diff /tmp/xx extglob2.right && rm -f /tmp/xx
diff --git a/tests/run-invert b/tests/run-invert
new file mode 100644
index 00000000..67e08792
--- /dev/null
+++ b/tests/run-invert
@@ -0,0 +1,2 @@
+${THIS_SH} ./invert.tests | grep -v '^expect' > /tmp/xx
+diff /tmp/xx invert.right && rm -f /tmp/xx
diff --git a/tests/run-minimal b/tests/run-minimal
index 018916a2..30141810 100644
--- a/tests/run-minimal
+++ b/tests/run-minimal
@@ -16,6 +16,8 @@ export THIS_SH
${THIS_SH} ./version.mini
+rm -f /tmp/xx
+
echo Testing ${THIS_SH}
echo Any output from any test, unless otherwise noted, indicates a possible anomaly
for x in run-*
@@ -24,8 +26,8 @@ do
$0) ;;
*.orig|*~) ;;
run-dollars|run-execscript|run-func|run-getopts|run-heredoc) echo $x ; sh $x ;;
- run-ifs-tests|run-input-test|run-more-exp|run-nquote|run-posix2) echo $x ; sh $x ;;
- run-posixpat) echo $x ; sh $x ;;
+ run-ifs-tests|run-input-test|run-invert|run-more-exp|run-nquote) echo $x ; sh $x ;;
+ run-posix2|run-posixpat) echo $x ; sh $x ;;
run-precedence|run-quote|run-read|run-rhs-exp|run-strip|run-tilde) echo $x ; sh $x ;;
*) ;;
esac
diff --git a/tests/run-new-exp b/tests/run-new-exp
index 56dff720..2e3d7c9d 100644
--- a/tests/run-new-exp
+++ b/tests/run-new-exp
@@ -2,6 +2,9 @@ echo "warning: two of these tests will fail if your OS does not support" >&2
echo "warning: named pipes or the /dev/fd filesystem. If the tests of the" >&2
echo "warning: process substitution mechanism fail, please do not consider" >&2
echo "warning: this a test failure" >&2
+echo "warning: if you have exported variables beginning with the string _Q," >&2
+echo "warning: diff output may be generated. If so, please do not consider" >&2
+echo "warning: this a test failure" >&2
${THIS_SH} ./new-exp.tests 2>&1 | grep -v '^expect' > /tmp/xx
diff /tmp/xx new-exp.right && rm -f /tmp/xx
diff --git a/tests/run-read b/tests/run-read
index f2444ba8..35c94e40 100644
--- a/tests/run-read
+++ b/tests/run-read
@@ -1,2 +1,2 @@
-${THIS_SH} ./read.tests > /tmp/xx
+${THIS_SH} ./read.tests > /tmp/xx 2>&1
diff /tmp/xx read.right && rm -f /tmp/xx
diff --git a/tests/run-test b/tests/run-test
index 645693f9..32fbde7a 100644
--- a/tests/run-test
+++ b/tests/run-test
@@ -1,2 +1,2 @@
-${THIS_SH} ./test-tests >/tmp/xx 2>&1
+${THIS_SH} ./test.tests >/tmp/xx 2>&1
diff /tmp/xx test.right && rm -f /tmp/xx
diff --git a/tests/shopt.right b/tests/shopt.right
index 9dc01fbc..3eff4b5e 100644
--- a/tests/shopt.right
+++ b/tests/shopt.right
@@ -18,12 +18,15 @@ shopt -u huponexit
shopt -s interactive_comments
shopt -u lithist
shopt -u mailwarn
+shopt -u no_empty_cmd_completion
shopt -u nocaseglob
shopt -u nullglob
+shopt -s progcomp
shopt -s promptvars
shopt -u restricted_shell
shopt -u shift_verbose
shopt -s sourcepath
+shopt -u xpg_echo
--
shopt -u huponexit
shopt -u checkwinsize
@@ -34,6 +37,7 @@ shopt -s cmdhist
shopt -s expand_aliases
shopt -s hostcomplete
shopt -s interactive_comments
+shopt -s progcomp
shopt -s promptvars
shopt -s sourcepath
--
@@ -49,10 +53,12 @@ shopt -u histverify
shopt -u huponexit
shopt -u lithist
shopt -u mailwarn
+shopt -u no_empty_cmd_completion
shopt -u nocaseglob
shopt -u nullglob
shopt -u restricted_shell
shopt -u shift_verbose
+shopt -u xpg_echo
--
cdable_vars off
checkhash off
@@ -66,10 +72,12 @@ histverify off
huponexit off
lithist off
mailwarn off
+no_empty_cmd_completion off
nocaseglob off
nullglob off
restricted_shell off
shift_verbose off
+xpg_echo off
--
set +o allexport
set -o braceexpand
diff --git a/tests/shopt.tests b/tests/shopt.tests
index 00170a97..d4f2a8b1 100644
--- a/tests/shopt.tests
+++ b/tests/shopt.tests
@@ -24,6 +24,7 @@ shopt -u nullglob
shopt -s promptvars
shopt -u shift_verbose
shopt -s sourcepath
+shopt -u xpg_echo
# Now, start checking the output
builtin printf -- "--\n"
diff --git a/tests/test.right b/tests/test.right
index 8684a121..2fd46808 100644
--- a/tests/test.right
+++ b/tests/test.right
@@ -154,6 +154,12 @@ t -w /dev/fd/1
0
t -w /dev/fd/2
0
+t -r /dev/stdin
+0
+t -w /dev/stdout
+0
+t -w /dev/stderr
+0
t
1
b
@@ -221,46 +227,46 @@ t -G /tmp/test.group
t -h /tmp/test.symlink
0
t 4+3 -eq 7
-./test-tests: test: 4+3: integer expression expected
+./test.tests: test: 4+3: integer expression expected
2
b 4-5 -eq 7
-./test-tests: [: 4+3: integer expression expected
+./test.tests: [: 4+3: integer expression expected
2
t 9 -eq 4+5
-./test-tests: test: 4+5: integer expression expected
+./test.tests: test: 4+5: integer expression expected
2
b 9 -eq 4+5
-./test-tests: [: 4+5: integer expression expected
+./test.tests: [: 4+5: integer expression expected
2
t A -eq 7
-./test-tests: test: A: integer expression expected
+./test.tests: test: A: integer expression expected
2
b A -eq 7
-./test-tests: [: A: integer expression expected
+./test.tests: [: A: integer expression expected
2
t 9 -eq B
-./test-tests: test: B: integer expression expected
+./test.tests: test: B: integer expression expected
2
b 9 -eq B
-./test-tests: [: B: integer expression expected
+./test.tests: [: B: integer expression expected
2
t ( 1 = 2
-./test-tests: test: `)' expected
+./test.tests: test: `)' expected
2
b ( 1 = 2
-./test-tests: [: `)' expected, found ]
+./test.tests: [: `)' expected, found ]
2
-./test-tests: test: a: unary operator expected
+./test.tests: test: a: unary operator expected
2
-./test-tests: test: b: binary operator expected
+./test.tests: test: b: binary operator expected
2
-./test-tests: test: -A: unary operator expected
+./test.tests: test: -A: unary operator expected
2
-./test-tests: test: too many arguments
+./test.tests: test: too many arguments
2
-./test-tests: test: too many arguments
+./test.tests: test: too many arguments
2
-./test-tests: [: missing `]'
+./test.tests: [: missing `]'
2
-./test-tests: test: (: unary operator expected
+./test.tests: test: (: unary operator expected
2
diff --git a/tests/test-tests b/tests/test.tests
index d0194d26..9df5cc2c 100644
--- a/tests/test-tests
+++ b/tests/test.tests
@@ -259,6 +259,13 @@ t -w /dev/fd/1
echo 't -w /dev/fd/2'
t -w /dev/fd/2
+echo 't -r /dev/stdin'
+t -r /dev/stdin
+echo 't -w /dev/stdout'
+t -w /dev/stdout
+echo 't -w /dev/stderr'
+t -w /dev/stderr
+
echo 't'
t
echo 'b'
diff --git a/tests/varenv.right b/tests/varenv.right
index 771ee640..f5baaaef 100644
--- a/tests/varenv.right
+++ b/tests/varenv.right
@@ -33,3 +33,4 @@ braceexpand:hashall
hPB
braceexpand:hashall:physical
declare -r SHELLOPTS="braceexpand:hashall:physical"
+abcde
diff --git a/tests/varenv.sh b/tests/varenv.sh
index 8f5a7163..4f907618 100644
--- a/tests/varenv.sh
+++ b/tests/varenv.sh
@@ -125,11 +125,11 @@ export A
# Make sure expansion doesn't use assignment statements preceding a builtin
A=ZVAR echo $A
-PATH=/bin:/usr/bin:/usr/local/bin:.
+XPATH=/bin:/usr/bin:/usr/local/bin:.
func2()
{
local z=yy
- local -a avar=( ${PATH//: } )
+ local -a avar=( ${XPATH//: } )
echo ${avar[@]}
local
}
@@ -184,3 +184,13 @@ echo ${SHELLOPTS}
# and make sure it is readonly
readonly -p | grep SHELLOPTS
+
+# This was an error in bash versions prior to bash-2.04. The `set -a'
+# should cause the assignment statement that's an argument to typeset
+# to create an exported variable
+unset FOOFOO
+FOOFOO=bar
+set -a
+typeset FOOFOO=abcde
+
+printenv FOOFOO
diff --git a/trap.c b/trap.c
index 7e27f185..684d433b 100644
--- a/trap.c
+++ b/trap.c
@@ -7,7 +7,7 @@
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
- Software Foundation; either version 1, or (at your option) any later
+ Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -17,7 +17,7 @@
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#include "config.h"
@@ -29,13 +29,19 @@
#include "bashansi.h"
#include <stdio.h>
+#include <errno.h>
#include "trap.h"
#include "shell.h"
+#include "input.h" /* for save_token_state, restore_token_state */
#include "signames.h"
#include "builtins/common.h"
+#ifndef errno
+extern int errno;
+#endif
+
/* Flags which describe the current handling state of a signal. */
#define SIG_INHERITED 0x0 /* Value inherited from parent. */
#define SIG_TRAPPED 0x1 /* Currently trapped. */
@@ -135,6 +141,25 @@ initialize_traps ()
}
}
+#ifdef INCLUDE_UNUSED
+/* Return a printable representation of the trap handler for SIG. */
+static char *
+trap_handler_string (sig)
+ int sig;
+{
+ if (trap_list[sig] == (char *)DEFAULT_SIG)
+ return "DEFAULT_SIG";
+ else if (trap_list[sig] == (char *)IGNORE_SIG)
+ return "IGNORE_SIG";
+ else if (trap_list[sig] == (char *)IMPOSSIBLE_TRAP_HANDLER)
+ return "IMPOSSIBLE_TRAP_HANDLER";
+ else if (trap_list[sig])
+ return trap_list[sig];
+ else
+ return "NULL";
+}
+#endif
+
/* Return the print name of this signal. */
char *
signal_name (sig)
@@ -183,7 +208,7 @@ void
run_pending_traps ()
{
register int sig;
- int old_exit_value;
+ int old_exit_value, *token_state;
if (catch_flag == 0) /* simple optimization */
return;
@@ -218,8 +243,38 @@ run_pending_traps ()
run_interrupt_trap ();
CLRINTERRUPT;
}
+ else if (trap_list[sig] == (char *)DEFAULT_SIG ||
+ trap_list[sig] == (char *)IGNORE_SIG ||
+ trap_list[sig] == (char *)IMPOSSIBLE_TRAP_HANDLER)
+ {
+ /* This is possible due to a race condition. Say a bash
+ process has SIGTERM trapped. A subshell is spawned
+ using { list; } & and the parent does something and kills
+ the subshell with SIGTERM. It's possible for the subshell
+ to set pending_traps[SIGTERM] to 1 before the code in
+ execute_cmd.c eventually calls restore_original_signals
+ to reset the SIGTERM signal handler in the subshell. The
+ next time run_pending_traps is called, pending_traps[SIGTERM]
+ will be 1, but the trap handler in trap_list[SIGTERM] will
+ be invalid (probably DEFAULT_SIG, but it could be IGNORE_SIG).
+ Unless we catch this, the subshell will dump core when
+ trap_list[SIGTERM] == DEFAULT_SIG, because DEFAULT_SIG is
+ usually 0x0. */
+ internal_warning ("run_pending_traps: bad value in trap_list[%d]: 0x%x",
+ sig, (int)trap_list[sig]);
+ if (trap_list[sig] == (char *)DEFAULT_SIG)
+ {
+ internal_warning ("run_pending_traps: signal handler is SIG_DFL, resending %d (%s) to myself", sig, signal_name (sig));
+ kill (getpid (), sig);
+ }
+ }
else
- parse_and_execute (savestring (trap_list[sig]), "trap", SEVAL_NONINT|SEVAL_NOHIST);
+ {
+ token_state = save_token_state ();
+ parse_and_execute (savestring (trap_list[sig]), "trap", SEVAL_NONINT|SEVAL_NOHIST);
+ restore_token_state (token_state);
+ free (token_state);
+ }
pending_traps[sig] = 0;
@@ -240,12 +295,15 @@ sighandler
trap_handler (sig)
int sig;
{
+ int oerrno;
+
if ((sig >= NSIG) ||
(trap_list[sig] == (char *)DEFAULT_SIG) ||
(trap_list[sig] == (char *)IGNORE_SIG))
programming_error ("trap_handler: bad signal %d", sig);
else
{
+ errno = oerrno;
#if defined (MUST_REINSTALL_SIGHANDLERS)
set_signal_handler (sig, trap_handler);
#endif /* MUST_REINSTALL_SIGHANDLERS */
@@ -255,6 +313,8 @@ trap_handler (sig)
if (interrupt_immediately)
run_pending_traps ();
+
+ errno = oerrno;
}
SIGRETURN (0);
@@ -563,7 +623,7 @@ _run_trap_internal (sig, tag)
char *tag;
{
char *trap_command, *old_trap;
- int old_exit_value, old_line_number;
+ int old_exit_value, old_line_number, *token_state;
/* Run the trap only if SIG is trapped and not ignored, and we are not
currently executing in the trap handler. */
@@ -581,7 +641,12 @@ _run_trap_internal (sig, tag)
/* Need to copy the value of line_number because parse_and_execute
resets it to 1, and the trap command might want it. */
trap_line_number = line_number;
+
+ token_state = save_token_state ();
parse_and_execute (trap_command, tag, SEVAL_NONINT|SEVAL_NOHIST);
+ restore_token_state (token_state);
+ free (token_state);
+
last_command_exit_value = old_exit_value;
running_trap = 0;
diff --git a/trap.h b/trap.h
index b39d5e90..c833cd42 100644
--- a/trap.h
+++ b/trap.h
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if !defined (_TRAP_H_)
#define _TRAP_H_
diff --git a/unwind_prot.c b/unwind_prot.c
index 17144dc7..60e911dd 100644
--- a/unwind_prot.c
+++ b/unwind_prot.c
@@ -7,7 +7,7 @@ This file is part of GNU Bash, the Bourne Again SHell.
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 1, or (at your option) any later
+Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -17,7 +17,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
/* **************************************************************** */
/* */
diff --git a/unwind_prot.h b/unwind_prot.h
index 14ef5dc8..a321f0ee 100644
--- a/unwind_prot.h
+++ b/unwind_prot.h
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if !defined (_UNWIND_PROT_H)
#define _UNWIND_PROT_H
diff --git a/variables.c b/variables.c
index 8f4bb420..615aacd1 100644
--- a/variables.c
+++ b/variables.c
@@ -6,7 +6,7 @@
Bash is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 1, or (at your option)
+ the Free Software Foundation; either version 2, or (at your option)
any later version.
Bash is distributed in the hope that it will be useful, but WITHOUT
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with Bash; see the file COPYING. If not, write to the Free
- Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#include "config.h"
@@ -58,6 +58,10 @@
# include <readline/history.h>
#endif /* HISTORY */
+#if defined (PROGRAMMABLE_COMPLETION)
+# include "pcomplete.h"
+#endif
+
/* Variables used here and defined in other files. */
extern int posixly_correct;
extern int variable_context, line_number;
@@ -69,6 +73,7 @@ extern char *shell_name;
extern char *primary_prompt, *secondary_prompt;
extern char *current_host_name;
extern Function *this_shell_builtin;
+extern SHELL_VAR *this_shell_function;
extern char *this_command_name;
extern time_t shell_start_time;
@@ -175,17 +180,14 @@ initialize_shell_variables (env, privmode)
char_index == strlen (name) */
/* If exported function, define it now. */
- if (privmode == 0 && STREQN ("() {", string, 4))
+ if (privmode == 0 && read_but_dont_execute == 0 && STREQN ("() {", string, 4))
{
string_length = strlen (string);
temp_string = xmalloc (3 + string_length + char_index);
-#if 1
+
strcpy (temp_string, name);
temp_string[char_index] = ' ';
strcpy (temp_string + char_index + 1, string);
-#else
- sprintf (temp_string, "%s %s", name, string);
-#endif
parse_and_execute (temp_string, name, SEVAL_NONINT|SEVAL_NOHIST);
@@ -196,14 +198,15 @@ initialize_shell_variables (env, privmode)
if (temp_var = find_function (name))
{
- temp_var->attributes |= (att_exported | att_imported);
+ VSETATTR (temp_var, (att_exported|att_imported));
array_needs_making = 1;
}
else
report_error ("error importing function definition for `%s'", name);
+ /* ( */
if (name[char_index - 1] == ')' && name[char_index - 2] == '\0')
- name[char_index - 2] = '(';
+ name[char_index - 2] = '('; /* ) */
}
#if defined (ARRAY_VARS)
# if 0
@@ -214,7 +217,7 @@ initialize_shell_variables (env, privmode)
temp_string = extract_array_assignment_list (string, &string_length);
temp_var = assign_array_from_string (name, temp_string);
FREE (temp_string);
- temp_var->attributes |= (att_exported | att_imported);
+ VSETATTR (temp_var, (att_exported | att_imported));
array_needs_making = 1;
}
# endif
@@ -222,11 +225,17 @@ initialize_shell_variables (env, privmode)
else
{
temp_var = bind_variable (name, string);
- temp_var->attributes |= (att_exported | att_imported);
+ VSETATTR (temp_var, (att_exported | att_imported));
array_needs_making = 1;
}
name[char_index] = '=';
+ /* temp_var can be NULL if it was an exported function with a syntax
+ error (a different bug, but it still shouldn't dump core). */
+ if (temp_var && function_p (temp_var) == 0) /* XXX not yet */
+ {
+ CACHE_IMPORTSTR (temp_var, name);
+ }
}
/* If we got PWD from the environment, update our idea of the current
@@ -253,7 +262,7 @@ initialize_shell_variables (env, privmode)
`environment variable' and therefore should be auto-exported.
Make a dummy invisible variable for OLDPWD, and mark it as exported. */
temp_var = bind_variable ("OLDPWD", (char *)NULL);
- temp_var->attributes |= (att_exported | att_invisible);
+ VSETATTR (temp_var, (att_exported | att_invisible));
/* Set up initial value of $_ */
temp_var = bind_variable ("_", dollar_vars[0]);
@@ -391,6 +400,13 @@ initialize_shell_variables (env, privmode)
}
#endif /* HISTORY */
+ temp_var = find_variable ("SSH_CLIENT");
+ if (temp_var && imported_p (temp_var))
+ {
+ VUNSETATTR (temp_var, att_exported);
+ array_needs_making = 1;
+ }
+
/* Get the user's real and effective user ids. */
uidset ();
@@ -419,7 +435,7 @@ set_home_var ()
temp_var = find_variable ("HOME");
if (temp_var == 0)
temp_var = bind_variable ("HOME", get_home_dir ());
- temp_var->attributes |= att_exported;
+ VSETATTR (temp_var, att_exported);
}
/* Set $SHELL to the user's login shell if it is not already set. Call
@@ -436,7 +452,7 @@ set_shell_var ()
get_current_user_info ();
temp_var = bind_variable ("SHELL", current_user.shell);
}
- temp_var->attributes |= att_exported;
+ VSETATTR (temp_var, att_exported);
}
static char *
@@ -555,12 +571,6 @@ adjust_shell_level (change)
static void
initialize_shell_level ()
{
-#if 0
- SHELL_VAR *temp_var;
-
- temp_var = set_if_not ("SHLVL", "0");
- set_auto_export (temp_var);
-#endif
adjust_shell_level (1);
}
@@ -574,9 +584,9 @@ set_ppid ()
name = inttostr ((int) getppid (), namebuf, sizeof(namebuf));
temp_var = find_variable ("PPID");
if (temp_var)
- temp_var->attributes &= ~(att_readonly | att_exported);
+ VUNSETATTR (temp_var, (att_readonly | att_exported));
temp_var = bind_variable ("PPID", name);
- temp_var->attributes |= (att_readonly | att_integer);
+ VSETATTR (temp_var, (att_readonly | att_integer));
}
static void
@@ -588,20 +598,20 @@ uidset ()
b = inttostr (current_user.uid, buff, sizeof (buff));
v = find_variable ("UID");
if (v)
- v->attributes &= ~att_readonly;
+ VUNSETATTR (v, att_readonly);
v = bind_variable ("UID", b);
- v->attributes |= (att_readonly | att_integer);
+ VSETATTR (v, (att_readonly | att_integer));
if (current_user.euid != current_user.uid)
b = inttostr (current_user.euid, buff, sizeof (buff));
v = find_variable ("EUID");
if (v)
- v->attributes &= ~att_readonly;
+ VUNSETATTR (v, att_readonly);
v = bind_variable ("EUID", b);
- v->attributes |= (att_readonly | att_integer);
+ VSETATTR (v, (att_readonly | att_integer));
}
#if defined (ARRAY_VARS)
@@ -629,7 +639,7 @@ make_vers_array ()
array_add_element (av, 4, release_status);
array_add_element (av, 5, MACHTYPE);
- vv->attributes |= att_readonly;
+ VSETATTR (vv, att_readonly);
}
#endif /* ARRAY_VARS */
@@ -893,6 +903,25 @@ print_array_assignment (var, quoted)
stupidly_hack_special_variables, but I wanted the changes as
localized as possible. */
+static SHELL_VAR *
+null_assign (self, value)
+ SHELL_VAR *self;
+ char *value;
+{
+ return (self);
+}
+
+#if defined (ARRAY_VARS)
+static SHELL_VAR *
+null_array_assign (self, ind, value)
+ SHELL_VAR *self;
+ int ind;
+ char *value;
+{
+ return (self);
+}
+#endif
+
/* The value of $SECONDS. This is the number of seconds since shell
invocation, or, the number of seconds since the last assignment + the
value of the last assignment. */
@@ -920,7 +949,7 @@ get_seconds (var)
FREE (var->value);
- var->attributes |= att_integer;
+ VSETATTR (var, att_integer);
var->value = p;
return (var);
}
@@ -979,7 +1008,7 @@ get_random (var)
FREE (var->value);
- var->attributes |= att_integer;
+ VSETATTR (var, att_integer);
var->value = p;
return (var);
}
@@ -1071,42 +1100,74 @@ get_groupset (self)
return (self);
}
#endif /* ARRAY_VARS */
-
-static void
-initialize_dynamic_variables ()
+
+static SHELL_VAR *
+get_funcname (self)
+ SHELL_VAR *self;
+{
+ if (variable_context && this_shell_function)
+ {
+ FREE (self->value);
+ self->value = savestring (this_shell_function->name);
+ }
+ return (self);
+}
+
+void
+make_funcname_visible (on_or_off)
+ int on_or_off;
{
SHELL_VAR *v;
- v = bind_variable ("SECONDS", (char *)NULL);
- v->dynamic_value = get_seconds;
- v->assign_func = assign_seconds;
+ v = find_variable ("FUNCNAME");
+ if (v == 0 || v->dynamic_value == 0)
+ return;
+
+ if (on_or_off)
+ VUNSETATTR (v, att_invisible);
+ else
+ VSETATTR (v, att_invisible);
+}
+
+#define INIT_DYNAMIC_VAR(var, val, gfunc, afunc) \
+ do \
+ { \
+ v = bind_variable (var, val); \
+ v->dynamic_value = gfunc; \
+ v->assign_func = afunc; \
+ } while (0)
+
+#define INIT_DYNAMIC_ARRAY_VAR(var, gfunc, afunc) \
+ do \
+ { \
+ v = make_new_array_variable (var); \
+ v->dynamic_value = gfunc; \
+ v->assign_func = afunc; \
+ } while (0)
- v = bind_variable ("RANDOM", (char *)NULL);
- v->dynamic_value = get_random;
- v->assign_func = assign_random;
+static void
+initialize_dynamic_variables ()
+{
+ SHELL_VAR *v;
- v = bind_variable ("LINENO", (char *)NULL);
- v->dynamic_value = get_lineno;
- v->assign_func = assign_lineno;
+ INIT_DYNAMIC_VAR ("SECONDS", (char *)NULL, get_seconds, assign_seconds);
+ INIT_DYNAMIC_VAR ("RANDOM", (char *)NULL, get_random, assign_random);
+ INIT_DYNAMIC_VAR ("LINENO", (char *)NULL, get_lineno, assign_lineno);
#if defined (HISTORY)
- v = bind_variable ("HISTCMD", (char *)NULL);
- v->dynamic_value = get_histcmd;
- v->assign_func = (DYNAMIC_FUNC *)NULL;
+ INIT_DYNAMIC_VAR ("HISTCMD", (char *)NULL, get_histcmd, (DYNAMIC_FUNC *)NULL);
#endif
#if defined (PUSHD_AND_POPD) && defined (ARRAY_VARS)
- v = make_new_array_variable ("DIRSTACK");
- v->dynamic_value = get_dirstack;
- v->assign_func = assign_dirstack;
+ INIT_DYNAMIC_ARRAY_VAR ("DIRSTACK", get_dirstack, assign_dirstack);
#endif /* PUSHD_AND_POPD && ARRAY_VARS */
#if defined (ARRAY_VARS)
- v = make_new_array_variable ("GROUPS");
- v->dynamic_value = get_groupset;
- v->assign_func = (DYNAMIC_FUNC *)NULL;
- v->attributes |= att_readonly;
+ INIT_DYNAMIC_ARRAY_VAR ("GROUPS", get_groupset, null_array_assign);
#endif
+
+ INIT_DYNAMIC_VAR ("FUNCNAME", (char *)NULL, get_funcname, null_assign);
+ VSETATTR (v, att_invisible);
}
/* How to get a pointer to the shell variable or function named NAME.
@@ -1211,6 +1272,15 @@ make_local_variable (name)
if (old_var && old_var->context == variable_context)
return (old_var);
+ /* Since this is called only from the local/declare/typeset code, we can
+ call builtin_error here without worry (of course, it will also work
+ for anything that sets this_command_name). */
+ if (old_var && readonly_p (old_var))
+ {
+ builtin_error ("%s: readonly variable");
+ return ((SHELL_VAR *)NULL);
+ }
+
elt = remove_hash_item (name, shell_variables);
if (elt)
{
@@ -1233,6 +1303,8 @@ make_local_variable (name)
new_var->value = xmalloc (1);
new_var->value[0] = '\0';
+ CLEAR_EXPORTSTR (new_var);
+
new_var->dynamic_value = (DYNAMIC_FUNC *)NULL;
new_var->assign_func = (DYNAMIC_FUNC *)NULL;
@@ -1244,7 +1316,7 @@ make_local_variable (name)
}
new_var->context = variable_context;
- new_var->attributes |= att_local;
+ VSETATTR (new_var, att_local);
/* XXX */
if (variable_context >= local_variable_stack_size)
@@ -1269,11 +1341,13 @@ make_local_array_variable (name)
ARRAY *array;
var = make_local_variable (name);
+ if (var == 0)
+ return var;
array = new_array ();
FREE (value_cell(var));
var->value = (char *)array;
- var->attributes |= att_array;
+ VSETATTR (var, att_array);
return var;
}
#endif /* ARRAY_VARS */
@@ -1293,6 +1367,7 @@ make_new_variable (name)
entry->attributes = 0;
entry->name = savestring (name);
entry->value = (char *)NULL;
+ CLEAR_EXPORTSTR (entry);
entry->dynamic_value = (DYNAMIC_FUNC *)NULL;
entry->assign_func = (DYNAMIC_FUNC *)NULL;
@@ -1320,7 +1395,7 @@ make_new_array_variable (name)
entry = make_new_variable (name);
array = new_array ();
entry->value = (char *)array;
- entry->attributes |= att_array;
+ VSETATTR (entry, att_array);
return entry;
}
#endif
@@ -1383,7 +1458,10 @@ bind_variable (name, value)
#else
else if (entry->assign_func)
#endif
- return ((*(entry->assign_func)) (entry, value));
+ {
+ INVALIDATE_EXPORTSTR (entry);
+ return ((*(entry->assign_func)) (entry, value));
+ }
else
{
if (readonly_p (entry))
@@ -1393,10 +1471,13 @@ bind_variable (name, value)
}
/* Variables which are bound are visible. */
- entry->attributes &= ~att_invisible;
+ VUNSETATTR (entry, att_invisible);
newval = make_variable_value (entry, value);
+ /* Invalidate any cached export string */
+ INVALIDATE_EXPORTSTR (entry);
+
#if defined (ARRAY_VARS)
/* XXX -- this bears looking at again -- XXX */
/* If an existing array variable x is being assigned to with x=b or
@@ -1419,7 +1500,7 @@ bind_variable (name, value)
}
if (mark_modified_vars)
- entry->attributes |= att_exported;
+ VSETATTR (entry, att_exported);
if (exported_p (entry))
array_needs_making = 1;
@@ -1427,6 +1508,67 @@ bind_variable (name, value)
return (entry);
}
+/* Make VAR, a simple shell variable, have value VALUE. Once assigned a
+ value, variables are no longer invisible. This is a duplicate of part
+ of the internals of bind_variable. If the variable is exported, or
+ all modified variables should be exported, mark the variable for export
+ and note that the export environment needs to be recreated. */
+SHELL_VAR *
+bind_variable_value (var, value)
+ SHELL_VAR *var;
+ char *value;
+{
+ char *t;
+
+ VUNSETATTR (var, att_invisible);
+
+ t = make_variable_value (var, value);
+ FREE (var->value);
+ var->value = t;
+
+ INVALIDATE_EXPORTSTR (var);
+
+ if (mark_modified_vars)
+ VSETATTR (var, att_exported);
+
+ if (exported_p (var))
+ array_needs_making = 1;
+
+ return (var);
+}
+
+/* Bind/create a shell variable with the name LHS to the RHS.
+ This creates or modifies a variable such that it is an integer.
+
+ This used to be in expr.c, but it is here so that all of the
+ variable binding stuff is localized. Since we don't want any
+ recursive evaluation from bind_variable() (possible without this code,
+ since bind_variable() calls the evaluator for variables with the integer
+ attribute set), we temporarily turn off the integer attribute for each
+ variable we set here, then turn it back on after binding as necessary. */
+
+SHELL_VAR *
+bind_int_variable (lhs, rhs)
+ char *lhs, *rhs;
+{
+ register SHELL_VAR *v;
+ int isint;
+
+ isint = 0;
+ v = find_variable (lhs);
+ if (v)
+ {
+ isint = integer_p (v);
+ VUNSETATTR (v, att_integer);
+ }
+
+ v = bind_variable (lhs, rhs);
+ if (isint)
+ VSETATTR (v, att_integer);
+
+ return (v);
+}
+
#if defined (ARRAY_VARS)
/* Convert a shell variable to an array variable. The original value is
saved as array[0]. */
@@ -1440,10 +1582,14 @@ convert_var_to_array (var)
oldval = value_cell (var);
array = new_array ();
array_add_element (array, 0, oldval);
+
FREE (value_cell (var));
var->value = (char *)array;
- var->attributes |= att_array;
- var->attributes &= ~att_invisible;
+
+ INVALIDATE_EXPORTSTR (var);
+
+ VSETATTR (var, att_array);
+ VUNSETATTR (var, att_invisible);
return var;
}
@@ -1526,6 +1672,40 @@ assign_array_var_from_word_list (var, list)
return var;
}
+/* For each word in a compound array assignment, if the word looks like
+ [ind]=value, quote the `[' and `]' before the `=' to protect them from
+ unwanted filename expansion. */
+static void
+quote_array_assignment_chars (list)
+ WORD_LIST *list;
+{
+ char *s, *t, *nword;
+ int saw_eq;
+ WORD_LIST *l;
+
+ for (l = list; l; l = l->next)
+ {
+ if (l->word == 0 || l->word->word == 0 || l->word->word[0] == '\0')
+ continue; /* should not happen, but just in case... */
+ /* Don't bother if it doesn't look like [ind]=value */
+ if (l->word->word[0] != '[' || strchr (l->word->word, '=') == 0) /* ] */
+ continue;
+ s = nword = xmalloc (strlen (l->word->word) * 2 + 1);
+ saw_eq = 0;
+ for (t = l->word->word; *t; )
+ {
+ if (*t == '=')
+ saw_eq = 1;
+ if (saw_eq == 0 && (*t == '[' || *t == ']'))
+ *s++ = '\\';
+ *s++ = *t++;
+ }
+ *s = '\0';
+ free (l->word->word);
+ l->word->word = nword;
+ }
+}
+
/* Perform a compound array assignment: VAR->name=( VALUE ). The
VALUE has already had the parentheses stripped. */
SHELL_VAR *
@@ -1559,13 +1739,15 @@ assign_array_var_from_string (var, value)
/* First we split the string on whitespace, using the shell parser
(ksh93 seems to do this). */
list = parse_string_to_word_list (val, "array assign");
+
+ /* If we're using [subscript]=value, we need to quote each [ and ] to
+ prevent unwanted filename expansion. */
+ if (list)
+ quote_array_assignment_chars (list);
+
/* Now that we've split it, perform the shell expansions on each
word in the list. */
-#if 0
- nlist = list ? expand_words_shellexp (list) : (WORD_LIST *)NULL;
-#else
nlist = list ? expand_words_no_vars (list) : (WORD_LIST *)NULL;
-#endif
dispose_words (list);
@@ -1660,6 +1842,8 @@ dispose_variable (var)
else
FREE (value_cell (var));
+ FREE_EXPORTSTR (var);
+
free (var->name);
if (exported_p (var))
@@ -1756,6 +1940,11 @@ makunbound (name, hash_list)
if (old_var && exported_p (old_var))
array_needs_making++;
+#if defined (PROGRAMMABLE_COMPLETION)
+ if (hash_list == shell_functions)
+ set_itemlist_dirty (&it_functions);
+#endif
+
/* If we're unsetting a local variable and we're still executing inside
the function, just mark the variable as invisible.
kill_all_local_variables will clean it up later. This must be done
@@ -1764,7 +1953,8 @@ makunbound (name, hash_list)
to add it back into the correct hash table. */
if (old_var && local_p (old_var) && variable_context == old_var->context)
{
- old_var->attributes |= att_invisible;
+ VSETATTR (old_var, att_invisible);
+ INVALIDATE_EXPORTSTR (old_var);
new_elt = add_hash_item (savestring (old_var->name), hash_list);
new_elt->data = (char *)old_var;
stupidly_hack_special_variables (old_var->name);
@@ -1852,7 +2042,7 @@ kill_all_local_variables ()
{
for (i = 0; var = list[i]; i++)
{
- var->attributes &= ~att_local;
+ VUNSETATTR (var, att_local);
makunbound (var->name, varlist);
}
free (list);
@@ -1914,29 +2104,37 @@ bind_function (name, value)
elt = add_hash_item (savestring (name), shell_functions);
- elt->data = (char *)new_shell_variable (name);
- entry = (SHELL_VAR *)elt->data;
+ entry = new_shell_variable (name);
entry->dynamic_value = entry->assign_func = (DYNAMIC_FUNC *)NULL;
+ CLEAR_EXPORTSTR (entry);
/* Functions are always made at the top level. This allows a
function to define another function (like autoload). */
entry->context = 0;
+
+ elt->data = (char *)entry;
}
+ INVALIDATE_EXPORTSTR (entry);
+
if (entry->value)
dispose_command ((COMMAND *)entry->value);
entry->value = value ? (char *)copy_command (value) : (char *)NULL;
- entry->attributes |= att_function;
+ VSETATTR (entry, att_function);
if (mark_modified_vars)
- entry->attributes |= att_exported;
+ VSETATTR (entry, att_exported);
- entry->attributes &= ~att_invisible; /* Just to be sure */
+ VUNSETATTR (entry, att_invisible); /* Just to be sure */
if (exported_p (entry))
array_needs_making = 1;
+#if defined (PROGRAMMABLE_COMPLETION)
+ set_itemlist_dirty (&it_functions);
+#endif
+
return (entry);
}
@@ -1969,6 +2167,8 @@ copy_variable (var)
copy->dynamic_value = var->dynamic_value;
copy->assign_func = var->assign_func;
+ copy->exportstr = COPY_EXPORTSTR (var);
+
copy->context = var->context;
/* Don't bother copying previous contexts along with this variable. */
@@ -1999,7 +2199,7 @@ set_var_read_only (name)
SHELL_VAR *entry;
FIND_OR_MAKE_VARIABLE (name, entry);
- entry->attributes |= att_readonly;
+ VSETATTR (entry, att_readonly);
}
#ifdef INCLUDE_UNUSED
@@ -2013,7 +2213,7 @@ set_func_read_only (name)
entry = find_function (name);
if (entry)
- entry->attributes |= att_readonly;
+ VSETATTR (entry, att_readonly);
}
/* Make the variable associated with NAME be auto-exported.
@@ -2102,8 +2302,6 @@ assignment (string)
return (0);
}
-#ifdef READLINE
-
static int
visible_var (var)
SHELL_VAR *var;
@@ -2126,19 +2324,17 @@ _visible_names (table)
}
SHELL_VAR **
-all_visible_variables ()
+all_visible_functions ()
{
- return (_visible_names (shell_variables));
+ return (_visible_names (shell_functions));
}
SHELL_VAR **
-all_visible_functions ()
+all_visible_variables ()
{
- return (_visible_names (shell_functions));
+ return (_visible_names (shell_variables));
}
-#endif /* READLINE */
-
/* Return non-zero if the variable VAR is visible and exported. Array
variables cannot be exported. */
static int
@@ -2148,6 +2344,114 @@ visible_and_exported (var)
return (invisible_p (var) == 0 && exported_p (var));
}
+SHELL_VAR **
+all_exported_variables ()
+{
+ SHELL_VAR **list;
+
+ list = map_over (visible_and_exported, shell_variables);
+ if (list)
+ sort_variables (list);
+ return (list);
+}
+
+#if defined (ARRAY_VARS)
+/* Return non-zero if the variable VAR is visible and an array. */
+static int
+visible_array_vars (var)
+ SHELL_VAR *var;
+{
+ return (invisible_p (var) == 0 && array_p (var));
+}
+
+SHELL_VAR **
+all_array_variables ()
+{
+ SHELL_VAR **list;
+
+ list = map_over (visible_array_vars, shell_variables);
+ if (list)
+ sort_variables (list);
+ return (list);
+}
+#endif /* ARRAY_VARS */
+
+char **
+all_variables_matching_prefix (prefix)
+ char *prefix;
+{
+ SHELL_VAR **varlist;
+ char **rlist;
+ int vind, rind, plen;
+
+ plen = STRLEN (prefix);
+ varlist = all_visible_variables ();
+ for (vind = 0; varlist && varlist[vind]; vind++)
+ ;
+ if (varlist == 0 || vind == 0)
+ return ((char **)NULL);
+ rlist = alloc_array (vind + 1);
+ for (vind = rind = 0; varlist[vind]; vind++)
+ {
+ if (plen == 0 || STREQN (prefix, varlist[vind]->name, plen))
+ rlist[rind++] = savestring (varlist[vind]->name);
+ }
+ rlist[rind] = (char *)0;
+ free (varlist);
+
+ return rlist;
+}
+
+static inline char *
+mk_env_string (name, value)
+ char *name, *value;
+{
+ int name_len, value_len;
+ char *p;
+
+ name_len = strlen (name);
+ value_len = STRLEN (value);
+ p = xmalloc (2 + name_len + value_len);
+ strcpy (p, name);
+ p[name_len] = '=';
+ if (value && *value)
+ strcpy (p + name_len + 1, value);
+ else
+ p[name_len + 1] = '\0';
+ return (p);
+}
+
+/* Debugging */
+static int
+valid_exportstr (v)
+ SHELL_VAR *v;
+{
+ char *s;
+
+ s = v->exportstr;
+ if (legal_variable_starter (*s) == 0)
+ {
+ internal_error ("invalid character %d in exportstr for %s", *s, v->name);
+ return (0);
+ }
+ for (s = v->exportstr + 1; s && *s; s++)
+ {
+ if (*s == '=')
+ break;
+ if (legal_variable_char (*s) == 0)
+ {
+ internal_error ("invalid character %d in exportstr for %s", *s, v->name);
+ return (0);
+ }
+ }
+ if (*s != '=')
+ {
+ internal_error ("no `=' in exportstr for %s", v->name);
+ return (0);
+ }
+ return (1);
+}
+
/* Make an array of assignment statements from the hash table
HASHED_VARS which contains SHELL_VARs. Only visible, exported
variables are eligible. */
@@ -2165,11 +2469,32 @@ make_var_array (hashed_vars)
if (vars == 0)
return (char **)NULL;
- list = (char **)xmalloc ((1 + array_len ((char **)vars)) * sizeof (char *));
+ list = alloc_array ((1 + array_len ((char **)vars)));
+
+#define USE_EXPORTSTR (value == var->exportstr)
for (i = 0, list_index = 0; var = vars[i]; i++)
{
- if (function_p (var))
+ if (var->exportstr)
+ {
+#if defined(__CYGWIN__) || defined (__CYGWIN32__)
+ INVALIDATE_EXPORTSTR (var);
+ value = value_cell (var);
+#else
+ /* XXX -- this test can go away in the next release, to be replaced
+ by a simple `value = var->exportstr;', when the exportstr code
+ is better-tested. Until then, don't do it for cygwin at all,
+ since that system has some weird environment variables. */
+ if (valid_exportstr (var))
+ value = var->exportstr;
+ else
+ {
+ INVALIDATE_EXPORTSTR (var);
+ value = value_cell (var);
+ }
+#endif
+ }
+ else if (function_p (var))
value = named_function_string ((char *)NULL, function_cell (var), 0);
#if defined (ARRAY_VARS)
else if (array_p (var))
@@ -2184,20 +2509,24 @@ make_var_array (hashed_vars)
if (value)
{
- int name_len, value_len;
- char *p;
-
- name_len = strlen (var->name);
- value_len = strlen (value);
- p = list[list_index] = xmalloc (2 + name_len + value_len);
- strcpy (p, var->name);
- p[name_len] = '=';
- strcpy (p + name_len + 1, value);
+ /* Gee, I'd like to get away with not using savestring() if we're
+ using the cached exportstr... */
+ list[list_index] = USE_EXPORTSTR ? savestring (value)
+ : mk_env_string (var->name, value);
+
+ if (USE_EXPORTSTR == 0 && function_p (var))
+ {
+ SAVE_EXPORTSTR (var, list[list_index]);
+ }
list_index++;
+#undef USE_EXPORTSTR
+
+#if 0 /* not yet */
#if defined (ARRAY_VARS)
if (array_p (var))
free (value);
#endif
+#endif
}
}
@@ -2245,18 +2574,8 @@ assign_in_env (string)
free (temp);
}
- nlen = strlen (name);
- vlen = value ? strlen (value) : 0;
- temp = xmalloc (2 + nlen + vlen);
- strcpy (temp, name);
- temp[nlen] = '=';
- temp[nlen + 1] = '\0';
- if (value)
- {
- if (*value)
- strcpy (temp + nlen + 1, value);
- free (value);
- }
+ temp = mk_env_string (name, value);
+ FREE (value);
free (name);
if (temporary_env == 0)
@@ -2317,6 +2636,7 @@ find_name_in_env_array (name, array)
temp->prev_context = (SHELL_VAR *)NULL;
temp->dynamic_value = temp->assign_func = (DYNAMIC_FUNC *)NULL;
+ CLEAR_EXPORTSTR (temp);
return (temp);
}
@@ -2427,6 +2747,12 @@ merge_builtin_env ()
merge_env_array (builtin_env);
}
+int
+any_temporary_variables ()
+{
+ return (temporary_env || function_env);
+}
+
/* Add ENVSTR to the end of the exported environment, EXPORT_ENV. */
#define add_to_export_env(envstr,do_alloc) \
do \
@@ -2495,7 +2821,7 @@ maybe_make_export_env ()
variables are not (yet) exported, this will always be big enough
for the exported variables and functions, without any temporary
or function environments. */
- new_size = shell_variables->nentries + shell_functions->nentries + 1;
+ new_size = HASH_ENTRIES (shell_variables) + HASH_ENTRIES (shell_functions) + 1;
if (new_size > export_env_size)
{
export_env_size = new_size;
@@ -2688,6 +3014,7 @@ struct name_and_function {
{ "LC_COLLATE", sv_locale },
{ "LC_CTYPE", sv_locale },
{ "LC_MESSAGES", sv_locale },
+ { "LC_NUMERIC", sv_locale },
{ "LANG", sv_locale },
#if defined (HAVE_TZSET) && defined (PROMPT_STRING_DECODE)
@@ -2768,7 +3095,13 @@ void
sv_hostfile (name)
char *name;
{
- hostname_list_initialized = 0;
+ SHELL_VAR *v;
+
+ v = find_variable (name);
+ if (v == 0)
+ clear_hostname_list ();
+ else
+ hostname_list_initialized = 0;
}
#endif /* READLINE */
diff --git a/variables.h b/variables.h
index 9246860f..baf7fd6a 100644
--- a/variables.h
+++ b/variables.h
@@ -1,5 +1,23 @@
/* variables.h -- data structures for shell variables. */
+/* 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 2, or (at your option)
+ any later version.
+
+ Bash is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
+ License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Bash; see the file COPYING. If not, write to the Free
+ Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+
#if !defined (_VARIABLES_H_)
#define _VARIABLES_H_
@@ -12,9 +30,24 @@
/* 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. */
-#define HOSTTYPE CONF_HOSTTYPE
-#define OSTYPE CONF_OSTYPE
-#define MACHTYPE CONF_MACHTYPE
+#if !defined (RHAPSODY)
+# 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 */
/* What a shell variable looks like. */
@@ -23,6 +56,7 @@ typedef struct variable *DYNAMIC_FUNC ();
typedef struct variable {
char *name; /* Symbol that the user types. */
char *value; /* Value that is returned. */
+ char *exportstr; /* String for the environment. */
DYNAMIC_FUNC *dynamic_value; /* Function called to return a `dynamic'
value for a variable, like $SECONDS
or $RANDOM. */
@@ -45,6 +79,7 @@ typedef struct variable {
#define att_imported 0x080 /* came from environment */
#define att_local 0x100 /* variable is local to a function */
#define att_tempvar 0x200 /* variable came from the temp environment */
+#define att_importstr 0x400 /* exportstr points into initial environment */
#define exported_p(var) ((((var)->attributes) & (att_exported)))
#define readonly_p(var) ((((var)->attributes) & (att_readonly)))
@@ -62,9 +97,51 @@ typedef struct variable {
#define array_cell(var) ((ARRAY *)(var)->value)
#define SETVARATTR(var, attr, undo) \
- ((undo == 0) ? ((var)->attributes |= (attribute)) \
- : ((var)->attributes &= ~(attribute)))
+ ((undo == 0) ? ((var)->attributes |= (attr)) \
+ : ((var)->attributes &= ~(attr)))
+
+#define VSETATTR(var, attr) ((var)->attributes |= (attr))
+#define VUNSETATTR(var, attr) ((var)->attributes &= ~(attr))
+
+/* Macros to perform various operations on `exportstr' member of a SHELL_VAR. */
+#define CLEAR_EXPORTSTR(var) (var)->exportstr = (char *)NULL
+#define COPY_EXPORTSTR(var) ((var)->exportstr) ? savestring ((var)->exportstr) : (char *)NULL
+#define SET_EXPORTSTR(var, value) (var)->exportstr = (value)
+#define SAVE_EXPORTSTR(var, value) (var)->exportstr = (value) ? savestring (value) : (char *)NULL
+#define FREE_EXPORTSTR(var) \
+ do { \
+ if ((var)->exportstr) \
+ { \
+ if (((var)->attributes & att_importstr) == 0) \
+ free ((var)->exportstr); \
+ } \
+ } while (0)
+
+#if 0
+#define CACHE_IMPORTSTR(var, value) \
+ do { \
+ (var)->exportstr = value; \
+ (var)->attributes |= att_importstr; \
+ } while (0)
+#else
+#define CACHE_IMPORTSTR(var, value) \
+ do { \
+ (var)->exportstr = savestring (value); \
+ } while (0)
+#endif
+
+#define INVALIDATE_EXPORTSTR(var) \
+ do { \
+ if ((var)->exportstr) \
+ { \
+ if (((var)->attributes & att_importstr) == 0) \
+ free ((var)->exportstr); \
+ (var)->exportstr = (char *)NULL; \
+ (var)->attributes &= ~att_importstr; \
+ } \
+ } while (0)
+
/* Stuff for hacking variables. */
extern int variable_context;
extern HASH_TABLE *shell_variables, *shell_functions;
@@ -78,6 +155,8 @@ extern void set_lines_and_columns __P((int, int));
extern void set_ppid __P((void));
+extern void make_funcname_visible __P((int));
+
extern SHELL_VAR *find_function __P((char *));
extern SHELL_VAR *find_variable __P((char *));
extern SHELL_VAR *find_variable_internal __P((char *, int));
@@ -86,11 +165,18 @@ extern SHELL_VAR *copy_variable __P((SHELL_VAR *));
extern SHELL_VAR *make_local_variable __P((char *));
extern SHELL_VAR *bind_variable __P((char *, char *));
extern SHELL_VAR *bind_function __P((char *, COMMAND *));
+
extern SHELL_VAR **map_over __P((Function *, HASH_TABLE *));
extern SHELL_VAR **all_shell_variables __P((void));
extern SHELL_VAR **all_shell_functions __P((void));
extern SHELL_VAR **all_visible_variables __P((void));
extern SHELL_VAR **all_visible_functions __P((void));
+extern SHELL_VAR **all_exported_variables __P((void));
+#if defined (ARRAY_VARS)
+extern SHELL_VAR **all_array_variables __P((void));
+#endif
+
+extern char **all_variables_matching_prefix __P((char *));
extern char **make_var_array __P((HASH_TABLE *));
extern char **add_or_supercede_exported_var __P((char *, int));
@@ -98,6 +184,9 @@ extern char **add_or_supercede_exported_var __P((char *, int));
extern char *get_string_value __P((char *));
extern char *make_variable_value __P((SHELL_VAR *, char *));
+extern SHELL_VAR *bind_variable_value __P((SHELL_VAR *, char *));
+extern SHELL_VAR *bind_int_variable __P((char *, char *));
+
extern int assignment __P((char *));
extern int variable_in_context __P((SHELL_VAR *));
extern int assign_in_env __P((char *));
diff --git a/version.c b/version.c
index 6adf7ba6..b0ba6e32 100644
--- a/version.c
+++ b/version.c
@@ -6,7 +6,7 @@
Bash is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
- Software Foundation; either version 1, or (at your option) any later
+ Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#include <stdio.h>
@@ -67,5 +67,5 @@ show_shell_version (extended)
{
printf ("GNU bash, version %s (%s)\n", shell_version_string (), MACHTYPE);
if (extended)
- printf ("Copyright 1998 Free Software Foundation, Inc.\n");
+ printf ("Copyright 1999 Free Software Foundation, Inc.\n");
}
diff --git a/xmalloc.c b/xmalloc.c
index ed7dd05c..ae00baf3 100644
--- a/xmalloc.c
+++ b/xmalloc.c
@@ -7,7 +7,7 @@
Readline is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
- Free Software Foundation; either version 1, or (at your option) any
+ Free Software Foundation; either version 2, or (at your option) any
later version.
Readline is distributed in the hope that it will be useful, but
@@ -17,7 +17,7 @@
You should have received a copy of the GNU General Public License
along with Readline; see the file COPYING. If not, write to the Free
- Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if defined (HAVE_CONFIG_H)
#include <config.h>
@@ -123,7 +123,7 @@ xrealloc (pointer, bytes)
don't need to know what free() returns. */
void
xfree (string)
- char *string;
+ PTR_T string;
{
if (string)
free (string);
diff --git a/y.tab.c b/y.tab.c
index a19a1fce..dd66aa92 100644
--- a/y.tab.c
+++ b/y.tab.c
@@ -30,19 +30,20 @@
#define ASSIGNMENT_WORD 280
#define NUMBER 281
#define ARITH_CMD 282
-#define COND_CMD 283
-#define AND_AND 284
-#define OR_OR 285
-#define GREATER_GREATER 286
-#define LESS_LESS 287
-#define LESS_AND 288
-#define GREATER_AND 289
-#define SEMI_SEMI 290
-#define LESS_LESS_MINUS 291
-#define AND_GREATER 292
-#define LESS_GREATER 293
-#define GREATER_BAR 294
-#define yacc_EOF 295
+#define ARITH_FOR_EXPRS 283
+#define COND_CMD 284
+#define AND_AND 285
+#define OR_OR 286
+#define GREATER_GREATER 287
+#define LESS_LESS 288
+#define LESS_AND 289
+#define GREATER_AND 290
+#define SEMI_SEMI 291
+#define LESS_LESS_MINUS 292
+#define AND_GREATER 293
+#define LESS_GREATER 294
+#define GREATER_BAR 295
+#define yacc_EOF 296
#line 21 "/usr/homes/chet/src/bash/src/parse.y"
@@ -127,6 +128,7 @@ extern Function *last_shell_builtin, *this_shell_builtin;
extern int bash_input_fd_changed;
#endif
+extern int errno;
/* **************************************************************** */
/* */
/* "Forward" declarations */
@@ -204,9 +206,12 @@ static int function_dstart;
/* The line number in a script on which a function body starts. */
static int function_bstart;
+/* The line number in a script at which an arithmetic for command starts. */
+static int arith_for_lineno;
+
static REDIRECTEE redir;
-#line 183 "/usr/homes/chet/src/bash/src/parse.y"
+#line 187 "/usr/homes/chet/src/bash/src/parse.y"
typedef union {
WORD_DESC *word; /* the word that we read. */
int number; /* the number that we read. */
@@ -226,26 +231,26 @@ typedef union {
-#define YYFINAL 269
+#define YYFINAL 279
#define YYFLAG -32768
-#define YYNTBASE 52
+#define YYNTBASE 53
-#define YYTRANSLATE(x) ((unsigned)(x) <= 295 ? yytranslate[x] : 85)
+#define YYTRANSLATE(x) ((unsigned)(x) <= 296 ? yytranslate[x] : 87)
static const char yytranslate[] = { 0,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 42,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 43,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 40, 2, 50,
- 51, 2, 2, 2, 47, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 41, 46,
- 2, 45, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 41, 2, 51,
+ 52, 2, 2, 2, 48, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 42, 47,
+ 2, 46, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 48, 44, 49, 2, 2, 2, 2, 2,
+ 2, 2, 49, 45, 50, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
@@ -262,7 +267,7 @@ static const char yytranslate[] = { 0,
6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
- 36, 37, 38, 39, 43
+ 36, 37, 38, 39, 40, 44
};
#if YYDEBUG != 0
@@ -272,88 +277,89 @@ static const short yyprhs[] = { 0,
64, 67, 71, 74, 78, 81, 85, 88, 92, 95,
99, 102, 105, 109, 111, 113, 115, 117, 120, 122,
125, 127, 129, 132, 134, 136, 142, 148, 150, 152,
- 154, 156, 158, 160, 162, 169, 176, 184, 192, 203,
- 214, 221, 228, 236, 244, 255, 266, 273, 281, 288,
- 294, 301, 306, 310, 316, 324, 331, 335, 337, 341,
- 346, 353, 359, 361, 364, 369, 374, 380, 386, 389,
- 393, 395, 399, 402, 404, 407, 411, 415, 419, 424,
- 429, 434, 439, 444, 446, 448, 450, 452, 453, 456,
- 458, 461, 464, 469, 474, 478, 482, 484, 486, 489,
- 492, 496, 500, 505, 507, 509
+ 154, 156, 158, 160, 162, 164, 171, 178, 186, 194,
+ 205, 216, 224, 232, 239, 246, 254, 262, 273, 284,
+ 291, 299, 306, 312, 319, 324, 328, 334, 342, 349,
+ 353, 355, 359, 364, 371, 377, 379, 382, 387, 392,
+ 398, 404, 407, 411, 413, 417, 420, 422, 425, 429,
+ 433, 437, 442, 447, 452, 457, 462, 464, 466, 468,
+ 470, 471, 474, 476, 479, 482, 487, 492, 496, 500,
+ 502, 504, 507, 510, 514, 518, 523, 525, 527
};
-static const short yyrhs[] = { 80,
- 42, 0, 42, 0, 1, 42, 0, 43, 0, 24,
- 0, 53, 24, 0, 45, 24, 0, 46, 24, 0,
- 26, 45, 24, 0, 26, 46, 24, 0, 31, 24,
- 0, 26, 31, 24, 0, 32, 24, 0, 26, 32,
- 24, 0, 33, 26, 0, 26, 33, 26, 0, 34,
- 26, 0, 26, 34, 26, 0, 33, 24, 0, 26,
- 33, 24, 0, 34, 24, 0, 26, 34, 24, 0,
- 36, 24, 0, 26, 36, 24, 0, 34, 47, 0,
- 26, 34, 47, 0, 33, 47, 0, 26, 33, 47,
- 0, 37, 24, 0, 26, 38, 24, 0, 38, 24,
- 0, 39, 24, 0, 26, 39, 24, 0, 24, 0,
- 25, 0, 54, 0, 54, 0, 56, 54, 0, 55,
- 0, 57, 55, 0, 57, 0, 59, 0, 59, 56,
- 0, 60, 0, 62, 0, 12, 75, 14, 75, 15,
- 0, 13, 75, 14, 75, 15, 0, 61, 0, 65,
- 0, 64, 0, 66, 0, 67, 0, 68, 0, 63,
- 0, 10, 24, 79, 14, 75, 15, 0, 10, 24,
- 79, 48, 75, 49, 0, 10, 24, 41, 79, 14,
- 75, 15, 0, 10, 24, 41, 79, 48, 75, 49,
- 0, 10, 24, 79, 20, 53, 78, 79, 14, 75,
- 15, 0, 10, 24, 79, 20, 53, 78, 79, 48,
- 75, 49, 0, 11, 24, 79, 14, 74, 15, 0,
- 11, 24, 79, 48, 74, 49, 0, 11, 24, 41,
- 79, 14, 74, 15, 0, 11, 24, 41, 79, 48,
- 74, 49, 0, 11, 24, 79, 20, 53, 78, 79,
- 14, 74, 15, 0, 11, 24, 79, 20, 53, 78,
- 79, 48, 74, 49, 0, 8, 24, 79, 20, 79,
- 9, 0, 8, 24, 79, 20, 72, 79, 9, 0,
- 8, 24, 79, 20, 70, 9, 0, 24, 50, 51,
- 79, 66, 0, 16, 24, 50, 51, 79, 66, 0,
- 16, 24, 79, 66, 0, 50, 75, 51, 0, 3,
- 75, 4, 75, 7, 0, 3, 75, 4, 75, 5,
- 75, 7, 0, 3, 75, 4, 75, 69, 7, 0,
- 48, 74, 49, 0, 27, 0, 17, 28, 18, 0,
- 6, 75, 4, 75, 0, 6, 75, 4, 75, 5,
- 75, 0, 6, 75, 4, 75, 69, 0, 71, 0,
- 72, 71, 0, 79, 73, 51, 75, 0, 79, 73,
- 51, 79, 0, 79, 50, 73, 51, 75, 0, 79,
- 50, 73, 51, 79, 0, 71, 35, 0, 72, 71,
- 35, 0, 24, 0, 73, 44, 24, 0, 79, 76,
- 0, 74, 0, 79, 77, 0, 77, 42, 79, 0,
- 77, 40, 79, 0, 77, 41, 79, 0, 77, 29,
- 79, 77, 0, 77, 30, 79, 77, 0, 77, 40,
- 79, 77, 0, 77, 41, 79, 77, 0, 77, 42,
- 79, 77, 0, 82, 0, 42, 0, 41, 0, 43,
- 0, 0, 79, 42, 0, 81, 0, 81, 40, 0,
- 81, 41, 0, 81, 29, 79, 81, 0, 81, 30,
- 79, 81, 0, 81, 40, 81, 0, 81, 41, 81,
- 0, 82, 0, 83, 0, 21, 83, 0, 84, 83,
- 0, 84, 21, 83, 0, 21, 84, 83, 0, 83,
- 44, 79, 83, 0, 58, 0, 22, 0, 22, 23,
- 0
+static const short yyrhs[] = { 82,
+ 43, 0, 43, 0, 1, 43, 0, 44, 0, 24,
+ 0, 54, 24, 0, 46, 24, 0, 47, 24, 0,
+ 26, 46, 24, 0, 26, 47, 24, 0, 32, 24,
+ 0, 26, 32, 24, 0, 33, 24, 0, 26, 33,
+ 24, 0, 34, 26, 0, 26, 34, 26, 0, 35,
+ 26, 0, 26, 35, 26, 0, 34, 24, 0, 26,
+ 34, 24, 0, 35, 24, 0, 26, 35, 24, 0,
+ 37, 24, 0, 26, 37, 24, 0, 35, 48, 0,
+ 26, 35, 48, 0, 34, 48, 0, 26, 34, 48,
+ 0, 38, 24, 0, 26, 39, 24, 0, 39, 24,
+ 0, 40, 24, 0, 26, 40, 24, 0, 24, 0,
+ 25, 0, 55, 0, 55, 0, 57, 55, 0, 56,
+ 0, 58, 56, 0, 58, 0, 60, 0, 60, 57,
+ 0, 61, 0, 64, 0, 12, 77, 14, 77, 15,
+ 0, 13, 77, 14, 77, 15, 0, 63, 0, 67,
+ 0, 66, 0, 68, 0, 69, 0, 70, 0, 62,
+ 0, 65, 0, 10, 24, 81, 14, 77, 15, 0,
+ 10, 24, 81, 49, 77, 50, 0, 10, 24, 42,
+ 81, 14, 77, 15, 0, 10, 24, 42, 81, 49,
+ 77, 50, 0, 10, 24, 81, 20, 54, 80, 81,
+ 14, 77, 15, 0, 10, 24, 81, 20, 54, 80,
+ 81, 49, 77, 50, 0, 10, 28, 80, 81, 14,
+ 77, 15, 0, 10, 28, 80, 81, 49, 77, 50,
+ 0, 11, 24, 81, 14, 76, 15, 0, 11, 24,
+ 81, 49, 76, 50, 0, 11, 24, 42, 81, 14,
+ 76, 15, 0, 11, 24, 42, 81, 49, 76, 50,
+ 0, 11, 24, 81, 20, 54, 80, 81, 14, 76,
+ 15, 0, 11, 24, 81, 20, 54, 80, 81, 49,
+ 76, 50, 0, 8, 24, 81, 20, 81, 9, 0,
+ 8, 24, 81, 20, 74, 81, 9, 0, 8, 24,
+ 81, 20, 72, 9, 0, 24, 51, 52, 81, 68,
+ 0, 16, 24, 51, 52, 81, 68, 0, 16, 24,
+ 81, 68, 0, 51, 77, 52, 0, 3, 77, 4,
+ 77, 7, 0, 3, 77, 4, 77, 5, 77, 7,
+ 0, 3, 77, 4, 77, 71, 7, 0, 49, 76,
+ 50, 0, 27, 0, 17, 29, 18, 0, 6, 77,
+ 4, 77, 0, 6, 77, 4, 77, 5, 77, 0,
+ 6, 77, 4, 77, 71, 0, 73, 0, 74, 73,
+ 0, 81, 75, 52, 77, 0, 81, 75, 52, 81,
+ 0, 81, 51, 75, 52, 77, 0, 81, 51, 75,
+ 52, 81, 0, 73, 36, 0, 74, 73, 36, 0,
+ 24, 0, 75, 45, 24, 0, 81, 78, 0, 76,
+ 0, 81, 79, 0, 79, 43, 81, 0, 79, 41,
+ 81, 0, 79, 42, 81, 0, 79, 30, 81, 79,
+ 0, 79, 31, 81, 79, 0, 79, 41, 81, 79,
+ 0, 79, 42, 81, 79, 0, 79, 43, 81, 79,
+ 0, 84, 0, 43, 0, 42, 0, 44, 0, 0,
+ 81, 43, 0, 83, 0, 83, 41, 0, 83, 42,
+ 0, 83, 30, 81, 83, 0, 83, 31, 81, 83,
+ 0, 83, 41, 83, 0, 83, 42, 83, 0, 84,
+ 0, 85, 0, 21, 85, 0, 86, 85, 0, 86,
+ 21, 85, 0, 21, 86, 85, 0, 85, 45, 81,
+ 85, 0, 59, 0, 22, 0, 22, 23, 0
};
#endif
#if YYDEBUG != 0
static const short yyrline[] = { 0,
- 232, 241, 248, 263, 273, 275, 279, 284, 289, 294,
- 299, 304, 309, 315, 321, 326, 331, 336, 341, 346,
- 351, 356, 361, 368, 375, 380, 385, 390, 395, 400,
- 405, 410, 415, 422, 424, 426, 430, 434, 445, 447,
- 451, 453, 455, 484, 486, 488, 490, 492, 494, 496,
- 498, 500, 502, 504, 508, 510, 512, 514, 516, 518,
- 522, 526, 530, 534, 538, 542, 548, 550, 552, 556,
- 560, 563, 567, 571, 573, 575, 580, 584, 588, 592,
- 594, 596, 600, 601, 605, 607, 609, 611, 615, 616,
- 620, 622, 631, 639, 640, 646, 647, 654, 658, 660,
- 662, 669, 671, 673, 677, 678, 679, 682, 683, 692,
- 698, 707, 715, 717, 719, 726, 729, 733, 735, 740,
- 745, 750, 757, 760, 764, 766
+ 237, 246, 253, 268, 278, 280, 284, 289, 294, 299,
+ 304, 309, 314, 320, 326, 331, 336, 341, 346, 351,
+ 356, 361, 366, 373, 380, 385, 390, 395, 400, 405,
+ 410, 415, 420, 427, 429, 431, 435, 439, 450, 452,
+ 456, 458, 460, 497, 499, 501, 503, 505, 507, 509,
+ 511, 513, 515, 517, 519, 523, 525, 527, 529, 531,
+ 533, 537, 539, 542, 546, 550, 554, 558, 562, 568,
+ 570, 572, 576, 580, 583, 587, 594, 596, 598, 603,
+ 607, 611, 615, 617, 619, 623, 624, 628, 630, 632,
+ 634, 638, 639, 643, 645, 654, 662, 663, 669, 670,
+ 677, 681, 683, 685, 692, 694, 696, 700, 701, 702,
+ 705, 706, 715, 721, 730, 738, 740, 742, 749, 752,
+ 756, 758, 763, 768, 773, 780, 783, 787, 789
};
#endif
@@ -363,32 +369,33 @@ static const short yyrline[] = { 0,
static const char * const yytname[] = { "$","error","$undefined.","IF","THEN",
"ELSE","ELIF","FI","CASE","ESAC","FOR","SELECT","WHILE","UNTIL","DO","DONE",
"FUNCTION","COND_START","COND_END","COND_ERROR","IN","BANG","TIME","TIMEOPT",
-"WORD","ASSIGNMENT_WORD","NUMBER","ARITH_CMD","COND_CMD","AND_AND","OR_OR","GREATER_GREATER",
-"LESS_LESS","LESS_AND","GREATER_AND","SEMI_SEMI","LESS_LESS_MINUS","AND_GREATER",
-"LESS_GREATER","GREATER_BAR","'&'","';'","'\\n'","yacc_EOF","'|'","'>'","'<'",
-"'-'","'{'","'}'","'('","')'","inputunit","word_list","redirection","simple_command_element",
-"redirection_list","simple_command","command","shell_command","for_command",
-"select_command","case_command","function_def","subshell","if_command","group_command",
-"arith_command","cond_command","elif_clause","case_clause","pattern_list","case_clause_sequence",
-"pattern","list","compound_list","list0","list1","list_terminator","newline_list",
-"simple_list","simple_list1","pipeline_command","pipeline","timespec", NULL
+"WORD","ASSIGNMENT_WORD","NUMBER","ARITH_CMD","ARITH_FOR_EXPRS","COND_CMD","AND_AND",
+"OR_OR","GREATER_GREATER","LESS_LESS","LESS_AND","GREATER_AND","SEMI_SEMI","LESS_LESS_MINUS",
+"AND_GREATER","LESS_GREATER","GREATER_BAR","'&'","';'","'\\n'","yacc_EOF","'|'",
+"'>'","'<'","'-'","'{'","'}'","'('","')'","inputunit","word_list","redirection",
+"simple_command_element","redirection_list","simple_command","command","shell_command",
+"for_command","arith_for_command","select_command","case_command","function_def",
+"subshell","if_command","group_command","arith_command","cond_command","elif_clause",
+"case_clause","pattern_list","case_clause_sequence","pattern","list","compound_list",
+"list0","list1","list_terminator","newline_list","simple_list","simple_list1",
+"pipeline_command","pipeline","timespec", NULL
};
#endif
static const short yyr1[] = { 0,
- 52, 52, 52, 52, 53, 53, 54, 54, 54, 54,
- 54, 54, 54, 54, 54, 54, 54, 54, 54, 54,
- 54, 54, 54, 54, 54, 54, 54, 54, 54, 54,
- 54, 54, 54, 55, 55, 55, 56, 56, 57, 57,
- 58, 58, 58, 59, 59, 59, 59, 59, 59, 59,
- 59, 59, 59, 59, 60, 60, 60, 60, 60, 60,
- 61, 61, 61, 61, 61, 61, 62, 62, 62, 63,
- 63, 63, 64, 65, 65, 65, 66, 67, 68, 69,
- 69, 69, 70, 70, 71, 71, 71, 71, 72, 72,
- 73, 73, 74, 75, 75, 76, 76, 76, 77, 77,
- 77, 77, 77, 77, 78, 78, 78, 79, 79, 80,
- 80, 80, 81, 81, 81, 81, 81, 82, 82, 82,
- 82, 82, 83, 83, 84, 84
+ 53, 53, 53, 53, 54, 54, 55, 55, 55, 55,
+ 55, 55, 55, 55, 55, 55, 55, 55, 55, 55,
+ 55, 55, 55, 55, 55, 55, 55, 55, 55, 55,
+ 55, 55, 55, 56, 56, 56, 57, 57, 58, 58,
+ 59, 59, 59, 60, 60, 60, 60, 60, 60, 60,
+ 60, 60, 60, 60, 60, 61, 61, 61, 61, 61,
+ 61, 62, 62, 63, 63, 63, 63, 63, 63, 64,
+ 64, 64, 65, 65, 65, 66, 67, 67, 67, 68,
+ 69, 70, 71, 71, 71, 72, 72, 73, 73, 73,
+ 73, 74, 74, 75, 75, 76, 77, 77, 78, 78,
+ 78, 79, 79, 79, 79, 79, 79, 80, 80, 80,
+ 81, 81, 82, 82, 82, 83, 83, 83, 83, 83,
+ 84, 84, 84, 84, 84, 85, 85, 86, 86
};
static const short yyr2[] = { 0,
@@ -397,214 +404,216 @@ static const short yyr2[] = { 0,
2, 3, 2, 3, 2, 3, 2, 3, 2, 3,
2, 2, 3, 1, 1, 1, 1, 2, 1, 2,
1, 1, 2, 1, 1, 5, 5, 1, 1, 1,
- 1, 1, 1, 1, 6, 6, 7, 7, 10, 10,
- 6, 6, 7, 7, 10, 10, 6, 7, 6, 5,
- 6, 4, 3, 5, 7, 6, 3, 1, 3, 4,
- 6, 5, 1, 2, 4, 4, 5, 5, 2, 3,
- 1, 3, 2, 1, 2, 3, 3, 3, 4, 4,
- 4, 4, 4, 1, 1, 1, 1, 0, 2, 1,
- 2, 2, 4, 4, 3, 3, 1, 1, 2, 2,
- 3, 3, 4, 1, 1, 2
+ 1, 1, 1, 1, 1, 6, 6, 7, 7, 10,
+ 10, 7, 7, 6, 6, 7, 7, 10, 10, 6,
+ 7, 6, 5, 6, 4, 3, 5, 7, 6, 3,
+ 1, 3, 4, 6, 5, 1, 2, 4, 4, 5,
+ 5, 2, 3, 1, 3, 2, 1, 2, 3, 3,
+ 3, 4, 4, 4, 4, 4, 1, 1, 1, 1,
+ 0, 2, 1, 2, 2, 4, 4, 3, 3, 1,
+ 1, 2, 2, 3, 3, 4, 1, 1, 2
};
static const short yydefact[] = { 0,
- 0, 108, 0, 0, 0, 108, 108, 0, 0, 0,
- 125, 34, 35, 0, 78, 0, 0, 0, 0, 0,
- 0, 0, 0, 2, 4, 0, 0, 108, 108, 36,
- 39, 41, 124, 42, 44, 48, 45, 54, 50, 49,
- 51, 52, 53, 0, 110, 117, 118, 0, 3, 94,
- 0, 0, 108, 108, 108, 0, 0, 108, 0, 119,
- 0, 126, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 11, 13, 19, 15, 27, 21, 17, 25,
- 23, 29, 31, 32, 7, 8, 0, 0, 0, 34,
- 40, 37, 43, 1, 108, 108, 111, 112, 108, 0,
- 120, 108, 109, 93, 95, 104, 0, 108, 0, 108,
- 0, 108, 108, 0, 0, 79, 122, 108, 12, 14,
- 20, 16, 28, 22, 18, 26, 24, 30, 33, 9,
- 10, 77, 0, 73, 38, 0, 0, 115, 116, 0,
- 121, 0, 108, 108, 108, 108, 108, 108, 0, 108,
- 0, 108, 0, 108, 0, 108, 0, 0, 108, 72,
- 0, 113, 114, 0, 0, 123, 108, 108, 74, 0,
- 0, 0, 97, 98, 96, 0, 83, 108, 0, 108,
- 108, 0, 5, 0, 0, 108, 108, 0, 0, 0,
- 46, 47, 0, 70, 0, 0, 76, 99, 100, 101,
- 102, 103, 69, 89, 84, 0, 67, 91, 0, 0,
- 0, 0, 55, 6, 106, 105, 107, 108, 56, 0,
- 0, 61, 108, 62, 71, 75, 108, 108, 108, 108,
- 90, 68, 0, 0, 108, 57, 58, 0, 63, 64,
- 0, 80, 0, 0, 0, 108, 92, 85, 86, 108,
- 108, 108, 108, 108, 82, 87, 88, 0, 0, 0,
- 0, 81, 59, 60, 65, 66, 0, 0, 0
+ 0, 111, 0, 0, 0, 111, 111, 0, 0, 0,
+ 128, 34, 35, 0, 81, 0, 0, 0, 0, 0,
+ 0, 0, 0, 2, 4, 0, 0, 111, 111, 36,
+ 39, 41, 127, 42, 44, 54, 48, 45, 55, 50,
+ 49, 51, 52, 53, 0, 113, 120, 121, 0, 3,
+ 97, 0, 0, 111, 111, 0, 111, 0, 0, 111,
+ 0, 122, 0, 129, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 11, 13, 19, 15, 27, 21,
+ 17, 25, 23, 29, 31, 32, 7, 8, 0, 0,
+ 0, 34, 40, 37, 43, 1, 111, 111, 114, 115,
+ 111, 0, 123, 111, 112, 96, 98, 107, 0, 111,
+ 0, 109, 108, 110, 111, 111, 0, 111, 111, 0,
+ 0, 82, 125, 111, 12, 14, 20, 16, 28, 22,
+ 18, 26, 24, 30, 33, 9, 10, 80, 0, 76,
+ 38, 0, 0, 118, 119, 0, 124, 0, 111, 111,
+ 111, 111, 111, 111, 0, 111, 0, 111, 0, 0,
+ 111, 0, 111, 0, 0, 111, 75, 0, 116, 117,
+ 0, 0, 126, 111, 111, 77, 0, 0, 0, 100,
+ 101, 99, 0, 86, 111, 0, 111, 111, 0, 5,
+ 0, 0, 111, 111, 111, 111, 0, 0, 0, 46,
+ 47, 0, 73, 0, 0, 79, 102, 103, 104, 105,
+ 106, 72, 92, 87, 0, 70, 94, 0, 0, 0,
+ 0, 56, 6, 111, 57, 0, 0, 0, 0, 64,
+ 111, 65, 74, 78, 111, 111, 111, 111, 93, 71,
+ 0, 0, 111, 58, 59, 0, 62, 63, 66, 67,
+ 0, 83, 0, 0, 0, 111, 95, 88, 89, 111,
+ 111, 111, 111, 111, 85, 90, 91, 0, 0, 0,
+ 0, 84, 60, 61, 68, 69, 0, 0, 0
};
-static const short yydefgoto[] = { 267,
- 184, 30, 31, 93, 32, 33, 34, 35, 36, 37,
- 38, 39, 40, 41, 42, 43, 170, 176, 177, 178,
- 210, 50, 51, 104, 105, 218, 52, 44, 138, 106,
- 47, 48
+static const short yydefgoto[] = { 277,
+ 191, 30, 31, 95, 32, 33, 34, 35, 36, 37,
+ 38, 39, 40, 41, 42, 43, 44, 177, 183, 184,
+ 185, 219, 51, 52, 106, 107, 115, 53, 45, 144,
+ 108, 48, 49
};
-static const short yypact[] = { 246,
- -34,-32768, 11, 20, 24,-32768,-32768, 33, -10, 369,
- 29, 19,-32768, 529,-32768, 42, 47, 30, 36, 64,
- 66, 78, 81,-32768,-32768, 84, 92,-32768,-32768,-32768,
--32768, 155,-32768, 513,-32768,-32768,-32768,-32768,-32768,-32768,
--32768,-32768,-32768, 89, -15,-32768, 77, 410,-32768,-32768,
- 130, 287,-32768, 95, 99, 127, 131, 97, 132, 77,
- 492,-32768, 100, 128, 129, 44, 56, 134, 135, 136,
- 139, 140,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
--32768,-32768,-32768,-32768,-32768,-32768, 105, 287, 104,-32768,
--32768,-32768, 513,-32768,-32768,-32768, 328, 328,-32768, 492,
- 77,-32768,-32768,-32768, 88,-32768, 1,-32768, -1,-32768,
- 16,-32768,-32768, 116, -32,-32768, 77,-32768,-32768,-32768,
+static const short yypact[] = { 256,
+ -9,-32768, 28, 54, 31,-32768,-32768, 38, -14, 382,
+ 49, 24,-32768, 188,-32768, 41, 56, 35, 42, 61,
+ 73, 75, 100,-32768,-32768, 111, 112,-32768,-32768,-32768,
+-32768, 171,-32768, 530,-32768,-32768,-32768,-32768,-32768,-32768,
+-32768,-32768,-32768,-32768, 95, 124,-32768, 59, 424,-32768,
+-32768, 136, 298,-32768, 104, 64, 107, 137, 142, 106,
+ 140, 59, 508,-32768, 108, 135, 138, 45, 55, 139,
+ 143, 146, 154, 155,-32768,-32768,-32768,-32768,-32768,-32768,
+-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 114, 298,
+ 131,-32768,-32768,-32768, 530,-32768,-32768,-32768, 340, 340,
+-32768, 508, 59,-32768,-32768,-32768, 80,-32768, -8,-32768,
+ -4,-32768,-32768,-32768,-32768,-32768, -1,-32768,-32768, 132,
+ -11,-32768, 59,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
+-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 80,-32768,
+-32768, 298, 298, 89, 89, 466, 59, 82,-32768,-32768,
+-32768,-32768,-32768,-32768, -3,-32768, 156,-32768, 4, 11,
+-32768, 156,-32768, 170, 177,-32768,-32768, -11,-32768,-32768,
+ 340, 340, 59,-32768,-32768,-32768, 179, 298, 298, 298,
+ 298, 298, 184, 158,-32768, -2,-32768,-32768, 183,-32768,
+ 52, 149,-32768,-32768,-32768,-32768, 186, 52, 152,-32768,
+-32768, -11,-32768, 208, 212,-32768,-32768,-32768, 101, 101,
+ 101,-32768,-32768, 190, 0,-32768,-32768, 200, -31, 215,
+ 181,-32768,-32768,-32768,-32768, 218, 191, 221, 194,-32768,
-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
--32768,-32768, 88,-32768,-32768, 287, 287, 69, 69, 451,
- 77, 79,-32768,-32768,-32768,-32768,-32768,-32768, 3,-32768,
- 144,-32768, 13,-32768, 144,-32768, 141, 157,-32768,-32768,
- -32,-32768,-32768, 328, 328, 77,-32768,-32768,-32768, 166,
- 287, 287, 287, 287, 287, 169, 147,-32768, -4,-32768,
--32768, 175,-32768, 52, 146,-32768,-32768, 181, 52, 149,
--32768,-32768, -32,-32768, 192, 199,-32768,-32768,-32768, 71,
- 71, 71,-32768,-32768, 170, 0,-32768,-32768, 180, -22,
- 191, 161,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 196,
- 163,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
--32768,-32768, 28, 189,-32768,-32768,-32768, 17,-32768,-32768,
- 25, 114, 287, 287, 287,-32768,-32768,-32768, 287,-32768,
--32768,-32768,-32768,-32768,-32768,-32768, 287, 200, 167, 202,
- 171,-32768,-32768,-32768,-32768,-32768, 218, 219,-32768
+ -25, 216,-32768,-32768,-32768, 14,-32768,-32768,-32768,-32768,
+ 15, 128, 298, 298, 298,-32768,-32768,-32768, 298,-32768,
+-32768,-32768,-32768,-32768,-32768,-32768, 298, 230, 196, 232,
+ 198,-32768,-32768,-32768,-32768,-32768, 249, 251,-32768
};
static const short yypgoto[] = {-32768,
- 67, -30, 194,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
--32768,-32768,-32768, -112,-32768,-32768, -19,-32768, 46,-32768,
- 18, -17, -6,-32768, -60, 39, -21,-32768, 6, 12,
- -8, 220
+ 90, -28, 224,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
+-32768,-32768,-32768,-32768, -118,-32768,-32768, 1,-32768, 76,
+-32768, 44, -20, -6,-32768, -64, -154, -24,-32768, 5,
+ 2, 7, 250
};
-#define YYLAST 575
-
-
-static const short yytable[] = { 56,
- 57, 60, 160, 92, 207, 45, 88, 49, 232, 103,
- 87, 46, 150, 95, 96, 28, 180, 59, 151, 208,
- 148, 234, 89, 208, 97, 98, 186, 133, 235, 154,
- 250, 107, 109, 111, 53, 155, 115, 103, 252, 101,
- 103, 103, 103, 54, 103, 209, 152, 55, 194, 209,
- 181, 62, 117, 75, 103, 76, 58, 103, 103, 78,
- 187, 79, 135, 156, 251, 73, 103, 121, 63, 122,
- 74, 234, 253, 136, 137, 214, 77, 140, 246, 124,
- 225, 125, 80, 167, 168, 169, 149, 81, 153, 82,
- 123, 141, 215, 216, 217, 142, 161, 95, 96, 143,
- 144, 83, 126, 139, 84, 157, 158, 85, 46, 46,
- 198, 199, 200, 201, 202, 86, 143, 144, 254, 168,
- 99, 171, 172, 173, 174, 175, 179, 145, 146, 147,
- 94, 166, 88, 102, 88, 108, 188, 193, 190, 110,
- 112, 162, 163, 182, 113, 185, 114, 46, 46, 116,
- 118, 119, 120, 132, 134, 191, 206, 127, 128, 129,
- 195, 196, 130, 131, 88, 88, 159, 183, 220, 221,
- 139, 192, 197, 211, 212, 46, 46, 203, 90, 13,
- 14, 204, 200, 201, 202, 16, 17, 18, 19, 213,
- 20, 21, 22, 23, 219, 222, 238, 224, 226, 26,
- 27, 241, 227, 208, 231, 236, 243, 244, 245, 237,
- 239, 240, 247, 249, 263, 264, 265, 268, 269, 266,
- 242, 189, 255, 205, 257, 91, 233, 223, 248, 61,
- 88, 88, 0, 0, 260, 261, 0, 0, 0, 256,
- 0, 0, 0, 258, 259, 0, 1, 262, 2, 0,
- 0, 0, 0, 3, 0, 4, 5, 6, 7, 0,
+#define YYLAST 577
+
+
+static const short yytable[] = { 58,
+ 59, 47, 167, 90, 46, 94, 216, 89, 240, 156,
+ 187, 154, 161, 242, 61, 157, 62, 193, 162, 242,
+ 243, 217, 91, 217, 195, 139, 256, 260, 262, 109,
+ 111, 105, 117, 50, 105, 121, 224, 28, 105, 105,
+ 105, 105, 105, 231, 158, 188, 105, 163, 218, 203,
+ 218, 54, 194, 105, 57, 103, 105, 105, 77, 196,
+ 78, 60, 261, 263, 75, 80, 141, 81, 127, 123,
+ 128, 64, 142, 143, 65, 223, 146, 55, 130, 76,
+ 131, 56, 79, 233, 83, 155, 174, 175, 176, 82,
+ 159, 160, 129, 112, 113, 114, 84, 148, 85, 168,
+ 47, 47, 132, 101, 145, 112, 113, 114, 147, 149,
+ 150, 164, 165, 207, 208, 209, 210, 211, 97, 98,
+ 151, 152, 153, 86, 178, 179, 180, 181, 182, 186,
+ 149, 150, 264, 175, 87, 88, 90, 96, 90, 104,
+ 197, 202, 199, 47, 47, 110, 169, 170, 116, 189,
+ 118, 192, 173, 97, 98, 119, 120, 122, 125, 124,
+ 215, 126, 133, 138, 99, 100, 134, 204, 205, 135,
+ 90, 90, 47, 47, 228, 229, 145, 136, 137, 190,
+ 220, 221, 140, 166, 200, 206, 226, 227, 209, 210,
+ 211, 201, 212, 213, 92, 13, 14, 222, 225, 246,
+ 230, 232, 16, 17, 18, 19, 251, 20, 21, 22,
+ 23, 253, 254, 255, 234, 235, 26, 27, 259, 66,
+ 67, 68, 69, 217, 70, 239, 71, 72, 252, 244,
+ 245, 267, 247, 73, 74, 249, 258, 90, 90, 257,
+ 248, 270, 271, 250, 273, 274, 275, 276, 278, 266,
+ 279, 198, 265, 268, 269, 93, 1, 272, 2, 63,
+ 214, 241, 0, 3, 0, 4, 5, 6, 7, 0,
0, 8, 9, 0, 0, 0, 10, 11, 0, 12,
- 13, 14, 15, 0, 0, 0, 16, 17, 18, 19,
- 0, 20, 21, 22, 23, 0, 0, 24, 25, 2,
- 26, 27, 0, 28, 3, 29, 4, 5, 6, 7,
- 0, 0, 8, 9, 0, 0, 0, 10, 11, 0,
- 12, 13, 14, 15, 0, 0, 0, 16, 17, 18,
- 19, 0, 20, 21, 22, 23, 0, 0, 103, 0,
+ 13, 14, 15, 0, 0, 0, 0, 16, 17, 18,
+ 19, 0, 20, 21, 22, 23, 0, 0, 24, 25,
2, 26, 27, 0, 28, 3, 29, 4, 5, 6,
7, 0, 0, 8, 9, 0, 0, 0, 10, 11,
- 0, 12, 13, 14, 15, 0, 0, 0, 16, 17,
- 18, 19, 0, 20, 21, 22, 23, 0, 0, 0,
- 0, 2, 26, 27, 0, 28, 3, 29, 4, 5,
- 6, 7, 0, 0, 8, 9, 0, 0, 0, 0,
- 11, 0, 12, 13, 14, 15, 0, 0, 0, 16,
+ 0, 12, 13, 14, 15, 0, 0, 0, 0, 16,
17, 18, 19, 0, 20, 21, 22, 23, 0, 0,
- 0, 0, 2, 26, 27, 0, 28, 3, 29, 4,
+ 105, 0, 2, 26, 27, 0, 28, 3, 29, 4,
5, 6, 7, 0, 0, 8, 9, 0, 0, 0,
- 100, 0, 0, 12, 13, 14, 15, 0, 0, 0,
- 16, 17, 18, 19, 0, 20, 21, 22, 23, 0,
- 0, 0, 0, 2, 26, 27, 0, 28, 3, 29,
- 4, 5, 6, 7, 0, 0, 8, 9, 0, 0,
- 0, 0, 0, 0, 12, 13, 14, 15, 0, 0,
+ 10, 11, 0, 12, 13, 14, 15, 0, 0, 0,
0, 16, 17, 18, 19, 0, 20, 21, 22, 23,
- 0, 0, 103, 0, 2, 26, 27, 0, 28, 3,
+ 0, 0, 0, 0, 2, 26, 27, 0, 28, 3,
29, 4, 5, 6, 7, 0, 0, 8, 9, 0,
- 0, 0, 0, 0, 0, 12, 13, 14, 15, 0,
- 0, 0, 16, 17, 18, 19, 0, 20, 21, 22,
- 23, 0, 0, 0, 0, 0, 26, 27, 14, 28,
- 0, 29, 0, 16, 17, 18, 19, 0, 20, 21,
- 22, 23, 0, 0, 0, 0, 0, 26, 27, 64,
- 65, 66, 67, 0, 68, 0, 69, 70, 0, 0,
- 0, 0, 0, 71, 72
+ 0, 0, 0, 11, 0, 12, 13, 14, 15, 0,
+ 0, 0, 0, 16, 17, 18, 19, 0, 20, 21,
+ 22, 23, 0, 0, 0, 0, 2, 26, 27, 0,
+ 28, 3, 29, 4, 5, 6, 7, 0, 0, 8,
+ 9, 0, 0, 0, 102, 0, 0, 12, 13, 14,
+ 15, 0, 0, 0, 0, 16, 17, 18, 19, 0,
+ 20, 21, 22, 23, 0, 0, 0, 0, 2, 26,
+ 27, 0, 28, 3, 29, 4, 5, 6, 7, 0,
+ 0, 8, 9, 0, 0, 0, 0, 0, 0, 12,
+ 13, 14, 15, 0, 0, 0, 0, 16, 17, 18,
+ 19, 0, 20, 21, 22, 23, 0, 0, 105, 0,
+ 2, 26, 27, 0, 28, 3, 29, 4, 5, 6,
+ 7, 0, 0, 8, 9, 0, 0, 0, 0, 0,
+ 0, 12, 13, 14, 15, 0, 0, 0, 0, 16,
+ 17, 18, 19, 0, 20, 21, 22, 23, 0, 0,
+ 0, 0, 0, 26, 27, 14, 28, 0, 29, 0,
+ 0, 16, 17, 18, 19, 0, 20, 21, 22, 23,
+ 0, 0, 0, 0, 0, 26, 27
};
static const short yycheck[] = { 6,
- 7, 10, 115, 34, 9, 0, 28, 42, 9, 42,
- 28, 0, 14, 29, 30, 48, 14, 28, 20, 24,
- 20, 44, 29, 24, 40, 41, 14, 88, 51, 14,
- 14, 53, 54, 55, 24, 20, 58, 42, 14, 48,
- 42, 42, 42, 24, 42, 50, 48, 24, 161, 50,
- 48, 23, 61, 24, 42, 26, 24, 42, 42, 24,
- 48, 26, 93, 48, 48, 24, 42, 24, 50, 26,
- 24, 44, 48, 95, 96, 24, 47, 99, 51, 24,
- 193, 26, 47, 5, 6, 7, 108, 24, 110, 24,
- 47, 100, 41, 42, 43, 102, 118, 29, 30, 29,
- 30, 24, 47, 98, 24, 112, 113, 24, 97, 98,
- 171, 172, 173, 174, 175, 24, 29, 30, 5, 6,
- 44, 143, 144, 145, 146, 147, 148, 40, 41, 42,
- 42, 140, 154, 4, 156, 41, 154, 159, 156, 41,
- 14, 136, 137, 150, 14, 152, 50, 136, 137, 18,
- 51, 24, 24, 49, 51, 15, 178, 24, 24, 24,
- 167, 168, 24, 24, 186, 187, 51, 24, 186, 187,
- 165, 15, 7, 180, 181, 164, 165, 9, 24, 25,
- 26, 35, 243, 244, 245, 31, 32, 33, 34, 15,
- 36, 37, 38, 39, 49, 15, 218, 49, 7, 45,
- 46, 223, 4, 24, 35, 15, 228, 229, 230, 49,
- 15, 49, 24, 235, 15, 49, 15, 0, 0, 49,
- 227, 155, 242, 178, 246, 32, 209, 189, 235, 10,
- 252, 253, -1, -1, 252, 253, -1, -1, -1, 246,
- -1, -1, -1, 250, 251, -1, 1, 254, 3, -1,
- -1, -1, -1, 8, -1, 10, 11, 12, 13, -1,
+ 7, 0, 121, 28, 0, 34, 9, 28, 9, 14,
+ 14, 20, 14, 45, 29, 20, 10, 14, 20, 45,
+ 52, 24, 29, 24, 14, 90, 52, 14, 14, 54,
+ 55, 43, 57, 43, 43, 60, 191, 49, 43, 43,
+ 43, 43, 43, 198, 49, 49, 43, 49, 51, 168,
+ 51, 24, 49, 43, 24, 49, 43, 43, 24, 49,
+ 26, 24, 49, 49, 24, 24, 95, 26, 24, 63,
+ 26, 23, 97, 98, 51, 24, 101, 24, 24, 24,
+ 26, 28, 48, 202, 24, 110, 5, 6, 7, 48,
+ 115, 116, 48, 42, 43, 44, 24, 104, 24, 124,
+ 99, 100, 48, 45, 100, 42, 43, 44, 102, 30,
+ 31, 118, 119, 178, 179, 180, 181, 182, 30, 31,
+ 41, 42, 43, 24, 149, 150, 151, 152, 153, 154,
+ 30, 31, 5, 6, 24, 24, 161, 43, 163, 4,
+ 161, 166, 163, 142, 143, 42, 142, 143, 42, 156,
+ 14, 158, 146, 30, 31, 14, 51, 18, 24, 52,
+ 185, 24, 24, 50, 41, 42, 24, 174, 175, 24,
+ 195, 196, 171, 172, 195, 196, 172, 24, 24, 24,
+ 187, 188, 52, 52, 15, 7, 193, 194, 253, 254,
+ 255, 15, 9, 36, 24, 25, 26, 15, 50, 224,
+ 15, 50, 32, 33, 34, 35, 231, 37, 38, 39,
+ 40, 236, 237, 238, 7, 4, 46, 47, 243, 32,
+ 33, 34, 35, 24, 37, 36, 39, 40, 235, 15,
+ 50, 256, 15, 46, 47, 15, 243, 262, 263, 24,
+ 50, 262, 263, 50, 15, 50, 15, 50, 0, 256,
+ 0, 162, 252, 260, 261, 32, 1, 264, 3, 10,
+ 185, 218, -1, 8, -1, 10, 11, 12, 13, -1,
-1, 16, 17, -1, -1, -1, 21, 22, -1, 24,
- 25, 26, 27, -1, -1, -1, 31, 32, 33, 34,
- -1, 36, 37, 38, 39, -1, -1, 42, 43, 3,
- 45, 46, -1, 48, 8, 50, 10, 11, 12, 13,
- -1, -1, 16, 17, -1, -1, -1, 21, 22, -1,
- 24, 25, 26, 27, -1, -1, -1, 31, 32, 33,
- 34, -1, 36, 37, 38, 39, -1, -1, 42, -1,
- 3, 45, 46, -1, 48, 8, 50, 10, 11, 12,
+ 25, 26, 27, -1, -1, -1, -1, 32, 33, 34,
+ 35, -1, 37, 38, 39, 40, -1, -1, 43, 44,
+ 3, 46, 47, -1, 49, 8, 51, 10, 11, 12,
13, -1, -1, 16, 17, -1, -1, -1, 21, 22,
- -1, 24, 25, 26, 27, -1, -1, -1, 31, 32,
- 33, 34, -1, 36, 37, 38, 39, -1, -1, -1,
- -1, 3, 45, 46, -1, 48, 8, 50, 10, 11,
- 12, 13, -1, -1, 16, 17, -1, -1, -1, -1,
- 22, -1, 24, 25, 26, 27, -1, -1, -1, 31,
- 32, 33, 34, -1, 36, 37, 38, 39, -1, -1,
- -1, -1, 3, 45, 46, -1, 48, 8, 50, 10,
+ -1, 24, 25, 26, 27, -1, -1, -1, -1, 32,
+ 33, 34, 35, -1, 37, 38, 39, 40, -1, -1,
+ 43, -1, 3, 46, 47, -1, 49, 8, 51, 10,
11, 12, 13, -1, -1, 16, 17, -1, -1, -1,
- 21, -1, -1, 24, 25, 26, 27, -1, -1, -1,
- 31, 32, 33, 34, -1, 36, 37, 38, 39, -1,
- -1, -1, -1, 3, 45, 46, -1, 48, 8, 50,
- 10, 11, 12, 13, -1, -1, 16, 17, -1, -1,
- -1, -1, -1, -1, 24, 25, 26, 27, -1, -1,
- -1, 31, 32, 33, 34, -1, 36, 37, 38, 39,
- -1, -1, 42, -1, 3, 45, 46, -1, 48, 8,
- 50, 10, 11, 12, 13, -1, -1, 16, 17, -1,
- -1, -1, -1, -1, -1, 24, 25, 26, 27, -1,
- -1, -1, 31, 32, 33, 34, -1, 36, 37, 38,
- 39, -1, -1, -1, -1, -1, 45, 46, 26, 48,
- -1, 50, -1, 31, 32, 33, 34, -1, 36, 37,
- 38, 39, -1, -1, -1, -1, -1, 45, 46, 31,
- 32, 33, 34, -1, 36, -1, 38, 39, -1, -1,
- -1, -1, -1, 45, 46
+ 21, 22, -1, 24, 25, 26, 27, -1, -1, -1,
+ -1, 32, 33, 34, 35, -1, 37, 38, 39, 40,
+ -1, -1, -1, -1, 3, 46, 47, -1, 49, 8,
+ 51, 10, 11, 12, 13, -1, -1, 16, 17, -1,
+ -1, -1, -1, 22, -1, 24, 25, 26, 27, -1,
+ -1, -1, -1, 32, 33, 34, 35, -1, 37, 38,
+ 39, 40, -1, -1, -1, -1, 3, 46, 47, -1,
+ 49, 8, 51, 10, 11, 12, 13, -1, -1, 16,
+ 17, -1, -1, -1, 21, -1, -1, 24, 25, 26,
+ 27, -1, -1, -1, -1, 32, 33, 34, 35, -1,
+ 37, 38, 39, 40, -1, -1, -1, -1, 3, 46,
+ 47, -1, 49, 8, 51, 10, 11, 12, 13, -1,
+ -1, 16, 17, -1, -1, -1, -1, -1, -1, 24,
+ 25, 26, 27, -1, -1, -1, -1, 32, 33, 34,
+ 35, -1, 37, 38, 39, 40, -1, -1, 43, -1,
+ 3, 46, 47, -1, 49, 8, 51, 10, 11, 12,
+ 13, -1, -1, 16, 17, -1, -1, -1, -1, -1,
+ -1, 24, 25, 26, 27, -1, -1, -1, -1, 32,
+ 33, 34, 35, -1, 37, 38, 39, 40, -1, -1,
+ -1, -1, -1, 46, 47, 26, 49, -1, 51, -1,
+ -1, 32, 33, 34, 35, -1, 37, 38, 39, 40,
+ -1, -1, -1, -1, -1, 46, 47
};
/* -*-C-*- Note some compilers choke on comments on `#line' lines. */
#line 3 "/usr/share/misc/bison.simple"
@@ -1105,7 +1114,7 @@ yyreduce:
switch (yyn) {
case 1:
-#line 233 "/usr/homes/chet/src/bash/src/parse.y"
+#line 238 "/usr/homes/chet/src/bash/src/parse.y"
{
/* Case of regular command. Discard the error
safety net,and return the command just parsed. */
@@ -1116,7 +1125,7 @@ case 1:
;
break;}
case 2:
-#line 242 "/usr/homes/chet/src/bash/src/parse.y"
+#line 247 "/usr/homes/chet/src/bash/src/parse.y"
{
/* Case of regular command, but not a very
interesting one. Return a NULL command. */
@@ -1125,7 +1134,7 @@ case 2:
;
break;}
case 3:
-#line 249 "/usr/homes/chet/src/bash/src/parse.y"
+#line 254 "/usr/homes/chet/src/bash/src/parse.y"
{
/* Error during parsing. Return NULL command. */
global_command = (COMMAND *)NULL;
@@ -1142,7 +1151,7 @@ case 3:
;
break;}
case 4:
-#line 264 "/usr/homes/chet/src/bash/src/parse.y"
+#line 269 "/usr/homes/chet/src/bash/src/parse.y"
{
/* Case of EOF seen by itself. Do ignoreeof or
not. */
@@ -1152,57 +1161,57 @@ case 4:
;
break;}
case 5:
-#line 274 "/usr/homes/chet/src/bash/src/parse.y"
+#line 279 "/usr/homes/chet/src/bash/src/parse.y"
{ yyval.word_list = make_word_list (yyvsp[0].word, (WORD_LIST *)NULL); ;
break;}
case 6:
-#line 276 "/usr/homes/chet/src/bash/src/parse.y"
+#line 281 "/usr/homes/chet/src/bash/src/parse.y"
{ yyval.word_list = make_word_list (yyvsp[0].word, yyvsp[-1].word_list); ;
break;}
case 7:
-#line 280 "/usr/homes/chet/src/bash/src/parse.y"
+#line 285 "/usr/homes/chet/src/bash/src/parse.y"
{
redir.filename = yyvsp[0].word;
yyval.redirect = make_redirection (1, r_output_direction, redir);
;
break;}
case 8:
-#line 285 "/usr/homes/chet/src/bash/src/parse.y"
+#line 290 "/usr/homes/chet/src/bash/src/parse.y"
{
redir.filename = yyvsp[0].word;
yyval.redirect = make_redirection (0, r_input_direction, redir);
;
break;}
case 9:
-#line 290 "/usr/homes/chet/src/bash/src/parse.y"
+#line 295 "/usr/homes/chet/src/bash/src/parse.y"
{
redir.filename = yyvsp[0].word;
yyval.redirect = make_redirection (yyvsp[-2].number, r_output_direction, redir);
;
break;}
case 10:
-#line 295 "/usr/homes/chet/src/bash/src/parse.y"
+#line 300 "/usr/homes/chet/src/bash/src/parse.y"
{
redir.filename = yyvsp[0].word;
yyval.redirect = make_redirection (yyvsp[-2].number, r_input_direction, redir);
;
break;}
case 11:
-#line 300 "/usr/homes/chet/src/bash/src/parse.y"
+#line 305 "/usr/homes/chet/src/bash/src/parse.y"
{
redir.filename = yyvsp[0].word;
yyval.redirect = make_redirection (1, r_appending_to, redir);
;
break;}
case 12:
-#line 305 "/usr/homes/chet/src/bash/src/parse.y"
+#line 310 "/usr/homes/chet/src/bash/src/parse.y"
{
redir.filename = yyvsp[0].word;
yyval.redirect = make_redirection (yyvsp[-2].number, r_appending_to, redir);
;
break;}
case 13:
-#line 310 "/usr/homes/chet/src/bash/src/parse.y"
+#line 315 "/usr/homes/chet/src/bash/src/parse.y"
{
redir.filename = yyvsp[0].word;
yyval.redirect = make_redirection (0, r_reading_until, redir);
@@ -1210,7 +1219,7 @@ case 13:
;
break;}
case 14:
-#line 316 "/usr/homes/chet/src/bash/src/parse.y"
+#line 321 "/usr/homes/chet/src/bash/src/parse.y"
{
redir.filename = yyvsp[0].word;
yyval.redirect = make_redirection (yyvsp[-2].number, r_reading_until, redir);
@@ -1218,63 +1227,63 @@ case 14:
;
break;}
case 15:
-#line 322 "/usr/homes/chet/src/bash/src/parse.y"
+#line 327 "/usr/homes/chet/src/bash/src/parse.y"
{
redir.dest = yyvsp[0].number;
yyval.redirect = make_redirection (0, r_duplicating_input, redir);
;
break;}
case 16:
-#line 327 "/usr/homes/chet/src/bash/src/parse.y"
+#line 332 "/usr/homes/chet/src/bash/src/parse.y"
{
redir.dest = yyvsp[0].number;
yyval.redirect = make_redirection (yyvsp[-2].number, r_duplicating_input, redir);
;
break;}
case 17:
-#line 332 "/usr/homes/chet/src/bash/src/parse.y"
+#line 337 "/usr/homes/chet/src/bash/src/parse.y"
{
redir.dest = yyvsp[0].number;
yyval.redirect = make_redirection (1, r_duplicating_output, redir);
;
break;}
case 18:
-#line 337 "/usr/homes/chet/src/bash/src/parse.y"
+#line 342 "/usr/homes/chet/src/bash/src/parse.y"
{
redir.dest = yyvsp[0].number;
yyval.redirect = make_redirection (yyvsp[-2].number, r_duplicating_output, redir);
;
break;}
case 19:
-#line 342 "/usr/homes/chet/src/bash/src/parse.y"
+#line 347 "/usr/homes/chet/src/bash/src/parse.y"
{
redir.filename = yyvsp[0].word;
yyval.redirect = make_redirection (0, r_duplicating_input_word, redir);
;
break;}
case 20:
-#line 347 "/usr/homes/chet/src/bash/src/parse.y"
+#line 352 "/usr/homes/chet/src/bash/src/parse.y"
{
redir.filename = yyvsp[0].word;
yyval.redirect = make_redirection (yyvsp[-2].number, r_duplicating_input_word, redir);
;
break;}
case 21:
-#line 352 "/usr/homes/chet/src/bash/src/parse.y"
+#line 357 "/usr/homes/chet/src/bash/src/parse.y"
{
redir.filename = yyvsp[0].word;
yyval.redirect = make_redirection (1, r_duplicating_output_word, redir);
;
break;}
case 22:
-#line 357 "/usr/homes/chet/src/bash/src/parse.y"
+#line 362 "/usr/homes/chet/src/bash/src/parse.y"
{
redir.filename = yyvsp[0].word;
yyval.redirect = make_redirection (yyvsp[-2].number, r_duplicating_output_word, redir);
;
break;}
case 23:
-#line 362 "/usr/homes/chet/src/bash/src/parse.y"
+#line 367 "/usr/homes/chet/src/bash/src/parse.y"
{
redir.filename = yyvsp[0].word;
yyval.redirect = make_redirection
@@ -1283,7 +1292,7 @@ case 23:
;
break;}
case 24:
-#line 369 "/usr/homes/chet/src/bash/src/parse.y"
+#line 374 "/usr/homes/chet/src/bash/src/parse.y"
{
redir.filename = yyvsp[0].word;
yyval.redirect = make_redirection
@@ -1292,88 +1301,88 @@ case 24:
;
break;}
case 25:
-#line 376 "/usr/homes/chet/src/bash/src/parse.y"
+#line 381 "/usr/homes/chet/src/bash/src/parse.y"
{
redir.dest = 0L;
yyval.redirect = make_redirection (1, r_close_this, redir);
;
break;}
case 26:
-#line 381 "/usr/homes/chet/src/bash/src/parse.y"
+#line 386 "/usr/homes/chet/src/bash/src/parse.y"
{
redir.dest = 0L;
yyval.redirect = make_redirection (yyvsp[-2].number, r_close_this, redir);
;
break;}
case 27:
-#line 386 "/usr/homes/chet/src/bash/src/parse.y"
+#line 391 "/usr/homes/chet/src/bash/src/parse.y"
{
redir.dest = 0L;
yyval.redirect = make_redirection (0, r_close_this, redir);
;
break;}
case 28:
-#line 391 "/usr/homes/chet/src/bash/src/parse.y"
+#line 396 "/usr/homes/chet/src/bash/src/parse.y"
{
redir.dest = 0L;
yyval.redirect = make_redirection (yyvsp[-2].number, r_close_this, redir);
;
break;}
case 29:
-#line 396 "/usr/homes/chet/src/bash/src/parse.y"
+#line 401 "/usr/homes/chet/src/bash/src/parse.y"
{
redir.filename = yyvsp[0].word;
yyval.redirect = make_redirection (1, r_err_and_out, redir);
;
break;}
case 30:
-#line 401 "/usr/homes/chet/src/bash/src/parse.y"
+#line 406 "/usr/homes/chet/src/bash/src/parse.y"
{
redir.filename = yyvsp[0].word;
yyval.redirect = make_redirection (yyvsp[-2].number, r_input_output, redir);
;
break;}
case 31:
-#line 406 "/usr/homes/chet/src/bash/src/parse.y"
+#line 411 "/usr/homes/chet/src/bash/src/parse.y"
{
redir.filename = yyvsp[0].word;
yyval.redirect = make_redirection (0, r_input_output, redir);
;
break;}
case 32:
-#line 411 "/usr/homes/chet/src/bash/src/parse.y"
+#line 416 "/usr/homes/chet/src/bash/src/parse.y"
{
redir.filename = yyvsp[0].word;
yyval.redirect = make_redirection (1, r_output_force, redir);
;
break;}
case 33:
-#line 416 "/usr/homes/chet/src/bash/src/parse.y"
+#line 421 "/usr/homes/chet/src/bash/src/parse.y"
{
redir.filename = yyvsp[0].word;
yyval.redirect = make_redirection (yyvsp[-2].number, r_output_force, redir);
;
break;}
case 34:
-#line 423 "/usr/homes/chet/src/bash/src/parse.y"
+#line 428 "/usr/homes/chet/src/bash/src/parse.y"
{ yyval.element.word = yyvsp[0].word; yyval.element.redirect = 0; ;
break;}
case 35:
-#line 425 "/usr/homes/chet/src/bash/src/parse.y"
+#line 430 "/usr/homes/chet/src/bash/src/parse.y"
{ yyval.element.word = yyvsp[0].word; yyval.element.redirect = 0; ;
break;}
case 36:
-#line 427 "/usr/homes/chet/src/bash/src/parse.y"
+#line 432 "/usr/homes/chet/src/bash/src/parse.y"
{ yyval.element.redirect = yyvsp[0].redirect; yyval.element.word = 0; ;
break;}
case 37:
-#line 431 "/usr/homes/chet/src/bash/src/parse.y"
+#line 436 "/usr/homes/chet/src/bash/src/parse.y"
{
yyval.redirect = yyvsp[0].redirect;
;
break;}
case 38:
-#line 435 "/usr/homes/chet/src/bash/src/parse.y"
+#line 440 "/usr/homes/chet/src/bash/src/parse.y"
{
register REDIRECT *t;
@@ -1384,23 +1393,23 @@ case 38:
;
break;}
case 39:
-#line 446 "/usr/homes/chet/src/bash/src/parse.y"
+#line 451 "/usr/homes/chet/src/bash/src/parse.y"
{ yyval.command = make_simple_command (yyvsp[0].element, (COMMAND *)NULL); ;
break;}
case 40:
-#line 448 "/usr/homes/chet/src/bash/src/parse.y"
+#line 453 "/usr/homes/chet/src/bash/src/parse.y"
{ yyval.command = make_simple_command (yyvsp[0].element, yyvsp[-1].command); ;
break;}
case 41:
-#line 452 "/usr/homes/chet/src/bash/src/parse.y"
+#line 457 "/usr/homes/chet/src/bash/src/parse.y"
{ yyval.command = clean_simple_command (yyvsp[0].command); ;
break;}
case 42:
-#line 454 "/usr/homes/chet/src/bash/src/parse.y"
+#line 459 "/usr/homes/chet/src/bash/src/parse.y"
{ yyval.command = yyvsp[0].command; ;
break;}
case 43:
-#line 456 "/usr/homes/chet/src/bash/src/parse.y"
+#line 461 "/usr/homes/chet/src/bash/src/parse.y"
{
COMMAND *tc;
@@ -1410,6 +1419,14 @@ case 43:
be attached to the function and performed when
the function is executed, not as part of the
function definition command. */
+ /* XXX - I don't think it matters, but we might
+ want to change this in the future to avoid
+ problems differentiating between a function
+ definition with a redirection and a function
+ definition containing a single command with a
+ redirection. The two are semantically equivalent,
+ though -- the only difference is in how the
+ command printing code displays the redirections. */
if (tc->type == cm_function_def)
{
tc = tc->value.Function_def->command;
@@ -1429,221 +1446,236 @@ case 43:
;
break;}
case 44:
-#line 485 "/usr/homes/chet/src/bash/src/parse.y"
+#line 498 "/usr/homes/chet/src/bash/src/parse.y"
{ yyval.command = yyvsp[0].command; ;
break;}
case 45:
-#line 487 "/usr/homes/chet/src/bash/src/parse.y"
+#line 500 "/usr/homes/chet/src/bash/src/parse.y"
{ yyval.command = yyvsp[0].command; ;
break;}
case 46:
-#line 489 "/usr/homes/chet/src/bash/src/parse.y"
+#line 502 "/usr/homes/chet/src/bash/src/parse.y"
{ yyval.command = make_while_command (yyvsp[-3].command, yyvsp[-1].command); ;
break;}
case 47:
-#line 491 "/usr/homes/chet/src/bash/src/parse.y"
+#line 504 "/usr/homes/chet/src/bash/src/parse.y"
{ yyval.command = make_until_command (yyvsp[-3].command, yyvsp[-1].command); ;
break;}
case 48:
-#line 493 "/usr/homes/chet/src/bash/src/parse.y"
+#line 506 "/usr/homes/chet/src/bash/src/parse.y"
{ yyval.command = yyvsp[0].command; ;
break;}
case 49:
-#line 495 "/usr/homes/chet/src/bash/src/parse.y"
+#line 508 "/usr/homes/chet/src/bash/src/parse.y"
{ yyval.command = yyvsp[0].command; ;
break;}
case 50:
-#line 497 "/usr/homes/chet/src/bash/src/parse.y"
+#line 510 "/usr/homes/chet/src/bash/src/parse.y"
{ yyval.command = yyvsp[0].command; ;
break;}
case 51:
-#line 499 "/usr/homes/chet/src/bash/src/parse.y"
+#line 512 "/usr/homes/chet/src/bash/src/parse.y"
{ yyval.command = yyvsp[0].command; ;
break;}
case 52:
-#line 501 "/usr/homes/chet/src/bash/src/parse.y"
+#line 514 "/usr/homes/chet/src/bash/src/parse.y"
{ yyval.command = yyvsp[0].command; ;
break;}
case 53:
-#line 503 "/usr/homes/chet/src/bash/src/parse.y"
+#line 516 "/usr/homes/chet/src/bash/src/parse.y"
{ yyval.command = yyvsp[0].command; ;
break;}
case 54:
-#line 505 "/usr/homes/chet/src/bash/src/parse.y"
+#line 518 "/usr/homes/chet/src/bash/src/parse.y"
{ yyval.command = yyvsp[0].command; ;
break;}
case 55:
-#line 509 "/usr/homes/chet/src/bash/src/parse.y"
-{ yyval.command = make_for_command (yyvsp[-4].word, add_string_to_list ("\"$@\"", (WORD_LIST *)NULL), yyvsp[-1].command); ;
+#line 520 "/usr/homes/chet/src/bash/src/parse.y"
+{ yyval.command = yyvsp[0].command; ;
break;}
case 56:
-#line 511 "/usr/homes/chet/src/bash/src/parse.y"
-{ yyval.command = make_for_command (yyvsp[-4].word, add_string_to_list ("$@", (WORD_LIST *)NULL), yyvsp[-1].command); ;
+#line 524 "/usr/homes/chet/src/bash/src/parse.y"
+{ yyval.command = make_for_command (yyvsp[-4].word, add_string_to_list ("\"$@\"", (WORD_LIST *)NULL), yyvsp[-1].command); ;
break;}
case 57:
-#line 513 "/usr/homes/chet/src/bash/src/parse.y"
-{ yyval.command = make_for_command (yyvsp[-5].word, add_string_to_list ("\"$@\"", (WORD_LIST *)NULL), yyvsp[-1].command); ;
+#line 526 "/usr/homes/chet/src/bash/src/parse.y"
+{ yyval.command = make_for_command (yyvsp[-4].word, add_string_to_list ("$@", (WORD_LIST *)NULL), yyvsp[-1].command); ;
break;}
case 58:
-#line 515 "/usr/homes/chet/src/bash/src/parse.y"
+#line 528 "/usr/homes/chet/src/bash/src/parse.y"
{ yyval.command = make_for_command (yyvsp[-5].word, add_string_to_list ("\"$@\"", (WORD_LIST *)NULL), yyvsp[-1].command); ;
break;}
case 59:
-#line 517 "/usr/homes/chet/src/bash/src/parse.y"
-{ yyval.command = make_for_command (yyvsp[-8].word, REVERSE_LIST (yyvsp[-5].word_list, WORD_LIST *), yyvsp[-1].command); ;
+#line 530 "/usr/homes/chet/src/bash/src/parse.y"
+{ yyval.command = make_for_command (yyvsp[-5].word, add_string_to_list ("\"$@\"", (WORD_LIST *)NULL), yyvsp[-1].command); ;
break;}
case 60:
-#line 519 "/usr/homes/chet/src/bash/src/parse.y"
+#line 532 "/usr/homes/chet/src/bash/src/parse.y"
{ yyval.command = make_for_command (yyvsp[-8].word, REVERSE_LIST (yyvsp[-5].word_list, WORD_LIST *), yyvsp[-1].command); ;
break;}
case 61:
-#line 523 "/usr/homes/chet/src/bash/src/parse.y"
+#line 534 "/usr/homes/chet/src/bash/src/parse.y"
+{ yyval.command = make_for_command (yyvsp[-8].word, REVERSE_LIST (yyvsp[-5].word_list, WORD_LIST *), yyvsp[-1].command); ;
+ break;}
+case 62:
+#line 538 "/usr/homes/chet/src/bash/src/parse.y"
+{ yyval.command = make_arith_for_command (yyvsp[-5].word_list, yyvsp[-1].command, arith_for_lineno); ;
+ break;}
+case 63:
+#line 540 "/usr/homes/chet/src/bash/src/parse.y"
+{ yyval.command = make_arith_for_command (yyvsp[-5].word_list, yyvsp[-1].command, arith_for_lineno); ;
+ break;}
+case 64:
+#line 543 "/usr/homes/chet/src/bash/src/parse.y"
{
yyval.command = make_select_command (yyvsp[-4].word, add_string_to_list ("\"$@\"", (WORD_LIST *)NULL), yyvsp[-1].command);
;
break;}
-case 62:
-#line 527 "/usr/homes/chet/src/bash/src/parse.y"
+case 65:
+#line 547 "/usr/homes/chet/src/bash/src/parse.y"
{
yyval.command = make_select_command (yyvsp[-4].word, add_string_to_list ("$@", (WORD_LIST *)NULL), yyvsp[-1].command);
;
break;}
-case 63:
-#line 531 "/usr/homes/chet/src/bash/src/parse.y"
+case 66:
+#line 551 "/usr/homes/chet/src/bash/src/parse.y"
{
yyval.command = make_select_command (yyvsp[-5].word, add_string_to_list ("\"$@\"", (WORD_LIST *)NULL), yyvsp[-1].command);
;
break;}
-case 64:
-#line 535 "/usr/homes/chet/src/bash/src/parse.y"
+case 67:
+#line 555 "/usr/homes/chet/src/bash/src/parse.y"
{
yyval.command = make_select_command (yyvsp[-5].word, add_string_to_list ("\"$@\"", (WORD_LIST *)NULL), yyvsp[-1].command);
;
break;}
-case 65:
-#line 539 "/usr/homes/chet/src/bash/src/parse.y"
+case 68:
+#line 559 "/usr/homes/chet/src/bash/src/parse.y"
{
yyval.command = make_select_command (yyvsp[-8].word, (WORD_LIST *)reverse_list (yyvsp[-5].word_list), yyvsp[-1].command);
;
break;}
-case 66:
-#line 543 "/usr/homes/chet/src/bash/src/parse.y"
+case 69:
+#line 563 "/usr/homes/chet/src/bash/src/parse.y"
{
yyval.command = make_select_command (yyvsp[-8].word, (WORD_LIST *)reverse_list (yyvsp[-5].word_list), yyvsp[-1].command);
;
break;}
-case 67:
-#line 549 "/usr/homes/chet/src/bash/src/parse.y"
+case 70:
+#line 569 "/usr/homes/chet/src/bash/src/parse.y"
{ yyval.command = make_case_command (yyvsp[-4].word, (PATTERN_LIST *)NULL); ;
break;}
-case 68:
-#line 551 "/usr/homes/chet/src/bash/src/parse.y"
+case 71:
+#line 571 "/usr/homes/chet/src/bash/src/parse.y"
{ yyval.command = make_case_command (yyvsp[-5].word, yyvsp[-2].pattern); ;
break;}
-case 69:
-#line 553 "/usr/homes/chet/src/bash/src/parse.y"
+case 72:
+#line 573 "/usr/homes/chet/src/bash/src/parse.y"
{ yyval.command = make_case_command (yyvsp[-4].word, yyvsp[-1].pattern); ;
break;}
-case 70:
-#line 557 "/usr/homes/chet/src/bash/src/parse.y"
+case 73:
+#line 577 "/usr/homes/chet/src/bash/src/parse.y"
{ yyval.command = make_function_def (yyvsp[-4].word, yyvsp[0].command, function_dstart, function_bstart); ;
break;}
-case 71:
-#line 561 "/usr/homes/chet/src/bash/src/parse.y"
+case 74:
+#line 581 "/usr/homes/chet/src/bash/src/parse.y"
{ yyval.command = make_function_def (yyvsp[-4].word, yyvsp[0].command, function_dstart, function_bstart); ;
break;}
-case 72:
-#line 564 "/usr/homes/chet/src/bash/src/parse.y"
+case 75:
+#line 584 "/usr/homes/chet/src/bash/src/parse.y"
{ yyval.command = make_function_def (yyvsp[-2].word, yyvsp[0].command, function_dstart, function_bstart); ;
break;}
-case 73:
-#line 568 "/usr/homes/chet/src/bash/src/parse.y"
-{ yyvsp[-1].command->flags |= CMD_WANT_SUBSHELL; yyval.command = yyvsp[-1].command; ;
+case 76:
+#line 588 "/usr/homes/chet/src/bash/src/parse.y"
+{
+ yyval.command = make_subshell_command (yyvsp[-1].command);
+ yyval.command->flags |= CMD_WANT_SUBSHELL;
+ ;
break;}
-case 74:
-#line 572 "/usr/homes/chet/src/bash/src/parse.y"
+case 77:
+#line 595 "/usr/homes/chet/src/bash/src/parse.y"
{ yyval.command = make_if_command (yyvsp[-3].command, yyvsp[-1].command, (COMMAND *)NULL); ;
break;}
-case 75:
-#line 574 "/usr/homes/chet/src/bash/src/parse.y"
+case 78:
+#line 597 "/usr/homes/chet/src/bash/src/parse.y"
{ yyval.command = make_if_command (yyvsp[-5].command, yyvsp[-3].command, yyvsp[-1].command); ;
break;}
-case 76:
-#line 576 "/usr/homes/chet/src/bash/src/parse.y"
+case 79:
+#line 599 "/usr/homes/chet/src/bash/src/parse.y"
{ yyval.command = make_if_command (yyvsp[-4].command, yyvsp[-2].command, yyvsp[-1].command); ;
break;}
-case 77:
-#line 581 "/usr/homes/chet/src/bash/src/parse.y"
+case 80:
+#line 604 "/usr/homes/chet/src/bash/src/parse.y"
{ yyval.command = make_group_command (yyvsp[-1].command); ;
break;}
-case 78:
-#line 585 "/usr/homes/chet/src/bash/src/parse.y"
+case 81:
+#line 608 "/usr/homes/chet/src/bash/src/parse.y"
{ yyval.command = make_arith_command (yyvsp[0].word_list); ;
break;}
-case 79:
-#line 589 "/usr/homes/chet/src/bash/src/parse.y"
+case 82:
+#line 612 "/usr/homes/chet/src/bash/src/parse.y"
{ yyval.command = yyvsp[-1].command; ;
break;}
-case 80:
-#line 593 "/usr/homes/chet/src/bash/src/parse.y"
+case 83:
+#line 616 "/usr/homes/chet/src/bash/src/parse.y"
{ yyval.command = make_if_command (yyvsp[-2].command, yyvsp[0].command, (COMMAND *)NULL); ;
break;}
-case 81:
-#line 595 "/usr/homes/chet/src/bash/src/parse.y"
+case 84:
+#line 618 "/usr/homes/chet/src/bash/src/parse.y"
{ yyval.command = make_if_command (yyvsp[-4].command, yyvsp[-2].command, yyvsp[0].command); ;
break;}
-case 82:
-#line 597 "/usr/homes/chet/src/bash/src/parse.y"
+case 85:
+#line 620 "/usr/homes/chet/src/bash/src/parse.y"
{ yyval.command = make_if_command (yyvsp[-3].command, yyvsp[-1].command, yyvsp[0].command); ;
break;}
-case 84:
-#line 602 "/usr/homes/chet/src/bash/src/parse.y"
+case 87:
+#line 625 "/usr/homes/chet/src/bash/src/parse.y"
{ yyvsp[0].pattern->next = yyvsp[-1].pattern; yyval.pattern = yyvsp[0].pattern; ;
break;}
-case 85:
-#line 606 "/usr/homes/chet/src/bash/src/parse.y"
+case 88:
+#line 629 "/usr/homes/chet/src/bash/src/parse.y"
{ yyval.pattern = make_pattern_list (yyvsp[-2].word_list, yyvsp[0].command); ;
break;}
-case 86:
-#line 608 "/usr/homes/chet/src/bash/src/parse.y"
+case 89:
+#line 631 "/usr/homes/chet/src/bash/src/parse.y"
{ yyval.pattern = make_pattern_list (yyvsp[-2].word_list, (COMMAND *)NULL); ;
break;}
-case 87:
-#line 610 "/usr/homes/chet/src/bash/src/parse.y"
+case 90:
+#line 633 "/usr/homes/chet/src/bash/src/parse.y"
{ yyval.pattern = make_pattern_list (yyvsp[-2].word_list, yyvsp[0].command); ;
break;}
-case 88:
-#line 612 "/usr/homes/chet/src/bash/src/parse.y"
+case 91:
+#line 635 "/usr/homes/chet/src/bash/src/parse.y"
{ yyval.pattern = make_pattern_list (yyvsp[-2].word_list, (COMMAND *)NULL); ;
break;}
-case 90:
-#line 617 "/usr/homes/chet/src/bash/src/parse.y"
+case 93:
+#line 640 "/usr/homes/chet/src/bash/src/parse.y"
{ yyvsp[-1].pattern->next = yyvsp[-2].pattern; yyval.pattern = yyvsp[-1].pattern; ;
break;}
-case 91:
-#line 621 "/usr/homes/chet/src/bash/src/parse.y"
+case 94:
+#line 644 "/usr/homes/chet/src/bash/src/parse.y"
{ yyval.word_list = make_word_list (yyvsp[0].word, (WORD_LIST *)NULL); ;
break;}
-case 92:
-#line 623 "/usr/homes/chet/src/bash/src/parse.y"
+case 95:
+#line 646 "/usr/homes/chet/src/bash/src/parse.y"
{ yyval.word_list = make_word_list (yyvsp[0].word, yyvsp[-2].word_list); ;
break;}
-case 93:
-#line 632 "/usr/homes/chet/src/bash/src/parse.y"
+case 96:
+#line 655 "/usr/homes/chet/src/bash/src/parse.y"
{
yyval.command = yyvsp[0].command;
if (need_here_doc)
gather_here_documents ();
;
break;}
-case 95:
-#line 641 "/usr/homes/chet/src/bash/src/parse.y"
+case 98:
+#line 664 "/usr/homes/chet/src/bash/src/parse.y"
{
yyval.command = yyvsp[0].command;
;
break;}
-case 97:
-#line 648 "/usr/homes/chet/src/bash/src/parse.y"
+case 100:
+#line 671 "/usr/homes/chet/src/bash/src/parse.y"
{
if (yyvsp[-2].command->type == cm_connection)
yyval.command = connect_async_list (yyvsp[-2].command, (COMMAND *)NULL, '&');
@@ -1651,16 +1683,16 @@ case 97:
yyval.command = command_connect (yyvsp[-2].command, (COMMAND *)NULL, '&');
;
break;}
-case 99:
-#line 659 "/usr/homes/chet/src/bash/src/parse.y"
+case 102:
+#line 682 "/usr/homes/chet/src/bash/src/parse.y"
{ yyval.command = command_connect (yyvsp[-3].command, yyvsp[0].command, AND_AND); ;
break;}
-case 100:
-#line 661 "/usr/homes/chet/src/bash/src/parse.y"
+case 103:
+#line 684 "/usr/homes/chet/src/bash/src/parse.y"
{ yyval.command = command_connect (yyvsp[-3].command, yyvsp[0].command, OR_OR); ;
break;}
-case 101:
-#line 663 "/usr/homes/chet/src/bash/src/parse.y"
+case 104:
+#line 686 "/usr/homes/chet/src/bash/src/parse.y"
{
if (yyvsp[-3].command->type == cm_connection)
yyval.command = connect_async_list (yyvsp[-3].command, yyvsp[0].command, '&');
@@ -1668,28 +1700,28 @@ case 101:
yyval.command = command_connect (yyvsp[-3].command, yyvsp[0].command, '&');
;
break;}
-case 102:
-#line 670 "/usr/homes/chet/src/bash/src/parse.y"
+case 105:
+#line 693 "/usr/homes/chet/src/bash/src/parse.y"
{ yyval.command = command_connect (yyvsp[-3].command, yyvsp[0].command, ';'); ;
break;}
-case 103:
-#line 672 "/usr/homes/chet/src/bash/src/parse.y"
+case 106:
+#line 695 "/usr/homes/chet/src/bash/src/parse.y"
{ yyval.command = command_connect (yyvsp[-3].command, yyvsp[0].command, ';'); ;
break;}
-case 104:
-#line 674 "/usr/homes/chet/src/bash/src/parse.y"
+case 107:
+#line 697 "/usr/homes/chet/src/bash/src/parse.y"
{ yyval.command = yyvsp[0].command; ;
break;}
-case 110:
-#line 693 "/usr/homes/chet/src/bash/src/parse.y"
+case 113:
+#line 716 "/usr/homes/chet/src/bash/src/parse.y"
{
yyval.command = yyvsp[0].command;
if (need_here_doc)
gather_here_documents ();
;
break;}
-case 111:
-#line 699 "/usr/homes/chet/src/bash/src/parse.y"
+case 114:
+#line 722 "/usr/homes/chet/src/bash/src/parse.y"
{
if (yyvsp[-1].command->type == cm_connection)
yyval.command = connect_async_list (yyvsp[-1].command, (COMMAND *)NULL, '&');
@@ -1699,24 +1731,24 @@ case 111:
gather_here_documents ();
;
break;}
-case 112:
-#line 708 "/usr/homes/chet/src/bash/src/parse.y"
+case 115:
+#line 731 "/usr/homes/chet/src/bash/src/parse.y"
{
yyval.command = yyvsp[-1].command;
if (need_here_doc)
gather_here_documents ();
;
break;}
-case 113:
-#line 716 "/usr/homes/chet/src/bash/src/parse.y"
+case 116:
+#line 739 "/usr/homes/chet/src/bash/src/parse.y"
{ yyval.command = command_connect (yyvsp[-3].command, yyvsp[0].command, AND_AND); ;
break;}
-case 114:
-#line 718 "/usr/homes/chet/src/bash/src/parse.y"
+case 117:
+#line 741 "/usr/homes/chet/src/bash/src/parse.y"
{ yyval.command = command_connect (yyvsp[-3].command, yyvsp[0].command, OR_OR); ;
break;}
-case 115:
-#line 720 "/usr/homes/chet/src/bash/src/parse.y"
+case 118:
+#line 743 "/usr/homes/chet/src/bash/src/parse.y"
{
if (yyvsp[-2].command->type == cm_connection)
yyval.command = connect_async_list (yyvsp[-2].command, yyvsp[0].command, '&');
@@ -1724,60 +1756,60 @@ case 115:
yyval.command = command_connect (yyvsp[-2].command, yyvsp[0].command, '&');
;
break;}
-case 116:
-#line 727 "/usr/homes/chet/src/bash/src/parse.y"
+case 119:
+#line 750 "/usr/homes/chet/src/bash/src/parse.y"
{ yyval.command = command_connect (yyvsp[-2].command, yyvsp[0].command, ';'); ;
break;}
-case 117:
-#line 730 "/usr/homes/chet/src/bash/src/parse.y"
+case 120:
+#line 753 "/usr/homes/chet/src/bash/src/parse.y"
{ yyval.command = yyvsp[0].command; ;
break;}
-case 118:
-#line 734 "/usr/homes/chet/src/bash/src/parse.y"
+case 121:
+#line 757 "/usr/homes/chet/src/bash/src/parse.y"
{ yyval.command = yyvsp[0].command; ;
break;}
-case 119:
-#line 736 "/usr/homes/chet/src/bash/src/parse.y"
+case 122:
+#line 759 "/usr/homes/chet/src/bash/src/parse.y"
{
yyvsp[0].command->flags |= CMD_INVERT_RETURN;
yyval.command = yyvsp[0].command;
;
break;}
-case 120:
-#line 741 "/usr/homes/chet/src/bash/src/parse.y"
+case 123:
+#line 764 "/usr/homes/chet/src/bash/src/parse.y"
{
yyvsp[0].command->flags |= yyvsp[-1].number;
yyval.command = yyvsp[0].command;
;
break;}
-case 121:
-#line 746 "/usr/homes/chet/src/bash/src/parse.y"
+case 124:
+#line 769 "/usr/homes/chet/src/bash/src/parse.y"
{
- yyvsp[0].command->flags |= yyvsp[-2].number;
+ yyvsp[0].command->flags |= yyvsp[-2].number|CMD_INVERT_RETURN;
yyval.command = yyvsp[0].command;
;
break;}
-case 122:
-#line 751 "/usr/homes/chet/src/bash/src/parse.y"
+case 125:
+#line 774 "/usr/homes/chet/src/bash/src/parse.y"
{
yyvsp[0].command->flags |= yyvsp[-1].number|CMD_INVERT_RETURN;
yyval.command = yyvsp[0].command;
;
break;}
-case 123:
-#line 759 "/usr/homes/chet/src/bash/src/parse.y"
+case 126:
+#line 782 "/usr/homes/chet/src/bash/src/parse.y"
{ yyval.command = command_connect (yyvsp[-3].command, yyvsp[0].command, '|'); ;
break;}
-case 124:
-#line 761 "/usr/homes/chet/src/bash/src/parse.y"
+case 127:
+#line 784 "/usr/homes/chet/src/bash/src/parse.y"
{ yyval.command = yyvsp[0].command; ;
break;}
-case 125:
-#line 765 "/usr/homes/chet/src/bash/src/parse.y"
+case 128:
+#line 788 "/usr/homes/chet/src/bash/src/parse.y"
{ yyval.number = CMD_TIME_PIPELINE; ;
break;}
-case 126:
-#line 767 "/usr/homes/chet/src/bash/src/parse.y"
+case 129:
+#line 790 "/usr/homes/chet/src/bash/src/parse.y"
{ yyval.number = CMD_TIME_PIPELINE|CMD_TIME_POSIX; ;
break;}
}
@@ -1978,7 +2010,7 @@ yyerrhandle:
yystate = yyn;
goto yynewstate;
}
-#line 769 "/usr/homes/chet/src/bash/src/parse.y"
+#line 792 "/usr/homes/chet/src/bash/src/parse.y"
/* Possible states for the parser that require it to do special things. */
@@ -1992,6 +2024,7 @@ yyerrhandle:
#define PST_CASESTMT 0x080 /* parsing a case statement */
#define PST_CONDCMD 0x100 /* parsing a [[...]] command */
#define PST_CONDEXPR 0x200 /* parsing the guts of [[...]] */
+#define PST_ARITHFOR 0x400 /* parsing an arithmetic for command */
/* Initial size to allocate for tokens, and the
amount to grow them by. */
@@ -2281,20 +2314,21 @@ with_input_from_string (string, name)
/* */
/* **************************************************************** */
+/* These two functions used to test the value of the HAVE_RESTARTABLE_SYSCALLS
+ define, and just use getc/ungetc if it was defined, but since bash
+ installs its signal handlers without the SA_RESTART flag, some signals
+ (like SIGCHLD, SIGWINCH, etc.) received during a read(2) will not cause
+ the read to be restarted. We need to restart it ourselves. */
+
static int
yy_stream_get ()
{
- int result = EOF;
+ int result;
+ result = EOF;
if (bash_input.location.file)
- {
-#if !defined (HAVE_RESTARTABLE_SYSCALLS)
- result = getc_with_restart (bash_input.location.file);
-#else /* HAVE_RESTARTABLE_SYSCALLS */
- result = getc (bash_input.location.file);
- result = (feof (bash_input.location.file)) ? EOF : (unsigned char)result;
-#endif /* HAVE_RESTARTABLE_SYSCALLS */
- }
+ result = getc_with_restart (bash_input.location.file);
+
return (result);
}
@@ -2302,11 +2336,7 @@ static int
yy_stream_unget (c)
int c;
{
-#if !defined (HAVE_RESTARTABLE_SYSCALLS)
return (ungetc_with_restart (c, bash_input.location.file));
-#else /* HAVE_RESTARTABLE_SYSCALLS */
- return (ungetc (c, bash_input.location.file));
-#endif /* HAVE_RESTARTABLE_SYSCALLS */
}
void
@@ -2422,6 +2452,30 @@ stream_on_stack (type)
return 0;
}
+/* Save the current token state and return it in a malloced array. */
+int *
+save_token_state ()
+{
+ int *ret;
+
+ ret = (int *)xmalloc (3 * sizeof (int));
+ ret[0] = last_read_token;
+ ret[1] = token_before_that;
+ ret[2] = two_tokens_ago;
+ return ret;
+}
+
+void
+restore_token_state (ts)
+ int *ts;
+{
+ if (ts == 0)
+ return;
+ last_read_token = ts[0];
+ token_before_that = ts[1];
+ two_tokens_ago = ts[2];
+}
+
/*
* This is used to inhibit alias expansion and reserved word recognition
* inside case statement pattern lists. A `case statement pattern list' is:
@@ -3417,8 +3471,36 @@ read_token (command)
case '|':
return (OR_OR);
-#if defined (DPAREN_ARITHMETIC)
+#if defined (DPAREN_ARITHMETIC) || defined (ARITH_FOR_COMMAND)
case '(': /* ) */
+# if defined (ARITH_FOR_COMMAND)
+ if (last_read_token == FOR)
+ {
+ int cmdtyp, len;
+ char *wval, *wv2;
+ WORD_DESC *wd;
+
+ arith_for_lineno = line_number;
+ cmdtyp = parse_arith_cmd (&wval);
+ if (cmdtyp == 1)
+ {
+ /* parse_arith_cmd adds quotes at the beginning and end
+ of the string it returns; we need to take those out. */
+ len = strlen (wval);
+ wv2 = xmalloc (len);
+ strncpy (wv2, wval + 1, len - 2);
+ wv2[len - 2] = '\0';
+ wd = make_word (wv2);
+ yylval.word_list = make_word_list (wd, (WORD_LIST *)NULL);
+ free (wval);
+ free (wv2);
+ return (ARITH_FOR_EXPRS);
+ }
+ else
+ return -1; /* ERROR */
+ }
+# endif
+# if defined (DPAREN_ARITHMETIC)
if (reserved_word_acceptable (last_read_token))
{
int cmdtyp, sline;
@@ -3446,6 +3528,7 @@ read_token (command)
return -1;
}
break;
+# endif
#endif
}
}
@@ -3515,6 +3598,7 @@ read_token (command)
correct error values if it reads EOF. */
#define P_FIRSTCLOSE 0x01
+#define P_ALLOWESC 0x02
static char matched_pair_error;
static char *
@@ -3537,7 +3621,7 @@ parse_matched_pair (qc, open, close, lenp, flags)
start_lineno = line_number;
while (count)
{
- ch = shell_getc (qc != '\'' && pass_next_character == 0);
+ ch = shell_getc ((qc != '\'' || (flags & P_ALLOWESC)) && pass_next_character == 0);
if (ch == EOF)
{
free (ret);
@@ -3575,6 +3659,11 @@ parse_matched_pair (qc, open, close, lenp, flags)
}
else if (ch == close) /* ending delimiter */
count--;
+#if 1
+ /* handle nested ${...} specially. */
+ else if (open != close && was_dollar && open == '{' && ch == open) /* } */
+ count++;
+#endif
else if (((flags & P_FIRSTCLOSE) == 0) && ch == open) /* nested begin */
count++;
@@ -3583,7 +3672,11 @@ parse_matched_pair (qc, open, close, lenp, flags)
ret[retind++] = ch;
if (open == '\'') /* '' inside grouping construct */
- continue;
+ {
+ if ((flags & P_ALLOWESC) && ch == '\\')
+ pass_next_character++;
+ continue;
+ }
if (ch == '\\') /* backslashes */
pass_next_character++;
@@ -3662,7 +3755,7 @@ parse_matched_pair (qc, open, close, lenp, flags)
return ret;
}
-#if defined (DPAREN_ARITHMETIC)
+#if defined (DPAREN_ARITHMETIC) || defined (ARITH_FOR_COMMAND)
/* We've seen a `(('. Look for the matching `))'. If we get it, return 1.
If not, assume it's a nested subshell for backwards compatibility and
return 0. In any case, put the characters we've consumed into a locally-
@@ -3686,7 +3779,7 @@ parse_arith_cmd (ep)
if ((c = shell_getc (0)) != ')')
rval = 0;
- token = xmalloc(ttoklen + 4);
+ token = xmalloc (ttoklen + 4);
/* (( ... )) -> "..." */
token[0] = (rval == 1) ? '"' : '(';
@@ -3706,7 +3799,7 @@ parse_arith_cmd (ep)
FREE (ttok);
return rval;
}
-#endif /* DPAREN_ARITHMETIC */
+#endif /* DPAREN_ARITHMETIC || ARITH_FOR_COMMAND */
#if defined (COND_COMMAND)
static COND_COM *cond_term ();
@@ -3817,7 +3910,7 @@ cond_term ()
(void)cond_skip_newlines ();
}
- else /* left argument to binary operator */
+ else if (tok == WORD) /* left argument to binary operator */
{
/* lhs */
tleft = make_cond_node (COND_TERM, yylval.word, (COND_COM *)NULL, (COND_COM *)NULL);
@@ -3862,6 +3955,14 @@ cond_term ()
(void)cond_skip_newlines ();
}
+ else
+ {
+ if (tok < 256)
+ parser_error (line_number, "unexpected token `%c' in conditional command", tok);
+ else
+ parser_error (line_number, "unexpected token %d in conditional command", tok);
+ COND_RETURN_ERROR ();
+ }
return (term);
}
@@ -4022,7 +4123,7 @@ read_token_word (character)
the command-oriented-history code. This way newlines
appearing in the $(...) string get added to the
history literally rather than causing a possibly-
- incorrect `;' to be added. */
+ incorrect `;' to be added. ) */
push_delimiter (dstack, peek_char);
ttok = parse_matched_pair (cd, '(', ')', &ttoklen, 0);
pop_delimiter (dstack);
@@ -4049,21 +4150,46 @@ read_token_word (character)
int first_line;
first_line = line_number;
- ttok = parse_matched_pair (peek_char, peek_char, peek_char, &ttoklen, 0);
+ push_delimiter (dstack, peek_char);
+ ttok = parse_matched_pair (peek_char, peek_char, peek_char,
+ &ttoklen,
+ (peek_char == '\'') ? P_ALLOWESC : 0);
+ pop_delimiter (dstack);
if (ttok == &matched_pair_error)
return -1;
if (peek_char == '\'')
- ttrans = ansiexpand (ttok, 0, ttoklen - 1, &ttranslen);
+ {
+ ttrans = ansiexpand (ttok, 0, ttoklen - 1, &ttranslen);
+ free (ttok);
+ /* Insert the single quotes and correctly quote any
+ embedded single quotes (allowed because P_ALLOWESC was
+ passed to parse_matched_pair). */
+ ttok = single_quote (ttrans);
+ free (ttrans);
+ ttrans = ttok;
+ ttranslen = strlen (ttrans);
+ }
else
- ttrans = localeexpand (ttok, 0, ttoklen - 1, first_line, &ttranslen);
- free (ttok);
+ {
+ /* Try to locale-expand the converted string. */
+ ttrans = localeexpand (ttok, 0, ttoklen - 1, first_line, &ttranslen);
+ free (ttok);
+
+ /* Add the double quotes back */
+ ttok = xmalloc (ttranslen + 3);
+ ttok[0] = '"';
+ strcpy (ttok + 1, ttrans);
+ ttok[ttranslen + 1] = '"';
+ ttok[ttranslen += 2] = '\0';
+ free (ttrans);
+ ttrans = ttok;
+ }
+
RESIZE_MALLOCED_BUFFER (token, token_index, ttranslen + 2,
token_buffer_size,
TOKEN_DEFAULT_GROW_SIZE);
- token[token_index++] = peek_char;
strcpy (token + token_index, ttrans);
token_index += ttranslen;
- token[token_index++] = peek_char;
FREE (ttrans);
quoted = 1;
all_digits = 0;
@@ -4249,7 +4375,7 @@ ansiexpand (string, start, end, lenp)
if (*temp)
{
- t = ansicstr (temp, tlen, (int *)NULL, lenp);
+ t = ansicstr (temp, tlen, 0, (int *)NULL, lenp);
free (temp);
return (t);
}
@@ -4261,6 +4387,52 @@ ansiexpand (string, start, end, lenp)
}
}
+/* Change a bash string into a string suitable for inclusion in a `po' file.
+ This backslash-escapes `"' and `\' and changes newlines into \\\n"\n". */
+static char *
+mk_msgstr (string, foundnlp)
+ char *string;
+ int *foundnlp;
+{
+ register int c, len;
+ char *result, *r, *s;
+
+ for (len = 0, s = string; s && *s; s++)
+ {
+ len++;
+ if (*s == '"' || *s == '\\')
+ len++;
+ else if (*s == '\n')
+ len += 5;
+ }
+
+ r = result = xmalloc (len + 3);
+ *r++ = '"';
+
+ for (s = string; s && (c = *s); s++)
+ {
+ if (c == '\n') /* <NL> -> \n"<NL>" */
+ {
+ *r++ = '\\';
+ *r++ = 'n';
+ *r++ = '"';
+ *r++ = '\n';
+ *r++ = '"';
+ if (foundnlp)
+ *foundnlp = 1;
+ continue;
+ }
+ if (c == '"' || c == '\\')
+ *r++ = '\\';
+ *r++ = c;
+ }
+
+ *r++ = '"';
+ *r++ = '\0';
+
+ return result;
+}
+
/* $"..." -- Translate the portion of STRING between START and END
according to current locale using gettext (if available) and return
the result. The caller will take care of leaving the quotes intact.
@@ -4273,22 +4445,35 @@ localeexpand (string, start, end, lineno, lenp)
char *string;
int start, end, lineno, *lenp;
{
- int len, tlen;
- char *temp, *t;
+ int len, tlen, foundnl;
+ char *temp, *t, *t2;
temp = xmalloc (end - start + 1);
for (tlen = 0, len = start; len < end; )
temp[tlen++] = string[len++];
temp[tlen] = '\0';
- /* If we're just dumping translatable strings, don't do anything. */
+ /* If we're just dumping translatable strings, don't do anything with the
+ string itself, but if we're dumping in `po' file format, convert it into a form more palatable to gettext(3)
+ and friends by quoting `"' and `\' with backslashes and converting <NL>
+ into `\n"<NL>"'. If we find a newline in TEMP, we first output a
+ `msgid ""' line and then the translated string; otherwise we output the
+ `msgid' and translated string all on one line. */
if (dump_translatable_strings)
{
if (dump_po_strings)
- printf ("#: %s:%d\nmsgid \"%s\"\nmsgstr \"\"\n",
- (bash_input.name ? bash_input.name : "stdin"), lineno, temp);
+ {
+ foundnl = 0;
+ t = mk_msgstr (temp, &foundnl);
+ t2 = foundnl ? "\"\"\n" : "";
+
+ printf ("#: %s:%d\nmsgid %s%s\nmsgstr \"\"\n",
+ (bash_input.name ? bash_input.name : "stdin"), lineno, t2, t);
+ free (t);
+ }
else
printf ("\"%s\"\n", temp);
+
if (lenp)
*lenp = tlen;
return (temp);
@@ -4424,6 +4609,17 @@ history_delimiting_chars ()
else if (token_before_that == WORD && two_tokens_ago == FUNCTION)
return " "; /* function def using `function name' without `()' */
+ else if (token_before_that == WORD && two_tokens_ago == FOR)
+ {
+ /* Tricky. `for i\nin ...' should not have a semicolon, but
+ `for i\ndo ...' should. We do what we can. */
+ for (i = shell_input_line_index; whitespace(shell_input_line[i]); i++)
+ ;
+ if (shell_input_line[i] && shell_input_line[i] == 'i' && shell_input_line[i+1] == 'n')
+ return " ";
+ return ";";
+ }
+
for (i = 0; no_semi_successors[i]; i++)
{
if (token_before_that == no_semi_successors[i])
@@ -4477,6 +4673,20 @@ prompt_again ()
}
}
+int
+get_current_prompt_level ()
+{
+ return ((current_prompt_string && current_prompt_string == ps2_prompt) ? 2 : 1);
+}
+
+void
+set_current_prompt_level (x)
+ int x;
+{
+ prompt_string_pointer = (x == 2) ? &ps2_prompt : &ps1_prompt;
+ current_prompt_string = *prompt_string_pointer;
+}
+
static void
print_prompt ()
{
@@ -4492,6 +4702,8 @@ print_prompt ()
\d the date in Day Mon Date format
\h the hostname up to the first `.'
\H the hostname
+ \j the number of active jobs
+ \l the basename of the shell's tty device name
\n CRLF
\s the name of the shell
\t the time in 24-hour hh:mm:ss format
@@ -4692,7 +4904,14 @@ decode_prompt_string (string)
/* If we're going to be expanding the prompt string later,
quote the directory name. */
if (promptvars || posixly_correct)
+#if 0
temp = backslash_quote (t_string);
+#else
+ /* Make sure that expand_prompt_string is called with a
+ second argument of Q_DOUBLE_QUOTE if we use this
+ function here. */
+ temp = backslash_quote_for_double_quotes (t_string);
+#endif
else
temp = savestring (t_string);
@@ -4700,6 +4919,8 @@ decode_prompt_string (string)
}
case 'u':
+ if (current_user.user_name == 0)
+ get_current_user_info ();
temp = savestring (current_user.user_name);
goto add_string;
@@ -4730,6 +4951,20 @@ decode_prompt_string (string)
*t = '\0';
goto add_string;
+ case 'j':
+ temp = itos (count_all_jobs ());
+ goto add_string;
+
+ case 'l':
+#if defined (HAVE_TTYNAME)
+ temp = (char *)ttyname (fileno (stdin));
+ t = temp ? base_pathname (temp) : "tty";
+ temp = savestring (t);
+#else
+ temp = savestring ("tty");
+#endif /* !HAVE_TTYNAME */
+ goto add_string;
+
#if defined (READLINE)
case '[':
case ']':
@@ -4791,7 +5026,11 @@ decode_prompt_string (string)
the prompt string. */
if (promptvars || posixly_correct)
{
+#if 0
list = expand_string_unsplit (result, Q_DOUBLE_QUOTES);
+#else
+ list = expand_prompt_string (result, Q_DOUBLE_QUOTES);
+#endif
free (result);
result = string_list (list);
dispose_words (list);
@@ -4866,11 +5105,7 @@ report_syntax_error (message)
if (token_end || (i == 0 && token_end == 0))
{
if (token_end)
- {
- msg = xmalloc (1 + (token_end - i));
- strncpy (msg, t + i, token_end - i);
- msg[token_end - i] = '\0';
- }
+ msg = substring (t, i, token_end);
else /* one-character token */
{
msg2[0] = t[i];
@@ -4974,3 +5209,73 @@ handle_eof_input_unit ()
EOF_Reached = 1;
}
}
+
+static WORD_LIST parse_string_error;
+
+/* Take a string and run it through the shell parser, returning the
+ resultant word list. Used by compound array assignment. */
+WORD_LIST *
+parse_string_to_word_list (s, whom)
+ char *s, *whom;
+{
+ WORD_LIST *wl;
+ int tok, orig_line_number, orig_input_terminator;
+#if defined (HISTORY)
+ int old_remember_on_history, old_history_expansion_inhibited;
+#endif
+
+#if defined (HISTORY)
+ old_remember_on_history = remember_on_history;
+# if defined (BANG_HISTORY)
+ old_history_expansion_inhibited = history_expansion_inhibited;
+# endif
+ bash_history_disable ();
+#endif
+
+ orig_line_number = line_number;
+ orig_input_terminator = shell_input_line_terminator;
+
+ push_stream (1);
+ last_read_token = '\n';
+
+ with_input_from_string (s, whom);
+ wl = (WORD_LIST *)NULL;
+ while ((tok = read_token (READ)) != yacc_EOF)
+ {
+ if (tok == '\n' && *bash_input.location.string == '\0')
+ break;
+ if (tok != WORD && tok != ASSIGNMENT_WORD)
+ {
+ line_number = orig_line_number + line_number - 1;
+ yyerror (); /* does the right thing */
+ if (wl)
+ dispose_words (wl);
+ wl = &parse_string_error;
+ break;
+ }
+ wl = make_word_list (yylval.word, wl);
+ }
+
+ last_read_token = '\n';
+ pop_stream ();
+
+#if defined (HISTORY)
+ remember_on_history = old_remember_on_history;
+# if defined (BANG_HISTORY)
+ history_expansion_inhibited = old_history_expansion_inhibited;
+# endif /* BANG_HISTORY */
+#endif /* HISTORY */
+
+ shell_input_line_terminator = orig_input_terminator;
+
+ if (wl == &parse_string_error)
+ {
+ last_command_exit_value = EXECUTION_FAILURE;
+ if (interactive_shell == 0 && posixly_correct)
+ jump_to_top_level (FORCE_EOF);
+ else
+ jump_to_top_level (DISCARD);
+ }
+
+ return (REVERSE_LIST (wl, WORD_LIST *));
+}
diff --git a/y.tab.h b/y.tab.h
index affe1206..03e9ce0f 100644
--- a/y.tab.h
+++ b/y.tab.h
@@ -32,19 +32,20 @@ typedef union {
#define ASSIGNMENT_WORD 280
#define NUMBER 281
#define ARITH_CMD 282
-#define COND_CMD 283
-#define AND_AND 284
-#define OR_OR 285
-#define GREATER_GREATER 286
-#define LESS_LESS 287
-#define LESS_AND 288
-#define GREATER_AND 289
-#define SEMI_SEMI 290
-#define LESS_LESS_MINUS 291
-#define AND_GREATER 292
-#define LESS_GREATER 293
-#define GREATER_BAR 294
-#define yacc_EOF 295
+#define ARITH_FOR_EXPRS 283
+#define COND_CMD 284
+#define AND_AND 285
+#define OR_OR 286
+#define GREATER_GREATER 287
+#define LESS_LESS 288
+#define LESS_AND 289
+#define GREATER_AND 290
+#define SEMI_SEMI 291
+#define LESS_LESS_MINUS 292
+#define AND_GREATER 293
+#define LESS_GREATER 294
+#define GREATER_BAR 295
+#define yacc_EOF 296
extern YYSTYPE yylval;